From 47849a9e58d5f6d06bb92e00b3de567da1a356dd Mon Sep 17 00:00:00 2001 From: sommersoft Date: Mon, 29 Jun 2020 18:18:25 -0500 Subject: [PATCH 001/207] add custom css for 'viewing-old-docs' message --- docs/static/customstyle.css | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/docs/static/customstyle.css b/docs/static/customstyle.css index 6c964b762c..1136edcd31 100644 --- a/docs/static/customstyle.css +++ b/docs/static/customstyle.css @@ -10,6 +10,19 @@ } +/* custom CSS to sticky the ' viewing outdated version' + warning +*/ +.document > .admonition { + position: sticky; + top: 0px; + background-color: salmon; + z-index: 2; +} + +body { + overflow-x: unset!important; +} /* override table width restrictions */ @media screen and (min-width: 767px) { From b637d3911e71c6136f761960f293954366dd76a1 Mon Sep 17 00:00:00 2001 From: gamblor21 Date: Sat, 24 Oct 2020 20:48:35 -0500 Subject: [PATCH 002/207] Initial commit --- py/circuitpy_defns.mk | 5 + py/circuitpy_mpconfig.h | 8 + py/circuitpy_mpconfig.mk | 3 + shared-bindings/busdevice/I2CDevice.c | 246 ++++++++++++++++++++++++++ shared-bindings/busdevice/I2CDevice.h | 58 ++++++ shared-bindings/busdevice/__init__.c | 79 +++++++++ shared-bindings/busdevice/__init__.h | 32 ++++ shared-module/busdevice/I2CDevice.c | 101 +++++++++++ shared-module/busdevice/I2CDevice.h | 40 +++++ shared-module/busdevice/__init__.c | 0 10 files changed, 572 insertions(+) create mode 100644 shared-bindings/busdevice/I2CDevice.c create mode 100644 shared-bindings/busdevice/I2CDevice.h create mode 100644 shared-bindings/busdevice/__init__.c create mode 100644 shared-bindings/busdevice/__init__.h create mode 100644 shared-module/busdevice/I2CDevice.c create mode 100644 shared-module/busdevice/I2CDevice.h create mode 100644 shared-module/busdevice/__init__.c diff --git a/py/circuitpy_defns.mk b/py/circuitpy_defns.mk index ccdf973e9f..9318bd466b 100644 --- a/py/circuitpy_defns.mk +++ b/py/circuitpy_defns.mk @@ -133,6 +133,9 @@ endif ifeq ($(CIRCUITPY_BOARD),1) SRC_PATTERNS += board/% endif +ifeq ($(CIRCUITPY_BUSDEVICE),1) +SRC_PATTERNS += busdevice/% +endif ifeq ($(CIRCUITPY_BUSIO),1) SRC_PATTERNS += busio/% bitbangio/OneWire.% endif @@ -432,6 +435,8 @@ SRC_SHARED_MODULE_ALL = \ bitbangio/SPI.c \ bitbangio/__init__.c \ board/__init__.c \ + busdevice/__init__.c \ + busdevice/I2CDevice.c \ busio/OneWire.c \ displayio/Bitmap.c \ displayio/ColorConverter.c \ diff --git a/py/circuitpy_mpconfig.h b/py/circuitpy_mpconfig.h index 1e01bd9c5e..240fac189b 100644 --- a/py/circuitpy_mpconfig.h +++ b/py/circuitpy_mpconfig.h @@ -324,6 +324,13 @@ extern const struct _mp_obj_module_t board_module; #define BOARD_UART_ROOT_POINTER #endif +#if CIRCUITPY_BUSDEVICE +extern const struct _mp_obj_module_t busdevice_module; +#define BUSDEVICE_MODULE { MP_OBJ_NEW_QSTR(MP_QSTR_busdevice), (mp_obj_t)&busdevice_module }, +#else +#define BUSDEVICE_MODULE +#endif + #if CIRCUITPY_BUSIO extern const struct _mp_obj_module_t busio_module; #define BUSIO_MODULE { MP_OBJ_NEW_QSTR(MP_QSTR_busio), (mp_obj_t)&busio_module }, @@ -773,6 +780,7 @@ extern const struct _mp_obj_module_t wifi_module; BITBANGIO_MODULE \ BLEIO_MODULE \ BOARD_MODULE \ + BUSDEVICE_MODULE \ BUSIO_MODULE \ CAMERA_MODULE \ CANIO_MODULE \ diff --git a/py/circuitpy_mpconfig.mk b/py/circuitpy_mpconfig.mk index a6aabec33d..1f96a8f2dd 100644 --- a/py/circuitpy_mpconfig.mk +++ b/py/circuitpy_mpconfig.mk @@ -90,6 +90,9 @@ CFLAGS += -DCIRCUITPY_BLEIO=$(CIRCUITPY_BLEIO) CIRCUITPY_BOARD ?= 1 CFLAGS += -DCIRCUITPY_BOARD=$(CIRCUITPY_BOARD) +CIRCUITPY_BUSDEVICE ?= 1 +CFLAGS += -DCIRCUITPY_BUSDEVICE=$(CIRCUITPY_BUSDEVICE) + CIRCUITPY_BUSIO ?= 1 CFLAGS += -DCIRCUITPY_BUSIO=$(CIRCUITPY_BUSIO) diff --git a/shared-bindings/busdevice/I2CDevice.c b/shared-bindings/busdevice/I2CDevice.c new file mode 100644 index 0000000000..02dac6a95b --- /dev/null +++ b/shared-bindings/busdevice/I2CDevice.c @@ -0,0 +1,246 @@ +/* + * 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. + */ + +// This file contains all of the Python API definitions for the +// busio.I2C class. + +#include "shared-bindings/microcontroller/Pin.h" +#include "shared-bindings/busdevice/I2CDevice.h" +#include "shared-bindings/util.h" +#include "shared-module/busdevice/I2CDevice.h" + +#include "lib/utils/buffer_helper.h" +#include "lib/utils/context_manager_helpers.h" +#include "py/runtime.h" +#include "supervisor/shared/translate.h" + +//| class I2CDevice: +//| """Two wire serial protocol""" +//| +//| def __init__(self, i2c, device_address, probe=True) -> None: +//| +//| ... +//| +STATIC mp_obj_t busdevice_i2cdevice_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { + busdevice_i2cdevice_obj_t *self = m_new_obj(busdevice_i2cdevice_obj_t); + self->base.type = &busdevice_i2cdevice_type; + enum { ARG_i2c, ARG_device_address, ARG_probe }; + static const mp_arg_t allowed_args[] = { + { MP_QSTR_i2c, MP_ARG_REQUIRED | MP_ARG_OBJ }, + { MP_QSTR_device_address, MP_ARG_REQUIRED | MP_ARG_INT }, + { MP_QSTR_probe, MP_ARG_BOOL, {.u_bool = true} }, + }; + 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); + + busio_i2c_obj_t* i2c = args[ARG_i2c].u_obj; + + common_hal_busdevice_i2cdevice_construct(self, i2c, args[ARG_device_address].u_int, args[ARG_probe].u_bool); + return (mp_obj_t)self; +} + +//| def __enter__(self) -> None: +//| """Automatically initializes the hardware on context exit. See FIX +//| :ref:`lifetime-and-contextmanagers` for more info.""" +//| ... +//| +STATIC mp_obj_t busdevice_i2cdevice_obj___enter__(mp_obj_t self_in) { + common_hal_busdevice_i2cdevice_lock(self_in); + return self_in; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_1(busdevice_i2cdevice___enter___obj, busdevice_i2cdevice_obj___enter__); + +//| def __exit__(self) -> None: +//| """Automatically deinitializes the hardware on context exit. See +//| :ref:`lifetime-and-contextmanagers` for more info.""" +//| ... +//| +STATIC mp_obj_t busdevice_i2cdevice_obj___exit__(size_t n_args, const mp_obj_t *args) { + common_hal_busdevice_i2cdevice_unlock(args[0]); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(busdevice_i2cdevice___exit___obj, 4, 4, busdevice_i2cdevice_obj___exit__); + +STATIC void readinto(busdevice_i2cdevice_obj_t *self, mp_obj_t buffer, int32_t start, mp_int_t end) { + mp_buffer_info_t bufinfo; + mp_get_buffer_raise(buffer, &bufinfo, MP_BUFFER_WRITE); + + size_t length = bufinfo.len; + normalize_buffer_bounds(&start, end, &length); + if (length == 0) { + mp_raise_ValueError(translate("Buffer must be at least length 1")); + } + + uint8_t status = common_hal_busdevice_i2cdevice_readinto(self, ((uint8_t*)bufinfo.buf) + start, length); + if (status != 0) { + mp_raise_OSError(status); + } +} + +STATIC mp_obj_t busdevice_i2cdevice_readinto(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { + enum { ARG_buffer, ARG_start, ARG_end }; + static const mp_arg_t allowed_args[] = { + { MP_QSTR_buffer, MP_ARG_REQUIRED | MP_ARG_OBJ, {.u_obj = MP_OBJ_NULL} }, + { MP_QSTR_start, MP_ARG_KW_ONLY | MP_ARG_INT, {.u_int = 0} }, + { MP_QSTR_end, MP_ARG_KW_ONLY | MP_ARG_INT, {.u_int = INT_MAX} }, + }; + + busdevice_i2cdevice_obj_t *self = MP_OBJ_TO_PTR(pos_args[0]); + + 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); + + readinto(self, args[ARG_buffer].u_obj, args[ARG_start].u_int, args[ARG_end].u_int); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_KW(busdevice_i2cdevice_readinto_obj, 2, busdevice_i2cdevice_readinto); + + +STATIC void write(busdevice_i2cdevice_obj_t *self, mp_obj_t buffer, int32_t start, mp_int_t end) { + mp_buffer_info_t bufinfo; + mp_get_buffer_raise(buffer, &bufinfo, MP_BUFFER_READ); + + size_t length = bufinfo.len; + normalize_buffer_bounds(&start, end, &length); + if (length == 0) { + mp_raise_ValueError(translate("Buffer must be at least length 1")); + } + + uint8_t status = common_hal_busdevice_i2cdevice_write(self, ((uint8_t*)bufinfo.buf) + start, length); + if (status != 0) { + mp_raise_OSError(status); + } +} + +STATIC mp_obj_t busdevice_i2cdevice_write(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { + enum { ARG_buffer, ARG_start, ARG_end }; + static const mp_arg_t allowed_args[] = { + { MP_QSTR_buffer, MP_ARG_REQUIRED | MP_ARG_OBJ, {.u_obj = MP_OBJ_NULL} }, + { MP_QSTR_start, MP_ARG_KW_ONLY | MP_ARG_INT, {.u_int = 0} }, + { MP_QSTR_end, MP_ARG_KW_ONLY | MP_ARG_INT, {.u_int = INT_MAX} }, + }; + busdevice_i2cdevice_obj_t *self = MP_OBJ_TO_PTR(pos_args[0]); + + 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); + + write(self, args[ARG_buffer].u_obj, args[ARG_start].u_int, args[ARG_end].u_int); + return mp_const_none; +} +MP_DEFINE_CONST_FUN_OBJ_KW(busdevice_i2cdevice_write_obj, 2, busdevice_i2cdevice_write); + + +/*STATIC void write_then_readinto(busdevice_i2cdevice_obj_t *self, mp_obj_t out_buffer, mp_obj_t in_buffer, + int32_t out_start, mp_int_t out_end, int32_t in_start, mp_int_t in_end) { + mp_buffer_info_t out_bufinfo; + mp_get_buffer_raise(out_buffer, &out_bufinfo, MP_BUFFER_READ); + + size_t out_length = out_bufinfo.len; + normalize_buffer_bounds(&out_start, out_end, &out_length); + if (out_length == 0) { + mp_raise_ValueError(translate("Buffer must be at least length 1")); + } + + mp_buffer_info_t in_bufinfo; + mp_get_buffer_raise(in_buffer, &in_bufinfo, MP_BUFFER_WRITE); + + size_t in_length = in_bufinfo.len; + normalize_buffer_bounds(&in_start, in_end, &in_length); + if (in_length == 0) { + mp_raise_ValueError(translate("Buffer must be at least length 1")); + } + + uint8_t status = common_hal_busdevice_i2cdevice_write_then_readinto(self, out_buffer, in_buffer, out_length, in_length); + if (status != 0) { + mp_raise_OSError(status); + } +}*/ + +STATIC mp_obj_t busdevice_i2cdevice_write_then_readinto(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { + enum { ARG_out_buffer, ARG_in_buffer, ARG_out_start, ARG_out_end, ARG_in_start, ARG_in_end }; + static const mp_arg_t allowed_args[] = { + { MP_QSTR_out_buffer, MP_ARG_REQUIRED | MP_ARG_OBJ, {.u_obj = MP_OBJ_NULL} }, + { MP_QSTR_in_buffer, MP_ARG_REQUIRED | MP_ARG_OBJ, {.u_obj = MP_OBJ_NULL} }, + { MP_QSTR_out_start, MP_ARG_KW_ONLY | MP_ARG_INT, {.u_int = 0} }, + { MP_QSTR_out_end, MP_ARG_KW_ONLY | MP_ARG_INT, {.u_int = INT_MAX} }, + { MP_QSTR_in_start, MP_ARG_KW_ONLY | MP_ARG_INT, {.u_int = 0} }, + { MP_QSTR_in_end, MP_ARG_KW_ONLY | MP_ARG_INT, {.u_int = INT_MAX} }, + }; + busdevice_i2cdevice_obj_t *self = MP_OBJ_TO_PTR(pos_args[0]); + + 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); + + write(self, args[ARG_out_buffer].u_obj, args[ARG_out_start].u_int, args[ARG_out_end].u_int); + + readinto(self, args[ARG_in_buffer].u_obj, args[ARG_in_start].u_int, args[ARG_in_end].u_int); + + return mp_const_none; +} +MP_DEFINE_CONST_FUN_OBJ_KW(busdevice_i2cdevice_write_then_readinto_obj, 3, busdevice_i2cdevice_write_then_readinto); + + +STATIC mp_obj_t busdevice_i2cdevice___probe_for_device(mp_obj_t self_in) { + //busdevice_i2cdevice_obj_t *self = self_in; + + //common_hal_busdevice_i2cdevice_lock(self_in); + +/* + uint8_t buffer; + mp_buffer_info_t bufinfo; + mp_get_buffer_raise(&buffer, &bufinfo, MP_BUFFER_WRITE); + + uint8_t status = common_hal_busdevice_i2cdevice_readinto(self_in, (uint8_t*)bufinfo.buf, 1); + if (status != 0) { + common_hal_busdevice_i2cdevice_unlock(self_in); + mp_raise_ValueError_varg(translate("No I2C device at address: %x"), self->device_address); + } +*/ + //common_hal_busdevice_i2cdevice_unlock(self_in); + + return mp_const_none; +} +MP_DEFINE_CONST_FUN_OBJ_1(busdevice_i2cdevice___probe_for_device_obj, busdevice_i2cdevice___probe_for_device); + + +STATIC const mp_rom_map_elem_t busdevice_i2cdevice_locals_dict_table[] = { + { MP_ROM_QSTR(MP_QSTR___enter__), MP_ROM_PTR(&busdevice_i2cdevice___enter___obj) }, + { MP_ROM_QSTR(MP_QSTR___exit__), MP_ROM_PTR(&busdevice_i2cdevice___exit___obj) }, + { MP_ROM_QSTR(MP_QSTR_readinto), MP_ROM_PTR(&busdevice_i2cdevice_readinto_obj) }, + { MP_ROM_QSTR(MP_QSTR_write), MP_ROM_PTR(&busdevice_i2cdevice_write_obj) }, + { MP_ROM_QSTR(MP_QSTR_write_then_readinto), MP_ROM_PTR(&busdevice_i2cdevice_write_then_readinto_obj) }, + { MP_ROM_QSTR(MP_QSTR___probe_for_device), MP_ROM_PTR(&busdevice_i2cdevice___probe_for_device_obj) }, +}; + + +STATIC MP_DEFINE_CONST_DICT(busdevice_i2cdevice_locals_dict, busdevice_i2cdevice_locals_dict_table); + +const mp_obj_type_t busdevice_i2cdevice_type = { + { &mp_type_type }, + .name = MP_QSTR_I2CDevice, + .make_new = busdevice_i2cdevice_make_new, + .locals_dict = (mp_obj_dict_t*)&busdevice_i2cdevice_locals_dict, +}; \ No newline at end of file diff --git a/shared-bindings/busdevice/I2CDevice.h b/shared-bindings/busdevice/I2CDevice.h new file mode 100644 index 0000000000..bc85023d79 --- /dev/null +++ b/shared-bindings/busdevice/I2CDevice.h @@ -0,0 +1,58 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2020 Mark Komus + * + * 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. + */ + +// Machine is the HAL for low-level, hardware accelerated functions. It is not +// meant to simplify APIs, its only meant to unify them so that other modules +// do not require port specific logic. +// +// This file includes externs for all functions a port should implement to +// support the machine module. + +#ifndef MICROPY_INCLUDED_SHARED_BINDINGS_BUSDEVICE_I2CDEVICE_H +#define MICROPY_INCLUDED_SHARED_BINDINGS_BUSDEVICE_I2CDEVICE_H + +#include "py/obj.h" + +#include "common-hal/microcontroller/Pin.h" +#include "shared-module/busdevice/I2CDevice.h" +#include "shared-bindings/busio/I2C.h" + +// Type object used in Python. Should be shared between ports. +extern const mp_obj_type_t busdevice_i2cdevice_type; + +// Initializes the hardware peripheral. +extern void common_hal_busdevice_i2cdevice_construct(busdevice_i2cdevice_obj_t *self, busio_i2c_obj_t *i2c, uint8_t device_address, bool probe); +extern void common_hal_busdevice_i2cdevice___enter__(busdevice_i2cdevice_obj_t *self); +extern void common_hal_busdevice_i2cdevice___exit__(busdevice_i2cdevice_obj_t *self); +extern uint8_t common_hal_busdevice_i2cdevice_readinto(busdevice_i2cdevice_obj_t *self, mp_obj_t buffer, size_t length); +extern uint8_t common_hal_busdevice_i2cdevice_write(busdevice_i2cdevice_obj_t *self, mp_obj_t buffer, size_t length); +extern uint8_t common_hal_busdevice_i2cdevice_write_then_readinto(busdevice_i2cdevice_obj_t *self, mp_obj_t out_buffer, + mp_obj_t in_buffer, size_t out_length, size_t in_length); +extern uint8_t common_hal_busdevice_i2cdevice___probe_for_device(busdevice_i2cdevice_obj_t *self); +extern void common_hal_busdevice_i2cdevice_lock(busdevice_i2cdevice_obj_t *self); +extern void common_hal_busdevice_i2cdevice_unlock(busdevice_i2cdevice_obj_t *self); + +#endif // MICROPY_INCLUDED_SHARED_BINDINGS_BUSDEVICE_I2CDEVICE_H diff --git a/shared-bindings/busdevice/__init__.c b/shared-bindings/busdevice/__init__.c new file mode 100644 index 0000000000..6b24160a02 --- /dev/null +++ b/shared-bindings/busdevice/__init__.c @@ -0,0 +1,79 @@ +/* + * 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 + +#include "py/obj.h" +#include "py/runtime.h" +#include "py/mphal.h" +#include "py/objproperty.h" + +#include "shared-bindings/busdevice/__init__.h" +#include "shared-bindings/busdevice/I2CDevice.h" + + +//| """Hardware accelerated external bus access +//| +//| The `busio` module contains classes to support a variety of serial +//| protocols. +//| +//| When the microcontroller does not support the behavior in a hardware +//| accelerated fashion it may internally use a bitbang routine. However, if +//| hardware support is available on a subset of pins but not those provided, +//| then a RuntimeError will be raised. Use the `bitbangio` module to explicitly +//| bitbang a serial protocol on any general purpose pins. +//| +//| All classes change hardware state and should be deinitialized when they +//| are no longer needed if the program continues after use. To do so, either +//| call :py:meth:`!deinit` or use a context manager. See +//| :ref:`lifetime-and-contextmanagers` for more info. +//| +//| For example:: +//| +//| import busio +//| from board import * +//| +//| i2c = busio.I2C(SCL, SDA) +//| print(i2c.scan()) +//| i2c.deinit() +//| +//| This example will initialize the the device, run +//| :py:meth:`~busio.I2C.scan` and then :py:meth:`~busio.I2C.deinit` the +//| hardware. The last step is optional because CircuitPython automatically +//| resets hardware after a program finishes.""" +//| + +STATIC const mp_rom_map_elem_t busdevice_module_globals_table[] = { + { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_busdevice) }, + { MP_ROM_QSTR(MP_QSTR_I2CDevice), MP_ROM_PTR(&busdevice_i2cdevice_type) }, +}; + +STATIC MP_DEFINE_CONST_DICT(busdevice_module_globals, busdevice_module_globals_table); + +const mp_obj_module_t busdevice_module = { + .base = { &mp_type_module }, + .globals = (mp_obj_dict_t*)&busdevice_module_globals, +}; diff --git a/shared-bindings/busdevice/__init__.h b/shared-bindings/busdevice/__init__.h new file mode 100644 index 0000000000..4a669807be --- /dev/null +++ b/shared-bindings/busdevice/__init__.h @@ -0,0 +1,32 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2020 Mark Komus + * + * 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_BUSDEVICE___INIT___H +#define MICROPY_INCLUDED_SHARED_BINDINGS_BUSDEVICE___INIT___H + +// Nothing now. + +#endif // MICROPY_INCLUDED_SHARED_BINDINGS_BUSDEVICE___INIT___H diff --git a/shared-module/busdevice/I2CDevice.c b/shared-module/busdevice/I2CDevice.c new file mode 100644 index 0000000000..30f4aad339 --- /dev/null +++ b/shared-module/busdevice/I2CDevice.c @@ -0,0 +1,101 @@ +/* + * 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 "shared-bindings/busdevice/I2CDevice.h" +#include "shared-bindings/busio/I2C.h" +#include "py/mperrno.h" +#include "py/nlr.h" + +void common_hal_busdevice_i2cdevice_construct(busdevice_i2cdevice_obj_t *self, busio_i2c_obj_t *i2c, uint8_t device_address, bool probe) { + self->i2c = i2c; + self->device_address = device_address; + self->probe = probe; + + if (self->probe == true) { + common_hal_busdevice_i2cdevice___probe_for_device(self); + } +} + +void common_hal_busdevice_i2cdevice_lock(busdevice_i2cdevice_obj_t *self) { + bool success = false; + while (!success) { + success = common_hal_busio_i2c_try_lock(self->i2c); + } +} + +void common_hal_busdevice_i2cdevice_unlock(busdevice_i2cdevice_obj_t *self) { + common_hal_busio_i2c_unlock(self->i2c); +} + +uint8_t common_hal_busdevice_i2cdevice_readinto(busdevice_i2cdevice_obj_t *self, mp_obj_t buffer, size_t length) { + uint8_t status = common_hal_busio_i2c_read(self->i2c, self->device_address, buffer, length); + + return status; +} + +uint8_t common_hal_busdevice_i2cdevice_write(busdevice_i2cdevice_obj_t *self, mp_obj_t buffer, size_t length) { + uint8_t status = common_hal_busio_i2c_write(self->i2c, self->device_address, buffer, length, true); + + return status; +} + +uint8_t common_hal_busdevice_i2cdevice_write_then_readinto(busdevice_i2cdevice_obj_t *self, mp_obj_t out_buffer, mp_obj_t in_buffer, + size_t out_length, size_t in_length) { + uint8_t status = 0; + + status = common_hal_busio_i2c_write(self->i2c, self->device_address, out_buffer, out_length, true); + + status = common_hal_busio_i2c_read(self->i2c, self->device_address, in_buffer, in_length); + + return status; +} + +uint8_t common_hal_busdevice_i2cdevice___probe_for_device(busdevice_i2cdevice_obj_t *self) { + + + + + // write "" + + +/* + while not self.i2c.try_lock(): + pass + try: + self.i2c.writeto(self.device_address, b"") + except OSError: + # some OS's dont like writing an empty bytesting... + # Retry by reading a byte + try: + result = bytearray(1) + self.i2c.readfrom_into(self.device_address, result) + except OSError: + raise ValueError("No I2C device at address: %x" % self.device_address) + finally: + self.i2c.unlock() +*/ + return 0; +} diff --git a/shared-module/busdevice/I2CDevice.h b/shared-module/busdevice/I2CDevice.h new file mode 100644 index 0000000000..c872704db6 --- /dev/null +++ b/shared-module/busdevice/I2CDevice.h @@ -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. + */ + +#ifndef MICROPY_INCLUDED_ATMEL_SAMD_SHARED_MODULE_BUSDEVICE_I2CDEVICE_H +#define MICROPY_INCLUDED_ATMEL_SAMD_SHARED_MODULE_BUSDEVICE_I2CDEVICE_H + +#include "py/obj.h" +#include "common-hal/busio/I2C.h" + +typedef struct { + mp_obj_base_t base; + busio_i2c_obj_t *i2c; + uint8_t device_address; + bool probe; +} busdevice_i2cdevice_obj_t; + +#endif // MICROPY_INCLUDED_ATMEL_SAMD_SHARED_MODULE_BUSDEVICE_I2CDEVICE_H diff --git a/shared-module/busdevice/__init__.c b/shared-module/busdevice/__init__.c new file mode 100644 index 0000000000..e69de29bb2 From 12d770b427e77c207b85aa9ddcda0047fa6d040a Mon Sep 17 00:00:00 2001 From: gamblor21 Date: Sun, 25 Oct 2020 10:15:45 -0500 Subject: [PATCH 003/207] Added __probe_for_device --- shared-bindings/busdevice/I2CDevice.c | 24 ++++++++++------ shared-bindings/busdevice/I2CDevice.h | 4 +-- shared-module/busdevice/I2CDevice.c | 41 +++++++++------------------ 3 files changed, 31 insertions(+), 38 deletions(-) diff --git a/shared-bindings/busdevice/I2CDevice.c b/shared-bindings/busdevice/I2CDevice.c index 02dac6a95b..fa5cb02e0b 100644 --- a/shared-bindings/busdevice/I2CDevice.c +++ b/shared-bindings/busdevice/I2CDevice.c @@ -37,6 +37,7 @@ #include "py/runtime.h" #include "supervisor/shared/translate.h" + //| class I2CDevice: //| """Two wire serial protocol""" //| @@ -59,6 +60,10 @@ STATIC mp_obj_t busdevice_i2cdevice_make_new(const mp_obj_type_t *type, size_t n busio_i2c_obj_t* i2c = args[ARG_i2c].u_obj; common_hal_busdevice_i2cdevice_construct(self, i2c, args[ARG_device_address].u_int, args[ARG_probe].u_bool); + if (args[ARG_probe].u_bool == true) { + common_hal_busdevice_i2cdevice___probe_for_device(self); + } + return (mp_obj_t)self; } @@ -204,28 +209,31 @@ MP_DEFINE_CONST_FUN_OBJ_KW(busdevice_i2cdevice_write_then_readinto_obj, 3, busde STATIC mp_obj_t busdevice_i2cdevice___probe_for_device(mp_obj_t self_in) { - //busdevice_i2cdevice_obj_t *self = self_in; + busdevice_i2cdevice_obj_t *self = self_in; + common_hal_busdevice_i2cdevice___probe_for_device(self); - //common_hal_busdevice_i2cdevice_lock(self_in); +/* common_hal_busdevice_i2cdevice_lock(self); -/* - uint8_t buffer; + + //uint8_t buffer; mp_buffer_info_t bufinfo; - mp_get_buffer_raise(&buffer, &bufinfo, MP_BUFFER_WRITE); + //mp_obj_t bufobj = MP_OBJ_FROM_PTR(&buffer) + mp_obj_t buffer = mp_obj_new_bytearray_of_zeros(1); + + mp_get_buffer_raise(buffer, &bufinfo, MP_BUFFER_WRITE); uint8_t status = common_hal_busdevice_i2cdevice_readinto(self_in, (uint8_t*)bufinfo.buf, 1); if (status != 0) { common_hal_busdevice_i2cdevice_unlock(self_in); mp_raise_ValueError_varg(translate("No I2C device at address: %x"), self->device_address); } + + common_hal_busdevice_i2cdevice_unlock(self); */ - //common_hal_busdevice_i2cdevice_unlock(self_in); - return mp_const_none; } MP_DEFINE_CONST_FUN_OBJ_1(busdevice_i2cdevice___probe_for_device_obj, busdevice_i2cdevice___probe_for_device); - STATIC const mp_rom_map_elem_t busdevice_i2cdevice_locals_dict_table[] = { { MP_ROM_QSTR(MP_QSTR___enter__), MP_ROM_PTR(&busdevice_i2cdevice___enter___obj) }, { MP_ROM_QSTR(MP_QSTR___exit__), MP_ROM_PTR(&busdevice_i2cdevice___exit___obj) }, diff --git a/shared-bindings/busdevice/I2CDevice.h b/shared-bindings/busdevice/I2CDevice.h index bc85023d79..795905b32d 100644 --- a/shared-bindings/busdevice/I2CDevice.h +++ b/shared-bindings/busdevice/I2CDevice.h @@ -45,14 +45,12 @@ extern const mp_obj_type_t busdevice_i2cdevice_type; // Initializes the hardware peripheral. extern void common_hal_busdevice_i2cdevice_construct(busdevice_i2cdevice_obj_t *self, busio_i2c_obj_t *i2c, uint8_t device_address, bool probe); -extern void common_hal_busdevice_i2cdevice___enter__(busdevice_i2cdevice_obj_t *self); -extern void common_hal_busdevice_i2cdevice___exit__(busdevice_i2cdevice_obj_t *self); extern uint8_t common_hal_busdevice_i2cdevice_readinto(busdevice_i2cdevice_obj_t *self, mp_obj_t buffer, size_t length); extern uint8_t common_hal_busdevice_i2cdevice_write(busdevice_i2cdevice_obj_t *self, mp_obj_t buffer, size_t length); extern uint8_t common_hal_busdevice_i2cdevice_write_then_readinto(busdevice_i2cdevice_obj_t *self, mp_obj_t out_buffer, mp_obj_t in_buffer, size_t out_length, size_t in_length); -extern uint8_t common_hal_busdevice_i2cdevice___probe_for_device(busdevice_i2cdevice_obj_t *self); extern void common_hal_busdevice_i2cdevice_lock(busdevice_i2cdevice_obj_t *self); extern void common_hal_busdevice_i2cdevice_unlock(busdevice_i2cdevice_obj_t *self); +extern void common_hal_busdevice_i2cdevice___probe_for_device(busdevice_i2cdevice_obj_t *self); #endif // MICROPY_INCLUDED_SHARED_BINDINGS_BUSDEVICE_I2CDEVICE_H diff --git a/shared-module/busdevice/I2CDevice.c b/shared-module/busdevice/I2CDevice.c index 30f4aad339..516132c84e 100644 --- a/shared-module/busdevice/I2CDevice.c +++ b/shared-module/busdevice/I2CDevice.c @@ -28,15 +28,12 @@ #include "shared-bindings/busio/I2C.h" #include "py/mperrno.h" #include "py/nlr.h" +#include "py/runtime.h" void common_hal_busdevice_i2cdevice_construct(busdevice_i2cdevice_obj_t *self, busio_i2c_obj_t *i2c, uint8_t device_address, bool probe) { self->i2c = i2c; self->device_address = device_address; self->probe = probe; - - if (self->probe == true) { - common_hal_busdevice_i2cdevice___probe_for_device(self); - } } void common_hal_busdevice_i2cdevice_lock(busdevice_i2cdevice_obj_t *self) { @@ -73,29 +70,19 @@ uint8_t common_hal_busdevice_i2cdevice_write_then_readinto(busdevice_i2cdevice_o return status; } -uint8_t common_hal_busdevice_i2cdevice___probe_for_device(busdevice_i2cdevice_obj_t *self) { +void common_hal_busdevice_i2cdevice___probe_for_device(busdevice_i2cdevice_obj_t *self) { + common_hal_busdevice_i2cdevice_lock(self); + mp_buffer_info_t bufinfo; + mp_obj_t buffer = mp_obj_new_bytearray_of_zeros(1); + mp_get_buffer_raise(buffer, &bufinfo, MP_BUFFER_WRITE); - - // write "" - - -/* - while not self.i2c.try_lock(): - pass - try: - self.i2c.writeto(self.device_address, b"") - except OSError: - # some OS's dont like writing an empty bytesting... - # Retry by reading a byte - try: - result = bytearray(1) - self.i2c.readfrom_into(self.device_address, result) - except OSError: - raise ValueError("No I2C device at address: %x" % self.device_address) - finally: - self.i2c.unlock() -*/ - return 0; -} + uint8_t status = common_hal_busdevice_i2cdevice_readinto(self, (uint8_t*)bufinfo.buf, 1); + if (status != 0) { + common_hal_busdevice_i2cdevice_unlock(self); + mp_raise_ValueError_varg(translate("No I2C device at address: %x"), self->device_address); + } + + common_hal_busdevice_i2cdevice_unlock(self); +} \ No newline at end of file From 8a379830a8a583750daedb2b1c72369f6bb413ef Mon Sep 17 00:00:00 2001 From: gamblor21 Date: Mon, 26 Oct 2020 16:54:24 -0500 Subject: [PATCH 004/207] Added doc and translations --- locale/circuitpython.pot | 12 ++- shared-bindings/busdevice/I2CDevice.c | 141 ++++++++++++++------------ shared-module/busdevice/I2CDevice.c | 2 +- 3 files changed, 89 insertions(+), 66 deletions(-) diff --git a/locale/circuitpython.pot b/locale/circuitpython.pot index 7ed2d1ba1d..f96b67d2af 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-10-16 19:50-0500\n" +"POT-Creation-Date: 2020-10-26 16:48-0500\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -477,7 +477,8 @@ msgstr "" msgid "Buffer must be a multiple of 512 bytes" msgstr "" -#: shared-bindings/bitbangio/I2C.c shared-bindings/busio/I2C.c +#: shared-bindings/bitbangio/I2C.c shared-bindings/busdevice/I2CDevice.c +#: shared-bindings/busio/I2C.c msgid "Buffer must be at least length 1" msgstr "" @@ -1251,6 +1252,11 @@ msgstr "" msgid "No DMA channel found" msgstr "" +#: shared-module/busdevice/I2CDevice.c +#, c-format +msgid "No I2C device at address: %x" +msgstr "" + #: ports/esp32s2/common-hal/busio/SPI.c ports/mimxrt10xx/common-hal/busio/SPI.c #: ports/stm/common-hal/busio/SPI.c msgid "No MISO Pin" @@ -3181,6 +3187,8 @@ msgstr "" #: ports/esp32s2/boards/espressif_saola_1_wrover/mpconfigboard.h #: ports/esp32s2/boards/microdev_micro_s2/mpconfigboard.h #: ports/esp32s2/boards/muselab_nanoesp32_s2/mpconfigboard.h +#: ports/esp32s2/boards/targett_module_clip_wroom/mpconfigboard.h +#: ports/esp32s2/boards/targett_module_clip_wrover/mpconfigboard.h #: ports/esp32s2/boards/unexpectedmaker_feathers2/mpconfigboard.h #: ports/esp32s2/boards/unexpectedmaker_feathers2_prerelease/mpconfigboard.h msgid "pressing boot button at start up.\n" diff --git a/shared-bindings/busdevice/I2CDevice.c b/shared-bindings/busdevice/I2CDevice.c index fa5cb02e0b..d8db9362f1 100644 --- a/shared-bindings/busdevice/I2CDevice.c +++ b/shared-bindings/busdevice/I2CDevice.c @@ -39,12 +39,29 @@ //| class I2CDevice: -//| """Two wire serial protocol""" -//| -//| def __init__(self, i2c, device_address, probe=True) -> None: -//| -//| ... -//| +//| """ +//| Represents a single I2C device and manages locking the bus and the device +//| address. +//| :param ~busio.I2C i2c: The I2C bus the device is on +//| :param int device_address: The 7 bit device address +//| :param bool probe: Probe for the device upon object creation, default is true +//| .. note:: This class is **NOT** built into CircuitPython. See +//| :ref:`here for install instructions `. +//| Example: +//| .. code-block:: python +//| import busio +//| from board import * +//| from adafruit_bus_device.i2c_device import I2CDevice +//| with busio.I2C(SCL, SDA) as i2c: +//| device = I2CDevice(i2c, 0x70) +//| bytes_read = bytearray(4) +//| with device: +//| device.readinto(bytes_read) +//| # A second transaction +//| with device: +//| device.write(bytes_read)""" +//| ... +//| STATIC mp_obj_t busdevice_i2cdevice_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { busdevice_i2cdevice_obj_t *self = m_new_obj(busdevice_i2cdevice_obj_t); self->base.type = &busdevice_i2cdevice_type; @@ -67,28 +84,30 @@ STATIC mp_obj_t busdevice_i2cdevice_make_new(const mp_obj_type_t *type, size_t n return (mp_obj_t)self; } -//| def __enter__(self) -> None: -//| """Automatically initializes the hardware on context exit. See FIX -//| :ref:`lifetime-and-contextmanagers` for more info.""" -//| ... -//| STATIC mp_obj_t busdevice_i2cdevice_obj___enter__(mp_obj_t self_in) { common_hal_busdevice_i2cdevice_lock(self_in); return self_in; } STATIC MP_DEFINE_CONST_FUN_OBJ_1(busdevice_i2cdevice___enter___obj, busdevice_i2cdevice_obj___enter__); -//| def __exit__(self) -> None: -//| """Automatically deinitializes the hardware on context exit. See -//| :ref:`lifetime-and-contextmanagers` for more info.""" -//| ... -//| STATIC mp_obj_t busdevice_i2cdevice_obj___exit__(size_t n_args, const mp_obj_t *args) { common_hal_busdevice_i2cdevice_unlock(args[0]); return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(busdevice_i2cdevice___exit___obj, 4, 4, busdevice_i2cdevice_obj___exit__); +//| def readinto(self, buf, *, start=0, end=None): +//| """ +//| Read into ``buf`` from the device. The number of bytes read will be the +//| length of ``buf``. +//| If ``start`` or ``end`` is provided, then the buffer will be sliced +//| as if ``buf[start:end]``. This will not cause an allocation like +//| ``buf[start:end]`` will so it saves memory. +//| :param bytearray buffer: buffer to write into +//| :param int start: Index to start writing at +//| :param int end: Index to write up to but not include; if None, use ``len(buf)``""" +//| ... +//| STATIC void readinto(busdevice_i2cdevice_obj_t *self, mp_obj_t buffer, int32_t start, mp_int_t end) { mp_buffer_info_t bufinfo; mp_get_buffer_raise(buffer, &bufinfo, MP_BUFFER_WRITE); @@ -123,7 +142,19 @@ STATIC mp_obj_t busdevice_i2cdevice_readinto(size_t n_args, const mp_obj_t *pos_ } STATIC MP_DEFINE_CONST_FUN_OBJ_KW(busdevice_i2cdevice_readinto_obj, 2, busdevice_i2cdevice_readinto); - +//| def write(self, buf, *, start=0, end=None): +//| """ +//| Write the bytes from ``buffer`` to the device, then transmit a stop +//| bit. +//| If ``start`` or ``end`` is provided, then the buffer will be sliced +//| as if ``buffer[start:end]``. This will not cause an allocation like +//| ``buffer[start:end]`` will so it saves memory. +//| :param bytearray buffer: buffer containing the bytes to write +//| :param int start: Index to start writing from +//| :param int end: Index to read up to but not include; if None, use ``len(buf)`` +//| """ +//| ... +//| STATIC void write(busdevice_i2cdevice_obj_t *self, mp_obj_t buffer, int32_t start, mp_int_t end) { mp_buffer_info_t bufinfo; mp_get_buffer_raise(buffer, &bufinfo, MP_BUFFER_READ); @@ -158,32 +189,28 @@ STATIC mp_obj_t busdevice_i2cdevice_write(size_t n_args, const mp_obj_t *pos_arg MP_DEFINE_CONST_FUN_OBJ_KW(busdevice_i2cdevice_write_obj, 2, busdevice_i2cdevice_write); -/*STATIC void write_then_readinto(busdevice_i2cdevice_obj_t *self, mp_obj_t out_buffer, mp_obj_t in_buffer, - int32_t out_start, mp_int_t out_end, int32_t in_start, mp_int_t in_end) { - mp_buffer_info_t out_bufinfo; - mp_get_buffer_raise(out_buffer, &out_bufinfo, MP_BUFFER_READ); - - size_t out_length = out_bufinfo.len; - normalize_buffer_bounds(&out_start, out_end, &out_length); - if (out_length == 0) { - mp_raise_ValueError(translate("Buffer must be at least length 1")); - } - - mp_buffer_info_t in_bufinfo; - mp_get_buffer_raise(in_buffer, &in_bufinfo, MP_BUFFER_WRITE); - - size_t in_length = in_bufinfo.len; - normalize_buffer_bounds(&in_start, in_end, &in_length); - if (in_length == 0) { - mp_raise_ValueError(translate("Buffer must be at least length 1")); - } - - uint8_t status = common_hal_busdevice_i2cdevice_write_then_readinto(self, out_buffer, in_buffer, out_length, in_length); - if (status != 0) { - mp_raise_OSError(status); - } -}*/ - +//| def write_then_readinto(self, out_buffer, in_buffer, *, out_start=0, out_end=None, in_start=0, in_end=None): +//| """ +//| Write the bytes from ``out_buffer`` to the device, then immediately +//| reads into ``in_buffer`` from the device. The number of bytes read +//| will be the length of ``in_buffer``. +//| If ``out_start`` or ``out_end`` is provided, then the output buffer +//| will be sliced as if ``out_buffer[out_start:out_end]``. This will +//| not cause an allocation like ``buffer[out_start:out_end]`` will so +//| it saves memory. +//| If ``in_start`` or ``in_end`` is provided, then the input buffer +//| will be sliced as if ``in_buffer[in_start:in_end]``. This will not +//| cause an allocation like ``in_buffer[in_start:in_end]`` will so +//| it saves memory. +//| :param bytearray out_buffer: buffer containing the bytes to write +//| :param bytearray in_buffer: buffer containing the bytes to read into +//| :param int out_start: Index to start writing from +//| :param int out_end: Index to read up to but not include; if None, use ``len(out_buffer)`` +//| :param int in_start: Index to start writing at +//| :param int in_end: Index to write up to but not include; if None, use ``len(in_buffer)`` +//| """ +//| ... +//| STATIC mp_obj_t busdevice_i2cdevice_write_then_readinto(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum { ARG_out_buffer, ARG_in_buffer, ARG_out_start, ARG_out_end, ARG_in_start, ARG_in_end }; static const mp_arg_t allowed_args[] = { @@ -207,29 +234,17 @@ STATIC mp_obj_t busdevice_i2cdevice_write_then_readinto(size_t n_args, const mp_ } MP_DEFINE_CONST_FUN_OBJ_KW(busdevice_i2cdevice_write_then_readinto_obj, 3, busdevice_i2cdevice_write_then_readinto); - +//| def __probe_for_device(self): +//| """ +//| Try to read a byte from an address, +//| if you get an OSError it means the device is not there +//| or that the device does not support these means of probing +//| """ +//| ... +//| STATIC mp_obj_t busdevice_i2cdevice___probe_for_device(mp_obj_t self_in) { busdevice_i2cdevice_obj_t *self = self_in; common_hal_busdevice_i2cdevice___probe_for_device(self); - -/* common_hal_busdevice_i2cdevice_lock(self); - - - //uint8_t buffer; - mp_buffer_info_t bufinfo; - //mp_obj_t bufobj = MP_OBJ_FROM_PTR(&buffer) - mp_obj_t buffer = mp_obj_new_bytearray_of_zeros(1); - - mp_get_buffer_raise(buffer, &bufinfo, MP_BUFFER_WRITE); - - uint8_t status = common_hal_busdevice_i2cdevice_readinto(self_in, (uint8_t*)bufinfo.buf, 1); - if (status != 0) { - common_hal_busdevice_i2cdevice_unlock(self_in); - mp_raise_ValueError_varg(translate("No I2C device at address: %x"), self->device_address); - } - - common_hal_busdevice_i2cdevice_unlock(self); -*/ return mp_const_none; } MP_DEFINE_CONST_FUN_OBJ_1(busdevice_i2cdevice___probe_for_device_obj, busdevice_i2cdevice___probe_for_device); diff --git a/shared-module/busdevice/I2CDevice.c b/shared-module/busdevice/I2CDevice.c index 516132c84e..085c4171f3 100644 --- a/shared-module/busdevice/I2CDevice.c +++ b/shared-module/busdevice/I2CDevice.c @@ -3,7 +3,7 @@ * * The MIT License (MIT) * - * Copyright (c) 2017 Scott Shawcroft for Adafruit Industries + * Copyright (c) 2020 Mark Komus * * 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 9ec224539b7c0fb4f2badf0a416e26b7c3e94854 Mon Sep 17 00:00:00 2001 From: gamblor21 Date: Tue, 27 Oct 2020 08:43:51 -0500 Subject: [PATCH 005/207] Clean up --- shared-bindings/busdevice/I2CDevice.c | 2 +- shared-bindings/busdevice/I2CDevice.h | 3 +-- shared-bindings/busdevice/__init__.c | 33 ++++----------------------- 3 files changed, 7 insertions(+), 31 deletions(-) diff --git a/shared-bindings/busdevice/I2CDevice.c b/shared-bindings/busdevice/I2CDevice.c index d8db9362f1..d21ac8c6eb 100644 --- a/shared-bindings/busdevice/I2CDevice.c +++ b/shared-bindings/busdevice/I2CDevice.c @@ -3,7 +3,7 @@ * * The MIT License (MIT) * - * Copyright (c) 2016 Scott Shawcroft + * Copyright (c) 2020 Mark Komus * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/shared-bindings/busdevice/I2CDevice.h b/shared-bindings/busdevice/I2CDevice.h index 795905b32d..146013cb76 100644 --- a/shared-bindings/busdevice/I2CDevice.h +++ b/shared-bindings/busdevice/I2CDevice.h @@ -36,9 +36,8 @@ #include "py/obj.h" -#include "common-hal/microcontroller/Pin.h" #include "shared-module/busdevice/I2CDevice.h" -#include "shared-bindings/busio/I2C.h" +//#include "shared-bindings/busio/I2C.h" // Type object used in Python. Should be shared between ports. extern const mp_obj_type_t busdevice_i2cdevice_type; diff --git a/shared-bindings/busdevice/__init__.c b/shared-bindings/busdevice/__init__.c index 6b24160a02..91f250c6a5 100644 --- a/shared-bindings/busdevice/__init__.c +++ b/shared-bindings/busdevice/__init__.c @@ -3,7 +3,7 @@ * * The MIT License (MIT) * - * Copyright (c) 2016 Scott Shawcroft for Adafruit Industries + * Copyright (c) 2020 Mark Komus * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -37,33 +37,10 @@ //| """Hardware accelerated external bus access //| -//| The `busio` module contains classes to support a variety of serial -//| protocols. -//| -//| When the microcontroller does not support the behavior in a hardware -//| accelerated fashion it may internally use a bitbang routine. However, if -//| hardware support is available on a subset of pins but not those provided, -//| then a RuntimeError will be raised. Use the `bitbangio` module to explicitly -//| bitbang a serial protocol on any general purpose pins. -//| -//| All classes change hardware state and should be deinitialized when they -//| are no longer needed if the program continues after use. To do so, either -//| call :py:meth:`!deinit` or use a context manager. See -//| :ref:`lifetime-and-contextmanagers` for more info. -//| -//| For example:: -//| -//| import busio -//| from board import * -//| -//| i2c = busio.I2C(SCL, SDA) -//| print(i2c.scan()) -//| i2c.deinit() -//| -//| This example will initialize the the device, run -//| :py:meth:`~busio.I2C.scan` and then :py:meth:`~busio.I2C.deinit` the -//| hardware. The last step is optional because CircuitPython automatically -//| resets hardware after a program finishes.""" +//| The I2CDevice and SPIDevice helper classes make managing transaction state on a bus easy. +//| For example, they manage locking the bus to prevent other concurrent access. For SPI +//| devices, it manages the chip select and protocol changes such as mode. For I2C, it +//| manages the device address. //| STATIC const mp_rom_map_elem_t busdevice_module_globals_table[] = { From 2374b0d013e60b543164f208315ed9f52895dac2 Mon Sep 17 00:00:00 2001 From: gamblor21 Date: Tue, 27 Oct 2020 09:13:14 -0500 Subject: [PATCH 006/207] Fixed whitespace issues --- shared-bindings/busdevice/I2CDevice.c | 16 ++++++++-------- shared-bindings/busdevice/__init__.c | 2 +- shared-module/busdevice/I2CDevice.c | 4 ++-- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/shared-bindings/busdevice/I2CDevice.c b/shared-bindings/busdevice/I2CDevice.c index d21ac8c6eb..1f3da46523 100644 --- a/shared-bindings/busdevice/I2CDevice.c +++ b/shared-bindings/busdevice/I2CDevice.c @@ -61,7 +61,7 @@ //| with device: //| device.write(bytes_read)""" //| ... -//| +//| STATIC mp_obj_t busdevice_i2cdevice_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { busdevice_i2cdevice_obj_t *self = m_new_obj(busdevice_i2cdevice_obj_t); self->base.type = &busdevice_i2cdevice_type; @@ -107,7 +107,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(busdevice_i2cdevice___exit___obj, 4, //| :param int start: Index to start writing at //| :param int end: Index to write up to but not include; if None, use ``len(buf)``""" //| ... -//| +//| STATIC void readinto(busdevice_i2cdevice_obj_t *self, mp_obj_t buffer, int32_t start, mp_int_t end) { mp_buffer_info_t bufinfo; mp_get_buffer_raise(buffer, &bufinfo, MP_BUFFER_WRITE); @@ -131,7 +131,7 @@ STATIC mp_obj_t busdevice_i2cdevice_readinto(size_t n_args, const mp_obj_t *pos_ { MP_QSTR_start, MP_ARG_KW_ONLY | MP_ARG_INT, {.u_int = 0} }, { MP_QSTR_end, MP_ARG_KW_ONLY | MP_ARG_INT, {.u_int = INT_MAX} }, }; - + busdevice_i2cdevice_obj_t *self = MP_OBJ_TO_PTR(pos_args[0]); mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; @@ -179,7 +179,7 @@ STATIC mp_obj_t busdevice_i2cdevice_write(size_t n_args, const mp_obj_t *pos_arg { MP_QSTR_end, MP_ARG_KW_ONLY | MP_ARG_INT, {.u_int = INT_MAX} }, }; busdevice_i2cdevice_obj_t *self = MP_OBJ_TO_PTR(pos_args[0]); - + 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); @@ -210,7 +210,7 @@ MP_DEFINE_CONST_FUN_OBJ_KW(busdevice_i2cdevice_write_obj, 2, busdevice_i2cdevice //| :param int in_end: Index to write up to but not include; if None, use ``len(in_buffer)`` //| """ //| ... -//| +//| STATIC mp_obj_t busdevice_i2cdevice_write_then_readinto(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum { ARG_out_buffer, ARG_in_buffer, ARG_out_start, ARG_out_end, ARG_in_start, ARG_in_end }; static const mp_arg_t allowed_args[] = { @@ -227,7 +227,7 @@ STATIC mp_obj_t busdevice_i2cdevice_write_then_readinto(size_t n_args, const mp_ mp_arg_parse_all(n_args - 1, pos_args + 1, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); write(self, args[ARG_out_buffer].u_obj, args[ARG_out_start].u_int, args[ARG_out_end].u_int); - + readinto(self, args[ARG_in_buffer].u_obj, args[ARG_in_start].u_int, args[ARG_in_end].u_int); return mp_const_none; @@ -241,7 +241,7 @@ MP_DEFINE_CONST_FUN_OBJ_KW(busdevice_i2cdevice_write_then_readinto_obj, 3, busde //| or that the device does not support these means of probing //| """ //| ... -//| +//| STATIC mp_obj_t busdevice_i2cdevice___probe_for_device(mp_obj_t self_in) { busdevice_i2cdevice_obj_t *self = self_in; common_hal_busdevice_i2cdevice___probe_for_device(self); @@ -266,4 +266,4 @@ const mp_obj_type_t busdevice_i2cdevice_type = { .name = MP_QSTR_I2CDevice, .make_new = busdevice_i2cdevice_make_new, .locals_dict = (mp_obj_dict_t*)&busdevice_i2cdevice_locals_dict, -}; \ No newline at end of file +}; diff --git a/shared-bindings/busdevice/__init__.c b/shared-bindings/busdevice/__init__.c index 91f250c6a5..112dabb7eb 100644 --- a/shared-bindings/busdevice/__init__.c +++ b/shared-bindings/busdevice/__init__.c @@ -37,7 +37,7 @@ //| """Hardware accelerated external bus access //| -//| The I2CDevice and SPIDevice helper classes make managing transaction state on a bus easy. +//| The I2CDevice and SPIDevice helper classes make managing transaction state on a bus easy. //| For example, they manage locking the bus to prevent other concurrent access. For SPI //| devices, it manages the chip select and protocol changes such as mode. For I2C, it //| manages the device address. diff --git a/shared-module/busdevice/I2CDevice.c b/shared-module/busdevice/I2CDevice.c index 085c4171f3..91013d52c7 100644 --- a/shared-module/busdevice/I2CDevice.c +++ b/shared-module/busdevice/I2CDevice.c @@ -83,6 +83,6 @@ void common_hal_busdevice_i2cdevice___probe_for_device(busdevice_i2cdevice_obj_t common_hal_busdevice_i2cdevice_unlock(self); mp_raise_ValueError_varg(translate("No I2C device at address: %x"), self->device_address); } - + common_hal_busdevice_i2cdevice_unlock(self); -} \ No newline at end of file +} From 90b9ec6f2ce840885492f125f8c473df8bd67337 Mon Sep 17 00:00:00 2001 From: microDev <70126934+microDev1@users.noreply.github.com> Date: Fri, 18 Sep 2020 17:40:49 +0530 Subject: [PATCH 007/207] Initial Sleep Support --- .../common-hal/microcontroller/__init__.c | 6 ++++ ports/esp32s2/common-hal/timealarm/__init__.c | 10 ++++++ ports/esp32s2/mpconfigport.mk | 1 + py/circuitpy_defns.mk | 4 +++ py/circuitpy_mpconfig.h | 8 +++++ py/circuitpy_mpconfig.mk | 3 ++ shared-bindings/microcontroller/__init__.c | 17 ++++++++++ shared-bindings/microcontroller/__init__.h | 2 ++ shared-bindings/timealarm/__init__.c | 31 +++++++++++++++++++ shared-bindings/timealarm/__init__.h | 8 +++++ 10 files changed, 90 insertions(+) create mode 100644 ports/esp32s2/common-hal/timealarm/__init__.c create mode 100644 shared-bindings/timealarm/__init__.c create mode 100644 shared-bindings/timealarm/__init__.h diff --git a/ports/esp32s2/common-hal/microcontroller/__init__.c b/ports/esp32s2/common-hal/microcontroller/__init__.c index 6b2e18673d..2fcc2ceda1 100644 --- a/ports/esp32s2/common-hal/microcontroller/__init__.c +++ b/ports/esp32s2/common-hal/microcontroller/__init__.c @@ -41,6 +41,8 @@ #include "freertos/FreeRTOS.h" +#include "esp_sleep.h" + void common_hal_mcu_delay_us(uint32_t delay) { } @@ -77,6 +79,10 @@ void common_hal_mcu_reset(void) { while(1); } +void common_hal_mcu_sleep(void) { + esp_deep_sleep_start(); +} + // 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 = { diff --git a/ports/esp32s2/common-hal/timealarm/__init__.c b/ports/esp32s2/common-hal/timealarm/__init__.c new file mode 100644 index 0000000000..e404f801a6 --- /dev/null +++ b/ports/esp32s2/common-hal/timealarm/__init__.c @@ -0,0 +1,10 @@ +#include "esp_sleep.h" + +#include "shared-bindings/timealarm/__init__.h" + +void common_hal_timealarm_duration (uint32_t ms) { + if (esp_sleep_enable_timer_wakeup((ms) * 1000) == ESP_ERR_INVALID_ARG) { + mp_raise_ValueError(translate("time out of range")); + } +} + diff --git a/ports/esp32s2/mpconfigport.mk b/ports/esp32s2/mpconfigport.mk index c06c89c909..125d078e8a 100644 --- a/ports/esp32s2/mpconfigport.mk +++ b/ports/esp32s2/mpconfigport.mk @@ -22,6 +22,7 @@ CIRCUITPY_FREQUENCYIO = 0 CIRCUITPY_I2CPERIPHERAL = 0 CIRCUITPY_ROTARYIO = 0 CIRCUITPY_NVM = 0 +CIRCUITPY_TIMEALARM = 1 # We don't have enough endpoints to include MIDI. CIRCUITPY_USB_MIDI = 0 CIRCUITPY_WIFI = 1 diff --git a/py/circuitpy_defns.mk b/py/circuitpy_defns.mk index ccdf973e9f..91af6ffc15 100644 --- a/py/circuitpy_defns.mk +++ b/py/circuitpy_defns.mk @@ -259,6 +259,9 @@ endif ifeq ($(CIRCUITPY_TIME),1) SRC_PATTERNS += time/% endif +ifeq ($(CIRCUITPY_TIMEALARM),1) +SRC_PATTERNS += timealarm/% +endif ifeq ($(CIRCUITPY_TOUCHIO),1) SRC_PATTERNS += touchio/% endif @@ -360,6 +363,7 @@ SRC_COMMON_HAL_ALL = \ ssl/SSLContext.c \ supervisor/Runtime.c \ supervisor/__init__.c \ + timealarm/__init__.c \ watchdog/WatchDogMode.c \ watchdog/WatchDogTimer.c \ watchdog/__init__.c \ diff --git a/py/circuitpy_mpconfig.h b/py/circuitpy_mpconfig.h index 1e01bd9c5e..8efd439212 100644 --- a/py/circuitpy_mpconfig.h +++ b/py/circuitpy_mpconfig.h @@ -663,6 +663,13 @@ extern const struct _mp_obj_module_t time_module; #define TIME_MODULE_ALT_NAME #endif +#if CIRCUITPY_TIMEALARM +extern const struct _mp_obj_module_t timealarm_module; +#define TIMEALARM_MODULE { MP_OBJ_NEW_QSTR(MP_QSTR_timealarm), (mp_obj_t)&timealarm_module }, +#else +#define TIMEALARM_MODULE +#endif + #if CIRCUITPY_TOUCHIO extern const struct _mp_obj_module_t touchio_module; #define TOUCHIO_MODULE { MP_OBJ_NEW_QSTR(MP_QSTR_touchio), (mp_obj_t)&touchio_module }, @@ -821,6 +828,7 @@ extern const struct _mp_obj_module_t wifi_module; STRUCT_MODULE \ SUPERVISOR_MODULE \ TOUCHIO_MODULE \ + TIMEALARM_MODULE \ UHEAP_MODULE \ USB_HID_MODULE \ USB_MIDI_MODULE \ diff --git a/py/circuitpy_mpconfig.mk b/py/circuitpy_mpconfig.mk index a6aabec33d..bb70daccc7 100644 --- a/py/circuitpy_mpconfig.mk +++ b/py/circuitpy_mpconfig.mk @@ -234,6 +234,9 @@ CFLAGS += -DCIRCUITPY_TERMINALIO=$(CIRCUITPY_TERMINALIO) CIRCUITPY_TIME ?= 1 CFLAGS += -DCIRCUITPY_TIME=$(CIRCUITPY_TIME) +CIRCUITPY_TIMEALARM ?= 0 +CFLAGS += -DCIRCUITPY_TIMEALARM=$(CIRCUITPY_TIMEALARM) + # touchio might be native or generic. See circuitpy_defns.mk. CIRCUITPY_TOUCHIO_USE_NATIVE ?= 0 CFLAGS += -DCIRCUITPY_TOUCHIO_USE_NATIVE=$(CIRCUITPY_TOUCHIO_USE_NATIVE) diff --git a/shared-bindings/microcontroller/__init__.c b/shared-bindings/microcontroller/__init__.c index 2e58bdcc29..b8ca8f18ba 100644 --- a/shared-bindings/microcontroller/__init__.c +++ b/shared-bindings/microcontroller/__init__.c @@ -136,6 +136,22 @@ STATIC mp_obj_t mcu_reset(void) { } STATIC MP_DEFINE_CONST_FUN_OBJ_0(mcu_reset_obj, mcu_reset); +//| def sleep() -> None: +//| """Microcontroller will go into deep sleep. +//| cpy will restart when wakeup func. is triggered`. +//| +//| .. warning:: This may result in file system corruption when connected to a +//| host computer. Be very careful when calling this! Make sure the device +//| "Safely removed" on Windows or "ejected" on Mac OSX and Linux.""" +//| ... +//| +STATIC mp_obj_t mcu_sleep(void) { + common_hal_mcu_sleep(); + // We won't actually get here because mcu is going into sleep. + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_0(mcu_sleep_obj, mcu_sleep); + //| nvm: Optional[ByteArray] //| """Available non-volatile memory. //| This object is the sole instance of `nvm.ByteArray` when available or ``None`` otherwise. @@ -171,6 +187,7 @@ STATIC const mp_rom_map_elem_t mcu_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR_enable_interrupts), MP_ROM_PTR(&mcu_enable_interrupts_obj) }, { MP_ROM_QSTR(MP_QSTR_on_next_reset), MP_ROM_PTR(&mcu_on_next_reset_obj) }, { MP_ROM_QSTR(MP_QSTR_reset), MP_ROM_PTR(&mcu_reset_obj) }, + { MP_ROM_QSTR(MP_QSTR_sleep), MP_ROM_PTR(&mcu_sleep_obj) }, #if CIRCUITPY_INTERNAL_NVM_SIZE > 0 { MP_ROM_QSTR(MP_QSTR_nvm), MP_ROM_PTR(&common_hal_mcu_nvm_obj) }, #else diff --git a/shared-bindings/microcontroller/__init__.h b/shared-bindings/microcontroller/__init__.h index 8abdff763c..b0f61e64b9 100644 --- a/shared-bindings/microcontroller/__init__.h +++ b/shared-bindings/microcontroller/__init__.h @@ -43,6 +43,8 @@ extern void common_hal_mcu_enable_interrupts(void); extern void common_hal_mcu_on_next_reset(mcu_runmode_t runmode); extern void common_hal_mcu_reset(void); +extern void common_hal_mcu_sleep(void); + extern const mp_obj_dict_t mcu_pin_globals; extern const mcu_processor_obj_t common_hal_mcu_processor_obj; diff --git a/shared-bindings/timealarm/__init__.c b/shared-bindings/timealarm/__init__.c new file mode 100644 index 0000000000..19fb4f093a --- /dev/null +++ b/shared-bindings/timealarm/__init__.c @@ -0,0 +1,31 @@ +#include "py/obj.h" +#include "shared-bindings/timealarm/__init__.h" + +//| Set Timer Wakeup +//| +STATIC mp_obj_t timealarm_duration(mp_obj_t seconds_o) { + #if MICROPY_PY_BUILTINS_FLOAT + mp_float_t seconds = mp_obj_get_float(seconds_o); + mp_float_t msecs = 1000.0f * seconds + 0.5f; + #else + 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_timealarm_duration(msecs); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_1(timealarm_duration_obj, timealarm_duration); + +STATIC const mp_rom_map_elem_t timealarm_module_globals_table[] = { + { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_timealarm) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_duration), MP_ROM_PTR(&timealarm_duration_obj) }, +}; +STATIC MP_DEFINE_CONST_DICT(timealarm_module_globals, timealarm_module_globals_table); + +const mp_obj_module_t timealarm_module = { + .base = { &mp_type_module }, + .globals = (mp_obj_dict_t*)&timealarm_module_globals, +}; diff --git a/shared-bindings/timealarm/__init__.h b/shared-bindings/timealarm/__init__.h new file mode 100644 index 0000000000..b70cbda1f2 --- /dev/null +++ b/shared-bindings/timealarm/__init__.h @@ -0,0 +1,8 @@ +#ifndef MICROPY_INCLUDED_SHARED_BINDINGS_ulp___INIT___H +#define MICROPY_INCLUDED_SHARED_BINDINGS_ulp___INIT___H + +#include "py/runtime.h" + +extern void common_hal_timealarm_duration(uint32_t); + +#endif \ No newline at end of file From 3a30887b444c6c17f116abd85308251486c9dfe9 Mon Sep 17 00:00:00 2001 From: microDev <70126934+microDev1@users.noreply.github.com> Date: Fri, 18 Sep 2020 17:59:18 +0530 Subject: [PATCH 008/207] Update soft reboot message --- main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.c b/main.c index b43b3b8c80..ebce8cd403 100755 --- a/main.c +++ b/main.c @@ -509,7 +509,7 @@ int __attribute__((used)) main(void) { } if (exit_code == PYEXEC_FORCED_EXIT) { if (!first_run) { - serial_write_compressed(translate("soft reboot\n")); + serial_write_compressed(translate("\n\n ----- soft reboot -----\n")); } first_run = false; skip_repl = run_code_py(safe_mode); From e310b871c8eb8cf924e6937edc7cd51a2be1a6b7 Mon Sep 17 00:00:00 2001 From: microDev <70126934+microDev1@users.noreply.github.com> Date: Sat, 19 Sep 2020 17:48:36 +0530 Subject: [PATCH 009/207] Get io wake working --- main.c | 2 +- ports/esp32s2/common-hal/io_alarm/__init__.c | 27 +++++++++++++++ .../{timealarm => time_alarm}/__init__.c | 4 +-- ports/esp32s2/mpconfigport.mk | 3 +- py/circuitpy_defns.mk | 10 ++++-- py/circuitpy_mpconfig.h | 18 +++++++--- py/circuitpy_mpconfig.mk | 7 ++-- shared-bindings/io_alarm/__init__.c | 34 +++++++++++++++++++ shared-bindings/io_alarm/__init__.h | 8 +++++ shared-bindings/time_alarm/__init__.c | 31 +++++++++++++++++ shared-bindings/time_alarm/__init__.h | 8 +++++ shared-bindings/timealarm/__init__.c | 31 ----------------- shared-bindings/timealarm/__init__.h | 8 ----- 13 files changed, 138 insertions(+), 53 deletions(-) create mode 100644 ports/esp32s2/common-hal/io_alarm/__init__.c rename ports/esp32s2/common-hal/{timealarm => time_alarm}/__init__.c (63%) create mode 100644 shared-bindings/io_alarm/__init__.c create mode 100644 shared-bindings/io_alarm/__init__.h create mode 100644 shared-bindings/time_alarm/__init__.c create mode 100644 shared-bindings/time_alarm/__init__.h delete mode 100644 shared-bindings/timealarm/__init__.c delete mode 100644 shared-bindings/timealarm/__init__.h diff --git a/main.c b/main.c index ebce8cd403..5a30f4bb26 100755 --- a/main.c +++ b/main.c @@ -509,7 +509,7 @@ int __attribute__((used)) main(void) { } if (exit_code == PYEXEC_FORCED_EXIT) { if (!first_run) { - serial_write_compressed(translate("\n\n ----- soft reboot -----\n")); + serial_write_compressed(translate("\n\n------ soft reboot ------\n")); } first_run = false; skip_repl = run_code_py(safe_mode); diff --git a/ports/esp32s2/common-hal/io_alarm/__init__.c b/ports/esp32s2/common-hal/io_alarm/__init__.c new file mode 100644 index 0000000000..d88c147fe0 --- /dev/null +++ b/ports/esp32s2/common-hal/io_alarm/__init__.c @@ -0,0 +1,27 @@ +#include "shared-bindings/io_alarm/__init__.h" + +#include "esp_sleep.h" +#include "driver/rtc_io.h" + +void common_hal_io_alarm_pin_state (uint8_t gpio, uint8_t level, bool pull) { + if (!rtc_gpio_is_valid_gpio(gpio)) { + mp_raise_ValueError(translate("io must be rtc io")); + return; + } + + switch(esp_sleep_enable_ext0_wakeup(gpio, level)) { + case ESP_ERR_INVALID_ARG: + mp_raise_ValueError(translate("trigger level must be 0 or 1")); + return; + case ESP_ERR_INVALID_STATE: + mp_raise_RuntimeError(translate("wakeup conflict")); + return; + default: + break; + } + + if (pull) { + (level) ? rtc_gpio_pulldown_en(gpio) : rtc_gpio_pullup_en(gpio); + } +} + diff --git a/ports/esp32s2/common-hal/timealarm/__init__.c b/ports/esp32s2/common-hal/time_alarm/__init__.c similarity index 63% rename from ports/esp32s2/common-hal/timealarm/__init__.c rename to ports/esp32s2/common-hal/time_alarm/__init__.c index e404f801a6..342ca9d154 100644 --- a/ports/esp32s2/common-hal/timealarm/__init__.c +++ b/ports/esp32s2/common-hal/time_alarm/__init__.c @@ -1,8 +1,8 @@ #include "esp_sleep.h" -#include "shared-bindings/timealarm/__init__.h" +#include "shared-bindings/time_alarm/__init__.h" -void common_hal_timealarm_duration (uint32_t ms) { +void common_hal_time_alarm_duration (uint32_t ms) { if (esp_sleep_enable_timer_wakeup((ms) * 1000) == ESP_ERR_INVALID_ARG) { mp_raise_ValueError(translate("time out of range")); } diff --git a/ports/esp32s2/mpconfigport.mk b/ports/esp32s2/mpconfigport.mk index 125d078e8a..0f8f3ada53 100644 --- a/ports/esp32s2/mpconfigport.mk +++ b/ports/esp32s2/mpconfigport.mk @@ -22,7 +22,8 @@ CIRCUITPY_FREQUENCYIO = 0 CIRCUITPY_I2CPERIPHERAL = 0 CIRCUITPY_ROTARYIO = 0 CIRCUITPY_NVM = 0 -CIRCUITPY_TIMEALARM = 1 +CIRCUITPY_TIME_ALARM = 1 +CIRCUITPY_IO_ALARM = 1 # We don't have enough endpoints to include MIDI. CIRCUITPY_USB_MIDI = 0 CIRCUITPY_WIFI = 1 diff --git a/py/circuitpy_defns.mk b/py/circuitpy_defns.mk index 91af6ffc15..672eeda40c 100644 --- a/py/circuitpy_defns.mk +++ b/py/circuitpy_defns.mk @@ -259,8 +259,11 @@ endif ifeq ($(CIRCUITPY_TIME),1) SRC_PATTERNS += time/% endif -ifeq ($(CIRCUITPY_TIMEALARM),1) -SRC_PATTERNS += timealarm/% +ifeq ($(CIRCUITPY_TIME_ALARM),1) +SRC_PATTERNS += time_alarm/% +endif +ifeq ($(CIRCUITPY_IO_ALARM),1) +SRC_PATTERNS += io_alarm/% endif ifeq ($(CIRCUITPY_TOUCHIO),1) SRC_PATTERNS += touchio/% @@ -363,7 +366,8 @@ SRC_COMMON_HAL_ALL = \ ssl/SSLContext.c \ supervisor/Runtime.c \ supervisor/__init__.c \ - timealarm/__init__.c \ + time_alarm/__init__.c \ + io_alarm/__init__.c \ watchdog/WatchDogMode.c \ watchdog/WatchDogTimer.c \ watchdog/__init__.c \ diff --git a/py/circuitpy_mpconfig.h b/py/circuitpy_mpconfig.h index 8efd439212..d899ecacb6 100644 --- a/py/circuitpy_mpconfig.h +++ b/py/circuitpy_mpconfig.h @@ -663,11 +663,18 @@ extern const struct _mp_obj_module_t time_module; #define TIME_MODULE_ALT_NAME #endif -#if CIRCUITPY_TIMEALARM -extern const struct _mp_obj_module_t timealarm_module; -#define TIMEALARM_MODULE { MP_OBJ_NEW_QSTR(MP_QSTR_timealarm), (mp_obj_t)&timealarm_module }, +#if CIRCUITPY_TIME_ALARM +extern const struct _mp_obj_module_t time_alarm_module; +#define TIME_ALARM_MODULE { MP_OBJ_NEW_QSTR(MP_QSTR_time_alarm), (mp_obj_t)&time_alarm_module }, #else -#define TIMEALARM_MODULE +#define TIME_ALARM_MODULE +#endif + +#if CIRCUITPY_IO_ALARM +extern const struct _mp_obj_module_t io_alarm_module; +#define IO_ALARM_MODULE { MP_OBJ_NEW_QSTR(MP_QSTR_io_alarm), (mp_obj_t)&io_alarm_module }, +#else +#define IO_ALARM_MODULE #endif #if CIRCUITPY_TOUCHIO @@ -828,7 +835,8 @@ extern const struct _mp_obj_module_t wifi_module; STRUCT_MODULE \ SUPERVISOR_MODULE \ TOUCHIO_MODULE \ - TIMEALARM_MODULE \ + TIME_ALARM_MODULE \ + IO_ALARM_MODULE \ UHEAP_MODULE \ USB_HID_MODULE \ USB_MIDI_MODULE \ diff --git a/py/circuitpy_mpconfig.mk b/py/circuitpy_mpconfig.mk index bb70daccc7..4cce2a0a1a 100644 --- a/py/circuitpy_mpconfig.mk +++ b/py/circuitpy_mpconfig.mk @@ -234,8 +234,11 @@ CFLAGS += -DCIRCUITPY_TERMINALIO=$(CIRCUITPY_TERMINALIO) CIRCUITPY_TIME ?= 1 CFLAGS += -DCIRCUITPY_TIME=$(CIRCUITPY_TIME) -CIRCUITPY_TIMEALARM ?= 0 -CFLAGS += -DCIRCUITPY_TIMEALARM=$(CIRCUITPY_TIMEALARM) +CIRCUITPY_TIME_ALARM ?= 0 +CFLAGS += -DCIRCUITPY_TIME_ALARM=$(CIRCUITPY_TIME_ALARM) + +CIRCUITPY_IO_ALARM ?= 0 +CFLAGS += -DCIRCUITPY_IO_ALARM=$(CIRCUITPY_IO_ALARM) # touchio might be native or generic. See circuitpy_defns.mk. CIRCUITPY_TOUCHIO_USE_NATIVE ?= 0 diff --git a/shared-bindings/io_alarm/__init__.c b/shared-bindings/io_alarm/__init__.c new file mode 100644 index 0000000000..534b7e66f5 --- /dev/null +++ b/shared-bindings/io_alarm/__init__.c @@ -0,0 +1,34 @@ +#include "py/obj.h" + +#include "shared-bindings/io_alarm/__init__.h" +#include "shared-bindings/microcontroller/Pin.h" + +//| Set Timer Wakeup +//| +STATIC mp_obj_t io_alarm_pin_state(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { + enum { ARG_level, ARG_pull }; + static const mp_arg_t allowed_args[] = { + { MP_QSTR_level, MP_ARG_INT | MP_ARG_KW_ONLY | MP_ARG_REQUIRED }, + { MP_QSTR_pull, MP_ARG_INT | MP_ARG_KW_ONLY, {.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); + + mcu_pin_obj_t *pin = validate_obj_is_pin(pos_args[0]); + common_hal_io_alarm_pin_state(pin->number, args[ARG_level].u_int, args[ARG_pull].u_bool); + + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_KW(io_alarm_pin_state_obj, 1, io_alarm_pin_state); + +STATIC const mp_rom_map_elem_t io_alarm_module_globals_table[] = { + { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_io_alarm) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_PinState), MP_ROM_PTR(&io_alarm_pin_state_obj) }, +}; +STATIC MP_DEFINE_CONST_DICT(io_alarm_module_globals, io_alarm_module_globals_table); + +const mp_obj_module_t io_alarm_module = { + .base = { &mp_type_module }, + .globals = (mp_obj_dict_t*)&io_alarm_module_globals, +}; diff --git a/shared-bindings/io_alarm/__init__.h b/shared-bindings/io_alarm/__init__.h new file mode 100644 index 0000000000..dd4b881657 --- /dev/null +++ b/shared-bindings/io_alarm/__init__.h @@ -0,0 +1,8 @@ +#ifndef MICROPY_INCLUDED_SHARED_BINDINGS_IO_ALARM___INIT___H +#define MICROPY_INCLUDED_SHARED_BINDINGS_IO_ALARM___INIT___H + +#include "py/runtime.h" + +extern void common_hal_io_alarm_pin_state(uint8_t gpio, uint8_t level, bool pull); + +#endif //MICROPY_INCLUDED_SHARED_BINDINGS_IO_ALARM___INIT___H diff --git a/shared-bindings/time_alarm/__init__.c b/shared-bindings/time_alarm/__init__.c new file mode 100644 index 0000000000..bfbece83c0 --- /dev/null +++ b/shared-bindings/time_alarm/__init__.c @@ -0,0 +1,31 @@ +#include "py/obj.h" +#include "shared-bindings/time_alarm/__init__.h" + +//| Set Timer Wakeup +//| +STATIC mp_obj_t time_alarm_duration(mp_obj_t seconds_o) { + #if MICROPY_PY_BUILTINS_FLOAT + mp_float_t seconds = mp_obj_get_float(seconds_o); + mp_float_t msecs = 1000.0f * seconds + 0.5f; + #else + 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_alarm_duration(msecs); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_1(time_alarm_duration_obj, time_alarm_duration); + +STATIC const mp_rom_map_elem_t time_alarm_module_globals_table[] = { + { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_time_alarm) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_Duration), MP_ROM_PTR(&time_alarm_duration_obj) }, +}; +STATIC MP_DEFINE_CONST_DICT(time_alarm_module_globals, time_alarm_module_globals_table); + +const mp_obj_module_t time_alarm_module = { + .base = { &mp_type_module }, + .globals = (mp_obj_dict_t*)&time_alarm_module_globals, +}; diff --git a/shared-bindings/time_alarm/__init__.h b/shared-bindings/time_alarm/__init__.h new file mode 100644 index 0000000000..0913f7fded --- /dev/null +++ b/shared-bindings/time_alarm/__init__.h @@ -0,0 +1,8 @@ +#ifndef MICROPY_INCLUDED_SHARED_BINDINGS_TIME_ALARM___INIT___H +#define MICROPY_INCLUDED_SHARED_BINDINGS_TIME_ALARM___INIT___H + +#include "py/runtime.h" + +extern void common_hal_time_alarm_duration(uint32_t); + +#endif //MICROPY_INCLUDED_SHARED_BINDINGS_TIME_ALARM___INIT___H diff --git a/shared-bindings/timealarm/__init__.c b/shared-bindings/timealarm/__init__.c deleted file mode 100644 index 19fb4f093a..0000000000 --- a/shared-bindings/timealarm/__init__.c +++ /dev/null @@ -1,31 +0,0 @@ -#include "py/obj.h" -#include "shared-bindings/timealarm/__init__.h" - -//| Set Timer Wakeup -//| -STATIC mp_obj_t timealarm_duration(mp_obj_t seconds_o) { - #if MICROPY_PY_BUILTINS_FLOAT - mp_float_t seconds = mp_obj_get_float(seconds_o); - mp_float_t msecs = 1000.0f * seconds + 0.5f; - #else - 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_timealarm_duration(msecs); - return mp_const_none; -} -STATIC MP_DEFINE_CONST_FUN_OBJ_1(timealarm_duration_obj, timealarm_duration); - -STATIC const mp_rom_map_elem_t timealarm_module_globals_table[] = { - { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_timealarm) }, - { MP_OBJ_NEW_QSTR(MP_QSTR_duration), MP_ROM_PTR(&timealarm_duration_obj) }, -}; -STATIC MP_DEFINE_CONST_DICT(timealarm_module_globals, timealarm_module_globals_table); - -const mp_obj_module_t timealarm_module = { - .base = { &mp_type_module }, - .globals = (mp_obj_dict_t*)&timealarm_module_globals, -}; diff --git a/shared-bindings/timealarm/__init__.h b/shared-bindings/timealarm/__init__.h deleted file mode 100644 index b70cbda1f2..0000000000 --- a/shared-bindings/timealarm/__init__.h +++ /dev/null @@ -1,8 +0,0 @@ -#ifndef MICROPY_INCLUDED_SHARED_BINDINGS_ulp___INIT___H -#define MICROPY_INCLUDED_SHARED_BINDINGS_ulp___INIT___H - -#include "py/runtime.h" - -extern void common_hal_timealarm_duration(uint32_t); - -#endif \ No newline at end of file From 05a3f203dbaf53fbccd97395a90d025f2d3b9dc2 Mon Sep 17 00:00:00 2001 From: microDev <70126934+microDev1@users.noreply.github.com> Date: Tue, 22 Sep 2020 23:45:38 +0530 Subject: [PATCH 010/207] Add function to get time elapsed during sleep --- .../common-hal/microcontroller/__init__.c | 46 +++++++++++++++++++ shared-bindings/microcontroller/__init__.c | 20 ++++++++ shared-bindings/microcontroller/__init__.h | 5 ++ 3 files changed, 71 insertions(+) diff --git a/ports/esp32s2/common-hal/microcontroller/__init__.c b/ports/esp32s2/common-hal/microcontroller/__init__.c index 2fcc2ceda1..8b9fef2f98 100644 --- a/ports/esp32s2/common-hal/microcontroller/__init__.c +++ b/ports/esp32s2/common-hal/microcontroller/__init__.c @@ -25,6 +25,8 @@ * THE SOFTWARE. */ +#include + #include "py/mphal.h" #include "py/obj.h" #include "py/runtime.h" @@ -42,6 +44,9 @@ #include "freertos/FreeRTOS.h" #include "esp_sleep.h" +#include "soc/rtc_periph.h" + +static RTC_DATA_ATTR struct timeval sleep_enter_time; void common_hal_mcu_delay_us(uint32_t delay) { @@ -80,9 +85,50 @@ void common_hal_mcu_reset(void) { } void common_hal_mcu_sleep(void) { + gettimeofday(&sleep_enter_time, NULL); esp_deep_sleep_start(); } +int common_hal_mcu_get_sleep_time(void) { + struct timeval now; + gettimeofday(&now, NULL); + return (now.tv_sec - sleep_enter_time.tv_sec) * 1000 + (now.tv_usec - sleep_enter_time.tv_usec) / 1000; +} + +mp_obj_t common_hal_mcu_get_wake_alarm(void) { + switch (esp_sleep_get_wakeup_cause()) { + case ESP_SLEEP_WAKEUP_TIMER: ; + //Wake up from timer. + time_alarm_obj_t *timer = m_new_obj(time_alarm_obj_t); + timer->base.type = &time_alarm_type; + return timer; + case ESP_SLEEP_WAKEUP_EXT0: ; + //Wake up from GPIO + io_alarm_obj_t *ext0 = m_new_obj(io_alarm_obj_t); + ext0->base.type = &io_alarm_type; + return ext0; + case ESP_SLEEP_WAKEUP_EXT1: + //Wake up from GPIO, returns -> esp_sleep_get_ext1_wakeup_status() + /*uint64_t wakeup_pin_mask = esp_sleep_get_ext1_wakeup_status(); + if (wakeup_pin_mask != 0) { + int pin = __builtin_ffsll(wakeup_pin_mask) - 1; + printf("Wake up from GPIO %d\n", pin); + } else { + printf("Wake up from GPIO\n"); + }*/ + break; + case ESP_SLEEP_WAKEUP_TOUCHPAD: + //TODO: implement TouchIO + //Wake up from touch on pad, returns -> esp_sleep_get_touchpad_wakeup_status() + break; + case ESP_SLEEP_WAKEUP_UNDEFINED: + default: + //Not a deep sleep reset + break; + } + return mp_const_none; +} + // 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 = { diff --git a/shared-bindings/microcontroller/__init__.c b/shared-bindings/microcontroller/__init__.c index b8ca8f18ba..7b896d99b2 100644 --- a/shared-bindings/microcontroller/__init__.c +++ b/shared-bindings/microcontroller/__init__.c @@ -152,6 +152,24 @@ STATIC mp_obj_t mcu_sleep(void) { } STATIC MP_DEFINE_CONST_FUN_OBJ_0(mcu_sleep_obj, mcu_sleep); +//| def getWakeAlarm() -> None: +//| """This returns the alarm that triggered wakeup, +//| also returns alarm specific parameters`. +//| +STATIC mp_obj_t mcu_get_wake_alarm(void) { + return common_hal_mcu_get_wake_alarm(); +} +STATIC MP_DEFINE_CONST_FUN_OBJ_0(mcu_get_wake_alarm_obj, mcu_get_wake_alarm); + +//| def getSleepTime() -> None: +//| """This returns the period of time in ms, +//| in which the board was in deep sleep`. +//| +STATIC mp_obj_t mcu_get_sleep_time(void) { + return mp_obj_new_int(common_hal_mcu_get_sleep_time()); +} +STATIC MP_DEFINE_CONST_FUN_OBJ_0(mcu_get_sleep_time_obj, mcu_get_sleep_time); + //| nvm: Optional[ByteArray] //| """Available non-volatile memory. //| This object is the sole instance of `nvm.ByteArray` when available or ``None`` otherwise. @@ -188,6 +206,8 @@ STATIC const mp_rom_map_elem_t mcu_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR_on_next_reset), MP_ROM_PTR(&mcu_on_next_reset_obj) }, { MP_ROM_QSTR(MP_QSTR_reset), MP_ROM_PTR(&mcu_reset_obj) }, { MP_ROM_QSTR(MP_QSTR_sleep), MP_ROM_PTR(&mcu_sleep_obj) }, + { MP_ROM_QSTR(MP_QSTR_getSleepTime), MP_ROM_PTR(&mcu_get_sleep_time_obj) }, + { MP_ROM_QSTR(MP_QSTR_getWakeAlarm), MP_ROM_PTR(&mcu_get_wake_alarm_obj) }, #if CIRCUITPY_INTERNAL_NVM_SIZE > 0 { MP_ROM_QSTR(MP_QSTR_nvm), MP_ROM_PTR(&common_hal_mcu_nvm_obj) }, #else diff --git a/shared-bindings/microcontroller/__init__.h b/shared-bindings/microcontroller/__init__.h index b0f61e64b9..f0a3cee2df 100644 --- a/shared-bindings/microcontroller/__init__.h +++ b/shared-bindings/microcontroller/__init__.h @@ -35,6 +35,9 @@ #include "shared-bindings/microcontroller/RunMode.h" +#include "shared-bindings/io_alarm/__init__.h" +#include "shared-bindings/time_alarm/__init__.h" + extern void common_hal_mcu_delay_us(uint32_t); extern void common_hal_mcu_disable_interrupts(void); @@ -44,6 +47,8 @@ extern void common_hal_mcu_on_next_reset(mcu_runmode_t runmode); extern void common_hal_mcu_reset(void); extern void common_hal_mcu_sleep(void); +extern int common_hal_mcu_get_sleep_time(void); +extern mp_obj_t common_hal_mcu_get_wake_alarm(void); extern const mp_obj_dict_t mcu_pin_globals; From 21ba61afbbdfbf1a693e9e136c645d970c0a7e9c Mon Sep 17 00:00:00 2001 From: microDev <70126934+microDev1@users.noreply.github.com> Date: Tue, 22 Sep 2020 23:47:10 +0530 Subject: [PATCH 011/207] Add function to disable alarm --- ports/esp32s2/common-hal/io_alarm/__init__.c | 20 +++++++------- .../esp32s2/common-hal/time_alarm/__init__.c | 3 +++ shared-bindings/io_alarm/__init__.c | 26 ++++++++++++++++--- shared-bindings/io_alarm/__init__.h | 11 +++++++- shared-bindings/time_alarm/__init__.c | 21 ++++++++++++++- shared-bindings/time_alarm/__init__.h | 7 +++++ 6 files changed, 73 insertions(+), 15 deletions(-) diff --git a/ports/esp32s2/common-hal/io_alarm/__init__.c b/ports/esp32s2/common-hal/io_alarm/__init__.c index d88c147fe0..5d926d4e93 100644 --- a/ports/esp32s2/common-hal/io_alarm/__init__.c +++ b/ports/esp32s2/common-hal/io_alarm/__init__.c @@ -3,25 +3,25 @@ #include "esp_sleep.h" #include "driver/rtc_io.h" -void common_hal_io_alarm_pin_state (uint8_t gpio, uint8_t level, bool pull) { - if (!rtc_gpio_is_valid_gpio(gpio)) { - mp_raise_ValueError(translate("io must be rtc io")); - return; +mp_obj_t common_hal_io_alarm_pin_state (io_alarm_obj_t *self_in) { + if (!rtc_gpio_is_valid_gpio(self_in->gpio)) { + mp_raise_ValueError(translate("io must be rtc io")); } - switch(esp_sleep_enable_ext0_wakeup(gpio, level)) { + switch(esp_sleep_enable_ext0_wakeup(self_in->gpio, self_in->level)) { case ESP_ERR_INVALID_ARG: mp_raise_ValueError(translate("trigger level must be 0 or 1")); - return; case ESP_ERR_INVALID_STATE: mp_raise_RuntimeError(translate("wakeup conflict")); - return; default: break; } - if (pull) { - (level) ? rtc_gpio_pulldown_en(gpio) : rtc_gpio_pullup_en(gpio); - } + if (self_in->pull) { (self_in->level) ? rtc_gpio_pulldown_en(self_in->gpio) : rtc_gpio_pullup_en(self_in->gpio); } + + return self_in; } +void common_hal_io_alarm_disable (void) { + esp_sleep_disable_wakeup_source(ESP_SLEEP_WAKEUP_EXT0 | ESP_SLEEP_WAKEUP_EXT1); +} diff --git a/ports/esp32s2/common-hal/time_alarm/__init__.c b/ports/esp32s2/common-hal/time_alarm/__init__.c index 342ca9d154..a33376bb09 100644 --- a/ports/esp32s2/common-hal/time_alarm/__init__.c +++ b/ports/esp32s2/common-hal/time_alarm/__init__.c @@ -8,3 +8,6 @@ void common_hal_time_alarm_duration (uint32_t ms) { } } +void common_hal_time_alarm_disable (void) { + esp_sleep_disable_wakeup_source(ESP_SLEEP_WAKEUP_TIMER); +} diff --git a/shared-bindings/io_alarm/__init__.c b/shared-bindings/io_alarm/__init__.c index 534b7e66f5..934b34e49d 100644 --- a/shared-bindings/io_alarm/__init__.c +++ b/shared-bindings/io_alarm/__init__.c @@ -3,7 +3,7 @@ #include "shared-bindings/io_alarm/__init__.h" #include "shared-bindings/microcontroller/Pin.h" -//| Set Timer Wakeup +//| Set Pin Wakeup //| STATIC mp_obj_t io_alarm_pin_state(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum { ARG_level, ARG_pull }; @@ -16,15 +16,30 @@ STATIC mp_obj_t io_alarm_pin_state(size_t n_args, const mp_obj_t *pos_args, mp_m mp_arg_parse_all(n_args - 1, pos_args + 1, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); mcu_pin_obj_t *pin = validate_obj_is_pin(pos_args[0]); - common_hal_io_alarm_pin_state(pin->number, args[ARG_level].u_int, args[ARG_pull].u_bool); + io_alarm_obj_t *self = m_new_obj(io_alarm_obj_t); - return mp_const_none; + self->base.type = &io_alarm_type; + self->gpio = pin->number; + self->level = args[ARG_level].u_int; + self->pull = args[ARG_pull].u_bool; + + return common_hal_io_alarm_pin_state(self); } STATIC MP_DEFINE_CONST_FUN_OBJ_KW(io_alarm_pin_state_obj, 1, io_alarm_pin_state); + +//| Disable Pin Wakeup +//| +STATIC mp_obj_t io_alarm_disable(void) { + common_hal_io_alarm_disable(); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_0(io_alarm_disable_obj, io_alarm_disable); + STATIC const mp_rom_map_elem_t io_alarm_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_io_alarm) }, { MP_OBJ_NEW_QSTR(MP_QSTR_PinState), MP_ROM_PTR(&io_alarm_pin_state_obj) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_Disable), MP_ROM_PTR(&io_alarm_disable_obj) }, }; STATIC MP_DEFINE_CONST_DICT(io_alarm_module_globals, io_alarm_module_globals_table); @@ -32,3 +47,8 @@ const mp_obj_module_t io_alarm_module = { .base = { &mp_type_module }, .globals = (mp_obj_dict_t*)&io_alarm_module_globals, }; + +const mp_obj_type_t io_alarm_type = { + { &mp_type_type }, + .name = MP_QSTR_ioAlarm, +}; diff --git a/shared-bindings/io_alarm/__init__.h b/shared-bindings/io_alarm/__init__.h index dd4b881657..2b91f781d5 100644 --- a/shared-bindings/io_alarm/__init__.h +++ b/shared-bindings/io_alarm/__init__.h @@ -3,6 +3,15 @@ #include "py/runtime.h" -extern void common_hal_io_alarm_pin_state(uint8_t gpio, uint8_t level, bool pull); +typedef struct { + mp_obj_base_t base; + uint8_t gpio, level; + bool pull; +} io_alarm_obj_t; + +extern const mp_obj_type_t io_alarm_type; + +extern mp_obj_t common_hal_io_alarm_pin_state (io_alarm_obj_t *self_in); +extern void common_hal_io_alarm_disable (void); #endif //MICROPY_INCLUDED_SHARED_BINDINGS_IO_ALARM___INIT___H diff --git a/shared-bindings/time_alarm/__init__.c b/shared-bindings/time_alarm/__init__.c index bfbece83c0..e45c5239f1 100644 --- a/shared-bindings/time_alarm/__init__.c +++ b/shared-bindings/time_alarm/__init__.c @@ -11,17 +11,31 @@ STATIC mp_obj_t time_alarm_duration(mp_obj_t 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_alarm_duration(msecs); - return mp_const_none; + + time_alarm_obj_t *self = m_new_obj(time_alarm_obj_t); + self->base.type = &time_alarm_type; + + return self; } STATIC MP_DEFINE_CONST_FUN_OBJ_1(time_alarm_duration_obj, time_alarm_duration); +//| Disable Timer Wakeup +//| +STATIC mp_obj_t time_alarm_disable(void) { + common_hal_time_alarm_disable(); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_0(time_alarm_disable_obj, time_alarm_disable); + STATIC const mp_rom_map_elem_t time_alarm_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_time_alarm) }, { MP_OBJ_NEW_QSTR(MP_QSTR_Duration), MP_ROM_PTR(&time_alarm_duration_obj) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_Disable), MP_ROM_PTR(&time_alarm_disable_obj) }, }; STATIC MP_DEFINE_CONST_DICT(time_alarm_module_globals, time_alarm_module_globals_table); @@ -29,3 +43,8 @@ const mp_obj_module_t time_alarm_module = { .base = { &mp_type_module }, .globals = (mp_obj_dict_t*)&time_alarm_module_globals, }; + +const mp_obj_type_t time_alarm_type = { + { &mp_type_type }, + .name = MP_QSTR_timeAlarm, +}; diff --git a/shared-bindings/time_alarm/__init__.h b/shared-bindings/time_alarm/__init__.h index 0913f7fded..52b6e89ee2 100644 --- a/shared-bindings/time_alarm/__init__.h +++ b/shared-bindings/time_alarm/__init__.h @@ -3,6 +3,13 @@ #include "py/runtime.h" +typedef struct { + mp_obj_base_t base; +} time_alarm_obj_t; + +extern const mp_obj_type_t time_alarm_type; + extern void common_hal_time_alarm_duration(uint32_t); +extern void common_hal_time_alarm_disable (void); #endif //MICROPY_INCLUDED_SHARED_BINDINGS_TIME_ALARM___INIT___H From e5ff55b15c8cc67c2ece3b8857b5805109b858b3 Mon Sep 17 00:00:00 2001 From: microDev <70126934+microDev1@users.noreply.github.com> Date: Wed, 23 Sep 2020 12:54:07 +0530 Subject: [PATCH 012/207] Renamed alarm modules --- .../{io_alarm => alarm_io}/__init__.c | 6 +-- .../{time_alarm => alarm_time}/__init__.c | 6 +-- .../common-hal/microcontroller/__init__.c | 8 +-- ports/esp32s2/mpconfigport.mk | 4 +- py/circuitpy_defns.mk | 12 ++--- py/circuitpy_mpconfig.h | 20 +++---- py/circuitpy_mpconfig.mk | 8 +-- shared-bindings/alarm_io/__init__.c | 54 +++++++++++++++++++ shared-bindings/alarm_io/__init__.h | 17 ++++++ shared-bindings/alarm_time/__init__.c | 50 +++++++++++++++++ shared-bindings/alarm_time/__init__.h | 15 ++++++ shared-bindings/io_alarm/__init__.c | 54 ------------------- shared-bindings/io_alarm/__init__.h | 17 ------ shared-bindings/microcontroller/__init__.h | 4 +- shared-bindings/time_alarm/__init__.c | 50 ----------------- shared-bindings/time_alarm/__init__.h | 15 ------ 16 files changed, 170 insertions(+), 170 deletions(-) rename ports/esp32s2/common-hal/{io_alarm => alarm_io}/__init__.c (83%) rename ports/esp32s2/common-hal/{time_alarm => alarm_time}/__init__.c (62%) create mode 100644 shared-bindings/alarm_io/__init__.c create mode 100644 shared-bindings/alarm_io/__init__.h create mode 100644 shared-bindings/alarm_time/__init__.c create mode 100644 shared-bindings/alarm_time/__init__.h delete mode 100644 shared-bindings/io_alarm/__init__.c delete mode 100644 shared-bindings/io_alarm/__init__.h delete mode 100644 shared-bindings/time_alarm/__init__.c delete mode 100644 shared-bindings/time_alarm/__init__.h diff --git a/ports/esp32s2/common-hal/io_alarm/__init__.c b/ports/esp32s2/common-hal/alarm_io/__init__.c similarity index 83% rename from ports/esp32s2/common-hal/io_alarm/__init__.c rename to ports/esp32s2/common-hal/alarm_io/__init__.c index 5d926d4e93..9aa28f4156 100644 --- a/ports/esp32s2/common-hal/io_alarm/__init__.c +++ b/ports/esp32s2/common-hal/alarm_io/__init__.c @@ -1,9 +1,9 @@ -#include "shared-bindings/io_alarm/__init__.h" +#include "shared-bindings/alarm_io/__init__.h" #include "esp_sleep.h" #include "driver/rtc_io.h" -mp_obj_t common_hal_io_alarm_pin_state (io_alarm_obj_t *self_in) { +mp_obj_t common_hal_alarm_io_pin_state (alarm_io_obj_t *self_in) { if (!rtc_gpio_is_valid_gpio(self_in->gpio)) { mp_raise_ValueError(translate("io must be rtc io")); } @@ -22,6 +22,6 @@ mp_obj_t common_hal_io_alarm_pin_state (io_alarm_obj_t *self_in) { return self_in; } -void common_hal_io_alarm_disable (void) { +void common_hal_alarm_io_disable (void) { esp_sleep_disable_wakeup_source(ESP_SLEEP_WAKEUP_EXT0 | ESP_SLEEP_WAKEUP_EXT1); } diff --git a/ports/esp32s2/common-hal/time_alarm/__init__.c b/ports/esp32s2/common-hal/alarm_time/__init__.c similarity index 62% rename from ports/esp32s2/common-hal/time_alarm/__init__.c rename to ports/esp32s2/common-hal/alarm_time/__init__.c index a33376bb09..fb601e6be0 100644 --- a/ports/esp32s2/common-hal/time_alarm/__init__.c +++ b/ports/esp32s2/common-hal/alarm_time/__init__.c @@ -1,13 +1,13 @@ #include "esp_sleep.h" -#include "shared-bindings/time_alarm/__init__.h" +#include "shared-bindings/alarm_time/__init__.h" -void common_hal_time_alarm_duration (uint32_t ms) { +void common_hal_alarm_time_duration (uint32_t ms) { if (esp_sleep_enable_timer_wakeup((ms) * 1000) == ESP_ERR_INVALID_ARG) { mp_raise_ValueError(translate("time out of range")); } } -void common_hal_time_alarm_disable (void) { +void common_hal_alarm_time_disable (void) { esp_sleep_disable_wakeup_source(ESP_SLEEP_WAKEUP_TIMER); } diff --git a/ports/esp32s2/common-hal/microcontroller/__init__.c b/ports/esp32s2/common-hal/microcontroller/__init__.c index 8b9fef2f98..e79c602020 100644 --- a/ports/esp32s2/common-hal/microcontroller/__init__.c +++ b/ports/esp32s2/common-hal/microcontroller/__init__.c @@ -99,13 +99,13 @@ mp_obj_t common_hal_mcu_get_wake_alarm(void) { switch (esp_sleep_get_wakeup_cause()) { case ESP_SLEEP_WAKEUP_TIMER: ; //Wake up from timer. - time_alarm_obj_t *timer = m_new_obj(time_alarm_obj_t); - timer->base.type = &time_alarm_type; + alarm_time_obj_t *timer = m_new_obj(alarm_time_obj_t); + timer->base.type = &alarm_time_type; return timer; case ESP_SLEEP_WAKEUP_EXT0: ; //Wake up from GPIO - io_alarm_obj_t *ext0 = m_new_obj(io_alarm_obj_t); - ext0->base.type = &io_alarm_type; + alarm_io_obj_t *ext0 = m_new_obj(alarm_io_obj_t); + ext0->base.type = &alarm_io_type; return ext0; case ESP_SLEEP_WAKEUP_EXT1: //Wake up from GPIO, returns -> esp_sleep_get_ext1_wakeup_status() diff --git a/ports/esp32s2/mpconfigport.mk b/ports/esp32s2/mpconfigport.mk index 0f8f3ada53..4aaf1d00c7 100644 --- a/ports/esp32s2/mpconfigport.mk +++ b/ports/esp32s2/mpconfigport.mk @@ -22,8 +22,8 @@ CIRCUITPY_FREQUENCYIO = 0 CIRCUITPY_I2CPERIPHERAL = 0 CIRCUITPY_ROTARYIO = 0 CIRCUITPY_NVM = 0 -CIRCUITPY_TIME_ALARM = 1 -CIRCUITPY_IO_ALARM = 1 +CIRCUITPY_ALARM_TIME = 1 +CIRCUITPY_ALARM_IO = 1 # We don't have enough endpoints to include MIDI. CIRCUITPY_USB_MIDI = 0 CIRCUITPY_WIFI = 1 diff --git a/py/circuitpy_defns.mk b/py/circuitpy_defns.mk index 672eeda40c..4c57165936 100644 --- a/py/circuitpy_defns.mk +++ b/py/circuitpy_defns.mk @@ -259,11 +259,11 @@ endif ifeq ($(CIRCUITPY_TIME),1) SRC_PATTERNS += time/% endif -ifeq ($(CIRCUITPY_TIME_ALARM),1) -SRC_PATTERNS += time_alarm/% +ifeq ($(CIRCUITPY_ALARM_TIME),1) +SRC_PATTERNS += alarm_time/% endif -ifeq ($(CIRCUITPY_IO_ALARM),1) -SRC_PATTERNS += io_alarm/% +ifeq ($(CIRCUITPY_ALARM_IO),1) +SRC_PATTERNS += alarm_io/% endif ifeq ($(CIRCUITPY_TOUCHIO),1) SRC_PATTERNS += touchio/% @@ -366,8 +366,8 @@ SRC_COMMON_HAL_ALL = \ ssl/SSLContext.c \ supervisor/Runtime.c \ supervisor/__init__.c \ - time_alarm/__init__.c \ - io_alarm/__init__.c \ + alarm_time/__init__.c \ + alarm_io/__init__.c \ watchdog/WatchDogMode.c \ watchdog/WatchDogTimer.c \ watchdog/__init__.c \ diff --git a/py/circuitpy_mpconfig.h b/py/circuitpy_mpconfig.h index d899ecacb6..94072f580b 100644 --- a/py/circuitpy_mpconfig.h +++ b/py/circuitpy_mpconfig.h @@ -663,18 +663,18 @@ extern const struct _mp_obj_module_t time_module; #define TIME_MODULE_ALT_NAME #endif -#if CIRCUITPY_TIME_ALARM -extern const struct _mp_obj_module_t time_alarm_module; -#define TIME_ALARM_MODULE { MP_OBJ_NEW_QSTR(MP_QSTR_time_alarm), (mp_obj_t)&time_alarm_module }, +#if CIRCUITPY_ALARM_TIME +extern const struct _mp_obj_module_t alarm_time_module; +#define ALARM_TIME_MODULE { MP_OBJ_NEW_QSTR(MP_QSTR_alarm_time), (mp_obj_t)&alarm_time_module }, #else -#define TIME_ALARM_MODULE +#define ALARM_TIME_MODULE #endif -#if CIRCUITPY_IO_ALARM -extern const struct _mp_obj_module_t io_alarm_module; -#define IO_ALARM_MODULE { MP_OBJ_NEW_QSTR(MP_QSTR_io_alarm), (mp_obj_t)&io_alarm_module }, +#if CIRCUITPY_ALARM_IO +extern const struct _mp_obj_module_t alarm_io_module; +#define ALARM_IO_MODULE { MP_OBJ_NEW_QSTR(MP_QSTR_alarm_io), (mp_obj_t)&alarm_io_module }, #else -#define IO_ALARM_MODULE +#define ALARM_IO_MODULE #endif #if CIRCUITPY_TOUCHIO @@ -835,8 +835,8 @@ extern const struct _mp_obj_module_t wifi_module; STRUCT_MODULE \ SUPERVISOR_MODULE \ TOUCHIO_MODULE \ - TIME_ALARM_MODULE \ - IO_ALARM_MODULE \ + ALARM_TIME_MODULE \ + ALARM_IO_MODULE \ UHEAP_MODULE \ USB_HID_MODULE \ USB_MIDI_MODULE \ diff --git a/py/circuitpy_mpconfig.mk b/py/circuitpy_mpconfig.mk index 4cce2a0a1a..e8619347dd 100644 --- a/py/circuitpy_mpconfig.mk +++ b/py/circuitpy_mpconfig.mk @@ -234,11 +234,11 @@ CFLAGS += -DCIRCUITPY_TERMINALIO=$(CIRCUITPY_TERMINALIO) CIRCUITPY_TIME ?= 1 CFLAGS += -DCIRCUITPY_TIME=$(CIRCUITPY_TIME) -CIRCUITPY_TIME_ALARM ?= 0 -CFLAGS += -DCIRCUITPY_TIME_ALARM=$(CIRCUITPY_TIME_ALARM) +CIRCUITPY_ALARM_TIME ?= 0 +CFLAGS += -DCIRCUITPY_ALARM_TIME=$(CIRCUITPY_ALARM_TIME) -CIRCUITPY_IO_ALARM ?= 0 -CFLAGS += -DCIRCUITPY_IO_ALARM=$(CIRCUITPY_IO_ALARM) +CIRCUITPY_ALARM_IO ?= 0 +CFLAGS += -DCIRCUITPY_ALARM_IO=$(CIRCUITPY_ALARM_IO) # touchio might be native or generic. See circuitpy_defns.mk. CIRCUITPY_TOUCHIO_USE_NATIVE ?= 0 diff --git a/shared-bindings/alarm_io/__init__.c b/shared-bindings/alarm_io/__init__.c new file mode 100644 index 0000000000..09783d0d08 --- /dev/null +++ b/shared-bindings/alarm_io/__init__.c @@ -0,0 +1,54 @@ +#include "py/obj.h" + +#include "shared-bindings/alarm_io/__init__.h" +#include "shared-bindings/microcontroller/Pin.h" + +//| Set Pin Wakeup +//| +STATIC mp_obj_t alarm_io_pin_state(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { + enum { ARG_level, ARG_pull }; + static const mp_arg_t allowed_args[] = { + { MP_QSTR_level, MP_ARG_INT | MP_ARG_KW_ONLY | MP_ARG_REQUIRED }, + { MP_QSTR_pull, MP_ARG_INT | MP_ARG_KW_ONLY, {.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); + + mcu_pin_obj_t *pin = validate_obj_is_pin(pos_args[0]); + alarm_io_obj_t *self = m_new_obj(alarm_io_obj_t); + + self->base.type = &alarm_io_type; + self->gpio = pin->number; + self->level = args[ARG_level].u_int; + self->pull = args[ARG_pull].u_bool; + + return common_hal_alarm_io_pin_state(self); +} +STATIC MP_DEFINE_CONST_FUN_OBJ_KW(alarm_io_pin_state_obj, 1, alarm_io_pin_state); + + +//| Disable Pin Wakeup +//| +STATIC mp_obj_t alarm_io_disable(void) { + common_hal_alarm_io_disable(); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_0(alarm_io_disable_obj, alarm_io_disable); + +STATIC const mp_rom_map_elem_t alarm_io_module_globals_table[] = { + { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_alarm_io) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_PinState), MP_ROM_PTR(&alarm_io_pin_state_obj) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_Disable), MP_ROM_PTR(&alarm_io_disable_obj) }, +}; +STATIC MP_DEFINE_CONST_DICT(alarm_io_module_globals, alarm_io_module_globals_table); + +const mp_obj_module_t alarm_io_module = { + .base = { &mp_type_module }, + .globals = (mp_obj_dict_t*)&alarm_io_module_globals, +}; + +const mp_obj_type_t alarm_io_type = { + { &mp_type_type }, + .name = MP_QSTR_ioAlarm, +}; diff --git a/shared-bindings/alarm_io/__init__.h b/shared-bindings/alarm_io/__init__.h new file mode 100644 index 0000000000..0a53497c01 --- /dev/null +++ b/shared-bindings/alarm_io/__init__.h @@ -0,0 +1,17 @@ +#ifndef MICROPY_INCLUDED_SHARED_BINDINGS_ALARM_IO___INIT___H +#define MICROPY_INCLUDED_SHARED_BINDINGS_ALARM_IO___INIT___H + +#include "py/runtime.h" + +typedef struct { + mp_obj_base_t base; + uint8_t gpio, level; + bool pull; +} alarm_io_obj_t; + +extern const mp_obj_type_t alarm_io_type; + +extern mp_obj_t common_hal_alarm_io_pin_state (alarm_io_obj_t *self_in); +extern void common_hal_alarm_io_disable (void); + +#endif //MICROPY_INCLUDED_SHARED_BINDINGS_ALARM_IO___INIT___H diff --git a/shared-bindings/alarm_time/__init__.c b/shared-bindings/alarm_time/__init__.c new file mode 100644 index 0000000000..22fb935064 --- /dev/null +++ b/shared-bindings/alarm_time/__init__.c @@ -0,0 +1,50 @@ +#include "py/obj.h" +#include "shared-bindings/alarm_time/__init__.h" + +//| Set Timer Wakeup +//| +STATIC mp_obj_t alarm_time_duration(mp_obj_t seconds_o) { + #if MICROPY_PY_BUILTINS_FLOAT + mp_float_t seconds = mp_obj_get_float(seconds_o); + mp_float_t msecs = 1000.0f * seconds + 0.5f; + #else + 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_alarm_time_duration(msecs); + + alarm_time_obj_t *self = m_new_obj(alarm_time_obj_t); + self->base.type = &alarm_time_type; + + return self; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_1(alarm_time_duration_obj, alarm_time_duration); + +//| Disable Timer Wakeup +//| +STATIC mp_obj_t alarm_time_disable(void) { + common_hal_alarm_time_disable(); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_0(alarm_time_disable_obj, alarm_time_disable); + +STATIC const mp_rom_map_elem_t alarm_time_module_globals_table[] = { + { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_alarm_time) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_Duration), MP_ROM_PTR(&alarm_time_duration_obj) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_Disable), MP_ROM_PTR(&alarm_time_disable_obj) }, +}; +STATIC MP_DEFINE_CONST_DICT(alarm_time_module_globals, alarm_time_module_globals_table); + +const mp_obj_module_t alarm_time_module = { + .base = { &mp_type_module }, + .globals = (mp_obj_dict_t*)&alarm_time_module_globals, +}; + +const mp_obj_type_t alarm_time_type = { + { &mp_type_type }, + .name = MP_QSTR_timeAlarm, +}; diff --git a/shared-bindings/alarm_time/__init__.h b/shared-bindings/alarm_time/__init__.h new file mode 100644 index 0000000000..d69aa5a443 --- /dev/null +++ b/shared-bindings/alarm_time/__init__.h @@ -0,0 +1,15 @@ +#ifndef MICROPY_INCLUDED_SHARED_BINDINGS_ALARM_TIME___INIT___H +#define MICROPY_INCLUDED_SHARED_BINDINGS_ALARM_TIME___INIT___H + +#include "py/runtime.h" + +typedef struct { + mp_obj_base_t base; +} alarm_time_obj_t; + +extern const mp_obj_type_t alarm_time_type; + +extern void common_hal_alarm_time_duration(uint32_t); +extern void common_hal_alarm_time_disable (void); + +#endif //MICROPY_INCLUDED_SHARED_BINDINGS_ALARM_TIME___INIT___H diff --git a/shared-bindings/io_alarm/__init__.c b/shared-bindings/io_alarm/__init__.c deleted file mode 100644 index 934b34e49d..0000000000 --- a/shared-bindings/io_alarm/__init__.c +++ /dev/null @@ -1,54 +0,0 @@ -#include "py/obj.h" - -#include "shared-bindings/io_alarm/__init__.h" -#include "shared-bindings/microcontroller/Pin.h" - -//| Set Pin Wakeup -//| -STATIC mp_obj_t io_alarm_pin_state(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { - enum { ARG_level, ARG_pull }; - static const mp_arg_t allowed_args[] = { - { MP_QSTR_level, MP_ARG_INT | MP_ARG_KW_ONLY | MP_ARG_REQUIRED }, - { MP_QSTR_pull, MP_ARG_INT | MP_ARG_KW_ONLY, {.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); - - mcu_pin_obj_t *pin = validate_obj_is_pin(pos_args[0]); - io_alarm_obj_t *self = m_new_obj(io_alarm_obj_t); - - self->base.type = &io_alarm_type; - self->gpio = pin->number; - self->level = args[ARG_level].u_int; - self->pull = args[ARG_pull].u_bool; - - return common_hal_io_alarm_pin_state(self); -} -STATIC MP_DEFINE_CONST_FUN_OBJ_KW(io_alarm_pin_state_obj, 1, io_alarm_pin_state); - - -//| Disable Pin Wakeup -//| -STATIC mp_obj_t io_alarm_disable(void) { - common_hal_io_alarm_disable(); - return mp_const_none; -} -STATIC MP_DEFINE_CONST_FUN_OBJ_0(io_alarm_disable_obj, io_alarm_disable); - -STATIC const mp_rom_map_elem_t io_alarm_module_globals_table[] = { - { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_io_alarm) }, - { MP_OBJ_NEW_QSTR(MP_QSTR_PinState), MP_ROM_PTR(&io_alarm_pin_state_obj) }, - { MP_OBJ_NEW_QSTR(MP_QSTR_Disable), MP_ROM_PTR(&io_alarm_disable_obj) }, -}; -STATIC MP_DEFINE_CONST_DICT(io_alarm_module_globals, io_alarm_module_globals_table); - -const mp_obj_module_t io_alarm_module = { - .base = { &mp_type_module }, - .globals = (mp_obj_dict_t*)&io_alarm_module_globals, -}; - -const mp_obj_type_t io_alarm_type = { - { &mp_type_type }, - .name = MP_QSTR_ioAlarm, -}; diff --git a/shared-bindings/io_alarm/__init__.h b/shared-bindings/io_alarm/__init__.h deleted file mode 100644 index 2b91f781d5..0000000000 --- a/shared-bindings/io_alarm/__init__.h +++ /dev/null @@ -1,17 +0,0 @@ -#ifndef MICROPY_INCLUDED_SHARED_BINDINGS_IO_ALARM___INIT___H -#define MICROPY_INCLUDED_SHARED_BINDINGS_IO_ALARM___INIT___H - -#include "py/runtime.h" - -typedef struct { - mp_obj_base_t base; - uint8_t gpio, level; - bool pull; -} io_alarm_obj_t; - -extern const mp_obj_type_t io_alarm_type; - -extern mp_obj_t common_hal_io_alarm_pin_state (io_alarm_obj_t *self_in); -extern void common_hal_io_alarm_disable (void); - -#endif //MICROPY_INCLUDED_SHARED_BINDINGS_IO_ALARM___INIT___H diff --git a/shared-bindings/microcontroller/__init__.h b/shared-bindings/microcontroller/__init__.h index f0a3cee2df..cd234fb033 100644 --- a/shared-bindings/microcontroller/__init__.h +++ b/shared-bindings/microcontroller/__init__.h @@ -35,8 +35,8 @@ #include "shared-bindings/microcontroller/RunMode.h" -#include "shared-bindings/io_alarm/__init__.h" -#include "shared-bindings/time_alarm/__init__.h" +#include "shared-bindings/alarm_io/__init__.h" +#include "shared-bindings/alarm_time/__init__.h" extern void common_hal_mcu_delay_us(uint32_t); diff --git a/shared-bindings/time_alarm/__init__.c b/shared-bindings/time_alarm/__init__.c deleted file mode 100644 index e45c5239f1..0000000000 --- a/shared-bindings/time_alarm/__init__.c +++ /dev/null @@ -1,50 +0,0 @@ -#include "py/obj.h" -#include "shared-bindings/time_alarm/__init__.h" - -//| Set Timer Wakeup -//| -STATIC mp_obj_t time_alarm_duration(mp_obj_t seconds_o) { - #if MICROPY_PY_BUILTINS_FLOAT - mp_float_t seconds = mp_obj_get_float(seconds_o); - mp_float_t msecs = 1000.0f * seconds + 0.5f; - #else - 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_alarm_duration(msecs); - - time_alarm_obj_t *self = m_new_obj(time_alarm_obj_t); - self->base.type = &time_alarm_type; - - return self; -} -STATIC MP_DEFINE_CONST_FUN_OBJ_1(time_alarm_duration_obj, time_alarm_duration); - -//| Disable Timer Wakeup -//| -STATIC mp_obj_t time_alarm_disable(void) { - common_hal_time_alarm_disable(); - return mp_const_none; -} -STATIC MP_DEFINE_CONST_FUN_OBJ_0(time_alarm_disable_obj, time_alarm_disable); - -STATIC const mp_rom_map_elem_t time_alarm_module_globals_table[] = { - { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_time_alarm) }, - { MP_OBJ_NEW_QSTR(MP_QSTR_Duration), MP_ROM_PTR(&time_alarm_duration_obj) }, - { MP_OBJ_NEW_QSTR(MP_QSTR_Disable), MP_ROM_PTR(&time_alarm_disable_obj) }, -}; -STATIC MP_DEFINE_CONST_DICT(time_alarm_module_globals, time_alarm_module_globals_table); - -const mp_obj_module_t time_alarm_module = { - .base = { &mp_type_module }, - .globals = (mp_obj_dict_t*)&time_alarm_module_globals, -}; - -const mp_obj_type_t time_alarm_type = { - { &mp_type_type }, - .name = MP_QSTR_timeAlarm, -}; diff --git a/shared-bindings/time_alarm/__init__.h b/shared-bindings/time_alarm/__init__.h deleted file mode 100644 index 52b6e89ee2..0000000000 --- a/shared-bindings/time_alarm/__init__.h +++ /dev/null @@ -1,15 +0,0 @@ -#ifndef MICROPY_INCLUDED_SHARED_BINDINGS_TIME_ALARM___INIT___H -#define MICROPY_INCLUDED_SHARED_BINDINGS_TIME_ALARM___INIT___H - -#include "py/runtime.h" - -typedef struct { - mp_obj_base_t base; -} time_alarm_obj_t; - -extern const mp_obj_type_t time_alarm_type; - -extern void common_hal_time_alarm_duration(uint32_t); -extern void common_hal_time_alarm_disable (void); - -#endif //MICROPY_INCLUDED_SHARED_BINDINGS_TIME_ALARM___INIT___H From 4d8ffdca8dc570f63c34b8f02856feae2d880688 Mon Sep 17 00:00:00 2001 From: microDev <70126934+microDev1@users.noreply.github.com> Date: Thu, 24 Sep 2020 10:59:04 +0530 Subject: [PATCH 013/207] restructure alarm modules --- ports/esp32s2/common-hal/alarm/__init__.c | 84 +++++++++++++++++++ ports/esp32s2/common-hal/alarm/__init__.h | 6 ++ .../common-hal/microcontroller/__init__.c | 48 +---------- ports/esp32s2/mpconfigport.mk | 6 +- ports/esp32s2/supervisor/port.c | 7 +- py/circuitpy_defns.mk | 20 +++-- py/circuitpy_mpconfig.h | 40 +++++---- py/circuitpy_mpconfig.mk | 15 ++-- shared-bindings/alarm/__init__.c | 32 +++++++ shared-bindings/alarm/__init__.h | 12 +++ shared-bindings/alarm_time/__init__.h | 2 +- shared-bindings/microcontroller/__init__.c | 21 ----- shared-bindings/microcontroller/__init__.h | 7 +- 13 files changed, 191 insertions(+), 109 deletions(-) create mode 100644 ports/esp32s2/common-hal/alarm/__init__.c create mode 100644 ports/esp32s2/common-hal/alarm/__init__.h create mode 100644 shared-bindings/alarm/__init__.c create mode 100644 shared-bindings/alarm/__init__.h diff --git a/ports/esp32s2/common-hal/alarm/__init__.c b/ports/esp32s2/common-hal/alarm/__init__.c new file mode 100644 index 0000000000..90e8e9ecc8 --- /dev/null +++ b/ports/esp32s2/common-hal/alarm/__init__.c @@ -0,0 +1,84 @@ +/* + * 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 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 + +#include "common-hal/alarm/__init__.h" +#include "shared-bindings/alarm/__init__.h" + +#include "esp_sleep.h" +#include "soc/rtc_periph.h" +#include "driver/rtc_io.h" + +static RTC_DATA_ATTR struct timeval sleep_enter_time; +static RTC_DATA_ATTR struct timeval sleep_exit_time; +static RTC_DATA_ATTR uint8_t wake_io; + +int common_hal_alarm_get_sleep_time(void) { + return (sleep_exit_time.tv_sec - sleep_enter_time.tv_sec) * 1000 + (sleep_exit_time.tv_usec - sleep_enter_time.tv_usec) / 1000; +} + +void RTC_IRAM_ATTR esp_wake_deep_sleep(void) { + esp_default_wake_deep_sleep(); + wake_io = rtc_gpio_get_level(6); + gettimeofday(&sleep_exit_time, NULL); +} + +mp_obj_t common_hal_alarm_get_wake_alarm(void) { + switch (esp_sleep_get_wakeup_cause()) { + case ESP_SLEEP_WAKEUP_TIMER: ; + //Wake up from timer. + alarm_time_obj_t *timer = m_new_obj(alarm_time_obj_t); + timer->base.type = &alarm_time_type; + return timer; + case ESP_SLEEP_WAKEUP_EXT0: ; + //Wake up from GPIO + /*alarm_io_obj_t *ext0 = m_new_obj(alarm_io_obj_t); + ext0->base.type = &alarm_io_type; + return ext0;*/ + return mp_obj_new_int(wake_io); + case ESP_SLEEP_WAKEUP_EXT1: + //Wake up from GPIO, returns -> esp_sleep_get_ext1_wakeup_status() + /*uint64_t wakeup_pin_mask = esp_sleep_get_ext1_wakeup_status(); + if (wakeup_pin_mask != 0) { + int pin = __builtin_ffsll(wakeup_pin_mask) - 1; + printf("Wake up from GPIO %d\n", pin); + } else { + printf("Wake up from GPIO\n"); + }*/ + break; + case ESP_SLEEP_WAKEUP_TOUCHPAD: + //TODO: implement TouchIO + //Wake up from touch on pad, returns -> esp_sleep_get_touchpad_wakeup_status() + break; + case ESP_SLEEP_WAKEUP_UNDEFINED: + default: + //Not a deep sleep reset + break; + } + return mp_const_none; +} diff --git a/ports/esp32s2/common-hal/alarm/__init__.h b/ports/esp32s2/common-hal/alarm/__init__.h new file mode 100644 index 0000000000..8ba5e2b04a --- /dev/null +++ b/ports/esp32s2/common-hal/alarm/__init__.h @@ -0,0 +1,6 @@ +#ifndef MICROPY_INCLUDED_ESP32S2_COMMON_HAL_MICROCONTROLLER_ALARM_H +#define MICROPY_INCLUDED_ESP32S2_COMMON_HAL_MICROCONTROLLER_ALARM_H + +extern void esp_wake_deep_sleep(void); + +#endif // MICROPY_INCLUDED_ESP32S2_COMMON_HAL_MICROCONTROLLER_ALARM_H \ No newline at end of file diff --git a/ports/esp32s2/common-hal/microcontroller/__init__.c b/ports/esp32s2/common-hal/microcontroller/__init__.c index e79c602020..ba24e1c48d 100644 --- a/ports/esp32s2/common-hal/microcontroller/__init__.c +++ b/ports/esp32s2/common-hal/microcontroller/__init__.c @@ -25,10 +25,8 @@ * THE SOFTWARE. */ -#include - -#include "py/mphal.h" #include "py/obj.h" +#include "py/mphal.h" #include "py/runtime.h" #include "common-hal/microcontroller/Pin.h" @@ -44,9 +42,6 @@ #include "freertos/FreeRTOS.h" #include "esp_sleep.h" -#include "soc/rtc_periph.h" - -static RTC_DATA_ATTR struct timeval sleep_enter_time; void common_hal_mcu_delay_us(uint32_t delay) { @@ -85,50 +80,9 @@ void common_hal_mcu_reset(void) { } void common_hal_mcu_sleep(void) { - gettimeofday(&sleep_enter_time, NULL); esp_deep_sleep_start(); } -int common_hal_mcu_get_sleep_time(void) { - struct timeval now; - gettimeofday(&now, NULL); - return (now.tv_sec - sleep_enter_time.tv_sec) * 1000 + (now.tv_usec - sleep_enter_time.tv_usec) / 1000; -} - -mp_obj_t common_hal_mcu_get_wake_alarm(void) { - switch (esp_sleep_get_wakeup_cause()) { - case ESP_SLEEP_WAKEUP_TIMER: ; - //Wake up from timer. - alarm_time_obj_t *timer = m_new_obj(alarm_time_obj_t); - timer->base.type = &alarm_time_type; - return timer; - case ESP_SLEEP_WAKEUP_EXT0: ; - //Wake up from GPIO - alarm_io_obj_t *ext0 = m_new_obj(alarm_io_obj_t); - ext0->base.type = &alarm_io_type; - return ext0; - case ESP_SLEEP_WAKEUP_EXT1: - //Wake up from GPIO, returns -> esp_sleep_get_ext1_wakeup_status() - /*uint64_t wakeup_pin_mask = esp_sleep_get_ext1_wakeup_status(); - if (wakeup_pin_mask != 0) { - int pin = __builtin_ffsll(wakeup_pin_mask) - 1; - printf("Wake up from GPIO %d\n", pin); - } else { - printf("Wake up from GPIO\n"); - }*/ - break; - case ESP_SLEEP_WAKEUP_TOUCHPAD: - //TODO: implement TouchIO - //Wake up from touch on pad, returns -> esp_sleep_get_touchpad_wakeup_status() - break; - case ESP_SLEEP_WAKEUP_UNDEFINED: - default: - //Not a deep sleep reset - break; - } - return mp_const_none; -} - // 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 = { diff --git a/ports/esp32s2/mpconfigport.mk b/ports/esp32s2/mpconfigport.mk index 4aaf1d00c7..1a78821d32 100644 --- a/ports/esp32s2/mpconfigport.mk +++ b/ports/esp32s2/mpconfigport.mk @@ -14,6 +14,9 @@ LONGINT_IMPL = MPZ # These modules are implemented in ports//common-hal: CIRCUITPY_FULL_BUILD = 1 +CIRCUITPY_ALARM = 1 +CIRCUITPY_ALARM_IO = 1 +CIRCUITPY_ALARM_TIME = 1 CIRCUITPY_AUDIOBUSIO = 0 CIRCUITPY_AUDIOIO = 0 CIRCUITPY_CANIO = 1 @@ -22,8 +25,7 @@ CIRCUITPY_FREQUENCYIO = 0 CIRCUITPY_I2CPERIPHERAL = 0 CIRCUITPY_ROTARYIO = 0 CIRCUITPY_NVM = 0 -CIRCUITPY_ALARM_TIME = 1 -CIRCUITPY_ALARM_IO = 1 + # We don't have enough endpoints to include MIDI. CIRCUITPY_USB_MIDI = 0 CIRCUITPY_WIFI = 1 diff --git a/ports/esp32s2/supervisor/port.c b/ports/esp32s2/supervisor/port.c index 0b9c03f747..98c064a8b7 100644 --- a/ports/esp32s2/supervisor/port.c +++ b/ports/esp32s2/supervisor/port.c @@ -34,13 +34,14 @@ #include "freertos/FreeRTOS.h" #include "freertos/task.h" -#include "common-hal/microcontroller/Pin.h" +#include "common-hal/alarm/__init__.h" #include "common-hal/analogio/AnalogOut.h" #include "common-hal/busio/I2C.h" #include "common-hal/busio/SPI.h" #include "common-hal/busio/UART.h" -#include "common-hal/pulseio/PulseIn.h" #include "common-hal/pwmio/PWMOut.h" +#include "common-hal/pulseio/PulseIn.h" +#include "common-hal/microcontroller/Pin.h" #include "common-hal/wifi/__init__.h" #include "supervisor/memory.h" #include "supervisor/shared/tick.h" @@ -87,6 +88,8 @@ safe_mode_t port_init(void) { return NO_HEAP; } + esp_wake_deep_sleep(); + return NO_SAFE_MODE; } diff --git a/py/circuitpy_defns.mk b/py/circuitpy_defns.mk index 4c57165936..cd25c01f23 100644 --- a/py/circuitpy_defns.mk +++ b/py/circuitpy_defns.mk @@ -99,6 +99,15 @@ endif ifeq ($(CIRCUITPY_AESIO),1) SRC_PATTERNS += aesio/% endif +ifeq ($(CIRCUITPY_ALARM),1) +SRC_PATTERNS += alarm/% +endif +ifeq ($(CIRCUITPY_ALARM_IO),1) +SRC_PATTERNS += alarm_io/% +endif +ifeq ($(CIRCUITPY_ALARM_TIME),1) +SRC_PATTERNS += alarm_time/% +endif ifeq ($(CIRCUITPY_ANALOGIO),1) SRC_PATTERNS += analogio/% endif @@ -259,12 +268,6 @@ endif ifeq ($(CIRCUITPY_TIME),1) SRC_PATTERNS += time/% endif -ifeq ($(CIRCUITPY_ALARM_TIME),1) -SRC_PATTERNS += alarm_time/% -endif -ifeq ($(CIRCUITPY_ALARM_IO),1) -SRC_PATTERNS += alarm_io/% -endif ifeq ($(CIRCUITPY_TOUCHIO),1) SRC_PATTERNS += touchio/% endif @@ -304,6 +307,9 @@ SRC_COMMON_HAL_ALL = \ _bleio/__init__.c \ _pew/PewPew.c \ _pew/__init__.c \ + alarm/__init__.c \ + alarm_io/__init__.c \ + alarm_time/__init__.c \ analogio/AnalogIn.c \ analogio/AnalogOut.c \ analogio/__init__.c \ @@ -366,8 +372,6 @@ SRC_COMMON_HAL_ALL = \ ssl/SSLContext.c \ supervisor/Runtime.c \ supervisor/__init__.c \ - alarm_time/__init__.c \ - alarm_io/__init__.c \ watchdog/WatchDogMode.c \ watchdog/WatchDogTimer.c \ watchdog/__init__.c \ diff --git a/py/circuitpy_mpconfig.h b/py/circuitpy_mpconfig.h index 94072f580b..778c3131b6 100644 --- a/py/circuitpy_mpconfig.h +++ b/py/circuitpy_mpconfig.h @@ -240,6 +240,27 @@ extern const struct _mp_obj_module_t aesio_module; #define AESIO_MODULE #endif +#if CIRCUITPY_ALARM +extern const struct _mp_obj_module_t alarm_module; +#define ALARM_MODULE { MP_OBJ_NEW_QSTR(MP_QSTR_alarm), (mp_obj_t)&alarm_module }, +#else +#define ALARM_MODULE +#endif + +#if CIRCUITPY_ALARM_IO +extern const struct _mp_obj_module_t alarm_io_module; +#define ALARM_IO_MODULE { MP_OBJ_NEW_QSTR(MP_QSTR_alarm_io), (mp_obj_t)&alarm_io_module }, +#else +#define ALARM_IO_MODULE +#endif + +#if CIRCUITPY_ALARM_TIME +extern const struct _mp_obj_module_t alarm_time_module; +#define ALARM_TIME_MODULE { MP_OBJ_NEW_QSTR(MP_QSTR_alarm_time), (mp_obj_t)&alarm_time_module }, +#else +#define ALARM_TIME_MODULE +#endif + #if CIRCUITPY_ANALOGIO #define ANALOGIO_MODULE { MP_OBJ_NEW_QSTR(MP_QSTR_analogio), (mp_obj_t)&analogio_module }, extern const struct _mp_obj_module_t analogio_module; @@ -663,20 +684,6 @@ extern const struct _mp_obj_module_t time_module; #define TIME_MODULE_ALT_NAME #endif -#if CIRCUITPY_ALARM_TIME -extern const struct _mp_obj_module_t alarm_time_module; -#define ALARM_TIME_MODULE { MP_OBJ_NEW_QSTR(MP_QSTR_alarm_time), (mp_obj_t)&alarm_time_module }, -#else -#define ALARM_TIME_MODULE -#endif - -#if CIRCUITPY_ALARM_IO -extern const struct _mp_obj_module_t alarm_io_module; -#define ALARM_IO_MODULE { MP_OBJ_NEW_QSTR(MP_QSTR_alarm_io), (mp_obj_t)&alarm_io_module }, -#else -#define ALARM_IO_MODULE -#endif - #if CIRCUITPY_TOUCHIO extern const struct _mp_obj_module_t touchio_module; #define TOUCHIO_MODULE { MP_OBJ_NEW_QSTR(MP_QSTR_touchio), (mp_obj_t)&touchio_module }, @@ -777,6 +784,9 @@ extern const struct _mp_obj_module_t wifi_module; // Some are omitted because they're in MICROPY_PORT_BUILTIN_MODULE_WEAK_LINKS above. #define MICROPY_PORT_BUILTIN_MODULES_STRONG_LINKS \ AESIO_MODULE \ + ALARM_MODULE \ + ALARM_IO_MODULE \ + ALARM_TIME_MODULE \ ANALOGIO_MODULE \ AUDIOBUSIO_MODULE \ AUDIOCORE_MODULE \ @@ -835,8 +845,6 @@ extern const struct _mp_obj_module_t wifi_module; STRUCT_MODULE \ SUPERVISOR_MODULE \ TOUCHIO_MODULE \ - ALARM_TIME_MODULE \ - ALARM_IO_MODULE \ UHEAP_MODULE \ USB_HID_MODULE \ USB_MIDI_MODULE \ diff --git a/py/circuitpy_mpconfig.mk b/py/circuitpy_mpconfig.mk index e8619347dd..c1790e5e35 100644 --- a/py/circuitpy_mpconfig.mk +++ b/py/circuitpy_mpconfig.mk @@ -39,6 +39,15 @@ CFLAGS += -DMICROPY_PY_ASYNC_AWAIT=$(MICROPY_PY_ASYNC_AWAIT) CIRCUITPY_AESIO ?= 0 CFLAGS += -DCIRCUITPY_AESIO=$(CIRCUITPY_AESIO) +CIRCUITPY_ALARM ?= 0 +CFLAGS += -DCIRCUITPY_ALARM=$(CIRCUITPY_ALARM) + +CIRCUITPY_ALARM_IO ?= 0 +CFLAGS += -DCIRCUITPY_ALARM_IO=$(CIRCUITPY_ALARM_IO) + +CIRCUITPY_ALARM_TIME ?= 0 +CFLAGS += -DCIRCUITPY_ALARM_TIME=$(CIRCUITPY_ALARM_TIME) + CIRCUITPY_ANALOGIO ?= 1 CFLAGS += -DCIRCUITPY_ANALOGIO=$(CIRCUITPY_ANALOGIO) @@ -234,12 +243,6 @@ CFLAGS += -DCIRCUITPY_TERMINALIO=$(CIRCUITPY_TERMINALIO) CIRCUITPY_TIME ?= 1 CFLAGS += -DCIRCUITPY_TIME=$(CIRCUITPY_TIME) -CIRCUITPY_ALARM_TIME ?= 0 -CFLAGS += -DCIRCUITPY_ALARM_TIME=$(CIRCUITPY_ALARM_TIME) - -CIRCUITPY_ALARM_IO ?= 0 -CFLAGS += -DCIRCUITPY_ALARM_IO=$(CIRCUITPY_ALARM_IO) - # touchio might be native or generic. See circuitpy_defns.mk. CIRCUITPY_TOUCHIO_USE_NATIVE ?= 0 CFLAGS += -DCIRCUITPY_TOUCHIO_USE_NATIVE=$(CIRCUITPY_TOUCHIO_USE_NATIVE) diff --git a/shared-bindings/alarm/__init__.c b/shared-bindings/alarm/__init__.c new file mode 100644 index 0000000000..51a3776934 --- /dev/null +++ b/shared-bindings/alarm/__init__.c @@ -0,0 +1,32 @@ +#include "shared-bindings/alarm/__init__.h" + +//| def getWakeAlarm() -> None: +//| """This returns the alarm that triggered wakeup, +//| also returns alarm specific parameters`. +//| +STATIC mp_obj_t alarm_get_wake_alarm(void) { + return common_hal_alarm_get_wake_alarm(); +} +STATIC MP_DEFINE_CONST_FUN_OBJ_0(alarm_get_wake_alarm_obj, alarm_get_wake_alarm); + +//| def getSleepTime() -> None: +//| """This returns the period of time in ms, +//| in which the board was in deep sleep`. +//| +STATIC mp_obj_t alarm_get_sleep_time(void) { + return mp_obj_new_int(common_hal_alarm_get_sleep_time()); +} +STATIC MP_DEFINE_CONST_FUN_OBJ_0(alarm_get_sleep_time_obj, alarm_get_sleep_time); + +STATIC const mp_rom_map_elem_t alarm_module_globals_table[] = { + { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_alarm) }, + { MP_ROM_QSTR(MP_QSTR_getSleepTime), MP_ROM_PTR(&alarm_get_sleep_time_obj) }, + { MP_ROM_QSTR(MP_QSTR_getWakeAlarm), MP_ROM_PTR(&alarm_get_wake_alarm_obj) }, +}; + +STATIC MP_DEFINE_CONST_DICT(alarm_module_globals, alarm_module_globals_table); + +const mp_obj_module_t alarm_module = { + .base = { &mp_type_module }, + .globals = (mp_obj_dict_t*)&alarm_module_globals, +}; diff --git a/shared-bindings/alarm/__init__.h b/shared-bindings/alarm/__init__.h new file mode 100644 index 0000000000..2289028eff --- /dev/null +++ b/shared-bindings/alarm/__init__.h @@ -0,0 +1,12 @@ +#ifndef MICROPY_INCLUDED_SHARED_BINDINGS_ALARM___INIT___H +#define MICROPY_INCLUDED_SHARED_BINDINGS_ALARM___INIT___H + +#include "py/obj.h" + +#include "shared-bindings/alarm_io/__init__.h" +#include "shared-bindings/alarm_time/__init__.h" + +extern int common_hal_alarm_get_sleep_time(void); +extern mp_obj_t common_hal_alarm_get_wake_alarm(void); + +#endif // MICROPY_INCLUDED_SHARED_BINDINGS_ALARM___INIT___H diff --git a/shared-bindings/alarm_time/__init__.h b/shared-bindings/alarm_time/__init__.h index d69aa5a443..a963830693 100644 --- a/shared-bindings/alarm_time/__init__.h +++ b/shared-bindings/alarm_time/__init__.h @@ -9,7 +9,7 @@ typedef struct { extern const mp_obj_type_t alarm_time_type; -extern void common_hal_alarm_time_duration(uint32_t); +extern void common_hal_alarm_time_duration (uint32_t); extern void common_hal_alarm_time_disable (void); #endif //MICROPY_INCLUDED_SHARED_BINDINGS_ALARM_TIME___INIT___H diff --git a/shared-bindings/microcontroller/__init__.c b/shared-bindings/microcontroller/__init__.c index 7b896d99b2..eb58a40982 100644 --- a/shared-bindings/microcontroller/__init__.c +++ b/shared-bindings/microcontroller/__init__.c @@ -39,7 +39,6 @@ #include "shared-bindings/microcontroller/Pin.h" #include "shared-bindings/microcontroller/Processor.h" -#include "py/runtime.h" #include "supervisor/shared/translate.h" //| """Pin references and cpu functionality @@ -152,24 +151,6 @@ STATIC mp_obj_t mcu_sleep(void) { } STATIC MP_DEFINE_CONST_FUN_OBJ_0(mcu_sleep_obj, mcu_sleep); -//| def getWakeAlarm() -> None: -//| """This returns the alarm that triggered wakeup, -//| also returns alarm specific parameters`. -//| -STATIC mp_obj_t mcu_get_wake_alarm(void) { - return common_hal_mcu_get_wake_alarm(); -} -STATIC MP_DEFINE_CONST_FUN_OBJ_0(mcu_get_wake_alarm_obj, mcu_get_wake_alarm); - -//| def getSleepTime() -> None: -//| """This returns the period of time in ms, -//| in which the board was in deep sleep`. -//| -STATIC mp_obj_t mcu_get_sleep_time(void) { - return mp_obj_new_int(common_hal_mcu_get_sleep_time()); -} -STATIC MP_DEFINE_CONST_FUN_OBJ_0(mcu_get_sleep_time_obj, mcu_get_sleep_time); - //| nvm: Optional[ByteArray] //| """Available non-volatile memory. //| This object is the sole instance of `nvm.ByteArray` when available or ``None`` otherwise. @@ -206,8 +187,6 @@ STATIC const mp_rom_map_elem_t mcu_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR_on_next_reset), MP_ROM_PTR(&mcu_on_next_reset_obj) }, { MP_ROM_QSTR(MP_QSTR_reset), MP_ROM_PTR(&mcu_reset_obj) }, { MP_ROM_QSTR(MP_QSTR_sleep), MP_ROM_PTR(&mcu_sleep_obj) }, - { MP_ROM_QSTR(MP_QSTR_getSleepTime), MP_ROM_PTR(&mcu_get_sleep_time_obj) }, - { MP_ROM_QSTR(MP_QSTR_getWakeAlarm), MP_ROM_PTR(&mcu_get_wake_alarm_obj) }, #if CIRCUITPY_INTERNAL_NVM_SIZE > 0 { MP_ROM_QSTR(MP_QSTR_nvm), MP_ROM_PTR(&common_hal_mcu_nvm_obj) }, #else diff --git a/shared-bindings/microcontroller/__init__.h b/shared-bindings/microcontroller/__init__.h index cd234fb033..95f1cf8fc7 100644 --- a/shared-bindings/microcontroller/__init__.h +++ b/shared-bindings/microcontroller/__init__.h @@ -28,16 +28,13 @@ #ifndef MICROPY_INCLUDED_SHARED_BINDINGS_MICROCONTROLLER___INIT___H #define MICROPY_INCLUDED_SHARED_BINDINGS_MICROCONTROLLER___INIT___H -#include "py/mpconfig.h" #include "py/obj.h" +#include "py/mpconfig.h" #include "common-hal/microcontroller/Processor.h" #include "shared-bindings/microcontroller/RunMode.h" -#include "shared-bindings/alarm_io/__init__.h" -#include "shared-bindings/alarm_time/__init__.h" - extern void common_hal_mcu_delay_us(uint32_t); extern void common_hal_mcu_disable_interrupts(void); @@ -47,8 +44,6 @@ extern void common_hal_mcu_on_next_reset(mcu_runmode_t runmode); extern void common_hal_mcu_reset(void); extern void common_hal_mcu_sleep(void); -extern int common_hal_mcu_get_sleep_time(void); -extern mp_obj_t common_hal_mcu_get_wake_alarm(void); extern const mp_obj_dict_t mcu_pin_globals; From da449723df14623647729954dd5427101070d01c Mon Sep 17 00:00:00 2001 From: microDev <70126934+microDev1@users.noreply.github.com> Date: Thu, 24 Sep 2020 15:01:36 +0530 Subject: [PATCH 014/207] Fix build error --- locale/circuitpython.pot | 13 +++++--- ports/esp32s2/common-hal/alarm/__init__.c | 38 +++-------------------- ports/esp32s2/common-hal/alarm/__init__.h | 6 ---- ports/esp32s2/supervisor/port.c | 5 +-- py/circuitpy_defns.mk | 2 +- shared-bindings/alarm/__init__.c | 14 --------- shared-bindings/alarm/__init__.h | 4 --- shared-bindings/alarm_io/__init__.c | 5 --- shared-bindings/alarm_time/__init__.c | 4 --- 9 files changed, 15 insertions(+), 76 deletions(-) delete mode 100644 ports/esp32s2/common-hal/alarm/__init__.h diff --git a/locale/circuitpython.pot b/locale/circuitpython.pot index 16c3dd973a..e344f4dd81 100644 --- a/locale/circuitpython.pot +++ b/locale/circuitpython.pot @@ -17,6 +17,13 @@ msgstr "" "Content-Type: text/plain; charset=CHARSET\n" "Content-Transfer-Encoding: 8bit\n" +#: main.c +msgid "" +"\n" +"\n" +"------ soft reboot ------\n" +msgstr "" + #: main.c msgid "" "\n" @@ -3303,7 +3310,7 @@ msgstr "" msgid "size is defined for ndarrays only" msgstr "" -#: shared-bindings/time/__init__.c +#: shared-bindings/alarm_time/__init__.c shared-bindings/time/__init__.c msgid "sleep length must be non-negative" msgstr "" @@ -3319,10 +3326,6 @@ msgstr "" msgid "small int overflow" msgstr "" -#: main.c -msgid "soft reboot\n" -msgstr "" - #: extmod/ulab/code/numerical/numerical.c msgid "sort argument must be an ndarray" msgstr "" diff --git a/ports/esp32s2/common-hal/alarm/__init__.c b/ports/esp32s2/common-hal/alarm/__init__.c index 90e8e9ecc8..89ff6865de 100644 --- a/ports/esp32s2/common-hal/alarm/__init__.c +++ b/ports/esp32s2/common-hal/alarm/__init__.c @@ -25,28 +25,11 @@ * THE SOFTWARE. */ -#include - -#include "common-hal/alarm/__init__.h" #include "shared-bindings/alarm/__init__.h" +#include "shared-bindings/alarm_io/__init__.h" +#include "shared-bindings/alarm_time/__init__.h" #include "esp_sleep.h" -#include "soc/rtc_periph.h" -#include "driver/rtc_io.h" - -static RTC_DATA_ATTR struct timeval sleep_enter_time; -static RTC_DATA_ATTR struct timeval sleep_exit_time; -static RTC_DATA_ATTR uint8_t wake_io; - -int common_hal_alarm_get_sleep_time(void) { - return (sleep_exit_time.tv_sec - sleep_enter_time.tv_sec) * 1000 + (sleep_exit_time.tv_usec - sleep_enter_time.tv_usec) / 1000; -} - -void RTC_IRAM_ATTR esp_wake_deep_sleep(void) { - esp_default_wake_deep_sleep(); - wake_io = rtc_gpio_get_level(6); - gettimeofday(&sleep_exit_time, NULL); -} mp_obj_t common_hal_alarm_get_wake_alarm(void) { switch (esp_sleep_get_wakeup_cause()) { @@ -57,23 +40,12 @@ mp_obj_t common_hal_alarm_get_wake_alarm(void) { return timer; case ESP_SLEEP_WAKEUP_EXT0: ; //Wake up from GPIO - /*alarm_io_obj_t *ext0 = m_new_obj(alarm_io_obj_t); + alarm_io_obj_t *ext0 = m_new_obj(alarm_io_obj_t); ext0->base.type = &alarm_io_type; - return ext0;*/ - return mp_obj_new_int(wake_io); - case ESP_SLEEP_WAKEUP_EXT1: - //Wake up from GPIO, returns -> esp_sleep_get_ext1_wakeup_status() - /*uint64_t wakeup_pin_mask = esp_sleep_get_ext1_wakeup_status(); - if (wakeup_pin_mask != 0) { - int pin = __builtin_ffsll(wakeup_pin_mask) - 1; - printf("Wake up from GPIO %d\n", pin); - } else { - printf("Wake up from GPIO\n"); - }*/ - break; + return ext0; case ESP_SLEEP_WAKEUP_TOUCHPAD: //TODO: implement TouchIO - //Wake up from touch on pad, returns -> esp_sleep_get_touchpad_wakeup_status() + //Wake up from touch on pad, esp_sleep_get_touchpad_wakeup_status() break; case ESP_SLEEP_WAKEUP_UNDEFINED: default: diff --git a/ports/esp32s2/common-hal/alarm/__init__.h b/ports/esp32s2/common-hal/alarm/__init__.h deleted file mode 100644 index 8ba5e2b04a..0000000000 --- a/ports/esp32s2/common-hal/alarm/__init__.h +++ /dev/null @@ -1,6 +0,0 @@ -#ifndef MICROPY_INCLUDED_ESP32S2_COMMON_HAL_MICROCONTROLLER_ALARM_H -#define MICROPY_INCLUDED_ESP32S2_COMMON_HAL_MICROCONTROLLER_ALARM_H - -extern void esp_wake_deep_sleep(void); - -#endif // MICROPY_INCLUDED_ESP32S2_COMMON_HAL_MICROCONTROLLER_ALARM_H \ No newline at end of file diff --git a/ports/esp32s2/supervisor/port.c b/ports/esp32s2/supervisor/port.c index 98c064a8b7..840b979632 100644 --- a/ports/esp32s2/supervisor/port.c +++ b/ports/esp32s2/supervisor/port.c @@ -34,7 +34,6 @@ #include "freertos/FreeRTOS.h" #include "freertos/task.h" -#include "common-hal/alarm/__init__.h" #include "common-hal/analogio/AnalogOut.h" #include "common-hal/busio/I2C.h" #include "common-hal/busio/SPI.h" @@ -87,9 +86,7 @@ safe_mode_t port_init(void) { if (heap == NULL) { return NO_HEAP; } - - esp_wake_deep_sleep(); - + return NO_SAFE_MODE; } diff --git a/py/circuitpy_defns.mk b/py/circuitpy_defns.mk index cd25c01f23..473536d530 100644 --- a/py/circuitpy_defns.mk +++ b/py/circuitpy_defns.mk @@ -309,7 +309,7 @@ SRC_COMMON_HAL_ALL = \ _pew/__init__.c \ alarm/__init__.c \ alarm_io/__init__.c \ - alarm_time/__init__.c \ + alarm_time/__init__.c \ analogio/AnalogIn.c \ analogio/AnalogOut.c \ analogio/__init__.c \ diff --git a/shared-bindings/alarm/__init__.c b/shared-bindings/alarm/__init__.c index 51a3776934..37462d88cc 100644 --- a/shared-bindings/alarm/__init__.c +++ b/shared-bindings/alarm/__init__.c @@ -1,26 +1,12 @@ #include "shared-bindings/alarm/__init__.h" -//| def getWakeAlarm() -> None: -//| """This returns the alarm that triggered wakeup, -//| also returns alarm specific parameters`. -//| STATIC mp_obj_t alarm_get_wake_alarm(void) { return common_hal_alarm_get_wake_alarm(); } STATIC MP_DEFINE_CONST_FUN_OBJ_0(alarm_get_wake_alarm_obj, alarm_get_wake_alarm); -//| def getSleepTime() -> None: -//| """This returns the period of time in ms, -//| in which the board was in deep sleep`. -//| -STATIC mp_obj_t alarm_get_sleep_time(void) { - return mp_obj_new_int(common_hal_alarm_get_sleep_time()); -} -STATIC MP_DEFINE_CONST_FUN_OBJ_0(alarm_get_sleep_time_obj, alarm_get_sleep_time); - STATIC const mp_rom_map_elem_t alarm_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_alarm) }, - { MP_ROM_QSTR(MP_QSTR_getSleepTime), MP_ROM_PTR(&alarm_get_sleep_time_obj) }, { MP_ROM_QSTR(MP_QSTR_getWakeAlarm), MP_ROM_PTR(&alarm_get_wake_alarm_obj) }, }; diff --git a/shared-bindings/alarm/__init__.h b/shared-bindings/alarm/__init__.h index 2289028eff..8b2cd9f770 100644 --- a/shared-bindings/alarm/__init__.h +++ b/shared-bindings/alarm/__init__.h @@ -3,10 +3,6 @@ #include "py/obj.h" -#include "shared-bindings/alarm_io/__init__.h" -#include "shared-bindings/alarm_time/__init__.h" - -extern int common_hal_alarm_get_sleep_time(void); extern mp_obj_t common_hal_alarm_get_wake_alarm(void); #endif // MICROPY_INCLUDED_SHARED_BINDINGS_ALARM___INIT___H diff --git a/shared-bindings/alarm_io/__init__.c b/shared-bindings/alarm_io/__init__.c index 09783d0d08..d772ccb796 100644 --- a/shared-bindings/alarm_io/__init__.c +++ b/shared-bindings/alarm_io/__init__.c @@ -3,8 +3,6 @@ #include "shared-bindings/alarm_io/__init__.h" #include "shared-bindings/microcontroller/Pin.h" -//| Set Pin Wakeup -//| STATIC mp_obj_t alarm_io_pin_state(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum { ARG_level, ARG_pull }; static const mp_arg_t allowed_args[] = { @@ -27,9 +25,6 @@ STATIC mp_obj_t alarm_io_pin_state(size_t n_args, const mp_obj_t *pos_args, mp_m } STATIC MP_DEFINE_CONST_FUN_OBJ_KW(alarm_io_pin_state_obj, 1, alarm_io_pin_state); - -//| Disable Pin Wakeup -//| STATIC mp_obj_t alarm_io_disable(void) { common_hal_alarm_io_disable(); return mp_const_none; diff --git a/shared-bindings/alarm_time/__init__.c b/shared-bindings/alarm_time/__init__.c index 22fb935064..d4474ea2de 100644 --- a/shared-bindings/alarm_time/__init__.c +++ b/shared-bindings/alarm_time/__init__.c @@ -1,8 +1,6 @@ #include "py/obj.h" #include "shared-bindings/alarm_time/__init__.h" -//| Set Timer Wakeup -//| STATIC mp_obj_t alarm_time_duration(mp_obj_t seconds_o) { #if MICROPY_PY_BUILTINS_FLOAT mp_float_t seconds = mp_obj_get_float(seconds_o); @@ -24,8 +22,6 @@ STATIC mp_obj_t alarm_time_duration(mp_obj_t seconds_o) { } STATIC MP_DEFINE_CONST_FUN_OBJ_1(alarm_time_duration_obj, alarm_time_duration); -//| Disable Timer Wakeup -//| STATIC mp_obj_t alarm_time_disable(void) { common_hal_alarm_time_disable(); return mp_const_none; From 59df1a11ade4a39d079c9f418740b45b4d6121ce Mon Sep 17 00:00:00 2001 From: microDev <70126934+microDev1@users.noreply.github.com> Date: Fri, 25 Sep 2020 00:28:50 +0530 Subject: [PATCH 015/207] Add alarm_touch module --- ports/esp32s2/common-hal/alarm/__init__.c | 10 ++++---- ports/esp32s2/common-hal/alarm_io/__init__.c | 12 +++++----- .../esp32s2/common-hal/alarm_time/__init__.c | 4 ++-- .../esp32s2/common-hal/alarm_touch/__init__.c | 7 ++++++ .../common-hal/microcontroller/__init__.c | 2 +- ports/esp32s2/mpconfigport.mk | 1 + ports/esp32s2/supervisor/port.c | 2 +- py/circuitpy_defns.mk | 4 ++++ py/circuitpy_mpconfig.h | 8 +++++++ py/circuitpy_mpconfig.mk | 3 +++ shared-bindings/alarm_io/__init__.c | 10 ++++---- shared-bindings/alarm_time/__init__.c | 4 ++-- shared-bindings/alarm_touch/__init__.c | 24 +++++++++++++++++++ shared-bindings/alarm_touch/__init__.h | 14 +++++++++++ shared-bindings/microcontroller/__init__.c | 9 ------- 15 files changed, 83 insertions(+), 31 deletions(-) create mode 100644 ports/esp32s2/common-hal/alarm_touch/__init__.c create mode 100644 shared-bindings/alarm_touch/__init__.c create mode 100644 shared-bindings/alarm_touch/__init__.h diff --git a/ports/esp32s2/common-hal/alarm/__init__.c b/ports/esp32s2/common-hal/alarm/__init__.c index 89ff6865de..46715d9bf6 100644 --- a/ports/esp32s2/common-hal/alarm/__init__.c +++ b/ports/esp32s2/common-hal/alarm/__init__.c @@ -36,17 +36,17 @@ mp_obj_t common_hal_alarm_get_wake_alarm(void) { case ESP_SLEEP_WAKEUP_TIMER: ; //Wake up from timer. alarm_time_obj_t *timer = m_new_obj(alarm_time_obj_t); - timer->base.type = &alarm_time_type; + timer->base.type = &alarm_time_type; return timer; case ESP_SLEEP_WAKEUP_EXT0: ; //Wake up from GPIO alarm_io_obj_t *ext0 = m_new_obj(alarm_io_obj_t); - ext0->base.type = &alarm_io_type; - return ext0; - case ESP_SLEEP_WAKEUP_TOUCHPAD: + ext0->base.type = &alarm_io_type; + return ext0; + case ESP_SLEEP_WAKEUP_TOUCHPAD: //TODO: implement TouchIO //Wake up from touch on pad, esp_sleep_get_touchpad_wakeup_status() - break; + break; case ESP_SLEEP_WAKEUP_UNDEFINED: default: //Not a deep sleep reset diff --git a/ports/esp32s2/common-hal/alarm_io/__init__.c b/ports/esp32s2/common-hal/alarm_io/__init__.c index 9aa28f4156..a98b933246 100644 --- a/ports/esp32s2/common-hal/alarm_io/__init__.c +++ b/ports/esp32s2/common-hal/alarm_io/__init__.c @@ -5,22 +5,22 @@ mp_obj_t common_hal_alarm_io_pin_state (alarm_io_obj_t *self_in) { if (!rtc_gpio_is_valid_gpio(self_in->gpio)) { - mp_raise_ValueError(translate("io must be rtc io")); - } + mp_raise_ValueError(translate("io must be rtc io")); + } switch(esp_sleep_enable_ext0_wakeup(self_in->gpio, self_in->level)) { case ESP_ERR_INVALID_ARG: mp_raise_ValueError(translate("trigger level must be 0 or 1")); case ESP_ERR_INVALID_STATE: mp_raise_RuntimeError(translate("wakeup conflict")); - default: - break; + default: + break; } if (self_in->pull) { (self_in->level) ? rtc_gpio_pulldown_en(self_in->gpio) : rtc_gpio_pullup_en(self_in->gpio); } - return self_in; -} + return self_in; +} void common_hal_alarm_io_disable (void) { esp_sleep_disable_wakeup_source(ESP_SLEEP_WAKEUP_EXT0 | ESP_SLEEP_WAKEUP_EXT1); diff --git a/ports/esp32s2/common-hal/alarm_time/__init__.c b/ports/esp32s2/common-hal/alarm_time/__init__.c index fb601e6be0..252b6e107c 100644 --- a/ports/esp32s2/common-hal/alarm_time/__init__.c +++ b/ports/esp32s2/common-hal/alarm_time/__init__.c @@ -5,8 +5,8 @@ void common_hal_alarm_time_duration (uint32_t ms) { if (esp_sleep_enable_timer_wakeup((ms) * 1000) == ESP_ERR_INVALID_ARG) { mp_raise_ValueError(translate("time out of range")); - } -} + } +} void common_hal_alarm_time_disable (void) { esp_sleep_disable_wakeup_source(ESP_SLEEP_WAKEUP_TIMER); diff --git a/ports/esp32s2/common-hal/alarm_touch/__init__.c b/ports/esp32s2/common-hal/alarm_touch/__init__.c new file mode 100644 index 0000000000..df32b26930 --- /dev/null +++ b/ports/esp32s2/common-hal/alarm_touch/__init__.c @@ -0,0 +1,7 @@ +#include "esp_sleep.h" + +#include "shared-bindings/alarm_touch/__init__.h" + +void common_hal_alarm_touch_disable (void) { + esp_sleep_disable_wakeup_source(ESP_SLEEP_WAKEUP_TOUCHPAD); +} diff --git a/ports/esp32s2/common-hal/microcontroller/__init__.c b/ports/esp32s2/common-hal/microcontroller/__init__.c index ba24e1c48d..f1dc24bb89 100644 --- a/ports/esp32s2/common-hal/microcontroller/__init__.c +++ b/ports/esp32s2/common-hal/microcontroller/__init__.c @@ -80,7 +80,7 @@ void common_hal_mcu_reset(void) { } void common_hal_mcu_sleep(void) { - esp_deep_sleep_start(); + esp_deep_sleep_start(); } // The singleton microcontroller.Processor object, bound to microcontroller.cpu diff --git a/ports/esp32s2/mpconfigport.mk b/ports/esp32s2/mpconfigport.mk index 1a78821d32..7024ceb630 100644 --- a/ports/esp32s2/mpconfigport.mk +++ b/ports/esp32s2/mpconfigport.mk @@ -17,6 +17,7 @@ CIRCUITPY_FULL_BUILD = 1 CIRCUITPY_ALARM = 1 CIRCUITPY_ALARM_IO = 1 CIRCUITPY_ALARM_TIME = 1 +CIRCUITPY_ALARM_TOUCH = 1 CIRCUITPY_AUDIOBUSIO = 0 CIRCUITPY_AUDIOIO = 0 CIRCUITPY_CANIO = 1 diff --git a/ports/esp32s2/supervisor/port.c b/ports/esp32s2/supervisor/port.c index 840b979632..df6755783d 100644 --- a/ports/esp32s2/supervisor/port.c +++ b/ports/esp32s2/supervisor/port.c @@ -86,7 +86,7 @@ safe_mode_t port_init(void) { if (heap == NULL) { return NO_HEAP; } - + return NO_SAFE_MODE; } diff --git a/py/circuitpy_defns.mk b/py/circuitpy_defns.mk index 473536d530..72091decbf 100644 --- a/py/circuitpy_defns.mk +++ b/py/circuitpy_defns.mk @@ -108,6 +108,9 @@ endif ifeq ($(CIRCUITPY_ALARM_TIME),1) SRC_PATTERNS += alarm_time/% endif +ifeq ($(CIRCUITPY_ALARM_TIME),1) +SRC_PATTERNS += alarm_touch/% +endif ifeq ($(CIRCUITPY_ANALOGIO),1) SRC_PATTERNS += analogio/% endif @@ -310,6 +313,7 @@ SRC_COMMON_HAL_ALL = \ alarm/__init__.c \ alarm_io/__init__.c \ alarm_time/__init__.c \ + alarm_touch/__init__.c \ analogio/AnalogIn.c \ analogio/AnalogOut.c \ analogio/__init__.c \ diff --git a/py/circuitpy_mpconfig.h b/py/circuitpy_mpconfig.h index 778c3131b6..c8141a99a6 100644 --- a/py/circuitpy_mpconfig.h +++ b/py/circuitpy_mpconfig.h @@ -261,6 +261,13 @@ extern const struct _mp_obj_module_t alarm_time_module; #define ALARM_TIME_MODULE #endif +#if CIRCUITPY_ALARM_TOUCH +extern const struct _mp_obj_module_t alarm_touch_module; +#define ALARM_TOUCH_MODULE { MP_OBJ_NEW_QSTR(MP_QSTR_alarm_touch), (mp_obj_t)&alarm_touch_module }, +#else +#define ALARM_TOUCH_MODULE +#endif + #if CIRCUITPY_ANALOGIO #define ANALOGIO_MODULE { MP_OBJ_NEW_QSTR(MP_QSTR_analogio), (mp_obj_t)&analogio_module }, extern const struct _mp_obj_module_t analogio_module; @@ -787,6 +794,7 @@ extern const struct _mp_obj_module_t wifi_module; ALARM_MODULE \ ALARM_IO_MODULE \ ALARM_TIME_MODULE \ + ALARM_TOUCH_MODULE \ ANALOGIO_MODULE \ AUDIOBUSIO_MODULE \ AUDIOCORE_MODULE \ diff --git a/py/circuitpy_mpconfig.mk b/py/circuitpy_mpconfig.mk index c1790e5e35..59d23e4667 100644 --- a/py/circuitpy_mpconfig.mk +++ b/py/circuitpy_mpconfig.mk @@ -48,6 +48,9 @@ CFLAGS += -DCIRCUITPY_ALARM_IO=$(CIRCUITPY_ALARM_IO) CIRCUITPY_ALARM_TIME ?= 0 CFLAGS += -DCIRCUITPY_ALARM_TIME=$(CIRCUITPY_ALARM_TIME) +CIRCUITPY_ALARM_TOUCH ?= 0 +CFLAGS += -DCIRCUITPY_ALARM_TOUCH=$(CIRCUITPY_ALARM_TOUCH) + CIRCUITPY_ANALOGIO ?= 1 CFLAGS += -DCIRCUITPY_ANALOGIO=$(CIRCUITPY_ANALOGIO) diff --git a/shared-bindings/alarm_io/__init__.c b/shared-bindings/alarm_io/__init__.c index d772ccb796..dbe4671763 100644 --- a/shared-bindings/alarm_io/__init__.c +++ b/shared-bindings/alarm_io/__init__.c @@ -3,15 +3,15 @@ #include "shared-bindings/alarm_io/__init__.h" #include "shared-bindings/microcontroller/Pin.h" -STATIC mp_obj_t alarm_io_pin_state(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { +STATIC mp_obj_t alarm_io_pin_state(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum { ARG_level, ARG_pull }; static const mp_arg_t allowed_args[] = { { MP_QSTR_level, MP_ARG_INT | MP_ARG_KW_ONLY | MP_ARG_REQUIRED }, { MP_QSTR_pull, MP_ARG_INT | MP_ARG_KW_ONLY, {.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_arg_parse_all(n_args - 1, pos_args + 1, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); mcu_pin_obj_t *pin = validate_obj_is_pin(pos_args[0]); alarm_io_obj_t *self = m_new_obj(alarm_io_obj_t); @@ -20,12 +20,12 @@ STATIC mp_obj_t alarm_io_pin_state(size_t n_args, const mp_obj_t *pos_args, mp_m self->gpio = pin->number; self->level = args[ARG_level].u_int; self->pull = args[ARG_pull].u_bool; - + return common_hal_alarm_io_pin_state(self); } STATIC MP_DEFINE_CONST_FUN_OBJ_KW(alarm_io_pin_state_obj, 1, alarm_io_pin_state); -STATIC mp_obj_t alarm_io_disable(void) { +STATIC mp_obj_t alarm_io_disable(void) { common_hal_alarm_io_disable(); return mp_const_none; } diff --git a/shared-bindings/alarm_time/__init__.c b/shared-bindings/alarm_time/__init__.c index d4474ea2de..218ac68575 100644 --- a/shared-bindings/alarm_time/__init__.c +++ b/shared-bindings/alarm_time/__init__.c @@ -1,7 +1,7 @@ #include "py/obj.h" #include "shared-bindings/alarm_time/__init__.h" -STATIC mp_obj_t alarm_time_duration(mp_obj_t seconds_o) { +STATIC mp_obj_t alarm_time_duration(mp_obj_t seconds_o) { #if MICROPY_PY_BUILTINS_FLOAT mp_float_t seconds = mp_obj_get_float(seconds_o); mp_float_t msecs = 1000.0f * seconds + 0.5f; @@ -22,7 +22,7 @@ STATIC mp_obj_t alarm_time_duration(mp_obj_t seconds_o) { } STATIC MP_DEFINE_CONST_FUN_OBJ_1(alarm_time_duration_obj, alarm_time_duration); -STATIC mp_obj_t alarm_time_disable(void) { +STATIC mp_obj_t alarm_time_disable(void) { common_hal_alarm_time_disable(); return mp_const_none; } diff --git a/shared-bindings/alarm_touch/__init__.c b/shared-bindings/alarm_touch/__init__.c new file mode 100644 index 0000000000..e36fa73cb8 --- /dev/null +++ b/shared-bindings/alarm_touch/__init__.c @@ -0,0 +1,24 @@ +#include "py/obj.h" +#include "shared-bindings/alarm_touch/__init__.h" + +STATIC mp_obj_t alarm_touch_disable(void) { + common_hal_alarm_touch_disable(); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_0(alarm_touch_disable_obj, alarm_touch_disable); + +STATIC const mp_rom_map_elem_t alarm_touch_module_globals_table[] = { + { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_alarm_touch) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_Disable), MP_ROM_PTR(&alarm_touch_disable_obj) }, +}; +STATIC MP_DEFINE_CONST_DICT(alarm_touch_module_globals, alarm_touch_module_globals_table); + +const mp_obj_module_t alarm_touch_module = { + .base = { &mp_type_module }, + .globals = (mp_obj_dict_t*)&alarm_touch_module_globals, +}; + +const mp_obj_type_t alarm_touch_type = { + { &mp_type_type }, + .name = MP_QSTR_touchAlarm, +}; diff --git a/shared-bindings/alarm_touch/__init__.h b/shared-bindings/alarm_touch/__init__.h new file mode 100644 index 0000000000..600587d247 --- /dev/null +++ b/shared-bindings/alarm_touch/__init__.h @@ -0,0 +1,14 @@ +#ifndef MICROPY_INCLUDED_SHARED_BINDINGS_ALARM_TOUCH___INIT___H +#define MICROPY_INCLUDED_SHARED_BINDINGS_ALARM_TOUCH___INIT___H + +#include "py/runtime.h" + +typedef struct { + mp_obj_base_t base; +} alarm_touch_obj_t; + +extern const mp_obj_type_t alarm_touch_type; + +extern void common_hal_alarm_touch_disable (void); + +#endif //MICROPY_INCLUDED_SHARED_BINDINGS_ALARM_TOUCH___INIT___H diff --git a/shared-bindings/microcontroller/__init__.c b/shared-bindings/microcontroller/__init__.c index eb58a40982..88dc4179d6 100644 --- a/shared-bindings/microcontroller/__init__.c +++ b/shared-bindings/microcontroller/__init__.c @@ -135,15 +135,6 @@ STATIC mp_obj_t mcu_reset(void) { } STATIC MP_DEFINE_CONST_FUN_OBJ_0(mcu_reset_obj, mcu_reset); -//| def sleep() -> None: -//| """Microcontroller will go into deep sleep. -//| cpy will restart when wakeup func. is triggered`. -//| -//| .. warning:: This may result in file system corruption when connected to a -//| host computer. Be very careful when calling this! Make sure the device -//| "Safely removed" on Windows or "ejected" on Mac OSX and Linux.""" -//| ... -//| STATIC mp_obj_t mcu_sleep(void) { common_hal_mcu_sleep(); // We won't actually get here because mcu is going into sleep. From e35938971a4e9c0177e68163e1baab3b25c17ca8 Mon Sep 17 00:00:00 2001 From: microDev <70126934+microDev1@users.noreply.github.com> Date: Fri, 25 Sep 2020 03:32:31 +0530 Subject: [PATCH 016/207] Add description of alarm modules --- ports/atmel-samd/common-hal/microcontroller/__init__.c | 4 ++++ ports/cxd56/common-hal/microcontroller/__init__.c | 4 ++++ ports/litex/common-hal/microcontroller/__init__.c | 4 ++++ ports/mimxrt10xx/common-hal/microcontroller/__init__.c | 4 ++++ ports/nrf/common-hal/microcontroller/__init__.c | 4 ++++ ports/stm/common-hal/microcontroller/__init__.c | 4 ++++ shared-bindings/alarm/__init__.c | 4 ++++ shared-bindings/alarm_io/__init__.c | 4 ++++ shared-bindings/alarm_time/__init__.c | 4 ++++ shared-bindings/alarm_touch/__init__.c | 4 ++++ 10 files changed, 40 insertions(+) diff --git a/ports/atmel-samd/common-hal/microcontroller/__init__.c b/ports/atmel-samd/common-hal/microcontroller/__init__.c index 50a1ec038e..b3ff06b62f 100644 --- a/ports/atmel-samd/common-hal/microcontroller/__init__.c +++ b/ports/atmel-samd/common-hal/microcontroller/__init__.c @@ -84,6 +84,10 @@ void common_hal_mcu_reset(void) { reset(); } +void common_hal_mcu_sleep(void) { + //deep sleep call here +} + // 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 = { diff --git a/ports/cxd56/common-hal/microcontroller/__init__.c b/ports/cxd56/common-hal/microcontroller/__init__.c index 7aa3b839d7..4379f9be66 100644 --- a/ports/cxd56/common-hal/microcontroller/__init__.c +++ b/ports/cxd56/common-hal/microcontroller/__init__.c @@ -81,6 +81,10 @@ void common_hal_mcu_reset(void) { boardctl(BOARDIOC_RESET, 0); } +void common_hal_mcu_sleep(void) { + //deep sleep call here +} + STATIC const mp_rom_map_elem_t mcu_pin_globals_table[] = { { MP_ROM_QSTR(MP_QSTR_UART2_RXD), MP_ROM_PTR(&pin_UART2_RXD) }, { MP_ROM_QSTR(MP_QSTR_UART2_TXD), MP_ROM_PTR(&pin_UART2_TXD) }, diff --git a/ports/litex/common-hal/microcontroller/__init__.c b/ports/litex/common-hal/microcontroller/__init__.c index 3c91661144..3b1628c39a 100644 --- a/ports/litex/common-hal/microcontroller/__init__.c +++ b/ports/litex/common-hal/microcontroller/__init__.c @@ -89,6 +89,10 @@ void common_hal_mcu_reset(void) { while(1); } +void common_hal_mcu_sleep(void) { + //deep sleep call here +} + // 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 = { diff --git a/ports/mimxrt10xx/common-hal/microcontroller/__init__.c b/ports/mimxrt10xx/common-hal/microcontroller/__init__.c index 6a8537e2da..c7bc7eb9e8 100644 --- a/ports/mimxrt10xx/common-hal/microcontroller/__init__.c +++ b/ports/mimxrt10xx/common-hal/microcontroller/__init__.c @@ -86,6 +86,10 @@ void common_hal_mcu_reset(void) { NVIC_SystemReset(); } +void common_hal_mcu_sleep(void) { + //deep sleep call here +} + // 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 = { diff --git a/ports/nrf/common-hal/microcontroller/__init__.c b/ports/nrf/common-hal/microcontroller/__init__.c index 06aac9409d..ff6c658b8b 100644 --- a/ports/nrf/common-hal/microcontroller/__init__.c +++ b/ports/nrf/common-hal/microcontroller/__init__.c @@ -95,6 +95,10 @@ void common_hal_mcu_reset(void) { reset_cpu(); } +void common_hal_mcu_sleep(void) { + //deep sleep call here +} + // 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 = { diff --git a/ports/stm/common-hal/microcontroller/__init__.c b/ports/stm/common-hal/microcontroller/__init__.c index a827399ccb..2a60c53426 100644 --- a/ports/stm/common-hal/microcontroller/__init__.c +++ b/ports/stm/common-hal/microcontroller/__init__.c @@ -81,6 +81,10 @@ void common_hal_mcu_reset(void) { NVIC_SystemReset(); } +void common_hal_mcu_sleep(void) { + //deep sleep call here +} + // 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 = { diff --git a/shared-bindings/alarm/__init__.c b/shared-bindings/alarm/__init__.c index 37462d88cc..88c4bc8878 100644 --- a/shared-bindings/alarm/__init__.c +++ b/shared-bindings/alarm/__init__.c @@ -1,5 +1,9 @@ #include "shared-bindings/alarm/__init__.h" +//| """alarm module +//| +//| The `alarm` module implements deep sleep.""" + STATIC mp_obj_t alarm_get_wake_alarm(void) { return common_hal_alarm_get_wake_alarm(); } diff --git a/shared-bindings/alarm_io/__init__.c b/shared-bindings/alarm_io/__init__.c index dbe4671763..4e42f9a2e1 100644 --- a/shared-bindings/alarm_io/__init__.c +++ b/shared-bindings/alarm_io/__init__.c @@ -3,6 +3,10 @@ #include "shared-bindings/alarm_io/__init__.h" #include "shared-bindings/microcontroller/Pin.h" +//| """alarm_io module +//| +//| The `alarm_io` module implements deep sleep.""" + STATIC mp_obj_t alarm_io_pin_state(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum { ARG_level, ARG_pull }; static const mp_arg_t allowed_args[] = { diff --git a/shared-bindings/alarm_time/__init__.c b/shared-bindings/alarm_time/__init__.c index 218ac68575..1707f7488f 100644 --- a/shared-bindings/alarm_time/__init__.c +++ b/shared-bindings/alarm_time/__init__.c @@ -1,6 +1,10 @@ #include "py/obj.h" #include "shared-bindings/alarm_time/__init__.h" +//| """alarm_time module +//| +//| The `alarm_time` module implements deep sleep.""" + STATIC mp_obj_t alarm_time_duration(mp_obj_t seconds_o) { #if MICROPY_PY_BUILTINS_FLOAT mp_float_t seconds = mp_obj_get_float(seconds_o); diff --git a/shared-bindings/alarm_touch/__init__.c b/shared-bindings/alarm_touch/__init__.c index e36fa73cb8..5f5a156d80 100644 --- a/shared-bindings/alarm_touch/__init__.c +++ b/shared-bindings/alarm_touch/__init__.c @@ -1,6 +1,10 @@ #include "py/obj.h" #include "shared-bindings/alarm_touch/__init__.h" +//| """alarm_touch module +//| +//| The `alarm_touch` module implements deep sleep.""" + STATIC mp_obj_t alarm_touch_disable(void) { common_hal_alarm_touch_disable(); return mp_const_none; From 930cf14dcef3e3552a0e7d7476fd89b873738c2d Mon Sep 17 00:00:00 2001 From: microDev <70126934+microDev1@users.noreply.github.com> Date: Sat, 26 Sep 2020 11:15:50 +0530 Subject: [PATCH 017/207] Add check for invalid io, function to disable all alarms --- ports/atmel-samd/common-hal/microcontroller/__init__.c | 2 +- ports/cxd56/common-hal/microcontroller/__init__.c | 2 +- ports/esp32s2/common-hal/alarm/__init__.c | 4 ++++ ports/esp32s2/common-hal/alarm_io/__init__.c | 8 ++++++++ ports/esp32s2/common-hal/microcontroller/__init__.c | 2 +- ports/litex/common-hal/microcontroller/__init__.c | 2 +- ports/mimxrt10xx/common-hal/microcontroller/__init__.c | 2 +- ports/nrf/common-hal/microcontroller/__init__.c | 2 +- ports/stm/common-hal/microcontroller/__init__.c | 2 +- py/circuitpy_defns.mk | 2 +- shared-bindings/alarm/__init__.c | 9 ++++++++- shared-bindings/alarm/__init__.h | 1 + shared-bindings/microcontroller/__init__.c | 3 ++- shared-bindings/microcontroller/__init__.h | 2 +- 14 files changed, 32 insertions(+), 11 deletions(-) diff --git a/ports/atmel-samd/common-hal/microcontroller/__init__.c b/ports/atmel-samd/common-hal/microcontroller/__init__.c index b3ff06b62f..ca39f28386 100644 --- a/ports/atmel-samd/common-hal/microcontroller/__init__.c +++ b/ports/atmel-samd/common-hal/microcontroller/__init__.c @@ -84,7 +84,7 @@ void common_hal_mcu_reset(void) { reset(); } -void common_hal_mcu_sleep(void) { +void common_hal_mcu_deep_sleep(void) { //deep sleep call here } diff --git a/ports/cxd56/common-hal/microcontroller/__init__.c b/ports/cxd56/common-hal/microcontroller/__init__.c index 4379f9be66..57140dec70 100644 --- a/ports/cxd56/common-hal/microcontroller/__init__.c +++ b/ports/cxd56/common-hal/microcontroller/__init__.c @@ -81,7 +81,7 @@ void common_hal_mcu_reset(void) { boardctl(BOARDIOC_RESET, 0); } -void common_hal_mcu_sleep(void) { +void common_hal_mcu_deep_sleep(void) { //deep sleep call here } diff --git a/ports/esp32s2/common-hal/alarm/__init__.c b/ports/esp32s2/common-hal/alarm/__init__.c index 46715d9bf6..552ad4452b 100644 --- a/ports/esp32s2/common-hal/alarm/__init__.c +++ b/ports/esp32s2/common-hal/alarm/__init__.c @@ -31,6 +31,10 @@ #include "esp_sleep.h" +void common_hal_alarm_disable_all(void) { + esp_sleep_disable_wakeup_source(ESP_SLEEP_WAKEUP_ALL); +} + mp_obj_t common_hal_alarm_get_wake_alarm(void) { switch (esp_sleep_get_wakeup_cause()) { case ESP_SLEEP_WAKEUP_TIMER: ; diff --git a/ports/esp32s2/common-hal/alarm_io/__init__.c b/ports/esp32s2/common-hal/alarm_io/__init__.c index a98b933246..b39693c6af 100644 --- a/ports/esp32s2/common-hal/alarm_io/__init__.c +++ b/ports/esp32s2/common-hal/alarm_io/__init__.c @@ -8,6 +8,14 @@ mp_obj_t common_hal_alarm_io_pin_state (alarm_io_obj_t *self_in) { mp_raise_ValueError(translate("io must be rtc io")); } + if (self_in->pull && !self_in->level) { + for (uint8_t i = 0; i<=4; i+=2) { + if (self_in->gpio == i) { + mp_raise_ValueError(translate("IOs 0, 2 & 4 do not support internal pullup in sleep")); + } + } + } + switch(esp_sleep_enable_ext0_wakeup(self_in->gpio, self_in->level)) { case ESP_ERR_INVALID_ARG: mp_raise_ValueError(translate("trigger level must be 0 or 1")); diff --git a/ports/esp32s2/common-hal/microcontroller/__init__.c b/ports/esp32s2/common-hal/microcontroller/__init__.c index f1dc24bb89..ab0e1bfaa4 100644 --- a/ports/esp32s2/common-hal/microcontroller/__init__.c +++ b/ports/esp32s2/common-hal/microcontroller/__init__.c @@ -79,7 +79,7 @@ void common_hal_mcu_reset(void) { while(1); } -void common_hal_mcu_sleep(void) { +void common_hal_mcu_deep_sleep(void) { esp_deep_sleep_start(); } diff --git a/ports/litex/common-hal/microcontroller/__init__.c b/ports/litex/common-hal/microcontroller/__init__.c index 3b1628c39a..e6f50ed5a6 100644 --- a/ports/litex/common-hal/microcontroller/__init__.c +++ b/ports/litex/common-hal/microcontroller/__init__.c @@ -89,7 +89,7 @@ void common_hal_mcu_reset(void) { while(1); } -void common_hal_mcu_sleep(void) { +void common_hal_mcu_deep_sleep(void) { //deep sleep call here } diff --git a/ports/mimxrt10xx/common-hal/microcontroller/__init__.c b/ports/mimxrt10xx/common-hal/microcontroller/__init__.c index c7bc7eb9e8..0329ced69b 100644 --- a/ports/mimxrt10xx/common-hal/microcontroller/__init__.c +++ b/ports/mimxrt10xx/common-hal/microcontroller/__init__.c @@ -86,7 +86,7 @@ void common_hal_mcu_reset(void) { NVIC_SystemReset(); } -void common_hal_mcu_sleep(void) { +void common_hal_mcu_deep_sleep(void) { //deep sleep call here } diff --git a/ports/nrf/common-hal/microcontroller/__init__.c b/ports/nrf/common-hal/microcontroller/__init__.c index ff6c658b8b..9911896bff 100644 --- a/ports/nrf/common-hal/microcontroller/__init__.c +++ b/ports/nrf/common-hal/microcontroller/__init__.c @@ -95,7 +95,7 @@ void common_hal_mcu_reset(void) { reset_cpu(); } -void common_hal_mcu_sleep(void) { +void common_hal_mcu_deep_sleep(void) { //deep sleep call here } diff --git a/ports/stm/common-hal/microcontroller/__init__.c b/ports/stm/common-hal/microcontroller/__init__.c index 2a60c53426..bc81b0e4f5 100644 --- a/ports/stm/common-hal/microcontroller/__init__.c +++ b/ports/stm/common-hal/microcontroller/__init__.c @@ -81,7 +81,7 @@ void common_hal_mcu_reset(void) { NVIC_SystemReset(); } -void common_hal_mcu_sleep(void) { +void common_hal_mcu_deep_sleep(void) { //deep sleep call here } diff --git a/py/circuitpy_defns.mk b/py/circuitpy_defns.mk index 72091decbf..7e17934a56 100644 --- a/py/circuitpy_defns.mk +++ b/py/circuitpy_defns.mk @@ -108,7 +108,7 @@ endif ifeq ($(CIRCUITPY_ALARM_TIME),1) SRC_PATTERNS += alarm_time/% endif -ifeq ($(CIRCUITPY_ALARM_TIME),1) +ifeq ($(CIRCUITPY_ALARM_TOUCH),1) SRC_PATTERNS += alarm_touch/% endif ifeq ($(CIRCUITPY_ANALOGIO),1) diff --git a/shared-bindings/alarm/__init__.c b/shared-bindings/alarm/__init__.c index 88c4bc8878..f43c2ea12d 100644 --- a/shared-bindings/alarm/__init__.c +++ b/shared-bindings/alarm/__init__.c @@ -4,6 +4,12 @@ //| //| The `alarm` module implements deep sleep.""" +STATIC mp_obj_t alarm_disable_all(void) { + common_hal_alarm_disable_all(); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_0(alarm_disable_all_obj, alarm_disable_all); + STATIC mp_obj_t alarm_get_wake_alarm(void) { return common_hal_alarm_get_wake_alarm(); } @@ -11,7 +17,8 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_0(alarm_get_wake_alarm_obj, alarm_get_wake_alarm) STATIC const mp_rom_map_elem_t alarm_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_alarm) }, - { MP_ROM_QSTR(MP_QSTR_getWakeAlarm), MP_ROM_PTR(&alarm_get_wake_alarm_obj) }, + { MP_ROM_QSTR(MP_QSTR_Disable), MP_ROM_PTR(&alarm_disable_all_obj) }, + { MP_ROM_QSTR(MP_QSTR_get_wake_alarm), MP_ROM_PTR(&alarm_get_wake_alarm_obj) }, }; STATIC MP_DEFINE_CONST_DICT(alarm_module_globals, alarm_module_globals_table); diff --git a/shared-bindings/alarm/__init__.h b/shared-bindings/alarm/__init__.h index 8b2cd9f770..db3966ac5d 100644 --- a/shared-bindings/alarm/__init__.h +++ b/shared-bindings/alarm/__init__.h @@ -3,6 +3,7 @@ #include "py/obj.h" +extern void common_hal_alarm_disable_all(void); extern mp_obj_t common_hal_alarm_get_wake_alarm(void); #endif // MICROPY_INCLUDED_SHARED_BINDINGS_ALARM___INIT___H diff --git a/shared-bindings/microcontroller/__init__.c b/shared-bindings/microcontroller/__init__.c index 88dc4179d6..bbc1640f76 100644 --- a/shared-bindings/microcontroller/__init__.c +++ b/shared-bindings/microcontroller/__init__.c @@ -136,7 +136,7 @@ STATIC mp_obj_t mcu_reset(void) { STATIC MP_DEFINE_CONST_FUN_OBJ_0(mcu_reset_obj, mcu_reset); STATIC mp_obj_t mcu_sleep(void) { - common_hal_mcu_sleep(); + common_hal_mcu_deep_sleep(); // We won't actually get here because mcu is going into sleep. return mp_const_none; } @@ -177,6 +177,7 @@ STATIC const mp_rom_map_elem_t mcu_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR_enable_interrupts), MP_ROM_PTR(&mcu_enable_interrupts_obj) }, { MP_ROM_QSTR(MP_QSTR_on_next_reset), MP_ROM_PTR(&mcu_on_next_reset_obj) }, { MP_ROM_QSTR(MP_QSTR_reset), MP_ROM_PTR(&mcu_reset_obj) }, + //ToDo: Remove MP_QSTR_sleep when sleep on code.py exit implemented. { MP_ROM_QSTR(MP_QSTR_sleep), MP_ROM_PTR(&mcu_sleep_obj) }, #if CIRCUITPY_INTERNAL_NVM_SIZE > 0 { MP_ROM_QSTR(MP_QSTR_nvm), MP_ROM_PTR(&common_hal_mcu_nvm_obj) }, diff --git a/shared-bindings/microcontroller/__init__.h b/shared-bindings/microcontroller/__init__.h index 95f1cf8fc7..f5bcfaa08a 100644 --- a/shared-bindings/microcontroller/__init__.h +++ b/shared-bindings/microcontroller/__init__.h @@ -43,7 +43,7 @@ extern void common_hal_mcu_enable_interrupts(void); extern void common_hal_mcu_on_next_reset(mcu_runmode_t runmode); extern void common_hal_mcu_reset(void); -extern void common_hal_mcu_sleep(void); +extern void common_hal_mcu_deep_sleep(void); extern const mp_obj_dict_t mcu_pin_globals; From 0e444f0de8dd4db8b5be1c41b4c8062364e4fd94 Mon Sep 17 00:00:00 2001 From: microDev <70126934+microDev1@users.noreply.github.com> Date: Wed, 30 Sep 2020 11:15:02 +0530 Subject: [PATCH 018/207] Implement sleep on code.py exit --- main.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/main.c b/main.c index 5a30f4bb26..328c3bbcba 100755 --- a/main.c +++ b/main.c @@ -57,6 +57,9 @@ #include "supervisor/shared/status_leds.h" #include "supervisor/shared/stack.h" #include "supervisor/serial.h" +#include "supervisor/usb.h" + +#include "shared-bindings/microcontroller/__init__.h" #include "boards/board.h" @@ -300,6 +303,19 @@ bool run_code_py(safe_mode_t safe_mode) { } } + for (uint8_t i = 0; i<=100; i++) { + if (!usb_msc_ejected()) { + //Go into light sleep + break; + } + mp_hal_delay_ms(10); + } + + if (usb_msc_ejected()) { + //Go into deep sleep + common_hal_mcu_deep_sleep(); + } + // Display a different completion message if the user has no USB attached (cannot save files) if (!serial_connected_at_start) { serial_write_compressed(translate("\nCode done running. Waiting for reload.\n")); From 354536c09fca3cecca6e6e5605710436501fccac Mon Sep 17 00:00:00 2001 From: microDev <70126934+microDev1@users.noreply.github.com> Date: Wed, 7 Oct 2020 09:55:48 +0530 Subject: [PATCH 019/207] Update translation --- locale/circuitpython.pot | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/locale/circuitpython.pot b/locale/circuitpython.pot index e344f4dd81..eb958a5999 100644 --- a/locale/circuitpython.pot +++ b/locale/circuitpython.pot @@ -980,6 +980,10 @@ msgstr "" msgid "I2SOut not available" msgstr "" +#: ports/esp32s2/common-hal/alarm_io/__init__.c +msgid "IOs 0, 2 & 4 do not support internal pullup in sleep" +msgstr "" + #: shared-bindings/aesio/aes.c #, c-format msgid "IV must be %d bytes long" @@ -2790,6 +2794,10 @@ msgstr "" msgid "invalid syntax for number" msgstr "" +#: ports/esp32s2/common-hal/alarm_io/__init__.c +msgid "io must be rtc io" +msgstr "" + #: py/objtype.c msgid "issubclass() arg 1 must be a class" msgstr "" @@ -3410,6 +3418,10 @@ msgstr "" msgid "threshold must be in the range 0-65536" msgstr "" +#: ports/esp32s2/common-hal/alarm_time/__init__.c +msgid "time out of range" +msgstr "" + #: shared-bindings/time/__init__.c msgid "time.struct_time() takes a 9-sequence" msgstr "" @@ -3455,6 +3467,10 @@ msgstr "" msgid "trapz is defined for 1D arrays of equal length" msgstr "" +#: ports/esp32s2/common-hal/alarm_io/__init__.c +msgid "trigger level must be 0 or 1" +msgstr "" + #: extmod/ulab/code/linalg/linalg.c msgid "tuple index out of range" msgstr "" @@ -3597,6 +3613,10 @@ msgstr "" msgid "vectors must have same lengths" msgstr "" +#: ports/esp32s2/common-hal/alarm_io/__init__.c +msgid "wakeup conflict" +msgstr "" + #: shared-bindings/watchdog/WatchDogTimer.c msgid "watchdog timeout must be greater than 0" msgstr "" From 1196d4bcf62884a18316bf44258a8d9b838f7273 Mon Sep 17 00:00:00 2001 From: Scott Shawcroft Date: Wed, 14 Oct 2020 14:09:41 -0700 Subject: [PATCH 020/207] move to new module --- shared-bindings/alarm/__init__.c | 29 --------- shared-bindings/alarm/__init__.h | 9 --- shared-bindings/sleepio/__init__.c | 101 +++++++++++++++++++++++++++++ shared-bindings/sleepio/__init__.h | 10 +++ 4 files changed, 111 insertions(+), 38 deletions(-) delete mode 100644 shared-bindings/alarm/__init__.c delete mode 100644 shared-bindings/alarm/__init__.h create mode 100644 shared-bindings/sleepio/__init__.c create mode 100644 shared-bindings/sleepio/__init__.h diff --git a/shared-bindings/alarm/__init__.c b/shared-bindings/alarm/__init__.c deleted file mode 100644 index f43c2ea12d..0000000000 --- a/shared-bindings/alarm/__init__.c +++ /dev/null @@ -1,29 +0,0 @@ -#include "shared-bindings/alarm/__init__.h" - -//| """alarm module -//| -//| The `alarm` module implements deep sleep.""" - -STATIC mp_obj_t alarm_disable_all(void) { - common_hal_alarm_disable_all(); - return mp_const_none; -} -STATIC MP_DEFINE_CONST_FUN_OBJ_0(alarm_disable_all_obj, alarm_disable_all); - -STATIC mp_obj_t alarm_get_wake_alarm(void) { - return common_hal_alarm_get_wake_alarm(); -} -STATIC MP_DEFINE_CONST_FUN_OBJ_0(alarm_get_wake_alarm_obj, alarm_get_wake_alarm); - -STATIC const mp_rom_map_elem_t alarm_module_globals_table[] = { - { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_alarm) }, - { MP_ROM_QSTR(MP_QSTR_Disable), MP_ROM_PTR(&alarm_disable_all_obj) }, - { MP_ROM_QSTR(MP_QSTR_get_wake_alarm), MP_ROM_PTR(&alarm_get_wake_alarm_obj) }, -}; - -STATIC MP_DEFINE_CONST_DICT(alarm_module_globals, alarm_module_globals_table); - -const mp_obj_module_t alarm_module = { - .base = { &mp_type_module }, - .globals = (mp_obj_dict_t*)&alarm_module_globals, -}; diff --git a/shared-bindings/alarm/__init__.h b/shared-bindings/alarm/__init__.h deleted file mode 100644 index db3966ac5d..0000000000 --- a/shared-bindings/alarm/__init__.h +++ /dev/null @@ -1,9 +0,0 @@ -#ifndef MICROPY_INCLUDED_SHARED_BINDINGS_ALARM___INIT___H -#define MICROPY_INCLUDED_SHARED_BINDINGS_ALARM___INIT___H - -#include "py/obj.h" - -extern void common_hal_alarm_disable_all(void); -extern mp_obj_t common_hal_alarm_get_wake_alarm(void); - -#endif // MICROPY_INCLUDED_SHARED_BINDINGS_ALARM___INIT___H diff --git a/shared-bindings/sleepio/__init__.c b/shared-bindings/sleepio/__init__.c new file mode 100644 index 0000000000..2f7a8c6c7b --- /dev/null +++ b/shared-bindings/sleepio/__init__.c @@ -0,0 +1,101 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * 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 "shared-bindings/alarm/__init__.h" + +//| """Light and deep sleep used to save power +//| +//| The `sleepio` module provides sleep related functionality. There are two supported levels of +//| sleep, light and deep. +//| +//| Light sleep leaves the CPU and RAM powered so that CircuitPython can resume where it left off +//| after being woken up. Light sleep is automatically done by CircuitPython when `time.sleep()` is +//| called. To light sleep until a non-time alarm use `sleepio.sleep_until_alarm()`. +//| +//| Deep sleep shuts down power to nearly all of the chip including the CPU and RAM. This can save +//| a more significant amount of power at the cost of starting CircuitPython from scratch when woken +//| up. CircuitPython will enter deep sleep automatically when code exits without error. If an +//| error causes CircuitPython to exit, error LED error flashes will be done periodically. To set +//| alarms for deep sleep use `sleepio.set_alarms` they will apply to next deep sleep only.""" + + +//| wake_alarm: Alarm +//| """The most recent alarm to wake us up from a sleep (light or deep.)""" +//| + +//| def sleep_until_alarm(alarm: Alarm, ...) -> Alarm: +//| """Performs a light sleep until woken by one of the alarms. The alarm that woke us up is +//| returned.""" +//| ... +//| + +STATIC mp_obj_t sleepio_sleep_until_alarm(size_t n_args, const mp_obj_t *args) { + // mp_int_t size = MP_OBJ_SMALL_INT_VALUE(struct_calcsize(args[0])); + // vstr_t vstr; + // vstr_init_len(&vstr, size); + // byte *p = (byte*)vstr.buf; + // memset(p, 0, size); + // byte *end_p = &p[size]; + // shared_modules_struct_pack_into(args[0], p, end_p, n_args - 1, &args[1]); + // return mp_obj_new_str_from_vstr(&mp_type_bytes, &vstr); +} +MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(sleepio_sleep_until_alarm_obj, 1, MP_OBJ_FUN_ARGS_MAX, sleepio_sleep_until_alarm); + +//| def set_alarms(alarm: Alarm, ...) -> None: +//| """Set one or more alarms to wake up from a deep sleep. The last alarm to wake us up is +//| available as `wake_alarm`.""" +//| ... +//| +STATIC mp_obj_t sleepio_set_alarms(size_t n_args, const mp_obj_t *args) { + // mp_int_t size = MP_OBJ_SMALL_INT_VALUE(struct_calcsize(args[0])); + // vstr_t vstr; + // vstr_init_len(&vstr, size); + // byte *p = (byte*)vstr.buf; + // memset(p, 0, size); + // byte *end_p = &p[size]; + // shared_modules_struct_pack_into(args[0], p, end_p, n_args - 1, &args[1]); + // return mp_obj_new_str_from_vstr(&mp_type_bytes, &vstr); +} +MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(sleepio_set_alarms_obj, 1, MP_OBJ_FUN_ARGS_MAX, sleepio_set_alarms); + + +mp_map_elem_t sleepio_module_globals_table[] = { + { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_sleepio) }, + + { MP_ROM_QSTR(MP_QSTR_wake_alarm), mp_const_none }, + { MP_ROM_QSTR(MP_QSTR_sleep_until_alarm), mp_const_none }, + { MP_ROM_QSTR(MP_QSTR_set_alarms), mp_const_none }, +}; +STATIC MP_DEFINE_CONST_DICT(sleepio_module_globals, sleepio_module_globals_table); + +void common_hal_sleepio_set_wake_alarm(mp_obj_t alarm) { + // sleepio_module_globals_table[1].value = alarm; +} + +const mp_obj_module_t sleepio_module = { + .base = { &mp_type_module }, + .globals = (mp_obj_dict_t*)&sleepio_module_globals, +}; diff --git a/shared-bindings/sleepio/__init__.h b/shared-bindings/sleepio/__init__.h new file mode 100644 index 0000000000..ccd3bf4a02 --- /dev/null +++ b/shared-bindings/sleepio/__init__.h @@ -0,0 +1,10 @@ +#ifndef MICROPY_INCLUDED_SHARED_BINDINGS_SLEEPIO___INIT___H +#define MICROPY_INCLUDED_SHARED_BINDINGS_SLEEPIO___INIT___H + +#include "py/obj.h" + +// This is implemented by shared-bindings so that implementations can set the +// newest alarm source. +extern void common_hal_sleepio_set_wake_alarm(mp_obj_t alarm); + +#endif // MICROPY_INCLUDED_SHARED_BINDINGS_SLEEPIO___INIT___H From 85dadf3a561c21e284d5daf42b1b3e367ce7ebc6 Mon Sep 17 00:00:00 2001 From: Scott Shawcroft Date: Thu, 15 Oct 2020 16:59:29 -0700 Subject: [PATCH 021/207] More API changes --- shared-bindings/_typing/__init__.pyi | 12 ++++ shared-bindings/alarm_time/Time.c | 76 ++++++++++++++++++++++++++ shared-bindings/alarm_time/Time.h | 42 ++++++++++++++ shared-bindings/alarm_time/__init__.c | 26 +++++++++ shared-bindings/canio/BusState.c | 70 ++++++++++++++++++++++++ shared-bindings/canio/BusState.h | 33 +++++++++++ shared-bindings/canio/__init__.c | 60 ++++---------------- shared-bindings/canio/__init__.h | 6 -- shared-bindings/sleepio/__init__.c | 10 ++-- shared-bindings/supervisor/RunReason.c | 62 +++++++++++++++++++++ shared-bindings/supervisor/RunReason.h | 36 ++++++++++++ shared-bindings/supervisor/Runtime.c | 22 ++++++++ 12 files changed, 395 insertions(+), 60 deletions(-) create mode 100644 shared-bindings/alarm_time/Time.c create mode 100644 shared-bindings/alarm_time/Time.h create mode 100644 shared-bindings/canio/BusState.c create mode 100644 shared-bindings/canio/BusState.h create mode 100644 shared-bindings/supervisor/RunReason.c create mode 100644 shared-bindings/supervisor/RunReason.h diff --git a/shared-bindings/_typing/__init__.pyi b/shared-bindings/_typing/__init__.pyi index 48e68a8d57..3b3f18cb9b 100644 --- a/shared-bindings/_typing/__init__.pyi +++ b/shared-bindings/_typing/__init__.pyi @@ -52,3 +52,15 @@ FrameBuffer = Union[rgbmatrix.RGBMatrix] - `rgbmatrix.RGBMatrix` """ + +Alarm = Union[ + alarm_time.Time, alarm_pin.PinLevel, alarm_touch.PinTouch +] +"""Classes that implement the audiosample protocol + + - `alarm_time.Time` + - `alarm_pin.PinLevel` + - `alarm_touch.PinTouch` + + You can play use these alarms to wake from light or deep sleep. +""" diff --git a/shared-bindings/alarm_time/Time.c b/shared-bindings/alarm_time/Time.c new file mode 100644 index 0000000000..904bf522e2 --- /dev/null +++ b/shared-bindings/alarm_time/Time.c @@ -0,0 +1,76 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * 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 "shared-bindings/alarm_time/__init__.h" + +//| """alarm_time module +//| +//| The `alarm_time` module implements deep sleep.""" + +STATIC mp_obj_t alarm_time_duration(mp_obj_t seconds_o) { + #if MICROPY_PY_BUILTINS_FLOAT + mp_float_t seconds = mp_obj_get_float(seconds_o); + mp_float_t msecs = 1000.0f * seconds + 0.5f; + #else + 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_alarm_time_duration(msecs); + + alarm_time_obj_t *self = m_new_obj(alarm_time_obj_t); + self->base.type = &alarm_time_type; + + return self; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_1(alarm_time_duration_obj, alarm_time_duration); + +STATIC mp_obj_t alarm_time_disable(void) { + common_hal_alarm_time_disable(); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_0(alarm_time_disable_obj, alarm_time_disable); + +STATIC const mp_rom_map_elem_t alarm_time_module_globals_table[] = { + { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_alarm_time) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_Duration), MP_ROM_PTR(&alarm_time_duration_obj) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_Disable), MP_ROM_PTR(&alarm_time_disable_obj) }, +}; +STATIC MP_DEFINE_CONST_DICT(alarm_time_module_globals, alarm_time_module_globals_table); + +const mp_obj_module_t alarm_time_module = { + .base = { &mp_type_module }, + .globals = (mp_obj_dict_t*)&alarm_time_module_globals, +}; + +const mp_obj_type_t alarm_time_type = { + { &mp_type_type }, + .name = MP_QSTR_timeAlarm, +}; diff --git a/shared-bindings/alarm_time/Time.h b/shared-bindings/alarm_time/Time.h new file mode 100644 index 0000000000..9962c26f25 --- /dev/null +++ b/shared-bindings/alarm_time/Time.h @@ -0,0 +1,42 @@ +/* + * This file is part of the Micro Python 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. + */ + +#ifndef MICROPY_INCLUDED_SHARED_BINDINGS_ALARM_TIME_TIME_H +#define MICROPY_INCLUDED_SHARED_BINDINGS_ALARM_TIME_TIME_H + +#include "py/runtime.h" + +typedef struct { + mp_obj_base_t base; + uint64_t time_to_alarm; +} alarm_time_time_obj_t; + +extern const mp_obj_type_t alarm_time_time_type; + +void common_hal_alarm_time_time_construct(alarm_time_time_obj_t* self, + uint64_t ticks_ms); + +#endif //MICROPY_INCLUDED_SHARED_BINDINGS_ALARM_TIME_TIME_H diff --git a/shared-bindings/alarm_time/__init__.c b/shared-bindings/alarm_time/__init__.c index 1707f7488f..904bf522e2 100644 --- a/shared-bindings/alarm_time/__init__.c +++ b/shared-bindings/alarm_time/__init__.c @@ -1,3 +1,29 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * 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 "shared-bindings/alarm_time/__init__.h" diff --git a/shared-bindings/canio/BusState.c b/shared-bindings/canio/BusState.c new file mode 100644 index 0000000000..e0501b8d83 --- /dev/null +++ b/shared-bindings/canio/BusState.c @@ -0,0 +1,70 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2020 Jeff Epler for Adafruit Industries + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include "py/enum.h" + +#include "shared-bindings/canio/BusState.h" + +MAKE_ENUM_VALUE(canio_bus_state_type, bus_state, ERROR_ACTIVE, BUS_STATE_ERROR_ACTIVE); +MAKE_ENUM_VALUE(canio_bus_state_type, bus_state, ERROR_PASSIVE, BUS_STATE_ERROR_PASSIVE); +MAKE_ENUM_VALUE(canio_bus_state_type, bus_state, ERROR_WARNING, BUS_STATE_ERROR_WARNING); +MAKE_ENUM_VALUE(canio_bus_state_type, bus_state, BUS_OFF, BUS_STATE_OFF); + +//| class BusState: +//| """The state of the CAN bus""" +//| +//| ERROR_ACTIVE: object +//| """The bus is in the normal (active) state""" +//| +//| ERROR_WARNING: object +//| """The bus is in the normal (active) state, but a moderate number of errors have occurred recently. +//| +//| NOTE: Not all implementations may use ERROR_WARNING. Do not rely on seeing ERROR_WARNING before ERROR_PASSIVE.""" +//| +//| ERROR_PASSIVE: object +//| """The bus is in the passive state due to the number of errors that have occurred recently. +//| +//| This device will acknowledge packets it receives, but cannot transmit messages. +//| If additional errors occur, this device may progress to BUS_OFF. +//| If it successfully acknowledges other packets on the bus, it can return to ERROR_WARNING or ERROR_ACTIVE and transmit packets. +//| """ +//| +//| BUS_OFF: object +//| """The bus has turned off due to the number of errors that have +//| occurred recently. It must be restarted before it will send or receive +//| packets. This device will neither send or acknowledge packets on the bus.""" +//| +MAKE_ENUM_MAP(canio_bus_state) { + MAKE_ENUM_MAP_ENTRY(bus_state, ERROR_ACTIVE), + MAKE_ENUM_MAP_ENTRY(bus_state, ERROR_PASSIVE), + MAKE_ENUM_MAP_ENTRY(bus_state, ERROR_WARNING), + MAKE_ENUM_MAP_ENTRY(bus_state, BUS_OFF), +}; +STATIC MP_DEFINE_CONST_DICT(canio_bus_state_locals_dict, canio_bus_state_locals_table); + +MAKE_PRINTER(canio, canio_bus_state); + +MAKE_ENUM_TYPE(canio, BusState, canio_bus_state); diff --git a/shared-bindings/canio/BusState.h b/shared-bindings/canio/BusState.h new file mode 100644 index 0000000000..e24eba92c1 --- /dev/null +++ b/shared-bindings/canio/BusState.h @@ -0,0 +1,33 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2020 Jeff Epler for Adafruit Industries + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#pragma once + +typedef enum { + BUS_STATE_ERROR_ACTIVE, BUS_STATE_ERROR_PASSIVE, BUS_STATE_ERROR_WARNING, BUS_STATE_OFF +} canio_bus_state_t; + +extern const mp_obj_type_t canio_bus_state_type; diff --git a/shared-bindings/canio/__init__.c b/shared-bindings/canio/__init__.c index f29d3ab8ac..451a68c9eb 100644 --- a/shared-bindings/canio/__init__.c +++ b/shared-bindings/canio/__init__.c @@ -24,6 +24,16 @@ * THE SOFTWARE. */ +#include "py/obj.h" + +#include "shared-bindings/canio/__init__.h" + +#include "shared-bindings/canio/BusState.h" +#include "shared-bindings/canio/CAN.h" +#include "shared-bindings/canio/Match.h" +#include "shared-bindings/canio/Message.h" +#include "shared-bindings/canio/Listener.h" + //| """CAN bus access //| //| The `canio` module contains low level classes to support the CAN bus @@ -57,56 +67,6 @@ //| """ //| -#include "py/obj.h" -#include "py/enum.h" - -#include "shared-bindings/canio/__init__.h" -#include "shared-bindings/canio/CAN.h" -#include "shared-bindings/canio/Match.h" -#include "shared-bindings/canio/Message.h" -#include "shared-bindings/canio/Listener.h" - -MAKE_ENUM_VALUE(canio_bus_state_type, bus_state, ERROR_ACTIVE, BUS_STATE_ERROR_ACTIVE); -MAKE_ENUM_VALUE(canio_bus_state_type, bus_state, ERROR_PASSIVE, BUS_STATE_ERROR_PASSIVE); -MAKE_ENUM_VALUE(canio_bus_state_type, bus_state, ERROR_WARNING, BUS_STATE_ERROR_WARNING); -MAKE_ENUM_VALUE(canio_bus_state_type, bus_state, BUS_OFF, BUS_STATE_OFF); - -//| class BusState: -//| """The state of the CAN bus""" -//| -//| ERROR_ACTIVE: object -//| """The bus is in the normal (active) state""" -//| -//| ERROR_WARNING: object -//| """The bus is in the normal (active) state, but a moderate number of errors have occurred recently. -//| -//| NOTE: Not all implementations may use ERROR_WARNING. Do not rely on seeing ERROR_WARNING before ERROR_PASSIVE.""" -//| -//| ERROR_PASSIVE: object -//| """The bus is in the passive state due to the number of errors that have occurred recently. -//| -//| This device will acknowledge packets it receives, but cannot transmit messages. -//| If additional errors occur, this device may progress to BUS_OFF. -//| If it successfully acknowledges other packets on the bus, it can return to ERROR_WARNING or ERROR_ACTIVE and transmit packets. -//| """ -//| -//| BUS_OFF: object -//| """The bus has turned off due to the number of errors that have -//| occurred recently. It must be restarted before it will send or receive -//| packets. This device will neither send or acknowledge packets on the bus.""" -//| -MAKE_ENUM_MAP(canio_bus_state) { - MAKE_ENUM_MAP_ENTRY(bus_state, ERROR_ACTIVE), - MAKE_ENUM_MAP_ENTRY(bus_state, ERROR_PASSIVE), - MAKE_ENUM_MAP_ENTRY(bus_state, ERROR_WARNING), - MAKE_ENUM_MAP_ENTRY(bus_state, BUS_OFF), -}; -STATIC MP_DEFINE_CONST_DICT(canio_bus_state_locals_dict, canio_bus_state_locals_table); - -MAKE_PRINTER(canio, canio_bus_state); - -MAKE_ENUM_TYPE(canio, BusState, canio_bus_state); - STATIC const mp_rom_map_elem_t canio_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR_BusState), MP_ROM_PTR(&canio_bus_state_type) }, { MP_ROM_QSTR(MP_QSTR_CAN), MP_ROM_PTR(&canio_can_type) }, diff --git a/shared-bindings/canio/__init__.h b/shared-bindings/canio/__init__.h index e24eba92c1..20b6638cd8 100644 --- a/shared-bindings/canio/__init__.h +++ b/shared-bindings/canio/__init__.h @@ -25,9 +25,3 @@ */ #pragma once - -typedef enum { - BUS_STATE_ERROR_ACTIVE, BUS_STATE_ERROR_PASSIVE, BUS_STATE_ERROR_WARNING, BUS_STATE_OFF -} canio_bus_state_t; - -extern const mp_obj_type_t canio_bus_state_type; diff --git a/shared-bindings/sleepio/__init__.c b/shared-bindings/sleepio/__init__.c index 2f7a8c6c7b..2d5db18f0a 100644 --- a/shared-bindings/sleepio/__init__.c +++ b/shared-bindings/sleepio/__init__.c @@ -33,14 +33,15 @@ //| //| Light sleep leaves the CPU and RAM powered so that CircuitPython can resume where it left off //| after being woken up. Light sleep is automatically done by CircuitPython when `time.sleep()` is -//| called. To light sleep until a non-time alarm use `sleepio.sleep_until_alarm()`. +//| called. To light sleep until a non-time alarm use `sleepio.sleep_until_alarm()`. Any active +//| peripherals, such as I2C, are left on. //| //| Deep sleep shuts down power to nearly all of the chip including the CPU and RAM. This can save //| a more significant amount of power at the cost of starting CircuitPython from scratch when woken //| up. CircuitPython will enter deep sleep automatically when code exits without error. If an //| error causes CircuitPython to exit, error LED error flashes will be done periodically. To set //| alarms for deep sleep use `sleepio.set_alarms` they will apply to next deep sleep only.""" - +//| //| wake_alarm: Alarm //| """The most recent alarm to wake us up from a sleep (light or deep.)""" @@ -86,8 +87,9 @@ mp_map_elem_t sleepio_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_sleepio) }, { MP_ROM_QSTR(MP_QSTR_wake_alarm), mp_const_none }, - { MP_ROM_QSTR(MP_QSTR_sleep_until_alarm), mp_const_none }, - { MP_ROM_QSTR(MP_QSTR_set_alarms), mp_const_none }, + + { MP_ROM_QSTR(MP_QSTR_sleep_until_alarm), sleepio_sleep_until_alarm_obj }, + { MP_ROM_QSTR(MP_QSTR_set_alarms), sleepio_set_alarms_obj }, }; STATIC MP_DEFINE_CONST_DICT(sleepio_module_globals, sleepio_module_globals_table); diff --git a/shared-bindings/supervisor/RunReason.c b/shared-bindings/supervisor/RunReason.c new file mode 100644 index 0000000000..5233cf959b --- /dev/null +++ b/shared-bindings/supervisor/RunReason.c @@ -0,0 +1,62 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2020 Scott Shawcroft for Adafruit Industries + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include "py/enum.h" + +#include "shared-bindings/supervisor/RunReason.h" + +MAKE_ENUM_VALUE(canio_bus_state_type, run_reason, ERROR_ACTIVE, RUN_REASON_STARTUP); +MAKE_ENUM_VALUE(canio_bus_state_type, bus_state, ERROR_PASSIVE, RUN_REASON_AUTORELOAD); +MAKE_ENUM_VALUE(canio_bus_state_type, bus_state, ERROR_WARNING, RUN_REASON_SUPERVISOR_RELOAD); +MAKE_ENUM_VALUE(canio_bus_state_type, bus_state, BUS_OFF, RUN_REASON_RELOAD_HOTKEY); + +//| class RunReason: +//| """The state of the CAN bus""" +//| +//| STARTUP: object +//| """The first VM was run after the microcontroller started up. See `microcontroller.start_reason` +//| for more detail why the microcontroller was started.""" +//| +//| AUTORELOAD: object +//| """The VM was run due to a USB write to the filesystem.""" +//| +//| SUPERVISOR_RELOAD: object +//| """The VM was run due to a call to `supervisor.reload()`.""" +//| +//| RELOAD_HOTKEY: object +//| """The VM was run due CTRL-D.""" +//| +MAKE_ENUM_MAP(canio_bus_state) { + MAKE_ENUM_MAP_ENTRY(bus_state, ERROR_ACTIVE), + MAKE_ENUM_MAP_ENTRY(bus_state, ERROR_PASSIVE), + MAKE_ENUM_MAP_ENTRY(bus_state, ERROR_WARNING), + MAKE_ENUM_MAP_ENTRY(bus_state, BUS_OFF), +}; +STATIC MP_DEFINE_CONST_DICT(canio_bus_state_locals_dict, canio_bus_state_locals_table); + +MAKE_PRINTER(canio, canio_bus_state); + +MAKE_ENUM_TYPE(canio, BusState, canio_bus_state); diff --git a/shared-bindings/supervisor/RunReason.h b/shared-bindings/supervisor/RunReason.h new file mode 100644 index 0000000000..f9aaacae63 --- /dev/null +++ b/shared-bindings/supervisor/RunReason.h @@ -0,0 +1,36 @@ +/* + * 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. + */ + +#pragma once + +typedef enum { + RUN_REASON_STARTUP, + RUN_REASON_AUTORELOAD, + RUN_REASON_SUPERVISOR_RELOAD, + RUN_REASON_RELOAD_HOTKEY +} supervisor_run_reason_t; + +extern const mp_obj_type_t canio_bus_state_type; diff --git a/shared-bindings/supervisor/Runtime.c b/shared-bindings/supervisor/Runtime.c index bfca6e7b1d..f9db38c9b5 100755 --- a/shared-bindings/supervisor/Runtime.c +++ b/shared-bindings/supervisor/Runtime.c @@ -90,9 +90,31 @@ const mp_obj_property_t supervisor_serial_bytes_available_obj = { }; +//| run_reason: RunReason +//| """Returns why the Python VM was run this time.""" +//| +STATIC mp_obj_t supervisor_get_run_reason(mp_obj_t self) { + if (!common_hal_get_serial_bytes_available()) { + return mp_const_false; + } + else { + return mp_const_true; + } +} +MP_DEFINE_CONST_FUN_OBJ_1(supervisor_get_run_reason_obj, supervisor_get_run_reason); + +const mp_obj_property_t supervisor_run_reason_obj = { + .base.type = &mp_type_property, + .proxy = {(mp_obj_t)&supervisor_get_run_reason_obj, + (mp_obj_t)&mp_const_none_obj, + (mp_obj_t)&mp_const_none_obj}, +}; + + STATIC const mp_rom_map_elem_t supervisor_runtime_locals_dict_table[] = { { MP_ROM_QSTR(MP_QSTR_serial_connected), MP_ROM_PTR(&supervisor_serial_connected_obj) }, { MP_ROM_QSTR(MP_QSTR_serial_bytes_available), MP_ROM_PTR(&supervisor_serial_bytes_available_obj) }, + { MP_ROM_QSTR(MP_QSTR_run_reason), MP_ROM_PTR(&supervisor_run_reason_obj) }, }; STATIC MP_DEFINE_CONST_DICT(supervisor_runtime_locals_dict, supervisor_runtime_locals_dict_table); From 9a4efed8cbaca3aa48c6cc0ce0a4e267eef7a8e1 Mon Sep 17 00:00:00 2001 From: Scott Shawcroft Date: Tue, 27 Oct 2020 17:55:03 -0700 Subject: [PATCH 022/207] Start tweaking the workflow to sleep --- main.c | 49 ++++++++++----- .../esp32s2/common-hal/alarm_touch/__init__.c | 7 --- shared-bindings/alarm_touch/__init__.c | 28 --------- shared-bindings/alarm_touch/__init__.h | 14 ----- shared-bindings/sleepio/ResetReason.c | 61 +++++++++++++++++++ shared-bindings/sleepio/ResetReason.h | 36 +++++++++++ shared-bindings/sleepio/__init__.c | 27 ++++---- shared-bindings/sleepio/__init__.h | 5 +- supervisor/serial.h | 1 - supervisor/shared/rgb_led_status.c | 10 ++- supervisor/shared/safe_mode.c | 4 ++ supervisor/shared/serial.h | 29 +++++++++ supervisor/shared/usb/usb.c | 9 ++- supervisor/shared/workflow.c | 32 ++++++++++ supervisor/shared/workflow.h | 29 +++++++++ supervisor/supervisor.mk | 1 + supervisor/workflow.h | 30 +++++++++ 17 files changed, 282 insertions(+), 90 deletions(-) delete mode 100644 ports/esp32s2/common-hal/alarm_touch/__init__.c delete mode 100644 shared-bindings/alarm_touch/__init__.c delete mode 100644 shared-bindings/alarm_touch/__init__.h create mode 100644 shared-bindings/sleepio/ResetReason.c create mode 100644 shared-bindings/sleepio/ResetReason.h create mode 100644 supervisor/shared/serial.h create mode 100644 supervisor/shared/workflow.c create mode 100644 supervisor/shared/workflow.h create mode 100755 supervisor/workflow.h diff --git a/main.c b/main.c index 328c3bbcba..1854a14071 100755 --- a/main.c +++ b/main.c @@ -88,6 +88,10 @@ #include "common-hal/canio/CAN.h" #endif +#if CIRCUITPY_SLEEPIO +#include "shared-bindings/sleepio/__init__.h" +#endif + void do_str(const char *src, mp_parse_input_kind_t input_kind) { mp_lexer_t *lex = mp_lexer_new_from_str_len(MP_QSTR__lt_stdin_gt_, src, strlen(src), 0); if (lex == NULL) { @@ -303,19 +307,6 @@ bool run_code_py(safe_mode_t safe_mode) { } } - for (uint8_t i = 0; i<=100; i++) { - if (!usb_msc_ejected()) { - //Go into light sleep - break; - } - mp_hal_delay_ms(10); - } - - if (usb_msc_ejected()) { - //Go into deep sleep - common_hal_mcu_deep_sleep(); - } - // Display a different completion message if the user has no USB attached (cannot save files) if (!serial_connected_at_start) { serial_write_compressed(translate("\nCode done running. Waiting for reload.\n")); @@ -326,6 +317,14 @@ bool run_code_py(safe_mode_t safe_mode) { bool refreshed_epaper_display = false; #endif rgb_status_animation_t animation; + bool ok = result->return_code != PYEXEC_EXCEPTION; + #if CIRCUITPY_SLEEPIO + // If USB isn't enumerated then deep sleep. + if (ok && !supervisor_workflow_active() && supervisor_ticks_ms64() > CIRCUITPY_USB_ENUMERATION_DELAY * 1024) { + common_hal_sleepio_deep_sleep(); + } + #endif + // Show the animation every N seconds. prep_rgb_status_animation(&result, found_main, safe_mode, &animation); while (true) { RUN_BACKGROUND_TASKS; @@ -358,8 +357,24 @@ bool run_code_py(safe_mode_t safe_mode) { refreshed_epaper_display = maybe_refresh_epaperdisplay(); } #endif - - tick_rgb_status_animation(&animation); + bool animation_done = tick_rgb_status_animation(&animation); + if (animation_done && supervisor_workflow_active()) { + #if CIRCUITPY_SLEEPIO + int64_t remaining_enumeration_wait = CIRCUITPY_USB_ENUMERATION_DELAY * 1024 - supervisor_ticks_ms64(); + // If USB isn't enumerated then deep sleep after our waiting period. + if (ok && remaining_enumeration_wait < 0) { + common_hal_sleepio_deep_sleep(); + return; // Doesn't actually get here. + } + #endif + // Wake up every so often to flash the error code. + if (!ok) { + port_interrupt_after_ticks(CIRCUITPY_FLASH_ERROR_PERIOD * 1024); + } else { + port_interrupt_after_ticks(remaining_enumeration_wait); + } + port_sleep_until_interrupt(); + } } } @@ -406,7 +421,9 @@ void __attribute__ ((noinline)) run_boot_py(safe_mode_t safe_mode) { if (!skip_boot_output) { // Wait 1.5 seconds before opening CIRCUITPY_BOOT_OUTPUT_FILE for write, // in case power is momentary or will fail shortly due to, say a low, battery. - mp_hal_delay_ms(1500); + if (common_hal_sleepio_get_reset_reason() == RESET_REASON_POWER_VALID) { + mp_hal_delay_ms(1500); + } // USB isn't up, so we can write the file. filesystem_set_internal_writable_by_usb(false); diff --git a/ports/esp32s2/common-hal/alarm_touch/__init__.c b/ports/esp32s2/common-hal/alarm_touch/__init__.c deleted file mode 100644 index df32b26930..0000000000 --- a/ports/esp32s2/common-hal/alarm_touch/__init__.c +++ /dev/null @@ -1,7 +0,0 @@ -#include "esp_sleep.h" - -#include "shared-bindings/alarm_touch/__init__.h" - -void common_hal_alarm_touch_disable (void) { - esp_sleep_disable_wakeup_source(ESP_SLEEP_WAKEUP_TOUCHPAD); -} diff --git a/shared-bindings/alarm_touch/__init__.c b/shared-bindings/alarm_touch/__init__.c deleted file mode 100644 index 5f5a156d80..0000000000 --- a/shared-bindings/alarm_touch/__init__.c +++ /dev/null @@ -1,28 +0,0 @@ -#include "py/obj.h" -#include "shared-bindings/alarm_touch/__init__.h" - -//| """alarm_touch module -//| -//| The `alarm_touch` module implements deep sleep.""" - -STATIC mp_obj_t alarm_touch_disable(void) { - common_hal_alarm_touch_disable(); - return mp_const_none; -} -STATIC MP_DEFINE_CONST_FUN_OBJ_0(alarm_touch_disable_obj, alarm_touch_disable); - -STATIC const mp_rom_map_elem_t alarm_touch_module_globals_table[] = { - { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_alarm_touch) }, - { MP_OBJ_NEW_QSTR(MP_QSTR_Disable), MP_ROM_PTR(&alarm_touch_disable_obj) }, -}; -STATIC MP_DEFINE_CONST_DICT(alarm_touch_module_globals, alarm_touch_module_globals_table); - -const mp_obj_module_t alarm_touch_module = { - .base = { &mp_type_module }, - .globals = (mp_obj_dict_t*)&alarm_touch_module_globals, -}; - -const mp_obj_type_t alarm_touch_type = { - { &mp_type_type }, - .name = MP_QSTR_touchAlarm, -}; diff --git a/shared-bindings/alarm_touch/__init__.h b/shared-bindings/alarm_touch/__init__.h deleted file mode 100644 index 600587d247..0000000000 --- a/shared-bindings/alarm_touch/__init__.h +++ /dev/null @@ -1,14 +0,0 @@ -#ifndef MICROPY_INCLUDED_SHARED_BINDINGS_ALARM_TOUCH___INIT___H -#define MICROPY_INCLUDED_SHARED_BINDINGS_ALARM_TOUCH___INIT___H - -#include "py/runtime.h" - -typedef struct { - mp_obj_base_t base; -} alarm_touch_obj_t; - -extern const mp_obj_type_t alarm_touch_type; - -extern void common_hal_alarm_touch_disable (void); - -#endif //MICROPY_INCLUDED_SHARED_BINDINGS_ALARM_TOUCH___INIT___H diff --git a/shared-bindings/sleepio/ResetReason.c b/shared-bindings/sleepio/ResetReason.c new file mode 100644 index 0000000000..095f4bed0d --- /dev/null +++ b/shared-bindings/sleepio/ResetReason.c @@ -0,0 +1,61 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2020 Scott Shawcroft for Adafruit Industries + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include "py/enum.h" + +#include "shared-bindings/sleepio/ResetReason.h" + +MAKE_ENUM_VALUE(sleepio_reset_reason_type, reset_reason, POWER_VALID, RESET_REASON_POWER_VALID); +MAKE_ENUM_VALUE(sleepio_reset_reason_type, reset_reason, SOFTWARE, RESET_REASON_SOFTWARE); +MAKE_ENUM_VALUE(sleepio_reset_reason_type, reset_reason, DEEP_SLEEP_ALARM, RESET_REASON_DEEP_SLEEP_ALARM); +MAKE_ENUM_VALUE(sleepio_reset_reason_type, reset_reason, EXTERNAL, RESET_REASON_EXTERNAL); + +//| class ResetReason: +//| """The reason the chip was last reset""" +//| +//| POWER_VALID: object +//| """The chip was reset and started once power levels were valid.""" +//| +//| SOFTWARE: object +//| """The chip was reset from software.""" +//| +//| DEEP_SLEEP_ALARM: object +//| """The chip was reset for deep sleep and started by an alarm.""" +//| +//| EXTERNAL: object +//| """The chip was reset by an external input such as a button.""" +//| +MAKE_ENUM_MAP(sleepio_reset_reason) { + MAKE_ENUM_MAP_ENTRY(reset_reason, POWER_VALID), + MAKE_ENUM_MAP_ENTRY(reset_reason, SOFTWARE), + MAKE_ENUM_MAP_ENTRY(reset_reason, DEEP_SLEEP_ALARM), + MAKE_ENUM_MAP_ENTRY(reset_reason, EXTERNAL), +}; +STATIC MP_DEFINE_CONST_DICT(sleepio_reset_reason_locals_dict, sleepio_reset_reason_locals_table); + +MAKE_PRINTER(sleepio, sleepio_reset_reason); + +MAKE_ENUM_TYPE(sleepio, ResetReason, sleepio_reset_reason); diff --git a/shared-bindings/sleepio/ResetReason.h b/shared-bindings/sleepio/ResetReason.h new file mode 100644 index 0000000000..50b8d002aa --- /dev/null +++ b/shared-bindings/sleepio/ResetReason.h @@ -0,0 +1,36 @@ +/* + * 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. + */ + +#pragma once + +typedef enum { + RESET_REASON_POWER_APPLIED, + RESET_REASON_SOFTWARE, + RESET_REASON_DEEP_SLEEP_ALARM, + RESET_REASON_BUTTON, +} sleepio_reset_reason_t; + +extern const mp_obj_type_t sleepio_reset_reason_type; diff --git a/shared-bindings/sleepio/__init__.c b/shared-bindings/sleepio/__init__.c index 2d5db18f0a..9793c1b502 100644 --- a/shared-bindings/sleepio/__init__.c +++ b/shared-bindings/sleepio/__init__.c @@ -47,6 +47,10 @@ //| """The most recent alarm to wake us up from a sleep (light or deep.)""" //| +//| reset_reason: ResetReason +//| """The reason the chip started up from reset state. This can may be power up or due to an alarm.""" +//| + //| def sleep_until_alarm(alarm: Alarm, ...) -> Alarm: //| """Performs a light sleep until woken by one of the alarms. The alarm that woke us up is //| returned.""" @@ -54,14 +58,6 @@ //| STATIC mp_obj_t sleepio_sleep_until_alarm(size_t n_args, const mp_obj_t *args) { - // mp_int_t size = MP_OBJ_SMALL_INT_VALUE(struct_calcsize(args[0])); - // vstr_t vstr; - // vstr_init_len(&vstr, size); - // byte *p = (byte*)vstr.buf; - // memset(p, 0, size); - // byte *end_p = &p[size]; - // shared_modules_struct_pack_into(args[0], p, end_p, n_args - 1, &args[1]); - // return mp_obj_new_str_from_vstr(&mp_type_bytes, &vstr); } MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(sleepio_sleep_until_alarm_obj, 1, MP_OBJ_FUN_ARGS_MAX, sleepio_sleep_until_alarm); @@ -71,14 +67,6 @@ MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(sleepio_sleep_until_alarm_obj, 1, MP_OBJ_FUN //| ... //| STATIC mp_obj_t sleepio_set_alarms(size_t n_args, const mp_obj_t *args) { - // mp_int_t size = MP_OBJ_SMALL_INT_VALUE(struct_calcsize(args[0])); - // vstr_t vstr; - // vstr_init_len(&vstr, size); - // byte *p = (byte*)vstr.buf; - // memset(p, 0, size); - // byte *end_p = &p[size]; - // shared_modules_struct_pack_into(args[0], p, end_p, n_args - 1, &args[1]); - // return mp_obj_new_str_from_vstr(&mp_type_bytes, &vstr); } MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(sleepio_set_alarms_obj, 1, MP_OBJ_FUN_ARGS_MAX, sleepio_set_alarms); @@ -87,16 +75,23 @@ mp_map_elem_t sleepio_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_sleepio) }, { MP_ROM_QSTR(MP_QSTR_wake_alarm), mp_const_none }, + { MP_ROM_QSTR(MP_QSTR_reset_reason), mp_const_none }, { MP_ROM_QSTR(MP_QSTR_sleep_until_alarm), sleepio_sleep_until_alarm_obj }, { MP_ROM_QSTR(MP_QSTR_set_alarms), sleepio_set_alarms_obj }, }; STATIC MP_DEFINE_CONST_DICT(sleepio_module_globals, sleepio_module_globals_table); +// These are called from common hal code to set the current wake alarm. void common_hal_sleepio_set_wake_alarm(mp_obj_t alarm) { // sleepio_module_globals_table[1].value = alarm; } +// These are called from common hal code to set the current wake alarm. +void common_hal_sleepio_set_reset_reason(mp_obj_t reset_reason) { + // sleepio_module_globals_table[1].value = alarm; +} + const mp_obj_module_t sleepio_module = { .base = { &mp_type_module }, .globals = (mp_obj_dict_t*)&sleepio_module_globals, diff --git a/shared-bindings/sleepio/__init__.h b/shared-bindings/sleepio/__init__.h index ccd3bf4a02..6ea538055a 100644 --- a/shared-bindings/sleepio/__init__.h +++ b/shared-bindings/sleepio/__init__.h @@ -3,8 +3,7 @@ #include "py/obj.h" -// This is implemented by shared-bindings so that implementations can set the -// newest alarm source. -extern void common_hal_sleepio_set_wake_alarm(mp_obj_t alarm); +extern mp_obj_t common_hal_sleepio_get_wake_alarm(void); +extern sleepio_reset_reason_t common_hal_sleepio_get_reset_reason(void); #endif // MICROPY_INCLUDED_SHARED_BINDINGS_SLEEPIO___INIT___H diff --git a/supervisor/serial.h b/supervisor/serial.h index 9c2d44737a..066886303e 100644 --- a/supervisor/serial.h +++ b/supervisor/serial.h @@ -47,5 +47,4 @@ char serial_read(void); bool serial_bytes_available(void); bool serial_connected(void); -extern volatile bool _serial_connected; #endif // MICROPY_INCLUDED_SUPERVISOR_SERIAL_H diff --git a/supervisor/shared/rgb_led_status.c b/supervisor/shared/rgb_led_status.c index 283b9da123..bff74a1f0e 100644 --- a/supervisor/shared/rgb_led_status.c +++ b/supervisor/shared/rgb_led_status.c @@ -367,6 +367,7 @@ void prep_rgb_status_animation(const pyexec_result_t* result, status->found_main = found_main; status->total_exception_cycle = 0; status->ok = result->return_code != PYEXEC_EXCEPTION; + status->cycles = 0; if (status->ok) { // If this isn't an exception, skip exception sorting and handling return; @@ -411,14 +412,16 @@ void prep_rgb_status_animation(const pyexec_result_t* result, #endif } -void tick_rgb_status_animation(rgb_status_animation_t* status) { +bool 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 = 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 = supervisor_ticks_ms32(); - tick_diff = 0; + status->cycles++; + new_status_color(BLACK); + return status->cycles; } uint16_t brightness = tick_diff * 255 / (ALL_GOOD_CYCLE_MS / 2); @@ -433,7 +436,8 @@ void tick_rgb_status_animation(rgb_status_animation_t* status) { } else { if (tick_diff > status->total_exception_cycle) { status->pattern_start = supervisor_ticks_ms32(); - tick_diff = 0; + status->cycles++; + return; } // First flash the file color. if (tick_diff < EXCEPTION_TYPE_LENGTH_MS) { diff --git a/supervisor/shared/safe_mode.c b/supervisor/shared/safe_mode.c index d59e754ed4..fa871eeebf 100644 --- a/supervisor/shared/safe_mode.c +++ b/supervisor/shared/safe_mode.c @@ -52,6 +52,10 @@ safe_mode_t wait_for_safe_mode_reset(void) { current_safe_mode = safe_mode; return safe_mode; } + if (common_hal_sleepio_get_reset_reason() != RESET_REASON_POWER_VALID && + common_hal_sleepio_get_reset_reason() != RESET_REASON_BUTTON) { + return NO_SAFE_MODE; + } port_set_saved_word(SAFE_MODE_DATA_GUARD | (MANUAL_SAFE_MODE << 8)); // Wait for a while to allow for reset. temp_status_color(SAFE_MODE); diff --git a/supervisor/shared/serial.h b/supervisor/shared/serial.h new file mode 100644 index 0000000000..84f92c337c --- /dev/null +++ b/supervisor/shared/serial.h @@ -0,0 +1,29 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2020 Scott Shawcroft for Adafruit Industries + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#pragma once + +extern volatile bool _serial_connected; diff --git a/supervisor/shared/usb/usb.c b/supervisor/shared/usb/usb.c index 89fbf56f37..7fbc5cbe6a 100644 --- a/supervisor/shared/usb/usb.c +++ b/supervisor/shared/usb/usb.c @@ -30,6 +30,7 @@ #include "supervisor/background_callback.h" #include "supervisor/port.h" #include "supervisor/serial.h" +#include "supervisor/shared/serial.h" #include "supervisor/usb.h" #include "lib/utils/interrupt_char.h" #include "lib/mp-readline/readline.h" @@ -102,14 +103,16 @@ void usb_irq_handler(void) { // tinyusb callbacks //--------------------------------------------------------------------+ -// Invoked when device is mounted +// Invoked when device is plugged into a host void tud_mount_cb(void) { usb_msc_mount(); + _workflow_active = true; } -// Invoked when device is unmounted +// Invoked when device is unplugged from the host void tud_umount_cb(void) { usb_msc_umount(); + _workflow_active = false; } // Invoked when usb bus is suspended @@ -117,10 +120,12 @@ void tud_umount_cb(void) { // USB Specs: Within 7ms, device must draw an average current less than 2.5 mA from bus void tud_suspend_cb(bool remote_wakeup_en) { _serial_connected = false; + _workflow_active = false; } // Invoked when usb bus is resumed void tud_resume_cb(void) { + _workflow_active = true; } // Invoked when cdc when line state changed e.g connected/disconnected diff --git a/supervisor/shared/workflow.c b/supervisor/shared/workflow.c new file mode 100644 index 0000000000..adcffb319a --- /dev/null +++ b/supervisor/shared/workflow.c @@ -0,0 +1,32 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2020 Scott Shawcroft for Adafruit Industries + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +// Set by the shared USB code. +volatile bool _workflow_active; + +bool workflow_active(void) { + return _workflow_active; +} diff --git a/supervisor/shared/workflow.h b/supervisor/shared/workflow.h new file mode 100644 index 0000000000..4a138332a7 --- /dev/null +++ b/supervisor/shared/workflow.h @@ -0,0 +1,29 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2020 Scott Shawcroft for Adafruit Industries + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#pragma once + +extern volatile bool _workflow_active; diff --git a/supervisor/supervisor.mk b/supervisor/supervisor.mk index e81c51a88c..a59e99e3de 100644 --- a/supervisor/supervisor.mk +++ b/supervisor/supervisor.mk @@ -75,6 +75,7 @@ else lib/tinyusb/src/class/cdc/cdc_device.c \ lib/tinyusb/src/tusb.c \ supervisor/shared/serial.c \ + supervisor/shared/workflow.c \ supervisor/usb.c \ supervisor/shared/usb/usb_desc.c \ supervisor/shared/usb/usb.c \ diff --git a/supervisor/workflow.h b/supervisor/workflow.h new file mode 100755 index 0000000000..4008b83a11 --- /dev/null +++ b/supervisor/workflow.h @@ -0,0 +1,30 @@ +/* + * 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. + */ + +#pragma once + +// True when the user could be actively iterating on their code. +bool workflow_active(void); From 7fd73c7d39399042ad6ed3bfe5b1c64da05c964e Mon Sep 17 00:00:00 2001 From: Scott Shawcroft Date: Wed, 28 Oct 2020 18:08:31 -0700 Subject: [PATCH 023/207] Initial UDP work. Need to test --- ports/esp32s2/common-hal/socketpool/Socket.c | 63 +++++++++- .../common-hal/socketpool/SocketPool.c | 7 +- shared-bindings/socketpool/Socket.c | 118 ++++++++---------- shared-bindings/socketpool/Socket.h | 4 + 4 files changed, 120 insertions(+), 72 deletions(-) diff --git a/ports/esp32s2/common-hal/socketpool/Socket.c b/ports/esp32s2/common-hal/socketpool/Socket.c index 0a994c604e..7f031521f7 100644 --- a/ports/esp32s2/common-hal/socketpool/Socket.c +++ b/ports/esp32s2/common-hal/socketpool/Socket.c @@ -121,16 +121,77 @@ mp_uint_t common_hal_socketpool_socket_recv_into(socketpool_socket_obj_t* self, return received; } +mp_uint_t common_hal_socketpool_socket_sendto(socketpool_socket_obj_t* self, + const char* host, size_t hostlen, uint8_t port, const uint8_t* buf, mp_uint_t len) { + + struct sockaddr_in dest_addr; + dest_addr.sin_addr.s_addr = inet_addr(HOST_IP_ADDR); + dest_addr.sin_family = AF_INET; + dest_addr.sin_port = htons(port); + + + const struct addrinfo hints = { + .ai_family = AF_INET, + .ai_socktype = SOCK_STREAM, + }; + struct addrinfo *res; + int err = getaddrinfo(host, NULL, &hints, &res); + if (err != 0 || res == NULL) { + return mp_const_none; + } + + #pragma GCC diagnostic push + #pragma GCC diagnostic ignored "-Wcast-align" + struct in_addr *addr = &((struct sockaddr_in *)res->ai_addr)->sin_addr; + #pragma GCC diagnostic pop + char ip_str[IP4ADDR_STRLEN_MAX]; + inet_ntoa_r(*addr, ip_str, IP4ADDR_STRLEN_MAX); + mp_obj_t ip_obj = mp_obj_new_str(ip_str, strlen(ip_str)); + freeaddrinfo(res); + + + + int err = lwip_sendto(self->num, buf, len, 0 /* flags */, + (struct sockaddr *)&dest_addr, sizeof(dest_addr)); +} + +mp_uint_t common_hal_socketpool_socket_recvfrom_into(socketpool_socket_obj_t* self, + const uint8_t* buf, mp_uint_t len, uint8_t* ip, uint8_t port) { + + const struct addrinfo hints = { + .ai_family = AF_INET, + .ai_socktype = SOCK_STREAM, + }; + struct addrinfo *res; + int err = getaddrinfo(host, NULL, &hints, &res); + if (err != 0 || res == NULL) { + return mp_const_none; + } + + #pragma GCC diagnostic push + #pragma GCC diagnostic ignored "-Wcast-align" + struct in_addr *addr = &((struct sockaddr_in *)res->ai_addr)->sin_addr; + #pragma GCC diagnostic pop + char ip_str[IP4ADDR_STRLEN_MAX]; + inet_ntoa_r(*addr, ip_str, IP4ADDR_STRLEN_MAX); + mp_obj_t ip_obj = mp_obj_new_str(ip_str, strlen(ip_str)); + freeaddrinfo(res); +} + void common_hal_socketpool_socket_close(socketpool_socket_obj_t* self) { self->connected = false; if (self->tcp != NULL) { esp_tls_conn_destroy(self->tcp); self->tcp = NULL; } + if (self->num >= 0) { + lwip_shutdown(self->num, 0); + lwip_close(self->num); + } } bool common_hal_socketpool_socket_get_closed(socketpool_socket_obj_t* self) { - return self->tcp == NULL; + return self->tcp == NULL && self->num < 0; } diff --git a/ports/esp32s2/common-hal/socketpool/SocketPool.c b/ports/esp32s2/common-hal/socketpool/SocketPool.c index 1d4d04b034..3bec5f337f 100644 --- a/ports/esp32s2/common-hal/socketpool/SocketPool.c +++ b/ports/esp32s2/common-hal/socketpool/SocketPool.c @@ -61,15 +61,14 @@ socketpool_socket_obj_t* common_hal_socketpool_socket(socketpool_socketpool_obj_ socket_type = SOCK_RAW; } - if (socket_type == SOCK_DGRAM || socket_type == SOCK_RAW || - addr_family == AF_INET6 || ipproto == IPPROTO_IPV6) { - mp_raise_NotImplementedError(translate("Only IPv4 SOCK_STREAM sockets supported")); + if (addr_family == AF_INET6 || ipproto == IPPROTO_IPV6) { + mp_raise_NotImplementedError(translate("Only IPv4 sockets supported")); } int socknum = -1; esp_tls_t* tcp_handle = NULL; if (socket_type == SOCK_DGRAM || socket_type == SOCK_RAW) { - // socknum = lwip_socket(addr_family, socket_type, ipproto); + socknum = lwip_socket(addr_family, socket_type, ipproto); } else { tcp_handle = esp_tls_init(); diff --git a/shared-bindings/socketpool/Socket.c b/shared-bindings/socketpool/Socket.c index e7b31842d2..2e369d442b 100644 --- a/shared-bindings/socketpool/Socket.c +++ b/shared-bindings/socketpool/Socket.c @@ -274,79 +274,63 @@ STATIC mp_obj_t socketpool_socket_recv_into(size_t n_args, const mp_obj_t *args) } STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(socketpool_socket_recv_into_obj, 2, 3, socketpool_socket_recv_into); -// //| def sendto(self, bytes: ReadableBuffer, address: tuple) -> int: -// //| """Send some bytes to a specific address. -// //| Suits sockets of type SOCK_DGRAM -// //| -// //| :param ~bytes bytes: some bytes to send -// //| :param ~tuple address: tuple of (remote_address, remote_port)""" -// //| ... -// //| +//| def sendto(self, bytes: ReadableBuffer, address: tuple) -> int: +//| """Send some bytes to a specific address. +//| Suits sockets of type SOCK_DGRAM +//| +//| :param ~bytes bytes: some bytes to send +//| :param ~tuple address: tuple of (remote_address, remote_port)""" +//| ... +//| -// STATIC mp_obj_t socketpool_socket_sendto(mp_obj_t self_in, mp_obj_t data_in, mp_obj_t addr_in) { -// // mod_network_socket_obj_t *self = MP_OBJ_TO_PTR(self_in); +STATIC mp_obj_t socketpool_socket_sendto(mp_obj_t self_in, mp_obj_t data_in, mp_obj_t addr_in) { + socketpool_socket_obj_t *self = MP_OBJ_TO_PTR(self_in); -// // // get the data -// // mp_buffer_info_t bufinfo; -// // mp_get_buffer_raise(data_in, &bufinfo, MP_BUFFER_READ); + // get the data + mp_buffer_info_t bufinfo; + mp_get_buffer_raise(data_in, &bufinfo, MP_BUFFER_READ); -// // // get address -// // uint8_t ip[MOD_NETWORK_IPADDR_BUF_SIZE]; -// // mp_uint_t port = netutils_parse_inet_addr(addr_in, ip, NETUTILS_BIG); + mp_obj_t *addr_items; + mp_obj_get_array_fixed_n(addr_in, 2, &addr_items); -// // // check if we need to select a NIC -// // socket_select_nic(self, ip); + size_t hostlen; + const char* host = mp_obj_str_get_data(addr_items[0], &hostlen); + mp_int_t port = mp_obj_get_int(addr_items[1]); -// // // call the NIC to sendto -// // int _errno; -// // mp_int_t ret = self->nic_type->sendto(self, bufinfo.buf, bufinfo.len, ip, port, &_errno); -// // if (ret == -1) { -// // mp_raise_OSError(_errno); -// // } -// mp_int_t ret = 0; + mp_int_t ret = common_hal_socketpool_socket_sendto(self, host, hostlen, port, bufinfo.buf, bufinfo.len); + if (!ok) { + mp_raise_OSError(0); + } -// return mp_obj_new_int(ret); -// } -// STATIC MP_DEFINE_CONST_FUN_OBJ_3(socketpool_socket_sendto_obj, socketpool_socket_sendto); + return mp_obj_new_int_from_uint(ret); +} +STATIC MP_DEFINE_CONST_FUN_OBJ_3(socketpool_socket_sendto_obj, socketpool_socket_sendto); -// //| def recvfrom(self, bufsize: int) -> Tuple[bytes, tuple]: -// //| """Reads some bytes from the connected remote address. -// //| Suits sockets of type SOCK_STREAM -// //| -// //| Returns a tuple containing -// //| * a bytes() of length <= bufsize -// //| * a remote_address, which is a tuple of ip address and port number -// //| -// //| :param ~int bufsize: maximum number of bytes to receive""" -// //| ... -// //| +//| def recvfrom_into(self, buffer) -> Tuple[int, tuple]: +//| """Reads some bytes from a remote address. +//| +//| Returns a tuple containing +//| * the number of bytes received into the given buffer +//| * a remote_address, which is a tuple of ip address and port number +//| +//| :param object buffer: buffer to read into""" +//| ... +//| +STATIC mp_obj_t socketpool_socket_recvfrom_into(mp_obj_t self_in, mp_obj_t data_in) { + socketpool_socket_obj_t *self = MP_OBJ_TO_PTR(self_in); + mp_buffer_info_t bufinfo; + mp_get_buffer_raise(data_in, &bufinfo, MP_BUFFER_WRITE); -// STATIC mp_obj_t socketpool_socket_recvfrom_into(mp_obj_t self_in, mp_obj_t len_in) { -// // mod_network_socket_obj_t *self = MP_OBJ_TO_PTR(self_in); -// // if (self->nic == MP_OBJ_NULL) { -// // // not connected -// // mp_raise_OSError(MP_ENOTCONN); -// // } -// // vstr_t vstr; -// // vstr_init_len(&vstr, mp_obj_get_int(len_in)); -// // byte ip[4]; -// // mp_uint_t port; -// // int _errno; -// // mp_int_t ret = self->nic_type->recvfrom(self, (byte*)vstr.buf, vstr.len, ip, &port, &_errno); -// // if (ret == -1) { -// // mp_raise_OSError(_errno); -// // } -// mp_obj_t tuple[2]; -// // if (ret == 0) { -// // tuple[0] = mp_const_empty_bytes; -// // } else { -// // vstr.len = ret; -// // tuple[0] = mp_obj_new_str_from_vstr(&mp_type_bytes, &vstr); -// // } -// // tuple[1] = netutils_format_inet_addr(ip, port, NETUTILS_BIG); -// return mp_obj_new_tuple(2, tuple); -// } -// STATIC MP_DEFINE_CONST_FUN_OBJ_2(socketpool_socket_recvfrom_into_obj, socketpool_socket_recvfrom_into); + byte ip[4]; + mp_uint_t port; + mp_int_t ret = common_hal_socketpool_socket_recvfrom_into(self, + (byte*)bufinfo.buf, len, ip, &port); + mp_obj_t tuple_contents[2]; + tuple_contents[0] = mp_obj_new_int_from_uint(ret); + tuple_contents[1] = netutils_format_inet_addr(ip, port, NETUTILS_BIG); + return mp_obj_new_tuple(2, tuple); +} +STATIC MP_DEFINE_CONST_FUN_OBJ_2(socketpool_socket_recvfrom_into_obj, socketpool_socket_recvfrom_into); // //| def setsockopt(self, level: int, optname: int, value: int) -> None: // //| """Sets socket options""" @@ -449,8 +433,8 @@ STATIC const mp_rom_map_elem_t socketpool_socket_locals_dict_table[] = { // { MP_ROM_QSTR(MP_QSTR_accept), MP_ROM_PTR(&socketpool_socket_accept_obj) }, { MP_ROM_QSTR(MP_QSTR_connect), MP_ROM_PTR(&socketpool_socket_connect_obj) }, { MP_ROM_QSTR(MP_QSTR_send), MP_ROM_PTR(&socketpool_socket_send_obj) }, - // { MP_ROM_QSTR(MP_QSTR_sendto), MP_ROM_PTR(&socketpool_socket_sendto_obj) }, - // { MP_ROM_QSTR(MP_QSTR_recvfrom_into), MP_ROM_PTR(&socketpool_socket_recvfrom_into_obj) }, + { MP_ROM_QSTR(MP_QSTR_sendto), MP_ROM_PTR(&socketpool_socket_sendto_obj) }, + { MP_ROM_QSTR(MP_QSTR_recvfrom_into), MP_ROM_PTR(&socketpool_socket_recvfrom_into_obj) }, { MP_ROM_QSTR(MP_QSTR_recv_into), MP_ROM_PTR(&socketpool_socket_recv_into_obj) }, // { MP_ROM_QSTR(MP_QSTR_setsockopt), MP_ROM_PTR(&socketpool_socket_setsockopt_obj) }, { MP_ROM_QSTR(MP_QSTR_settimeout), MP_ROM_PTR(&socketpool_socket_settimeout_obj) }, diff --git a/shared-bindings/socketpool/Socket.h b/shared-bindings/socketpool/Socket.h index f0be95c925..72a4c9e3c3 100644 --- a/shared-bindings/socketpool/Socket.h +++ b/shared-bindings/socketpool/Socket.h @@ -35,6 +35,10 @@ void common_hal_socketpool_socket_settimeout(socketpool_socket_obj_t* self, mp_u bool common_hal_socketpool_socket_connect(socketpool_socket_obj_t* self, const char* host, size_t hostlen, mp_int_t port); mp_uint_t common_hal_socketpool_socket_send(socketpool_socket_obj_t* self, const uint8_t* buf, mp_uint_t len); mp_uint_t common_hal_socketpool_socket_recv_into(socketpool_socket_obj_t* self, const uint8_t* buf, mp_uint_t len); +mp_uint_t common_hal_socketpool_socket_sendto(socketpool_socket_obj_t* self, + const uint8_t* host, size_t hostlen, uint8_t port, const uint8_t* buf, mp_uint_t len); +mp_uint_t common_hal_socketpool_socket_recvfrom_into(socketpool_socket_obj_t* self, + const uint8_t* buf, mp_uint_t len, uint8_t* ip, uint8_t port); void common_hal_socketpool_socket_close(socketpool_socket_obj_t* self); bool common_hal_socketpool_socket_get_closed(socketpool_socket_obj_t* self); bool common_hal_socketpool_socket_get_connected(socketpool_socket_obj_t* self); From e7da852db7c3784c8c162f7914815ba439baa989 Mon Sep 17 00:00:00 2001 From: gamblor21 Date: Thu, 29 Oct 2020 16:13:03 -0500 Subject: [PATCH 024/207] Fixing review comments --- shared-bindings/busdevice/I2CDevice.c | 40 ++++++++------------------- shared-bindings/busdevice/I2CDevice.h | 6 ++-- shared-module/busdevice/I2CDevice.c | 26 ++++------------- shared-module/busdevice/I2CDevice.h | 1 - 4 files changed, 20 insertions(+), 53 deletions(-) diff --git a/shared-bindings/busdevice/I2CDevice.c b/shared-bindings/busdevice/I2CDevice.c index 1f3da46523..f5e968137c 100644 --- a/shared-bindings/busdevice/I2CDevice.c +++ b/shared-bindings/busdevice/I2CDevice.c @@ -76,22 +76,23 @@ STATIC mp_obj_t busdevice_i2cdevice_make_new(const mp_obj_type_t *type, size_t n busio_i2c_obj_t* i2c = args[ARG_i2c].u_obj; - common_hal_busdevice_i2cdevice_construct(self, i2c, args[ARG_device_address].u_int, args[ARG_probe].u_bool); + common_hal_busdevice_i2cdevice_construct(MP_OBJ_TO_PTR(self), i2c, args[ARG_device_address].u_int); if (args[ARG_probe].u_bool == true) { - common_hal_busdevice_i2cdevice___probe_for_device(self); + common_hal_busdevice_i2cdevice_probe_for_device(self); } return (mp_obj_t)self; } STATIC mp_obj_t busdevice_i2cdevice_obj___enter__(mp_obj_t self_in) { - common_hal_busdevice_i2cdevice_lock(self_in); - return self_in; + busdevice_i2cdevice_obj_t *self = MP_OBJ_TO_PTR(self_in); + common_hal_busdevice_i2cdevice_lock(self); + return self; } STATIC MP_DEFINE_CONST_FUN_OBJ_1(busdevice_i2cdevice___enter___obj, busdevice_i2cdevice_obj___enter__); STATIC mp_obj_t busdevice_i2cdevice_obj___exit__(size_t n_args, const mp_obj_t *args) { - common_hal_busdevice_i2cdevice_unlock(args[0]); + common_hal_busdevice_i2cdevice_unlock(MP_OBJ_TO_PTR(args[0])); return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(busdevice_i2cdevice___exit___obj, 4, 4, busdevice_i2cdevice_obj___exit__); @@ -118,7 +119,7 @@ STATIC void readinto(busdevice_i2cdevice_obj_t *self, mp_obj_t buffer, int32_t s mp_raise_ValueError(translate("Buffer must be at least length 1")); } - uint8_t status = common_hal_busdevice_i2cdevice_readinto(self, ((uint8_t*)bufinfo.buf) + start, length); + uint8_t status = common_hal_busdevice_i2cdevice_readinto(MP_OBJ_TO_PTR(self), ((uint8_t*)bufinfo.buf) + start, length); if (status != 0) { mp_raise_OSError(status); } @@ -127,7 +128,7 @@ STATIC void readinto(busdevice_i2cdevice_obj_t *self, mp_obj_t buffer, int32_t s STATIC mp_obj_t busdevice_i2cdevice_readinto(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum { ARG_buffer, ARG_start, ARG_end }; static const mp_arg_t allowed_args[] = { - { MP_QSTR_buffer, MP_ARG_REQUIRED | MP_ARG_OBJ, {.u_obj = MP_OBJ_NULL} }, + { MP_QSTR_buffer, MP_ARG_REQUIRED | MP_ARG_OBJ }, { MP_QSTR_start, MP_ARG_KW_ONLY | MP_ARG_INT, {.u_int = 0} }, { MP_QSTR_end, MP_ARG_KW_ONLY | MP_ARG_INT, {.u_int = INT_MAX} }, }; @@ -165,7 +166,7 @@ STATIC void write(busdevice_i2cdevice_obj_t *self, mp_obj_t buffer, int32_t star mp_raise_ValueError(translate("Buffer must be at least length 1")); } - uint8_t status = common_hal_busdevice_i2cdevice_write(self, ((uint8_t*)bufinfo.buf) + start, length); + uint8_t status = common_hal_busdevice_i2cdevice_write(MP_OBJ_TO_PTR(self), ((uint8_t*)bufinfo.buf) + start, length); if (status != 0) { mp_raise_OSError(status); } @@ -174,7 +175,7 @@ STATIC void write(busdevice_i2cdevice_obj_t *self, mp_obj_t buffer, int32_t star STATIC mp_obj_t busdevice_i2cdevice_write(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum { ARG_buffer, ARG_start, ARG_end }; static const mp_arg_t allowed_args[] = { - { MP_QSTR_buffer, MP_ARG_REQUIRED | MP_ARG_OBJ, {.u_obj = MP_OBJ_NULL} }, + { MP_QSTR_buffer, MP_ARG_REQUIRED | MP_ARG_OBJ }, { MP_QSTR_start, MP_ARG_KW_ONLY | MP_ARG_INT, {.u_int = 0} }, { MP_QSTR_end, MP_ARG_KW_ONLY | MP_ARG_INT, {.u_int = INT_MAX} }, }; @@ -214,8 +215,8 @@ MP_DEFINE_CONST_FUN_OBJ_KW(busdevice_i2cdevice_write_obj, 2, busdevice_i2cdevice STATIC mp_obj_t busdevice_i2cdevice_write_then_readinto(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum { ARG_out_buffer, ARG_in_buffer, ARG_out_start, ARG_out_end, ARG_in_start, ARG_in_end }; static const mp_arg_t allowed_args[] = { - { MP_QSTR_out_buffer, MP_ARG_REQUIRED | MP_ARG_OBJ, {.u_obj = MP_OBJ_NULL} }, - { MP_QSTR_in_buffer, MP_ARG_REQUIRED | MP_ARG_OBJ, {.u_obj = MP_OBJ_NULL} }, + { MP_QSTR_out_buffer, MP_ARG_REQUIRED | MP_ARG_OBJ }, + { MP_QSTR_in_buffer, MP_ARG_REQUIRED | MP_ARG_OBJ }, { MP_QSTR_out_start, MP_ARG_KW_ONLY | MP_ARG_INT, {.u_int = 0} }, { MP_QSTR_out_end, MP_ARG_KW_ONLY | MP_ARG_INT, {.u_int = INT_MAX} }, { MP_QSTR_in_start, MP_ARG_KW_ONLY | MP_ARG_INT, {.u_int = 0} }, @@ -234,31 +235,14 @@ STATIC mp_obj_t busdevice_i2cdevice_write_then_readinto(size_t n_args, const mp_ } MP_DEFINE_CONST_FUN_OBJ_KW(busdevice_i2cdevice_write_then_readinto_obj, 3, busdevice_i2cdevice_write_then_readinto); -//| def __probe_for_device(self): -//| """ -//| Try to read a byte from an address, -//| if you get an OSError it means the device is not there -//| or that the device does not support these means of probing -//| """ -//| ... -//| -STATIC mp_obj_t busdevice_i2cdevice___probe_for_device(mp_obj_t self_in) { - busdevice_i2cdevice_obj_t *self = self_in; - common_hal_busdevice_i2cdevice___probe_for_device(self); - return mp_const_none; -} -MP_DEFINE_CONST_FUN_OBJ_1(busdevice_i2cdevice___probe_for_device_obj, busdevice_i2cdevice___probe_for_device); - STATIC const mp_rom_map_elem_t busdevice_i2cdevice_locals_dict_table[] = { { MP_ROM_QSTR(MP_QSTR___enter__), MP_ROM_PTR(&busdevice_i2cdevice___enter___obj) }, { MP_ROM_QSTR(MP_QSTR___exit__), MP_ROM_PTR(&busdevice_i2cdevice___exit___obj) }, { MP_ROM_QSTR(MP_QSTR_readinto), MP_ROM_PTR(&busdevice_i2cdevice_readinto_obj) }, { MP_ROM_QSTR(MP_QSTR_write), MP_ROM_PTR(&busdevice_i2cdevice_write_obj) }, { MP_ROM_QSTR(MP_QSTR_write_then_readinto), MP_ROM_PTR(&busdevice_i2cdevice_write_then_readinto_obj) }, - { MP_ROM_QSTR(MP_QSTR___probe_for_device), MP_ROM_PTR(&busdevice_i2cdevice___probe_for_device_obj) }, }; - STATIC MP_DEFINE_CONST_DICT(busdevice_i2cdevice_locals_dict, busdevice_i2cdevice_locals_dict_table); const mp_obj_type_t busdevice_i2cdevice_type = { diff --git a/shared-bindings/busdevice/I2CDevice.h b/shared-bindings/busdevice/I2CDevice.h index 146013cb76..a1f869c450 100644 --- a/shared-bindings/busdevice/I2CDevice.h +++ b/shared-bindings/busdevice/I2CDevice.h @@ -43,13 +43,11 @@ extern const mp_obj_type_t busdevice_i2cdevice_type; // Initializes the hardware peripheral. -extern void common_hal_busdevice_i2cdevice_construct(busdevice_i2cdevice_obj_t *self, busio_i2c_obj_t *i2c, uint8_t device_address, bool probe); +extern void common_hal_busdevice_i2cdevice_construct(busdevice_i2cdevice_obj_t *self, busio_i2c_obj_t *i2c, uint8_t device_address); extern uint8_t common_hal_busdevice_i2cdevice_readinto(busdevice_i2cdevice_obj_t *self, mp_obj_t buffer, size_t length); extern uint8_t common_hal_busdevice_i2cdevice_write(busdevice_i2cdevice_obj_t *self, mp_obj_t buffer, size_t length); -extern uint8_t common_hal_busdevice_i2cdevice_write_then_readinto(busdevice_i2cdevice_obj_t *self, mp_obj_t out_buffer, - mp_obj_t in_buffer, size_t out_length, size_t in_length); extern void common_hal_busdevice_i2cdevice_lock(busdevice_i2cdevice_obj_t *self); extern void common_hal_busdevice_i2cdevice_unlock(busdevice_i2cdevice_obj_t *self); -extern void common_hal_busdevice_i2cdevice___probe_for_device(busdevice_i2cdevice_obj_t *self); +extern void common_hal_busdevice_i2cdevice_probe_for_device(busdevice_i2cdevice_obj_t *self); #endif // MICROPY_INCLUDED_SHARED_BINDINGS_BUSDEVICE_I2CDEVICE_H diff --git a/shared-module/busdevice/I2CDevice.c b/shared-module/busdevice/I2CDevice.c index 91013d52c7..41706c1a81 100644 --- a/shared-module/busdevice/I2CDevice.c +++ b/shared-module/busdevice/I2CDevice.c @@ -30,16 +30,17 @@ #include "py/nlr.h" #include "py/runtime.h" -void common_hal_busdevice_i2cdevice_construct(busdevice_i2cdevice_obj_t *self, busio_i2c_obj_t *i2c, uint8_t device_address, bool probe) { +void common_hal_busdevice_i2cdevice_construct(busdevice_i2cdevice_obj_t *self, busio_i2c_obj_t *i2c, uint8_t device_address) { self->i2c = i2c; self->device_address = device_address; - self->probe = probe; } void common_hal_busdevice_i2cdevice_lock(busdevice_i2cdevice_obj_t *self) { bool success = false; while (!success) { success = common_hal_busio_i2c_try_lock(self->i2c); + RUN_BACKGROUND_TASKS; + mp_handle_pending(); } } @@ -48,29 +49,14 @@ void common_hal_busdevice_i2cdevice_unlock(busdevice_i2cdevice_obj_t *self) { } uint8_t common_hal_busdevice_i2cdevice_readinto(busdevice_i2cdevice_obj_t *self, mp_obj_t buffer, size_t length) { - uint8_t status = common_hal_busio_i2c_read(self->i2c, self->device_address, buffer, length); - - return status; + return common_hal_busio_i2c_read(self->i2c, self->device_address, buffer, length); } uint8_t common_hal_busdevice_i2cdevice_write(busdevice_i2cdevice_obj_t *self, mp_obj_t buffer, size_t length) { - uint8_t status = common_hal_busio_i2c_write(self->i2c, self->device_address, buffer, length, true); - - return status; + return common_hal_busio_i2c_write(self->i2c, self->device_address, buffer, length, true); } -uint8_t common_hal_busdevice_i2cdevice_write_then_readinto(busdevice_i2cdevice_obj_t *self, mp_obj_t out_buffer, mp_obj_t in_buffer, - size_t out_length, size_t in_length) { - uint8_t status = 0; - - status = common_hal_busio_i2c_write(self->i2c, self->device_address, out_buffer, out_length, true); - - status = common_hal_busio_i2c_read(self->i2c, self->device_address, in_buffer, in_length); - - return status; -} - -void common_hal_busdevice_i2cdevice___probe_for_device(busdevice_i2cdevice_obj_t *self) { +void common_hal_busdevice_i2cdevice_probe_for_device(busdevice_i2cdevice_obj_t *self) { common_hal_busdevice_i2cdevice_lock(self); mp_buffer_info_t bufinfo; diff --git a/shared-module/busdevice/I2CDevice.h b/shared-module/busdevice/I2CDevice.h index c872704db6..918dc7719d 100644 --- a/shared-module/busdevice/I2CDevice.h +++ b/shared-module/busdevice/I2CDevice.h @@ -34,7 +34,6 @@ typedef struct { mp_obj_base_t base; busio_i2c_obj_t *i2c; uint8_t device_address; - bool probe; } busdevice_i2cdevice_obj_t; #endif // MICROPY_INCLUDED_ATMEL_SAMD_SHARED_MODULE_BUSDEVICE_I2CDEVICE_H From 78477a374afad09aa7141af5cf590652b32c141f Mon Sep 17 00:00:00 2001 From: gamblor21 Date: Sat, 31 Oct 2020 12:17:29 -0500 Subject: [PATCH 025/207] Initial SPI commit --- py/circuitpy_defns.mk | 1 + shared-bindings/busdevice/SPIDevice.c | 124 ++++++++++++++++++++++++++ shared-bindings/busdevice/SPIDevice.h | 50 +++++++++++ shared-module/busdevice/SPIDevice.c | 85 ++++++++++++++++++ shared-module/busdevice/SPIDevice.h | 44 +++++++++ 5 files changed, 304 insertions(+) create mode 100644 shared-bindings/busdevice/SPIDevice.c create mode 100644 shared-bindings/busdevice/SPIDevice.h create mode 100644 shared-module/busdevice/SPIDevice.c create mode 100644 shared-module/busdevice/SPIDevice.h diff --git a/py/circuitpy_defns.mk b/py/circuitpy_defns.mk index 9318bd466b..4822c03208 100644 --- a/py/circuitpy_defns.mk +++ b/py/circuitpy_defns.mk @@ -437,6 +437,7 @@ SRC_SHARED_MODULE_ALL = \ board/__init__.c \ busdevice/__init__.c \ busdevice/I2CDevice.c \ + busdevice/SPIDevice.c \ busio/OneWire.c \ displayio/Bitmap.c \ displayio/ColorConverter.c \ diff --git a/shared-bindings/busdevice/SPIDevice.c b/shared-bindings/busdevice/SPIDevice.c new file mode 100644 index 0000000000..7ef047349c --- /dev/null +++ b/shared-bindings/busdevice/SPIDevice.c @@ -0,0 +1,124 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2020 Mark Komus + * + * 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 contains all of the Python API definitions for the +// busio.SPI class. + +#include "shared-bindings/microcontroller/Pin.h" +#include "shared-bindings/busdevice/SPIDevice.h" +#include "shared-bindings/util.h" +#include "shared-module/busdevice/SPIDevice.h" +#include "common-hal/digitalio/DigitalInOut.h" +#include "shared-bindings/digitalio/DigitalInOut.h" + + +#include "lib/utils/buffer_helper.h" +#include "lib/utils/context_manager_helpers.h" +#include "py/runtime.h" +#include "supervisor/shared/translate.h" + + +//| class SPIDevice: +//| """ +//| Represents a single SPI device and manages locking the bus and the device +//| address. +//| :param ~busio.SPI spi: The SPI bus the device is on +//| :param int device_address: The 7 bit device address +//| :param bool probe: Probe for the device upon object creation, default is true +//| .. note:: This class is **NOT** built into CircuitPython. See +//| :ref:`here for install instructions `. +//| Example: +//| .. code-block:: python +//| import busio +//| from board import * +//| from adafruit_bus_device.spi_device import SPIDevice +//| with busio.SPI(SCL, SDA) as spi: +//| device = SPIDevice(spi, 0x70) +//| bytes_read = bytearray(4) +//| with device: +//| device.readinto(bytes_read) +//| # A second transaction +//| with device: +//| device.write(bytes_read)""" +//| ... +//| +STATIC mp_obj_t busdevice_spidevice_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { + busdevice_spidevice_obj_t *self = m_new_obj(busdevice_spidevice_obj_t); + self->base.type = &busdevice_spidevice_type; + enum { ARG_spi, ARG_chip_select, ARG_baudrate, ARG_polarity, ARG_phase, ARG_extra_clocks }; + static const mp_arg_t allowed_args[] = { + { MP_QSTR_spi, MP_ARG_REQUIRED | MP_ARG_OBJ }, + { MP_QSTR_chip_select, MP_ARG_OBJ, {.u_obj = MP_OBJ_NULL} }, + { MP_QSTR_baudrate, MP_ARG_KW_ONLY | MP_ARG_INT, {.u_int = 100000} }, + { MP_QSTR_polarity, MP_ARG_KW_ONLY | MP_ARG_INT, {.u_int = 0} }, + { MP_QSTR_phase, MP_ARG_KW_ONLY | MP_ARG_INT, {.u_int = 0} }, + { MP_QSTR_extra_clocks, MP_ARG_KW_ONLY | MP_ARG_INT, {.u_int = 0} }, + }; + 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); + + busio_spi_obj_t* spi = args[ARG_spi].u_obj; + + common_hal_busdevice_spidevice_construct(MP_OBJ_TO_PTR(self), spi, args[ARG_chip_select].u_obj, args[ARG_baudrate].u_int, args[ARG_polarity].u_int, + args[ARG_phase].u_int, args[ARG_extra_clocks].u_int); + + if (args[ARG_chip_select].u_obj != MP_OBJ_NULL) { + digitalinout_result_t result = common_hal_digitalio_digitalinout_switch_to_output(MP_OBJ_TO_PTR(args[ARG_chip_select].u_obj), + true, DRIVE_MODE_PUSH_PULL); + if (result == DIGITALINOUT_INPUT_ONLY) { + mp_raise_NotImplementedError(translate("Pin is input only")); + } + } + + return (mp_obj_t)self; +} + +STATIC mp_obj_t busdevice_spidevice_obj___enter__(mp_obj_t self_in) { + busdevice_spidevice_obj_t *self = MP_OBJ_TO_PTR(self_in); + common_hal_busdevice_spidevice_enter(self); + return self; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_1(busdevice_spidevice___enter___obj, busdevice_spidevice_obj___enter__); + +STATIC mp_obj_t busdevice_spidevice_obj___exit__(size_t n_args, const mp_obj_t *args) { + common_hal_busdevice_spidevice_exit(MP_OBJ_TO_PTR(args[0])); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(busdevice_spidevice___exit___obj, 4, 4, busdevice_spidevice_obj___exit__); + +STATIC const mp_rom_map_elem_t busdevice_spidevice_locals_dict_table[] = { + { MP_ROM_QSTR(MP_QSTR___enter__), MP_ROM_PTR(&busdevice_spidevice___enter___obj) }, + { MP_ROM_QSTR(MP_QSTR___exit__), MP_ROM_PTR(&busdevice_spidevice___exit___obj) }, +}; + +STATIC MP_DEFINE_CONST_DICT(busdevice_spidevice_locals_dict, busdevice_spidevice_locals_dict_table); + +const mp_obj_type_t busdevice_spidevice_type = { + { &mp_type_type }, + .name = MP_QSTR_SPIDevice, + .make_new = busdevice_spidevice_make_new, + .locals_dict = (mp_obj_dict_t*)&busdevice_spidevice_locals_dict, +}; diff --git a/shared-bindings/busdevice/SPIDevice.h b/shared-bindings/busdevice/SPIDevice.h new file mode 100644 index 0000000000..040f98548e --- /dev/null +++ b/shared-bindings/busdevice/SPIDevice.h @@ -0,0 +1,50 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2020 Mark Komus + * + * 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. + */ + +// Machine is the HAL for low-level, hardware accelerated functions. It is not +// meant to simplify APIs, its only meant to unify them so that other modules +// do not require port specific logic. +// +// This file includes externs for all functions a port should implement to +// support the machine module. + +#ifndef MICROPY_INCLUDED_SHARED_BINDINGS_BUSDEVICE_SPIDEVICE_H +#define MICROPY_INCLUDED_SHARED_BINDINGS_BUSDEVICE_SPIDEVICE_H + +#include "py/obj.h" + +#include "shared-module/busdevice/SPIDevice.h" + +// Type object used in Python. Should be shared between ports. +extern const mp_obj_type_t busdevice_spidevice_type; + +// Initializes the hardware peripheral. +extern void common_hal_busdevice_spidevice_construct(busdevice_spidevice_obj_t *self, busio_spi_obj_t *spi, digitalio_digitalinout_obj_t *cs, + uint32_t baudrate, uint8_t polarity, uint8_t phase, uint8_t extra_clocks); +extern void common_hal_busdevice_spidevice_enter(busdevice_spidevice_obj_t *self); +extern void common_hal_busdevice_spidevice_exit(busdevice_spidevice_obj_t *self); + +#endif // MICROPY_INCLUDED_SHARED_BINDINGS_BUSDEVICE_SPIDEVICE_H diff --git a/shared-module/busdevice/SPIDevice.c b/shared-module/busdevice/SPIDevice.c new file mode 100644 index 0000000000..d9b63a007e --- /dev/null +++ b/shared-module/busdevice/SPIDevice.c @@ -0,0 +1,85 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2020 Mark Komus + * + * 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/busdevice/SPIDevice.h" +#include "shared-bindings/busio/SPI.h" +#include "shared-bindings/digitalio/DigitalInOut.h" +#include "py/mperrno.h" +#include "py/nlr.h" +#include "py/runtime.h" + +void common_hal_busdevice_spidevice_construct(busdevice_spidevice_obj_t *self, busio_spi_obj_t *spi, digitalio_digitalinout_obj_t *cs, + uint32_t baudrate, uint8_t polarity, uint8_t phase, uint8_t extra_clocks) { + self->spi = spi; + self->baudrate = baudrate; + self->polarity = polarity; + self->phase = phase; + self->extra_clocks = extra_clocks; + self->chip_select = cs; +} + +void common_hal_busdevice_spidevice_enter(busdevice_spidevice_obj_t *self) { + bool success = false; + while (!success) { + success = common_hal_busio_spi_try_lock(self->spi); + RUN_BACKGROUND_TASKS; + mp_handle_pending(); + } + + common_hal_busio_spi_configure(self->spi, self->baudrate, self->polarity, self->phase, 8); + + if (self->chip_select != MP_OBJ_NULL) { + common_hal_digitalio_digitalinout_set_value(MP_OBJ_TO_PTR(self->chip_select), false); + } +} + +void common_hal_busdevice_spidevice_exit(busdevice_spidevice_obj_t *self) { + if (self->chip_select != MP_OBJ_NULL) { + common_hal_digitalio_digitalinout_set_value(MP_OBJ_TO_PTR(self->chip_select), true); + } + + if (self->extra_clocks > 0) { + + mp_buffer_info_t bufinfo; + mp_obj_t buffer = mp_obj_new_bytearray_of_zeros(1); + + mp_get_buffer_raise(buffer, &bufinfo, MP_BUFFER_READ); + ((uint8_t*)bufinfo.buf)[0] = 0xFF; + + uint8_t clocks = self->extra_clocks / 8; + if ((self->extra_clocks % 8) != 0) + clocks += 1; + + while (clocks > 0) { + if (!common_hal_busio_spi_write(self->spi, ((uint8_t*)bufinfo.buf), 1)) { + mp_raise_OSError(MP_EIO); + } + clocks--; + } + } + + common_hal_busio_spi_unlock(self->spi); +} diff --git a/shared-module/busdevice/SPIDevice.h b/shared-module/busdevice/SPIDevice.h new file mode 100644 index 0000000000..ffabf79dff --- /dev/null +++ b/shared-module/busdevice/SPIDevice.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 + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#ifndef MICROPY_INCLUDED_ATMEL_SAMD_SHARED_MODULE_BUSDEVICE_SPIDEVICE_H +#define MICROPY_INCLUDED_ATMEL_SAMD_SHARED_MODULE_BUSDEVICE_SPIDEVICE_H + +#include "py/obj.h" +#include "common-hal/busio/SPI.h" +#include "common-hal/digitalio/DigitalInOut.h" + +typedef struct { + mp_obj_base_t base; + busio_spi_obj_t *spi; + uint32_t baudrate; + uint8_t polarity; + uint8_t phase; + uint8_t extra_clocks; + digitalio_digitalinout_obj_t *chip_select; +} busdevice_spidevice_obj_t; + +#endif // MICROPY_INCLUDED_ATMEL_SAMD_SHARED_MODULE_BUSDEVICE_SPIDEVICE_H From 5ea09fe34847f6d05e579e8e838501438f122640 Mon Sep 17 00:00:00 2001 From: gamblor21 Date: Sat, 31 Oct 2020 13:37:05 -0500 Subject: [PATCH 026/207] Fixed stubs --- shared-bindings/busdevice/I2CDevice.c | 80 +++++++++++++++------------ shared-bindings/busdevice/__init__.c | 2 +- 2 files changed, 46 insertions(+), 36 deletions(-) diff --git a/shared-bindings/busdevice/I2CDevice.c b/shared-bindings/busdevice/I2CDevice.c index f5e968137c..e0e89e16ab 100644 --- a/shared-bindings/busdevice/I2CDevice.c +++ b/shared-bindings/busdevice/I2CDevice.c @@ -39,27 +39,30 @@ //| class I2CDevice: -//| """ -//| Represents a single I2C device and manages locking the bus and the device -//| address. -//| :param ~busio.I2C i2c: The I2C bus the device is on -//| :param int device_address: The 7 bit device address -//| :param bool probe: Probe for the device upon object creation, default is true -//| .. note:: This class is **NOT** built into CircuitPython. See -//| :ref:`here for install instructions `. -//| Example: -//| .. code-block:: python -//| import busio -//| from board import * -//| from adafruit_bus_device.i2c_device import I2CDevice -//| with busio.I2C(SCL, SDA) as i2c: -//| device = I2CDevice(i2c, 0x70) -//| bytes_read = bytearray(4) -//| with device: -//| device.readinto(bytes_read) -//| # A second transaction -//| with device: -//| device.write(bytes_read)""" +//| """I2C Device Manager""" +//| +//| def __init__(self, scl: microcontroller.Pin, sda: microcontroller.Pin, *, frequency: int = 100000, timeout: int = 255) -> None: +//| +//| """Represents a single I2C device and manages locking the bus and the device +//| address. +//| :param ~busio.I2C i2c: The I2C bus the device is on +//| :param int device_address: The 7 bit device address +//| :param bool probe: Probe for the device upon object creation, default is true +//| .. note:: This class is **NOT** built into CircuitPython. See +//| :ref:`here for install instructions `. +//| Example: +//| .. code-block:: python +//| import busio +//| from board import * +//| from adafruit_bus_device.i2c_device import I2CDevice +//| with busio.I2C(SCL, SDA) as i2c: +//| device = I2CDevice(i2c, 0x70) +//| bytes_read = bytearray(4) +//| with device: +//| device.readinto(bytes_read) +//| # A second transaction +//| with device: +//| device.write(bytes_read)""" //| ... //| STATIC mp_obj_t busdevice_i2cdevice_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { @@ -84,6 +87,10 @@ STATIC mp_obj_t busdevice_i2cdevice_make_new(const mp_obj_type_t *type, size_t n return (mp_obj_t)self; } +//| def __enter__(self) -> I2C: +//| """Context manager entry to lock bus.""" +//| ... +//| STATIC mp_obj_t busdevice_i2cdevice_obj___enter__(mp_obj_t self_in) { busdevice_i2cdevice_obj_t *self = MP_OBJ_TO_PTR(self_in); common_hal_busdevice_i2cdevice_lock(self); @@ -91,13 +98,17 @@ STATIC mp_obj_t busdevice_i2cdevice_obj___enter__(mp_obj_t self_in) { } STATIC MP_DEFINE_CONST_FUN_OBJ_1(busdevice_i2cdevice___enter___obj, busdevice_i2cdevice_obj___enter__); +//| def __exit__(self) -> None: +//| """Automatically unlocks the bus on exit.""" +//| ... +//| STATIC mp_obj_t busdevice_i2cdevice_obj___exit__(size_t n_args, const mp_obj_t *args) { common_hal_busdevice_i2cdevice_unlock(MP_OBJ_TO_PTR(args[0])); return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(busdevice_i2cdevice___exit___obj, 4, 4, busdevice_i2cdevice_obj___exit__); -//| def readinto(self, buf, *, start=0, end=None): +//| def readinto(self, buf, *, start=0, end=None) -> None: //| """ //| Read into ``buf`` from the device. The number of bytes read will be the //| length of ``buf``. @@ -143,18 +154,17 @@ STATIC mp_obj_t busdevice_i2cdevice_readinto(size_t n_args, const mp_obj_t *pos_ } STATIC MP_DEFINE_CONST_FUN_OBJ_KW(busdevice_i2cdevice_readinto_obj, 2, busdevice_i2cdevice_readinto); -//| def write(self, buf, *, start=0, end=None): -//| """ -//| Write the bytes from ``buffer`` to the device, then transmit a stop -//| bit. -//| If ``start`` or ``end`` is provided, then the buffer will be sliced -//| as if ``buffer[start:end]``. This will not cause an allocation like -//| ``buffer[start:end]`` will so it saves memory. -//| :param bytearray buffer: buffer containing the bytes to write -//| :param int start: Index to start writing from -//| :param int end: Index to read up to but not include; if None, use ``len(buf)`` -//| """ -//| ... +//| def write(self, buf, *, start=0, end=None) -> None: +//| """ +//| Write the bytes from ``buffer`` to the device, then transmit a stop bit. +//| If ``start`` or ``end`` is provided, then the buffer will be sliced +//| as if ``buffer[start:end]``. This will not cause an allocation like +//| ``buffer[start:end]`` will so it saves memory. +//| :param bytearray buffer: buffer containing the bytes to write +//| :param int start: Index to start writing from +//| :param int end: Index to read up to but not include; if None, use ``len(buf)`` +//| """ +//| ... //| STATIC void write(busdevice_i2cdevice_obj_t *self, mp_obj_t buffer, int32_t start, mp_int_t end) { mp_buffer_info_t bufinfo; @@ -190,7 +200,7 @@ STATIC mp_obj_t busdevice_i2cdevice_write(size_t n_args, const mp_obj_t *pos_arg MP_DEFINE_CONST_FUN_OBJ_KW(busdevice_i2cdevice_write_obj, 2, busdevice_i2cdevice_write); -//| def write_then_readinto(self, out_buffer, in_buffer, *, out_start=0, out_end=None, in_start=0, in_end=None): +//| def write_then_readinto(self, out_buffer, in_buffer, *, out_start=0, out_end=None, in_start=0, in_end=None) -> None: //| """ //| Write the bytes from ``out_buffer`` to the device, then immediately //| reads into ``in_buffer`` from the device. The number of bytes read diff --git a/shared-bindings/busdevice/__init__.c b/shared-bindings/busdevice/__init__.c index 112dabb7eb..391d3698a8 100644 --- a/shared-bindings/busdevice/__init__.c +++ b/shared-bindings/busdevice/__init__.c @@ -40,7 +40,7 @@ //| The I2CDevice and SPIDevice helper classes make managing transaction state on a bus easy. //| For example, they manage locking the bus to prevent other concurrent access. For SPI //| devices, it manages the chip select and protocol changes such as mode. For I2C, it -//| manages the device address. +//| manages the device address.""" //| STATIC const mp_rom_map_elem_t busdevice_module_globals_table[] = { From 76c11533807a12571889b81136d710dfc9da2c56 Mon Sep 17 00:00:00 2001 From: gamblor21 Date: Sun, 1 Nov 2020 08:57:31 -0600 Subject: [PATCH 027/207] Fixed stubs --- shared-bindings/busdevice/I2CDevice.c | 2 +- shared-bindings/busdevice/SPIDevice.c | 53 +++++++++++++++------------ 2 files changed, 30 insertions(+), 25 deletions(-) diff --git a/shared-bindings/busdevice/I2CDevice.c b/shared-bindings/busdevice/I2CDevice.c index e0e89e16ab..5f1fac3197 100644 --- a/shared-bindings/busdevice/I2CDevice.c +++ b/shared-bindings/busdevice/I2CDevice.c @@ -41,7 +41,7 @@ //| class I2CDevice: //| """I2C Device Manager""" //| -//| def __init__(self, scl: microcontroller.Pin, sda: microcontroller.Pin, *, frequency: int = 100000, timeout: int = 255) -> None: +//| def __init__(self, i2c: busio.I2C, device_address: int, probe: bool = True) -> None: //| //| """Represents a single I2C device and manages locking the bus and the device //| address. diff --git a/shared-bindings/busdevice/SPIDevice.c b/shared-bindings/busdevice/SPIDevice.c index 7ef047349c..039cd842c9 100644 --- a/shared-bindings/busdevice/SPIDevice.c +++ b/shared-bindings/busdevice/SPIDevice.c @@ -24,9 +24,6 @@ * THE SOFTWARE. */ -// This file contains all of the Python API definitions for the -// busio.SPI class. - #include "shared-bindings/microcontroller/Pin.h" #include "shared-bindings/busdevice/SPIDevice.h" #include "shared-bindings/util.h" @@ -42,27 +39,35 @@ //| class SPIDevice: -//| """ -//| Represents a single SPI device and manages locking the bus and the device -//| address. -//| :param ~busio.SPI spi: The SPI bus the device is on -//| :param int device_address: The 7 bit device address -//| :param bool probe: Probe for the device upon object creation, default is true -//| .. note:: This class is **NOT** built into CircuitPython. See -//| :ref:`here for install instructions `. -//| Example: -//| .. code-block:: python -//| import busio -//| from board import * -//| from adafruit_bus_device.spi_device import SPIDevice -//| with busio.SPI(SCL, SDA) as spi: -//| device = SPIDevice(spi, 0x70) -//| bytes_read = bytearray(4) -//| with device: -//| device.readinto(bytes_read) -//| # A second transaction -//| with device: -//| device.write(bytes_read)""" +//| """SPI Device Manager""" +//| +//| def __init__(self, spi: busio.SPI, chip_select: microcontroller.Pin, *, baudrate: int = 100000, polarity: int = 0, phase: int = 0, extra_clocks : int = 0) -> None: +//| +//| """ +//| Represents a single SPI device and manages locking the bus and the device address. +//| :param ~busio.SPI spi: The SPI bus the device is on +//| :param ~digitalio.DigitalInOut chip_select: The chip select pin object that implements the +//| DigitalInOut API. +//| :param int extra_clocks: The minimum number of clock cycles to cycle the bus after CS is high. +//| (Used for SD cards.) +//| Example: +//| .. code-block:: python +//| import busio +//| import digitalio +//| from board import * +//| from adafruit_bus_device.spi_device import SPIDevice +//| with busio.SPI(SCK, MOSI, MISO) as spi_bus: +//| cs = digitalio.DigitalInOut(D10) +//| device = SPIDevice(spi_bus, cs) +//| bytes_read = bytearray(4) +//| # The object assigned to spi in the with statements below +//| # is the original spi_bus object. We are using the busio.SPI +//| # operations busio.SPI.readinto() and busio.SPI.write(). +//| with device as spi: +//| spi.readinto(bytes_read) +//| # A second transaction +//| with device as spi: +//| spi.write(bytes_read)""" //| ... //| STATIC mp_obj_t busdevice_spidevice_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { From 7dd53804a023dad0ae8f6b8504522f88c6015e90 Mon Sep 17 00:00:00 2001 From: gamblor21 Date: Sun, 1 Nov 2020 10:31:31 -0600 Subject: [PATCH 028/207] Fixed stubs again --- shared-bindings/busdevice/I2CDevice.c | 7 +++---- shared-bindings/busdevice/SPIDevice.c | 11 +++++------ 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/shared-bindings/busdevice/I2CDevice.c b/shared-bindings/busdevice/I2CDevice.c index 5f1fac3197..43996138b7 100644 --- a/shared-bindings/busdevice/I2CDevice.c +++ b/shared-bindings/busdevice/I2CDevice.c @@ -48,10 +48,9 @@ //| :param ~busio.I2C i2c: The I2C bus the device is on //| :param int device_address: The 7 bit device address //| :param bool probe: Probe for the device upon object creation, default is true -//| .. note:: This class is **NOT** built into CircuitPython. See -//| :ref:`here for install instructions `. -//| Example: -//| .. code-block:: python +//| +//| Example:: +//| //| import busio //| from board import * //| from adafruit_bus_device.i2c_device import I2CDevice diff --git a/shared-bindings/busdevice/SPIDevice.c b/shared-bindings/busdevice/SPIDevice.c index 039cd842c9..4c633b4fd4 100644 --- a/shared-bindings/busdevice/SPIDevice.c +++ b/shared-bindings/busdevice/SPIDevice.c @@ -46,12 +46,11 @@ //| """ //| Represents a single SPI device and manages locking the bus and the device address. //| :param ~busio.SPI spi: The SPI bus the device is on -//| :param ~digitalio.DigitalInOut chip_select: The chip select pin object that implements the -//| DigitalInOut API. -//| :param int extra_clocks: The minimum number of clock cycles to cycle the bus after CS is high. -//| (Used for SD cards.) -//| Example: -//| .. code-block:: python +//| :param ~digitalio.DigitalInOut chip_select: The chip select pin object that implements the DigitalInOut API. +//| :param int extra_clocks: The minimum number of clock cycles to cycle the bus after CS is high. (Used for SD cards.) +//| +//| Example:: +//| //| import busio //| import digitalio //| from board import * From 8bbbb2833ad6d9b649132559795f58f8f31f486f Mon Sep 17 00:00:00 2001 From: gamblor21 Date: Sun, 1 Nov 2020 21:38:20 -0600 Subject: [PATCH 029/207] Fixes from testing SPI --- shared-bindings/busdevice/SPIDevice.c | 2 +- shared-bindings/busdevice/__init__.c | 2 ++ shared-module/busdevice/I2CDevice.c | 4 ++-- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/shared-bindings/busdevice/SPIDevice.c b/shared-bindings/busdevice/SPIDevice.c index 4c633b4fd4..631d0eec49 100644 --- a/shared-bindings/busdevice/SPIDevice.c +++ b/shared-bindings/busdevice/SPIDevice.c @@ -103,7 +103,7 @@ STATIC mp_obj_t busdevice_spidevice_make_new(const mp_obj_type_t *type, size_t n STATIC mp_obj_t busdevice_spidevice_obj___enter__(mp_obj_t self_in) { busdevice_spidevice_obj_t *self = MP_OBJ_TO_PTR(self_in); common_hal_busdevice_spidevice_enter(self); - return self; + return self->spi; } STATIC MP_DEFINE_CONST_FUN_OBJ_1(busdevice_spidevice___enter___obj, busdevice_spidevice_obj___enter__); diff --git a/shared-bindings/busdevice/__init__.c b/shared-bindings/busdevice/__init__.c index 391d3698a8..6e6ede532f 100644 --- a/shared-bindings/busdevice/__init__.c +++ b/shared-bindings/busdevice/__init__.c @@ -33,6 +33,7 @@ #include "shared-bindings/busdevice/__init__.h" #include "shared-bindings/busdevice/I2CDevice.h" +#include "shared-bindings/busdevice/SPIDevice.h" //| """Hardware accelerated external bus access @@ -46,6 +47,7 @@ STATIC const mp_rom_map_elem_t busdevice_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_busdevice) }, { MP_ROM_QSTR(MP_QSTR_I2CDevice), MP_ROM_PTR(&busdevice_i2cdevice_type) }, + { MP_ROM_QSTR(MP_QSTR_SPIDevice), MP_ROM_PTR(&busdevice_spidevice_type) }, }; STATIC MP_DEFINE_CONST_DICT(busdevice_module_globals, busdevice_module_globals_table); diff --git a/shared-module/busdevice/I2CDevice.c b/shared-module/busdevice/I2CDevice.c index 41706c1a81..b9f8ee25c0 100644 --- a/shared-module/busdevice/I2CDevice.c +++ b/shared-module/busdevice/I2CDevice.c @@ -39,8 +39,8 @@ void common_hal_busdevice_i2cdevice_lock(busdevice_i2cdevice_obj_t *self) { bool success = false; while (!success) { success = common_hal_busio_i2c_try_lock(self->i2c); - RUN_BACKGROUND_TASKS; - mp_handle_pending(); + //RUN_BACKGROUND_TASKS; + //mp_handle_pending(); } } From 197539bd8262132155929927db974616f550f033 Mon Sep 17 00:00:00 2001 From: gamblor21 Date: Tue, 3 Nov 2020 17:30:33 -0600 Subject: [PATCH 030/207] Moved I2CDevice and SPI to match python library --- shared-bindings/busdevice/__init__.c | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/shared-bindings/busdevice/__init__.c b/shared-bindings/busdevice/__init__.c index 6e6ede532f..a9a1a83a33 100644 --- a/shared-bindings/busdevice/__init__.c +++ b/shared-bindings/busdevice/__init__.c @@ -35,6 +35,27 @@ #include "shared-bindings/busdevice/I2CDevice.h" #include "shared-bindings/busdevice/SPIDevice.h" +STATIC const mp_rom_map_elem_t busdevice_i2c_device_globals_table[] = { + { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_i2c_device) }, + { MP_ROM_QSTR(MP_QSTR_I2CDevice), MP_ROM_PTR(&busdevice_i2cdevice_type) }, +}; +STATIC MP_DEFINE_CONST_DICT(busdevice_i2c_device_globals, busdevice_i2c_device_globals_table); + +const mp_obj_module_t busdevice_i2c_device_module = { + .base = { &mp_type_module }, + .globals = (mp_obj_dict_t*)&busdevice_i2c_device_globals, +}; + +STATIC const mp_rom_map_elem_t busdevice_spi_device_globals_table[] = { + { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_spi_device) }, + { MP_ROM_QSTR(MP_QSTR_SPIDevice), MP_ROM_PTR(&busdevice_spidevice_type) }, +}; +STATIC MP_DEFINE_CONST_DICT(busdevice_spi_device_globals, busdevice_spi_device_globals_table); + +const mp_obj_module_t busdevice_spi_device_module = { + .base = { &mp_type_module }, + .globals = (mp_obj_dict_t*)&busdevice_spi_device_globals, +}; //| """Hardware accelerated external bus access //| @@ -43,11 +64,10 @@ //| devices, it manages the chip select and protocol changes such as mode. For I2C, it //| manages the device address.""" //| - STATIC const mp_rom_map_elem_t busdevice_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_busdevice) }, - { MP_ROM_QSTR(MP_QSTR_I2CDevice), MP_ROM_PTR(&busdevice_i2cdevice_type) }, - { MP_ROM_QSTR(MP_QSTR_SPIDevice), MP_ROM_PTR(&busdevice_spidevice_type) }, + { MP_ROM_QSTR(MP_QSTR_i2c_device), MP_ROM_PTR(&busdevice_i2c_device_module) }, + { MP_ROM_QSTR(MP_QSTR_spi_device), MP_ROM_PTR(&busdevice_spi_device_module) }, }; STATIC MP_DEFINE_CONST_DICT(busdevice_module_globals, busdevice_module_globals_table); From 4c93db35959e96889b3a28af792c837fbe1fdca5 Mon Sep 17 00:00:00 2001 From: gamblor21 Date: Tue, 3 Nov 2020 18:35:20 -0600 Subject: [PATCH 031/207] Renamed to adafruit_bus_device --- py/circuitpy_defns.mk | 8 +- py/circuitpy_mpconfig.h | 4 +- py/circuitpy_mpconfig.mk | 2 +- .../I2CDevice.c | 74 +++++++++---------- .../I2CDevice.h | 16 ++-- .../SPIDevice.c | 40 +++++----- .../SPIDevice.h | 10 +-- .../__init__.c | 40 +++++----- .../__init__.h | 0 .../I2CDevice.c | 22 +++--- .../I2CDevice.h | 2 +- .../SPIDevice.c | 8 +- .../SPIDevice.h | 2 +- .../__init__.c | 0 14 files changed, 114 insertions(+), 114 deletions(-) rename shared-bindings/{busdevice => adafruit_bus_device}/I2CDevice.c (71%) rename shared-bindings/{busdevice => adafruit_bus_device}/I2CDevice.h (68%) rename shared-bindings/{busdevice => adafruit_bus_device}/SPIDevice.c (70%) rename shared-bindings/{busdevice => adafruit_bus_device}/SPIDevice.h (79%) rename shared-bindings/{busdevice => adafruit_bus_device}/__init__.c (55%) rename shared-bindings/{busdevice => adafruit_bus_device}/__init__.h (100%) rename shared-module/{busdevice => adafruit_bus_device}/I2CDevice.c (66%) rename shared-module/{busdevice => adafruit_bus_device}/I2CDevice.h (97%) rename shared-module/{busdevice => adafruit_bus_device}/SPIDevice.c (87%) rename shared-module/{busdevice => adafruit_bus_device}/SPIDevice.h (97%) rename shared-module/{busdevice => adafruit_bus_device}/__init__.c (100%) diff --git a/py/circuitpy_defns.mk b/py/circuitpy_defns.mk index 4822c03208..41ef8d742a 100644 --- a/py/circuitpy_defns.mk +++ b/py/circuitpy_defns.mk @@ -134,7 +134,7 @@ ifeq ($(CIRCUITPY_BOARD),1) SRC_PATTERNS += board/% endif ifeq ($(CIRCUITPY_BUSDEVICE),1) -SRC_PATTERNS += busdevice/% +SRC_PATTERNS += adafruit_bus_device/% endif ifeq ($(CIRCUITPY_BUSIO),1) SRC_PATTERNS += busio/% bitbangio/OneWire.% @@ -435,9 +435,9 @@ SRC_SHARED_MODULE_ALL = \ bitbangio/SPI.c \ bitbangio/__init__.c \ board/__init__.c \ - busdevice/__init__.c \ - busdevice/I2CDevice.c \ - busdevice/SPIDevice.c \ + adafruit_bus_device/__init__.c \ + adafruit_bus_device/I2CDevice.c \ + adafruit_bus_device/SPIDevice.c \ busio/OneWire.c \ displayio/Bitmap.c \ displayio/ColorConverter.c \ diff --git a/py/circuitpy_mpconfig.h b/py/circuitpy_mpconfig.h index 240fac189b..78de7905a2 100644 --- a/py/circuitpy_mpconfig.h +++ b/py/circuitpy_mpconfig.h @@ -325,8 +325,8 @@ extern const struct _mp_obj_module_t board_module; #endif #if CIRCUITPY_BUSDEVICE -extern const struct _mp_obj_module_t busdevice_module; -#define BUSDEVICE_MODULE { MP_OBJ_NEW_QSTR(MP_QSTR_busdevice), (mp_obj_t)&busdevice_module }, +extern const struct _mp_obj_module_t adafruit_bus_device_module; +#define BUSDEVICE_MODULE { MP_OBJ_NEW_QSTR(MP_QSTR_adafruit_bus_device), (mp_obj_t)&adafruit_bus_device_module }, #else #define BUSDEVICE_MODULE #endif diff --git a/py/circuitpy_mpconfig.mk b/py/circuitpy_mpconfig.mk index 1f96a8f2dd..e814edd169 100644 --- a/py/circuitpy_mpconfig.mk +++ b/py/circuitpy_mpconfig.mk @@ -90,7 +90,7 @@ CFLAGS += -DCIRCUITPY_BLEIO=$(CIRCUITPY_BLEIO) CIRCUITPY_BOARD ?= 1 CFLAGS += -DCIRCUITPY_BOARD=$(CIRCUITPY_BOARD) -CIRCUITPY_BUSDEVICE ?= 1 +CIRCUITPY_BUSDEVICE ?= $(CIRCUITPY_FULL_BUILD) CFLAGS += -DCIRCUITPY_BUSDEVICE=$(CIRCUITPY_BUSDEVICE) CIRCUITPY_BUSIO ?= 1 diff --git a/shared-bindings/busdevice/I2CDevice.c b/shared-bindings/adafruit_bus_device/I2CDevice.c similarity index 71% rename from shared-bindings/busdevice/I2CDevice.c rename to shared-bindings/adafruit_bus_device/I2CDevice.c index 43996138b7..3ec4dae12e 100644 --- a/shared-bindings/busdevice/I2CDevice.c +++ b/shared-bindings/adafruit_bus_device/I2CDevice.c @@ -28,9 +28,9 @@ // busio.I2C class. #include "shared-bindings/microcontroller/Pin.h" -#include "shared-bindings/busdevice/I2CDevice.h" +#include "shared-bindings/adafruit_bus_device/I2CDevice.h" #include "shared-bindings/util.h" -#include "shared-module/busdevice/I2CDevice.h" +#include "shared-module/adafruit_bus_device/I2CDevice.h" #include "lib/utils/buffer_helper.h" #include "lib/utils/context_manager_helpers.h" @@ -64,9 +64,9 @@ //| device.write(bytes_read)""" //| ... //| -STATIC mp_obj_t busdevice_i2cdevice_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { - busdevice_i2cdevice_obj_t *self = m_new_obj(busdevice_i2cdevice_obj_t); - self->base.type = &busdevice_i2cdevice_type; +STATIC mp_obj_t adafruit_bus_device_i2cdevice_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { + adafruit_bus_device_i2cdevice_obj_t *self = m_new_obj(adafruit_bus_device_i2cdevice_obj_t); + self->base.type = &adafruit_bus_device_i2cdevice_type; enum { ARG_i2c, ARG_device_address, ARG_probe }; static const mp_arg_t allowed_args[] = { { MP_QSTR_i2c, MP_ARG_REQUIRED | MP_ARG_OBJ }, @@ -78,9 +78,9 @@ STATIC mp_obj_t busdevice_i2cdevice_make_new(const mp_obj_type_t *type, size_t n busio_i2c_obj_t* i2c = args[ARG_i2c].u_obj; - common_hal_busdevice_i2cdevice_construct(MP_OBJ_TO_PTR(self), i2c, args[ARG_device_address].u_int); + common_hal_adafruit_bus_device_i2cdevice_construct(MP_OBJ_TO_PTR(self), i2c, args[ARG_device_address].u_int); if (args[ARG_probe].u_bool == true) { - common_hal_busdevice_i2cdevice_probe_for_device(self); + common_hal_adafruit_bus_device_i2cdevice_probe_for_device(self); } return (mp_obj_t)self; @@ -90,22 +90,22 @@ STATIC mp_obj_t busdevice_i2cdevice_make_new(const mp_obj_type_t *type, size_t n //| """Context manager entry to lock bus.""" //| ... //| -STATIC mp_obj_t busdevice_i2cdevice_obj___enter__(mp_obj_t self_in) { - busdevice_i2cdevice_obj_t *self = MP_OBJ_TO_PTR(self_in); - common_hal_busdevice_i2cdevice_lock(self); +STATIC mp_obj_t adafruit_bus_device_i2cdevice_obj___enter__(mp_obj_t self_in) { + adafruit_bus_device_i2cdevice_obj_t *self = MP_OBJ_TO_PTR(self_in); + common_hal_adafruit_bus_device_i2cdevice_lock(self); return self; } -STATIC MP_DEFINE_CONST_FUN_OBJ_1(busdevice_i2cdevice___enter___obj, busdevice_i2cdevice_obj___enter__); +STATIC MP_DEFINE_CONST_FUN_OBJ_1(adafruit_bus_device_i2cdevice___enter___obj, adafruit_bus_device_i2cdevice_obj___enter__); //| def __exit__(self) -> None: //| """Automatically unlocks the bus on exit.""" //| ... //| -STATIC mp_obj_t busdevice_i2cdevice_obj___exit__(size_t n_args, const mp_obj_t *args) { - common_hal_busdevice_i2cdevice_unlock(MP_OBJ_TO_PTR(args[0])); +STATIC mp_obj_t adafruit_bus_device_i2cdevice_obj___exit__(size_t n_args, const mp_obj_t *args) { + common_hal_adafruit_bus_device_i2cdevice_unlock(MP_OBJ_TO_PTR(args[0])); return mp_const_none; } -STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(busdevice_i2cdevice___exit___obj, 4, 4, busdevice_i2cdevice_obj___exit__); +STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(adafruit_bus_device_i2cdevice___exit___obj, 4, 4, adafruit_bus_device_i2cdevice_obj___exit__); //| def readinto(self, buf, *, start=0, end=None) -> None: //| """ @@ -119,7 +119,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(busdevice_i2cdevice___exit___obj, 4, //| :param int end: Index to write up to but not include; if None, use ``len(buf)``""" //| ... //| -STATIC void readinto(busdevice_i2cdevice_obj_t *self, mp_obj_t buffer, int32_t start, mp_int_t end) { +STATIC void readinto(adafruit_bus_device_i2cdevice_obj_t *self, mp_obj_t buffer, int32_t start, mp_int_t end) { mp_buffer_info_t bufinfo; mp_get_buffer_raise(buffer, &bufinfo, MP_BUFFER_WRITE); @@ -129,13 +129,13 @@ STATIC void readinto(busdevice_i2cdevice_obj_t *self, mp_obj_t buffer, int32_t s mp_raise_ValueError(translate("Buffer must be at least length 1")); } - uint8_t status = common_hal_busdevice_i2cdevice_readinto(MP_OBJ_TO_PTR(self), ((uint8_t*)bufinfo.buf) + start, length); + uint8_t status = common_hal_adafruit_bus_device_i2cdevice_readinto(MP_OBJ_TO_PTR(self), ((uint8_t*)bufinfo.buf) + start, length); if (status != 0) { mp_raise_OSError(status); } } -STATIC mp_obj_t busdevice_i2cdevice_readinto(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { +STATIC mp_obj_t adafruit_bus_device_i2cdevice_readinto(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum { ARG_buffer, ARG_start, ARG_end }; static const mp_arg_t allowed_args[] = { { MP_QSTR_buffer, MP_ARG_REQUIRED | MP_ARG_OBJ }, @@ -143,7 +143,7 @@ STATIC mp_obj_t busdevice_i2cdevice_readinto(size_t n_args, const mp_obj_t *pos_ { MP_QSTR_end, MP_ARG_KW_ONLY | MP_ARG_INT, {.u_int = INT_MAX} }, }; - busdevice_i2cdevice_obj_t *self = MP_OBJ_TO_PTR(pos_args[0]); + adafruit_bus_device_i2cdevice_obj_t *self = MP_OBJ_TO_PTR(pos_args[0]); 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); @@ -151,7 +151,7 @@ STATIC mp_obj_t busdevice_i2cdevice_readinto(size_t n_args, const mp_obj_t *pos_ readinto(self, args[ARG_buffer].u_obj, args[ARG_start].u_int, args[ARG_end].u_int); return mp_const_none; } -STATIC MP_DEFINE_CONST_FUN_OBJ_KW(busdevice_i2cdevice_readinto_obj, 2, busdevice_i2cdevice_readinto); +STATIC MP_DEFINE_CONST_FUN_OBJ_KW(adafruit_bus_device_i2cdevice_readinto_obj, 2, adafruit_bus_device_i2cdevice_readinto); //| def write(self, buf, *, start=0, end=None) -> None: //| """ @@ -165,7 +165,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_KW(busdevice_i2cdevice_readinto_obj, 2, busdevice //| """ //| ... //| -STATIC void write(busdevice_i2cdevice_obj_t *self, mp_obj_t buffer, int32_t start, mp_int_t end) { +STATIC void write(adafruit_bus_device_i2cdevice_obj_t *self, mp_obj_t buffer, int32_t start, mp_int_t end) { mp_buffer_info_t bufinfo; mp_get_buffer_raise(buffer, &bufinfo, MP_BUFFER_READ); @@ -175,20 +175,20 @@ STATIC void write(busdevice_i2cdevice_obj_t *self, mp_obj_t buffer, int32_t star mp_raise_ValueError(translate("Buffer must be at least length 1")); } - uint8_t status = common_hal_busdevice_i2cdevice_write(MP_OBJ_TO_PTR(self), ((uint8_t*)bufinfo.buf) + start, length); + uint8_t status = common_hal_adafruit_bus_device_i2cdevice_write(MP_OBJ_TO_PTR(self), ((uint8_t*)bufinfo.buf) + start, length); if (status != 0) { mp_raise_OSError(status); } } -STATIC mp_obj_t busdevice_i2cdevice_write(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { +STATIC mp_obj_t adafruit_bus_device_i2cdevice_write(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum { ARG_buffer, ARG_start, ARG_end }; static const mp_arg_t allowed_args[] = { { MP_QSTR_buffer, MP_ARG_REQUIRED | MP_ARG_OBJ }, { MP_QSTR_start, MP_ARG_KW_ONLY | MP_ARG_INT, {.u_int = 0} }, { MP_QSTR_end, MP_ARG_KW_ONLY | MP_ARG_INT, {.u_int = INT_MAX} }, }; - busdevice_i2cdevice_obj_t *self = MP_OBJ_TO_PTR(pos_args[0]); + adafruit_bus_device_i2cdevice_obj_t *self = MP_OBJ_TO_PTR(pos_args[0]); 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); @@ -196,7 +196,7 @@ STATIC mp_obj_t busdevice_i2cdevice_write(size_t n_args, const mp_obj_t *pos_arg write(self, args[ARG_buffer].u_obj, args[ARG_start].u_int, args[ARG_end].u_int); return mp_const_none; } -MP_DEFINE_CONST_FUN_OBJ_KW(busdevice_i2cdevice_write_obj, 2, busdevice_i2cdevice_write); +MP_DEFINE_CONST_FUN_OBJ_KW(adafruit_bus_device_i2cdevice_write_obj, 2, adafruit_bus_device_i2cdevice_write); //| def write_then_readinto(self, out_buffer, in_buffer, *, out_start=0, out_end=None, in_start=0, in_end=None) -> None: @@ -221,7 +221,7 @@ MP_DEFINE_CONST_FUN_OBJ_KW(busdevice_i2cdevice_write_obj, 2, busdevice_i2cdevice //| """ //| ... //| -STATIC mp_obj_t busdevice_i2cdevice_write_then_readinto(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { +STATIC mp_obj_t adafruit_bus_device_i2cdevice_write_then_readinto(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum { ARG_out_buffer, ARG_in_buffer, ARG_out_start, ARG_out_end, ARG_in_start, ARG_in_end }; static const mp_arg_t allowed_args[] = { { MP_QSTR_out_buffer, MP_ARG_REQUIRED | MP_ARG_OBJ }, @@ -231,7 +231,7 @@ STATIC mp_obj_t busdevice_i2cdevice_write_then_readinto(size_t n_args, const mp_ { MP_QSTR_in_start, MP_ARG_KW_ONLY | MP_ARG_INT, {.u_int = 0} }, { MP_QSTR_in_end, MP_ARG_KW_ONLY | MP_ARG_INT, {.u_int = INT_MAX} }, }; - busdevice_i2cdevice_obj_t *self = MP_OBJ_TO_PTR(pos_args[0]); + adafruit_bus_device_i2cdevice_obj_t *self = MP_OBJ_TO_PTR(pos_args[0]); 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); @@ -242,21 +242,21 @@ STATIC mp_obj_t busdevice_i2cdevice_write_then_readinto(size_t n_args, const mp_ return mp_const_none; } -MP_DEFINE_CONST_FUN_OBJ_KW(busdevice_i2cdevice_write_then_readinto_obj, 3, busdevice_i2cdevice_write_then_readinto); +MP_DEFINE_CONST_FUN_OBJ_KW(adafruit_bus_device_i2cdevice_write_then_readinto_obj, 3, adafruit_bus_device_i2cdevice_write_then_readinto); -STATIC const mp_rom_map_elem_t busdevice_i2cdevice_locals_dict_table[] = { - { MP_ROM_QSTR(MP_QSTR___enter__), MP_ROM_PTR(&busdevice_i2cdevice___enter___obj) }, - { MP_ROM_QSTR(MP_QSTR___exit__), MP_ROM_PTR(&busdevice_i2cdevice___exit___obj) }, - { MP_ROM_QSTR(MP_QSTR_readinto), MP_ROM_PTR(&busdevice_i2cdevice_readinto_obj) }, - { MP_ROM_QSTR(MP_QSTR_write), MP_ROM_PTR(&busdevice_i2cdevice_write_obj) }, - { MP_ROM_QSTR(MP_QSTR_write_then_readinto), MP_ROM_PTR(&busdevice_i2cdevice_write_then_readinto_obj) }, +STATIC const mp_rom_map_elem_t adafruit_bus_device_i2cdevice_locals_dict_table[] = { + { MP_ROM_QSTR(MP_QSTR___enter__), MP_ROM_PTR(&adafruit_bus_device_i2cdevice___enter___obj) }, + { MP_ROM_QSTR(MP_QSTR___exit__), MP_ROM_PTR(&adafruit_bus_device_i2cdevice___exit___obj) }, + { MP_ROM_QSTR(MP_QSTR_readinto), MP_ROM_PTR(&adafruit_bus_device_i2cdevice_readinto_obj) }, + { MP_ROM_QSTR(MP_QSTR_write), MP_ROM_PTR(&adafruit_bus_device_i2cdevice_write_obj) }, + { MP_ROM_QSTR(MP_QSTR_write_then_readinto), MP_ROM_PTR(&adafruit_bus_device_i2cdevice_write_then_readinto_obj) }, }; -STATIC MP_DEFINE_CONST_DICT(busdevice_i2cdevice_locals_dict, busdevice_i2cdevice_locals_dict_table); +STATIC MP_DEFINE_CONST_DICT(adafruit_bus_device_i2cdevice_locals_dict, adafruit_bus_device_i2cdevice_locals_dict_table); -const mp_obj_type_t busdevice_i2cdevice_type = { +const mp_obj_type_t adafruit_bus_device_i2cdevice_type = { { &mp_type_type }, .name = MP_QSTR_I2CDevice, - .make_new = busdevice_i2cdevice_make_new, - .locals_dict = (mp_obj_dict_t*)&busdevice_i2cdevice_locals_dict, + .make_new = adafruit_bus_device_i2cdevice_make_new, + .locals_dict = (mp_obj_dict_t*)&adafruit_bus_device_i2cdevice_locals_dict, }; diff --git a/shared-bindings/busdevice/I2CDevice.h b/shared-bindings/adafruit_bus_device/I2CDevice.h similarity index 68% rename from shared-bindings/busdevice/I2CDevice.h rename to shared-bindings/adafruit_bus_device/I2CDevice.h index a1f869c450..7b2182ff03 100644 --- a/shared-bindings/busdevice/I2CDevice.h +++ b/shared-bindings/adafruit_bus_device/I2CDevice.h @@ -36,18 +36,18 @@ #include "py/obj.h" -#include "shared-module/busdevice/I2CDevice.h" +#include "shared-module/adafruit_bus_device/I2CDevice.h" //#include "shared-bindings/busio/I2C.h" // Type object used in Python. Should be shared between ports. -extern const mp_obj_type_t busdevice_i2cdevice_type; +extern const mp_obj_type_t adafruit_bus_device_i2cdevice_type; // Initializes the hardware peripheral. -extern void common_hal_busdevice_i2cdevice_construct(busdevice_i2cdevice_obj_t *self, busio_i2c_obj_t *i2c, uint8_t device_address); -extern uint8_t common_hal_busdevice_i2cdevice_readinto(busdevice_i2cdevice_obj_t *self, mp_obj_t buffer, size_t length); -extern uint8_t common_hal_busdevice_i2cdevice_write(busdevice_i2cdevice_obj_t *self, mp_obj_t buffer, size_t length); -extern void common_hal_busdevice_i2cdevice_lock(busdevice_i2cdevice_obj_t *self); -extern void common_hal_busdevice_i2cdevice_unlock(busdevice_i2cdevice_obj_t *self); -extern void common_hal_busdevice_i2cdevice_probe_for_device(busdevice_i2cdevice_obj_t *self); +extern void common_hal_adafruit_bus_device_i2cdevice_construct(adafruit_bus_device_i2cdevice_obj_t *self, busio_i2c_obj_t *i2c, uint8_t device_address); +extern uint8_t common_hal_adafruit_bus_device_i2cdevice_readinto(adafruit_bus_device_i2cdevice_obj_t *self, mp_obj_t buffer, size_t length); +extern uint8_t common_hal_adafruit_bus_device_i2cdevice_write(adafruit_bus_device_i2cdevice_obj_t *self, mp_obj_t buffer, size_t length); +extern void common_hal_adafruit_bus_device_i2cdevice_lock(adafruit_bus_device_i2cdevice_obj_t *self); +extern void common_hal_adafruit_bus_device_i2cdevice_unlock(adafruit_bus_device_i2cdevice_obj_t *self); +extern void common_hal_adafruit_bus_device_i2cdevice_probe_for_device(adafruit_bus_device_i2cdevice_obj_t *self); #endif // MICROPY_INCLUDED_SHARED_BINDINGS_BUSDEVICE_I2CDEVICE_H diff --git a/shared-bindings/busdevice/SPIDevice.c b/shared-bindings/adafruit_bus_device/SPIDevice.c similarity index 70% rename from shared-bindings/busdevice/SPIDevice.c rename to shared-bindings/adafruit_bus_device/SPIDevice.c index 631d0eec49..e127e39b81 100644 --- a/shared-bindings/busdevice/SPIDevice.c +++ b/shared-bindings/adafruit_bus_device/SPIDevice.c @@ -25,9 +25,9 @@ */ #include "shared-bindings/microcontroller/Pin.h" -#include "shared-bindings/busdevice/SPIDevice.h" +#include "shared-bindings/adafruit_bus_device/SPIDevice.h" #include "shared-bindings/util.h" -#include "shared-module/busdevice/SPIDevice.h" +#include "shared-module/adafruit_bus_device/SPIDevice.h" #include "common-hal/digitalio/DigitalInOut.h" #include "shared-bindings/digitalio/DigitalInOut.h" @@ -69,9 +69,9 @@ //| spi.write(bytes_read)""" //| ... //| -STATIC mp_obj_t busdevice_spidevice_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { - busdevice_spidevice_obj_t *self = m_new_obj(busdevice_spidevice_obj_t); - self->base.type = &busdevice_spidevice_type; +STATIC mp_obj_t adafruit_bus_device_spidevice_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { + adafruit_bus_device_spidevice_obj_t *self = m_new_obj(adafruit_bus_device_spidevice_obj_t); + self->base.type = &adafruit_bus_device_spidevice_type; enum { ARG_spi, ARG_chip_select, ARG_baudrate, ARG_polarity, ARG_phase, ARG_extra_clocks }; static const mp_arg_t allowed_args[] = { { MP_QSTR_spi, MP_ARG_REQUIRED | MP_ARG_OBJ }, @@ -86,7 +86,7 @@ STATIC mp_obj_t busdevice_spidevice_make_new(const mp_obj_type_t *type, size_t n busio_spi_obj_t* spi = args[ARG_spi].u_obj; - common_hal_busdevice_spidevice_construct(MP_OBJ_TO_PTR(self), spi, args[ARG_chip_select].u_obj, args[ARG_baudrate].u_int, args[ARG_polarity].u_int, + common_hal_adafruit_bus_device_spidevice_construct(MP_OBJ_TO_PTR(self), spi, args[ARG_chip_select].u_obj, args[ARG_baudrate].u_int, args[ARG_polarity].u_int, args[ARG_phase].u_int, args[ARG_extra_clocks].u_int); if (args[ARG_chip_select].u_obj != MP_OBJ_NULL) { @@ -100,29 +100,29 @@ STATIC mp_obj_t busdevice_spidevice_make_new(const mp_obj_type_t *type, size_t n return (mp_obj_t)self; } -STATIC mp_obj_t busdevice_spidevice_obj___enter__(mp_obj_t self_in) { - busdevice_spidevice_obj_t *self = MP_OBJ_TO_PTR(self_in); - common_hal_busdevice_spidevice_enter(self); +STATIC mp_obj_t adafruit_bus_device_spidevice_obj___enter__(mp_obj_t self_in) { + adafruit_bus_device_spidevice_obj_t *self = MP_OBJ_TO_PTR(self_in); + common_hal_adafruit_bus_device_spidevice_enter(self); return self->spi; } -STATIC MP_DEFINE_CONST_FUN_OBJ_1(busdevice_spidevice___enter___obj, busdevice_spidevice_obj___enter__); +STATIC MP_DEFINE_CONST_FUN_OBJ_1(adafruit_bus_device_spidevice___enter___obj, adafruit_bus_device_spidevice_obj___enter__); -STATIC mp_obj_t busdevice_spidevice_obj___exit__(size_t n_args, const mp_obj_t *args) { - common_hal_busdevice_spidevice_exit(MP_OBJ_TO_PTR(args[0])); +STATIC mp_obj_t adafruit_bus_device_spidevice_obj___exit__(size_t n_args, const mp_obj_t *args) { + common_hal_adafruit_bus_device_spidevice_exit(MP_OBJ_TO_PTR(args[0])); return mp_const_none; } -STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(busdevice_spidevice___exit___obj, 4, 4, busdevice_spidevice_obj___exit__); +STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(adafruit_bus_device_spidevice___exit___obj, 4, 4, adafruit_bus_device_spidevice_obj___exit__); -STATIC const mp_rom_map_elem_t busdevice_spidevice_locals_dict_table[] = { - { MP_ROM_QSTR(MP_QSTR___enter__), MP_ROM_PTR(&busdevice_spidevice___enter___obj) }, - { MP_ROM_QSTR(MP_QSTR___exit__), MP_ROM_PTR(&busdevice_spidevice___exit___obj) }, +STATIC const mp_rom_map_elem_t adafruit_bus_device_spidevice_locals_dict_table[] = { + { MP_ROM_QSTR(MP_QSTR___enter__), MP_ROM_PTR(&adafruit_bus_device_spidevice___enter___obj) }, + { MP_ROM_QSTR(MP_QSTR___exit__), MP_ROM_PTR(&adafruit_bus_device_spidevice___exit___obj) }, }; -STATIC MP_DEFINE_CONST_DICT(busdevice_spidevice_locals_dict, busdevice_spidevice_locals_dict_table); +STATIC MP_DEFINE_CONST_DICT(adafruit_bus_device_spidevice_locals_dict, adafruit_bus_device_spidevice_locals_dict_table); -const mp_obj_type_t busdevice_spidevice_type = { +const mp_obj_type_t adafruit_bus_device_spidevice_type = { { &mp_type_type }, .name = MP_QSTR_SPIDevice, - .make_new = busdevice_spidevice_make_new, - .locals_dict = (mp_obj_dict_t*)&busdevice_spidevice_locals_dict, + .make_new = adafruit_bus_device_spidevice_make_new, + .locals_dict = (mp_obj_dict_t*)&adafruit_bus_device_spidevice_locals_dict, }; diff --git a/shared-bindings/busdevice/SPIDevice.h b/shared-bindings/adafruit_bus_device/SPIDevice.h similarity index 79% rename from shared-bindings/busdevice/SPIDevice.h rename to shared-bindings/adafruit_bus_device/SPIDevice.h index 040f98548e..5596b157f0 100644 --- a/shared-bindings/busdevice/SPIDevice.h +++ b/shared-bindings/adafruit_bus_device/SPIDevice.h @@ -36,15 +36,15 @@ #include "py/obj.h" -#include "shared-module/busdevice/SPIDevice.h" +#include "shared-module/adafruit_bus_device/SPIDevice.h" // Type object used in Python. Should be shared between ports. -extern const mp_obj_type_t busdevice_spidevice_type; +extern const mp_obj_type_t adafruit_bus_device_spidevice_type; // Initializes the hardware peripheral. -extern void common_hal_busdevice_spidevice_construct(busdevice_spidevice_obj_t *self, busio_spi_obj_t *spi, digitalio_digitalinout_obj_t *cs, +extern void common_hal_adafruit_bus_device_spidevice_construct(adafruit_bus_device_spidevice_obj_t *self, busio_spi_obj_t *spi, digitalio_digitalinout_obj_t *cs, uint32_t baudrate, uint8_t polarity, uint8_t phase, uint8_t extra_clocks); -extern void common_hal_busdevice_spidevice_enter(busdevice_spidevice_obj_t *self); -extern void common_hal_busdevice_spidevice_exit(busdevice_spidevice_obj_t *self); +extern void common_hal_adafruit_bus_device_spidevice_enter(adafruit_bus_device_spidevice_obj_t *self); +extern void common_hal_adafruit_bus_device_spidevice_exit(adafruit_bus_device_spidevice_obj_t *self); #endif // MICROPY_INCLUDED_SHARED_BINDINGS_BUSDEVICE_SPIDEVICE_H diff --git a/shared-bindings/busdevice/__init__.c b/shared-bindings/adafruit_bus_device/__init__.c similarity index 55% rename from shared-bindings/busdevice/__init__.c rename to shared-bindings/adafruit_bus_device/__init__.c index a9a1a83a33..e01abcab3f 100644 --- a/shared-bindings/busdevice/__init__.c +++ b/shared-bindings/adafruit_bus_device/__init__.c @@ -31,30 +31,30 @@ #include "py/mphal.h" #include "py/objproperty.h" -#include "shared-bindings/busdevice/__init__.h" -#include "shared-bindings/busdevice/I2CDevice.h" -#include "shared-bindings/busdevice/SPIDevice.h" +#include "shared-bindings/adafruit_bus_device/__init__.h" +#include "shared-bindings/adafruit_bus_device/I2CDevice.h" +#include "shared-bindings/adafruit_bus_device/SPIDevice.h" -STATIC const mp_rom_map_elem_t busdevice_i2c_device_globals_table[] = { +STATIC const mp_rom_map_elem_t adafruit_bus_device_i2c_device_globals_table[] = { { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_i2c_device) }, - { MP_ROM_QSTR(MP_QSTR_I2CDevice), MP_ROM_PTR(&busdevice_i2cdevice_type) }, + { MP_ROM_QSTR(MP_QSTR_I2CDevice), MP_ROM_PTR(&adafruit_bus_device_i2cdevice_type) }, }; -STATIC MP_DEFINE_CONST_DICT(busdevice_i2c_device_globals, busdevice_i2c_device_globals_table); +STATIC MP_DEFINE_CONST_DICT(adafruit_bus_device_i2c_device_globals, adafruit_bus_device_i2c_device_globals_table); -const mp_obj_module_t busdevice_i2c_device_module = { +const mp_obj_module_t adafruit_bus_device_i2c_device_module = { .base = { &mp_type_module }, - .globals = (mp_obj_dict_t*)&busdevice_i2c_device_globals, + .globals = (mp_obj_dict_t*)&adafruit_bus_device_i2c_device_globals, }; -STATIC const mp_rom_map_elem_t busdevice_spi_device_globals_table[] = { +STATIC const mp_rom_map_elem_t adafruit_bus_device_spi_device_globals_table[] = { { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_spi_device) }, - { MP_ROM_QSTR(MP_QSTR_SPIDevice), MP_ROM_PTR(&busdevice_spidevice_type) }, + { MP_ROM_QSTR(MP_QSTR_SPIDevice), MP_ROM_PTR(&adafruit_bus_device_spidevice_type) }, }; -STATIC MP_DEFINE_CONST_DICT(busdevice_spi_device_globals, busdevice_spi_device_globals_table); +STATIC MP_DEFINE_CONST_DICT(adafruit_bus_device_spi_device_globals, adafruit_bus_device_spi_device_globals_table); -const mp_obj_module_t busdevice_spi_device_module = { +const mp_obj_module_t adafruit_bus_device_spi_device_module = { .base = { &mp_type_module }, - .globals = (mp_obj_dict_t*)&busdevice_spi_device_globals, + .globals = (mp_obj_dict_t*)&adafruit_bus_device_spi_device_globals, }; //| """Hardware accelerated external bus access @@ -64,15 +64,15 @@ const mp_obj_module_t busdevice_spi_device_module = { //| devices, it manages the chip select and protocol changes such as mode. For I2C, it //| manages the device address.""" //| -STATIC const mp_rom_map_elem_t busdevice_module_globals_table[] = { - { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_busdevice) }, - { MP_ROM_QSTR(MP_QSTR_i2c_device), MP_ROM_PTR(&busdevice_i2c_device_module) }, - { MP_ROM_QSTR(MP_QSTR_spi_device), MP_ROM_PTR(&busdevice_spi_device_module) }, +STATIC const mp_rom_map_elem_t adafruit_bus_device_module_globals_table[] = { + { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_adafruit_bus_device) }, + { MP_ROM_QSTR(MP_QSTR_i2c_device), MP_ROM_PTR(&adafruit_bus_device_i2c_device_module) }, + { MP_ROM_QSTR(MP_QSTR_spi_device), MP_ROM_PTR(&adafruit_bus_device_spi_device_module) }, }; -STATIC MP_DEFINE_CONST_DICT(busdevice_module_globals, busdevice_module_globals_table); +STATIC MP_DEFINE_CONST_DICT(adafruit_bus_device_module_globals, adafruit_bus_device_module_globals_table); -const mp_obj_module_t busdevice_module = { +const mp_obj_module_t adafruit_bus_device_module = { .base = { &mp_type_module }, - .globals = (mp_obj_dict_t*)&busdevice_module_globals, + .globals = (mp_obj_dict_t*)&adafruit_bus_device_module_globals, }; diff --git a/shared-bindings/busdevice/__init__.h b/shared-bindings/adafruit_bus_device/__init__.h similarity index 100% rename from shared-bindings/busdevice/__init__.h rename to shared-bindings/adafruit_bus_device/__init__.h diff --git a/shared-module/busdevice/I2CDevice.c b/shared-module/adafruit_bus_device/I2CDevice.c similarity index 66% rename from shared-module/busdevice/I2CDevice.c rename to shared-module/adafruit_bus_device/I2CDevice.c index b9f8ee25c0..d790ff53a4 100644 --- a/shared-module/busdevice/I2CDevice.c +++ b/shared-module/adafruit_bus_device/I2CDevice.c @@ -24,18 +24,18 @@ * THE SOFTWARE. */ -#include "shared-bindings/busdevice/I2CDevice.h" +#include "shared-bindings/adafruit_bus_device/I2CDevice.h" #include "shared-bindings/busio/I2C.h" #include "py/mperrno.h" #include "py/nlr.h" #include "py/runtime.h" -void common_hal_busdevice_i2cdevice_construct(busdevice_i2cdevice_obj_t *self, busio_i2c_obj_t *i2c, uint8_t device_address) { +void common_hal_adafruit_bus_device_i2cdevice_construct(adafruit_bus_device_i2cdevice_obj_t *self, busio_i2c_obj_t *i2c, uint8_t device_address) { self->i2c = i2c; self->device_address = device_address; } -void common_hal_busdevice_i2cdevice_lock(busdevice_i2cdevice_obj_t *self) { +void common_hal_adafruit_bus_device_i2cdevice_lock(adafruit_bus_device_i2cdevice_obj_t *self) { bool success = false; while (!success) { success = common_hal_busio_i2c_try_lock(self->i2c); @@ -44,31 +44,31 @@ void common_hal_busdevice_i2cdevice_lock(busdevice_i2cdevice_obj_t *self) { } } -void common_hal_busdevice_i2cdevice_unlock(busdevice_i2cdevice_obj_t *self) { +void common_hal_adafruit_bus_device_i2cdevice_unlock(adafruit_bus_device_i2cdevice_obj_t *self) { common_hal_busio_i2c_unlock(self->i2c); } -uint8_t common_hal_busdevice_i2cdevice_readinto(busdevice_i2cdevice_obj_t *self, mp_obj_t buffer, size_t length) { +uint8_t common_hal_adafruit_bus_device_i2cdevice_readinto(adafruit_bus_device_i2cdevice_obj_t *self, mp_obj_t buffer, size_t length) { return common_hal_busio_i2c_read(self->i2c, self->device_address, buffer, length); } -uint8_t common_hal_busdevice_i2cdevice_write(busdevice_i2cdevice_obj_t *self, mp_obj_t buffer, size_t length) { +uint8_t common_hal_adafruit_bus_device_i2cdevice_write(adafruit_bus_device_i2cdevice_obj_t *self, mp_obj_t buffer, size_t length) { return common_hal_busio_i2c_write(self->i2c, self->device_address, buffer, length, true); } -void common_hal_busdevice_i2cdevice_probe_for_device(busdevice_i2cdevice_obj_t *self) { - common_hal_busdevice_i2cdevice_lock(self); +void common_hal_adafruit_bus_device_i2cdevice_probe_for_device(adafruit_bus_device_i2cdevice_obj_t *self) { + common_hal_adafruit_bus_device_i2cdevice_lock(self); mp_buffer_info_t bufinfo; mp_obj_t buffer = mp_obj_new_bytearray_of_zeros(1); mp_get_buffer_raise(buffer, &bufinfo, MP_BUFFER_WRITE); - uint8_t status = common_hal_busdevice_i2cdevice_readinto(self, (uint8_t*)bufinfo.buf, 1); + uint8_t status = common_hal_adafruit_bus_device_i2cdevice_readinto(self, (uint8_t*)bufinfo.buf, 1); if (status != 0) { - common_hal_busdevice_i2cdevice_unlock(self); + common_hal_adafruit_bus_device_i2cdevice_unlock(self); mp_raise_ValueError_varg(translate("No I2C device at address: %x"), self->device_address); } - common_hal_busdevice_i2cdevice_unlock(self); + common_hal_adafruit_bus_device_i2cdevice_unlock(self); } diff --git a/shared-module/busdevice/I2CDevice.h b/shared-module/adafruit_bus_device/I2CDevice.h similarity index 97% rename from shared-module/busdevice/I2CDevice.h rename to shared-module/adafruit_bus_device/I2CDevice.h index 918dc7719d..d06adb9f50 100644 --- a/shared-module/busdevice/I2CDevice.h +++ b/shared-module/adafruit_bus_device/I2CDevice.h @@ -34,6 +34,6 @@ typedef struct { mp_obj_base_t base; busio_i2c_obj_t *i2c; uint8_t device_address; -} busdevice_i2cdevice_obj_t; +} adafruit_bus_device_i2cdevice_obj_t; #endif // MICROPY_INCLUDED_ATMEL_SAMD_SHARED_MODULE_BUSDEVICE_I2CDEVICE_H diff --git a/shared-module/busdevice/SPIDevice.c b/shared-module/adafruit_bus_device/SPIDevice.c similarity index 87% rename from shared-module/busdevice/SPIDevice.c rename to shared-module/adafruit_bus_device/SPIDevice.c index d9b63a007e..e489fc7c07 100644 --- a/shared-module/busdevice/SPIDevice.c +++ b/shared-module/adafruit_bus_device/SPIDevice.c @@ -24,14 +24,14 @@ * THE SOFTWARE. */ -#include "shared-bindings/busdevice/SPIDevice.h" +#include "shared-bindings/adafruit_bus_device/SPIDevice.h" #include "shared-bindings/busio/SPI.h" #include "shared-bindings/digitalio/DigitalInOut.h" #include "py/mperrno.h" #include "py/nlr.h" #include "py/runtime.h" -void common_hal_busdevice_spidevice_construct(busdevice_spidevice_obj_t *self, busio_spi_obj_t *spi, digitalio_digitalinout_obj_t *cs, +void common_hal_adafruit_bus_device_spidevice_construct(adafruit_bus_device_spidevice_obj_t *self, busio_spi_obj_t *spi, digitalio_digitalinout_obj_t *cs, uint32_t baudrate, uint8_t polarity, uint8_t phase, uint8_t extra_clocks) { self->spi = spi; self->baudrate = baudrate; @@ -41,7 +41,7 @@ void common_hal_busdevice_spidevice_construct(busdevice_spidevice_obj_t *self, b self->chip_select = cs; } -void common_hal_busdevice_spidevice_enter(busdevice_spidevice_obj_t *self) { +void common_hal_adafruit_bus_device_spidevice_enter(adafruit_bus_device_spidevice_obj_t *self) { bool success = false; while (!success) { success = common_hal_busio_spi_try_lock(self->spi); @@ -56,7 +56,7 @@ void common_hal_busdevice_spidevice_enter(busdevice_spidevice_obj_t *self) { } } -void common_hal_busdevice_spidevice_exit(busdevice_spidevice_obj_t *self) { +void common_hal_adafruit_bus_device_spidevice_exit(adafruit_bus_device_spidevice_obj_t *self) { if (self->chip_select != MP_OBJ_NULL) { common_hal_digitalio_digitalinout_set_value(MP_OBJ_TO_PTR(self->chip_select), true); } diff --git a/shared-module/busdevice/SPIDevice.h b/shared-module/adafruit_bus_device/SPIDevice.h similarity index 97% rename from shared-module/busdevice/SPIDevice.h rename to shared-module/adafruit_bus_device/SPIDevice.h index ffabf79dff..1a7c70fa73 100644 --- a/shared-module/busdevice/SPIDevice.h +++ b/shared-module/adafruit_bus_device/SPIDevice.h @@ -39,6 +39,6 @@ typedef struct { uint8_t phase; uint8_t extra_clocks; digitalio_digitalinout_obj_t *chip_select; -} busdevice_spidevice_obj_t; +} adafruit_bus_device_spidevice_obj_t; #endif // MICROPY_INCLUDED_ATMEL_SAMD_SHARED_MODULE_BUSDEVICE_SPIDEVICE_H diff --git a/shared-module/busdevice/__init__.c b/shared-module/adafruit_bus_device/__init__.c similarity index 100% rename from shared-module/busdevice/__init__.c rename to shared-module/adafruit_bus_device/__init__.c From 6c59836c5db03744d7dbef01c2323989d13ef02a Mon Sep 17 00:00:00 2001 From: microDev <70126934+microDev1@users.noreply.github.com> Date: Tue, 10 Nov 2020 16:32:46 +0530 Subject: [PATCH 032/207] watchdog implementation for esp32s2 --- locale/circuitpython.pot | 15 +++- .../common-hal/microcontroller/__init__.c | 11 +++ .../common-hal/watchdog/WatchDogMode.c | 1 + .../common-hal/watchdog/WatchDogTimer.c | 86 +++++++++++++++++++ .../common-hal/watchdog/WatchDogTimer.h | 44 ++++++++++ ports/esp32s2/common-hal/watchdog/__init__.c | 1 + ports/esp32s2/mpconfigport.mk | 1 + 7 files changed, 157 insertions(+), 2 deletions(-) create mode 100644 ports/esp32s2/common-hal/watchdog/WatchDogMode.c create mode 100644 ports/esp32s2/common-hal/watchdog/WatchDogTimer.c create mode 100644 ports/esp32s2/common-hal/watchdog/WatchDogTimer.h create mode 100644 ports/esp32s2/common-hal/watchdog/__init__.c diff --git a/locale/circuitpython.pot b/locale/circuitpython.pot index b4445abfbf..7a39e9a327 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-11-04 21:18+0530\n" +"POT-Creation-Date: 2020-11-10 15:30+0530\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -296,7 +296,8 @@ msgstr "" msgid "All I2C peripherals are in use" msgstr "" -#: ports/esp32s2/peripherals/pcnt_handler.c +#: ports/esp32s2/common-hal/countio/Counter.c +#: ports/esp32s2/common-hal/rotaryio/IncrementalEncoder.c msgid "All PCNT units in use" msgstr "" @@ -992,6 +993,10 @@ msgstr "" msgid "Incorrect buffer size" msgstr "" +#: ports/esp32s2/common-hal/watchdog/WatchDogTimer.c +msgid "Initialization failed due to lack of memory" +msgstr "" + #: ports/atmel-samd/common-hal/pulseio/PulseIn.c msgid "Input taking too long" msgstr "" @@ -3201,6 +3206,7 @@ msgstr "" msgid "pow() with 3 arguments requires integers" msgstr "" +#: ports/esp32s2/boards/adafruit_magtag_2.9_grayscale/mpconfigboard.h #: ports/esp32s2/boards/adafruit_metro_esp32s2/mpconfigboard.h #: ports/esp32s2/boards/electroniccats_bastwifi/mpconfigboard.h #: ports/esp32s2/boards/espressif_kaluga_1/mpconfigboard.h @@ -3416,6 +3422,7 @@ msgstr "" msgid "time.struct_time() takes a 9-sequence" msgstr "" +#: ports/esp32s2/common-hal/watchdog/WatchDogTimer.c #: ports/nrf/common-hal/watchdog/WatchDogTimer.c msgid "timeout duration exceeded the maximum supported value" msgstr "" @@ -3599,6 +3606,10 @@ msgstr "" msgid "vectors must have same lengths" msgstr "" +#: ports/esp32s2/common-hal/watchdog/WatchDogTimer.c +msgid "watchdog not initialized" +msgstr "" + #: shared-bindings/watchdog/WatchDogTimer.c msgid "watchdog timeout must be greater than 0" msgstr "" diff --git a/ports/esp32s2/common-hal/microcontroller/__init__.c b/ports/esp32s2/common-hal/microcontroller/__init__.c index 6b2e18673d..e5cfc7eef0 100644 --- a/ports/esp32s2/common-hal/microcontroller/__init__.c +++ b/ports/esp32s2/common-hal/microcontroller/__init__.c @@ -85,6 +85,17 @@ const mcu_processor_obj_t common_hal_mcu_processor_obj = { }, }; +#if CIRCUITPY_WATCHDOG +// The singleton watchdog.WatchDogTimer object. +watchdog_watchdogtimer_obj_t common_hal_mcu_watchdogtimer_obj = { + .base = { + .type = &watchdog_watchdogtimer_type, + }, + .timeout = 0.0f, + .mode = WATCHDOGMODE_NONE, +}; +#endif + // This maps MCU pin names to pin objects. STATIC const mp_rom_map_elem_t mcu_pin_global_dict_table[] = { { MP_ROM_QSTR(MP_QSTR_GPIO0), MP_ROM_PTR(&pin_GPIO0) }, diff --git a/ports/esp32s2/common-hal/watchdog/WatchDogMode.c b/ports/esp32s2/common-hal/watchdog/WatchDogMode.c new file mode 100644 index 0000000000..fc4e0e008c --- /dev/null +++ b/ports/esp32s2/common-hal/watchdog/WatchDogMode.c @@ -0,0 +1 @@ +// No watchdog module functions. diff --git a/ports/esp32s2/common-hal/watchdog/WatchDogTimer.c b/ports/esp32s2/common-hal/watchdog/WatchDogTimer.c new file mode 100644 index 0000000000..59b9dafcf0 --- /dev/null +++ b/ports/esp32s2/common-hal/watchdog/WatchDogTimer.c @@ -0,0 +1,86 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2020 microDev + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include "py/runtime.h" +#include "common-hal/watchdog/WatchDogTimer.h" + +#include "shared-bindings/microcontroller/__init__.h" + +#include "esp_task_wdt.h" + +void esp_task_wdt_isr_user_handler(void) { + +} + +void common_hal_watchdog_feed(watchdog_watchdogtimer_obj_t *self) { + if (esp_task_wdt_reset() != ESP_OK) { + mp_raise_RuntimeError(translate("watchdog not initialized")); + } +} + +void common_hal_watchdog_deinit(watchdog_watchdogtimer_obj_t *self) { + if (esp_task_wdt_deinit() == ESP_OK) { + self->mode = WATCHDOGMODE_NONE; + } +} + +void watchdog_reset(void) { + common_hal_watchdog_deinit(&common_hal_mcu_watchdogtimer_obj); +} + +static void wdt_config(watchdog_watchdogtimer_obj_t *self) { + // enable panic hanler in WATCHDOGMODE_RESET mode + // initialize Task Watchdog Timer (TWDT) + if (esp_task_wdt_init((uint32_t)self->timeout, (self->mode == WATCHDOGMODE_RESET)) != ESP_OK) { + mp_raise_RuntimeError(translate("Initialization failed due to lack of memory")); + } + esp_task_wdt_add(NULL); +} + +mp_float_t common_hal_watchdog_get_timeout(watchdog_watchdogtimer_obj_t *self) { + return self->timeout; +} + +void common_hal_watchdog_set_timeout(watchdog_watchdogtimer_obj_t *self, mp_float_t new_timeout) { + if ((uint64_t)new_timeout > UINT32_MAX) { + mp_raise_ValueError(translate("timeout duration exceeded the maximum supported value")); + } + if ((uint32_t)self->timeout != (uint32_t)new_timeout) { + self->timeout = new_timeout; + wdt_config(self); + } +} + +watchdog_watchdogmode_t common_hal_watchdog_get_mode(watchdog_watchdogtimer_obj_t *self) { + return self->mode; +} + +void common_hal_watchdog_set_mode(watchdog_watchdogtimer_obj_t *self, watchdog_watchdogmode_t new_mode) { + if (self->mode != new_mode) { + self->mode = new_mode; + wdt_config(self); + } +} diff --git a/ports/esp32s2/common-hal/watchdog/WatchDogTimer.h b/ports/esp32s2/common-hal/watchdog/WatchDogTimer.h new file mode 100644 index 0000000000..05e0e954d2 --- /dev/null +++ b/ports/esp32s2/common-hal/watchdog/WatchDogTimer.h @@ -0,0 +1,44 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2020 microDev + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#ifndef MICROPY_INCLUDED_ESP32S2_COMMON_HAL_WATCHDOG_WATCHDOGTIMER_H +#define MICROPY_INCLUDED_ESP32S2_COMMON_HAL_WATCHDOG_WATCHDOGTIMER_H + +#include "py/obj.h" +#include "shared-bindings/watchdog/WatchDogMode.h" +#include "shared-bindings/watchdog/WatchDogTimer.h" + +struct _watchdog_watchdogtimer_obj_t { + mp_obj_base_t base; + mp_float_t timeout; + watchdog_watchdogmode_t mode; +}; + +// This needs to be called in order to disable the watchdog if it's set to +// "RAISE". If set to "RESET", then the watchdog cannot be reset. +void watchdog_reset(void); + +#endif // MICROPY_INCLUDED_ESP32S2_COMMON_HAL_WATCHDOG_WATCHDOGTIMER_H diff --git a/ports/esp32s2/common-hal/watchdog/__init__.c b/ports/esp32s2/common-hal/watchdog/__init__.c new file mode 100644 index 0000000000..fc4e0e008c --- /dev/null +++ b/ports/esp32s2/common-hal/watchdog/__init__.c @@ -0,0 +1 @@ +// No watchdog module functions. diff --git a/ports/esp32s2/mpconfigport.mk b/ports/esp32s2/mpconfigport.mk index 4579b95ab6..335d2caf72 100644 --- a/ports/esp32s2/mpconfigport.mk +++ b/ports/esp32s2/mpconfigport.mk @@ -25,6 +25,7 @@ CIRCUITPY_NVM = 0 # We don't have enough endpoints to include MIDI. CIRCUITPY_USB_MIDI = 0 CIRCUITPY_WIFI = 1 +CIRCUITPY_WATCHDOG ?= 1 CIRCUITPY_ESPIDF = 1 ifndef CIRCUITPY_TOUCHIO_USE_NATIVE From 10e8b8cf456b36b6e1e1582601a3fc437727cec5 Mon Sep 17 00:00:00 2001 From: microDev <70126934+microDev1@users.noreply.github.com> Date: Wed, 11 Nov 2020 00:24:01 +0530 Subject: [PATCH 033/207] move port specific check --- ports/nrf/common-hal/watchdog/WatchDogTimer.c | 3 +++ shared-bindings/watchdog/WatchDogTimer.c | 7 +------ 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/ports/nrf/common-hal/watchdog/WatchDogTimer.c b/ports/nrf/common-hal/watchdog/WatchDogTimer.c index bec0ac4732..539b43e762 100644 --- a/ports/nrf/common-hal/watchdog/WatchDogTimer.c +++ b/ports/nrf/common-hal/watchdog/WatchDogTimer.c @@ -93,6 +93,9 @@ void common_hal_watchdog_feed(watchdog_watchdogtimer_obj_t *self) { } void common_hal_watchdog_deinit(watchdog_watchdogtimer_obj_t *self) { + if (self->mode == WATCHDOGMODE_RESET) { + mp_raise_NotImplementedError(translate("WatchDogTimer cannot be deinitialized once mode is set to RESET")); + } if (timer) { timer_free(); } diff --git a/shared-bindings/watchdog/WatchDogTimer.c b/shared-bindings/watchdog/WatchDogTimer.c index 09219f7109..575021a219 100644 --- a/shared-bindings/watchdog/WatchDogTimer.c +++ b/shared-bindings/watchdog/WatchDogTimer.c @@ -66,6 +66,7 @@ STATIC mp_obj_t watchdog_watchdogtimer_feed(mp_obj_t self_in) { if (current_mode == WATCHDOGMODE_NONE) { mp_raise_ValueError(translate("WatchDogTimer is not currently running")); } + common_hal_watchdog_feed(self); return mp_const_none; } @@ -78,12 +79,6 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_1(watchdog_watchdogtimer_feed_obj, watchdog_watch //| STATIC mp_obj_t watchdog_watchdogtimer_deinit(mp_obj_t self_in) { watchdog_watchdogtimer_obj_t *self = MP_OBJ_TO_PTR(self_in); - watchdog_watchdogmode_t current_mode = common_hal_watchdog_get_mode(self); - - if (current_mode == WATCHDOGMODE_RESET) { - mp_raise_NotImplementedError(translate("WatchDogTimer cannot be deinitialized once mode is set to RESET")); - } - common_hal_watchdog_deinit(self); return mp_const_none; } From 03b110b44c8e8fed1feb43b7c14b03bbfddf4f2c Mon Sep 17 00:00:00 2001 From: gamblor21 Date: Wed, 11 Nov 2020 09:58:08 -0600 Subject: [PATCH 034/207] Add abort check in I2C lock --- shared-module/adafruit_bus_device/I2CDevice.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/shared-module/adafruit_bus_device/I2CDevice.c b/shared-module/adafruit_bus_device/I2CDevice.c index d790ff53a4..ee4b4fa554 100644 --- a/shared-module/adafruit_bus_device/I2CDevice.c +++ b/shared-module/adafruit_bus_device/I2CDevice.c @@ -29,6 +29,7 @@ #include "py/mperrno.h" #include "py/nlr.h" #include "py/runtime.h" +#include "lib/utils/interrupt_char.h" void common_hal_adafruit_bus_device_i2cdevice_construct(adafruit_bus_device_i2cdevice_obj_t *self, busio_i2c_obj_t *i2c, uint8_t device_address) { self->i2c = i2c; @@ -36,11 +37,15 @@ void common_hal_adafruit_bus_device_i2cdevice_construct(adafruit_bus_device_i2cd } void common_hal_adafruit_bus_device_i2cdevice_lock(adafruit_bus_device_i2cdevice_obj_t *self) { - bool success = false; + bool success = common_hal_busio_i2c_try_lock(self->i2c); + while (!success) { + RUN_BACKGROUND_TASKS; + if (mp_hal_is_interrupted()) { + break; + } + success = common_hal_busio_i2c_try_lock(self->i2c); - //RUN_BACKGROUND_TASKS; - //mp_handle_pending(); } } From f61c4e62c14e52da83b17f740b5c5409ee4b05a5 Mon Sep 17 00:00:00 2001 From: gamblor21 Date: Wed, 11 Nov 2020 10:24:33 -0600 Subject: [PATCH 035/207] Removing from smaller builds --- ports/atmel-samd/boards/bdmicro_vina_d21/mpconfigboard.mk | 1 + .../atmel-samd/boards/circuitplayground_express/mpconfigboard.mk | 1 - .../boards/circuitplayground_express_crickit/mpconfigboard.mk | 1 - .../boards/circuitplayground_express_displayio/mpconfigboard.mk | 1 - ports/atmel-samd/boards/dynossat_edu_eps/mpconfigboard.mk | 1 + ports/atmel-samd/boards/feather_m0_express/mpconfigboard.mk | 1 + ports/atmel-samd/boards/feather_m0_supersized/mpconfigboard.mk | 1 + ports/atmel-samd/boards/metro_m0_express/mpconfigboard.mk | 1 + ports/atmel-samd/boards/snekboard/mpconfigboard.mk | 1 + ports/atmel-samd/boards/sparkfun_redboard_turbo/mpconfigboard.mk | 1 + ports/litex/mpconfigport.mk | 1 + 11 files changed, 8 insertions(+), 3 deletions(-) diff --git a/ports/atmel-samd/boards/bdmicro_vina_d21/mpconfigboard.mk b/ports/atmel-samd/boards/bdmicro_vina_d21/mpconfigboard.mk index a9885d064b..a0d9a779f8 100644 --- a/ports/atmel-samd/boards/bdmicro_vina_d21/mpconfigboard.mk +++ b/ports/atmel-samd/boards/bdmicro_vina_d21/mpconfigboard.mk @@ -15,6 +15,7 @@ CIRCUITPY_BITBANGIO = 0 CIRCUITPY_COUNTIO = 0 CIRCUITPY_I2CPERIPHERAL = 0 CIRCUITPY_VECTORIO = 0 +CIRCUITPY_BUSDEVICE = 0 CFLAGS_INLINE_LIMIT = 60 SUPEROPT_GC = 0 diff --git a/ports/atmel-samd/boards/circuitplayground_express/mpconfigboard.mk b/ports/atmel-samd/boards/circuitplayground_express/mpconfigboard.mk index 13ec9e861c..5389fc89a5 100644 --- a/ports/atmel-samd/boards/circuitplayground_express/mpconfigboard.mk +++ b/ports/atmel-samd/boards/circuitplayground_express/mpconfigboard.mk @@ -21,7 +21,6 @@ SUPEROPT_GC = 0 CFLAGS_INLINE_LIMIT = 55 # Include these Python libraries in firmware. -FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_BusDevice FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_CircuitPlayground FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_HID FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_LIS3DH diff --git a/ports/atmel-samd/boards/circuitplayground_express_crickit/mpconfigboard.mk b/ports/atmel-samd/boards/circuitplayground_express_crickit/mpconfigboard.mk index 7aa45eb39e..31e10d736c 100644 --- a/ports/atmel-samd/boards/circuitplayground_express_crickit/mpconfigboard.mk +++ b/ports/atmel-samd/boards/circuitplayground_express_crickit/mpconfigboard.mk @@ -25,7 +25,6 @@ CFLAGS_INLINE_LIMIT = 50 # Include these Python libraries in firmware. -FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_BusDevice FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_CircuitPlayground FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_Crickit FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_LIS3DH diff --git a/ports/atmel-samd/boards/circuitplayground_express_displayio/mpconfigboard.mk b/ports/atmel-samd/boards/circuitplayground_express_displayio/mpconfigboard.mk index 3a43093a98..36b49b0eef 100644 --- a/ports/atmel-samd/boards/circuitplayground_express_displayio/mpconfigboard.mk +++ b/ports/atmel-samd/boards/circuitplayground_express_displayio/mpconfigboard.mk @@ -26,7 +26,6 @@ SUPEROPT_GC = 0 CFLAGS_INLINE_LIMIT = 55 # Include these Python libraries in firmware. -FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_BusDevice FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_CircuitPlayground FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_LIS3DH FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_NeoPixel diff --git a/ports/atmel-samd/boards/dynossat_edu_eps/mpconfigboard.mk b/ports/atmel-samd/boards/dynossat_edu_eps/mpconfigboard.mk index 3c0cc07bea..733784bf4c 100644 --- a/ports/atmel-samd/boards/dynossat_edu_eps/mpconfigboard.mk +++ b/ports/atmel-samd/boards/dynossat_edu_eps/mpconfigboard.mk @@ -17,6 +17,7 @@ CIRCUITPY_FREQUENCYIO = 0 CIRCUITPY_COUNTIO = 0 CIRCUITPY_I2CPERIPHERAL = 0 CIRCUITPY_VECTORIO = 0 +CIRCUITPY_BUSDEVICE = 0 CFLAGS_INLINE_LIMIT = 60 diff --git a/ports/atmel-samd/boards/feather_m0_express/mpconfigboard.mk b/ports/atmel-samd/boards/feather_m0_express/mpconfigboard.mk index dc02e1f60d..2fe085567a 100644 --- a/ports/atmel-samd/boards/feather_m0_express/mpconfigboard.mk +++ b/ports/atmel-samd/boards/feather_m0_express/mpconfigboard.mk @@ -16,6 +16,7 @@ CIRCUITPY_FREQUENCYIO = 0 CIRCUITPY_COUNTIO = 0 CIRCUITPY_I2CPERIPHERAL = 0 CIRCUITPY_VECTORIO = 0 +CIRCUITPY_BUSDEVICE = 0 CFLAGS_INLINE_LIMIT = 60 SUPEROPT_GC = 0 diff --git a/ports/atmel-samd/boards/feather_m0_supersized/mpconfigboard.mk b/ports/atmel-samd/boards/feather_m0_supersized/mpconfigboard.mk index 6f7f2d8b67..c2d692f9b7 100644 --- a/ports/atmel-samd/boards/feather_m0_supersized/mpconfigboard.mk +++ b/ports/atmel-samd/boards/feather_m0_supersized/mpconfigboard.mk @@ -17,6 +17,7 @@ CIRCUITPY_COUNTIO = 0 CIRCUITPY_I2CPERIPHERAL = 0 # supersized, not ultra-supersized CIRCUITPY_VECTORIO = 0 +CIRCUITPY_BUSDEVICE = 0 CFLAGS_INLINE_LIMIT = 60 SUPEROPT_GC = 0 diff --git a/ports/atmel-samd/boards/metro_m0_express/mpconfigboard.mk b/ports/atmel-samd/boards/metro_m0_express/mpconfigboard.mk index 7dd9650003..c35854758c 100644 --- a/ports/atmel-samd/boards/metro_m0_express/mpconfigboard.mk +++ b/ports/atmel-samd/boards/metro_m0_express/mpconfigboard.mk @@ -15,6 +15,7 @@ CIRCUITPY_BITBANGIO = 0 CIRCUITPY_COUNTIO = 0 CIRCUITPY_I2CPERIPHERAL = 0 CIRCUITPY_VECTORIO = 0 +CIRCUITPY_BUSDEVICE = 0 CFLAGS_INLINE_LIMIT = 60 SUPEROPT_GC = 0 diff --git a/ports/atmel-samd/boards/snekboard/mpconfigboard.mk b/ports/atmel-samd/boards/snekboard/mpconfigboard.mk index e0262b6b22..67e5b2312d 100644 --- a/ports/atmel-samd/boards/snekboard/mpconfigboard.mk +++ b/ports/atmel-samd/boards/snekboard/mpconfigboard.mk @@ -15,6 +15,7 @@ CIRCUITPY_BITBANGIO = 0 CIRCUITPY_GAMEPAD = 0 CIRCUITPY_I2CPERIPHERAL = 0 CIRCUITPY_VECTORIO = 0 +CIRCUITPY_BUSDEVICE = 0 CFLAGS_INLINE_LIMIT = 60 diff --git a/ports/atmel-samd/boards/sparkfun_redboard_turbo/mpconfigboard.mk b/ports/atmel-samd/boards/sparkfun_redboard_turbo/mpconfigboard.mk index 5170f8a233..590c4795fb 100755 --- a/ports/atmel-samd/boards/sparkfun_redboard_turbo/mpconfigboard.mk +++ b/ports/atmel-samd/boards/sparkfun_redboard_turbo/mpconfigboard.mk @@ -16,6 +16,7 @@ CIRCUITPY_COUNTIO = 0 CIRCUITPY_GAMEPAD = 0 CIRCUITPY_I2CPERIPHERAL = 0 CIRCUITPY_VECTORIO = 0 +CIRCUITPY_BUSDEVICE = 0 CFLAGS_INLINE_LIMIT = 60 SUPEROPT_GC = 0 diff --git a/ports/litex/mpconfigport.mk b/ports/litex/mpconfigport.mk index 485a75fde0..003fb5c2c3 100644 --- a/ports/litex/mpconfigport.mk +++ b/ports/litex/mpconfigport.mk @@ -18,6 +18,7 @@ CIRCUITPY_AUDIOIO = 0 CIRCUITPY_BITBANGIO = 0 CIRCUITPY_BLEIO_HCI = 0 CIRCUITPY_BOARD = 0 +CIRCUITPY_BUSDEVICE = 0 CIRCUITPY_BUSIO = 0 CIRCUITPY_COUNTIO = 0 CIRCUITPY_DISPLAYIO = 0 From 23ed3ef971f8f38497337874da39273e5ae090d7 Mon Sep 17 00:00:00 2001 From: gamblor21 Date: Wed, 11 Nov 2020 11:36:04 -0600 Subject: [PATCH 036/207] Removing frozen libs --- ports/atmel-samd/boards/8086_commander/mpconfigboard.mk | 1 - .../boards/feather_m0_express_crickit/mpconfigboard.mk | 1 - ports/atmel-samd/boards/feather_m0_rfm69/mpconfigboard.mk | 1 - ports/atmel-samd/boards/feather_m0_rfm9x/mpconfigboard.mk | 1 - ports/atmel-samd/boards/hallowing_m0_express/mpconfigboard.mk | 1 - ports/atmel-samd/boards/pycubed/mpconfigboard.mk | 1 - ports/atmel-samd/boards/pycubed_mram/mpconfigboard.mk | 1 - ports/atmel-samd/boards/sam32/mpconfigboard.mk | 1 - ports/atmel-samd/boards/xinabox_cc03/mpconfigboard.mk | 1 - ports/atmel-samd/boards/xinabox_cs11/mpconfigboard.mk | 1 - 10 files changed, 10 deletions(-) diff --git a/ports/atmel-samd/boards/8086_commander/mpconfigboard.mk b/ports/atmel-samd/boards/8086_commander/mpconfigboard.mk index 9151040a08..66e1a12256 100644 --- a/ports/atmel-samd/boards/8086_commander/mpconfigboard.mk +++ b/ports/atmel-samd/boards/8086_commander/mpconfigboard.mk @@ -21,7 +21,6 @@ CFLAGS_INLINE_LIMIT = 60 CIRCUITPY_GAMEPAD = 1 # Include these Python libraries in firmware. -FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_BusDevice FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_HID FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_SD #FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_ADXL34x 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 5624144e88..331a3110ef 100644 --- a/ports/atmel-samd/boards/feather_m0_express_crickit/mpconfigboard.mk +++ b/ports/atmel-samd/boards/feather_m0_express_crickit/mpconfigboard.mk @@ -20,7 +20,6 @@ CIRCUITPY_GAMEPAD = 0 CFLAGS_INLINE_LIMIT = 50 # Include these Python libraries in firmware. -FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_BusDevice FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_Crickit FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_Motor FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_NeoPixel diff --git a/ports/atmel-samd/boards/feather_m0_rfm69/mpconfigboard.mk b/ports/atmel-samd/boards/feather_m0_rfm69/mpconfigboard.mk index c33ab07400..614ddfa9ce 100644 --- a/ports/atmel-samd/boards/feather_m0_rfm69/mpconfigboard.mk +++ b/ports/atmel-samd/boards/feather_m0_rfm69/mpconfigboard.mk @@ -27,5 +27,4 @@ CFLAGS_INLINE_LIMIT = 35 SUPEROPT_GC = 0 # Include these Python libraries in firmware. -FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_BusDevice FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_RFM69 diff --git a/ports/atmel-samd/boards/feather_m0_rfm9x/mpconfigboard.mk b/ports/atmel-samd/boards/feather_m0_rfm9x/mpconfigboard.mk index 49b0ef5e36..5c1fd1ce98 100644 --- a/ports/atmel-samd/boards/feather_m0_rfm9x/mpconfigboard.mk +++ b/ports/atmel-samd/boards/feather_m0_rfm9x/mpconfigboard.mk @@ -28,5 +28,4 @@ CFLAGS_INLINE_LIMIT = 35 SUPEROPT_GC = 0 # Include these Python libraries in firmware. -FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_BusDevice FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_RFM9x diff --git a/ports/atmel-samd/boards/hallowing_m0_express/mpconfigboard.mk b/ports/atmel-samd/boards/hallowing_m0_express/mpconfigboard.mk index 1931ceb9a8..2b211abd4e 100644 --- a/ports/atmel-samd/boards/hallowing_m0_express/mpconfigboard.mk +++ b/ports/atmel-samd/boards/hallowing_m0_express/mpconfigboard.mk @@ -27,7 +27,6 @@ CFLAGS_INLINE_LIMIT = 55 SUPEROPT_GC = 0 # Include these Python libraries in firmware. -FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_BusDevice FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_LIS3DH FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_NeoPixel diff --git a/ports/atmel-samd/boards/pycubed/mpconfigboard.mk b/ports/atmel-samd/boards/pycubed/mpconfigboard.mk index b7b8073ab9..a82362b8d2 100644 --- a/ports/atmel-samd/boards/pycubed/mpconfigboard.mk +++ b/ports/atmel-samd/boards/pycubed/mpconfigboard.mk @@ -21,7 +21,6 @@ CIRCUITPY_GAMEPAD = 0 CIRCUITPY_RGBMATRIX = 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 diff --git a/ports/atmel-samd/boards/pycubed_mram/mpconfigboard.mk b/ports/atmel-samd/boards/pycubed_mram/mpconfigboard.mk index f49bb3fef0..3bf42d7054 100644 --- a/ports/atmel-samd/boards/pycubed_mram/mpconfigboard.mk +++ b/ports/atmel-samd/boards/pycubed_mram/mpconfigboard.mk @@ -21,7 +21,6 @@ CIRCUITPY_GAMEPAD = 0 CIRCUITPY_RGBMATRIX = 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 diff --git a/ports/atmel-samd/boards/sam32/mpconfigboard.mk b/ports/atmel-samd/boards/sam32/mpconfigboard.mk index 1dc686ef8a..9ac24a014c 100644 --- a/ports/atmel-samd/boards/sam32/mpconfigboard.mk +++ b/ports/atmel-samd/boards/sam32/mpconfigboard.mk @@ -13,5 +13,4 @@ LONGINT_IMPL = MPZ CIRCUITPY_AUDIOBUSIO = 0 CIRCUITPY_USTACK = 1 -FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_BusDevice FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_NeoPixel diff --git a/ports/atmel-samd/boards/xinabox_cc03/mpconfigboard.mk b/ports/atmel-samd/boards/xinabox_cc03/mpconfigboard.mk index fdcde4a07e..7243c54db7 100644 --- a/ports/atmel-samd/boards/xinabox_cc03/mpconfigboard.mk +++ b/ports/atmel-samd/boards/xinabox_cc03/mpconfigboard.mk @@ -23,4 +23,3 @@ CIRCUITPY_TOUCHIO_USE_NATIVE=0 CIRCUITPY_TOUCHIO=0 # Include these Python libraries in firmware. -FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_BusDevice diff --git a/ports/atmel-samd/boards/xinabox_cs11/mpconfigboard.mk b/ports/atmel-samd/boards/xinabox_cs11/mpconfigboard.mk index 9309fdce0d..50b2100aba 100644 --- a/ports/atmel-samd/boards/xinabox_cs11/mpconfigboard.mk +++ b/ports/atmel-samd/boards/xinabox_cs11/mpconfigboard.mk @@ -26,5 +26,4 @@ CIRCUITPY_RTC=0 CIRCUITPY_COUNTIO=0 # Include these Python libraries in firmware. -FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_BusDevice FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_SD From 35ef6c687fdd27a01e4e3a31731eeb622becc2fb Mon Sep 17 00:00:00 2001 From: microDev <70126934+microDev1@users.noreply.github.com> Date: Wed, 11 Nov 2020 23:11:12 +0530 Subject: [PATCH 037/207] nvm implementation for esp32s2 --- locale/circuitpython.pot | 10 ++- ports/esp32s2/Makefile | 2 + .../common-hal/microcontroller/__init__.c | 12 +++ ports/esp32s2/common-hal/nvm/ByteArray.c | 80 +++++++++++++++++++ ports/esp32s2/common-hal/nvm/ByteArray.h | 38 +++++++++ ports/esp32s2/common-hal/nvm/__init__.c | 1 + ports/esp32s2/mpconfigport.h | 7 +- ports/esp32s2/mpconfigport.mk | 2 +- 8 files changed, 147 insertions(+), 5 deletions(-) create mode 100644 ports/esp32s2/common-hal/nvm/ByteArray.c create mode 100644 ports/esp32s2/common-hal/nvm/ByteArray.h create mode 100644 ports/esp32s2/common-hal/nvm/__init__.c diff --git a/locale/circuitpython.pot b/locale/circuitpython.pot index b4445abfbf..2bb02b2c9d 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-11-04 21:18+0530\n" +"POT-Creation-Date: 2020-11-11 16:30+0530\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -296,7 +296,8 @@ msgstr "" msgid "All I2C peripherals are in use" msgstr "" -#: ports/esp32s2/peripherals/pcnt_handler.c +#: ports/esp32s2/common-hal/countio/Counter.c +#: ports/esp32s2/common-hal/rotaryio/IncrementalEncoder.c msgid "All PCNT units in use" msgstr "" @@ -1248,6 +1249,10 @@ msgstr "" msgid "Must use a multiple of 6 rgb pins, not %d" msgstr "" +#: ports/esp32s2/common-hal/nvm/ByteArray.c +msgid "NVS Error" +msgstr "" + #: py/parse.c msgid "Name too long" msgstr "" @@ -3201,6 +3206,7 @@ msgstr "" msgid "pow() with 3 arguments requires integers" msgstr "" +#: ports/esp32s2/boards/adafruit_magtag_2.9_grayscale/mpconfigboard.h #: ports/esp32s2/boards/adafruit_metro_esp32s2/mpconfigboard.h #: ports/esp32s2/boards/electroniccats_bastwifi/mpconfigboard.h #: ports/esp32s2/boards/espressif_kaluga_1/mpconfigboard.h diff --git a/ports/esp32s2/Makefile b/ports/esp32s2/Makefile index 55d6e91d44..ec389e9feb 100644 --- a/ports/esp32s2/Makefile +++ b/ports/esp32s2/Makefile @@ -104,6 +104,8 @@ INC += -isystem esp-idf/components/soc/soc/include INC += -isystem esp-idf/components/soc/soc/esp32s2/include INC += -isystem esp-idf/components/heap/include INC += -isystem esp-idf/components/esp_system/include +INC += -isystem esp-idf/components/spi_flash/include +INC += -isystem esp-idf/components/nvs_flash/include INC += -I$(BUILD)/esp-idf/config CFLAGS += -DHAVE_CONFIG_H \ diff --git a/ports/esp32s2/common-hal/microcontroller/__init__.c b/ports/esp32s2/common-hal/microcontroller/__init__.c index 6b2e18673d..dc4d2c095e 100644 --- a/ports/esp32s2/common-hal/microcontroller/__init__.c +++ b/ports/esp32s2/common-hal/microcontroller/__init__.c @@ -35,6 +35,7 @@ #include "shared-bindings/microcontroller/__init__.h" #include "shared-bindings/microcontroller/Pin.h" #include "shared-bindings/microcontroller/Processor.h" +#include "shared-bindings/nvm/ByteArray.h" #include "supervisor/filesystem.h" #include "supervisor/shared/safe_mode.h" @@ -85,6 +86,17 @@ 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 = (uint8_t*) CIRCUITPY_INTERNAL_NVM_START_ADDR, + .len = 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[] = { { MP_ROM_QSTR(MP_QSTR_GPIO0), MP_ROM_PTR(&pin_GPIO0) }, diff --git a/ports/esp32s2/common-hal/nvm/ByteArray.c b/ports/esp32s2/common-hal/nvm/ByteArray.c new file mode 100644 index 0000000000..30051df1ef --- /dev/null +++ b/ports/esp32s2/common-hal/nvm/ByteArray.c @@ -0,0 +1,80 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2020 microDev + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include "common-hal/nvm/ByteArray.h" + +#include "py/runtime.h" + +#include "nvs_flash.h" + +uint32_t common_hal_nvm_bytearray_get_length(nvm_bytearray_obj_t *self) { + return self->len; +} + +static nvs_handle get_nvs_handle(void) { + // Initialize NVS + esp_err_t err = nvs_flash_init(); + if (err == ESP_ERR_NVS_NO_FREE_PAGES || err == ESP_ERR_NVS_NEW_VERSION_FOUND) { + // NVS partition was truncated and needs to be erased + // Retry nvs_flash_init + ESP_ERROR_CHECK(nvs_flash_erase()); + err = nvs_flash_init(); + } + ESP_ERROR_CHECK(err); + + // Open NVS handle + nvs_handle nvs_handle; + if (nvs_open("CPY", NVS_READWRITE, &nvs_handle) != ESP_OK) { + mp_raise_RuntimeError(translate("NVS Error")); + } + return nvs_handle; +} + +bool common_hal_nvm_bytearray_set_bytes(nvm_bytearray_obj_t *self, + uint32_t start_index, uint8_t* values, uint32_t len) { + char index[9]; + sprintf(index, "%i", start_index); + // start nvs + nvs_handle handle = get_nvs_handle(); + bool status = ((nvs_set_u8(handle, (const char *)index, *values) == ESP_OK) && (nvs_commit(handle) == ESP_OK)); + // close nvs + nvs_close(handle); + return status; +} + +// NVM memory is memory mapped so reading it is easy. +void common_hal_nvm_bytearray_get_bytes(nvm_bytearray_obj_t *self, + uint32_t start_index, uint32_t len, uint8_t* values) { + char index[9]; + sprintf(index, "%i", start_index); + // start nvs + nvs_handle handle = get_nvs_handle(); + if (nvs_get_u8(handle, (const char *)index, values) != ESP_OK) { + mp_raise_RuntimeError(translate("NVS Error")); + } + // close nvs + nvs_close(handle); +} diff --git a/ports/esp32s2/common-hal/nvm/ByteArray.h b/ports/esp32s2/common-hal/nvm/ByteArray.h new file mode 100644 index 0000000000..44b63d7241 --- /dev/null +++ b/ports/esp32s2/common-hal/nvm/ByteArray.h @@ -0,0 +1,38 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2020 microDev + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#ifndef MICROPY_INCLUDED_ESP32S2_COMMON_HAL_NVM_BYTEARRAY_H +#define MICROPY_INCLUDED_ESP32S2_COMMON_HAL_NVM_BYTEARRAY_H + +#include "py/obj.h" + +typedef struct { + mp_obj_base_t base; + uint8_t* start_address; + uint32_t len; +} nvm_bytearray_obj_t; + +#endif // MICROPY_INCLUDED_ESP32S2_COMMON_HAL_NVM_BYTEARRAY_H diff --git a/ports/esp32s2/common-hal/nvm/__init__.c b/ports/esp32s2/common-hal/nvm/__init__.c new file mode 100644 index 0000000000..1b702a1584 --- /dev/null +++ b/ports/esp32s2/common-hal/nvm/__init__.c @@ -0,0 +1 @@ +// No nvm module functions. diff --git a/ports/esp32s2/mpconfigport.h b/ports/esp32s2/mpconfigport.h index cec8dd35df..11ea5f6382 100644 --- a/ports/esp32s2/mpconfigport.h +++ b/ports/esp32s2/mpconfigport.h @@ -28,7 +28,6 @@ #ifndef ESP32S2_MPCONFIGPORT_H__ #define ESP32S2_MPCONFIGPORT_H__ -#define CIRCUITPY_INTERNAL_NVM_SIZE (0) #define MICROPY_NLR_THUMB (0) #define MICROPY_PY_UJSON (1) @@ -36,11 +35,15 @@ #include "py/circuitpy_mpconfig.h" - #define MICROPY_PORT_ROOT_POINTERS \ CIRCUITPY_COMMON_ROOT_POINTERS #define MICROPY_NLR_SETJMP (1) #define CIRCUITPY_DEFAULT_STACK_SIZE 0x6000 +#define CIRCUITPY_INTERNAL_NVM_START_ADDR (0x9000) + +#ifndef CIRCUITPY_INTERNAL_NVM_SIZE +#define CIRCUITPY_INTERNAL_NVM_SIZE (20000) +#endif #endif // __INCLUDED_ESP32S2_MPCONFIGPORT_H diff --git a/ports/esp32s2/mpconfigport.mk b/ports/esp32s2/mpconfigport.mk index 4579b95ab6..7f3b4241a0 100644 --- a/ports/esp32s2/mpconfigport.mk +++ b/ports/esp32s2/mpconfigport.mk @@ -21,7 +21,7 @@ CIRCUITPY_COUNTIO = 1 CIRCUITPY_FREQUENCYIO = 0 CIRCUITPY_I2CPERIPHERAL = 0 CIRCUITPY_ROTARYIO = 1 -CIRCUITPY_NVM = 0 +CIRCUITPY_NVM = 1 # We don't have enough endpoints to include MIDI. CIRCUITPY_USB_MIDI = 0 CIRCUITPY_WIFI = 1 From 0f7081781e8a45da513b371978a354ea8734cc31 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Thu, 12 Nov 2020 20:40:09 -0600 Subject: [PATCH 038/207] esp32s2: wifi: fix several debug-build errors Closes #3688 With this change, I don't get the ESP_ERROR_CHECK failed repeatedly running code that imports wifi. (I'm not getting a successful connection but that's probably my own fault, such as a secrets problem) --- ports/esp32s2/common-hal/wifi/__init__.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ports/esp32s2/common-hal/wifi/__init__.c b/ports/esp32s2/common-hal/wifi/__init__.c index 833ef0623f..2eb3719b4d 100644 --- a/ports/esp32s2/common-hal/wifi/__init__.c +++ b/ports/esp32s2/common-hal/wifi/__init__.c @@ -143,8 +143,8 @@ void wifi_reset(void) { radio->handler_instance_got_ip)); ESP_ERROR_CHECK(esp_wifi_deinit()); esp_netif_destroy(radio->netif); + ESP_ERROR_CHECK(esp_event_loop_delete_default()); radio->netif = NULL; - ESP_ERROR_CHECK(esp_netif_deinit()); } void ipaddress_ipaddress_to_esp_idf(mp_obj_t ip_address, ip_addr_t* esp_ip_address) { From 146adca060d7abc76149c88c7cdd2d401f799efa Mon Sep 17 00:00:00 2001 From: microDev <70126934+microDev1@users.noreply.github.com> Date: Sat, 14 Nov 2020 11:41:14 +0530 Subject: [PATCH 039/207] Add watchdog mode raise --- ports/esp32s2/common-hal/watchdog/WatchDogTimer.c | 9 ++++++++- ports/esp32s2/common-hal/watchdog/WatchDogTimer.h | 3 +-- ports/esp32s2/supervisor/port.c | 5 +++++ 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/ports/esp32s2/common-hal/watchdog/WatchDogTimer.c b/ports/esp32s2/common-hal/watchdog/WatchDogTimer.c index 59b9dafcf0..b51a391b7f 100644 --- a/ports/esp32s2/common-hal/watchdog/WatchDogTimer.c +++ b/ports/esp32s2/common-hal/watchdog/WatchDogTimer.c @@ -27,12 +27,19 @@ #include "py/runtime.h" #include "common-hal/watchdog/WatchDogTimer.h" +#include "shared-bindings/watchdog/__init__.h" #include "shared-bindings/microcontroller/__init__.h" #include "esp_task_wdt.h" void esp_task_wdt_isr_user_handler(void) { - + mp_obj_exception_clear_traceback(MP_OBJ_FROM_PTR(&mp_watchdog_timeout_exception)); + MP_STATE_VM(mp_pending_exception) = &mp_watchdog_timeout_exception; +#if MICROPY_ENABLE_SCHEDULER + if (MP_STATE_VM(sched_state) == MP_SCHED_IDLE) { + MP_STATE_VM(sched_state) = MP_SCHED_PENDING; + } +#endif } void common_hal_watchdog_feed(watchdog_watchdogtimer_obj_t *self) { diff --git a/ports/esp32s2/common-hal/watchdog/WatchDogTimer.h b/ports/esp32s2/common-hal/watchdog/WatchDogTimer.h index 05e0e954d2..04d9aeee6c 100644 --- a/ports/esp32s2/common-hal/watchdog/WatchDogTimer.h +++ b/ports/esp32s2/common-hal/watchdog/WatchDogTimer.h @@ -37,8 +37,7 @@ struct _watchdog_watchdogtimer_obj_t { watchdog_watchdogmode_t mode; }; -// This needs to be called in order to disable the watchdog if it's set to -// "RAISE". If set to "RESET", then the watchdog cannot be reset. +// This needs to be called in order to disable the watchdog void watchdog_reset(void); #endif // MICROPY_INCLUDED_ESP32S2_COMMON_HAL_WATCHDOG_WATCHDOGTIMER_H diff --git a/ports/esp32s2/supervisor/port.c b/ports/esp32s2/supervisor/port.c index 0b9c03f747..1b6f5ef7cb 100644 --- a/ports/esp32s2/supervisor/port.c +++ b/ports/esp32s2/supervisor/port.c @@ -41,6 +41,7 @@ #include "common-hal/busio/UART.h" #include "common-hal/pulseio/PulseIn.h" #include "common-hal/pwmio/PWMOut.h" +#include "common-hal/watchdog/WatchDogTimer.h" #include "common-hal/wifi/__init__.h" #include "supervisor/memory.h" #include "supervisor/shared/tick.h" @@ -119,6 +120,10 @@ void reset_port(void) { rtc_reset(); #endif +#if CIRCUITPY_WATCHDOG + watchdog_reset(); +#endif + #if CIRCUITPY_WIFI wifi_reset(); #endif From 231e3d362dae1988d5103b1042957ae793599d8b Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Sat, 14 Nov 2020 10:16:39 -0600 Subject: [PATCH 040/207] esp32s2: Update esp-idf submodule to include fix for #3424 This re-points the submodule to my personal fork of esp-idf. Users may need to `git submodule sync` in their existing trees when this change occurs. Adds just the following commit in esp-idf: > esp_crt_bundle: Allow verify_callback to correct BADCERT_BAD_MD --- .gitmodules | 2 +- ports/esp32s2/esp-idf | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitmodules b/.gitmodules index f66ce8aafa..aaa66caf71 100644 --- a/.gitmodules +++ b/.gitmodules @@ -152,4 +152,4 @@ url = https://github.com/adafruit/Adafruit_CircuitPython_RFM69.git [submodule "ports/esp32s2/esp-idf"] path = ports/esp32s2/esp-idf - url = https://github.com/espressif/esp-idf.git + url = https://github.com/jepler/esp-idf.git diff --git a/ports/esp32s2/esp-idf b/ports/esp32s2/esp-idf index 8bc19ba893..d06744f5ef 160000 --- a/ports/esp32s2/esp-idf +++ b/ports/esp32s2/esp-idf @@ -1 +1 @@ -Subproject commit 8bc19ba893e5544d571a753d82b44a84799b94b1 +Subproject commit d06744f5efc382c61cbad8758107cec308feef09 From 6c3c076cc110d935f0f8406de81007563994e553 Mon Sep 17 00:00:00 2001 From: RubenD Date: Fri, 13 Nov 2020 23:49:31 +0000 Subject: [PATCH 041/207] Translated using Weblate (Spanish) Currently translated at 99.2% (840 of 846 strings) Translation: CircuitPython/main Translate-URL: https://hosted.weblate.org/projects/circuitpython/main/es/ --- locale/es.po | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/locale/es.po b/locale/es.po index ed7431eb7c..c5e2ad75f0 100644 --- a/locale/es.po +++ b/locale/es.po @@ -8,15 +8,15 @@ msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2020-11-04 21:18+0530\n" -"PO-Revision-Date: 2020-11-01 16:26+0000\n" -"Last-Translator: Alvaro Figueroa \n" +"PO-Revision-Date: 2020-11-15 16:28+0000\n" +"Last-Translator: RubenD \n" "Language-Team: \n" "Language: es\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=2; plural=n != 1;\n" -"X-Generator: Weblate 4.3.2-dev\n" +"X-Generator: Weblate 4.4-dev\n" #: main.c msgid "" @@ -305,7 +305,7 @@ msgstr "Todos los periféricos I2C están siendo usados" #: ports/esp32s2/peripherals/pcnt_handler.c msgid "All PCNT units in use" -msgstr "" +msgstr "Todas las unidades PCNT en uso" #: ports/atmel-samd/common-hal/canio/Listener.c #: ports/esp32s2/common-hal/canio/Listener.c @@ -445,7 +445,7 @@ msgstr "Bit clock y word select deben compartir una unidad de reloj" #: shared-bindings/rgbmatrix/RGBMatrix.c #, c-format msgid "Bit depth must be from 1 to 6 inclusive, not %d" -msgstr "" +msgstr "Bit depth tiene que ser de 1 a 6 inclusivo, no %d" #: shared-bindings/audiobusio/PDMIn.c msgid "Bit depth must be multiple of 8." From 76d60ba95bb79e0a553fd6f9dcb5cb25806ada2f Mon Sep 17 00:00:00 2001 From: Antonin ENFRUN Date: Fri, 13 Nov 2020 07:56:16 +0000 Subject: [PATCH 042/207] Translated using Weblate (French) Currently translated at 100.0% (846 of 846 strings) Translation: CircuitPython/main Translate-URL: https://hosted.weblate.org/projects/circuitpython/main/fr/ --- locale/fr.po | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/locale/fr.po b/locale/fr.po index ff15b527e6..5d4ca75d5c 100644 --- a/locale/fr.po +++ b/locale/fr.po @@ -8,14 +8,14 @@ msgstr "" "Project-Id-Version: 0.1\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2020-11-04 21:18+0530\n" -"PO-Revision-Date: 2020-10-22 20:48+0000\n" +"PO-Revision-Date: 2020-11-15 16:28+0000\n" "Last-Translator: Antonin ENFRUN \n" "Language: fr\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=utf-8\n" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=2; plural=n > 1;\n" -"X-Generator: Weblate 4.3.1\n" +"X-Generator: Weblate 4.4-dev\n" #: main.c msgid "" @@ -298,7 +298,7 @@ msgstr "Type d'adresse hors plage" #: ports/esp32s2/common-hal/canio/CAN.c msgid "All CAN peripherals are in use" -msgstr "" +msgstr "Tous les périphériques CAN sont utilisés" #: ports/esp32s2/common-hal/busio/I2C.c ports/nrf/common-hal/busio/I2C.c msgid "All I2C peripherals are in use" @@ -306,7 +306,7 @@ msgstr "Tous les périphériques I2C sont utilisés" #: ports/esp32s2/peripherals/pcnt_handler.c msgid "All PCNT units in use" -msgstr "" +msgstr "Toutes les unités PCNT sont utilisées" #: ports/atmel-samd/common-hal/canio/Listener.c #: ports/esp32s2/common-hal/canio/Listener.c @@ -431,7 +431,7 @@ msgstr "" #: ports/esp32s2/common-hal/canio/CAN.c msgid "Baudrate not supported by peripheral" -msgstr "" +msgstr "Baudrate non prise en charge par le périphérique" #: shared-module/displayio/Display.c #: shared-module/framebufferio/FramebufferDisplay.c @@ -445,7 +445,7 @@ msgstr "'bit clock' et 'word select' doivent partager une horloge" #: shared-bindings/rgbmatrix/RGBMatrix.c #, c-format msgid "Bit depth must be from 1 to 6 inclusive, not %d" -msgstr "" +msgstr "Bit depth doit être compris entre 1 et 6 inclus, et non %d" #: shared-bindings/audiobusio/PDMIn.c msgid "Bit depth must be multiple of 8." @@ -2953,7 +2953,7 @@ msgstr "entiers longs non supportés dans cette build" #: ports/esp32s2/common-hal/canio/CAN.c msgid "loopback + silent mode not supported by peripheral" -msgstr "" +msgstr "loopback + silent mode non pris en charge par le périphérique" #: py/parse.c msgid "malformed f-string" @@ -2991,11 +2991,11 @@ msgstr "profondeur maximale de récursivité dépassée" #: extmod/ulab/code/approx/approx.c msgid "maxiter must be > 0" -msgstr "" +msgstr "maxiter doit être > 0" #: extmod/ulab/code/approx/approx.c msgid "maxiter should be > 0" -msgstr "" +msgstr "maxiter devrait être > 0" #: py/runtime.c #, c-format @@ -3440,7 +3440,7 @@ msgstr "l'argument de «sort» doit être un ndarray" #: extmod/ulab/code/numerical/numerical.c msgid "sorted axis can't be longer than 65535" -msgstr "" +msgstr "sorted axis ne peut pas dépasser 65535" #: extmod/ulab/code/filter/filter.c msgid "sos array must be of shape (n_section, 6)" @@ -3575,12 +3575,12 @@ msgstr "tuple/liste a une mauvaise longueur" #: ports/esp32s2/common-hal/canio/CAN.c #, c-format msgid "twai_driver_install returned esp-idf error #%d" -msgstr "" +msgstr "twai_driver_install a renvoyé l'erreur esp-idf #%d" #: ports/esp32s2/common-hal/canio/CAN.c #, c-format msgid "twai_start returned esp-idf error #%d" -msgstr "" +msgstr "twai_start a renvoyé l'erreur esp-idf #%d" #: ports/atmel-samd/common-hal/busio/UART.c #: ports/esp32s2/common-hal/busio/UART.c ports/nrf/common-hal/busio/UART.c From 8218eb2ddf92d979b16391a9a5400ab8a5ce2e67 Mon Sep 17 00:00:00 2001 From: Jonny Bergdahl Date: Fri, 13 Nov 2020 19:51:22 +0000 Subject: [PATCH 043/207] Translated using Weblate (Swedish) Currently translated at 100.0% (846 of 846 strings) Translation: CircuitPython/main Translate-URL: https://hosted.weblate.org/projects/circuitpython/main/sv/ --- locale/sv.po | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/locale/sv.po b/locale/sv.po index be7eb08946..1a603e4961 100644 --- a/locale/sv.po +++ b/locale/sv.po @@ -6,7 +6,7 @@ msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2020-11-04 21:18+0530\n" -"PO-Revision-Date: 2020-11-05 20:26+0000\n" +"PO-Revision-Date: 2020-11-15 16:28+0000\n" "Last-Translator: Jonny Bergdahl \n" "Language-Team: LANGUAGE \n" "Language: sv\n" @@ -14,7 +14,7 @@ msgstr "" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=2; plural=n != 1;\n" -"X-Generator: Weblate 4.3.2\n" +"X-Generator: Weblate 4.4-dev\n" #: main.c msgid "" @@ -302,7 +302,7 @@ msgstr "All I2C-kringutrustning används" #: ports/esp32s2/peripherals/pcnt_handler.c msgid "All PCNT units in use" -msgstr "" +msgstr "Alla PCNT-enheter används" #: ports/atmel-samd/common-hal/canio/Listener.c #: ports/esp32s2/common-hal/canio/Listener.c @@ -438,7 +438,7 @@ msgstr "Bitklocka och ordval måste dela en klockenhet" #: shared-bindings/rgbmatrix/RGBMatrix.c #, c-format msgid "Bit depth must be from 1 to 6 inclusive, not %d" -msgstr "" +msgstr "Bitdjup måste vara inom 1 till 6, inte %d" #: shared-bindings/audiobusio/PDMIn.c msgid "Bit depth must be multiple of 8." From 64725190f47fbe3d2b4e54b0e58c485949878a89 Mon Sep 17 00:00:00 2001 From: hexthat Date: Sat, 14 Nov 2020 15:43:32 +0000 Subject: [PATCH 044/207] Translated using Weblate (Chinese (Pinyin)) Currently translated at 100.0% (846 of 846 strings) Translation: CircuitPython/main Translate-URL: https://hosted.weblate.org/projects/circuitpython/main/zh_Latn/ --- locale/zh_Latn_pinyin.po | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/locale/zh_Latn_pinyin.po b/locale/zh_Latn_pinyin.po index 4ac1c3e1ee..2731ec4f5e 100644 --- a/locale/zh_Latn_pinyin.po +++ b/locale/zh_Latn_pinyin.po @@ -7,7 +7,7 @@ msgstr "" "Project-Id-Version: circuitpython-cn\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2020-11-04 21:18+0530\n" -"PO-Revision-Date: 2020-11-11 19:13+0000\n" +"PO-Revision-Date: 2020-11-15 16:28+0000\n" "Last-Translator: hexthat \n" "Language-Team: Chinese Hanyu Pinyin\n" "Language: zh_Latn_pinyin\n" @@ -440,7 +440,7 @@ msgstr "Bǐtè shízhōng hé dānzì xuǎnzé bìxū gòngxiǎng shízhōng dā #: shared-bindings/rgbmatrix/RGBMatrix.c #, c-format msgid "Bit depth must be from 1 to 6 inclusive, not %d" -msgstr "" +msgstr "wèi shēn dù bì xū bāo hán 1 dào 6, ér bù shì %d" #: shared-bindings/audiobusio/PDMIn.c msgid "Bit depth must be multiple of 8." From c4917cdabd97c016a46b6193e93b274573d94193 Mon Sep 17 00:00:00 2001 From: microDev <70126934+microDev1@users.noreply.github.com> Date: Mon, 16 Nov 2020 00:11:00 +0530 Subject: [PATCH 045/207] frequencyio implementation for esp32s2 --- .../common-hal/frequencyio/FrequencyIn.c | 158 ++++++++++++++++++ .../common-hal/frequencyio/FrequencyIn.h | 43 +++++ .../esp32s2/common-hal/frequencyio/__init__.c | 1 + ports/esp32s2/mpconfigport.mk | 2 +- 4 files changed, 203 insertions(+), 1 deletion(-) create mode 100644 ports/esp32s2/common-hal/frequencyio/FrequencyIn.c create mode 100644 ports/esp32s2/common-hal/frequencyio/FrequencyIn.h create mode 100644 ports/esp32s2/common-hal/frequencyio/__init__.c diff --git a/ports/esp32s2/common-hal/frequencyio/FrequencyIn.c b/ports/esp32s2/common-hal/frequencyio/FrequencyIn.c new file mode 100644 index 0000000000..fce1d34d87 --- /dev/null +++ b/ports/esp32s2/common-hal/frequencyio/FrequencyIn.c @@ -0,0 +1,158 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2020 microDev + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include "shared-bindings/frequencyio/FrequencyIn.h" + +#include + +#include "py/runtime.h" + +#include "supervisor/shared/tick.h" +#include "shared-bindings/time/__init__.h" + +#include "common-hal/microcontroller/Pin.h" + +static void frequencyin_interrupt_handler(void *self_in) { + frequencyio_frequencyin_obj_t* self = self_in; + // get counter value + int16_t count; + pcnt_get_counter_value(self->unit, &count); + self->frequency = count / 2.0 / self->capture_period; + + // reset counter + pcnt_counter_clear(self->unit); +} + +static void init_timer(frequencyio_frequencyin_obj_t* self, uint16_t capture_period) { + // Prepare configuration for the timer module + timer_config_t config = { + .alarm_en = true, + .counter_en = false, + .intr_type = TIMER_INTR_LEVEL, + .counter_dir = TIMER_COUNT_UP, + .auto_reload = true, + .divider = 80 // 1 us per tick + }; + + // Initialize timer module + timer_init(TIMER_GROUP_0, TIMER_0, &config); + timer_set_counter_value(TIMER_GROUP_0, TIMER_0, 0); + timer_set_alarm_value(TIMER_GROUP_0, TIMER_0, capture_period * 1000000); + timer_enable_intr(TIMER_GROUP_0, TIMER_0); + timer_isr_register(TIMER_GROUP_0, TIMER_0, &frequencyin_interrupt_handler, (void *)self, 0, &self->handle); + + // Start timer + timer_start(TIMER_GROUP_0, TIMER_0); +} + +void common_hal_frequencyio_frequencyin_construct(frequencyio_frequencyin_obj_t* self, + const mcu_pin_obj_t* pin, const uint16_t capture_period) { + if ((capture_period == 0) || (capture_period > 500)) { + mp_raise_ValueError(translate("Invalid capture period. Valid range: 1 - 500")); + } + + // Prepare configuration for the PCNT unit + const pcnt_config_t pcnt_config = { + // Set PCNT input signal and control GPIOs + .pulse_gpio_num = pin->number, + .ctrl_gpio_num = PCNT_PIN_NOT_USED, + .channel = PCNT_CHANNEL_0, + .lctrl_mode = PCNT_MODE_DISABLE, + .hctrl_mode = PCNT_MODE_KEEP, + .pos_mode = PCNT_COUNT_INC, // count both rising and falling edges + .neg_mode = PCNT_COUNT_INC, + .counter_h_lim = 0, + .counter_l_lim = 0, + }; + + // Initialize PCNT unit + const int8_t unit = peripherals_pcnt_init(pcnt_config); + if (unit == -1) { + mp_raise_RuntimeError(translate("All PCNT units in use")); + } + + // set the GPIO back to high-impedance, as pcnt_unit_config sets it as pull-up + gpio_set_pull_mode(pin->number, GPIO_FLOATING); + + // initialize timer + init_timer(self, capture_period); + + self->pin = pin->number; + self->unit = (pcnt_unit_t)unit; + self->capture_period = capture_period; + + claim_pin(pin); +} + +bool common_hal_frequencyio_frequencyin_deinited(frequencyio_frequencyin_obj_t* self) { + return self->unit == PCNT_UNIT_MAX; +} + +void common_hal_frequencyio_frequencyin_deinit(frequencyio_frequencyin_obj_t* self) { + if (common_hal_frequencyio_frequencyin_deinited(self)) { + return; + } + reset_pin_number(self->pin); + peripherals_pcnt_deinit(&self->unit); + if (self->handle) { + timer_deinit(TIMER_GROUP_0, TIMER_0); + esp_intr_free(self->handle); + self->handle = NULL; + } +} + +uint32_t common_hal_frequencyio_frequencyin_get_item(frequencyio_frequencyin_obj_t* self) { + return (1000 / (self->capture_period / self->frequency)); +} + +void common_hal_frequencyio_frequencyin_pause(frequencyio_frequencyin_obj_t* self) { + pcnt_counter_pause(self->unit); + timer_pause(TIMER_GROUP_0, TIMER_0); +} + +void common_hal_frequencyio_frequencyin_resume(frequencyio_frequencyin_obj_t* self) { + pcnt_counter_resume(self->unit); + timer_start(TIMER_GROUP_0, TIMER_0); +} + +void common_hal_frequencyio_frequencyin_clear(frequencyio_frequencyin_obj_t* self) { + self->frequency = 0; + pcnt_counter_clear(self->unit); + timer_set_counter_value(TIMER_GROUP_0, TIMER_0, 0); +} + +uint16_t common_hal_frequencyio_frequencyin_get_capture_period(frequencyio_frequencyin_obj_t *self) { + return self->capture_period; +} + +void common_hal_frequencyio_frequencyin_set_capture_period(frequencyio_frequencyin_obj_t *self, uint16_t capture_period) { + if ((capture_period == 0) || (capture_period > 500)) { + mp_raise_ValueError(translate("Invalid capture period. Valid range: 1 - 500")); + } + self->capture_period = capture_period; + common_hal_frequencyio_frequencyin_clear(self); + timer_set_alarm_value(TIMER_GROUP_0, TIMER_0, capture_period * 1000000); +} diff --git a/ports/esp32s2/common-hal/frequencyio/FrequencyIn.h b/ports/esp32s2/common-hal/frequencyio/FrequencyIn.h new file mode 100644 index 0000000000..01e617d13a --- /dev/null +++ b/ports/esp32s2/common-hal/frequencyio/FrequencyIn.h @@ -0,0 +1,43 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2020 microDev + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#ifndef MICROPY_INCLUDED_ESP32S2_COMMON_HAL_FREQUENCYIO_FREQUENCYIN_H +#define MICROPY_INCLUDED_ESP32S2_COMMON_HAL_FREQUENCYIO_FREQUENCYIN_H + +#include "py/obj.h" +#include "driver/timer.h" +#include "peripherals/pcnt.h" + +typedef struct { + mp_obj_base_t base; + pcnt_unit_t unit; + intr_handle_t handle; + uint8_t pin; + uint32_t frequency; + uint16_t capture_period; +} frequencyio_frequencyin_obj_t; + +#endif // MICROPY_INCLUDED_ESP32S2_COMMON_HAL_FREQUENCYIO_FREQUENCYIN_H diff --git a/ports/esp32s2/common-hal/frequencyio/__init__.c b/ports/esp32s2/common-hal/frequencyio/__init__.c new file mode 100644 index 0000000000..487814bd07 --- /dev/null +++ b/ports/esp32s2/common-hal/frequencyio/__init__.c @@ -0,0 +1 @@ +// No ferquencyio module functions. diff --git a/ports/esp32s2/mpconfigport.mk b/ports/esp32s2/mpconfigport.mk index 4579b95ab6..a84965a6a1 100644 --- a/ports/esp32s2/mpconfigport.mk +++ b/ports/esp32s2/mpconfigport.mk @@ -18,7 +18,7 @@ CIRCUITPY_AUDIOBUSIO = 0 CIRCUITPY_AUDIOIO = 0 CIRCUITPY_CANIO = 1 CIRCUITPY_COUNTIO = 1 -CIRCUITPY_FREQUENCYIO = 0 +CIRCUITPY_FREQUENCYIO = 1 CIRCUITPY_I2CPERIPHERAL = 0 CIRCUITPY_ROTARYIO = 1 CIRCUITPY_NVM = 0 From d4ab00f734203d358299508c01378d97ddf9d40f Mon Sep 17 00:00:00 2001 From: BennyE Date: Mon, 16 Nov 2020 00:31:06 +0100 Subject: [PATCH 046/207] Set station mode early to avoid SoftAP on startup --- ports/esp32s2/common-hal/wifi/Radio.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ports/esp32s2/common-hal/wifi/Radio.c b/ports/esp32s2/common-hal/wifi/Radio.c index 275bae31af..1945da207b 100644 --- a/ports/esp32s2/common-hal/wifi/Radio.c +++ b/ports/esp32s2/common-hal/wifi/Radio.c @@ -72,6 +72,8 @@ void common_hal_wifi_radio_set_enabled(wifi_radio_obj_t *self, bool enabled) { return; } if (!self->started && enabled) { + // esp_wifi_start() would default to soft-AP, thus setting it to station + ESP_ERROR_CHECK(esp_wifi_set_mode(WIFI_MODE_STA)); ESP_ERROR_CHECK(esp_wifi_start()); self->started = true; return; From 2bec02738fb7eacaaea710bd448b98a418eb2693 Mon Sep 17 00:00:00 2001 From: microDev <70126934+microDev1@users.noreply.github.com> Date: Mon, 16 Nov 2020 11:44:11 +0530 Subject: [PATCH 047/207] move interrupt handler to iram --- ports/esp32s2/common-hal/frequencyio/FrequencyIn.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/ports/esp32s2/common-hal/frequencyio/FrequencyIn.c b/ports/esp32s2/common-hal/frequencyio/FrequencyIn.c index fce1d34d87..ec7ebb21ac 100644 --- a/ports/esp32s2/common-hal/frequencyio/FrequencyIn.c +++ b/ports/esp32s2/common-hal/frequencyio/FrequencyIn.c @@ -35,7 +35,7 @@ #include "common-hal/microcontroller/Pin.h" -static void frequencyin_interrupt_handler(void *self_in) { +static void IRAM_ATTR frequencyin_interrupt_handler(void *self_in) { frequencyio_frequencyin_obj_t* self = self_in; // get counter value int16_t count; @@ -44,6 +44,10 @@ static void frequencyin_interrupt_handler(void *self_in) { // reset counter pcnt_counter_clear(self->unit); + + // reset interrupt + TIMERG0.int_clr.t0 = 1; + TIMERG0.hw_timer[0].config.alarm_en = 1; } static void init_timer(frequencyio_frequencyin_obj_t* self, uint16_t capture_period) { @@ -62,7 +66,7 @@ static void init_timer(frequencyio_frequencyin_obj_t* self, uint16_t capture_per timer_set_counter_value(TIMER_GROUP_0, TIMER_0, 0); timer_set_alarm_value(TIMER_GROUP_0, TIMER_0, capture_period * 1000000); timer_enable_intr(TIMER_GROUP_0, TIMER_0); - timer_isr_register(TIMER_GROUP_0, TIMER_0, &frequencyin_interrupt_handler, (void *)self, 0, &self->handle); + timer_isr_register(TIMER_GROUP_0, TIMER_0, frequencyin_interrupt_handler, (void *)self, ESP_INTR_FLAG_IRAM, &self->handle); // Start timer timer_start(TIMER_GROUP_0, TIMER_0); From f2824f6a68b3d326e0f4a137880e08147a0074d2 Mon Sep 17 00:00:00 2001 From: microDev <70126934+microDev1@users.noreply.github.com> Date: Mon, 16 Nov 2020 12:55:55 +0530 Subject: [PATCH 048/207] update frequency measurement --- ports/esp32s2/common-hal/frequencyio/FrequencyIn.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/ports/esp32s2/common-hal/frequencyio/FrequencyIn.c b/ports/esp32s2/common-hal/frequencyio/FrequencyIn.c index ec7ebb21ac..bdbe782add 100644 --- a/ports/esp32s2/common-hal/frequencyio/FrequencyIn.c +++ b/ports/esp32s2/common-hal/frequencyio/FrequencyIn.c @@ -84,12 +84,9 @@ void common_hal_frequencyio_frequencyin_construct(frequencyio_frequencyin_obj_t* .pulse_gpio_num = pin->number, .ctrl_gpio_num = PCNT_PIN_NOT_USED, .channel = PCNT_CHANNEL_0, - .lctrl_mode = PCNT_MODE_DISABLE, - .hctrl_mode = PCNT_MODE_KEEP, + // What to do on the positive / negative edge of pulse input? .pos_mode = PCNT_COUNT_INC, // count both rising and falling edges .neg_mode = PCNT_COUNT_INC, - .counter_h_lim = 0, - .counter_l_lim = 0, }; // Initialize PCNT unit @@ -129,7 +126,7 @@ void common_hal_frequencyio_frequencyin_deinit(frequencyio_frequencyin_obj_t* se } uint32_t common_hal_frequencyio_frequencyin_get_item(frequencyio_frequencyin_obj_t* self) { - return (1000 / (self->capture_period / self->frequency)); + return self->frequency; } void common_hal_frequencyio_frequencyin_pause(frequencyio_frequencyin_obj_t* self) { From 0cd951fb73198f5c3dd03ea0463382edac0d3d4d Mon Sep 17 00:00:00 2001 From: root Date: Mon, 16 Nov 2020 10:36:05 -0600 Subject: [PATCH 049/207] Prevent exceptions from accumulating in REPL --- py/obj.c | 1 + 1 file changed, 1 insertion(+) diff --git a/py/obj.c b/py/obj.c index 9dc0cf4749..315e816e0b 100644 --- a/py/obj.c +++ b/py/obj.c @@ -125,6 +125,7 @@ void mp_obj_print_exception(const mp_print_t *print, mp_obj_t exc) { mp_printf(print, decompressed_block, block); } } + mp_obj_exception_clear_traceback(exc); } } mp_obj_print_helper(print, exc, PRINT_EXC); From 18e463cca538ed80f03ce9eda0e2ff757f1ba8f4 Mon Sep 17 00:00:00 2001 From: microDev <70126934+microDev1@users.noreply.github.com> Date: Mon, 16 Nov 2020 23:32:22 +0530 Subject: [PATCH 050/207] add pcnt overflow handler & clean-up --- .../common-hal/frequencyio/FrequencyIn.c | 91 +++++++++++-------- .../common-hal/frequencyio/FrequencyIn.h | 3 +- 2 files changed, 57 insertions(+), 37 deletions(-) diff --git a/ports/esp32s2/common-hal/frequencyio/FrequencyIn.c b/ports/esp32s2/common-hal/frequencyio/FrequencyIn.c index bdbe782add..20d744139d 100644 --- a/ports/esp32s2/common-hal/frequencyio/FrequencyIn.c +++ b/ports/esp32s2/common-hal/frequencyio/FrequencyIn.c @@ -26,16 +26,21 @@ #include "shared-bindings/frequencyio/FrequencyIn.h" -#include - #include "py/runtime.h" -#include "supervisor/shared/tick.h" -#include "shared-bindings/time/__init__.h" +static void IRAM_ATTR pcnt_overflow_handler(void *self_in) { + frequencyio_frequencyin_obj_t* self = self_in; + // reset counter + pcnt_counter_clear(self->unit); -#include "common-hal/microcontroller/Pin.h" + // increase multiplier + self->multiplier++; -static void IRAM_ATTR frequencyin_interrupt_handler(void *self_in) { + // reset interrupt + PCNT.int_clr.val = BIT(self->unit); +} + +static void IRAM_ATTR timer_interrupt_handler(void *self_in) { frequencyio_frequencyin_obj_t* self = self_in; // get counter value int16_t count; @@ -50,9 +55,41 @@ static void IRAM_ATTR frequencyin_interrupt_handler(void *self_in) { TIMERG0.hw_timer[0].config.alarm_en = 1; } -static void init_timer(frequencyio_frequencyin_obj_t* self, uint16_t capture_period) { +static void init_pcnt(frequencyio_frequencyin_obj_t* self) { + // Prepare configuration for the PCNT unit + const pcnt_config_t pcnt_config = { + // Set PCNT input signal and control GPIOs + .pulse_gpio_num = self->pin, + .ctrl_gpio_num = PCNT_PIN_NOT_USED, + .channel = PCNT_CHANNEL_0, + // What to do on the positive / negative edge of pulse input? + .pos_mode = PCNT_COUNT_INC, // count both rising and falling edges + .neg_mode = PCNT_COUNT_INC, + // Set counter limit + .counter_h_lim = INT16_MAX, + .counter_l_lim = 0, + }; + + // Initialize PCNT unit + const int8_t unit = peripherals_pcnt_init(pcnt_config); + if (unit == -1) { + mp_raise_RuntimeError(translate("All PCNT units in use")); + } + + // set the GPIO back to high-impedance, as pcnt_unit_config sets it as pull-up + gpio_set_pull_mode(self->pin, GPIO_FLOATING); + + self->unit = (pcnt_unit_t)unit; + + // enable pcnt interrupt + pcnt_event_enable(self->unit, PCNT_EVT_H_LIM); + pcnt_isr_register(pcnt_overflow_handler, (void *)self, ESP_INTR_FLAG_IRAM, &self->handle); + pcnt_intr_enable(self->unit); +} + +static void init_timer(frequencyio_frequencyin_obj_t* self) { // Prepare configuration for the timer module - timer_config_t config = { + const timer_config_t config = { .alarm_en = true, .counter_en = false, .intr_type = TIMER_INTR_LEVEL, @@ -64,9 +101,9 @@ static void init_timer(frequencyio_frequencyin_obj_t* self, uint16_t capture_per // Initialize timer module timer_init(TIMER_GROUP_0, TIMER_0, &config); timer_set_counter_value(TIMER_GROUP_0, TIMER_0, 0); - timer_set_alarm_value(TIMER_GROUP_0, TIMER_0, capture_period * 1000000); + timer_set_alarm_value(TIMER_GROUP_0, TIMER_0, self->capture_period * 1000000); + timer_isr_register(TIMER_GROUP_0, TIMER_0, timer_interrupt_handler, (void *)self, ESP_INTR_FLAG_IRAM, &self->handle); timer_enable_intr(TIMER_GROUP_0, TIMER_0); - timer_isr_register(TIMER_GROUP_0, TIMER_0, frequencyin_interrupt_handler, (void *)self, ESP_INTR_FLAG_IRAM, &self->handle); // Start timer timer_start(TIMER_GROUP_0, TIMER_0); @@ -78,33 +115,15 @@ void common_hal_frequencyio_frequencyin_construct(frequencyio_frequencyin_obj_t* mp_raise_ValueError(translate("Invalid capture period. Valid range: 1 - 500")); } - // Prepare configuration for the PCNT unit - const pcnt_config_t pcnt_config = { - // Set PCNT input signal and control GPIOs - .pulse_gpio_num = pin->number, - .ctrl_gpio_num = PCNT_PIN_NOT_USED, - .channel = PCNT_CHANNEL_0, - // What to do on the positive / negative edge of pulse input? - .pos_mode = PCNT_COUNT_INC, // count both rising and falling edges - .neg_mode = PCNT_COUNT_INC, - }; - - // Initialize PCNT unit - const int8_t unit = peripherals_pcnt_init(pcnt_config); - if (unit == -1) { - mp_raise_RuntimeError(translate("All PCNT units in use")); - } - - // set the GPIO back to high-impedance, as pcnt_unit_config sets it as pull-up - gpio_set_pull_mode(pin->number, GPIO_FLOATING); - - // initialize timer - init_timer(self, capture_period); - self->pin = pin->number; - self->unit = (pcnt_unit_t)unit; + self->handle = NULL; + self->multiplier = 0; self->capture_period = capture_period; + // initialize pcnt and timer + init_pcnt(self); + init_timer(self); + claim_pin(pin); } @@ -118,15 +137,15 @@ void common_hal_frequencyio_frequencyin_deinit(frequencyio_frequencyin_obj_t* se } reset_pin_number(self->pin); peripherals_pcnt_deinit(&self->unit); + timer_deinit(TIMER_GROUP_0, TIMER_0); if (self->handle) { - timer_deinit(TIMER_GROUP_0, TIMER_0); esp_intr_free(self->handle); self->handle = NULL; } } uint32_t common_hal_frequencyio_frequencyin_get_item(frequencyio_frequencyin_obj_t* self) { - return self->frequency; + return (self->frequency + (self->multiplier * INT16_MAX)); } void common_hal_frequencyio_frequencyin_pause(frequencyio_frequencyin_obj_t* self) { diff --git a/ports/esp32s2/common-hal/frequencyio/FrequencyIn.h b/ports/esp32s2/common-hal/frequencyio/FrequencyIn.h index 01e617d13a..ce3bf8f2f9 100644 --- a/ports/esp32s2/common-hal/frequencyio/FrequencyIn.h +++ b/ports/esp32s2/common-hal/frequencyio/FrequencyIn.h @@ -36,7 +36,8 @@ typedef struct { pcnt_unit_t unit; intr_handle_t handle; uint8_t pin; - uint32_t frequency; + uint8_t multiplier; + uint16_t frequency; uint16_t capture_period; } frequencyio_frequencyin_obj_t; From 0686cde2263a50e2074f741417d169a1c1ea752e Mon Sep 17 00:00:00 2001 From: microDev <70126934+microDev1@users.noreply.github.com> Date: Tue, 17 Nov 2020 01:19:12 +0530 Subject: [PATCH 051/207] update internal nvm size --- ports/esp32s2/common-hal/nvm/ByteArray.c | 4 ++-- ports/esp32s2/mpconfigport.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/ports/esp32s2/common-hal/nvm/ByteArray.c b/ports/esp32s2/common-hal/nvm/ByteArray.c index 30051df1ef..d90f7fbdc2 100644 --- a/ports/esp32s2/common-hal/nvm/ByteArray.c +++ b/ports/esp32s2/common-hal/nvm/ByteArray.c @@ -56,7 +56,7 @@ static nvs_handle get_nvs_handle(void) { bool common_hal_nvm_bytearray_set_bytes(nvm_bytearray_obj_t *self, uint32_t start_index, uint8_t* values, uint32_t len) { char index[9]; - sprintf(index, "%i", start_index); + sprintf(index, "%i", start_index - CIRCUITPY_INTERNAL_NVM_START_ADDR); // start nvs nvs_handle handle = get_nvs_handle(); bool status = ((nvs_set_u8(handle, (const char *)index, *values) == ESP_OK) && (nvs_commit(handle) == ESP_OK)); @@ -69,7 +69,7 @@ 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) { char index[9]; - sprintf(index, "%i", start_index); + sprintf(index, "%i", start_index - CIRCUITPY_INTERNAL_NVM_START_ADDR); // start nvs nvs_handle handle = get_nvs_handle(); if (nvs_get_u8(handle, (const char *)index, values) != ESP_OK) { diff --git a/ports/esp32s2/mpconfigport.h b/ports/esp32s2/mpconfigport.h index 11ea5f6382..db7393d8ef 100644 --- a/ports/esp32s2/mpconfigport.h +++ b/ports/esp32s2/mpconfigport.h @@ -43,7 +43,7 @@ #define CIRCUITPY_INTERNAL_NVM_START_ADDR (0x9000) #ifndef CIRCUITPY_INTERNAL_NVM_SIZE -#define CIRCUITPY_INTERNAL_NVM_SIZE (20000) +#define CIRCUITPY_INTERNAL_NVM_SIZE (20 * 1024) #endif #endif // __INCLUDED_ESP32S2_MPCONFIGPORT_H From 9c4b6c34b8cfacdc86074df261a4eac0fc23b129 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Mon, 16 Nov 2020 16:03:29 -0600 Subject: [PATCH 052/207] see what happens if workflows move to ubuntu 20.04 --- .github/workflows/build.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index c83f37e6ed..bd0dea5cf8 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -14,7 +14,7 @@ on: jobs: test: - runs-on: ubuntu-18.04 + runs-on: ubuntu-20.04 steps: - name: Dump GitHub context env: @@ -165,7 +165,7 @@ jobs: build-arm: - runs-on: ubuntu-18.04 + runs-on: ubuntu-20.04 needs: test strategy: fail-fast: false @@ -368,7 +368,7 @@ jobs: if: github.event_name == 'push' || (github.event_name == 'release' && (github.event.action == 'published' || github.event.action == 'rerequested')) build-riscv: - runs-on: ubuntu-18.04 + runs-on: ubuntu-20.04 needs: test strategy: fail-fast: false From 3b27810a3ab6c15d0612b986e6f6086aecccdbcb Mon Sep 17 00:00:00 2001 From: Hosted Weblate Date: Tue, 17 Nov 2020 00:02:02 +0100 Subject: [PATCH 053/207] Update translation files Updated by "Update PO files to match POT (msgmerge)" hook in Weblate. Translation: CircuitPython/main Translate-URL: https://hosted.weblate.org/projects/circuitpython/main/ --- locale/ID.po | 15 +++++++++++++-- locale/cs.po | 15 +++++++++++++-- locale/de_DE.po | 15 +++++++++++++-- locale/el.po | 15 +++++++++++++-- locale/es.po | 15 +++++++++++++-- locale/fil.po | 15 +++++++++++++-- locale/fr.po | 15 +++++++++++++-- locale/hi.po | 15 +++++++++++++-- locale/it_IT.po | 15 +++++++++++++-- locale/ja.po | 15 +++++++++++++-- locale/ko.po | 15 +++++++++++++-- locale/nl.po | 15 +++++++++++++-- locale/pl.po | 15 +++++++++++++-- locale/pt_BR.po | 15 +++++++++++++-- locale/sv.po | 15 +++++++++++++-- locale/zh_Latn_pinyin.po | 15 +++++++++++++-- 16 files changed, 208 insertions(+), 32 deletions(-) diff --git a/locale/ID.po b/locale/ID.po index 90e416b3b9..d6672b1e40 100644 --- a/locale/ID.po +++ b/locale/ID.po @@ -5,7 +5,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-11-04 21:18+0530\n" +"POT-Creation-Date: 2020-11-10 15:30+0530\n" "PO-Revision-Date: 2020-10-10 23:51+0000\n" "Last-Translator: oon arfiandwi \n" "Language-Team: LANGUAGE \n" @@ -300,7 +300,8 @@ msgstr "" msgid "All I2C peripherals are in use" msgstr "Semua perangkat I2C sedang digunakan" -#: ports/esp32s2/peripherals/pcnt_handler.c +#: ports/esp32s2/common-hal/countio/Counter.c +#: ports/esp32s2/common-hal/rotaryio/IncrementalEncoder.c msgid "All PCNT units in use" msgstr "" @@ -1018,6 +1019,10 @@ msgstr "" msgid "Incorrect buffer size" msgstr "Ukuran penyangga salah" +#: ports/esp32s2/common-hal/watchdog/WatchDogTimer.c +msgid "Initialization failed due to lack of memory" +msgstr "" + #: ports/atmel-samd/common-hal/pulseio/PulseIn.c msgid "Input taking too long" msgstr "" @@ -3254,6 +3259,7 @@ msgstr "" msgid "pow() with 3 arguments requires integers" msgstr "" +#: ports/esp32s2/boards/adafruit_magtag_2.9_grayscale/mpconfigboard.h #: ports/esp32s2/boards/adafruit_metro_esp32s2/mpconfigboard.h #: ports/esp32s2/boards/electroniccats_bastwifi/mpconfigboard.h #: ports/esp32s2/boards/espressif_kaluga_1/mpconfigboard.h @@ -3469,6 +3475,7 @@ msgstr "" msgid "time.struct_time() takes a 9-sequence" msgstr "" +#: ports/esp32s2/common-hal/watchdog/WatchDogTimer.c #: ports/nrf/common-hal/watchdog/WatchDogTimer.c msgid "timeout duration exceeded the maximum supported value" msgstr "" @@ -3653,6 +3660,10 @@ msgstr "" msgid "vectors must have same lengths" msgstr "" +#: ports/esp32s2/common-hal/watchdog/WatchDogTimer.c +msgid "watchdog not initialized" +msgstr "" + #: shared-bindings/watchdog/WatchDogTimer.c msgid "watchdog timeout must be greater than 0" msgstr "" diff --git a/locale/cs.po b/locale/cs.po index f02d31e4dd..bde3a20b87 100644 --- a/locale/cs.po +++ b/locale/cs.po @@ -5,7 +5,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-11-04 21:18+0530\n" +"POT-Creation-Date: 2020-11-10 15:30+0530\n" "PO-Revision-Date: 2020-05-24 03:22+0000\n" "Last-Translator: dronecz \n" "Language-Team: LANGUAGE \n" @@ -300,7 +300,8 @@ msgstr "" msgid "All I2C peripherals are in use" msgstr "" -#: ports/esp32s2/peripherals/pcnt_handler.c +#: ports/esp32s2/common-hal/countio/Counter.c +#: ports/esp32s2/common-hal/rotaryio/IncrementalEncoder.c msgid "All PCNT units in use" msgstr "" @@ -1001,6 +1002,10 @@ msgstr "" msgid "Incorrect buffer size" msgstr "" +#: ports/esp32s2/common-hal/watchdog/WatchDogTimer.c +msgid "Initialization failed due to lack of memory" +msgstr "" + #: ports/atmel-samd/common-hal/pulseio/PulseIn.c msgid "Input taking too long" msgstr "" @@ -3210,6 +3215,7 @@ msgstr "" msgid "pow() with 3 arguments requires integers" msgstr "" +#: ports/esp32s2/boards/adafruit_magtag_2.9_grayscale/mpconfigboard.h #: ports/esp32s2/boards/adafruit_metro_esp32s2/mpconfigboard.h #: ports/esp32s2/boards/electroniccats_bastwifi/mpconfigboard.h #: ports/esp32s2/boards/espressif_kaluga_1/mpconfigboard.h @@ -3425,6 +3431,7 @@ msgstr "" msgid "time.struct_time() takes a 9-sequence" msgstr "" +#: ports/esp32s2/common-hal/watchdog/WatchDogTimer.c #: ports/nrf/common-hal/watchdog/WatchDogTimer.c msgid "timeout duration exceeded the maximum supported value" msgstr "" @@ -3608,6 +3615,10 @@ msgstr "" msgid "vectors must have same lengths" msgstr "" +#: ports/esp32s2/common-hal/watchdog/WatchDogTimer.c +msgid "watchdog not initialized" +msgstr "" + #: shared-bindings/watchdog/WatchDogTimer.c msgid "watchdog timeout must be greater than 0" msgstr "" diff --git a/locale/de_DE.po b/locale/de_DE.po index c2cb265508..dabc486595 100644 --- a/locale/de_DE.po +++ b/locale/de_DE.po @@ -5,7 +5,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-11-04 21:18+0530\n" +"POT-Creation-Date: 2020-11-10 15:30+0530\n" "PO-Revision-Date: 2020-06-16 18:24+0000\n" "Last-Translator: Andreas Buchen \n" "Language: de_DE\n" @@ -299,7 +299,8 @@ msgstr "" msgid "All I2C peripherals are in use" msgstr "Alle I2C-Peripheriegeräte sind in Benutzung" -#: ports/esp32s2/peripherals/pcnt_handler.c +#: ports/esp32s2/common-hal/countio/Counter.c +#: ports/esp32s2/common-hal/rotaryio/IncrementalEncoder.c msgid "All PCNT units in use" msgstr "" @@ -1018,6 +1019,10 @@ msgstr "" msgid "Incorrect buffer size" msgstr "Inkorrekte Puffergröße" +#: ports/esp32s2/common-hal/watchdog/WatchDogTimer.c +msgid "Initialization failed due to lack of memory" +msgstr "" + #: ports/atmel-samd/common-hal/pulseio/PulseIn.c msgid "Input taking too long" msgstr "" @@ -3293,6 +3298,7 @@ msgstr "pow() drittes Argument darf nicht 0 sein" msgid "pow() with 3 arguments requires integers" msgstr "pow () mit 3 Argumenten erfordert Integer" +#: ports/esp32s2/boards/adafruit_magtag_2.9_grayscale/mpconfigboard.h #: ports/esp32s2/boards/adafruit_metro_esp32s2/mpconfigboard.h #: ports/esp32s2/boards/electroniccats_bastwifi/mpconfigboard.h #: ports/esp32s2/boards/espressif_kaluga_1/mpconfigboard.h @@ -3511,6 +3517,7 @@ msgstr "threshold muss im Intervall 0-65536 liegen" msgid "time.struct_time() takes a 9-sequence" msgstr "time.struct_time() nimmt eine 9-Sequenz an" +#: ports/esp32s2/common-hal/watchdog/WatchDogTimer.c #: ports/nrf/common-hal/watchdog/WatchDogTimer.c msgid "timeout duration exceeded the maximum supported value" msgstr "Das Zeitlimit hat den maximal zulässigen Wert überschritten" @@ -3698,6 +3705,10 @@ msgstr "value_count muss größer als 0 sein" msgid "vectors must have same lengths" msgstr "Vektoren müssen die selbe Länge haben" +#: ports/esp32s2/common-hal/watchdog/WatchDogTimer.c +msgid "watchdog not initialized" +msgstr "" + #: shared-bindings/watchdog/WatchDogTimer.c msgid "watchdog timeout must be greater than 0" msgstr "" diff --git a/locale/el.po b/locale/el.po index 4d7bff1930..0d35c20ceb 100644 --- a/locale/el.po +++ b/locale/el.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-11-04 21:18+0530\n" +"POT-Creation-Date: 2020-11-10 15:30+0530\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: Automatically generated\n" "Language-Team: none\n" @@ -295,7 +295,8 @@ msgstr "" msgid "All I2C peripherals are in use" msgstr "" -#: ports/esp32s2/peripherals/pcnt_handler.c +#: ports/esp32s2/common-hal/countio/Counter.c +#: ports/esp32s2/common-hal/rotaryio/IncrementalEncoder.c msgid "All PCNT units in use" msgstr "" @@ -996,6 +997,10 @@ msgstr "" msgid "Incorrect buffer size" msgstr "" +#: ports/esp32s2/common-hal/watchdog/WatchDogTimer.c +msgid "Initialization failed due to lack of memory" +msgstr "" + #: ports/atmel-samd/common-hal/pulseio/PulseIn.c msgid "Input taking too long" msgstr "" @@ -3205,6 +3210,7 @@ msgstr "" msgid "pow() with 3 arguments requires integers" msgstr "" +#: ports/esp32s2/boards/adafruit_magtag_2.9_grayscale/mpconfigboard.h #: ports/esp32s2/boards/adafruit_metro_esp32s2/mpconfigboard.h #: ports/esp32s2/boards/electroniccats_bastwifi/mpconfigboard.h #: ports/esp32s2/boards/espressif_kaluga_1/mpconfigboard.h @@ -3420,6 +3426,7 @@ msgstr "" msgid "time.struct_time() takes a 9-sequence" msgstr "" +#: ports/esp32s2/common-hal/watchdog/WatchDogTimer.c #: ports/nrf/common-hal/watchdog/WatchDogTimer.c msgid "timeout duration exceeded the maximum supported value" msgstr "" @@ -3603,6 +3610,10 @@ msgstr "" msgid "vectors must have same lengths" msgstr "" +#: ports/esp32s2/common-hal/watchdog/WatchDogTimer.c +msgid "watchdog not initialized" +msgstr "" + #: shared-bindings/watchdog/WatchDogTimer.c msgid "watchdog timeout must be greater than 0" msgstr "" diff --git a/locale/es.po b/locale/es.po index c5e2ad75f0..bdb4b68a5d 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-11-04 21:18+0530\n" +"POT-Creation-Date: 2020-11-10 15:30+0530\n" "PO-Revision-Date: 2020-11-15 16:28+0000\n" "Last-Translator: RubenD \n" "Language-Team: \n" @@ -303,7 +303,8 @@ msgstr "Todos los periféricos CAN están en uso" msgid "All I2C peripherals are in use" msgstr "Todos los periféricos I2C están siendo usados" -#: ports/esp32s2/peripherals/pcnt_handler.c +#: ports/esp32s2/common-hal/countio/Counter.c +#: ports/esp32s2/common-hal/rotaryio/IncrementalEncoder.c msgid "All PCNT units in use" msgstr "Todas las unidades PCNT en uso" @@ -1019,6 +1020,10 @@ msgstr "" msgid "Incorrect buffer size" msgstr "Tamaño incorrecto del buffer" +#: ports/esp32s2/common-hal/watchdog/WatchDogTimer.c +msgid "Initialization failed due to lack of memory" +msgstr "" + #: ports/atmel-samd/common-hal/pulseio/PulseIn.c msgid "Input taking too long" msgstr "La entrada está durando mucho tiempo" @@ -3281,6 +3286,7 @@ msgstr "el 3er argumento de pow() no puede ser 0" msgid "pow() with 3 arguments requires integers" msgstr "pow() con 3 argumentos requiere enteros" +#: ports/esp32s2/boards/adafruit_magtag_2.9_grayscale/mpconfigboard.h #: ports/esp32s2/boards/adafruit_metro_esp32s2/mpconfigboard.h #: ports/esp32s2/boards/electroniccats_bastwifi/mpconfigboard.h #: ports/esp32s2/boards/espressif_kaluga_1/mpconfigboard.h @@ -3498,6 +3504,7 @@ 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" +#: ports/esp32s2/common-hal/watchdog/WatchDogTimer.c #: ports/nrf/common-hal/watchdog/WatchDogTimer.c msgid "timeout duration exceeded the maximum supported value" msgstr "" @@ -3682,6 +3689,10 @@ msgstr "value_count debe ser > 0" msgid "vectors must have same lengths" msgstr "los vectores deben tener el mismo tamaño" +#: ports/esp32s2/common-hal/watchdog/WatchDogTimer.c +msgid "watchdog not initialized" +msgstr "" + #: shared-bindings/watchdog/WatchDogTimer.c msgid "watchdog timeout must be greater than 0" msgstr "el tiempo de espera del perro guardián debe ser mayor a 0" diff --git a/locale/fil.po b/locale/fil.po index 93f41a88eb..c74e13c6c8 100644 --- a/locale/fil.po +++ b/locale/fil.po @@ -5,7 +5,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-11-04 21:18+0530\n" +"POT-Creation-Date: 2020-11-10 15:30+0530\n" "PO-Revision-Date: 2018-12-20 22:15-0800\n" "Last-Translator: Timothy \n" "Language-Team: fil\n" @@ -297,7 +297,8 @@ msgstr "" msgid "All I2C peripherals are in use" msgstr "Lahat ng I2C peripherals ginagamit" -#: ports/esp32s2/peripherals/pcnt_handler.c +#: ports/esp32s2/common-hal/countio/Counter.c +#: ports/esp32s2/common-hal/rotaryio/IncrementalEncoder.c msgid "All PCNT units in use" msgstr "" @@ -1011,6 +1012,10 @@ msgstr "" msgid "Incorrect buffer size" msgstr "" +#: ports/esp32s2/common-hal/watchdog/WatchDogTimer.c +msgid "Initialization failed due to lack of memory" +msgstr "" + #: ports/atmel-samd/common-hal/pulseio/PulseIn.c msgid "Input taking too long" msgstr "" @@ -3256,6 +3261,7 @@ msgstr "pow() 3rd argument ay hindi maaring 0" msgid "pow() with 3 arguments requires integers" msgstr "pow() na may 3 argumento kailangan ng integers" +#: ports/esp32s2/boards/adafruit_magtag_2.9_grayscale/mpconfigboard.h #: ports/esp32s2/boards/adafruit_metro_esp32s2/mpconfigboard.h #: ports/esp32s2/boards/electroniccats_bastwifi/mpconfigboard.h #: ports/esp32s2/boards/espressif_kaluga_1/mpconfigboard.h @@ -3474,6 +3480,7 @@ 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" +#: ports/esp32s2/common-hal/watchdog/WatchDogTimer.c #: ports/nrf/common-hal/watchdog/WatchDogTimer.c msgid "timeout duration exceeded the maximum supported value" msgstr "" @@ -3658,6 +3665,10 @@ msgstr "" msgid "vectors must have same lengths" msgstr "" +#: ports/esp32s2/common-hal/watchdog/WatchDogTimer.c +msgid "watchdog not initialized" +msgstr "" + #: shared-bindings/watchdog/WatchDogTimer.c msgid "watchdog timeout must be greater than 0" msgstr "" diff --git a/locale/fr.po b/locale/fr.po index 5d4ca75d5c..a15bbb8d50 100644 --- a/locale/fr.po +++ b/locale/fr.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: 0.1\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-11-04 21:18+0530\n" +"POT-Creation-Date: 2020-11-10 15:30+0530\n" "PO-Revision-Date: 2020-11-15 16:28+0000\n" "Last-Translator: Antonin ENFRUN \n" "Language: fr\n" @@ -304,7 +304,8 @@ msgstr "Tous les périphériques CAN sont utilisés" msgid "All I2C peripherals are in use" msgstr "Tous les périphériques I2C sont utilisés" -#: ports/esp32s2/peripherals/pcnt_handler.c +#: ports/esp32s2/common-hal/countio/Counter.c +#: ports/esp32s2/common-hal/rotaryio/IncrementalEncoder.c msgid "All PCNT units in use" msgstr "Toutes les unités PCNT sont utilisées" @@ -1024,6 +1025,10 @@ msgstr "" msgid "Incorrect buffer size" msgstr "Taille de tampon incorrecte" +#: ports/esp32s2/common-hal/watchdog/WatchDogTimer.c +msgid "Initialization failed due to lack of memory" +msgstr "" + #: ports/atmel-samd/common-hal/pulseio/PulseIn.c msgid "Input taking too long" msgstr "L'entrée prend trop de temps" @@ -3305,6 +3310,7 @@ msgstr "le 3e argument de pow() ne peut être 0" msgid "pow() with 3 arguments requires integers" msgstr "pow() avec 3 arguments nécessite des entiers" +#: ports/esp32s2/boards/adafruit_magtag_2.9_grayscale/mpconfigboard.h #: ports/esp32s2/boards/adafruit_metro_esp32s2/mpconfigboard.h #: ports/esp32s2/boards/electroniccats_bastwifi/mpconfigboard.h #: ports/esp32s2/boards/espressif_kaluga_1/mpconfigboard.h @@ -3523,6 +3529,7 @@ 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" +#: ports/esp32s2/common-hal/watchdog/WatchDogTimer.c #: ports/nrf/common-hal/watchdog/WatchDogTimer.c msgid "timeout duration exceeded the maximum supported value" msgstr "le délai d'expiration a dépassé la valeur maximale prise en charge" @@ -3706,6 +3713,10 @@ msgstr "'value_count' doit être > 0" msgid "vectors must have same lengths" msgstr "les vecteurs doivent avoir la même longueur" +#: ports/esp32s2/common-hal/watchdog/WatchDogTimer.c +msgid "watchdog not initialized" +msgstr "" + #: shared-bindings/watchdog/WatchDogTimer.c msgid "watchdog timeout must be greater than 0" msgstr "watchdog timeout doit être supérieur à 0" diff --git a/locale/hi.po b/locale/hi.po index aea2b3f0c4..6c49e1f01f 100644 --- a/locale/hi.po +++ b/locale/hi.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-11-04 21:18+0530\n" +"POT-Creation-Date: 2020-11-10 15:30+0530\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: Automatically generated\n" "Language-Team: none\n" @@ -295,7 +295,8 @@ msgstr "" msgid "All I2C peripherals are in use" msgstr "" -#: ports/esp32s2/peripherals/pcnt_handler.c +#: ports/esp32s2/common-hal/countio/Counter.c +#: ports/esp32s2/common-hal/rotaryio/IncrementalEncoder.c msgid "All PCNT units in use" msgstr "" @@ -996,6 +997,10 @@ msgstr "" msgid "Incorrect buffer size" msgstr "" +#: ports/esp32s2/common-hal/watchdog/WatchDogTimer.c +msgid "Initialization failed due to lack of memory" +msgstr "" + #: ports/atmel-samd/common-hal/pulseio/PulseIn.c msgid "Input taking too long" msgstr "" @@ -3205,6 +3210,7 @@ msgstr "" msgid "pow() with 3 arguments requires integers" msgstr "" +#: ports/esp32s2/boards/adafruit_magtag_2.9_grayscale/mpconfigboard.h #: ports/esp32s2/boards/adafruit_metro_esp32s2/mpconfigboard.h #: ports/esp32s2/boards/electroniccats_bastwifi/mpconfigboard.h #: ports/esp32s2/boards/espressif_kaluga_1/mpconfigboard.h @@ -3420,6 +3426,7 @@ msgstr "" msgid "time.struct_time() takes a 9-sequence" msgstr "" +#: ports/esp32s2/common-hal/watchdog/WatchDogTimer.c #: ports/nrf/common-hal/watchdog/WatchDogTimer.c msgid "timeout duration exceeded the maximum supported value" msgstr "" @@ -3603,6 +3610,10 @@ msgstr "" msgid "vectors must have same lengths" msgstr "" +#: ports/esp32s2/common-hal/watchdog/WatchDogTimer.c +msgid "watchdog not initialized" +msgstr "" + #: shared-bindings/watchdog/WatchDogTimer.c msgid "watchdog timeout must be greater than 0" msgstr "" diff --git a/locale/it_IT.po b/locale/it_IT.po index 603cf9fd08..fc0f016752 100644 --- a/locale/it_IT.po +++ b/locale/it_IT.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-11-04 21:18+0530\n" +"POT-Creation-Date: 2020-11-10 15:30+0530\n" "PO-Revision-Date: 2018-10-02 16:27+0200\n" "Last-Translator: Enrico Paganin \n" "Language-Team: \n" @@ -296,7 +296,8 @@ msgstr "" msgid "All I2C peripherals are in use" msgstr "Tutte le periferiche I2C sono in uso" -#: ports/esp32s2/peripherals/pcnt_handler.c +#: ports/esp32s2/common-hal/countio/Counter.c +#: ports/esp32s2/common-hal/rotaryio/IncrementalEncoder.c msgid "All PCNT units in use" msgstr "" @@ -1011,6 +1012,10 @@ msgstr "" msgid "Incorrect buffer size" msgstr "" +#: ports/esp32s2/common-hal/watchdog/WatchDogTimer.c +msgid "Initialization failed due to lack of memory" +msgstr "" + #: ports/atmel-samd/common-hal/pulseio/PulseIn.c msgid "Input taking too long" msgstr "" @@ -3263,6 +3268,7 @@ msgstr "il terzo argomento di pow() non può essere 0" msgid "pow() with 3 arguments requires integers" msgstr "pow() con 3 argomenti richiede interi" +#: ports/esp32s2/boards/adafruit_magtag_2.9_grayscale/mpconfigboard.h #: ports/esp32s2/boards/adafruit_metro_esp32s2/mpconfigboard.h #: ports/esp32s2/boards/electroniccats_bastwifi/mpconfigboard.h #: ports/esp32s2/boards/espressif_kaluga_1/mpconfigboard.h @@ -3481,6 +3487,7 @@ msgstr "la soglia deve essere nell'intervallo 0-65536" msgid "time.struct_time() takes a 9-sequence" msgstr "" +#: ports/esp32s2/common-hal/watchdog/WatchDogTimer.c #: ports/nrf/common-hal/watchdog/WatchDogTimer.c msgid "timeout duration exceeded the maximum supported value" msgstr "" @@ -3665,6 +3672,10 @@ msgstr "" msgid "vectors must have same lengths" msgstr "" +#: ports/esp32s2/common-hal/watchdog/WatchDogTimer.c +msgid "watchdog not initialized" +msgstr "" + #: shared-bindings/watchdog/WatchDogTimer.c msgid "watchdog timeout must be greater than 0" msgstr "" diff --git a/locale/ja.po b/locale/ja.po index 80486dc210..f3dfc6c900 100644 --- a/locale/ja.po +++ b/locale/ja.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-11-04 21:18+0530\n" +"POT-Creation-Date: 2020-11-10 15:30+0530\n" "PO-Revision-Date: 2020-11-12 22:51+0000\n" "Last-Translator: sporeball \n" "Language-Team: none\n" @@ -302,7 +302,8 @@ msgstr "全てのCAN周辺機器が使用中" msgid "All I2C peripherals are in use" msgstr "全てのI2C周辺機器が使用中" -#: ports/esp32s2/peripherals/pcnt_handler.c +#: ports/esp32s2/common-hal/countio/Counter.c +#: ports/esp32s2/common-hal/rotaryio/IncrementalEncoder.c msgid "All PCNT units in use" msgstr "" @@ -1011,6 +1012,10 @@ msgstr "" msgid "Incorrect buffer size" msgstr "バッファサイズが正しくありません" +#: ports/esp32s2/common-hal/watchdog/WatchDogTimer.c +msgid "Initialization failed due to lack of memory" +msgstr "" + #: ports/atmel-samd/common-hal/pulseio/PulseIn.c msgid "Input taking too long" msgstr "" @@ -3237,6 +3242,7 @@ msgstr "pow()の3つ目の引数は0にできません" msgid "pow() with 3 arguments requires integers" msgstr "pow()の第3引数には整数が必要" +#: ports/esp32s2/boards/adafruit_magtag_2.9_grayscale/mpconfigboard.h #: ports/esp32s2/boards/adafruit_metro_esp32s2/mpconfigboard.h #: ports/esp32s2/boards/electroniccats_bastwifi/mpconfigboard.h #: ports/esp32s2/boards/espressif_kaluga_1/mpconfigboard.h @@ -3453,6 +3459,7 @@ msgstr "threshouldは0から65536まで" msgid "time.struct_time() takes a 9-sequence" msgstr "time.struct_time()は9要素のシーケンスを受け取ります" +#: ports/esp32s2/common-hal/watchdog/WatchDogTimer.c #: ports/nrf/common-hal/watchdog/WatchDogTimer.c msgid "timeout duration exceeded the maximum supported value" msgstr "タイムアウト長は対応する最大値を超えています" @@ -3636,6 +3643,10 @@ msgstr "value_countは0より大きくなければなりません" msgid "vectors must have same lengths" msgstr "" +#: ports/esp32s2/common-hal/watchdog/WatchDogTimer.c +msgid "watchdog not initialized" +msgstr "" + #: shared-bindings/watchdog/WatchDogTimer.c msgid "watchdog timeout must be greater than 0" msgstr "watchdogのtimeoutは0以上でなければなりません" diff --git a/locale/ko.po b/locale/ko.po index c9215fb85e..bfa49ab70c 100644 --- a/locale/ko.po +++ b/locale/ko.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-11-04 21:18+0530\n" +"POT-Creation-Date: 2020-11-10 15:30+0530\n" "PO-Revision-Date: 2020-10-05 12:12+0000\n" "Last-Translator: Michal Čihař \n" "Language-Team: LANGUAGE \n" @@ -298,7 +298,8 @@ msgstr "" msgid "All I2C peripherals are in use" msgstr "사용중인 모든 I2C주변 기기" -#: ports/esp32s2/peripherals/pcnt_handler.c +#: ports/esp32s2/common-hal/countio/Counter.c +#: ports/esp32s2/common-hal/rotaryio/IncrementalEncoder.c msgid "All PCNT units in use" msgstr "" @@ -1001,6 +1002,10 @@ msgstr "" msgid "Incorrect buffer size" msgstr "" +#: ports/esp32s2/common-hal/watchdog/WatchDogTimer.c +msgid "Initialization failed due to lack of memory" +msgstr "" + #: ports/atmel-samd/common-hal/pulseio/PulseIn.c msgid "Input taking too long" msgstr "" @@ -3211,6 +3216,7 @@ msgstr "" msgid "pow() with 3 arguments requires integers" msgstr "" +#: ports/esp32s2/boards/adafruit_magtag_2.9_grayscale/mpconfigboard.h #: ports/esp32s2/boards/adafruit_metro_esp32s2/mpconfigboard.h #: ports/esp32s2/boards/electroniccats_bastwifi/mpconfigboard.h #: ports/esp32s2/boards/espressif_kaluga_1/mpconfigboard.h @@ -3426,6 +3432,7 @@ msgstr "" msgid "time.struct_time() takes a 9-sequence" msgstr "" +#: ports/esp32s2/common-hal/watchdog/WatchDogTimer.c #: ports/nrf/common-hal/watchdog/WatchDogTimer.c msgid "timeout duration exceeded the maximum supported value" msgstr "" @@ -3609,6 +3616,10 @@ msgstr "" msgid "vectors must have same lengths" msgstr "" +#: ports/esp32s2/common-hal/watchdog/WatchDogTimer.c +msgid "watchdog not initialized" +msgstr "" + #: shared-bindings/watchdog/WatchDogTimer.c msgid "watchdog timeout must be greater than 0" msgstr "" diff --git a/locale/nl.po b/locale/nl.po index cfe2193bba..7625cdb26b 100644 --- a/locale/nl.po +++ b/locale/nl.po @@ -5,7 +5,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-11-04 21:18+0530\n" +"POT-Creation-Date: 2020-11-10 15:30+0530\n" "PO-Revision-Date: 2020-10-27 16:47+0000\n" "Last-Translator: Jelle Jager \n" "Language-Team: none\n" @@ -300,7 +300,8 @@ msgstr "" msgid "All I2C peripherals are in use" msgstr "Alle I2C peripherals zijn in gebruik" -#: ports/esp32s2/peripherals/pcnt_handler.c +#: ports/esp32s2/common-hal/countio/Counter.c +#: ports/esp32s2/common-hal/rotaryio/IncrementalEncoder.c msgid "All PCNT units in use" msgstr "" @@ -1013,6 +1014,10 @@ msgstr "" msgid "Incorrect buffer size" msgstr "Incorrecte buffer grootte" +#: ports/esp32s2/common-hal/watchdog/WatchDogTimer.c +msgid "Initialization failed due to lack of memory" +msgstr "" + #: ports/atmel-samd/common-hal/pulseio/PulseIn.c msgid "Input taking too long" msgstr "Invoer duurt te lang" @@ -3270,6 +3275,7 @@ msgstr "derde argument van pow() mag geen 0 zijn" msgid "pow() with 3 arguments requires integers" msgstr "pow() met 3 argumenten vereist integers" +#: ports/esp32s2/boards/adafruit_magtag_2.9_grayscale/mpconfigboard.h #: ports/esp32s2/boards/adafruit_metro_esp32s2/mpconfigboard.h #: ports/esp32s2/boards/electroniccats_bastwifi/mpconfigboard.h #: ports/esp32s2/boards/espressif_kaluga_1/mpconfigboard.h @@ -3487,6 +3493,7 @@ msgstr "drempelwaarde moet in het bereik 0-65536 liggen" msgid "time.struct_time() takes a 9-sequence" msgstr "time.struct_time() accepteert een 9-rij" +#: ports/esp32s2/common-hal/watchdog/WatchDogTimer.c #: ports/nrf/common-hal/watchdog/WatchDogTimer.c msgid "timeout duration exceeded the maximum supported value" msgstr "time-outduur is groter dan de ondersteunde maximale waarde" @@ -3670,6 +3677,10 @@ msgstr "value_count moet groter dan 0 zijn" msgid "vectors must have same lengths" msgstr "vectoren moeten van gelijke lengte zijn" +#: ports/esp32s2/common-hal/watchdog/WatchDogTimer.c +msgid "watchdog not initialized" +msgstr "" + #: shared-bindings/watchdog/WatchDogTimer.c msgid "watchdog timeout must be greater than 0" msgstr "watchdog time-out moet groter zijn dan 0" diff --git a/locale/pl.po b/locale/pl.po index 623acd4c56..f04887e682 100644 --- a/locale/pl.po +++ b/locale/pl.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-11-04 21:18+0530\n" +"POT-Creation-Date: 2020-11-10 15:30+0530\n" "PO-Revision-Date: 2020-11-11 19:13+0000\n" "Last-Translator: Maciej Stankiewicz \n" "Language-Team: pl\n" @@ -302,7 +302,8 @@ msgstr "" msgid "All I2C peripherals are in use" msgstr "Wszystkie peryferia I2C w użyciu" -#: ports/esp32s2/peripherals/pcnt_handler.c +#: ports/esp32s2/common-hal/countio/Counter.c +#: ports/esp32s2/common-hal/rotaryio/IncrementalEncoder.c msgid "All PCNT units in use" msgstr "" @@ -1011,6 +1012,10 @@ msgstr "" msgid "Incorrect buffer size" msgstr "Niewłaściwa wielkość bufora" +#: ports/esp32s2/common-hal/watchdog/WatchDogTimer.c +msgid "Initialization failed due to lack of memory" +msgstr "" + #: ports/atmel-samd/common-hal/pulseio/PulseIn.c msgid "Input taking too long" msgstr "" @@ -3229,6 +3234,7 @@ msgstr "trzeci argument pow() nie może być 0" msgid "pow() with 3 arguments requires integers" msgstr "trzyargumentowe pow() wymaga liczb całkowitych" +#: ports/esp32s2/boards/adafruit_magtag_2.9_grayscale/mpconfigboard.h #: ports/esp32s2/boards/adafruit_metro_esp32s2/mpconfigboard.h #: ports/esp32s2/boards/electroniccats_bastwifi/mpconfigboard.h #: ports/esp32s2/boards/espressif_kaluga_1/mpconfigboard.h @@ -3445,6 +3451,7 @@ msgstr "threshold musi być w zakresie 0-65536" msgid "time.struct_time() takes a 9-sequence" msgstr "time.struct_time() wymaga 9-elementowej sekwencji" +#: ports/esp32s2/common-hal/watchdog/WatchDogTimer.c #: ports/nrf/common-hal/watchdog/WatchDogTimer.c msgid "timeout duration exceeded the maximum supported value" msgstr "" @@ -3628,6 +3635,10 @@ msgstr "value_count musi być > 0" msgid "vectors must have same lengths" msgstr "wektory muszą mieć identyczną długość" +#: ports/esp32s2/common-hal/watchdog/WatchDogTimer.c +msgid "watchdog not initialized" +msgstr "" + #: shared-bindings/watchdog/WatchDogTimer.c msgid "watchdog timeout must be greater than 0" msgstr "" diff --git a/locale/pt_BR.po b/locale/pt_BR.po index 67b3dc8a7d..4918689795 100644 --- a/locale/pt_BR.po +++ b/locale/pt_BR.po @@ -5,7 +5,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-11-04 21:18+0530\n" +"POT-Creation-Date: 2020-11-10 15:30+0530\n" "PO-Revision-Date: 2020-11-08 10:26+0000\n" "Last-Translator: Wellington Terumi Uemura \n" "Language-Team: \n" @@ -304,7 +304,8 @@ msgstr "Todos os periféricos CAN estão em uso" msgid "All I2C peripherals are in use" msgstr "Todos os periféricos I2C estão em uso" -#: ports/esp32s2/peripherals/pcnt_handler.c +#: ports/esp32s2/common-hal/countio/Counter.c +#: ports/esp32s2/common-hal/rotaryio/IncrementalEncoder.c msgid "All PCNT units in use" msgstr "Todas as unidades PCNT estão em uso" @@ -1022,6 +1023,10 @@ msgstr "" msgid "Incorrect buffer size" msgstr "O tamanho do buffer está incorreto" +#: ports/esp32s2/common-hal/watchdog/WatchDogTimer.c +msgid "Initialization failed due to lack of memory" +msgstr "" + #: ports/atmel-samd/common-hal/pulseio/PulseIn.c msgid "Input taking too long" msgstr "A entrada está demorando demais" @@ -3296,6 +3301,7 @@ msgstr "O terceiro argumento pow() não pode ser 0" msgid "pow() with 3 arguments requires integers" msgstr "o pow() com 3 argumentos requer números inteiros" +#: ports/esp32s2/boards/adafruit_magtag_2.9_grayscale/mpconfigboard.h #: ports/esp32s2/boards/adafruit_metro_esp32s2/mpconfigboard.h #: ports/esp32s2/boards/electroniccats_bastwifi/mpconfigboard.h #: ports/esp32s2/boards/espressif_kaluga_1/mpconfigboard.h @@ -3513,6 +3519,7 @@ msgstr "Limite deve estar no alcance de 0-65536" msgid "time.struct_time() takes a 9-sequence" msgstr "time.struct_time() leva uma sequência com 9" +#: ports/esp32s2/common-hal/watchdog/WatchDogTimer.c #: ports/nrf/common-hal/watchdog/WatchDogTimer.c msgid "timeout duration exceeded the maximum supported value" msgstr "a duração do tempo limite excedeu o valor máximo suportado" @@ -3696,6 +3703,10 @@ msgstr "o value_count deve ser > 0" msgid "vectors must have same lengths" msgstr "os vetores devem ter os mesmos comprimentos" +#: ports/esp32s2/common-hal/watchdog/WatchDogTimer.c +msgid "watchdog not initialized" +msgstr "" + #: shared-bindings/watchdog/WatchDogTimer.c msgid "watchdog timeout must be greater than 0" msgstr "o tempo limite do watchdog deve ser maior que 0" diff --git a/locale/sv.po b/locale/sv.po index 1a603e4961..55e6368ae5 100644 --- a/locale/sv.po +++ b/locale/sv.po @@ -5,7 +5,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-11-04 21:18+0530\n" +"POT-Creation-Date: 2020-11-10 15:30+0530\n" "PO-Revision-Date: 2020-11-15 16:28+0000\n" "Last-Translator: Jonny Bergdahl \n" "Language-Team: LANGUAGE \n" @@ -300,7 +300,8 @@ msgstr "All I2C-kringutrustning används" msgid "All I2C peripherals are in use" msgstr "All I2C-kringutrustning används" -#: ports/esp32s2/peripherals/pcnt_handler.c +#: ports/esp32s2/common-hal/countio/Counter.c +#: ports/esp32s2/common-hal/rotaryio/IncrementalEncoder.c msgid "All PCNT units in use" msgstr "Alla PCNT-enheter används" @@ -1011,6 +1012,10 @@ msgstr "" msgid "Incorrect buffer size" msgstr "Fel buffertstorlek" +#: ports/esp32s2/common-hal/watchdog/WatchDogTimer.c +msgid "Initialization failed due to lack of memory" +msgstr "" + #: ports/atmel-samd/common-hal/pulseio/PulseIn.c msgid "Input taking too long" msgstr "Indata tar för lång tid" @@ -3263,6 +3268,7 @@ msgstr "pow() 3: e argument kan inte vara 0" msgid "pow() with 3 arguments requires integers" msgstr "pow() med 3 argument kräver heltal" +#: ports/esp32s2/boards/adafruit_magtag_2.9_grayscale/mpconfigboard.h #: ports/esp32s2/boards/adafruit_metro_esp32s2/mpconfigboard.h #: ports/esp32s2/boards/electroniccats_bastwifi/mpconfigboard.h #: ports/esp32s2/boards/espressif_kaluga_1/mpconfigboard.h @@ -3480,6 +3486,7 @@ msgstr "tröskelvärdet måste ligga i intervallet 0-65536" msgid "time.struct_time() takes a 9-sequence" msgstr "time.struct_time() kräver en 9-sekvens" +#: ports/esp32s2/common-hal/watchdog/WatchDogTimer.c #: ports/nrf/common-hal/watchdog/WatchDogTimer.c msgid "timeout duration exceeded the maximum supported value" msgstr "timeout-längd överskred det maximala värde som stöds" @@ -3663,6 +3670,10 @@ msgstr "value_count måste vara > 0" msgid "vectors must have same lengths" msgstr "vektorer måste ha samma längd" +#: ports/esp32s2/common-hal/watchdog/WatchDogTimer.c +msgid "watchdog not initialized" +msgstr "" + #: shared-bindings/watchdog/WatchDogTimer.c msgid "watchdog timeout must be greater than 0" msgstr "watchdog timeout måste vara större än 0" diff --git a/locale/zh_Latn_pinyin.po b/locale/zh_Latn_pinyin.po index 2731ec4f5e..dd44aab939 100644 --- a/locale/zh_Latn_pinyin.po +++ b/locale/zh_Latn_pinyin.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: circuitpython-cn\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-11-04 21:18+0530\n" +"POT-Creation-Date: 2020-11-10 15:30+0530\n" "PO-Revision-Date: 2020-11-15 16:28+0000\n" "Last-Translator: hexthat \n" "Language-Team: Chinese Hanyu Pinyin\n" @@ -302,7 +302,8 @@ msgstr "suǒ yǒu CAN wài shè dōu zài shǐ yòng zhōng" msgid "All I2C peripherals are in use" msgstr "Suǒyǒu I2C wàiwéi qì zhèngzài shǐyòng" -#: ports/esp32s2/peripherals/pcnt_handler.c +#: ports/esp32s2/common-hal/countio/Counter.c +#: ports/esp32s2/common-hal/rotaryio/IncrementalEncoder.c msgid "All PCNT units in use" msgstr "suǒ yǒu zhèng zài shǐ yòng zhōng de PCNT dān yuán" @@ -1009,6 +1010,10 @@ msgstr "" msgid "Incorrect buffer size" msgstr "Huǎnchōng qū dàxiǎo bù zhèngquè" +#: ports/esp32s2/common-hal/watchdog/WatchDogTimer.c +msgid "Initialization failed due to lack of memory" +msgstr "" + #: ports/atmel-samd/common-hal/pulseio/PulseIn.c msgid "Input taking too long" msgstr "Shūrù shíjiānguò zhǎng" @@ -3252,6 +3257,7 @@ msgstr "pow() 3 cān shǔ bùnéng wéi 0" msgid "pow() with 3 arguments requires integers" msgstr "pow() yǒu 3 cānshù xūyào zhěngshù" +#: ports/esp32s2/boards/adafruit_magtag_2.9_grayscale/mpconfigboard.h #: ports/esp32s2/boards/adafruit_metro_esp32s2/mpconfigboard.h #: ports/esp32s2/boards/electroniccats_bastwifi/mpconfigboard.h #: ports/esp32s2/boards/espressif_kaluga_1/mpconfigboard.h @@ -3469,6 +3475,7 @@ 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è" +#: ports/esp32s2/common-hal/watchdog/WatchDogTimer.c #: ports/nrf/common-hal/watchdog/WatchDogTimer.c msgid "timeout duration exceeded the maximum supported value" msgstr "chāoshí shíjiān chāoguò zuìdà zhīchí zhí" @@ -3652,6 +3659,10 @@ msgstr "zhí jìshù bìxū wèi > 0" msgid "vectors must have same lengths" msgstr "xiàngliàng bìxū jùyǒu xiāngtóng de chángdù" +#: ports/esp32s2/common-hal/watchdog/WatchDogTimer.c +msgid "watchdog not initialized" +msgstr "" + #: shared-bindings/watchdog/WatchDogTimer.c msgid "watchdog timeout must be greater than 0" msgstr "kān mén gǒu chāoshí bìxū dàyú 0" From 119e9d38202cb26f7f04d1050263e27e1083865a Mon Sep 17 00:00:00 2001 From: jgillick Date: Mon, 16 Nov 2020 23:50:00 -0800 Subject: [PATCH 054/207] Add Thunderpack 1.2 --- ports/stm/boards/thunderpack_v12/board.c | 38 ++ .../boards/thunderpack_v12/mpconfigboard.h | 61 +++ .../boards/thunderpack_v12/mpconfigboard.mk | 20 + ports/stm/boards/thunderpack_v12/pins.c | 39 ++ .../thunderpack_v12/stm32f4xx_hal_conf.h | 440 ++++++++++++++++++ ports/stm/common-hal/microcontroller/Pin.c | 33 ++ 6 files changed, 631 insertions(+) create mode 100644 ports/stm/boards/thunderpack_v12/board.c create mode 100644 ports/stm/boards/thunderpack_v12/mpconfigboard.h create mode 100644 ports/stm/boards/thunderpack_v12/mpconfigboard.mk create mode 100644 ports/stm/boards/thunderpack_v12/pins.c create mode 100644 ports/stm/boards/thunderpack_v12/stm32f4xx_hal_conf.h diff --git a/ports/stm/boards/thunderpack_v12/board.c b/ports/stm/boards/thunderpack_v12/board.c new file mode 100644 index 0000000000..4421970eef --- /dev/null +++ b/ports/stm/boards/thunderpack_v12/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/stm/boards/thunderpack_v12/mpconfigboard.h b/ports/stm/boards/thunderpack_v12/mpconfigboard.h new file mode 100644 index 0000000000..4c71b8aeb2 --- /dev/null +++ b/ports/stm/boards/thunderpack_v12/mpconfigboard.h @@ -0,0 +1,61 @@ +/* + * 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. + */ +#define MICROPY_HW_BOARD_NAME "THUNDERPACK_v12" +#define MICROPY_HW_MCU_NAME "STM32F411CE" + +// Non-volatile memory config +#define CIRCUITPY_INTERNAL_NVM_SIZE (0x4000) +#define CIRCUITPY_INTERNAL_NVM_START_ADDR (0x08010000) +#define CIRCUITPY_INTERNAL_NVM_SECTOR FLASH_SECTOR_4 + +// Putting the entire flash sector in the NVM byte array buffer +// would take up too much RAM. This limits how much of the sector we use. +#define NVM_BYTEARRAY_BUFFER_SIZE 512 + +// Flash config +#define FLASH_SIZE (0x80000) +#define FLASH_PAGE_SIZE (0x4000) +#define BOARD_FLASH_SIZE (FLASH_SIZE - CIRCUITPY_INTERNAL_NVM_SIZE- 0x2000 - 0xC000) + +// 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) + +// Status LEDs +#define MICROPY_HW_LED_STATUS (&pin_PA02) +#define MICROPY_HW_APA102_MOSI (&pin_PB08) +#define MICROPY_HW_APA102_SCK (&pin_PB00) + +// I2C +#define DEFAULT_I2C_BUS_SCL (&pin_PB06) +#define DEFAULT_I2C_BUS_SDA (&pin_PB07) + +// General config +#define BOARD_OSC_DIV (24) +#define BOARD_OVERWRITE_SWD (1) +#define BOARD_NO_VBUS_SENSE (1) \ No newline at end of file diff --git a/ports/stm/boards/thunderpack_v12/mpconfigboard.mk b/ports/stm/boards/thunderpack_v12/mpconfigboard.mk new file mode 100644 index 0000000000..d11cfb7505 --- /dev/null +++ b/ports/stm/boards/thunderpack_v12/mpconfigboard.mk @@ -0,0 +1,20 @@ +USB_VID = 0x239A +USB_PID = 0x806A +USB_PRODUCT = "Thunderpack STM32F411" +USB_MANUFACTURER = "Jeremy Gillick" +USB_DEVICES = "CDC,MSC" + +LONGINT_IMPL = NONE + +SPI_FLASH_FILESYSTEM = 1 +EXTERNAL_FLASH_DEVICE_COUNT = 1 +EXTERNAL_FLASH_DEVICES = GD25Q16C + +CIRCUITPY_NVM = 1 + +MCU_SERIES = F4 +MCU_VARIANT = STM32F411xE +MCU_PACKAGE = UFQFPN48 + +LD_COMMON = boards/common_nvm.ld +LD_FILE = boards/STM32F411_nvm.ld diff --git a/ports/stm/boards/thunderpack_v12/pins.c b/ports/stm/boards/thunderpack_v12/pins.c new file mode 100644 index 0000000000..1e07621eaa --- /dev/null +++ b/ports/stm/boards/thunderpack_v12/pins.c @@ -0,0 +1,39 @@ +#include "shared-bindings/board/__init__.h" + +STATIC const mp_rom_map_elem_t board_module_globals_table[] = { + { MP_ROM_QSTR(MP_QSTR_PA0), MP_ROM_PTR(&pin_PA00) }, + { MP_ROM_QSTR(MP_QSTR_PA1), MP_ROM_PTR(&pin_PA01) }, + { MP_ROM_QSTR(MP_QSTR_PA2), MP_ROM_PTR(&pin_PA02) }, + { MP_ROM_QSTR(MP_QSTR_PA3), MP_ROM_PTR(&pin_PA03) }, + { MP_ROM_QSTR(MP_QSTR_PA4), MP_ROM_PTR(&pin_PA04) }, + { MP_ROM_QSTR(MP_QSTR_PA5), MP_ROM_PTR(&pin_PA05) }, + { MP_ROM_QSTR(MP_QSTR_PA6), MP_ROM_PTR(&pin_PA06) }, + { MP_ROM_QSTR(MP_QSTR_PA7), MP_ROM_PTR(&pin_PA07) }, + { MP_ROM_QSTR(MP_QSTR_PA8), MP_ROM_PTR(&pin_PA08) }, + { MP_ROM_QSTR(MP_QSTR_PA9), MP_ROM_PTR(&pin_PA09) }, + { MP_ROM_QSTR(MP_QSTR_PA10), MP_ROM_PTR(&pin_PA10) }, + { MP_ROM_QSTR(MP_QSTR_PA13), MP_ROM_PTR(&pin_PA13) }, + { MP_ROM_QSTR(MP_QSTR_PA14), MP_ROM_PTR(&pin_PA14) }, + + { MP_ROM_QSTR(MP_QSTR_PB0), MP_ROM_PTR(&pin_PB00) }, + { MP_ROM_QSTR(MP_QSTR_PB5), MP_ROM_PTR(&pin_PB05) }, + { MP_ROM_QSTR(MP_QSTR_PB6), MP_ROM_PTR(&pin_PB06) }, + { MP_ROM_QSTR(MP_QSTR_PB7), MP_ROM_PTR(&pin_PB07) }, + { MP_ROM_QSTR(MP_QSTR_PB8), MP_ROM_PTR(&pin_PB08) }, + + { MP_ROM_QSTR(MP_QSTR_LED1), MP_ROM_PTR(&pin_PA00) }, + { MP_ROM_QSTR(MP_QSTR_LED2), MP_ROM_PTR(&pin_PA01) }, + { MP_ROM_QSTR(MP_QSTR_LED3), MP_ROM_PTR(&pin_PA02) }, + { MP_ROM_QSTR(MP_QSTR_LED4), MP_ROM_PTR(&pin_PA03) }, + + { MP_ROM_QSTR(MP_QSTR_BUTTON), MP_ROM_PTR(&pin_PB04) }, + + { MP_ROM_QSTR(MP_QSTR_SCL), MP_ROM_PTR(&pin_PB06) }, + { MP_ROM_QSTR(MP_QSTR_SDA), MP_ROM_PTR(&pin_PB07) }, + + { MP_ROM_QSTR(MP_QSTR_APA102_MOSI), MP_ROM_PTR(&pin_PB08) }, + { MP_ROM_QSTR(MP_QSTR_APA102_SCK), MP_ROM_PTR(&pin_PB00) }, + + { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) }, +}; +MP_DEFINE_CONST_DICT(board_module_globals, board_module_globals_table); diff --git a/ports/stm/boards/thunderpack_v12/stm32f4xx_hal_conf.h b/ports/stm/boards/thunderpack_v12/stm32f4xx_hal_conf.h new file mode 100644 index 0000000000..5cb5634223 --- /dev/null +++ b/ports/stm/boards/thunderpack_v12/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)24000000) /*!< 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/stm/common-hal/microcontroller/Pin.c b/ports/stm/common-hal/microcontroller/Pin.c index 2c513f4aad..cf5cd754f4 100644 --- a/ports/stm/common-hal/microcontroller/Pin.c +++ b/ports/stm/common-hal/microcontroller/Pin.c @@ -35,6 +35,10 @@ #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 #if defined(LQFP144) #define GPIO_PORT_COUNT 7 @@ -66,6 +70,10 @@ void reset_all_pins(void) { #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 } // Mark pin as free and return it to a quiescent state. @@ -85,6 +93,15 @@ void reset_pin_number(uint8_t pin_port, uint8_t pin_number) { return; } #endif + #ifdef MICROPY_HW_APA102_MOSI + if ((pin_port == MICROPY_HW_APA102_MOSI->port && pin_number == MICROPY_HW_APA102_MOSI->number) + || (pin_port == MICROPY_HW_APA102_SCK->port && pin_number == MICROPY_HW_APA102_MOSI->number)) { + apa102_mosi_in_use = false; + apa102_sck_in_use = false; + rgb_led_status_init(); + return; + } + #endif } void never_reset_pin_number(uint8_t pin_port, uint8_t pin_number) { @@ -108,6 +125,14 @@ void claim_pin(const mcu_pin_obj_t* pin) { 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 } bool pin_number_is_free(uint8_t pin_port, uint8_t pin_number) { @@ -120,6 +145,14 @@ bool common_hal_mcu_pin_is_free(const mcu_pin_obj_t *pin) { 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 return pin_number_is_free(pin->port, pin->number); } From 7750b4d6712b410bd8ccc498e571297b4628884a Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Tue, 17 Nov 2020 07:37:07 -0600 Subject: [PATCH 055/207] actions: Disable pagination of 'aws' commands An anticipatory workaround for https://docs.aws.amazon.com/cli/latest/userguide/cliv2-migration.html#cliv2-migration-output-pager --- .github/workflows/build.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index bd0dea5cf8..9c3c87b586 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -119,6 +119,7 @@ jobs: zip -9r circuitpython-stubs.zip circuitpython-stubs [ -z "$AWS_ACCESS_KEY_ID" ] || aws s3 cp circuitpython-stubs.zip s3://adafruit-circuit-python/bin/stubs/circuitpython-stubs-${{ env.CP_VERSION }}.zip --no-progress --region us-east-1 env: + AWS_PAGER: '' AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} if: github.event_name == 'push' || (github.event_name == 'release' && (github.event.action == 'published' || github.event.action == 'rerequested')) @@ -159,6 +160,7 @@ jobs: run: | [ -z "$AWS_ACCESS_KEY_ID" ] || aws s3 cp mpy-cross/mpy-cross s3://adafruit-circuit-python/bin/mpy-cross/mpy-cross-macos-catalina-${{ env.CP_VERSION }} --no-progress --region us-east-1 env: + AWS_PAGER: '' AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} if: github.event_name == 'push' || (github.event_name == 'release' && (github.event.action == 'published' || github.event.action == 'rerequested')) @@ -363,6 +365,7 @@ jobs: - name: Upload to S3 run: "[ -z \"$AWS_ACCESS_KEY_ID\" ] || aws s3 cp bin/ s3://adafruit-circuit-python/bin/ --recursive --no-progress --region us-east-1" env: + AWS_PAGER: '' AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} if: github.event_name == 'push' || (github.event_name == 'release' && (github.event.action == 'published' || github.event.action == 'rerequested')) @@ -411,6 +414,7 @@ jobs: - name: Upload to S3 run: "[ -z \"$AWS_ACCESS_KEY_ID\" ] || aws s3 cp bin/ s3://adafruit-circuit-python/bin/ --recursive --no-progress --region us-east-1" env: + AWS_PAGER: '' AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} if: github.event_name == 'push' || (github.event_name == 'release' && (github.event.action == 'published' || github.event.action == 'rerequested')) @@ -505,6 +509,7 @@ jobs: - name: Upload to S3 run: "[ -z \"$AWS_ACCESS_KEY_ID\" ] || aws s3 cp bin/ s3://adafruit-circuit-python/bin/ --recursive --no-progress --region us-east-1" env: + AWS_PAGER: '' AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} if: github.event_name == 'push' || (github.event_name == 'release' && (github.event.action == 'published' || github.event.action == 'rerequested')) From a0d305042c335d55176a8f6951572b1a1b7629ba Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Tue, 17 Nov 2020 09:01:50 -0600 Subject: [PATCH 056/207] fix ubuntu-latest stragglers --- .github/workflows/build.yml | 2 +- .github/workflows/create_website_pr.yml | 2 +- .github/workflows/pre-commit.yml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 9c3c87b586..f3e728a05c 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -419,7 +419,7 @@ jobs: AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} if: github.event_name == 'push' || (github.event_name == 'release' && (github.event.action == 'published' || github.event.action == 'rerequested')) build-xtensa: - runs-on: ubuntu-latest + runs-on: ubuntu-20.04 needs: test strategy: fail-fast: false diff --git a/.github/workflows/create_website_pr.yml b/.github/workflows/create_website_pr.yml index 71959ffdcd..c8aca30e4a 100644 --- a/.github/workflows/create_website_pr.yml +++ b/.github/workflows/create_website_pr.yml @@ -10,7 +10,7 @@ on: jobs: website: - runs-on: ubuntu-latest + runs-on: ubuntu-20.04 steps: - name: Dump GitHub context env: diff --git a/.github/workflows/pre-commit.yml b/.github/workflows/pre-commit.yml index eac9bfe096..8caf56d268 100644 --- a/.github/workflows/pre-commit.yml +++ b/.github/workflows/pre-commit.yml @@ -11,7 +11,7 @@ on: jobs: pre-commit: - runs-on: ubuntu-latest + runs-on: ubuntu-20.04 steps: - uses: actions/checkout@v1 - uses: actions/setup-python@v1 From 0bbdf05936c1b36bee6ef4f9f81bd3b9ea40fbc6 Mon Sep 17 00:00:00 2001 From: Lucian Copeland Date: Fri, 13 Nov 2020 13:12:07 -0500 Subject: [PATCH 057/207] Implement recvfrom_into and sendto for UDP --- ports/esp32s2/Makefile | 1 + ports/esp32s2/common-hal/socketpool/Socket.c | 86 ++++++++++---------- shared-bindings/socketpool/Socket.c | 8 +- shared-bindings/socketpool/Socket.h | 4 +- 4 files changed, 52 insertions(+), 47 deletions(-) diff --git a/ports/esp32s2/Makefile b/ports/esp32s2/Makefile index 55d6e91d44..a2e6cb73d9 100644 --- a/ports/esp32s2/Makefile +++ b/ports/esp32s2/Makefile @@ -188,6 +188,7 @@ SRC_C += \ lib/utils/pyexec.c \ lib/utils/stdout_helpers.c \ lib/utils/sys_stdio_mphal.c \ + lib/netutils/netutils.c \ peripherals/pcnt.c \ peripherals/pins.c \ peripherals/rmt.c \ diff --git a/ports/esp32s2/common-hal/socketpool/Socket.c b/ports/esp32s2/common-hal/socketpool/Socket.c index de9e6ad31b..937d199f21 100644 --- a/ports/esp32s2/common-hal/socketpool/Socket.c +++ b/ports/esp32s2/common-hal/socketpool/Socket.c @@ -32,6 +32,11 @@ #include "py/runtime.h" #include "supervisor/shared/tick.h" +#include "components/lwip/lwip/src/include/lwip/err.h" +#include "components/lwip/lwip/src/include/lwip/sockets.h" +#include "components/lwip/lwip/src/include/lwip/sys.h" +#include "components/lwip/lwip/src/include/lwip/netdb.h" + void common_hal_socketpool_socket_settimeout(socketpool_socket_obj_t* self, mp_uint_t timeout_ms) { self->timeout_ms = timeout_ms; } @@ -122,58 +127,55 @@ mp_uint_t common_hal_socketpool_socket_recv_into(socketpool_socket_obj_t* self, mp_uint_t common_hal_socketpool_socket_sendto(socketpool_socket_obj_t* self, const char* host, size_t hostlen, uint8_t port, const uint8_t* buf, mp_uint_t len) { + // Get the IP address string + const struct addrinfo hints = { + .ai_family = AF_INET, + .ai_socktype = SOCK_STREAM, + }; + struct addrinfo *result; + int error = lwip_getaddrinfo(host, NULL, &hints, &result); + if (error != 0 || result == NULL) { + return 0; + } + #pragma GCC diagnostic push + #pragma GCC diagnostic ignored "-Wcast-align" + struct in_addr *addr = &((struct sockaddr_in *)result->ai_addr)->sin_addr; + #pragma GCC diagnostic pop + char ip_str[IP4ADDR_STRLEN_MAX]; + inet_ntoa_r(*addr, ip_str, IP4ADDR_STRLEN_MAX); + freeaddrinfo(result); + + // Set parameters struct sockaddr_in dest_addr; - dest_addr.sin_addr.s_addr = inet_addr(HOST_IP_ADDR); + dest_addr.sin_addr.s_addr = inet_addr((const char *)ip_str); dest_addr.sin_family = AF_INET; dest_addr.sin_port = htons(port); - - const struct addrinfo hints = { - .ai_family = AF_INET, - .ai_socktype = SOCK_STREAM, - }; - struct addrinfo *res; - int err = getaddrinfo(host, NULL, &hints, &res); - if (err != 0 || res == NULL) { - return mp_const_none; + int bytes_sent = lwip_sendto(self->num, buf, len, 0, (struct sockaddr *)&dest_addr, sizeof(dest_addr)); + if (bytes_sent < 0) { + mp_raise_BrokenPipeError(); + return 0; } - - #pragma GCC diagnostic push - #pragma GCC diagnostic ignored "-Wcast-align" - struct in_addr *addr = &((struct sockaddr_in *)res->ai_addr)->sin_addr; - #pragma GCC diagnostic pop - char ip_str[IP4ADDR_STRLEN_MAX]; - inet_ntoa_r(*addr, ip_str, IP4ADDR_STRLEN_MAX); - mp_obj_t ip_obj = mp_obj_new_str(ip_str, strlen(ip_str)); - freeaddrinfo(res); - - - - int err = lwip_sendto(self->num, buf, len, 0 /* flags */, - (struct sockaddr *)&dest_addr, sizeof(dest_addr)); + return bytes_sent; } mp_uint_t common_hal_socketpool_socket_recvfrom_into(socketpool_socket_obj_t* self, - const uint8_t* buf, mp_uint_t len, uint8_t* ip, uint8_t port) { + uint8_t* buf, mp_uint_t len, uint8_t* ip, uint *port) { - const struct addrinfo hints = { - .ai_family = AF_INET, - .ai_socktype = SOCK_STREAM, - }; - struct addrinfo *res; - int err = getaddrinfo(host, NULL, &hints, &res); - if (err != 0 || res == NULL) { - return mp_const_none; + struct sockaddr_in source_addr; + socklen_t socklen = sizeof(source_addr); + int bytes_received = lwip_recvfrom(self->num, buf, len - 1, 0, (struct sockaddr *)&source_addr, &socklen); + + memcpy((void *)ip, (void*)&source_addr.sin_addr.s_addr, sizeof source_addr.sin_addr.s_addr); + *port = source_addr.sin_port; + + if (bytes_received < 0) { + mp_raise_BrokenPipeError(); + return 0; + } else { + buf[bytes_received] = 0; // Null-terminate whatever we received + return bytes_received; } - - #pragma GCC diagnostic push - #pragma GCC diagnostic ignored "-Wcast-align" - struct in_addr *addr = &((struct sockaddr_in *)res->ai_addr)->sin_addr; - #pragma GCC diagnostic pop - char ip_str[IP4ADDR_STRLEN_MAX]; - inet_ntoa_r(*addr, ip_str, IP4ADDR_STRLEN_MAX); - mp_obj_t ip_obj = mp_obj_new_str(ip_str, strlen(ip_str)); - freeaddrinfo(res); } void common_hal_socketpool_socket_close(socketpool_socket_obj_t* self) { diff --git a/shared-bindings/socketpool/Socket.c b/shared-bindings/socketpool/Socket.c index 591b7d8bbd..99e2c8fccb 100644 --- a/shared-bindings/socketpool/Socket.c +++ b/shared-bindings/socketpool/Socket.c @@ -36,6 +36,8 @@ #include "py/runtime.h" #include "py/mperrno.h" +#include "lib/netutils/netutils.h" + //| class Socket: //| """TCP, UDP and RAW socket. Cannot be created directly. Instead, call //| `SocketPool.socket()`. @@ -298,7 +300,7 @@ STATIC mp_obj_t socketpool_socket_sendto(mp_obj_t self_in, mp_obj_t data_in, mp_ mp_int_t port = mp_obj_get_int(addr_items[1]); mp_int_t ret = common_hal_socketpool_socket_sendto(self, host, hostlen, port, bufinfo.buf, bufinfo.len); - if (!ok) { + if (!ret) { mp_raise_OSError(0); } @@ -324,11 +326,11 @@ STATIC mp_obj_t socketpool_socket_recvfrom_into(mp_obj_t self_in, mp_obj_t data_ byte ip[4]; mp_uint_t port; mp_int_t ret = common_hal_socketpool_socket_recvfrom_into(self, - (byte*)bufinfo.buf, len, ip, &port); + (byte*)bufinfo.buf, bufinfo.len, ip, &port); mp_obj_t tuple_contents[2]; tuple_contents[0] = mp_obj_new_int_from_uint(ret); tuple_contents[1] = netutils_format_inet_addr(ip, port, NETUTILS_BIG); - return mp_obj_new_tuple(2, tuple); + return mp_obj_new_tuple(2, tuple_contents); } STATIC MP_DEFINE_CONST_FUN_OBJ_2(socketpool_socket_recvfrom_into_obj, socketpool_socket_recvfrom_into); diff --git a/shared-bindings/socketpool/Socket.h b/shared-bindings/socketpool/Socket.h index 72a4c9e3c3..54fbe59b28 100644 --- a/shared-bindings/socketpool/Socket.h +++ b/shared-bindings/socketpool/Socket.h @@ -36,9 +36,9 @@ bool common_hal_socketpool_socket_connect(socketpool_socket_obj_t* self, const c mp_uint_t common_hal_socketpool_socket_send(socketpool_socket_obj_t* self, const uint8_t* buf, mp_uint_t len); mp_uint_t common_hal_socketpool_socket_recv_into(socketpool_socket_obj_t* self, const uint8_t* buf, mp_uint_t len); mp_uint_t common_hal_socketpool_socket_sendto(socketpool_socket_obj_t* self, - const uint8_t* host, size_t hostlen, uint8_t port, const uint8_t* buf, mp_uint_t len); + const char* host, size_t hostlen, uint8_t port, const uint8_t* buf, mp_uint_t len); mp_uint_t common_hal_socketpool_socket_recvfrom_into(socketpool_socket_obj_t* self, - const uint8_t* buf, mp_uint_t len, uint8_t* ip, uint8_t port); + uint8_t* buf, mp_uint_t len, uint8_t* ip, uint *port); void common_hal_socketpool_socket_close(socketpool_socket_obj_t* self); bool common_hal_socketpool_socket_get_closed(socketpool_socket_obj_t* self); bool common_hal_socketpool_socket_get_connected(socketpool_socket_obj_t* self); From 1bc770c3dc308b91184e8cab52f6f4cabdda99fc Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Tue, 17 Nov 2020 17:31:54 -0600 Subject: [PATCH 058/207] esp32s2: PulseIn: Fix supervisor tick enabling Before, there were two problems: * Even if a pulsein was never constructed, supervisor_disable_tick would occur during restart. This could cancel out a supervisor_enable_tick from someplace else, with unexpected results. * If two or more pulseins were constructed, each one would enable ticks, but only the last one deinited (or the reset routine) would disable, leaving ticks running indefinitely. In my testing, it seemed that this led to the board sometimes stopping when it should have auto-reloaded. --- ports/esp32s2/common-hal/pulseio/PulseIn.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/ports/esp32s2/common-hal/pulseio/PulseIn.c b/ports/esp32s2/common-hal/pulseio/PulseIn.c index f7429ec12c..9feeea1479 100644 --- a/ports/esp32s2/common-hal/pulseio/PulseIn.c +++ b/ports/esp32s2/common-hal/pulseio/PulseIn.c @@ -77,7 +77,9 @@ void pulsein_reset(void) { for (size_t i = 0; i < RMT_CHANNEL_MAX; i++) { handles[i] = NULL; } - supervisor_disable_tick(); + if (refcount != 0) { + supervisor_disable_tick(); + } refcount = 0; } @@ -122,8 +124,10 @@ void common_hal_pulseio_pulsein_construct(pulseio_pulsein_obj_t* self, const mcu // start RMT RX, and enable ticks so the core doesn't turn off. rmt_rx_start(channel, true); - supervisor_enable_tick(); refcount++; + if (refcount == 1) { + supervisor_enable_tick(); + } } bool common_hal_pulseio_pulsein_deinited(pulseio_pulsein_obj_t* self) { From 9206925bf8d2e3d8220b59200ee50c3e4c8a64d2 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Tue, 17 Nov 2020 17:45:12 -0600 Subject: [PATCH 059/207] esp32s2: port_get_raw_ticks: Use a more efficient, monotonic routine While trying to debug #3572, I noticed that I would frequently break in the midst of gettimeofday and that the routine get_adjusted_boot_time had to take and release locks. Furthermore, we don't want "adjusted" boot time, which could go forwards or backwards depending on the adjustment (such as setting the clock used by gettimeofday() to the network time) --- ports/esp32s2/supervisor/port.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/ports/esp32s2/supervisor/port.c b/ports/esp32s2/supervisor/port.c index 47d0c7f463..876ad739d6 100644 --- a/ports/esp32s2/supervisor/port.c +++ b/ports/esp32s2/supervisor/port.c @@ -191,14 +191,14 @@ uint32_t port_get_saved_word(void) { } uint64_t port_get_raw_ticks(uint8_t* subticks) { - struct timeval tv_now; - gettimeofday(&tv_now, NULL); - // convert usec back to ticks - uint64_t all_subticks = (uint64_t)(tv_now.tv_usec * 2) / 71; + // Convert microseconds to subticks of 1/32768 seconds + // 32768/1000000 = 64/15625 in lowest terms + // this arithmetic overflows after 570 years + int64_t all_subticks = esp_timer_get_time() * 512 / 15625; if (subticks != NULL) { *subticks = all_subticks % 32; } - return (uint64_t)tv_now.tv_sec * 1024L + all_subticks / 32; + return all_subticks / 32; } // Enable 1/1024 second tick. From 8ae7b996278f379b6d40b2d3cf9729b5be53abd9 Mon Sep 17 00:00:00 2001 From: Wellington Terumi Uemura Date: Mon, 16 Nov 2020 23:32:22 +0000 Subject: [PATCH 060/207] Translated using Weblate (Portuguese (Brazil)) Currently translated at 100.0% (848 of 848 strings) Translation: CircuitPython/main Translate-URL: https://hosted.weblate.org/projects/circuitpython/main/pt_BR/ --- locale/pt_BR.po | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/locale/pt_BR.po b/locale/pt_BR.po index 4918689795..4cf204ae81 100644 --- a/locale/pt_BR.po +++ b/locale/pt_BR.po @@ -6,7 +6,7 @@ msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2020-11-10 15:30+0530\n" -"PO-Revision-Date: 2020-11-08 10:26+0000\n" +"PO-Revision-Date: 2020-11-18 00:28+0000\n" "Last-Translator: Wellington Terumi Uemura \n" "Language-Team: \n" "Language: pt_BR\n" @@ -14,7 +14,7 @@ msgstr "" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=2; plural=n > 1;\n" -"X-Generator: Weblate 4.3.2\n" +"X-Generator: Weblate 4.4-dev\n" #: main.c msgid "" @@ -447,7 +447,7 @@ msgstr "" #: shared-bindings/rgbmatrix/RGBMatrix.c #, c-format msgid "Bit depth must be from 1 to 6 inclusive, not %d" -msgstr "" +msgstr "A profundidade dos bits deve ser de 1 até 6 inclusive, porém não %d" #: shared-bindings/audiobusio/PDMIn.c msgid "Bit depth must be multiple of 8." @@ -1025,7 +1025,7 @@ msgstr "O tamanho do buffer está incorreto" #: ports/esp32s2/common-hal/watchdog/WatchDogTimer.c msgid "Initialization failed due to lack of memory" -msgstr "" +msgstr "A inicialização falhou devido à falta de memória" #: ports/atmel-samd/common-hal/pulseio/PulseIn.c msgid "Input taking too long" @@ -3705,7 +3705,7 @@ msgstr "os vetores devem ter os mesmos comprimentos" #: ports/esp32s2/common-hal/watchdog/WatchDogTimer.c msgid "watchdog not initialized" -msgstr "" +msgstr "o watchdog não foi inicializado" #: shared-bindings/watchdog/WatchDogTimer.c msgid "watchdog timeout must be greater than 0" From ff987e7496152c3175608570d90f36753b4c4670 Mon Sep 17 00:00:00 2001 From: microDev <70126934+microDev1@users.noreply.github.com> Date: Wed, 18 Nov 2020 12:16:14 +0530 Subject: [PATCH 061/207] add timer peripheral --- ports/esp32s2/Makefile | 1 + ports/esp32s2/peripherals/timer.c | 73 +++++++++++++++++++++++++++++++ ports/esp32s2/peripherals/timer.h | 41 +++++++++++++++++ ports/esp32s2/supervisor/port.c | 23 ++++++---- 4 files changed, 129 insertions(+), 9 deletions(-) create mode 100644 ports/esp32s2/peripherals/timer.c create mode 100644 ports/esp32s2/peripherals/timer.h diff --git a/ports/esp32s2/Makefile b/ports/esp32s2/Makefile index 55d6e91d44..931e4d0639 100644 --- a/ports/esp32s2/Makefile +++ b/ports/esp32s2/Makefile @@ -188,6 +188,7 @@ SRC_C += \ lib/utils/pyexec.c \ lib/utils/stdout_helpers.c \ lib/utils/sys_stdio_mphal.c \ + peripherals/timer.c \ peripherals/pcnt.c \ peripherals/pins.c \ peripherals/rmt.c \ diff --git a/ports/esp32s2/peripherals/timer.c b/ports/esp32s2/peripherals/timer.c new file mode 100644 index 0000000000..3aee33dc50 --- /dev/null +++ b/ports/esp32s2/peripherals/timer.c @@ -0,0 +1,73 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2020 microDev + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include "peripherals/timer.h" + +#define TIMER_FREE 1 +#define TIMER_BUSY 0 + +static uint8_t timer_state[2][2]; + +void peripherals_timer_reset(void) { + timer_index_t timer; + for (uint8_t i = 0; i < 2; i++) { + for (uint8_t j = 0; j < 2; j++) { + if (timer_state[i][j] == TIMER_BUSY) { + timer.idx = (timer_idx_t)j; + timer.group = (timer_group_t)i; + timer_state[i][j] = TIMER_FREE; + peripherals_timer_deinit(&timer); + } + } + } +} + +void peripherals_timer_init(const timer_config_t * config, timer_index_t * timer) { + // get free timer + for (uint8_t i = 0; i < 2; i++) { + for (uint8_t j = 0; j < 2; j++) { + if (timer_state[i][j] == TIMER_FREE) { + timer->idx = (timer_idx_t)j; + timer->group = (timer_group_t)i; + timer_state[i][j] = TIMER_BUSY; + goto init_timer; + } else if (i == 1 && j == 1) { + timer->idx = TIMER_MAX; + timer->group = TIMER_GROUP_MAX; + return; + } + } + } + +init_timer: + // initialize timer module + timer_init(timer->group, timer->idx, config); + timer_set_counter_value(timer->group, timer->idx, 0); +} + +void peripherals_timer_deinit(timer_index_t * timer) { + timer_deinit(timer->group, timer->idx); +} diff --git a/ports/esp32s2/peripherals/timer.h b/ports/esp32s2/peripherals/timer.h new file mode 100644 index 0000000000..8c9ebd91c9 --- /dev/null +++ b/ports/esp32s2/peripherals/timer.h @@ -0,0 +1,41 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2020 microDev + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#ifndef MICROPY_INCLUDED_ESP32S2_PERIPHERALS_TIMER_HANDLER_H +#define MICROPY_INCLUDED_ESP32S2_PERIPHERALS_TIMER_HANDLER_H + +#include "driver/timer.h" + +typedef struct { + timer_idx_t idx; + timer_group_t group; +} timer_index_t; + +extern void peripherals_timer_init(const timer_config_t * config, timer_index_t * timer); +extern void peripherals_timer_deinit(timer_index_t * timer); +extern void peripherals_timer_reset(void); + +#endif // MICROPY_INCLUDED_ESP32S2_PERIPHERALS_TIMER_HANDLER_H diff --git a/ports/esp32s2/supervisor/port.c b/ports/esp32s2/supervisor/port.c index ef032c4a76..4bf792516d 100644 --- a/ports/esp32s2/supervisor/port.c +++ b/ports/esp32s2/supervisor/port.c @@ -50,6 +50,7 @@ #include "peripherals/rmt.h" #include "peripherals/pcnt.h" +#include "peripherals/timer.h" #include "components/heap/include/esp_heap_caps.h" #include "components/soc/soc/esp32s2/include/soc/cache_memory.h" @@ -103,15 +104,6 @@ void reset_port(void) { analogout_reset(); #endif -#if CIRCUITPY_PULSEIO - esp32s2_peripherals_rmt_reset(); - pulsein_reset(); -#endif - -#if CIRCUITPY_PWMIO - pwmout_reset(); -#endif - #if CIRCUITPY_BUSIO i2c_reset(); spi_reset(); @@ -122,6 +114,19 @@ void reset_port(void) { peripherals_pcnt_reset(); #endif +#if CIRCUITPY_FREQUENCYIO + peripherals_timer_reset(); +#endif + +#if CIRCUITPY_PULSEIO + esp32s2_peripherals_rmt_reset(); + pulsein_reset(); +#endif + +#if CIRCUITPY_PWMIO + pwmout_reset(); +#endif + #if CIRCUITPY_RTC rtc_reset(); #endif From c457d373e18a5bcadec44e0815bea8b9beb30a97 Mon Sep 17 00:00:00 2001 From: microDev <70126934+microDev1@users.noreply.github.com> Date: Wed, 18 Nov 2020 12:24:48 +0530 Subject: [PATCH 062/207] update init_timer & frequency calculation --- .../common-hal/frequencyio/FrequencyIn.c | 55 ++++++++++++------- .../common-hal/frequencyio/FrequencyIn.h | 5 +- 2 files changed, 38 insertions(+), 22 deletions(-) diff --git a/ports/esp32s2/common-hal/frequencyio/FrequencyIn.c b/ports/esp32s2/common-hal/frequencyio/FrequencyIn.c index 20d744139d..12d612abb0 100644 --- a/ports/esp32s2/common-hal/frequencyio/FrequencyIn.c +++ b/ports/esp32s2/common-hal/frequencyio/FrequencyIn.c @@ -29,7 +29,7 @@ #include "py/runtime.h" static void IRAM_ATTR pcnt_overflow_handler(void *self_in) { - frequencyio_frequencyin_obj_t* self = self_in; + frequencyio_frequencyin_obj_t * self = self_in; // reset counter pcnt_counter_clear(self->unit); @@ -41,18 +41,26 @@ static void IRAM_ATTR pcnt_overflow_handler(void *self_in) { } static void IRAM_ATTR timer_interrupt_handler(void *self_in) { - frequencyio_frequencyin_obj_t* self = self_in; + frequencyio_frequencyin_obj_t * self = self_in; // get counter value int16_t count; pcnt_get_counter_value(self->unit, &count); - self->frequency = count / 2.0 / self->capture_period; + self->frequency = ((count / 2.0) + (self->multiplier * INT16_MAX / 4.0)) / (self->capture_period); + + // reset multiplier + self->multiplier = 0; // reset counter pcnt_counter_clear(self->unit); // reset interrupt - TIMERG0.int_clr.t0 = 1; - TIMERG0.hw_timer[0].config.alarm_en = 1; + timg_dev_t *device = self->timer.group ? &(TIMERG1) : &(TIMERG0); + if (self->timer.idx) { + device->int_clr.t1 = 1; + } else { + device->int_clr.t0 = 1; + } + device->hw_timer[self->timer.idx].config.alarm_en = 1; } static void init_pcnt(frequencyio_frequencyin_obj_t* self) { @@ -70,7 +78,7 @@ static void init_pcnt(frequencyio_frequencyin_obj_t* self) { .counter_l_lim = 0, }; - // Initialize PCNT unit + // initialize PCNT const int8_t unit = peripherals_pcnt_init(pcnt_config); if (unit == -1) { mp_raise_RuntimeError(translate("All PCNT units in use")); @@ -98,15 +106,22 @@ static void init_timer(frequencyio_frequencyin_obj_t* self) { .divider = 80 // 1 us per tick }; - // Initialize timer module - timer_init(TIMER_GROUP_0, TIMER_0, &config); - timer_set_counter_value(TIMER_GROUP_0, TIMER_0, 0); - timer_set_alarm_value(TIMER_GROUP_0, TIMER_0, self->capture_period * 1000000); - timer_isr_register(TIMER_GROUP_0, TIMER_0, timer_interrupt_handler, (void *)self, ESP_INTR_FLAG_IRAM, &self->handle); - timer_enable_intr(TIMER_GROUP_0, TIMER_0); + // initialize Timer + peripherals_timer_init(&config, &self->timer); + if (self->timer.idx == TIMER_MAX || self->timer.group == TIMER_GROUP_MAX) { + mp_raise_RuntimeError(translate("All timers in use")); + } - // Start timer - timer_start(TIMER_GROUP_0, TIMER_0); + timer_idx_t idx = self->timer.idx; + timer_group_t group = self->timer.group; + + // enable timer interrupt + timer_set_alarm_value(group, idx, self->capture_period * 1000000); + timer_isr_register(group, idx, timer_interrupt_handler, (void *)self, ESP_INTR_FLAG_IRAM, &self->handle); + timer_enable_intr(group, idx); + + // start timer + timer_start(self->timer.group, self->timer.idx); } void common_hal_frequencyio_frequencyin_construct(frequencyio_frequencyin_obj_t* self, @@ -137,7 +152,7 @@ void common_hal_frequencyio_frequencyin_deinit(frequencyio_frequencyin_obj_t* se } reset_pin_number(self->pin); peripherals_pcnt_deinit(&self->unit); - timer_deinit(TIMER_GROUP_0, TIMER_0); + peripherals_timer_deinit(&self->timer); if (self->handle) { esp_intr_free(self->handle); self->handle = NULL; @@ -145,23 +160,23 @@ void common_hal_frequencyio_frequencyin_deinit(frequencyio_frequencyin_obj_t* se } uint32_t common_hal_frequencyio_frequencyin_get_item(frequencyio_frequencyin_obj_t* self) { - return (self->frequency + (self->multiplier * INT16_MAX)); + return self->frequency; } void common_hal_frequencyio_frequencyin_pause(frequencyio_frequencyin_obj_t* self) { pcnt_counter_pause(self->unit); - timer_pause(TIMER_GROUP_0, TIMER_0); + timer_pause(self->timer.group, self->timer.idx); } void common_hal_frequencyio_frequencyin_resume(frequencyio_frequencyin_obj_t* self) { pcnt_counter_resume(self->unit); - timer_start(TIMER_GROUP_0, TIMER_0); + timer_start(self->timer.group, self->timer.idx); } void common_hal_frequencyio_frequencyin_clear(frequencyio_frequencyin_obj_t* self) { self->frequency = 0; pcnt_counter_clear(self->unit); - timer_set_counter_value(TIMER_GROUP_0, TIMER_0, 0); + timer_set_counter_value(self->timer.group, self->timer.idx, 0); } uint16_t common_hal_frequencyio_frequencyin_get_capture_period(frequencyio_frequencyin_obj_t *self) { @@ -174,5 +189,5 @@ void common_hal_frequencyio_frequencyin_set_capture_period(frequencyio_frequency } self->capture_period = capture_period; common_hal_frequencyio_frequencyin_clear(self); - timer_set_alarm_value(TIMER_GROUP_0, TIMER_0, capture_period * 1000000); + timer_set_alarm_value(self->timer.group, self->timer.idx, capture_period * 1000000); } diff --git a/ports/esp32s2/common-hal/frequencyio/FrequencyIn.h b/ports/esp32s2/common-hal/frequencyio/FrequencyIn.h index ce3bf8f2f9..cf9d2ae538 100644 --- a/ports/esp32s2/common-hal/frequencyio/FrequencyIn.h +++ b/ports/esp32s2/common-hal/frequencyio/FrequencyIn.h @@ -28,16 +28,17 @@ #define MICROPY_INCLUDED_ESP32S2_COMMON_HAL_FREQUENCYIO_FREQUENCYIN_H #include "py/obj.h" -#include "driver/timer.h" #include "peripherals/pcnt.h" +#include "peripherals/timer.h" typedef struct { mp_obj_base_t base; pcnt_unit_t unit; + timer_index_t timer; intr_handle_t handle; uint8_t pin; uint8_t multiplier; - uint16_t frequency; + uint32_t frequency; uint16_t capture_period; } frequencyio_frequencyin_obj_t; From bab41afce759916af15ab57645691336ea2bdd06 Mon Sep 17 00:00:00 2001 From: microDev <70126934+microDev1@users.noreply.github.com> Date: Wed, 18 Nov 2020 12:34:56 +0530 Subject: [PATCH 063/207] ps2io implementation for esp32s2 --- ports/esp32s2/common-hal/ps2io/Ps2.c | 393 ++++++++++++++++++++++ ports/esp32s2/common-hal/ps2io/Ps2.h | 60 ++++ ports/esp32s2/common-hal/ps2io/__init__.c | 1 + ports/esp32s2/mpconfigport.mk | 4 + 4 files changed, 458 insertions(+) create mode 100644 ports/esp32s2/common-hal/ps2io/Ps2.c create mode 100644 ports/esp32s2/common-hal/ps2io/Ps2.h create mode 100644 ports/esp32s2/common-hal/ps2io/__init__.c diff --git a/ports/esp32s2/common-hal/ps2io/Ps2.c b/ports/esp32s2/common-hal/ps2io/Ps2.c new file mode 100644 index 0000000000..2156a42479 --- /dev/null +++ b/ports/esp32s2/common-hal/ps2io/Ps2.c @@ -0,0 +1,393 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2020 microDev + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include "common-hal/ps2io/Ps2.h" + +#include "py/runtime.h" +#include "supervisor/port.h" +#include "shared-bindings/ps2io/Ps2.h" +#include "shared-bindings/microcontroller/__init__.h" + +#define STATE_IDLE 0 +#define STATE_RECV 1 +#define STATE_RECV_PARITY 2 +#define STATE_RECV_STOP 3 +#define STATE_RECV_ERR 10 + +#define ERROR_STARTBIT 0x01 +#define ERROR_TIMEOUT 0x02 +#define ERROR_PARITY 0x04 +#define ERROR_STOPBIT 0x08 +#define ERROR_BUFFER 0x10 + +#define ERROR_TX_CLKLO 0x100 +#define ERROR_TX_CLKHI 0x200 +#define ERROR_TX_ACKDATA 0x400 +#define ERROR_TX_ACKCLK 0x800 +#define ERROR_TX_RTS 0x1000 +#define ERROR_TX_NORESP 0x2000 + +static void IRAM_ATTR ps2_interrupt_handler(void *self_in); + +static void ps2_set_config(ps2io_ps2_obj_t* self) { + // turn on falling edge interrupt + gpio_set_intr_type(self->clk_pin, GPIO_INTR_NEGEDGE); + gpio_isr_register(ps2_interrupt_handler, (void *)self, ESP_INTR_FLAG_IRAM, &self->handle); + gpio_intr_enable(self->clk_pin); +} + +static void disable_interrupt(ps2io_ps2_obj_t* self) { + // turn off fallling edge interrupt + gpio_intr_disable(self->clk_pin); +} + +static void resume_interrupt(ps2io_ps2_obj_t* self) { + self->state = STATE_IDLE; + gpio_intr_enable(self->clk_pin); +} + +static void clk_hi(ps2io_ps2_obj_t* self) { + // external pull-up + gpio_set_direction(self->clk_pin, GPIO_MODE_INPUT); + gpio_pullup_dis(self->clk_pin); +} + +static bool wait_clk_lo(ps2io_ps2_obj_t* self, uint32_t us) { + clk_hi(self); + common_hal_mcu_delay_us(1); + while (gpio_get_level(self->clk_pin) && us) { + --us; + common_hal_mcu_delay_us(1); + } + return us; +} + +static bool wait_clk_hi(ps2io_ps2_obj_t* self, uint32_t us) { + clk_hi(self); + common_hal_mcu_delay_us(1); + while (!gpio_get_level(self->clk_pin) && us) { + --us; + common_hal_mcu_delay_us(1); + } + return us; +} + +static void clk_lo(ps2io_ps2_obj_t* self) { + gpio_pullup_dis(self->clk_pin); + gpio_set_direction(self->clk_pin, GPIO_MODE_OUTPUT); + gpio_set_level(self->clk_pin, 0); +} + +static void data_hi(ps2io_ps2_obj_t* self) { + // external pull-up + gpio_set_direction(self->data_pin, GPIO_MODE_INPUT); + gpio_pullup_dis(self->data_pin); +} + +static bool wait_data_lo(ps2io_ps2_obj_t* self, uint32_t us) { + data_hi(self); + common_hal_mcu_delay_us(1); + while (gpio_get_level(self->data_pin) && us) { + --us; + common_hal_mcu_delay_us(1); + } + return us; +} + +static bool wait_data_hi(ps2io_ps2_obj_t* self, uint32_t us) { + data_hi(self); + common_hal_mcu_delay_us(1); + while (!gpio_get_level(self->data_pin) && us) { + --us; + common_hal_mcu_delay_us(1); + } + return us; +} + +static void data_lo(ps2io_ps2_obj_t* self) { + gpio_pullup_dis(self->data_pin); + gpio_set_direction(self->data_pin, GPIO_MODE_OUTPUT); + gpio_set_level(self->data_pin, 0); +} + +static void idle(ps2io_ps2_obj_t* self) { + clk_hi(self); + data_hi(self); +} + +static void inhibit(ps2io_ps2_obj_t* self) { + clk_lo(self); + data_hi(self); +} + +static void delay_us(uint32_t t) { + common_hal_mcu_delay_us(t); +} + +static void IRAM_ATTR ps2_interrupt_handler(void *self_in) { + // Grab the current time first. + uint64_t current_tick = port_get_raw_ticks(NULL); + + ps2io_ps2_obj_t * self = self_in; + int data_bit = gpio_get_level(self->data_pin) ? 1 : 0; + + // test for timeout + if (self->state != STATE_IDLE) { + int64_t diff_ms = current_tick - self->last_raw_ticks; + if (diff_ms > 1) { // a.k.a. > 1.001ms + self->last_errors |= ERROR_TIMEOUT; + self->state = STATE_IDLE; + } + } + + self->last_raw_ticks = current_tick; + + if (self->state == STATE_IDLE) { + self->bits = 0; + self->parity = false; + self->bitcount = 0; + self->state = STATE_RECV; + if (data_bit) { + // start bit should be 0 + self->last_errors |= ERROR_STARTBIT; + self->state = STATE_RECV_ERR; + } else { + self->state = STATE_RECV; + } + + } else if (self->state == STATE_RECV) { + if (data_bit) { + self->bits |= data_bit << self->bitcount; + self->parity = !self->parity; + } + ++self->bitcount; + if (self->bitcount >= 8) { + self->state = STATE_RECV_PARITY; + } + + } else if (self->state == STATE_RECV_PARITY) { + ++self->bitcount; + if (data_bit) { + self->parity = !self->parity; + } + if (!self->parity) { + self->last_errors |= ERROR_PARITY; + self->state = STATE_RECV_ERR; + } else { + self->state = STATE_RECV_STOP; + } + + } else if (self->state == STATE_RECV_STOP) { + ++self->bitcount; + if (! data_bit) { + self->last_errors |= ERROR_STOPBIT; + } else if (self->waiting_cmd_response) { + self->cmd_response = self->bits; + self->waiting_cmd_response = false; + } else if (self->bufcount >= sizeof(self->buffer)) { + self->last_errors |= ERROR_BUFFER; + } else { + self->buffer[self->bufposw] = self->bits; + self->bufposw = (self->bufposw + 1) % sizeof(self->buffer); + self->bufcount++; + } + self->state = STATE_IDLE; + + } else if (self->state == STATE_RECV_ERR) { + // just count the bits until idle + if (++self->bitcount >= 10) { + self->state = STATE_IDLE; + } + } +} + +void common_hal_ps2io_ps2_construct(ps2io_ps2_obj_t* self, + const mcu_pin_obj_t* data_pin, const mcu_pin_obj_t* clk_pin) { + clk_hi(self); + data_hi(self); + + self->clk_pin = (gpio_num_t)clk_pin->number; + self->data_pin = (gpio_num_t)data_pin->number; + self->state = STATE_IDLE; + self->bufcount = 0; + self->bufposr = 0; + self->bufposw = 0; + self->waiting_cmd_response = false; + + claim_pin(clk_pin); + claim_pin(data_pin); + + // set config will enable the interrupt. + ps2_set_config(self); +} + +bool common_hal_ps2io_ps2_deinited(ps2io_ps2_obj_t* self) { + return self->clk_pin == GPIO_NUM_MAX; +} + +void common_hal_ps2io_ps2_deinit(ps2io_ps2_obj_t* self) { + if (common_hal_ps2io_ps2_deinited(self)) { + return; + } + if (self->handle) { + esp_intr_free(self->handle); + self->handle = NULL; + } + reset_pin_number(self->clk_pin); + reset_pin_number(self->data_pin); + self->clk_pin = GPIO_NUM_MAX; + self->data_pin = GPIO_NUM_MAX; +} + +uint16_t common_hal_ps2io_ps2_get_len(ps2io_ps2_obj_t* self) { + return self->bufcount; +} + +int16_t common_hal_ps2io_ps2_popleft(ps2io_ps2_obj_t* self) { + common_hal_mcu_disable_interrupts(); + if (self->bufcount <= 0) { + common_hal_mcu_enable_interrupts(); + return -1; + } + uint8_t b = self->buffer[self->bufposr]; + self->bufposr = (self->bufposr + 1) % sizeof(self->buffer); + self->bufcount -= 1; + common_hal_mcu_enable_interrupts(); + return b; +} + +uint16_t common_hal_ps2io_ps2_clear_errors(ps2io_ps2_obj_t* self) { + common_hal_mcu_disable_interrupts(); + uint16_t errors = self->last_errors; + self->last_errors = 0; + common_hal_mcu_enable_interrupts(); + return errors; +} + +// Based upon TMK implementation of PS/2 protocol +// https://github.com/tmk/tmk_keyboard/blob/master/tmk_core/protocol/ps2_interrupt.c + +int16_t common_hal_ps2io_ps2_sendcmd(ps2io_ps2_obj_t* self, uint8_t b) { + disable_interrupt(self); + inhibit(self); + delay_us(100); + + /* RTS and start bit */ + data_lo(self); + clk_hi(self); + if (!wait_clk_lo(self, 10000)) { + self->last_errors |= ERROR_TX_RTS; + goto ERROR; + } + + bool parity = true; + for (uint8_t i = 0; i < 8; i++) { + delay_us(15); + if (b & (1 << i)) { + parity = !parity; + data_hi(self); + } else { + data_lo(self); + } + if (!wait_clk_hi(self, 50)) { + self->last_errors |= ERROR_TX_CLKHI; + goto ERROR; + } + if (!wait_clk_lo(self, 50)) { + self->last_errors |= ERROR_TX_CLKLO; + goto ERROR; + } + } + + delay_us(15); + if (parity) { + data_hi(self); + } else { + data_lo(self); + } + if (!wait_clk_hi(self, 50)) { + self->last_errors |= ERROR_TX_CLKHI; + goto ERROR; + } + if (!wait_clk_lo(self, 50)) { + self->last_errors |= ERROR_TX_CLKLO; + goto ERROR; + } + + /* Stop bit */ + delay_us(15); + data_hi(self); + + /* Ack */ + if (!wait_data_lo(self, 50)) { + self->last_errors |= ERROR_TX_ACKDATA; + goto ERROR; + } + if (!wait_clk_lo(self, 50)) { + self->last_errors |= ERROR_TX_ACKCLK; + goto ERROR; + } + + /* wait for idle state */ + if (!wait_clk_hi(self, 50)) { + self->last_errors |= ERROR_TX_ACKCLK; + goto ERROR; + } + if (!wait_data_hi(self, 50)) { + self->last_errors |= ERROR_TX_ACKDATA; + goto ERROR; + } + + /* Wait for response byte */ + self->waiting_cmd_response = true; + idle(self); + resume_interrupt(self); + + for (int i = 0; i < 25; ++i) { + delay_us(1000); + common_hal_mcu_disable_interrupts(); + bool has_response = !self->waiting_cmd_response; + uint8_t response = self->cmd_response; + common_hal_mcu_enable_interrupts(); + + if (has_response) { + return response; + } + } + + /* No response */ + common_hal_mcu_disable_interrupts(); + self->waiting_cmd_response = false; + self->last_errors |= ERROR_TX_NORESP; + common_hal_mcu_enable_interrupts(); + return -1; + + /* Other errors */ +ERROR: + idle(self); + resume_interrupt(self); + return -1; +} diff --git a/ports/esp32s2/common-hal/ps2io/Ps2.h b/ports/esp32s2/common-hal/ps2io/Ps2.h new file mode 100644 index 0000000000..51ebde4487 --- /dev/null +++ b/ports/esp32s2/common-hal/ps2io/Ps2.h @@ -0,0 +1,60 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2020 microDev + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#ifndef MICROPY_INCLUDED_ESP32S2_COMMON_HAL_PS2IO_PS2_H +#define MICROPY_INCLUDED_ESP32S2_COMMON_HAL_PS2IO_PS2_H + +#include "common-hal/microcontroller/Pin.h" + +#include "py/obj.h" +#include "driver/gpio.h" + +typedef struct { + mp_obj_base_t base; + gpio_num_t clk_pin; + gpio_num_t data_pin; + + uint8_t state; + uint64_t last_raw_ticks; + + uint16_t bits; + bool parity; + uint8_t bitcount; + + uint8_t buffer[16]; + uint8_t bufcount; + uint8_t bufposr; + uint8_t bufposw; + + uint16_t last_errors; + + bool waiting_cmd_response; + uint8_t cmd_response; + + intr_handle_t handle; +} ps2io_ps2_obj_t; + +#endif // MICROPY_INCLUDED_ESP32S2_COMMON_HAL_PS2IO_PS2_H diff --git a/ports/esp32s2/common-hal/ps2io/__init__.c b/ports/esp32s2/common-hal/ps2io/__init__.c new file mode 100644 index 0000000000..ba4b4249f7 --- /dev/null +++ b/ports/esp32s2/common-hal/ps2io/__init__.c @@ -0,0 +1 @@ +// No ps2io module functions. diff --git a/ports/esp32s2/mpconfigport.mk b/ports/esp32s2/mpconfigport.mk index 335d2caf72..26bb516114 100644 --- a/ports/esp32s2/mpconfigport.mk +++ b/ports/esp32s2/mpconfigport.mk @@ -28,6 +28,10 @@ CIRCUITPY_WIFI = 1 CIRCUITPY_WATCHDOG ?= 1 CIRCUITPY_ESPIDF = 1 +ifndef CIRCUITPY_PS2IO +CIRCUITPY_PS2IO = 1 +endif + ifndef CIRCUITPY_TOUCHIO_USE_NATIVE CIRCUITPY_TOUCHIO_USE_NATIVE = 1 endif From 0d3e81f969adc6d8744e8e720ec4b01848a8fa6c Mon Sep 17 00:00:00 2001 From: microDev <70126934+microDev1@users.noreply.github.com> Date: Wed, 18 Nov 2020 22:22:42 +0530 Subject: [PATCH 064/207] update interrupt handling --- ports/esp32s2/common-hal/ps2io/Ps2.c | 13 +++++-------- ports/esp32s2/common-hal/ps2io/Ps2.h | 2 -- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/ports/esp32s2/common-hal/ps2io/Ps2.c b/ports/esp32s2/common-hal/ps2io/Ps2.c index 2156a42479..9c19ea950e 100644 --- a/ports/esp32s2/common-hal/ps2io/Ps2.c +++ b/ports/esp32s2/common-hal/ps2io/Ps2.c @@ -55,18 +55,18 @@ static void IRAM_ATTR ps2_interrupt_handler(void *self_in); static void ps2_set_config(ps2io_ps2_obj_t* self) { // turn on falling edge interrupt gpio_set_intr_type(self->clk_pin, GPIO_INTR_NEGEDGE); - gpio_isr_register(ps2_interrupt_handler, (void *)self, ESP_INTR_FLAG_IRAM, &self->handle); - gpio_intr_enable(self->clk_pin); + gpio_install_isr_service(ESP_INTR_FLAG_IRAM); + gpio_isr_handler_add(self->clk_pin, ps2_interrupt_handler, (void*)self); } static void disable_interrupt(ps2io_ps2_obj_t* self) { // turn off fallling edge interrupt - gpio_intr_disable(self->clk_pin); + gpio_isr_handler_remove(self->clk_pin); } static void resume_interrupt(ps2io_ps2_obj_t* self) { self->state = STATE_IDLE; - gpio_intr_enable(self->clk_pin); + gpio_isr_handler_add(self->clk_pin, ps2_interrupt_handler, (void*)self); } static void clk_hi(ps2io_ps2_obj_t* self) { @@ -252,10 +252,7 @@ void common_hal_ps2io_ps2_deinit(ps2io_ps2_obj_t* self) { if (common_hal_ps2io_ps2_deinited(self)) { return; } - if (self->handle) { - esp_intr_free(self->handle); - self->handle = NULL; - } + gpio_uninstall_isr_service(); reset_pin_number(self->clk_pin); reset_pin_number(self->data_pin); self->clk_pin = GPIO_NUM_MAX; diff --git a/ports/esp32s2/common-hal/ps2io/Ps2.h b/ports/esp32s2/common-hal/ps2io/Ps2.h index 51ebde4487..eb93829b46 100644 --- a/ports/esp32s2/common-hal/ps2io/Ps2.h +++ b/ports/esp32s2/common-hal/ps2io/Ps2.h @@ -53,8 +53,6 @@ typedef struct { bool waiting_cmd_response; uint8_t cmd_response; - - intr_handle_t handle; } ps2io_ps2_obj_t; #endif // MICROPY_INCLUDED_ESP32S2_COMMON_HAL_PS2IO_PS2_H From 83d790ad8f7838d70269d0f0add6de1199198227 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Wed, 18 Nov 2020 17:45:42 -0600 Subject: [PATCH 065/207] esp32s2: don't delete the event loop .. it seems to make the esp-idf grumpy. --- ports/esp32s2/common-hal/wifi/__init__.c | 1 - 1 file changed, 1 deletion(-) diff --git a/ports/esp32s2/common-hal/wifi/__init__.c b/ports/esp32s2/common-hal/wifi/__init__.c index 2eb3719b4d..1b244dd2ff 100644 --- a/ports/esp32s2/common-hal/wifi/__init__.c +++ b/ports/esp32s2/common-hal/wifi/__init__.c @@ -143,7 +143,6 @@ void wifi_reset(void) { radio->handler_instance_got_ip)); ESP_ERROR_CHECK(esp_wifi_deinit()); esp_netif_destroy(radio->netif); - ESP_ERROR_CHECK(esp_event_loop_delete_default()); radio->netif = NULL; } From f61f8f999b5eeb8a545f5cea13b30ac5b3aeb04a Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Wed, 18 Nov 2020 18:06:31 -0600 Subject: [PATCH 066/207] EPaperDisplay: add rotation property untested, because I don't want to mess my magtag demo up :) but it builds --- shared-bindings/displayio/EPaperDisplay.c | 24 +++++++++++++++++++++++ shared-bindings/displayio/EPaperDisplay.h | 2 ++ shared-module/displayio/EPaperDisplay.c | 23 ++++++++++++++++++++++ 3 files changed, 49 insertions(+) diff --git a/shared-bindings/displayio/EPaperDisplay.c b/shared-bindings/displayio/EPaperDisplay.c index ebff640085..4f5c47acab 100644 --- a/shared-bindings/displayio/EPaperDisplay.c +++ b/shared-bindings/displayio/EPaperDisplay.c @@ -294,6 +294,29 @@ const mp_obj_property_t displayio_epaperdisplay_height_obj = { (mp_obj_t)&mp_const_none_obj}, }; +//| rotation: int +//| """The rotation of the display as an int in degrees.""" +//| +STATIC mp_obj_t displayio_epaperdisplay_obj_get_rotation(mp_obj_t self_in) { + displayio_epaperdisplay_obj_t *self = native_display(self_in); + return MP_OBJ_NEW_SMALL_INT(common_hal_displayio_epaperdisplay_get_rotation(self)); +} +MP_DEFINE_CONST_FUN_OBJ_1(displayio_epaperdisplay_get_rotation_obj, displayio_epaperdisplay_obj_get_rotation); +STATIC mp_obj_t displayio_epaperdisplay_obj_set_rotation(mp_obj_t self_in, mp_obj_t value) { + displayio_epaperdisplay_obj_t *self = native_display(self_in); + common_hal_displayio_epaperdisplay_set_rotation(self, mp_obj_get_int(value)); + return mp_const_none; +} +MP_DEFINE_CONST_FUN_OBJ_2(displayio_epaperdisplay_set_rotation_obj, displayio_epaperdisplay_obj_set_rotation); + + +const mp_obj_property_t displayio_epaperdisplay_rotation_obj = { + .base.type = &mp_type_property, + .proxy = {(mp_obj_t)&displayio_epaperdisplay_get_rotation_obj, + (mp_obj_t)&displayio_epaperdisplay_set_rotation_obj, + (mp_obj_t)&mp_const_none_obj}, +}; + //| bus: _DisplayBus //| """The bus being used by the display""" //| @@ -317,6 +340,7 @@ STATIC const mp_rom_map_elem_t displayio_epaperdisplay_locals_dict_table[] = { { MP_ROM_QSTR(MP_QSTR_width), MP_ROM_PTR(&displayio_epaperdisplay_width_obj) }, { MP_ROM_QSTR(MP_QSTR_height), MP_ROM_PTR(&displayio_epaperdisplay_height_obj) }, + { MP_ROM_QSTR(MP_QSTR_rotation), MP_ROM_PTR(&displayio_epaperdisplay_rotation_obj) }, { MP_ROM_QSTR(MP_QSTR_bus), MP_ROM_PTR(&displayio_epaperdisplay_bus_obj) }, { MP_ROM_QSTR(MP_QSTR_busy), MP_ROM_PTR(&displayio_epaperdisplay_busy_obj) }, { MP_ROM_QSTR(MP_QSTR_time_to_refresh), MP_ROM_PTR(&displayio_epaperdisplay_time_to_refresh_obj) }, diff --git a/shared-bindings/displayio/EPaperDisplay.h b/shared-bindings/displayio/EPaperDisplay.h index f785203a41..14d4f6aa9a 100644 --- a/shared-bindings/displayio/EPaperDisplay.h +++ b/shared-bindings/displayio/EPaperDisplay.h @@ -56,6 +56,8 @@ bool common_hal_displayio_epaperdisplay_get_busy(displayio_epaperdisplay_obj_t* uint16_t common_hal_displayio_epaperdisplay_get_width(displayio_epaperdisplay_obj_t* self); uint16_t common_hal_displayio_epaperdisplay_get_height(displayio_epaperdisplay_obj_t* self); +uint16_t common_hal_displayio_epaperdisplay_get_rotation(displayio_epaperdisplay_obj_t* self); +void common_hal_displayio_epaperdisplay_set_rotation(displayio_epaperdisplay_obj_t* self, int rotation); mp_obj_t common_hal_displayio_epaperdisplay_get_bus(displayio_epaperdisplay_obj_t* self); diff --git a/shared-module/displayio/EPaperDisplay.c b/shared-module/displayio/EPaperDisplay.c index 1b285b4b1d..3fb37ff219 100644 --- a/shared-module/displayio/EPaperDisplay.c +++ b/shared-module/displayio/EPaperDisplay.c @@ -198,6 +198,29 @@ mp_obj_t common_hal_displayio_epaperdisplay_get_bus(displayio_epaperdisplay_obj_ return self->core.bus; } +void common_hal_displayio_epaperdisplay_set_rotation(displayio_epaperdisplay_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); + if (self == &displays[0].epaper_display) { + 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_epaperdisplay_get_rotation(displayio_epaperdisplay_obj_t* self){ + return self->core.rotation; +} + + bool displayio_epaperdisplay_refresh_area(displayio_epaperdisplay_obj_t* self, const displayio_area_t* area) { uint16_t buffer_size = 128; // In uint32_ts From 2463a6d6ac3fb53fa471c77bc585c8ef350d2b96 Mon Sep 17 00:00:00 2001 From: Scott Shawcroft Date: Wed, 18 Nov 2020 16:28:21 -0800 Subject: [PATCH 067/207] Fix Palette grayscale for EInk. It needs to do the bitmasking that was only added to ColorConverter in #3611 --- shared-module/displayio/Palette.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/shared-module/displayio/Palette.c b/shared-module/displayio/Palette.c index facb1fa732..ba5ff665c9 100644 --- a/shared-module/displayio/Palette.c +++ b/shared-module/displayio/Palette.c @@ -83,7 +83,8 @@ bool displayio_palette_get_color(displayio_palette_t *self, const _displayio_col uint8_t pixel_hue = self->colors[palette_index].hue; displayio_colorconverter_compute_tricolor(colorspace, pixel_hue, luma, color); } else if (colorspace->grayscale) { - *color = self->colors[palette_index].luma >> (8 - colorspace->depth); + size_t bitmask = (1 << colorspace->depth) - 1; + *color = (self->colors[palette_index].luma >> colorspace->grayscale_bit) & bitmask; } else { uint16_t packed = self->colors[palette_index].rgb565; if (colorspace->reverse_bytes_in_word) { From 081aec44290cdacc2a28cf8b5c01d34c3d681d93 Mon Sep 17 00:00:00 2001 From: Scott Shawcroft Date: Wed, 18 Nov 2020 16:39:34 -0800 Subject: [PATCH 068/207] Retry connection when getting NOT_AUTHED I saw it once with a correct password. Retrying may still fail but at least it'll try first. --- ports/esp32s2/common-hal/wifi/__init__.c | 1 + 1 file changed, 1 insertion(+) diff --git a/ports/esp32s2/common-hal/wifi/__init__.c b/ports/esp32s2/common-hal/wifi/__init__.c index 2eb3719b4d..70f1d98cba 100644 --- a/ports/esp32s2/common-hal/wifi/__init__.c +++ b/ports/esp32s2/common-hal/wifi/__init__.c @@ -59,6 +59,7 @@ static void event_handler(void* arg, esp_event_base_t event_base, ESP_EARLY_LOGW(TAG, "reason %d 0x%02x", reason, reason); if (radio->retries_left > 0 && (reason == WIFI_REASON_AUTH_EXPIRE || + reason == WIFI_REASON_NOT_AUTHED || reason == WIFI_REASON_ASSOC_EXPIRE || reason == WIFI_REASON_CONNECTION_FAIL || reason == WIFI_REASON_4WAY_HANDSHAKE_TIMEOUT)) { From b98835a1d787f3d1e20eb29bf65ca8cf41d9abf0 Mon Sep 17 00:00:00 2001 From: hexthat Date: Wed, 18 Nov 2020 01:12:46 +0000 Subject: [PATCH 069/207] Translated using Weblate (Chinese (Pinyin)) Currently translated at 100.0% (848 of 848 strings) Translation: CircuitPython/main Translate-URL: https://hosted.weblate.org/projects/circuitpython/main/zh_Latn/ --- locale/zh_Latn_pinyin.po | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/locale/zh_Latn_pinyin.po b/locale/zh_Latn_pinyin.po index dd44aab939..e94ae8173f 100644 --- a/locale/zh_Latn_pinyin.po +++ b/locale/zh_Latn_pinyin.po @@ -7,7 +7,7 @@ msgstr "" "Project-Id-Version: circuitpython-cn\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2020-11-10 15:30+0530\n" -"PO-Revision-Date: 2020-11-15 16:28+0000\n" +"PO-Revision-Date: 2020-11-19 01:28+0000\n" "Last-Translator: hexthat \n" "Language-Team: Chinese Hanyu Pinyin\n" "Language: zh_Latn_pinyin\n" @@ -1012,7 +1012,7 @@ msgstr "Huǎnchōng qū dàxiǎo bù zhèngquè" #: ports/esp32s2/common-hal/watchdog/WatchDogTimer.c msgid "Initialization failed due to lack of memory" -msgstr "" +msgstr "yóu yú nèi cún bù zú, chū shǐ huà shī bài" #: ports/atmel-samd/common-hal/pulseio/PulseIn.c msgid "Input taking too long" @@ -3661,7 +3661,7 @@ msgstr "xiàngliàng bìxū jùyǒu xiāngtóng de chángdù" #: ports/esp32s2/common-hal/watchdog/WatchDogTimer.c msgid "watchdog not initialized" -msgstr "" +msgstr "wèi chū shǐ huà jiān shì qì" #: shared-bindings/watchdog/WatchDogTimer.c msgid "watchdog timeout must be greater than 0" From b9bec87f2930787cb1d2f3baea8284985a0062d5 Mon Sep 17 00:00:00 2001 From: Scott Shawcroft Date: Wed, 18 Nov 2020 17:38:06 -0800 Subject: [PATCH 070/207] Update build board info. * Don't add full urls because they are too large. * Remove the unstable version when it starts with the current version. --- tools/build_board_info.py | 135 +++++++++++++++++++------------------- 1 file changed, 69 insertions(+), 66 deletions(-) diff --git a/tools/build_board_info.py b/tools/build_board_info.py index f83282ea9d..ce9d45fe2f 100644 --- a/tools/build_board_info.py +++ b/tools/build_board_info.py @@ -19,20 +19,24 @@ import shared_bindings_matrix sys.path.append("adabot") import adabot.github_requests as github -SUPPORTED_PORTS = ["atmel-samd", "cxd56", "esp32s2", "litex", "mimxrt10xx", "nrf", "stm"] +SUPPORTED_PORTS = [ + "atmel-samd", + "cxd56", + "esp32s2", + "litex", + "mimxrt10xx", + "nrf", + "stm", +] -BIN = ('bin',) -UF2 = ('uf2',) -BIN_UF2 = ('bin', 'uf2') -HEX = ('hex',) -HEX_UF2 = ('hex', 'uf2') -SPK = ('spk',) -DFU = ('dfu',) -BIN_DFU = ('bin', 'dfu') - -# Example: -# https://downloads.circuitpython.org/bin/trinket_m0/en_US/adafruit-circuitpython-trinket_m0-en_US-5.0.0-rc.0.uf2 -DOWNLOAD_BASE_URL = "https://downloads.circuitpython.org/bin" +BIN = ("bin",) +UF2 = ("uf2",) +BIN_UF2 = ("bin", "uf2") +HEX = ("hex",) +HEX_UF2 = ("hex", "uf2") +SPK = ("spk",) +DFU = ("dfu",) +BIN_DFU = ("bin", "dfu") # Default extensions extension_by_port = { @@ -42,7 +46,7 @@ extension_by_port = { "cxd56": SPK, "mimxrt10xx": HEX_UF2, "litex": DFU, - "esp32s2": BIN_UF2 + "esp32s2": BIN_UF2, } # Per board overrides @@ -57,26 +61,28 @@ extension_by_board = { "feather_m0_rfm69": BIN_UF2, "feather_m0_rfm9x": BIN_UF2, "uchip": BIN_UF2, - # nRF52840 dev kits that may not have UF2 bootloaders, "makerdiary_nrf52840_mdk": HEX, "makerdiary_nrf52840_mdk_usb_dongle": HEX_UF2, "pca10056": BIN_UF2, "pca10059": BIN_UF2, "electronut_labs_blip": HEX, - # stm32 - "meowbit_v121": UF2 + "meowbit_v121": UF2, } aliases_by_board = { - "circuitplayground_express": ["circuitplayground_express_4h", "circuitplayground_express_digikey_pycon2019"], + "circuitplayground_express": [ + "circuitplayground_express_4h", + "circuitplayground_express_digikey_pycon2019", + ], "pybadge": ["edgebadge"], "pyportal": ["pyportal_pynt"], "gemma_m0": ["gemma_m0_pycon2018"], - "pewpew10": ["pewpew13"] + "pewpew10": ["pewpew13"], } + def get_languages(): languages = [] for f in os.scandir("../locale"): @@ -84,6 +90,7 @@ def get_languages(): languages.append(f.name[:-3]) return languages + def get_board_mapping(): boards = {} for port in SUPPORTED_PORTS: @@ -95,23 +102,30 @@ def get_board_mapping(): extensions = extension_by_port[port] extensions = extension_by_board.get(board_path.name, extensions) aliases = aliases_by_board.get(board_path.name, []) - boards[board_id] = {"port": port, - "extensions": extensions, - "download_count": 0, - "aliases": aliases} + boards[board_id] = { + "port": port, + "extensions": extensions, + "download_count": 0, + "aliases": aliases, + } for alias in aliases: - boards[alias] = {"port": port, - "extensions": extensions, - "download_count": 0, - "alias": True, - "aliases": []} + boards[alias] = { + "port": port, + "extensions": extensions, + "download_count": 0, + "alias": True, + "aliases": [], + } return boards + def get_version_info(): version = None sha = git("rev-parse", "--short", "HEAD").stdout.decode("utf-8") try: - version = git("describe", "--tags", "--exact-match").stdout.decode("utf-8").strip() + version = ( + git("describe", "--tags", "--exact-match").stdout.decode("utf-8").strip() + ) except sh.ErrorReturnCode_128: # No exact match pass @@ -120,10 +134,11 @@ def get_version_info(): sha = os.environ["GITHUB_SHA"] if not version: - version="{}-{}".format(date.today().strftime("%Y%m%d"), sha[:7]) + version = "{}-{}".format(date.today().strftime("%Y%m%d"), sha[:7]) return sha, version + def get_current_info(): response = github.get("/repos/adafruit/circuitpython-org/git/refs/heads/master") if not response.ok: @@ -131,7 +146,9 @@ def get_current_info(): raise RuntimeError("cannot get master sha") commit_sha = response.json()["object"]["sha"] - response = github.get("/repos/adafruit/circuitpython-org/contents/_data/files.json?ref=" + commit_sha) + response = github.get( + "/repos/adafruit/circuitpython-org/contents/_data/files.json?ref=" + commit_sha + ) if not response.ok: print(response.text) raise RuntimeError("cannot get previous files.json") @@ -145,6 +162,7 @@ def get_current_info(): current_info[info["id"]] = info return git_info, current_info + def create_pr(changes, updated, git_info, user): commit_sha, original_blob_sha = git_info branch_name = "new_release_" + changes["new_release"] @@ -158,7 +176,7 @@ def create_pr(changes, updated, git_info, user): updated_list.append(info) updated = json.dumps(updated_list, sort_keys=True, indent=1).encode("utf-8") + b"\n" - #print(updated.decode("utf-8")) + # print(updated.decode("utf-8")) pr_title = "Automated website update for release {}".format(changes["new_release"]) boards = "" if changes["new_boards"]: @@ -167,16 +185,13 @@ def create_pr(changes, updated, git_info, user): if changes["new_languages"]: languages = "New languages:\n* " + "\n* ".join(changes["new_languages"]) message = "Automated website update for release {} by Blinka.\n\n{}\n\n{}\n".format( - changes["new_release"], - boards, - languages + changes["new_release"], boards, languages ) - create_branch = { - "ref": "refs/heads/" + branch_name, - "sha": commit_sha - } - response = github.post("/repos/{}/circuitpython-org/git/refs".format(user), json=create_branch) + create_branch = {"ref": "refs/heads/" + branch_name, "sha": commit_sha} + response = github.post( + "/repos/{}/circuitpython-org/git/refs".format(user), json=create_branch + ) if not response.ok and response.json()["message"] != "Reference already exists": print("unable to create branch") print(response.text) @@ -186,10 +201,13 @@ def create_pr(changes, updated, git_info, user): "message": message, "content": base64.b64encode(updated).decode("utf-8"), "sha": original_blob_sha, - "branch": branch_name + "branch": branch_name, } - response = github.put("/repos/{}/circuitpython-org/contents/_data/files.json".format(user), json=update_file) + response = github.put( + "/repos/{}/circuitpython-org/contents/_data/files.json".format(user), + json=update_file, + ) if not response.ok: print("unable to post new file") print(response.text) @@ -199,7 +217,7 @@ def create_pr(changes, updated, git_info, user): "head": user + ":" + branch_name, "base": "master", "body": message, - "maintainer_can_modify": True + "maintainer_can_modify": True, } response = github.post("/repos/adafruit/circuitpython-org/pulls", json=pr_info) if not response.ok: @@ -220,17 +238,14 @@ def print_active_user(): print("Not logged in") return None + def generate_download_info(): boards = {} errors = [] new_tag = os.environ["RELEASE_TAG"] - changes = { - "new_release": new_tag, - "new_boards": [], - "new_languages": [] - } + changes = {"new_release": new_tag, "new_boards": [], "new_languages": []} user = print_active_user() @@ -254,8 +269,9 @@ def generate_download_info(): info = current_info[board] for version in info["versions"]: previous_releases.add(version["version"]) - previous_languages.update(version["files"].keys()) - if version["stable"] == new_stable: + if version["stable"] == new_stable or ( + new_stable and version["version"].startswith(this_version) + ): info["versions"].remove(version) board_mapping = get_board_mapping() @@ -272,29 +288,15 @@ def generate_download_info(): alias_info = board_mapping[alias] if alias not in current_info: changes["new_boards"].append(alias) - current_info[alias] = {"downloads": 0, - "versions": []} + current_info[alias] = {"downloads": 0, "versions": []} new_version = { "stable": new_stable, "version": new_tag, "modules": support_matrix.get(alias, "[]"), - "files": {}, "languages": languages, - "extensions": board_info["extensions"] + "extensions": board_info["extensions"], } - for language in languages: - files = [] - new_version["files"][language] = files - for extension in board_info["extensions"]: - files.append( - "{base_url}/{alias}/{language}/adafruit-circuitpython-{alias}-{language}-{tag}.{extension}" - .format( - base_url=DOWNLOAD_BASE_URL, - tag=new_tag, - alias=alias, - language=language, - extension=extension)) current_info[alias]["downloads"] = alias_info["download_count"] current_info[alias]["versions"].append(new_version) @@ -305,6 +307,7 @@ def generate_download_info(): else: print("No new release to update") + if __name__ == "__main__": if "RELEASE_TAG" in os.environ and os.environ["RELEASE_TAG"]: generate_download_info() From 9a642fc0490c22b60460bcca8dec3b0b93344d81 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Wed, 18 Nov 2020 20:37:26 -0600 Subject: [PATCH 071/207] samd21: Enable terse error reporting on resource constrained chip family This reclaims over 1kB of flash space by simplifying certain exception messages. e.g., it will no longer display the requested/actual length when a fixed list/tuple of N items is needed: if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) { mp_raise_ValueError(translate("tuple/list has wrong length")); } else { mp_raise_ValueError_varg(translate("requested length %d but object has length %d"), (int)len, (int)seq_len); Other chip families including samd51 keep their current error reporting capabilities. --- ports/atmel-samd/mpconfigport.h | 1 + py/circuitpy_mpconfig.h | 2 ++ 2 files changed, 3 insertions(+) diff --git a/ports/atmel-samd/mpconfigport.h b/ports/atmel-samd/mpconfigport.h index ed10da9b9d..3069def33b 100644 --- a/ports/atmel-samd/mpconfigport.h +++ b/ports/atmel-samd/mpconfigport.h @@ -42,6 +42,7 @@ #define CIRCUITPY_MCU_FAMILY samd21 #define MICROPY_PY_SYS_PLATFORM "Atmel SAMD21" #define SPI_FLASH_MAX_BAUDRATE 8000000 +#define MICROPY_ERROR_REPORTING (MICROPY_ERROR_REPORTING_TERSE) #define MICROPY_PY_BUILTINS_NOTIMPLEMENTED (0) #define MICROPY_PY_FUNCTION_ATTRS (0) // MICROPY_PY_UJSON depends on MICROPY_PY_IO diff --git a/py/circuitpy_mpconfig.h b/py/circuitpy_mpconfig.h index 85e152670a..4c2e33be01 100644 --- a/py/circuitpy_mpconfig.h +++ b/py/circuitpy_mpconfig.h @@ -64,7 +64,9 @@ #define MICROPY_ENABLE_FINALISER (1) #define MICROPY_ENABLE_GC (1) #define MICROPY_ENABLE_SOURCE_LINE (1) +#ifndef MICROPY_ERROR_REPORTING #define MICROPY_ERROR_REPORTING (MICROPY_ERROR_REPORTING_NORMAL) +#endif #define MICROPY_FLOAT_HIGH_QUALITY_HASH (0) #define MICROPY_FLOAT_IMPL (MICROPY_FLOAT_IMPL_FLOAT) #define MICROPY_GC_ALLOC_THRESHOLD (0) From 682054a2169c108ad69e84acdb53fdd26405077e Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Wed, 18 Nov 2020 20:44:34 -0500 Subject: [PATCH 072/207] WIP: redo API; not compiled yet --- locale/circuitpython.pot | 8 +- ports/esp32s2/mpconfigport.mk | 3 - py/circuitpy_defns.mk | 22 +-- py/circuitpy_mpconfig.h | 32 ----- py/circuitpy_mpconfig.mk | 20 +-- .../{sleep => alarm}/ResetReason.c | 18 +-- .../{sleep => alarm}/ResetReason.h | 9 +- shared-bindings/alarm/__init__.c | 130 ++++++++++++++++++ shared-bindings/alarm/__init__.h | 35 +++++ shared-bindings/alarm/pin/PinAlarm.c | 116 ++++++++++++++++ .../Time.h => alarm/pin/PinAlarm.h} | 22 ++- shared-bindings/alarm/time/DurationAlarm.c | 91 ++++++++++++ shared-bindings/alarm/time/DurationAlarm.h | 34 +++++ shared-bindings/alarm_io/__init__.c | 53 ------- shared-bindings/alarm_io/__init__.h | 17 --- shared-bindings/alarm_time/Time.c | 76 ---------- shared-bindings/alarm_time/__init__.c | 76 ---------- shared-bindings/alarm_time/__init__.h | 15 -- shared-bindings/microcontroller/__init__.c | 1 - shared-bindings/sleep/__init__.c | 112 --------------- shared-bindings/sleep/__init__.h | 9 -- 21 files changed, 445 insertions(+), 454 deletions(-) rename shared-bindings/{sleep => alarm}/ResetReason.c (79%) rename shared-bindings/{sleep => alarm}/ResetReason.h (83%) create mode 100644 shared-bindings/alarm/__init__.c create mode 100644 shared-bindings/alarm/__init__.h create mode 100644 shared-bindings/alarm/pin/PinAlarm.c rename shared-bindings/{alarm_time/Time.h => alarm/pin/PinAlarm.h} (64%) create mode 100644 shared-bindings/alarm/time/DurationAlarm.c create mode 100644 shared-bindings/alarm/time/DurationAlarm.h delete mode 100644 shared-bindings/alarm_io/__init__.c delete mode 100644 shared-bindings/alarm_io/__init__.h delete mode 100644 shared-bindings/alarm_time/Time.c delete mode 100644 shared-bindings/alarm_time/__init__.c delete mode 100644 shared-bindings/alarm_time/__init__.h delete mode 100644 shared-bindings/sleep/__init__.c delete mode 100644 shared-bindings/sleep/__init__.h diff --git a/locale/circuitpython.pot b/locale/circuitpython.pot index 14049eaef7..daeb5c3123 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-11-04 21:18+0530\n" +"POT-Creation-Date: 2020-11-19 00:22-0500\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -303,7 +303,8 @@ msgstr "" msgid "All I2C peripherals are in use" msgstr "" -#: ports/esp32s2/peripherals/pcnt_handler.c +#: ports/esp32s2/common-hal/countio/Counter.c +#: ports/esp32s2/common-hal/rotaryio/IncrementalEncoder.c msgid "All PCNT units in use" msgstr "" @@ -3221,6 +3222,7 @@ msgstr "" msgid "pow() with 3 arguments requires integers" msgstr "" +#: ports/esp32s2/boards/adafruit_magtag_2.9_grayscale/mpconfigboard.h #: ports/esp32s2/boards/adafruit_metro_esp32s2/mpconfigboard.h #: ports/esp32s2/boards/electroniccats_bastwifi/mpconfigboard.h #: ports/esp32s2/boards/espressif_kaluga_1/mpconfigboard.h @@ -3328,7 +3330,7 @@ msgstr "" msgid "size is defined for ndarrays only" msgstr "" -#: shared-bindings/alarm_time/__init__.c shared-bindings/time/__init__.c +#: shared-bindings/time/__init__.c msgid "sleep length must be non-negative" msgstr "" diff --git a/ports/esp32s2/mpconfigport.mk b/ports/esp32s2/mpconfigport.mk index af1db2b2bf..dea5d4dc18 100644 --- a/ports/esp32s2/mpconfigport.mk +++ b/ports/esp32s2/mpconfigport.mk @@ -15,9 +15,6 @@ LONGINT_IMPL = MPZ # These modules are implemented in ports//common-hal: CIRCUITPY_FULL_BUILD = 1 CIRCUITPY_ALARM = 1 -CIRCUITPY_ALARM_IO = 1 -CIRCUITPY_ALARM_TIME = 1 -CIRCUITPY_ALARM_TOUCH = 1 CIRCUITPY_AUDIOBUSIO = 0 CIRCUITPY_AUDIOIO = 0 CIRCUITPY_CANIO = 1 diff --git a/py/circuitpy_defns.mk b/py/circuitpy_defns.mk index d6c0f995ec..dd36c9457f 100644 --- a/py/circuitpy_defns.mk +++ b/py/circuitpy_defns.mk @@ -102,15 +102,6 @@ endif ifeq ($(CIRCUITPY_ALARM),1) SRC_PATTERNS += alarm/% endif -ifeq ($(CIRCUITPY_ALARM_IO),1) -SRC_PATTERNS += alarm_io/% -endif -ifeq ($(CIRCUITPY_ALARM_TIME),1) -SRC_PATTERNS += alarm_time/% -endif -ifeq ($(CIRCUITPY_ALARM_TOUCH),1) -SRC_PATTERNS += alarm_touch/% -endif ifeq ($(CIRCUITPY_ANALOGIO),1) SRC_PATTERNS += analogio/% endif @@ -247,9 +238,6 @@ endif ifeq ($(CIRCUITPY_SHARPDISPLAY),1) SRC_PATTERNS += sharpdisplay/% endif -ifeq ($(CIRCUITPY_SLEEP),1) -SRC_PATTERNS += sleep/% -endif ifeq ($(CIRCUITPY_SOCKETPOOL),1) SRC_PATTERNS += socketpool/% endif @@ -314,9 +302,9 @@ SRC_COMMON_HAL_ALL = \ _pew/PewPew.c \ _pew/__init__.c \ alarm/__init__.c \ - alarm_io/__init__.c \ - alarm_time/__init__.c \ - alarm_touch/__init__.c \ + alarm/pin/__init__.c \ + alarm/time/__init__.c \ + alarm/touch/__init__.c \ analogio/AnalogIn.c \ analogio/AnalogOut.c \ analogio/__init__.c \ @@ -372,8 +360,8 @@ SRC_COMMON_HAL_ALL = \ rtc/__init__.c \ sdioio/SDCard.c \ sdioio/__init__.c \ - sleep/__init__.c \ - sleep/ResetReason.c \ + sleepio/__init__.c \ + sleepio/ResetReason.c \ socketpool/__init__.c \ socketpool/SocketPool.c \ socketpool/Socket.c \ diff --git a/py/circuitpy_mpconfig.h b/py/circuitpy_mpconfig.h index b31cef8071..b5e9faa26e 100644 --- a/py/circuitpy_mpconfig.h +++ b/py/circuitpy_mpconfig.h @@ -250,27 +250,6 @@ extern const struct _mp_obj_module_t alarm_module; #define ALARM_MODULE #endif -#if CIRCUITPY_ALARM_IO -extern const struct _mp_obj_module_t alarm_io_module; -#define ALARM_IO_MODULE { MP_OBJ_NEW_QSTR(MP_QSTR_alarm_io), (mp_obj_t)&alarm_io_module }, -#else -#define ALARM_IO_MODULE -#endif - -#if CIRCUITPY_ALARM_TIME -extern const struct _mp_obj_module_t alarm_time_module; -#define ALARM_TIME_MODULE { MP_OBJ_NEW_QSTR(MP_QSTR_alarm_time), (mp_obj_t)&alarm_time_module }, -#else -#define ALARM_TIME_MODULE -#endif - -#if CIRCUITPY_ALARM_TOUCH -extern const struct _mp_obj_module_t alarm_touch_module; -#define ALARM_TOUCH_MODULE { MP_OBJ_NEW_QSTR(MP_QSTR_alarm_touch), (mp_obj_t)&alarm_touch_module }, -#else -#define ALARM_TOUCH_MODULE -#endif - #if CIRCUITPY_ANALOGIO #define ANALOGIO_MODULE { MP_OBJ_NEW_QSTR(MP_QSTR_analogio), (mp_obj_t)&analogio_module }, extern const struct _mp_obj_module_t analogio_module; @@ -642,13 +621,6 @@ extern const struct _mp_obj_module_t sharpdisplay_module; #define SHARPDISPLAY_MODULE #endif -#if CIRCUITPY_SLEEP -extern const struct _mp_obj_module_t sleep_module; -#define SLEEP_MODULE { MP_OBJ_NEW_QSTR(MP_QSTR_sleep),(mp_obj_t)&sleep_module }, -#else -#define SLEEP_MODULE -#endif - #if CIRCUITPY_SOCKETPOOL extern const struct _mp_obj_module_t socketpool_module; #define SOCKETPOOL_MODULE { MP_OBJ_NEW_QSTR(MP_QSTR_socketpool), (mp_obj_t)&socketpool_module }, @@ -807,9 +779,6 @@ extern const struct _mp_obj_module_t wifi_module; #define MICROPY_PORT_BUILTIN_MODULES_STRONG_LINKS \ AESIO_MODULE \ ALARM_MODULE \ - ALARM_IO_MODULE \ - ALARM_TIME_MODULE \ - ALARM_TOUCH_MODULE \ ANALOGIO_MODULE \ AUDIOBUSIO_MODULE \ AUDIOCORE_MODULE \ @@ -862,7 +831,6 @@ extern const struct _mp_obj_module_t wifi_module; SDCARDIO_MODULE \ SDIOIO_MODULE \ SHARPDISPLAY_MODULE \ - SLEEP_MODULE \ SOCKETPOOL_MODULE \ SSL_MODULE \ STAGE_MODULE \ diff --git a/py/circuitpy_mpconfig.mk b/py/circuitpy_mpconfig.mk index c47e3755ba..6192ee8a7a 100644 --- a/py/circuitpy_mpconfig.mk +++ b/py/circuitpy_mpconfig.mk @@ -39,18 +39,15 @@ CFLAGS += -DMICROPY_PY_ASYNC_AWAIT=$(MICROPY_PY_ASYNC_AWAIT) CIRCUITPY_AESIO ?= 0 CFLAGS += -DCIRCUITPY_AESIO=$(CIRCUITPY_AESIO) +# TODO: CIRCUITPY_ALARM will gradually be added to +# as many ports as possible +# so make this 1 or CIRCUITPY_FULL_BUILD eventually +CIRCUITPY_SLEEPIO ?= 0 +CFLAGS += -DCIRCUITPY_SLEEPIO=$(CIRCUITPY_SLEEPIO) + CIRCUITPY_ALARM ?= 0 CFLAGS += -DCIRCUITPY_ALARM=$(CIRCUITPY_ALARM) -CIRCUITPY_ALARM_IO ?= 0 -CFLAGS += -DCIRCUITPY_ALARM_IO=$(CIRCUITPY_ALARM_IO) - -CIRCUITPY_ALARM_TIME ?= 0 -CFLAGS += -DCIRCUITPY_ALARM_TIME=$(CIRCUITPY_ALARM_TIME) - -CIRCUITPY_ALARM_TOUCH ?= 0 -CFLAGS += -DCIRCUITPY_ALARM_TOUCH=$(CIRCUITPY_ALARM_TOUCH) - CIRCUITPY_ANALOGIO ?= 1 CFLAGS += -DCIRCUITPY_ANALOGIO=$(CIRCUITPY_ANALOGIO) @@ -221,11 +218,6 @@ CFLAGS += -DCIRCUITPY_SDIOIO=$(CIRCUITPY_SDIOIO) CIRCUITPY_SHARPDISPLAY ?= $(CIRCUITPY_FRAMEBUFFERIO) CFLAGS += -DCIRCUITPY_SHARPDISPLAY=$(CIRCUITPY_SHARPDISPLAY) -# TODO: CIRCUITPY_SLEEP will gradually be added to all ports -# even if it doesn't actually sleep, so make this 1 eventually. -CIRCUITPY_SLEEP ?= 0 -CFLAGS += -DCIRCUITPY_SLEEP=$(CIRCUITPY_SLEEP) - CIRCUITPY_SOCKETPOOL ?= $(CIRCUITPY_WIFI) CFLAGS += -DCIRCUITPY_SOCKETPOOL=$(CIRCUITPY_SOCKETPOOL) diff --git a/shared-bindings/sleep/ResetReason.c b/shared-bindings/alarm/ResetReason.c similarity index 79% rename from shared-bindings/sleep/ResetReason.c rename to shared-bindings/alarm/ResetReason.c index cce55a81a5..456715a08e 100644 --- a/shared-bindings/sleep/ResetReason.c +++ b/shared-bindings/alarm/ResetReason.c @@ -26,12 +26,12 @@ #include "py/enum.h" -#include "shared-bindings/sleep/ResetReason.h" +#include "shared-bindings/alarm/ResetReason.h" -MAKE_ENUM_VALUE(sleep_reset_reason_type, reset_reason, POWER_VALID, RESET_REASON_POWER_VALID); -MAKE_ENUM_VALUE(sleep_reset_reason_type, reset_reason, SOFTWARE, RESET_REASON_SOFTWARE); -MAKE_ENUM_VALUE(sleep_reset_reason_type, reset_reason, DEEP_SLEEP_ALARM, RESET_REASON_DEEP_SLEEP_ALARM); -MAKE_ENUM_VALUE(sleep_reset_reason_type, reset_reason, EXTERNAL, RESET_REASON_EXTERNAL); +MAKE_ENUM_VALUE(alarm_reset_reason_type, reset_reason, POWER_VALID, RESET_REASON_POWER_VALID); +MAKE_ENUM_VALUE(alarm_reset_reason_type, reset_reason, SOFTWARE, RESET_REASON_SOFTWARE); +MAKE_ENUM_VALUE(alarm_reset_reason_type, reset_reason, DEEP_SLEEP_ALARM, RESET_REASON_DEEP_SLEEP_ALARM); +MAKE_ENUM_VALUE(alarm_reset_reason_type, reset_reason, EXTERNAL, RESET_REASON_EXTERNAL); //| class ResetReason: //| """The reason the chip was last reset""" @@ -48,14 +48,14 @@ MAKE_ENUM_VALUE(sleep_reset_reason_type, reset_reason, EXTERNAL, RESET_REASON_EX //| EXTERNAL: object //| """The chip was reset by an external input such as a button.""" //| -MAKE_ENUM_MAP(sleep_reset_reason) { +MAKE_ENUM_MAP(alarm_reset_reason) { MAKE_ENUM_MAP_ENTRY(reset_reason, POWER_VALID), MAKE_ENUM_MAP_ENTRY(reset_reason, SOFTWARE), MAKE_ENUM_MAP_ENTRY(reset_reason, DEEP_SLEEP_ALARM), MAKE_ENUM_MAP_ENTRY(reset_reason, EXTERNAL), }; -STATIC MP_DEFINE_CONST_DICT(sleep_reset_reason_locals_dict, sleep_reset_reason_locals_table); +STATIC MP_DEFINE_CONST_DICT(alarm_reset_reason_locals_dict, alarm_reset_reason_locals_table); -MAKE_PRINTER(sleep, sleep_reset_reason); +MAKE_PRINTER(alarm, alarm_reset_reason); -MAKE_ENUM_TYPE(sleep, ResetReason, sleep_reset_reason); +MAKE_ENUM_TYPE(alarm, ResetReason, alarm_reset_reason); diff --git a/shared-bindings/sleep/ResetReason.h b/shared-bindings/alarm/ResetReason.h similarity index 83% rename from shared-bindings/sleep/ResetReason.h rename to shared-bindings/alarm/ResetReason.h index 2b312bb897..6fe7a4bd31 100644 --- a/shared-bindings/sleep/ResetReason.h +++ b/shared-bindings/alarm/ResetReason.h @@ -24,13 +24,16 @@ * THE SOFTWARE. */ -#pragma once +#ifndef MICROPY_INCLUDED_SHARED_BINDINGS_ALARM__RESET_REASON__H +#define MICROPY_INCLUDED_SHARED_BINDINGS_ALARM__RESET_REASON__H typedef enum { RESET_REASON_POWER_APPLIED, RESET_REASON_SOFTWARE, RESET_REASON_DEEP_SLEEP_ALARM, RESET_REASON_BUTTON, -} sleep_reset_reason_t; +} alarm_reset_reason_t; -extern const mp_obj_type_t sleep_reset_reason_type; +extern const mp_obj_type_t alarm_reset_reason_type; + +#endif // MICROPY_INCLUDED_SHARED_BINDINGS_ALARM__RESET_REASON__H diff --git a/shared-bindings/alarm/__init__.c b/shared-bindings/alarm/__init__.c new file mode 100644 index 0000000000..20535e156b --- /dev/null +++ b/shared-bindings/alarm/__init__.c @@ -0,0 +1,130 @@ +//| """Power-saving light and deep sleep. Alarms can be set to wake up from sleep. +//| +//| The `alarm` module provides sleep related functionality. There are two supported levels of +//| sleep, light and deep. +//| +//| Light sleep leaves the CPU and RAM powered so that CircuitPython can resume where it left off +//| after being woken up. CircuitPython automatically goes into a light sleep when `time.sleep()` is +//| called. To light sleep until a non-time alarm use `alarm.sleep_until_alarm()`. Any active +//| peripherals, such as I2C, are left on. +//| +//| Deep sleep shuts down power to nearly all of the chip including the CPU and RAM. This can save +//| a more significant amount of power, but CircuitPython must start ``code.py`` from the beginning when woken +//| up. CircuitPython will enter deep sleep automatically when the current program exits without error +//| or calls `sys.exit(0)`. +//| If an error causes CircuitPython to exit, error LED error flashes will be done periodically. +//| An error includes an uncaught exception, or sys.exit called with a non-zero argumetn. +//| To set alarms for deep sleep use `alarm.reload_on_alarm()` they will apply to next deep sleep only.""" +//| + +//| wake_alarm: Alarm +//| """The most recent alarm to wake us up from a sleep (light or deep.)""" +//| + +//| reset_reason: ResetReason +//| """The reason the chip started up from reset state. This can may be power up or due to an alarm.""" +//| + +//| def sleep(alarm: Alarm, ...) -> Alarm: +//| """Performs a light sleep until woken by one of the alarms. The alarm that triggers the wake +//| is returned, and is also available as `alarm.wake_alarm` +//| ... +//| + +#include "py/obj.h" +#include "py/runtime.h" + +#include "shared-bindings/alarm/pin/__init__.h" +#include "shared-bindings/alarm/time/__init__.h" + +STATIC mp_obj_t alarm_sleep_until_alarm(size_t n_args, const mp_obj_t *args) { + // TODO +} +MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(alarm_sleep_until_alarm_obj, 1, MP_OBJ_FUN_ARGS_MAX, alarm_sleep_until_alarm); + +//| def restart_on_alarm(alarm: Alarm, ...) -> None: +//| """Set one or more alarms to wake up from a deep sleep. +//| When awakened, ``code.py`` will restart from the beginning. +//| The last alarm to wake us up is available as `wake_alarm`. +//| """ +//| ... +//| +STATIC mp_obj_t alarm_restart_on_alarm(size_t n_args, const mp_obj_t *args) { + // TODO +} +MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(alarm_restart_on_alarm_obj, 1, MP_OBJ_FUN_ARGS_MAX, alarm_restart_on_alarm); + +//| """The `alarm.pin` module contains alarm attributes and classes related to pins +//| """ +//| +mp_map_elem_t alarm_pin_globals_table[] = { + { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_pin) }, + + { MP_ROM_QSTR(MP_QSTR_PinAlarm), MP_ROM_PTR(&alarm_pin_pin_alarm_type) }, +}; + +STATIC MP_DEFINE_CONST_DICT(alarm_pin_globals, alarm_pin_globals_table); + +const mp_obj_module_t alarm_pin_module = { + .base = { &mp_type_module }, + .globals = (mp_obj_dict_t*)&alarm_pinn_globals, +}; + +//| """The `alarm.time` module contains alarm attributes and classes related to time-keeping. +//| """ +//| +mp_map_elem_t alarm_time_globals_table[] = { + { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_time) }, + + { MP_ROM_QSTR(MP_QSTR_DurationAlarm), MP_ROM_PTR(&alarm_time_duration_alarm_type) }, +}; + +STATIC MP_DEFINE_CONST_DICT(alarm_time_globals, alarm_time_globals_table); + +const mp_obj_module_t alarm_time_module = { + .base = { &mp_type_module }, + .globals = (mp_obj_dict_t*)&alarm_time_globals, +}; + +mp_map_elem_t alarm_module_globals_table[] = { + { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_alarm) }, + + // wake_alarm and reset_reason are mutable attributes. + { MP_ROM_QSTR(MP_QSTR_wake_alarm), mp_const_none }, + { MP_ROM_QSTR(MP_QSTR_reset_reason), mp_const_none }, + + { MP_ROM_QSTR(MP_QSTR_sleep_until_alarm), MP_ROM_PTR(&alarm_sleep_until_alarm_obj) }, + { MP_ROM_QSTR(MP_QSTR_restart_on_alarm), MP_ROM_PTR(&alarm_restart_on_alarm_obj) }, + + { MP_ROM_QSTR(MP_QSTR_pin), MP_ROM_PTR(&alarm_pin_module) }, + { MP_ROM_QSTR(MP_QSTR_time), MP_ROM_PTR(&alarm_time_module) } + +}; +STATIC MP_DEFINE_MUTABLE_DICT(alarm_module_globals, alarm_module_globals_table); + +// These are called from common_hal code to set the current wake alarm. +void common_hal_alarm_set_wake_alarm(mp_obj_t alarm) { + // Equivalent of: + // alarm.wake_alarm = alarm + mp_map_elem_t *elem = + mp_map_lookup(&alarm_module_globals_table, MP_ROM_QSTR(MP_QSTR_wake_alarm), MP_MAP_LOOKUP); + if (elem) { + elem->value = alarm; + } +} + +// These are called from common hal code to set the current wake alarm. +void common_hal_alarm_set_reset_reason(mp_obj_t reset_reason) { + // Equivalent of: + // alarm.reset_reason = reset_reason + mp_map_elem_t *elem = + mp_map_lookup(&alarm_module_globals_table, MP_ROM_QSTR(MP_QSTR_reset_reason), MP_MAP_LOOKUP); + if (elem) { + elem->value = reset_reason; + } +} + +const mp_obj_module_t alarm_module = { + .base = { &mp_type_module }, + .globals = (mp_obj_dict_t*)&alarm_module_globals, +}; diff --git a/shared-bindings/alarm/__init__.h b/shared-bindings/alarm/__init__.h new file mode 100644 index 0000000000..ce9cc79f40 --- /dev/null +++ b/shared-bindings/alarm/__init__.h @@ -0,0 +1,35 @@ +/* + * 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_SHARED_BINDINGS_ALARM___INIT___H +#define MICROPY_INCLUDED_SHARED_BINDINGS_ALARM___INIT___H + +#include "py/obj.h" + +extern void common_hal_alarm_set_wake_alarm(mp_obj_t alarm); +extern void common_hal_alarm_set_reset_reason(mp_obj_t reset_reason); + +#endif // MICROPY_INCLUDED_SHARED_BINDINGS_ALARM___INIT___H diff --git a/shared-bindings/alarm/pin/PinAlarm.c b/shared-bindings/alarm/pin/PinAlarm.c new file mode 100644 index 0000000000..1404fa3f41 --- /dev/null +++ b/shared-bindings/alarm/pin/PinAlarm.c @@ -0,0 +1,116 @@ +/* + * 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 "shared-bindings/board/__init__.h" +#include "shared-bindings/microcontroller/__init__.h" +#include "shared-bindings/microcontroller/Pin.h" + +#include "py/nlr.h" +#include "py/obj.h" +#include "py/runtime.h" +#include "supervisor/shared/translate.h" + +//| class PinAlarm: +//| """Trigger an alarm when a pin changes state. +//| +//| def __init__(self, pin: microcontroller.Pin, level: bool, *, edge: bool = False, pull: bool = False) -> None: +//| """Create an alarm triggered by a `~microcontroller.Pin` level. The alarm is not active +//| until it is listed in an `alarm`-enabling function, such as `alarm.sleep()` or +//| `alarm.wake_after_exit()`. + +//| :param ~microcontroller.Pin pin: The pin to monitor. On some ports, the choice of pin +//| may be limited due to hardware restrictions, particularly for deep-sleep alarms. +//| :param bool level: When active, trigger when the level is high (``True``) or low (``False``). +//| On some ports, multiple `PinAlarm` objects may need to have coordinated levels +//| for deep-sleep alarms +//| :param bool edge: If ``True``, trigger only when there is a transition to the specified +//| value of `level`. If ``True``, if the alarm becomes active when the pin level already +//| matches `level`, the alarm is not triggered: the pin must transition from ``not level`` +//| to ``level`` to trigger the alarm. On some ports, edge-triggering may not be available, +//| particularly for deep-sleep alarms. +//| :param bool pull: Enable a pull-up or pull-down which pulls the pin to level opposite +//| opposite that of `level`. For instance, if `level` is set to ``True``, setting `pull` +//| to ``True`` will enable a pull-down, to hold the pin low normally until an outside signal +//| pulls it high. +//| """ +//| ... +//| +STATIC mp_obj_t alarm_pin_pin_alarm_make_new(const mp_obj_type_t *type, + mp_uint_t n_args, const mp_obj_t *args, mp_map_t *kw_args) { + alarm_pin_pin_alarm_obj_t *self = m_new_obj(alarm_pin_pin_alarm_obj_t); + self->base.type = &alarm_pin_pin_alarm_type; + enum { ARG_pin, ARG_level, ARG_edge, ARG_pull }; + static const mp_arg_t allowed_args[] = { + { MP_QSTR_pin, MP_ARG_REQUIRED | MP_ARG_OBJ }, + { MP_QSTR_level, MP_ARG_REQUIRED | MP_ARG_BOOL }, + { MP_QSTR_edge, MP_ARG_KW_ONLY | MP_ARG_BOOL, {.u_bool = false} }, + { MP_QSTR_pull, 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); + + const mcu_pin_obj_t* pin = validate_obj_is_free_pin(args[ARG_pin].u_obj); + + common_hal_alarm_pin_pin_pin_alarm_construct( + self, pin, args[ARG_level].u_bool, args[ARG_edge].u_bool, args[ARG_pull].u_bool); + + return MP_OBJ_FROM_PTR(self); +} + +//| def __eq__(self, other: object) -> bool: +//| """Two PinAlarm objects are equal if their durations are the same if their pin, +//| level, edge, and pull attributes are all the same.""" +//| ... +//| +STATIC mp_obj_t alarm_pin_pin_alarm_binary_op(mp_binary_op_t op, mp_obj_t lhs_in, mp_obj_t rhs_in) { + switch (op) { + case MP_BINARY_OP_EQUAL: + if (MP_OBJ_IS_TYPE(rhs_in, &alarm_pin_pin_alarm_type)) { + // Pins are singletons, so we can compare them directly. + return mp_obj_new_bool( + common_hal_pin_pin_alarm_get_pin(lhs_in) == common_hal_pin_pin_alarm_get_pin(rhs_in) && + common_hal_pin_pin_alarm_get_level(lhs_in) == common_hal_pin_pin_alarm_get_level(rhs_in) && + common_hal_pin_pin_alarm_get_edge(lhs_in) == common_hal_pin_pin_alarm_get_edge(rhs_in) && + common_hal_pin_pin_alarm_get_pull(lhs_in) == common_hal_pin_pin_alarm_get_pull(rhs_in)) + } + return mp_const_false; + + default: + return MP_OBJ_NULL; // op not supported + } +} + +STATIC const mp_rom_map_elem_t alarm_pin_pin_alarm_locals_dict_table[] = { +}; + +STATIC MP_DEFINE_CONST_DICT(alarm_pin_pin_alarm_locals, alarm_pin_pin_alarm_locals_dict); + +const mp_obj_type_t alarm_pin_pin_alarm_type = { + { &mp_type_type }, + .name = MP_QSTR_PinAlarm, + .make_new = alarm_pin_pin_alarm_make_new, + .locals_dict = (mp_obj_t)&alarm_pin_pin_alarm_locals, +}; diff --git a/shared-bindings/alarm_time/Time.h b/shared-bindings/alarm/pin/PinAlarm.h similarity index 64% rename from shared-bindings/alarm_time/Time.h rename to shared-bindings/alarm/pin/PinAlarm.h index 9962c26f25..e38c7f620c 100644 --- a/shared-bindings/alarm_time/Time.h +++ b/shared-bindings/alarm/pin/PinAlarm.h @@ -1,9 +1,9 @@ /* - * This file is part of the Micro Python project, http://micropython.org/ + * This file is part of the MicroPython project, http://micropython.org/ * * The MIT License (MIT) * - * Copyright (c) 2020 Scott Shawcroft for Adafruit Industries + * 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 @@ -24,19 +24,13 @@ * THE SOFTWARE. */ -#ifndef MICROPY_INCLUDED_SHARED_BINDINGS_ALARM_TIME_TIME_H -#define MICROPY_INCLUDED_SHARED_BINDINGS_ALARM_TIME_TIME_H +#ifndef MICROPY_INCLUDED_SHARED_BINDINGS_ALARM_PIN_PIN_ALARM_H +#define MICROPY_INCLUDED_SHARED_BINDINGS_ALARM_PIN_PIN_ALARM_H -#include "py/runtime.h" +#include "py/obj.h" -typedef struct { - mp_obj_base_t base; - uint64_t time_to_alarm; -} alarm_time_time_obj_t; +extern const mp_obj_type_t alarm_pin_pin_alarm_type; -extern const mp_obj_type_t alarm_time_time_type; +extern void common_hal_alarm_pin_pin_pin_alarm_construct(alarm_pin_pin_alarm_obj_t *self, const mcu_pin_obj_t *pin, bool level, bool edge, bool pull); -void common_hal_alarm_time_time_construct(alarm_time_time_obj_t* self, - uint64_t ticks_ms); - -#endif //MICROPY_INCLUDED_SHARED_BINDINGS_ALARM_TIME_TIME_H +#endif // MICROPY_INCLUDED_SHARED_BINDINGS_ALARM_PIN_PIN_ALARM_H diff --git a/shared-bindings/alarm/time/DurationAlarm.c b/shared-bindings/alarm/time/DurationAlarm.c new file mode 100644 index 0000000000..c30c7f326c --- /dev/null +++ b/shared-bindings/alarm/time/DurationAlarm.c @@ -0,0 +1,91 @@ +/* + * 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 "shared-bindings/board/__init__.h" +#include "shared-bindings/microcontroller/__init__.h" +#include "shared-bindings/microcontroller/Pin.h" + +#include "py/nlr.h" +#include "py/obj.h" +#include "py/runtime.h" +#include "supervisor/shared/translate.h" + +//| class DurationAlarm: +//| """Trigger an alarm at a specified interval from now. +//| +//| def __init__(self, secs: float) -> None: +//| """Create an alarm that will be triggered in `secs` seconds **from the time +//| the alarm is created**. The alarm is not active until it is listed in an +//| `alarm`-enabling function, such as `alarm.sleep()` or +//| `alarm.wake_after_exit()`. But the interval starts immediately upon +//| instantiation. +//| """ +//| ... +//| +STATIC mp_obj_t alarm_time_duration_alarm_make_new(const mp_obj_type_t *type, + mp_uint_t n_args, const mp_obj_t *args, mp_map_t *kw_args) { + mp_arg_check_num(n_args, kw_args, 1, 1, false); + + alarm_pin_duration_alarm_obj_t *self = m_new_obj(alarm_pin_duration_alarm_obj_t); + self->base.type = &alarm_pin_pin_alarm_type; + + mp_float_t secs = mp_obj_get_float(args[0]); + + common_hal_alarm_time_duration_alarm_construct(self, secs); + + return MP_OBJ_FROM_PTR(self); +} + +//| def __eq__(self, other: object) -> bool: +//| """Two DurationAlarm objects are equal if their durations are the same.""" +//| ... +//| +STATIC mp_obj_t alarm_time_duration_alarm_binary_op(mp_binary_op_t op, mp_obj_t lhs_in, mp_obj_t rhs_in) { + switch (op) { + case MP_BINARY_OP_EQUAL: + if (MP_OBJ_IS_TYPE(rhs_in, &alarm_time_duration_alarm_type)) { + return mp_obj_new_bool( + common_hal_alarm_time_duration_alarm_get_duration(lhs_in) == + common_hal_alarm_time_duration_alarm_get_duration(rhs_in)); + } + return mp_const_false; + + default: + return MP_OBJ_NULL; // op not supported + } +} + +STATIC const mp_rom_map_elem_t alarm_time_duration_alarm_locals_dict_table[] = { +}; + +STATIC MP_DEFINE_CONST_DICT(alarm_time_duration_alarm_locals_dict, alarm_time_duration_alarm_locals_dict_table); + +const mp_obj_type_t alarm_time_duration_alarm_type = { + { &mp_type_type }, + .name = MP_QSTR_DurationAlarm, + .make_new = alarm_time_duration_alarm_make_new, + .locals_dict = (mp_obj_t)&alarm_time_duration_alarm_locals, +}; diff --git a/shared-bindings/alarm/time/DurationAlarm.h b/shared-bindings/alarm/time/DurationAlarm.h new file mode 100644 index 0000000000..1e4db6ac53 --- /dev/null +++ b/shared-bindings/alarm/time/DurationAlarm.h @@ -0,0 +1,34 @@ +/* + * 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_SHARED_BINDINGS_ALARM_TIME_DURATION_ALARM_H +#define MICROPY_INCLUDED_SHARED_BINDINGS_ALARM_TIME_DURATION_ALARM_H + +#include "py/obj.h" + +extern const mp_obj_type_t alarm_time_duration_alarm_type; + +#endif // MICROPY_INCLUDED_SHARED_BINDINGS_ALARM_TIME_DURATION_ALARM_H diff --git a/shared-bindings/alarm_io/__init__.c b/shared-bindings/alarm_io/__init__.c deleted file mode 100644 index 4e42f9a2e1..0000000000 --- a/shared-bindings/alarm_io/__init__.c +++ /dev/null @@ -1,53 +0,0 @@ -#include "py/obj.h" - -#include "shared-bindings/alarm_io/__init__.h" -#include "shared-bindings/microcontroller/Pin.h" - -//| """alarm_io module -//| -//| The `alarm_io` module implements deep sleep.""" - -STATIC mp_obj_t alarm_io_pin_state(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { - enum { ARG_level, ARG_pull }; - static const mp_arg_t allowed_args[] = { - { MP_QSTR_level, MP_ARG_INT | MP_ARG_KW_ONLY | MP_ARG_REQUIRED }, - { MP_QSTR_pull, MP_ARG_INT | MP_ARG_KW_ONLY, {.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); - - mcu_pin_obj_t *pin = validate_obj_is_pin(pos_args[0]); - alarm_io_obj_t *self = m_new_obj(alarm_io_obj_t); - - self->base.type = &alarm_io_type; - self->gpio = pin->number; - self->level = args[ARG_level].u_int; - self->pull = args[ARG_pull].u_bool; - - return common_hal_alarm_io_pin_state(self); -} -STATIC MP_DEFINE_CONST_FUN_OBJ_KW(alarm_io_pin_state_obj, 1, alarm_io_pin_state); - -STATIC mp_obj_t alarm_io_disable(void) { - common_hal_alarm_io_disable(); - return mp_const_none; -} -STATIC MP_DEFINE_CONST_FUN_OBJ_0(alarm_io_disable_obj, alarm_io_disable); - -STATIC const mp_rom_map_elem_t alarm_io_module_globals_table[] = { - { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_alarm_io) }, - { MP_OBJ_NEW_QSTR(MP_QSTR_PinState), MP_ROM_PTR(&alarm_io_pin_state_obj) }, - { MP_OBJ_NEW_QSTR(MP_QSTR_Disable), MP_ROM_PTR(&alarm_io_disable_obj) }, -}; -STATIC MP_DEFINE_CONST_DICT(alarm_io_module_globals, alarm_io_module_globals_table); - -const mp_obj_module_t alarm_io_module = { - .base = { &mp_type_module }, - .globals = (mp_obj_dict_t*)&alarm_io_module_globals, -}; - -const mp_obj_type_t alarm_io_type = { - { &mp_type_type }, - .name = MP_QSTR_ioAlarm, -}; diff --git a/shared-bindings/alarm_io/__init__.h b/shared-bindings/alarm_io/__init__.h deleted file mode 100644 index 0a53497c01..0000000000 --- a/shared-bindings/alarm_io/__init__.h +++ /dev/null @@ -1,17 +0,0 @@ -#ifndef MICROPY_INCLUDED_SHARED_BINDINGS_ALARM_IO___INIT___H -#define MICROPY_INCLUDED_SHARED_BINDINGS_ALARM_IO___INIT___H - -#include "py/runtime.h" - -typedef struct { - mp_obj_base_t base; - uint8_t gpio, level; - bool pull; -} alarm_io_obj_t; - -extern const mp_obj_type_t alarm_io_type; - -extern mp_obj_t common_hal_alarm_io_pin_state (alarm_io_obj_t *self_in); -extern void common_hal_alarm_io_disable (void); - -#endif //MICROPY_INCLUDED_SHARED_BINDINGS_ALARM_IO___INIT___H diff --git a/shared-bindings/alarm_time/Time.c b/shared-bindings/alarm_time/Time.c deleted file mode 100644 index 904bf522e2..0000000000 --- a/shared-bindings/alarm_time/Time.c +++ /dev/null @@ -1,76 +0,0 @@ -/* - * This file is part of the MicroPython project, http://micropython.org/ - * - * The MIT License (MIT) - * - * 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 "shared-bindings/alarm_time/__init__.h" - -//| """alarm_time module -//| -//| The `alarm_time` module implements deep sleep.""" - -STATIC mp_obj_t alarm_time_duration(mp_obj_t seconds_o) { - #if MICROPY_PY_BUILTINS_FLOAT - mp_float_t seconds = mp_obj_get_float(seconds_o); - mp_float_t msecs = 1000.0f * seconds + 0.5f; - #else - 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_alarm_time_duration(msecs); - - alarm_time_obj_t *self = m_new_obj(alarm_time_obj_t); - self->base.type = &alarm_time_type; - - return self; -} -STATIC MP_DEFINE_CONST_FUN_OBJ_1(alarm_time_duration_obj, alarm_time_duration); - -STATIC mp_obj_t alarm_time_disable(void) { - common_hal_alarm_time_disable(); - return mp_const_none; -} -STATIC MP_DEFINE_CONST_FUN_OBJ_0(alarm_time_disable_obj, alarm_time_disable); - -STATIC const mp_rom_map_elem_t alarm_time_module_globals_table[] = { - { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_alarm_time) }, - { MP_OBJ_NEW_QSTR(MP_QSTR_Duration), MP_ROM_PTR(&alarm_time_duration_obj) }, - { MP_OBJ_NEW_QSTR(MP_QSTR_Disable), MP_ROM_PTR(&alarm_time_disable_obj) }, -}; -STATIC MP_DEFINE_CONST_DICT(alarm_time_module_globals, alarm_time_module_globals_table); - -const mp_obj_module_t alarm_time_module = { - .base = { &mp_type_module }, - .globals = (mp_obj_dict_t*)&alarm_time_module_globals, -}; - -const mp_obj_type_t alarm_time_type = { - { &mp_type_type }, - .name = MP_QSTR_timeAlarm, -}; diff --git a/shared-bindings/alarm_time/__init__.c b/shared-bindings/alarm_time/__init__.c deleted file mode 100644 index 904bf522e2..0000000000 --- a/shared-bindings/alarm_time/__init__.c +++ /dev/null @@ -1,76 +0,0 @@ -/* - * This file is part of the MicroPython project, http://micropython.org/ - * - * The MIT License (MIT) - * - * 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 "shared-bindings/alarm_time/__init__.h" - -//| """alarm_time module -//| -//| The `alarm_time` module implements deep sleep.""" - -STATIC mp_obj_t alarm_time_duration(mp_obj_t seconds_o) { - #if MICROPY_PY_BUILTINS_FLOAT - mp_float_t seconds = mp_obj_get_float(seconds_o); - mp_float_t msecs = 1000.0f * seconds + 0.5f; - #else - 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_alarm_time_duration(msecs); - - alarm_time_obj_t *self = m_new_obj(alarm_time_obj_t); - self->base.type = &alarm_time_type; - - return self; -} -STATIC MP_DEFINE_CONST_FUN_OBJ_1(alarm_time_duration_obj, alarm_time_duration); - -STATIC mp_obj_t alarm_time_disable(void) { - common_hal_alarm_time_disable(); - return mp_const_none; -} -STATIC MP_DEFINE_CONST_FUN_OBJ_0(alarm_time_disable_obj, alarm_time_disable); - -STATIC const mp_rom_map_elem_t alarm_time_module_globals_table[] = { - { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_alarm_time) }, - { MP_OBJ_NEW_QSTR(MP_QSTR_Duration), MP_ROM_PTR(&alarm_time_duration_obj) }, - { MP_OBJ_NEW_QSTR(MP_QSTR_Disable), MP_ROM_PTR(&alarm_time_disable_obj) }, -}; -STATIC MP_DEFINE_CONST_DICT(alarm_time_module_globals, alarm_time_module_globals_table); - -const mp_obj_module_t alarm_time_module = { - .base = { &mp_type_module }, - .globals = (mp_obj_dict_t*)&alarm_time_module_globals, -}; - -const mp_obj_type_t alarm_time_type = { - { &mp_type_type }, - .name = MP_QSTR_timeAlarm, -}; diff --git a/shared-bindings/alarm_time/__init__.h b/shared-bindings/alarm_time/__init__.h deleted file mode 100644 index a963830693..0000000000 --- a/shared-bindings/alarm_time/__init__.h +++ /dev/null @@ -1,15 +0,0 @@ -#ifndef MICROPY_INCLUDED_SHARED_BINDINGS_ALARM_TIME___INIT___H -#define MICROPY_INCLUDED_SHARED_BINDINGS_ALARM_TIME___INIT___H - -#include "py/runtime.h" - -typedef struct { - mp_obj_base_t base; -} alarm_time_obj_t; - -extern const mp_obj_type_t alarm_time_type; - -extern void common_hal_alarm_time_duration (uint32_t); -extern void common_hal_alarm_time_disable (void); - -#endif //MICROPY_INCLUDED_SHARED_BINDINGS_ALARM_TIME___INIT___H diff --git a/shared-bindings/microcontroller/__init__.c b/shared-bindings/microcontroller/__init__.c index bbc1640f76..bfeb812d67 100644 --- a/shared-bindings/microcontroller/__init__.c +++ b/shared-bindings/microcontroller/__init__.c @@ -160,7 +160,6 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_0(mcu_sleep_obj, mcu_sleep); //| //| .. module:: microcontroller.pin //| :synopsis: Microcontroller pin names -//| :platform: SAMD21 //| //| References to pins as named by the microcontroller""" //| diff --git a/shared-bindings/sleep/__init__.c b/shared-bindings/sleep/__init__.c deleted file mode 100644 index a714e00213..0000000000 --- a/shared-bindings/sleep/__init__.c +++ /dev/null @@ -1,112 +0,0 @@ -/* - * This file is part of the MicroPython project, http://micropython.org/ - * - * The MIT License (MIT) - * - * 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 "shared-bindings/alarm/__init__.h" - -//| """Light and deep sleep used to save power -//| -//| The `sleep` module provides sleep related functionality. There are two supported levels of -//| sleep, light and deep. -//| -//| Light sleep leaves the CPU and RAM powered so that CircuitPython can resume where it left off -//| after being woken up. Light sleep is automatically done by CircuitPython when `time.sleep()` is -//| called. To light sleep until a non-time alarm use `sleep.sleep_until_alarm()`. Any active -//| peripherals, such as I2C, are left on. -//| -//| Deep sleep shuts down power to nearly all of the chip including the CPU and RAM. This can save -//| a more significant amount of power, but CircuitPython must start code.py from the beginning when woken -//| up. CircuitPython will enter deep sleep automatically when the current program exits without error -//| or calls `sys.exit(0)`. -//| If an error causes CircuitPython to exit, error LED error flashes will be done periodically. -//| An error includes an uncaught exception, or sys.exit called with a non-zero argumetn. -//| To set alarms for deep sleep use `sleep.restart_on_alarm()` they will apply to next deep sleep only.""" -//| - -//| wake_alarm: Alarm -//| """The most recent alarm to wake us up from a sleep (light or deep.)""" -//| - -//| reset_reason: ResetReason -//| """The reason the chip started up from reset state. This can may be power up or due to an alarm.""" -//| - -//| def sleep_until_alarm(alarm: Alarm, ...) -> Alarm: -//| """Performs a light sleep until woken by one of the alarms. The alarm that woke us up is -//| returned.""" -//| ... -//| - -STATIC mp_obj_t sleep_sleep_until_alarm(size_t n_args, const mp_obj_t *args) { -} -MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(sleep_sleep_until_alarm_obj, 1, MP_OBJ_FUN_ARGS_MAX, sleep_sleep_until_alarm); - -//| def restart_on_alarm(alarm: Alarm, ...) -> None: -//| """Set one or more alarms to wake up from a deep sleep. When awakened, ``code.py`` will restart -//| from the beginning. The last alarm to wake us up is available as `wake_alarm`. """ -//| ... -//| -STATIC mp_obj_t sleep_restart_on_alarm(size_t n_args, const mp_obj_t *args) { -} -MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(sleep_restart_on_alarm_obj, 1, MP_OBJ_FUN_ARGS_MAX, sleep_restart_on_alarm); - - -mp_map_elem_t sleep_module_globals_table[] = { - { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_sleep) }, - - { MP_ROM_QSTR(MP_QSTR_wake_alarm), mp_const_none }, - { MP_ROM_QSTR(MP_QSTR_reset_reason), mp_const_none }, - - { MP_ROM_QSTR(MP_QSTR_sleep_until_alarm), sleep_sleep_until_alarm_obj }, - { MP_ROM_QSTR(MP_QSTR_restart_on_alarm), sleep_restart_on_alarm_obj }, -}; -STATIC MP_DEFINE_MUTABLE_DICT(sleep_module_globals, sleep_module_globals_table); - -// These are called from common hal code to set the current wake alarm. -void common_hal_sleep_set_wake_alarm(mp_obj_t alarm) { - // Equivalent of: - // sleep.wake_alarm = alarm - mp_map_elem_t *elem = - mp_map_lookup(&sleep_module_globals_table, MP_ROM_QSTR(MP_QSTR_wake_alarm), MP_MAP_LOOKUP); - if (elem) { - elem->value = alarm; - } -} - -// These are called from common hal code to set the current wake alarm. -void common_hal_sleep_set_reset_reason(mp_obj_t reset_reason) { - // Equivalent of: - // sleep.reset_reason = reset_reason - mp_map_elem_t *elem = - mp_map_lookup(&sleep_module_globals_table, MP_ROM_QSTR(MP_QSTR_reset_reason), MP_MAP_LOOKUP); - if (elem) { - elem->value = reset_reason; - } -} - -const mp_obj_module_t sleep_module = { - .base = { &mp_type_module }, - .globals = (mp_obj_dict_t*)&sleep_module_globals, -}; diff --git a/shared-bindings/sleep/__init__.h b/shared-bindings/sleep/__init__.h deleted file mode 100644 index cd23ba5e49..0000000000 --- a/shared-bindings/sleep/__init__.h +++ /dev/null @@ -1,9 +0,0 @@ -#ifndef MICROPY_INCLUDED_SHARED_BINDINGS_SLEEP___INIT___H -#define MICROPY_INCLUDED_SHARED_BINDINGS_SLEEP___INIT___H - -#include "py/obj.h" - -extern mp_obj_t common_hal_sleep_get_wake_alarm(void); -extern sleep_reset_reason_t common_hal_sleep_get_reset_reason(void); - -#endif // MICROPY_INCLUDED_SHARED_BINDINGS_SLEEPxs___INIT___H From b56645808c88cca22a42cb66ed7b3ddc8383436a Mon Sep 17 00:00:00 2001 From: microDev <70126934+microDev1@users.noreply.github.com> Date: Thu, 19 Nov 2020 11:44:22 +0530 Subject: [PATCH 073/207] fix crash on user code exit --- ports/esp32s2/common-hal/ps2io/Ps2.c | 6 ++++-- ports/esp32s2/common-hal/ps2io/Ps2.h | 2 ++ ports/esp32s2/supervisor/port.c | 5 +++++ shared-bindings/ps2io/Ps2.c | 5 +++-- 4 files changed, 14 insertions(+), 4 deletions(-) diff --git a/ports/esp32s2/common-hal/ps2io/Ps2.c b/ports/esp32s2/common-hal/ps2io/Ps2.c index 9c19ea950e..56199f4cbf 100644 --- a/ports/esp32s2/common-hal/ps2io/Ps2.c +++ b/ports/esp32s2/common-hal/ps2io/Ps2.c @@ -26,9 +26,7 @@ #include "common-hal/ps2io/Ps2.h" -#include "py/runtime.h" #include "supervisor/port.h" -#include "shared-bindings/ps2io/Ps2.h" #include "shared-bindings/microcontroller/__init__.h" #define STATE_IDLE 0 @@ -259,6 +257,10 @@ void common_hal_ps2io_ps2_deinit(ps2io_ps2_obj_t* self) { self->data_pin = GPIO_NUM_MAX; } +void ps2_reset(void) { + gpio_uninstall_isr_service(); +} + uint16_t common_hal_ps2io_ps2_get_len(ps2io_ps2_obj_t* self) { return self->bufcount; } diff --git a/ports/esp32s2/common-hal/ps2io/Ps2.h b/ports/esp32s2/common-hal/ps2io/Ps2.h index eb93829b46..497952b250 100644 --- a/ports/esp32s2/common-hal/ps2io/Ps2.h +++ b/ports/esp32s2/common-hal/ps2io/Ps2.h @@ -55,4 +55,6 @@ typedef struct { uint8_t cmd_response; } ps2io_ps2_obj_t; +void ps2_reset(void); + #endif // MICROPY_INCLUDED_ESP32S2_COMMON_HAL_PS2IO_PS2_H diff --git a/ports/esp32s2/supervisor/port.c b/ports/esp32s2/supervisor/port.c index 47d0c7f463..f66a8511ad 100644 --- a/ports/esp32s2/supervisor/port.c +++ b/ports/esp32s2/supervisor/port.c @@ -41,6 +41,7 @@ #include "common-hal/busio/I2C.h" #include "common-hal/busio/SPI.h" #include "common-hal/busio/UART.h" +#include "common-hal/ps2io/Ps2.h" #include "common-hal/pulseio/PulseIn.h" #include "common-hal/pwmio/PWMOut.h" #include "common-hal/watchdog/WatchDogTimer.h" @@ -104,6 +105,10 @@ void reset_port(void) { analogout_reset(); #endif +#if CIRCUITPY_PS2IO + ps2_reset(); +#endif + #if CIRCUITPY_PULSEIO esp32s2_peripherals_rmt_reset(); pulsein_reset(); diff --git a/shared-bindings/ps2io/Ps2.c b/shared-bindings/ps2io/Ps2.c index 0977e08ff7..07fa5cebb9 100644 --- a/shared-bindings/ps2io/Ps2.c +++ b/shared-bindings/ps2io/Ps2.c @@ -116,8 +116,9 @@ STATIC void check_for_deinit(ps2io_ps2_obj_t *self) { //| ... //| STATIC mp_obj_t ps2io_ps2_obj___exit__(size_t n_args, const mp_obj_t *args) { - (void)n_args; - common_hal_ps2io_ps2_deinit(args[0]); + mp_check_self(MP_OBJ_IS_TYPE(args[0], &ps2io_ps2_type)); + ps2io_ps2_obj_t *self = MP_OBJ_TO_PTR(args[0]); + common_hal_ps2io_ps2_deinit(self); return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(ps2io_ps2___exit___obj, 4, 4, ps2io_ps2_obj___exit__); From 040eaa044344562ec1f9905d67b612ea2ec12949 Mon Sep 17 00:00:00 2001 From: microDev <70126934+microDev1@users.noreply.github.com> Date: Thu, 19 Nov 2020 15:30:15 +0530 Subject: [PATCH 074/207] re-organize and clean-up --- ports/esp32s2/common-hal/ps2io/Ps2.c | 200 +++++++++++++-------------- 1 file changed, 100 insertions(+), 100 deletions(-) diff --git a/ports/esp32s2/common-hal/ps2io/Ps2.c b/ports/esp32s2/common-hal/ps2io/Ps2.c index 56199f4cbf..003f0d827e 100644 --- a/ports/esp32s2/common-hal/ps2io/Ps2.c +++ b/ports/esp32s2/common-hal/ps2io/Ps2.c @@ -48,103 +48,16 @@ #define ERROR_TX_RTS 0x1000 #define ERROR_TX_NORESP 0x2000 -static void IRAM_ATTR ps2_interrupt_handler(void *self_in); - -static void ps2_set_config(ps2io_ps2_obj_t* self) { - // turn on falling edge interrupt - gpio_set_intr_type(self->clk_pin, GPIO_INTR_NEGEDGE); - gpio_install_isr_service(ESP_INTR_FLAG_IRAM); - gpio_isr_handler_add(self->clk_pin, ps2_interrupt_handler, (void*)self); -} - -static void disable_interrupt(ps2io_ps2_obj_t* self) { - // turn off fallling edge interrupt - gpio_isr_handler_remove(self->clk_pin); -} - -static void resume_interrupt(ps2io_ps2_obj_t* self) { - self->state = STATE_IDLE; - gpio_isr_handler_add(self->clk_pin, ps2_interrupt_handler, (void*)self); -} - -static void clk_hi(ps2io_ps2_obj_t* self) { - // external pull-up - gpio_set_direction(self->clk_pin, GPIO_MODE_INPUT); - gpio_pullup_dis(self->clk_pin); -} - -static bool wait_clk_lo(ps2io_ps2_obj_t* self, uint32_t us) { - clk_hi(self); - common_hal_mcu_delay_us(1); - while (gpio_get_level(self->clk_pin) && us) { - --us; - common_hal_mcu_delay_us(1); - } - return us; -} - -static bool wait_clk_hi(ps2io_ps2_obj_t* self, uint32_t us) { - clk_hi(self); - common_hal_mcu_delay_us(1); - while (!gpio_get_level(self->clk_pin) && us) { - --us; - common_hal_mcu_delay_us(1); - } - return us; -} - -static void clk_lo(ps2io_ps2_obj_t* self) { - gpio_pullup_dis(self->clk_pin); - gpio_set_direction(self->clk_pin, GPIO_MODE_OUTPUT); - gpio_set_level(self->clk_pin, 0); -} - -static void data_hi(ps2io_ps2_obj_t* self) { - // external pull-up - gpio_set_direction(self->data_pin, GPIO_MODE_INPUT); - gpio_pullup_dis(self->data_pin); -} - -static bool wait_data_lo(ps2io_ps2_obj_t* self, uint32_t us) { - data_hi(self); - common_hal_mcu_delay_us(1); - while (gpio_get_level(self->data_pin) && us) { - --us; - common_hal_mcu_delay_us(1); - } - return us; -} - -static bool wait_data_hi(ps2io_ps2_obj_t* self, uint32_t us) { - data_hi(self); - common_hal_mcu_delay_us(1); - while (!gpio_get_level(self->data_pin) && us) { - --us; - common_hal_mcu_delay_us(1); - } - return us; -} - -static void data_lo(ps2io_ps2_obj_t* self) { - gpio_pullup_dis(self->data_pin); - gpio_set_direction(self->data_pin, GPIO_MODE_OUTPUT); - gpio_set_level(self->data_pin, 0); -} - -static void idle(ps2io_ps2_obj_t* self) { - clk_hi(self); - data_hi(self); -} - -static void inhibit(ps2io_ps2_obj_t* self) { - clk_lo(self); - data_hi(self); +void ps2_reset(void) { + gpio_uninstall_isr_service(); } static void delay_us(uint32_t t) { common_hal_mcu_delay_us(t); } +/* interrupt handling */ + static void IRAM_ATTR ps2_interrupt_handler(void *self_in) { // Grab the current time first. uint64_t current_tick = port_get_raw_ticks(NULL); @@ -222,11 +135,99 @@ static void IRAM_ATTR ps2_interrupt_handler(void *self_in) { } } -void common_hal_ps2io_ps2_construct(ps2io_ps2_obj_t* self, - const mcu_pin_obj_t* data_pin, const mcu_pin_obj_t* clk_pin) { +static void enable_interrupt(ps2io_ps2_obj_t* self) { + // turn on falling edge interrupt + gpio_install_isr_service(ESP_INTR_FLAG_IRAM); + gpio_set_intr_type(self->clk_pin, GPIO_INTR_NEGEDGE); + gpio_isr_handler_add(self->clk_pin, ps2_interrupt_handler, (void*)self); +} + +static void disable_interrupt(ps2io_ps2_obj_t* self) { + // turn off fallling edge interrupt + gpio_isr_handler_remove(self->clk_pin); +} + +static void resume_interrupt(ps2io_ps2_obj_t* self) { + self->state = STATE_IDLE; + gpio_isr_handler_add(self->clk_pin, ps2_interrupt_handler, (void*)self); +} + +/* gpio handling */ + +static void clk_hi(ps2io_ps2_obj_t* self) { + // external pull-up + gpio_set_direction(self->clk_pin, GPIO_MODE_INPUT); +} + +static bool wait_clk_lo(ps2io_ps2_obj_t* self, uint32_t us) { + clk_hi(self); + delay_us(1); + while (gpio_get_level(self->clk_pin) && us) { + --us; + delay_us(1); + } + return us; +} + +static bool wait_clk_hi(ps2io_ps2_obj_t* self, uint32_t us) { + clk_hi(self); + delay_us(1); + while (!gpio_get_level(self->clk_pin) && us) { + --us; + delay_us(1); + } + return us; +} + +static void clk_lo(ps2io_ps2_obj_t* self) { + gpio_set_direction(self->clk_pin, GPIO_MODE_OUTPUT); + gpio_set_level(self->clk_pin, 0); +} + +static void data_hi(ps2io_ps2_obj_t* self) { + // external pull-up + gpio_set_direction(self->data_pin, GPIO_MODE_INPUT); +} + +static bool wait_data_lo(ps2io_ps2_obj_t* self, uint32_t us) { + data_hi(self); + delay_us(1); + while (gpio_get_level(self->data_pin) && us) { + --us; + delay_us(1); + } + return us; +} + +static bool wait_data_hi(ps2io_ps2_obj_t* self, uint32_t us) { + data_hi(self); + delay_us(1); + while (!gpio_get_level(self->data_pin) && us) { + --us; + delay_us(1); + } + return us; +} + +static void data_lo(ps2io_ps2_obj_t* self) { + gpio_set_direction(self->data_pin, GPIO_MODE_OUTPUT); + gpio_set_level(self->data_pin, 0); +} + +static void idle(ps2io_ps2_obj_t* self) { clk_hi(self); data_hi(self); +} +static void inhibit(ps2io_ps2_obj_t* self) { + clk_lo(self); + data_hi(self); +} + +/* ps2io module functions */ + +void common_hal_ps2io_ps2_construct(ps2io_ps2_obj_t* self, + const mcu_pin_obj_t* data_pin, const mcu_pin_obj_t* clk_pin) { self->clk_pin = (gpio_num_t)clk_pin->number; self->data_pin = (gpio_num_t)data_pin->number; self->state = STATE_IDLE; @@ -235,11 +236,11 @@ void common_hal_ps2io_ps2_construct(ps2io_ps2_obj_t* self, self->bufposw = 0; self->waiting_cmd_response = false; + idle(self); + enable_interrupt(self); + claim_pin(clk_pin); claim_pin(data_pin); - - // set config will enable the interrupt. - ps2_set_config(self); } bool common_hal_ps2io_ps2_deinited(ps2io_ps2_obj_t* self) { @@ -257,10 +258,6 @@ void common_hal_ps2io_ps2_deinit(ps2io_ps2_obj_t* self) { self->data_pin = GPIO_NUM_MAX; } -void ps2_reset(void) { - gpio_uninstall_isr_service(); -} - uint16_t common_hal_ps2io_ps2_get_len(ps2io_ps2_obj_t* self) { return self->bufcount; } @@ -291,6 +288,8 @@ uint16_t common_hal_ps2io_ps2_clear_errors(ps2io_ps2_obj_t* self) { int16_t common_hal_ps2io_ps2_sendcmd(ps2io_ps2_obj_t* self, uint8_t b) { disable_interrupt(self); + + /* terminate a transmission if we have */ inhibit(self); delay_us(100); @@ -321,6 +320,7 @@ int16_t common_hal_ps2io_ps2_sendcmd(ps2io_ps2_obj_t* self, uint8_t b) { } } + /* Parity bit */ delay_us(15); if (parity) { data_hi(self); From 76d4824728c6dc99d9bfed48a41933fa48c8bbf7 Mon Sep 17 00:00:00 2001 From: Kamil Tomaszewski Date: Thu, 19 Nov 2020 15:04:52 +0100 Subject: [PATCH 075/207] spresense: Return fixed stack --- ports/cxd56/supervisor/port.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/ports/cxd56/supervisor/port.c b/ports/cxd56/supervisor/port.c index 92d335cd59..086c2d198e 100644 --- a/ports/cxd56/supervisor/port.c +++ b/ports/cxd56/supervisor/port.c @@ -98,8 +98,12 @@ void reset_to_bootloader(void) { } } +supervisor_allocation _fixed_stack; + supervisor_allocation* port_fixed_stack(void) { - return NULL; + _fixed_stack.ptr = port_stack_get_limit(); + _fixed_stack.length = (port_stack_get_top() - port_stack_get_limit()) * sizeof(uint32_t); + return &_fixed_stack; } uint32_t *port_stack_get_limit(void) { From dd108b755dc2bb886df14c9fcfcd4f09be61f2d4 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Thu, 19 Nov 2020 11:36:02 -0600 Subject: [PATCH 076/207] esp32s2: initialize event loop ane netif only once deinitting these seems to cause problems. --- ports/esp32s2/common-hal/wifi/__init__.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/ports/esp32s2/common-hal/wifi/__init__.c b/ports/esp32s2/common-hal/wifi/__init__.c index 1b244dd2ff..f53e68fc28 100644 --- a/ports/esp32s2/common-hal/wifi/__init__.c +++ b/ports/esp32s2/common-hal/wifi/__init__.c @@ -88,14 +88,17 @@ static void event_handler(void* arg, esp_event_base_t event_base, } } -static bool wifi_inited; +static bool wifi_inited, wifi_ever_inited; void common_hal_wifi_init(void) { wifi_inited = true; common_hal_wifi_radio_obj.base.type = &wifi_radio_type; - ESP_ERROR_CHECK(esp_netif_init()); - ESP_ERROR_CHECK(esp_event_loop_create_default()); + if (!wifi_ever_inited) { + ESP_ERROR_CHECK(esp_netif_init()); + ESP_ERROR_CHECK(esp_event_loop_create_default()); + } + wifi_ever_inited = true; wifi_radio_obj_t* self = &common_hal_wifi_radio_obj; self->netif = esp_netif_create_default_wifi_sta(); From 331aa6e59fd36b52afb4119068d0baa99c85ea3c Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Thu, 19 Nov 2020 11:43:18 -0600 Subject: [PATCH 077/207] displayio: When the display is tall, move blinka above the text This makes a more useful display on the portrait magtag, allowing 21 characters across instead of just 18. There are 20 full rows of text, instead of 21. The total number of characters increases slightly from 378 to 420. For comparison, the Commodore VIC 20 had 22 rows of 23 characters for a total of 506 characters. :-P --- supervisor/shared/display.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/supervisor/shared/display.c b/supervisor/shared/display.c index afb3f3a9a6..a9ae258842 100644 --- a/supervisor/shared/display.c +++ b/supervisor/shared/display.c @@ -60,18 +60,21 @@ void supervisor_start_terminal(uint16_t width_px, uint16_t height_px) { #if CIRCUITPY_TERMINALIO displayio_tilegrid_t* grid = &supervisor_terminal_text_grid; - uint16_t width_in_tiles = (width_px - blinka_bitmap.width) / grid->tile_width; + bool tall = height_px > width_px; + uint16_t terminal_width_px = tall ? width_px : width_px - blinka_bitmap.width; + uint16_t terminal_height_px = tall ? height_px - blinka_bitmap.height : height_px ; + uint16_t width_in_tiles = terminal_width_px / grid->tile_width; // determine scale based on h if (width_in_tiles < 80) { scale = 1; } - width_in_tiles = (width_px - blinka_bitmap.width * scale) / (grid->tile_width * scale); + width_in_tiles = terminal_width_px / (grid->tile_width * scale); if (width_in_tiles < 1) { width_in_tiles = 1; } - uint16_t height_in_tiles = height_px / (grid->tile_height * scale); - uint16_t remaining_pixels = height_px % (grid->tile_height * scale); + uint16_t height_in_tiles = terminal_height_px / (grid->tile_height * scale); + uint16_t remaining_pixels = tall ? 0 : terminal_height_px % (grid->tile_height * scale); if (height_in_tiles < 1 || remaining_pixels > 0) { height_in_tiles += 1; } @@ -91,7 +94,8 @@ void supervisor_start_terminal(uint16_t width_px, uint16_t height_px) { if (tiles == NULL) { return; } - grid->y = 0; + grid->y = tall ? blinka_bitmap.height : 0; + grid->x = tall ? 0 : blinka_bitmap.width; grid->top_left_y = 0; if (remaining_pixels > 0) { grid->y -= (grid->tile_height - remaining_pixels); From bc9036f35370fcd0e4806c42dd47a8c6bb42a085 Mon Sep 17 00:00:00 2001 From: microDev <70126934+microDev1@users.noreply.github.com> Date: Fri, 20 Nov 2020 00:15:30 +0530 Subject: [PATCH 078/207] use pointer to get nvs handle --- ports/esp32s2/common-hal/nvm/ByteArray.c | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/ports/esp32s2/common-hal/nvm/ByteArray.c b/ports/esp32s2/common-hal/nvm/ByteArray.c index d90f7fbdc2..9f8ced3ec5 100644 --- a/ports/esp32s2/common-hal/nvm/ByteArray.c +++ b/ports/esp32s2/common-hal/nvm/ByteArray.c @@ -27,14 +27,13 @@ #include "common-hal/nvm/ByteArray.h" #include "py/runtime.h" - #include "nvs_flash.h" uint32_t common_hal_nvm_bytearray_get_length(nvm_bytearray_obj_t *self) { return self->len; } -static nvs_handle get_nvs_handle(void) { +static void get_nvs_handle(nvs_handle_t * nvs_handle) { // Initialize NVS esp_err_t err = nvs_flash_init(); if (err == ESP_ERR_NVS_NO_FREE_PAGES || err == ESP_ERR_NVS_NEW_VERSION_FOUND) { @@ -46,32 +45,31 @@ static nvs_handle get_nvs_handle(void) { ESP_ERROR_CHECK(err); // Open NVS handle - nvs_handle nvs_handle; - if (nvs_open("CPY", NVS_READWRITE, &nvs_handle) != ESP_OK) { + if (nvs_open("CPY", NVS_READWRITE, nvs_handle) != ESP_OK) { mp_raise_RuntimeError(translate("NVS Error")); } - return nvs_handle; } bool common_hal_nvm_bytearray_set_bytes(nvm_bytearray_obj_t *self, uint32_t start_index, uint8_t* values, uint32_t len) { char index[9]; - sprintf(index, "%i", start_index - CIRCUITPY_INTERNAL_NVM_START_ADDR); + sprintf(index, "%i", start_index); // start nvs - nvs_handle handle = get_nvs_handle(); + nvs_handle_t handle; + get_nvs_handle(&handle); bool status = ((nvs_set_u8(handle, (const char *)index, *values) == ESP_OK) && (nvs_commit(handle) == ESP_OK)); // close nvs nvs_close(handle); return status; } -// NVM memory is memory mapped so reading it is easy. void common_hal_nvm_bytearray_get_bytes(nvm_bytearray_obj_t *self, uint32_t start_index, uint32_t len, uint8_t* values) { char index[9]; - sprintf(index, "%i", start_index - CIRCUITPY_INTERNAL_NVM_START_ADDR); + sprintf(index, "%i", start_index); // start nvs - nvs_handle handle = get_nvs_handle(); + nvs_handle_t handle; + get_nvs_handle(&handle); if (nvs_get_u8(handle, (const char *)index, values) != ESP_OK) { mp_raise_RuntimeError(translate("NVS Error")); } From a25b27520d077424219832d764e9e59da6759562 Mon Sep 17 00:00:00 2001 From: microDev <70126934+microDev1@users.noreply.github.com> Date: Fri, 20 Nov 2020 00:22:00 +0530 Subject: [PATCH 079/207] update nvm implementation --- ports/esp32s2/common-hal/nvm/ByteArray.c | 40 ++++++++++++++++++++---- 1 file changed, 34 insertions(+), 6 deletions(-) diff --git a/ports/esp32s2/common-hal/nvm/ByteArray.c b/ports/esp32s2/common-hal/nvm/ByteArray.c index 9f8ced3ec5..e304dd8302 100644 --- a/ports/esp32s2/common-hal/nvm/ByteArray.c +++ b/ports/esp32s2/common-hal/nvm/ByteArray.c @@ -26,6 +26,8 @@ #include "common-hal/nvm/ByteArray.h" +#include + #include "py/runtime.h" #include "nvs_flash.h" @@ -53,26 +55,52 @@ static void get_nvs_handle(nvs_handle_t * nvs_handle) { bool common_hal_nvm_bytearray_set_bytes(nvm_bytearray_obj_t *self, uint32_t start_index, uint8_t* values, uint32_t len) { char index[9]; - sprintf(index, "%i", start_index); + + uint8_t buffer[len]; + memcpy(buffer, values, len); + // start nvs nvs_handle_t handle; get_nvs_handle(&handle); - bool status = ((nvs_set_u8(handle, (const char *)index, *values) == ESP_OK) && (nvs_commit(handle) == ESP_OK)); + + // stage flash changes + for (uint32_t i = 0; i < len; i++) { + sprintf(index, "%i", start_index + i); + if (nvs_set_u8(handle, (const char *)index, buffer[i]) != ESP_OK) { + return false; + } + } + + // commit flash changes + if (nvs_commit(handle) != ESP_OK) { + return false; + } + // close nvs nvs_close(handle); - return status; + return true; } void common_hal_nvm_bytearray_get_bytes(nvm_bytearray_obj_t *self, uint32_t start_index, uint32_t len, uint8_t* values) { char index[9]; - sprintf(index, "%i", start_index); + uint8_t buffer[len]; + // start nvs nvs_handle_t handle; get_nvs_handle(&handle); - if (nvs_get_u8(handle, (const char *)index, values) != ESP_OK) { - mp_raise_RuntimeError(translate("NVS Error")); + + // get from flash + for (uint32_t i = 0; i < len; i++) { + sprintf(index, "%i", start_index + i); + if (nvs_get_u8(handle, (const char *)index, &buffer[i]) != ESP_OK) { + mp_raise_RuntimeError(translate("NVS Error")); + } } + + // set into values + memcpy(values, buffer, len); + // close nvs nvs_close(handle); } From 649c9305364f10ea1dc43179e768ec968d0b9ed5 Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Thu, 19 Nov 2020 15:43:39 -0500 Subject: [PATCH 080/207] wip --- main.c | 18 ++++--- ports/esp32s2/common-hal/alarm/pin/PinAlarm.c | 52 +++++++++++++++++++ ports/esp32s2/common-hal/alarm/pin/PinAlarm.h | 36 +++++++++++++ .../{alarm_io => alarm/pin}/__init__.c | 0 .../common-hal/alarm/time/DurationAlarm.c | 48 +++++++++++++++++ .../common-hal/alarm/time/DurationAlarm.h | 34 ++++++++++++ .../esp32s2/common-hal/alarm_time/__init__.c | 13 ----- py/circuitpy_defns.mk | 5 +- py/circuitpy_mpconfig.mk | 3 -- shared-bindings/alarm/ResetReason.c | 24 ++++++--- shared-bindings/alarm/ResetReason.h | 8 ++- shared-bindings/alarm/pin/PinAlarm.c | 12 +++-- shared-bindings/alarm/pin/PinAlarm.h | 5 ++ shared-bindings/alarm/time/DurationAlarm.h | 6 +++ supervisor/shared/rgb_led_status.c | 7 +-- supervisor/shared/rgb_led_status.h | 2 +- supervisor/shared/safe_mode.c | 9 +++- 17 files changed, 234 insertions(+), 48 deletions(-) create mode 100644 ports/esp32s2/common-hal/alarm/pin/PinAlarm.c create mode 100644 ports/esp32s2/common-hal/alarm/pin/PinAlarm.h rename ports/esp32s2/common-hal/{alarm_io => alarm/pin}/__init__.c (100%) create mode 100644 ports/esp32s2/common-hal/alarm/time/DurationAlarm.c create mode 100644 ports/esp32s2/common-hal/alarm/time/DurationAlarm.h delete mode 100644 ports/esp32s2/common-hal/alarm_time/__init__.c diff --git a/main.c b/main.c index a200b62641..251cb00a3f 100755 --- a/main.c +++ b/main.c @@ -63,6 +63,10 @@ #include "boards/board.h" +#if CIRCUITPY_ALARM +#include "shared-bindings/alarm/__init__.h" +#endif + #if CIRCUITPY_DISPLAYIO #include "shared-module/displayio/__init__.h" #endif @@ -88,10 +92,6 @@ #include "common-hal/canio/CAN.h" #endif -#if CIRCUITPY_SLEEP -#include "shared-bindings/sleep/__init__.h" -#endif - void do_str(const char *src, mp_parse_input_kind_t input_kind) { mp_lexer_t *lex = mp_lexer_new_from_str_len(MP_QSTR__lt_stdin_gt_, src, strlen(src), 0); if (lex == NULL) { @@ -320,7 +320,7 @@ bool run_code_py(safe_mode_t safe_mode) { #endif rgb_status_animation_t animation; bool ok = result->return_code != PYEXEC_EXCEPTION; - #if CIRCUITPY_SLEEP + #if CIRCUITPY_ALARM // If USB isn't enumerated then deep sleep. if (ok && !supervisor_workflow_active() && supervisor_ticks_ms64() > CIRCUITPY_USB_ENUMERATION_DELAY * 1024) { common_hal_sleep_deep_sleep(); @@ -361,7 +361,7 @@ bool run_code_py(safe_mode_t safe_mode) { #endif bool animation_done = tick_rgb_status_animation(&animation); if (animation_done && supervisor_workflow_active()) { - #if CIRCUITPY_SLEEP + #if CIRCUITPY_ALARM int64_t remaining_enumeration_wait = CIRCUITPY_USB_ENUMERATION_DELAY * 1024 - supervisor_ticks_ms64(); // If USB isn't enumerated then deep sleep after our waiting period. if (ok && remaining_enumeration_wait < 0) { @@ -423,9 +423,13 @@ void __attribute__ ((noinline)) run_boot_py(safe_mode_t safe_mode) { if (!skip_boot_output) { // Wait 1.5 seconds before opening CIRCUITPY_BOOT_OUTPUT_FILE for write, // in case power is momentary or will fail shortly due to, say a low, battery. - if (common_hal_sleep_get_reset_reason() == RESET_REASON_POWER_VALID) { +#if CIRCUITPY_ALARM + if (common_hal_sleep_get_reset_reason() == RESET_REASON_POWER_ON) { +#endif mp_hal_delay_ms(1500); +#if CIRCUITPY_ALARM } +#endif // USB isn't up, so we can write the file. filesystem_set_internal_writable_by_usb(false); diff --git a/ports/esp32s2/common-hal/alarm/pin/PinAlarm.c b/ports/esp32s2/common-hal/alarm/pin/PinAlarm.c new file mode 100644 index 0000000000..1211406665 --- /dev/null +++ b/ports/esp32s2/common-hal/alarm/pin/PinAlarm.c @@ -0,0 +1,52 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2020 @microDev1 (GitHub) + * 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 "esp_sleep.h" + +#include "shared-bindings/alarm/time/DurationAlarm.h" + +void common_hal_alarm_pin_pin_pin_alarm_construct(alarm_pin_pin_alarm_obj_t *self, mcu_pin_obj_t *pin, bool level, bool edge, bool pull) { + self->pin = pin; + self->level = level; + self->edge = edge; + self->pull = pull; + +mcu_pin_obj_t *common_hal_alarm_pin_pin_alarm_get_pin(alarm_pin_pin_alarm_obj_t *self) { + return self->pin; +} + +bool common_hal_alarm_pin_pin_alarm_get_level(alarm_pin_pin_alarm_obj_t *self) { + return self->level; +} + +bool common_hal_alarm_pin_pin_alarm_get_edge(alarm_pin_pin_alarm_obj_t *self) { + return self->edge; +} + +bool common_hal_alarm_pin_pin_alarm_get_pull(alarm_pin_pin_alarm_obj_t *self) { + return self->pull; +} diff --git a/ports/esp32s2/common-hal/alarm/pin/PinAlarm.h b/ports/esp32s2/common-hal/alarm/pin/PinAlarm.h new file mode 100644 index 0000000000..5273918584 --- /dev/null +++ b/ports/esp32s2/common-hal/alarm/pin/PinAlarm.h @@ -0,0 +1,36 @@ +/* + * 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 "py/obj.h" + +typedef struct { + mp_obj_base_t base; + mcu_pin_obj_t *pin; + bool level; + bool edge; + bool pull; +} alarm_pin_pin_alarm_obj_t; diff --git a/ports/esp32s2/common-hal/alarm_io/__init__.c b/ports/esp32s2/common-hal/alarm/pin/__init__.c similarity index 100% rename from ports/esp32s2/common-hal/alarm_io/__init__.c rename to ports/esp32s2/common-hal/alarm/pin/__init__.c diff --git a/ports/esp32s2/common-hal/alarm/time/DurationAlarm.c b/ports/esp32s2/common-hal/alarm/time/DurationAlarm.c new file mode 100644 index 0000000000..bf1a6cc421 --- /dev/null +++ b/ports/esp32s2/common-hal/alarm/time/DurationAlarm.c @@ -0,0 +1,48 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2020 @microDev1 (GitHub) + * 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 "esp_sleep.h" + +#include "shared-bindings/alarm/time/DurationAlarm.h" + +void common_hal_alarm_time_duration_alarm_construct(alarm_time_duration_alarm_obj_t *self, mp_float_t duration) { + self->duration = duration; +} + +mp_float_t common_hal_alarm_time_duration_alarm_get_duration(alarm_time_duration_alarm_obj_t *self) { + return self->duration; +} +void common_hal_alarm_time_duration_alarm_enable(alarm_time_duration_alarm_obj_t *self) + if (esp_sleep_enable_timer_wakeup((uint64_t) (self->duration * 1000000)) == ESP_ERR_INVALID_ARG) { + mp_raise_ValueError(translate("duration out of range")); + } +} + +void common_hal_alarm_time_duration_alarm_disable (alarm_time_duration_alarm_obj_t *self) { + (void) self; + esp_sleep_disable_wakeup_source(ESP_SLEEP_WAKEUP_TIMER); +} diff --git a/ports/esp32s2/common-hal/alarm/time/DurationAlarm.h b/ports/esp32s2/common-hal/alarm/time/DurationAlarm.h new file mode 100644 index 0000000000..3e81cbac2f --- /dev/null +++ b/ports/esp32s2/common-hal/alarm/time/DurationAlarm.h @@ -0,0 +1,34 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2020 @microDev1 (GitHub) + * 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 "py/obj.h" + +typedef struct { + mp_obj_base_t base; + mp_float_t duration; // seconds +} alarm_time_duration_alarm_obj_t; diff --git a/ports/esp32s2/common-hal/alarm_time/__init__.c b/ports/esp32s2/common-hal/alarm_time/__init__.c deleted file mode 100644 index 252b6e107c..0000000000 --- a/ports/esp32s2/common-hal/alarm_time/__init__.c +++ /dev/null @@ -1,13 +0,0 @@ -#include "esp_sleep.h" - -#include "shared-bindings/alarm_time/__init__.h" - -void common_hal_alarm_time_duration (uint32_t ms) { - if (esp_sleep_enable_timer_wakeup((ms) * 1000) == ESP_ERR_INVALID_ARG) { - mp_raise_ValueError(translate("time out of range")); - } -} - -void common_hal_alarm_time_disable (void) { - esp_sleep_disable_wakeup_source(ESP_SLEEP_WAKEUP_TIMER); -} diff --git a/py/circuitpy_defns.mk b/py/circuitpy_defns.mk index dd36c9457f..dbde1a34d6 100644 --- a/py/circuitpy_defns.mk +++ b/py/circuitpy_defns.mk @@ -302,9 +302,8 @@ SRC_COMMON_HAL_ALL = \ _pew/PewPew.c \ _pew/__init__.c \ alarm/__init__.c \ - alarm/pin/__init__.c \ - alarm/time/__init__.c \ - alarm/touch/__init__.c \ + alarm/pin/PinAlarm.c \ + alarm/time/DurationAlarm.c \ analogio/AnalogIn.c \ analogio/AnalogOut.c \ analogio/__init__.c \ diff --git a/py/circuitpy_mpconfig.mk b/py/circuitpy_mpconfig.mk index 6192ee8a7a..6d555a44b4 100644 --- a/py/circuitpy_mpconfig.mk +++ b/py/circuitpy_mpconfig.mk @@ -42,9 +42,6 @@ CFLAGS += -DCIRCUITPY_AESIO=$(CIRCUITPY_AESIO) # TODO: CIRCUITPY_ALARM will gradually be added to # as many ports as possible # so make this 1 or CIRCUITPY_FULL_BUILD eventually -CIRCUITPY_SLEEPIO ?= 0 -CFLAGS += -DCIRCUITPY_SLEEPIO=$(CIRCUITPY_SLEEPIO) - CIRCUITPY_ALARM ?= 0 CFLAGS += -DCIRCUITPY_ALARM=$(CIRCUITPY_ALARM) diff --git a/shared-bindings/alarm/ResetReason.c b/shared-bindings/alarm/ResetReason.c index 456715a08e..c46b2ba8f1 100644 --- a/shared-bindings/alarm/ResetReason.c +++ b/shared-bindings/alarm/ResetReason.c @@ -28,7 +28,7 @@ #include "shared-bindings/alarm/ResetReason.h" -MAKE_ENUM_VALUE(alarm_reset_reason_type, reset_reason, POWER_VALID, RESET_REASON_POWER_VALID); +MAKE_ENUM_VALUE(alarm_reset_reason_type, reset_reason, POWER_VALID, RESET_REASON_POWER_ON); MAKE_ENUM_VALUE(alarm_reset_reason_type, reset_reason, SOFTWARE, RESET_REASON_SOFTWARE); MAKE_ENUM_VALUE(alarm_reset_reason_type, reset_reason, DEEP_SLEEP_ALARM, RESET_REASON_DEEP_SLEEP_ALARM); MAKE_ENUM_VALUE(alarm_reset_reason_type, reset_reason, EXTERNAL, RESET_REASON_EXTERNAL); @@ -36,23 +36,31 @@ MAKE_ENUM_VALUE(alarm_reset_reason_type, reset_reason, EXTERNAL, RESET_REASON_EX //| class ResetReason: //| """The reason the chip was last reset""" //| -//| POWER_VALID: object -//| """The chip was reset and started once power levels were valid.""" +//| POWER_ON: object +//| """The chip was started from power off.""" +//| +//| BROWNOUT: object +//| """The chip was reset due to voltage brownout.""" //| //| SOFTWARE: object //| """The chip was reset from software.""" //| //| DEEP_SLEEP_ALARM: object -//| """The chip was reset for deep sleep and started by an alarm.""" +//| """The chip was reset for deep sleep and restarted by an alarm.""" //| -//| EXTERNAL: object -//| """The chip was reset by an external input such as a button.""" +//| RESET_PIN: object +//| """The chip was reset by a signal on its reset pin. The pin might be connected to a reset buton.""" +//| +//| WATCHDOG: object +//| """The chip was reset by its watchdog timer.""" //| MAKE_ENUM_MAP(alarm_reset_reason) { - MAKE_ENUM_MAP_ENTRY(reset_reason, POWER_VALID), + MAKE_ENUM_MAP_ENTRY(reset_reason, POWER_ON), + MAKE_ENUM_MAP_ENTRY(reset_reason, BROWNOUT), MAKE_ENUM_MAP_ENTRY(reset_reason, SOFTWARE), MAKE_ENUM_MAP_ENTRY(reset_reason, DEEP_SLEEP_ALARM), - MAKE_ENUM_MAP_ENTRY(reset_reason, EXTERNAL), + MAKE_ENUM_MAP_ENTRY(reset_reason, RESET_PIN), + MAKE_ENUM_MAP_ENTRY(reset_reason, WATCHDOG), }; STATIC MP_DEFINE_CONST_DICT(alarm_reset_reason_locals_dict, alarm_reset_reason_locals_table); diff --git a/shared-bindings/alarm/ResetReason.h b/shared-bindings/alarm/ResetReason.h index 6fe7a4bd31..0325ba8e33 100644 --- a/shared-bindings/alarm/ResetReason.h +++ b/shared-bindings/alarm/ResetReason.h @@ -28,12 +28,16 @@ #define MICROPY_INCLUDED_SHARED_BINDINGS_ALARM__RESET_REASON__H typedef enum { - RESET_REASON_POWER_APPLIED, + RESET_REASON_POWER_ON, + RESET_REASON_BROWNOUT, RESET_REASON_SOFTWARE, RESET_REASON_DEEP_SLEEP_ALARM, - RESET_REASON_BUTTON, + RESET_REASON_RESET_PIN, + RESET_REASON_WATCHDOG, } alarm_reset_reason_t; extern const mp_obj_type_t alarm_reset_reason_type; +extern alarm_reset_reason_t common_hal_alarm_get_reset_reason(void); + #endif // MICROPY_INCLUDED_SHARED_BINDINGS_ALARM__RESET_REASON__H diff --git a/shared-bindings/alarm/pin/PinAlarm.c b/shared-bindings/alarm/pin/PinAlarm.c index 1404fa3f41..0146a3a1ad 100644 --- a/shared-bindings/alarm/pin/PinAlarm.c +++ b/shared-bindings/alarm/pin/PinAlarm.c @@ -91,10 +91,14 @@ STATIC mp_obj_t alarm_pin_pin_alarm_binary_op(mp_binary_op_t op, mp_obj_t lhs_in if (MP_OBJ_IS_TYPE(rhs_in, &alarm_pin_pin_alarm_type)) { // Pins are singletons, so we can compare them directly. return mp_obj_new_bool( - common_hal_pin_pin_alarm_get_pin(lhs_in) == common_hal_pin_pin_alarm_get_pin(rhs_in) && - common_hal_pin_pin_alarm_get_level(lhs_in) == common_hal_pin_pin_alarm_get_level(rhs_in) && - common_hal_pin_pin_alarm_get_edge(lhs_in) == common_hal_pin_pin_alarm_get_edge(rhs_in) && - common_hal_pin_pin_alarm_get_pull(lhs_in) == common_hal_pin_pin_alarm_get_pull(rhs_in)) + common_hal_alarm_pin_pin_alarm_get_pin(lhs_in) == + common_hal_alarm_pin_pin_alarm_get_pin(rhs_in) && + common_hal_alarm_pin_pin_alarm_get_level(lhs_in) == + common_hal_alarm_pin_pin_alarm_get_level(rhs_in) && + common_hal_alarm_pin_pin_alarm_get_edge(lhs_in) == + common_hal_alarm_pin_pin_alarm_get_edge(rhs_in) && + common_hal_alarm_pin_pin_alarm_get_pull(lhs_in) == + common_hal_alarm_pin_pin_alarm_get_pull(rhs_in)); } return mp_const_false; diff --git a/shared-bindings/alarm/pin/PinAlarm.h b/shared-bindings/alarm/pin/PinAlarm.h index e38c7f620c..b7c553ad5d 100644 --- a/shared-bindings/alarm/pin/PinAlarm.h +++ b/shared-bindings/alarm/pin/PinAlarm.h @@ -28,9 +28,14 @@ #define MICROPY_INCLUDED_SHARED_BINDINGS_ALARM_PIN_PIN_ALARM_H #include "py/obj.h" +#include "common-hal/microcontroller/Pin.h" extern const mp_obj_type_t alarm_pin_pin_alarm_type; extern void common_hal_alarm_pin_pin_pin_alarm_construct(alarm_pin_pin_alarm_obj_t *self, const mcu_pin_obj_t *pin, bool level, bool edge, bool pull); +extern mcu_pin_obj_t *common_hal_alarm_pin_pin_alarm_get_pin(alarm_pin_pin_alarm_obj_t *self); +extern bool common_hal_alarm_pin_pin_alarm_get_level(alarm_pin_pin_alarm_obj_t *self); +extern bool common_hal_alarm_pin_pin_alarm_get_edge(alarm_pin_pin_alarm_obj_t *self); +extern bool common_hal_alarm_pin_pin_alarm_get_pull(alarm_pin_pin_alarm_obj_t *self); #endif // MICROPY_INCLUDED_SHARED_BINDINGS_ALARM_PIN_PIN_ALARM_H diff --git a/shared-bindings/alarm/time/DurationAlarm.h b/shared-bindings/alarm/time/DurationAlarm.h index 1e4db6ac53..f6ab4f975c 100644 --- a/shared-bindings/alarm/time/DurationAlarm.h +++ b/shared-bindings/alarm/time/DurationAlarm.h @@ -31,4 +31,10 @@ extern const mp_obj_type_t alarm_time_duration_alarm_type; +extern void common_hal_alarm_time_duration_alarm_construct(alarm_time_duration_alarm_obj_t *self, mp_float_t duration); +extern mp_float_t common_hal_alarm_time_duration_alarm_get_duration(alarm_time_duration_alarm_obj_t *self); + +extern void common_hal_alarm_time_duration_alarm_enable(alarm_time_duration_alarm_obj_t *self); +extern void common_hal_alarm_time_duration_alarm_disable (alarm_time_duration_alarm_obj_t *self); + #endif // MICROPY_INCLUDED_SHARED_BINDINGS_ALARM_TIME_DURATION_ALARM_H diff --git a/supervisor/shared/rgb_led_status.c b/supervisor/shared/rgb_led_status.c index bff74a1f0e..c3d33ad3ea 100644 --- a/supervisor/shared/rgb_led_status.c +++ b/supervisor/shared/rgb_led_status.c @@ -367,7 +367,6 @@ void prep_rgb_status_animation(const pyexec_result_t* result, status->found_main = found_main; status->total_exception_cycle = 0; status->ok = result->return_code != PYEXEC_EXCEPTION; - status->cycles = 0; if (status->ok) { // If this isn't an exception, skip exception sorting and handling return; @@ -419,9 +418,8 @@ bool tick_rgb_status_animation(rgb_status_animation_t* status) { // All is good. Ramp ALL_DONE up and down. if (tick_diff > ALL_GOOD_CYCLE_MS) { status->pattern_start = supervisor_ticks_ms32(); - status->cycles++; new_status_color(BLACK); - return status->cycles; + return true; } uint16_t brightness = tick_diff * 255 / (ALL_GOOD_CYCLE_MS / 2); @@ -436,8 +434,7 @@ bool tick_rgb_status_animation(rgb_status_animation_t* status) { } else { if (tick_diff > status->total_exception_cycle) { status->pattern_start = supervisor_ticks_ms32(); - status->cycles++; - return; + return true; } // First flash the file color. if (tick_diff < EXCEPTION_TYPE_LENGTH_MS) { diff --git a/supervisor/shared/rgb_led_status.h b/supervisor/shared/rgb_led_status.h index e4e1981a21..84c97796a4 100644 --- a/supervisor/shared/rgb_led_status.h +++ b/supervisor/shared/rgb_led_status.h @@ -76,6 +76,6 @@ void prep_rgb_status_animation(const pyexec_result_t* result, bool found_main, safe_mode_t safe_mode, rgb_status_animation_t* status); -void tick_rgb_status_animation(rgb_status_animation_t* status); +bool tick_rgb_status_animation(rgb_status_animation_t* status); #endif // MICROPY_INCLUDED_SUPERVISOR_RGB_LED_STATUS_H diff --git a/supervisor/shared/safe_mode.c b/supervisor/shared/safe_mode.c index 905a0c408f..7630010d03 100644 --- a/supervisor/shared/safe_mode.c +++ b/supervisor/shared/safe_mode.c @@ -29,6 +29,9 @@ #include "mphalport.h" #include "shared-bindings/digitalio/DigitalInOut.h" +#if CIRCUITPY_ALARM +#include "shared-bindings/alarm/ResetReason.h" +#endif #include "supervisor/serial.h" #include "supervisor/shared/rgb_led_colors.h" @@ -52,10 +55,12 @@ safe_mode_t wait_for_safe_mode_reset(void) { current_safe_mode = safe_mode; return safe_mode; } - if (common_hal_sleep_get_reset_reason() != RESET_REASON_POWER_VALID && - common_hal_sleep_get_reset_reason() != RESET_REASON_BUTTON) { +#if CIRCUITPY_ALARM + if (common_hal_alarm_get_reset_reason() != RESET_REASON_POWER_ON && + common_hal_alarm_get_reset_reason() != RESET_REASON_RESET_PIN) { return NO_SAFE_MODE; } +#endif port_set_saved_word(SAFE_MODE_DATA_GUARD | (MANUAL_SAFE_MODE << 8)); // Wait for a while to allow for reset. temp_status_color(SAFE_MODE); From 0556f9f851f0bd5fdb392b925af1076affbf5e00 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Thu, 19 Nov 2020 15:12:56 -0600 Subject: [PATCH 081/207] Revert "samd21: Enable terse error reporting on resource constrained chip family" This reverts commit 9a642fc0490c22b60460bcca8dec3b0b93344d81. --- ports/atmel-samd/mpconfigport.h | 1 - py/circuitpy_mpconfig.h | 2 -- 2 files changed, 3 deletions(-) diff --git a/ports/atmel-samd/mpconfigport.h b/ports/atmel-samd/mpconfigport.h index 3069def33b..ed10da9b9d 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 MICROPY_ERROR_REPORTING (MICROPY_ERROR_REPORTING_TERSE) #define MICROPY_PY_BUILTINS_NOTIMPLEMENTED (0) #define MICROPY_PY_FUNCTION_ATTRS (0) // MICROPY_PY_UJSON depends on MICROPY_PY_IO diff --git a/py/circuitpy_mpconfig.h b/py/circuitpy_mpconfig.h index 4c2e33be01..85e152670a 100644 --- a/py/circuitpy_mpconfig.h +++ b/py/circuitpy_mpconfig.h @@ -64,9 +64,7 @@ #define MICROPY_ENABLE_FINALISER (1) #define MICROPY_ENABLE_GC (1) #define MICROPY_ENABLE_SOURCE_LINE (1) -#ifndef MICROPY_ERROR_REPORTING #define MICROPY_ERROR_REPORTING (MICROPY_ERROR_REPORTING_NORMAL) -#endif #define MICROPY_FLOAT_HIGH_QUALITY_HASH (0) #define MICROPY_FLOAT_IMPL (MICROPY_FLOAT_IMPL_FLOAT) #define MICROPY_GC_ALLOC_THRESHOLD (0) From d5f6748d1bea832c6f483ca8b0095e776eaca2df Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Thu, 19 Nov 2020 16:12:53 -0600 Subject: [PATCH 082/207] Use mp_raise instead of nlr_raise(new_exception) where possible This saves a bit of code space --- extmod/machine_mem.c | 2 +- extmod/moduheapq.c | 2 +- extmod/vfs_posix_file.c | 2 +- py/bc.c | 4 ++-- py/objstr.c | 6 ++---- 5 files changed, 7 insertions(+), 9 deletions(-) diff --git a/extmod/machine_mem.c b/extmod/machine_mem.c index 6c6e110631..8944c3a666 100644 --- a/extmod/machine_mem.c +++ b/extmod/machine_mem.c @@ -21,7 +21,7 @@ STATIC uintptr_t machine_mem_get_addr(mp_obj_t addr_o, uint align) { uintptr_t addr = mp_obj_int_get_truncated(addr_o); if ((addr & (align - 1)) != 0) { - nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_ValueError, translate("address %08x is not aligned to %d bytes"), addr, align)); + mp_raise_ValueError_varg(translate("address %08x is not aligned to %d bytes"), addr, align); } return addr; } diff --git a/extmod/moduheapq.c b/extmod/moduheapq.c index bc4b97ff5b..50fe6c0513 100644 --- a/extmod/moduheapq.c +++ b/extmod/moduheapq.c @@ -62,7 +62,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_2(mod_uheapq_heappush_obj, mod_uheapq_heappush); STATIC mp_obj_t mod_uheapq_heappop(mp_obj_t heap_in) { mp_obj_list_t *heap = get_heap(heap_in); if (heap->len == 0) { - nlr_raise(mp_obj_new_exception_msg(&mp_type_IndexError, translate("empty heap"))); + mp_raise_IndexError(translate("empty heap")); } mp_obj_t item = heap->items[0]; heap->len -= 1; diff --git a/extmod/vfs_posix_file.c b/extmod/vfs_posix_file.c index 3f887785e7..593b8d6a29 100644 --- a/extmod/vfs_posix_file.c +++ b/extmod/vfs_posix_file.c @@ -24,7 +24,7 @@ typedef struct _mp_obj_vfs_posix_file_t { #ifdef MICROPY_CPYTHON_COMPAT STATIC void check_fd_is_open(const mp_obj_vfs_posix_file_t *o) { if (o->fd < 0) { - nlr_raise(mp_obj_new_exception_msg(&mp_type_ValueError, translate("I/O operation on closed file"))); + mp_raise_ValueError(translate("I/O operation on closed file")); } } #else diff --git a/py/bc.c b/py/bc.c index 6406713385..01131cb4c0 100644 --- a/py/bc.c +++ b/py/bc.c @@ -214,8 +214,8 @@ void mp_setup_code_state(mp_code_state_t *code_state, size_t n_args, size_t n_kw #if MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE mp_raise_TypeError(translate("unexpected keyword argument")); #else - nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_TypeError, - translate("unexpected keyword argument '%q'"), MP_OBJ_QSTR_VALUE(wanted_arg_name))); + mp_raise_TypeError_varg( + translate("unexpected keyword argument '%q'"), MP_OBJ_QSTR_VALUE(wanted_arg_name)); #endif } mp_obj_dict_store(dict, kwargs[2 * i], kwargs[2 * i + 1]); diff --git a/py/objstr.c b/py/objstr.c index edb562df27..6a03f5fc3e 100644 --- a/py/objstr.c +++ b/py/objstr.c @@ -2134,10 +2134,8 @@ STATIC NORETURN void bad_implicit_conversion(mp_obj_t self_in) { mp_raise_TypeError(translate("can't convert to str implicitly")); } else { const qstr src_name = mp_obj_get_type_qstr(self_in); - nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_TypeError, - translate("can't convert '%q' object to %q implicitly"), - src_name, src_name == MP_QSTR_str ? MP_QSTR_bytes : MP_QSTR_str)); - } + mp_raise_TypeError_varg(translate("can't convert '%q' object to %q implicitly"), + src_name, src_name == MP_QSTR_str ? MP_QSTR_bytes : MP_QSTR_str); } // use this if you will anyway convert the string to a qstr From c06fc8e02dc7c17e827e3fe736dc7226d7819452 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Thu, 19 Nov 2020 16:13:54 -0600 Subject: [PATCH 083/207] Introduce, use mp_raise_arg1 This raises an exception with a given object value. Saves a bit of code size. --- extmod/modure.c | 6 +++--- extmod/moduzlib.c | 2 +- ports/unix/modjni.c | 4 ++-- py/modsys.c | 2 +- py/objdict.c | 6 +++--- py/objset.c | 2 +- py/objstr.c | 2 +- py/pystack.c | 4 ++-- py/runtime.c | 8 ++++++-- py/runtime.h | 1 + 10 files changed, 21 insertions(+), 16 deletions(-) diff --git a/extmod/modure.c b/extmod/modure.c index a20f3ee429..bb54bc732f 100644 --- a/extmod/modure.c +++ b/extmod/modure.c @@ -43,7 +43,7 @@ STATIC mp_obj_t match_group(mp_obj_t self_in, mp_obj_t no_in) { mp_obj_match_t *self = MP_OBJ_TO_PTR(self_in); mp_int_t no = mp_obj_get_int(no_in); if (no < 0 || no >= self->num_matches) { - nlr_raise(mp_obj_new_exception_arg1(&mp_type_IndexError, no_in)); + mp_raise_arg1(&mp_type_IndexError, no_in); } const char *start = self->caps[no * 2]; @@ -82,7 +82,7 @@ STATIC void match_span_helper(size_t n_args, const mp_obj_t *args, mp_obj_t span if (n_args == 2) { no = mp_obj_get_int(args[1]); if (no < 0 || no >= self->num_matches) { - nlr_raise(mp_obj_new_exception_arg1(&mp_type_IndexError, args[1])); + mp_raise_arg1(&mp_type_IndexError, args[1]); } } @@ -326,7 +326,7 @@ STATIC mp_obj_t re_sub_helper(mp_obj_t self_in, size_t n_args, const mp_obj_t *a } if (match_no >= (unsigned int)match->num_matches) { - nlr_raise(mp_obj_new_exception_arg1(&mp_type_IndexError, MP_OBJ_NEW_SMALL_INT(match_no))); + mp_raise_arg1(&mp_type_IndexError, MP_OBJ_NEW_SMALL_INT(match_no)); } const char *start_match = match->caps[match_no * 2]; diff --git a/extmod/moduzlib.c b/extmod/moduzlib.c index 8422e75983..b344f96429 100644 --- a/extmod/moduzlib.c +++ b/extmod/moduzlib.c @@ -179,7 +179,7 @@ STATIC mp_obj_t mod_uzlib_decompress(size_t n_args, const mp_obj_t *args) { return res; error: - nlr_raise(mp_obj_new_exception_arg1(&mp_type_ValueError, MP_OBJ_NEW_SMALL_INT(st))); + mp_raise_arg1(&mp_type_ValueError, MP_OBJ_NEW_SMALL_INT(st)); } STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mod_uzlib_decompress_obj, 1, 3, mod_uzlib_decompress); diff --git a/ports/unix/modjni.c b/ports/unix/modjni.c index 8ec5ae54d9..82d1ccd559 100644 --- a/ports/unix/modjni.c +++ b/ports/unix/modjni.c @@ -102,9 +102,9 @@ STATIC void check_exception(void) { mp_obj_t py_e = new_jobject(exc); JJ1(ExceptionClear); if (JJ(IsInstanceOf, exc, IndexException_class)) { - nlr_raise(mp_obj_new_exception_arg1(&mp_type_IndexError, py_e)); + mp_raise_arg1(&mp_type_IndexError, py_e); } - nlr_raise(mp_obj_new_exception_arg1(&mp_type_Exception, py_e)); + mp_raise_arg1(&mp_type_Exception, py_e); } } diff --git a/py/modsys.c b/py/modsys.c index a1d2cf831c..31f28a36fa 100644 --- a/py/modsys.c +++ b/py/modsys.c @@ -96,7 +96,7 @@ STATIC mp_obj_t mp_sys_exit(size_t n_args, const mp_obj_t *args) { if (n_args == 0) { exc = mp_obj_new_exception(&mp_type_SystemExit); } else { - exc = mp_obj_new_exception_arg1(&mp_type_SystemExit, args[0]); + mp_raise_arg1(&mp_type_SystemExit, args[0]); } nlr_raise(exc); } diff --git a/py/objdict.c b/py/objdict.c index 63fd86f357..098aec5d2f 100644 --- a/py/objdict.c +++ b/py/objdict.c @@ -169,7 +169,7 @@ mp_obj_t mp_obj_dict_get(mp_obj_t self_in, mp_obj_t index) { mp_obj_dict_t *self = MP_OBJ_TO_PTR(self_in); mp_map_elem_t *elem = mp_map_lookup(&self->map, index, MP_MAP_LOOKUP); if (elem == NULL) { - nlr_raise(mp_obj_new_exception_arg1(&mp_type_KeyError, index)); + mp_raise_arg1(&mp_type_KeyError, index); } else { return elem->value; } @@ -185,7 +185,7 @@ STATIC mp_obj_t dict_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value) { mp_obj_dict_t *self = MP_OBJ_TO_PTR(self_in); mp_map_elem_t *elem = mp_map_lookup(&self->map, index, MP_MAP_LOOKUP); if (elem == NULL) { - nlr_raise(mp_obj_new_exception_arg1(&mp_type_KeyError, index)); + mp_raise_arg1(&mp_type_KeyError, index); } else { return elem->value; } @@ -272,7 +272,7 @@ STATIC mp_obj_t dict_get_helper(size_t n_args, const mp_obj_t *args, mp_map_look if (elem == NULL || elem->value == MP_OBJ_NULL) { if (n_args == 2) { if (lookup_kind == MP_MAP_LOOKUP_REMOVE_IF_FOUND) { - nlr_raise(mp_obj_new_exception_arg1(&mp_type_KeyError, args[1])); + mp_raise_arg1(&mp_type_KeyError, args[1]); } else { value = mp_const_none; } diff --git a/py/objset.c b/py/objset.c index 45b5c12606..c5d54aede5 100644 --- a/py/objset.c +++ b/py/objset.c @@ -378,7 +378,7 @@ STATIC mp_obj_t set_remove(mp_obj_t self_in, mp_obj_t item) { check_set(self_in); mp_obj_set_t *self = MP_OBJ_TO_PTR(self_in); if (mp_set_lookup(&self->set, item, MP_MAP_LOOKUP_REMOVE_IF_FOUND) == MP_OBJ_NULL) { - nlr_raise(mp_obj_new_exception_arg1(&mp_type_KeyError, item)); + mp_raise_arg1(&mp_type_KeyError, item); } return mp_const_none; } diff --git a/py/objstr.c b/py/objstr.c index 6a03f5fc3e..34ccab86d6 100644 --- a/py/objstr.c +++ b/py/objstr.c @@ -1087,7 +1087,7 @@ STATIC vstr_t mp_obj_str_format_helper(const char *str, const char *top, int *ar field_name = lookup; mp_map_elem_t *key_elem = mp_map_lookup(kwargs, field_q, MP_MAP_LOOKUP); if (key_elem == NULL) { - nlr_raise(mp_obj_new_exception_arg1(&mp_type_KeyError, field_q)); + mp_raise_arg1(&mp_type_KeyError, field_q); } arg = key_elem->value; } diff --git a/py/pystack.c b/py/pystack.c index f79ea92101..0def75b109 100644 --- a/py/pystack.c +++ b/py/pystack.c @@ -43,8 +43,8 @@ void *mp_pystack_alloc(size_t n_bytes) { #endif if (MP_STATE_THREAD(pystack_cur) + n_bytes > MP_STATE_THREAD(pystack_end)) { // out of memory in the pystack - nlr_raise(mp_obj_new_exception_arg1(&mp_type_RuntimeError, - MP_OBJ_NEW_QSTR(MP_QSTR_pystack_space_exhausted))); + mp_raise_arg1(&mp_type_RuntimeError, + MP_OBJ_NEW_QSTR(MP_QSTR_pystack_space_exhausted)); } void *ptr = MP_STATE_THREAD(pystack_cur); MP_STATE_THREAD(pystack_cur) += n_bytes; diff --git a/py/runtime.c b/py/runtime.c index e63e2337d9..3745e16e30 100644 --- a/py/runtime.c +++ b/py/runtime.c @@ -1514,6 +1514,10 @@ NORETURN void m_malloc_fail(size_t num_bytes) { translate("memory allocation failed, allocating %u bytes"), (uint)num_bytes); } +NORETURN void mp_raise_arg1(const mp_obj_type_t *exc_type, mp_obj_t arg) { + nlr_raise(mp_obj_new_exception_arg1(exc_type, arg)); +} + NORETURN void mp_raise_msg(const mp_obj_type_t *exc_type, const compressed_string_t *msg) { if (msg == NULL) { nlr_raise(mp_obj_new_exception(exc_type)); @@ -1580,7 +1584,7 @@ NORETURN void mp_raise_TypeError_varg(const compressed_string_t *fmt, ...) { } NORETURN void mp_raise_OSError(int errno_) { - nlr_raise(mp_obj_new_exception_arg1(&mp_type_OSError, MP_OBJ_NEW_SMALL_INT(errno_))); + mp_raise_arg1(&mp_type_OSError, MP_OBJ_NEW_SMALL_INT(errno_)); } NORETURN void mp_raise_OSError_msg(const compressed_string_t *msg) { @@ -1607,7 +1611,7 @@ NORETURN void mp_raise_ConnectionError(const compressed_string_t *msg) { } NORETURN void mp_raise_BrokenPipeError(void) { - nlr_raise(mp_obj_new_exception_arg1(&mp_type_BrokenPipeError, MP_OBJ_NEW_SMALL_INT(MP_EPIPE))); + mp_raise_arg1(&mp_type_BrokenPipeError, MP_OBJ_NEW_SMALL_INT(MP_EPIPE)); } NORETURN void mp_raise_NotImplementedError(const compressed_string_t *msg) { diff --git a/py/runtime.h b/py/runtime.h index ad7d0feaba..5e8fda35c1 100644 --- a/py/runtime.h +++ b/py/runtime.h @@ -150,6 +150,7 @@ mp_obj_t mp_import_name(qstr name, mp_obj_t fromlist, mp_obj_t level); mp_obj_t mp_import_from(mp_obj_t module, qstr name); void mp_import_all(mp_obj_t module); +NORETURN void mp_raise_arg1(const mp_obj_type_t *exc_type, mp_obj_t arg); NORETURN void mp_raise_msg(const mp_obj_type_t *exc_type, const compressed_string_t *msg); NORETURN void mp_raise_msg_varg(const mp_obj_type_t *exc_type, const compressed_string_t *fmt, ...); NORETURN void mp_raise_msg_vlist(const mp_obj_type_t *exc_type, const compressed_string_t *fmt, va_list argptr); From b2b8520880e9d458adbd279a34b831f8d6b68d40 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Thu, 19 Nov 2020 16:18:52 -0600 Subject: [PATCH 084/207] Always use preprocessor for MICROPY_ERROR_REPORTING This ensures that only the translate("") alternative that will be used is seen after preprocessing. Improves the quality of the Huffman encoding and reduces binary size slightly. Also makes one "enhanced" error message only occur when ERROR_REPORTING_DETAILED: Instead of the word-for-word python3 error message "Type object has no attribute '%q'", the message will be "'type' object has no attribute '%q'". Also reduces binary size. (that's rolled into this commit as it was right next to a change to use the preprocessor for MICROPY_ERROR_REPORTING) Note that the odd semicolon after "value_error:" in parsenum.c is necessary due to a detail of the C grammar, in which a declaration cannot follow a label directly. --- py/argcheck.c | 18 ++++---- py/builtinimport.c | 12 +++--- py/compile.c | 12 +++--- py/modbuiltins.c | 6 +-- py/modsys.c | 4 +- py/obj.c | 66 ++++++++++++++-------------- py/objnamedtuple.c | 20 ++++----- py/objstr.c | 105 +++++++++++++++++++++++---------------------- py/objtype.c | 24 +++++------ py/parsenum.c | 10 ++--- py/runtime.c | 76 ++++++++++++++++---------------- 11 files changed, 178 insertions(+), 175 deletions(-) diff --git a/py/argcheck.c b/py/argcheck.c index 9341c02a6c..af5c81bf37 100644 --- a/py/argcheck.c +++ b/py/argcheck.c @@ -99,12 +99,12 @@ void mp_arg_parse_all(size_t n_pos, const mp_obj_t *pos, mp_map_t *kws, size_t n mp_map_elem_t *kw = mp_map_lookup(kws, MP_OBJ_NEW_QSTR(allowed[i].qst), MP_MAP_LOOKUP); if (kw == NULL) { if (allowed[i].flags & MP_ARG_REQUIRED) { - if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) { + #if MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE mp_arg_error_terse_mismatch(); - } else { + #else mp_raise_TypeError_varg( translate("'%q' argument required"), allowed[i].qst); - } + #endif } out_vals[i] = allowed[i].defval; continue; @@ -124,20 +124,20 @@ void mp_arg_parse_all(size_t n_pos, const mp_obj_t *pos, mp_map_t *kws, size_t n } if (pos_found < n_pos) { extra_positional: - if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) { + #if MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE mp_arg_error_terse_mismatch(); - } else { + #else // TODO better error message mp_raise_TypeError(translate("extra positional arguments given")); - } + #endif } if (kws_found < kws->used) { - if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) { + #if MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE mp_arg_error_terse_mismatch(); - } else { + #else // TODO better error message mp_raise_TypeError(translate("extra keyword arguments given")); - } + #endif } } diff --git a/py/builtinimport.c b/py/builtinimport.c index 47ffab5196..c4768cc777 100644 --- a/py/builtinimport.c +++ b/py/builtinimport.c @@ -426,12 +426,12 @@ mp_obj_t mp_builtin___import__(size_t n_args, const mp_obj_t *args) { mp_module_call_init(mod_name, module_obj); } else { // couldn't find the file, so fail - if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) { + #if MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE mp_raise_ImportError(translate("module not found")); - } else { + #else mp_raise_msg_varg(&mp_type_ImportError, translate("no module named '%q'"), mod_name); - } + #endif } } else { // found the file, so get the module @@ -538,12 +538,12 @@ mp_obj_t mp_builtin___import__(size_t n_args, const mp_obj_t *args) { #endif // Couldn't find the module, so fail - if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) { + #if MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE mp_raise_msg(&mp_type_ImportError, translate("module not found")); - } else { + #else nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_ImportError, translate("no module named '%q'"), module_name_qstr)); - } + #endif } #endif // MICROPY_ENABLE_EXTERNAL_IMPORT diff --git a/py/compile.c b/py/compile.c index 04bcf5bc14..b4d81ed445 100644 --- a/py/compile.c +++ b/py/compile.c @@ -2486,21 +2486,21 @@ STATIC void compile_atom_brace(compiler_t *comp, mp_parse_node_struct_t *pns) { compile_node(comp, pn_i); if (is_dict) { if (!is_key_value) { - if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) { + #if MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE compile_syntax_error(comp, (mp_parse_node_t)pns, translate("invalid syntax")); - } else { + #else compile_syntax_error(comp, (mp_parse_node_t)pns, translate("expecting key:value for dict")); - } + #endif return; } EMIT(store_map); } else { if (is_key_value) { - if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) { + #if MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE compile_syntax_error(comp, (mp_parse_node_t)pns, translate("invalid syntax")); - } else { + #else compile_syntax_error(comp, (mp_parse_node_t)pns, translate("expecting just a value for set")); - } + #endif return; } } diff --git a/py/modbuiltins.c b/py/modbuiltins.c index 41e1d4e488..fe3c366eec 100644 --- a/py/modbuiltins.c +++ b/py/modbuiltins.c @@ -346,12 +346,12 @@ STATIC mp_obj_t mp_builtin_ord(mp_obj_t o_in) { } } - if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) { + #if MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE mp_raise_TypeError(translate("ord expects a character")); - } else { + #else mp_raise_TypeError_varg( translate("ord() expected a character, but string of length %d found"), (int)len); - } + #endif } MP_DEFINE_CONST_FUN_OBJ_1(mp_builtin_ord_obj, mp_builtin_ord); diff --git a/py/modsys.c b/py/modsys.c index 31f28a36fa..81628683d8 100644 --- a/py/modsys.c +++ b/py/modsys.c @@ -92,13 +92,11 @@ STATIC const MP_DEFINE_STR_OBJ(platform_obj, MICROPY_PY_SYS_PLATFORM); // exit([retval]): raise SystemExit, with optional argument given to the exception STATIC mp_obj_t mp_sys_exit(size_t n_args, const mp_obj_t *args) { - mp_obj_t exc; if (n_args == 0) { - exc = mp_obj_new_exception(&mp_type_SystemExit); + nlr_raise(mp_obj_new_exception(&mp_type_SystemExit)); } else { mp_raise_arg1(&mp_type_SystemExit, args[0]); } - nlr_raise(exc); } MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mp_sys_exit_obj, 0, 1, mp_sys_exit); diff --git a/py/obj.c b/py/obj.c index 315e816e0b..d8e34746ca 100644 --- a/py/obj.c +++ b/py/obj.c @@ -262,12 +262,12 @@ mp_int_t mp_obj_get_int(mp_const_obj_t arg) { } else if (MP_OBJ_IS_TYPE(arg, &mp_type_int)) { return mp_obj_int_get_checked(arg); } else { - if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) { + #if MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE mp_raise_TypeError_varg(translate("can't convert to %q"), MP_QSTR_int); - } else { + #else mp_raise_TypeError_varg( translate("can't convert %q to %q"), mp_obj_get_type_qstr(arg), MP_QSTR_int); - } + #endif } } @@ -325,12 +325,12 @@ mp_float_t mp_obj_get_float(mp_obj_t arg) { mp_float_t val; if (!mp_obj_get_float_maybe(arg, &val)) { - if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) { + #if MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE mp_raise_TypeError_varg(translate("can't convert to %q"), MP_QSTR_float); - } else { + #else mp_raise_TypeError_varg( translate("can't convert %q to %q"), mp_obj_get_type_qstr(arg), MP_QSTR_float); - } + #endif } return val; @@ -358,12 +358,12 @@ void mp_obj_get_complex(mp_obj_t arg, mp_float_t *real, mp_float_t *imag) { } else if (MP_OBJ_IS_TYPE(arg, &mp_type_complex)) { mp_obj_complex_get(arg, real, imag); } else { - if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) { + #if MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE mp_raise_TypeError_varg(translate("can't convert to %q"), MP_QSTR_complex); - } else { + #else mp_raise_TypeError_varg( translate("can't convert %q to %q"), mp_obj_get_type_qstr(arg), MP_QSTR_complex); - } + #endif } } #endif @@ -376,12 +376,12 @@ void mp_obj_get_array(mp_obj_t o, size_t *len, mp_obj_t **items) { } else if (MP_OBJ_IS_TYPE(o, &mp_type_list)) { mp_obj_list_get(o, len, items); } else { - if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) { + #if MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE mp_raise_TypeError(translate("expected tuple/list")); - } else { + #else mp_raise_TypeError_varg( translate("object '%q' is not a tuple or list"), mp_obj_get_type_qstr(o)); - } + #endif } } @@ -390,12 +390,12 @@ void mp_obj_get_array_fixed_n(mp_obj_t o, size_t len, mp_obj_t **items) { size_t seq_len; mp_obj_get_array(o, &seq_len, items); if (seq_len != len) { - if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) { + #if MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE mp_raise_ValueError(translate("tuple/list has wrong length")); - } else { + #else mp_raise_ValueError_varg(translate("requested length %d but object has length %d"), (int)len, (int)seq_len); - } + #endif } } @@ -405,13 +405,13 @@ size_t mp_get_index(const mp_obj_type_t *type, size_t len, mp_obj_t index, bool if (MP_OBJ_IS_SMALL_INT(index)) { i = MP_OBJ_SMALL_INT_VALUE(index); } else if (!mp_obj_get_int_maybe(index, &i)) { - if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) { + #if MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE mp_raise_TypeError(translate("indices must be integers")); - } else { + #else mp_raise_TypeError_varg( translate("%q indices must be integers, not %q"), type->name, mp_obj_get_type_qstr(index)); - } + #endif } if (i < 0) { @@ -425,12 +425,12 @@ size_t mp_get_index(const mp_obj_type_t *type, size_t len, mp_obj_t index, bool } } else { if (i < 0 || (mp_uint_t)i >= len) { - if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) { + #if MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE mp_raise_IndexError(translate("index out of range")); - } else { + #else mp_raise_msg_varg(&mp_type_IndexError, translate("%q index out of range"), type->name); - } + #endif } } @@ -460,12 +460,12 @@ 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 len = mp_obj_len_maybe(o_in); if (len == MP_OBJ_NULL) { - if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) { + #if MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE mp_raise_TypeError(translate("object has no len")); - } else { + #else mp_raise_TypeError_varg( translate("object of type '%q' has no len()"), mp_obj_get_type_qstr(o_in)); - } + #endif } else { return len; } @@ -503,26 +503,26 @@ mp_obj_t mp_obj_subscr(mp_obj_t base, mp_obj_t index, mp_obj_t value) { } } if (value == MP_OBJ_NULL) { - if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) { + #if MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE mp_raise_TypeError(translate("object does not support item deletion")); - } else { + #else mp_raise_TypeError_varg( translate("'%q' object does not support item deletion"), mp_obj_get_type_qstr(base)); - } + #endif } else if (value == MP_OBJ_SENTINEL) { - if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) { + #if MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE mp_raise_TypeError(translate("object is not subscriptable")); - } else { + #else mp_raise_TypeError_varg( translate("'%q' object is not subscriptable"), mp_obj_get_type_qstr(base)); - } + #endif } else { - if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) { + #if MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE mp_raise_TypeError(translate("object does not support item assignment")); - } else { + #else mp_raise_TypeError_varg( translate("'%q' object does not support item assignment"), mp_obj_get_type_qstr(base)); - } + #endif } } diff --git a/py/objnamedtuple.c b/py/objnamedtuple.c index ab2f2f3c00..8b595da571 100644 --- a/py/objnamedtuple.c +++ b/py/objnamedtuple.c @@ -102,17 +102,17 @@ mp_obj_t namedtuple_make_new(const mp_obj_type_t *type_in, size_t n_args, const n_kw = kw_args->used; } if (n_args + n_kw != num_fields) { - if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) { + #if MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE mp_arg_error_terse_mismatch(); - } else if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_NORMAL) { + #elif MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_NORMAL mp_raise_TypeError_varg( translate("function takes %d positional arguments but %d were given"), num_fields, n_args + n_kw); - } else if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_DETAILED) { + #else mp_raise_TypeError_varg( translate("%q() takes %d positional arguments but %d were given"), type->base.name, num_fields, n_args + n_kw); - } + #endif } // Create a tuple and set the type to this namedtuple @@ -128,20 +128,20 @@ mp_obj_t namedtuple_make_new(const mp_obj_type_t *type_in, size_t n_args, const qstr kw = mp_obj_str_get_qstr(kw_args->table[i].key); size_t id = mp_obj_namedtuple_find_field(type, kw); if (id == (size_t)-1) { - if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) { + #if MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE mp_arg_error_terse_mismatch(); - } else { + #else mp_raise_TypeError_varg( translate("unexpected keyword argument '%q'"), kw); - } + #endif } if (tuple->items[id] != MP_OBJ_NULL) { - if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) { + #if MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE mp_arg_error_terse_mismatch(); - } else { + #else mp_raise_TypeError_varg( translate("function got multiple values for argument '%q'"), kw); - } + #endif } tuple->items[id] = kw_args->table[i].value; } diff --git a/py/objstr.c b/py/objstr.c index 34ccab86d6..1a59aeaecd 100644 --- a/py/objstr.c +++ b/py/objstr.c @@ -971,11 +971,11 @@ STATIC vstr_t mp_obj_str_format_helper(const char *str, const char *top, int *ar vstr_add_byte(&vstr, '}'); continue; } - if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) { + #if MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE terse_str_format_value_error(); - } else { + #else mp_raise_ValueError(translate("single '}' encountered in format string")); - } + #endif } if (*str != '{') { vstr_add_byte(&vstr, *str); @@ -1010,18 +1010,18 @@ STATIC vstr_t mp_obj_str_format_helper(const char *str, const char *top, int *ar if (str < top && (*str == 'r' || *str == 's')) { conversion = *str++; } else { - if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) { + #if MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE terse_str_format_value_error(); - } else if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_NORMAL) { + #elif MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_NORMAL mp_raise_ValueError(translate("bad conversion specifier")); - } else { + #else if (str >= top) { mp_raise_ValueError( translate("end of format while looking for conversion specifier")); } else { mp_raise_ValueError_varg(translate("unknown conversion specifier %c"), *str); } - } + #endif } } @@ -1047,18 +1047,18 @@ STATIC vstr_t mp_obj_str_format_helper(const char *str, const char *top, int *ar } } if (str >= top) { - if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) { + #if MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE terse_str_format_value_error(); - } else { + #else mp_raise_ValueError(translate("unmatched '{' in format")); - } + #endif } if (*str != '}') { - if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) { - terse_str_format_value_error(); - } else { + #if MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE +:w + #else mp_raise_ValueError(translate("expected ':' after format specifier")); - } + #endif } mp_obj_t arg = mp_const_none; @@ -1067,12 +1067,12 @@ STATIC vstr_t mp_obj_str_format_helper(const char *str, const char *top, int *ar int index = 0; if (MP_LIKELY(unichar_isdigit(*field_name))) { if (*arg_i > 0) { - if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) { + #if MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE terse_str_format_value_error(); - } else { + #else mp_raise_ValueError( translate("can't switch from automatic field numbering to manual field specification")); - } + #endif } field_name = str_to_int(field_name, field_name_top, &index); if ((uint)index >= n_args - 1) { @@ -1096,12 +1096,12 @@ STATIC vstr_t mp_obj_str_format_helper(const char *str, const char *top, int *ar } } else { if (*arg_i < 0) { - if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) { + #if MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE terse_str_format_value_error(); - } else { + #else mp_raise_ValueError( translate("can't switch from manual field specification to automatic field numbering")); - } + #endif } if ((uint)*arg_i >= n_args - 1) { mp_raise_IndexError_varg(translate("%q index out of range"), MP_QSTR_tuple); @@ -1189,11 +1189,11 @@ STATIC vstr_t mp_obj_str_format_helper(const char *str, const char *top, int *ar type = *s++; } if (*s) { - if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) { + #if MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE terse_str_format_value_error(); - } else { + #else mp_raise_ValueError(translate("invalid format specifier")); - } + #endif } vstr_clear(&format_spec_vstr); } @@ -1210,19 +1210,19 @@ STATIC vstr_t mp_obj_str_format_helper(const char *str, const char *top, int *ar if (flags & (PF_FLAG_SHOW_SIGN | PF_FLAG_SPACE_SIGN)) { if (type == 's') { - if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) { + #if MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE terse_str_format_value_error(); - } else { + #else mp_raise_ValueError(translate("sign not allowed in string format specifier")); - } + #endif } if (type == 'c') { - if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) { + #if MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE terse_str_format_value_error(); - } else { + #else mp_raise_ValueError( translate("sign not allowed with integer format specifier 'c'")); - } + #endif } } @@ -1276,13 +1276,13 @@ STATIC vstr_t mp_obj_str_format_helper(const char *str, const char *top, int *ar break; default: - if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) { + #if MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE terse_str_format_value_error(); - } else { + #else mp_raise_ValueError_varg( translate("unknown format code '%c' for object of type '%q'"), type, mp_obj_get_type_qstr(arg)); - } + #endif } } @@ -1348,24 +1348,24 @@ STATIC vstr_t mp_obj_str_format_helper(const char *str, const char *top, int *ar #endif default: - if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) { + #if MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE terse_str_format_value_error(); - } else { + #else mp_raise_ValueError_varg( translate("unknown format code '%c' for object of type '%q'"), type, mp_obj_get_type_qstr(arg)); - } + #endif } } else { // arg doesn't look like a number if (align == '=') { - if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) { + #if MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE terse_str_format_value_error(); - } else { + #else mp_raise_ValueError( translate("'=' alignment not allowed in string format specifier")); - } + #endif } switch (type) { @@ -1384,13 +1384,13 @@ STATIC vstr_t mp_obj_str_format_helper(const char *str, const char *top, int *ar } default: - if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) { + #if MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE terse_str_format_value_error(); - } else { + #else mp_raise_ValueError_varg( translate("unknown format code '%c' for object of type '%q'"), type, mp_obj_get_type_qstr(arg)); - } + #endif } } } @@ -1442,11 +1442,11 @@ STATIC mp_obj_t str_modulo_format(mp_obj_t pattern, size_t n_args, const mp_obj_ const byte *key = ++str; while (*str != ')') { if (str >= top) { - if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) { + #if MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE terse_str_format_value_error(); - } else { + #else mp_raise_ValueError(translate("incomplete format key")); - } + #endif } ++str; } @@ -1500,11 +1500,11 @@ STATIC mp_obj_t str_modulo_format(mp_obj_t pattern, size_t n_args, const mp_obj_ if (str >= top) { incomplete_format: - if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) { + #if MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE terse_str_format_value_error(); - } else { + #else mp_raise_ValueError(translate("incomplete format")); - } + #endif } // Tuple value lookup @@ -1587,13 +1587,13 @@ not_enough_args: break; default: - if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) { + #if MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE terse_str_format_value_error(); - } else { + #else mp_raise_ValueError_varg( translate("unsupported format character '%c' (0x%x) at index %d"), *str, *str, str - start_str); - } + #endif } } @@ -2130,12 +2130,13 @@ bool mp_obj_str_equal(mp_obj_t s1, mp_obj_t s2) { } STATIC NORETURN void bad_implicit_conversion(mp_obj_t self_in) { - if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) { + #if MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE mp_raise_TypeError(translate("can't convert to str implicitly")); - } else { + #else const qstr src_name = mp_obj_get_type_qstr(self_in); mp_raise_TypeError_varg(translate("can't convert '%q' object to %q implicitly"), src_name, src_name == MP_QSTR_str ? MP_QSTR_bytes : MP_QSTR_str); + #endif } // use this if you will anyway convert the string to a qstr diff --git a/py/objtype.c b/py/objtype.c index ccd014c335..1254b015c9 100644 --- a/py/objtype.c +++ b/py/objtype.c @@ -373,12 +373,12 @@ mp_obj_t mp_obj_instance_make_new(const mp_obj_type_t *self, size_t n_args, cons m_del(mp_obj_t, args2, 2 + n_args + 2 * n_kw); } if (init_ret != mp_const_none) { - if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) { + #if MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE mp_raise_TypeError(translate("__init__() should return None")); - } else { + #else mp_raise_TypeError_varg(translate("__init__() should return None, not '%q'"), mp_obj_get_type_qstr(init_ret)); - } + #endif } } @@ -888,12 +888,12 @@ mp_obj_t mp_obj_instance_call(mp_obj_t self_in, size_t n_args, size_t n_kw, cons mp_obj_t member[2] = {MP_OBJ_NULL, MP_OBJ_NULL}; mp_obj_t call = mp_obj_instance_get_call(self_in, member); if (call == MP_OBJ_NULL) { - if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) { + #if MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE mp_raise_TypeError(translate("object not callable")); - } else { + #else mp_raise_TypeError_varg(translate("'%q' object is not callable"), mp_obj_get_type_qstr(self_in)); - } + #endif } mp_obj_instance_t *self = MP_OBJ_TO_PTR(self_in); if (call == MP_OBJ_SENTINEL) { @@ -1024,11 +1024,11 @@ STATIC mp_obj_t type_call(mp_obj_t self_in, size_t n_args, size_t n_kw, const mp mp_obj_type_t *self = MP_OBJ_TO_PTR(self_in); if (self->make_new == NULL) { - if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) { + #if MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE mp_raise_TypeError(translate("cannot create instance")); - } else { + #else mp_raise_TypeError_varg(translate("cannot create '%q' instances"), self->name); - } + #endif } // create a map directly from the given args array and make a new instance @@ -1134,12 +1134,12 @@ mp_obj_t mp_obj_new_type(qstr name, mp_obj_t bases_tuple, mp_obj_t locals_dict) mp_obj_type_t *t = MP_OBJ_TO_PTR(bases_items[i]); // TODO: Verify with CPy, tested on function type if (t->make_new == NULL) { - if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) { + #if MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE mp_raise_TypeError(translate("type is not an acceptable base type")); - } else { + #else mp_raise_TypeError_varg( translate("type '%q' is not an acceptable base type"), t->name); - } + #endif } #if ENABLE_SPECIAL_ACCESSORS if (mp_obj_is_instance_type(t)) { diff --git a/py/parsenum.c b/py/parsenum.c index da63825e4b..a72829b203 100644 --- a/py/parsenum.c +++ b/py/parsenum.c @@ -145,16 +145,16 @@ overflow: goto have_ret_val; } -value_error: - if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) { +value_error: ; + #if MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE mp_obj_t exc = mp_obj_new_exception_msg(&mp_type_ValueError, translate("invalid syntax for integer")); raise_exc(exc, lex); - } else if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_NORMAL) { + #elif MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_NORMAL mp_obj_t exc = mp_obj_new_exception_msg_varg(&mp_type_ValueError, translate("invalid syntax for integer with base %d"), base); raise_exc(exc, lex); - } else { + #else vstr_t vstr; mp_print_t print; vstr_init_print(&vstr, 50, &print); @@ -163,7 +163,7 @@ value_error: mp_obj_t exc = mp_obj_new_exception_arg1(&mp_type_ValueError, mp_obj_new_str_from_vstr(&mp_type_str, &vstr)); raise_exc(exc, lex); - } + #endif } typedef enum { diff --git a/py/runtime.c b/py/runtime.c index 3745e16e30..a3acb954a6 100644 --- a/py/runtime.c +++ b/py/runtime.c @@ -177,12 +177,12 @@ mp_obj_t mp_load_global(qstr qst) { #endif elem = mp_map_lookup((mp_map_t*)&mp_module_builtins_globals.map, MP_OBJ_NEW_QSTR(qst), MP_MAP_LOOKUP); if (elem == NULL) { - if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) { + #if MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE mp_raise_msg(&mp_type_NameError, translate("name not defined")); - } else { + #else nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_NameError, translate("name '%q' is not defined"), qst)); - } + #endif } } return elem->value; @@ -275,13 +275,13 @@ mp_obj_t mp_unary_op(mp_unary_op_t op, mp_obj_t arg) { return result; } } - if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) { + #if MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE mp_raise_TypeError(translate("unsupported type for operator")); - } else { + #else mp_raise_TypeError_varg( translate("unsupported type for %q: '%q'"), mp_unary_op_method_name[op], mp_obj_get_type_qstr(arg)); - } + #endif } } @@ -582,13 +582,13 @@ generic_binary_op: } unsupported_op: - if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) { + #if MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE mp_raise_TypeError(translate("unsupported type for operator")); - } else { + #else mp_raise_TypeError_varg( translate("unsupported types for %q: '%q', '%q'"), mp_binary_op_method_name[op], mp_obj_get_type_qstr(lhs), mp_obj_get_type_qstr(rhs)); - } + #endif zero_division: mp_raise_msg(&mp_type_ZeroDivisionError, translate("division by zero")); @@ -624,11 +624,11 @@ mp_obj_t mp_call_function_n_kw(mp_obj_t fun_in, size_t n_args, size_t n_kw, cons return type->call(fun_in, n_args, n_kw, args); } - if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) { + #if MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE mp_raise_TypeError(translate("object not callable")); - } else { + #else mp_raise_TypeError_varg(translate("'%q' object is not callable"), mp_obj_get_type_qstr(fun_in)); - } + #endif } // args contains: fun self/NULL arg(0) ... arg(n_args-2) arg(n_args-1) kw_key(0) kw_val(0) ... kw_key(n_kw-1) kw_val(n_kw-1) @@ -852,19 +852,19 @@ void mp_unpack_sequence(mp_obj_t seq_in, size_t num, mp_obj_t *items) { return; too_short: - if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) { + #if MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE mp_raise_ValueError(translate("wrong number of values to unpack")); - } else { + #else mp_raise_ValueError_varg(translate("need more than %d values to unpack"), (int)seq_len); - } + #endif too_long: - if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) { + #if MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE mp_raise_ValueError(translate("wrong number of values to unpack")); - } else { + #else mp_raise_ValueError_varg(translate("too many values to unpack (expected %d)"), (int)num); - } + #endif } // unpacked items are stored in reverse order into the array pointed to by items @@ -916,12 +916,12 @@ void mp_unpack_ex(mp_obj_t seq_in, size_t num_in, mp_obj_t *items) { return; too_short: - if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) { + #if MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE mp_raise_ValueError(translate("wrong number of values to unpack")); - } else { + #else mp_raise_ValueError_varg(translate("need more than %d values to unpack"), (int)seq_len); - } + #endif } mp_obj_t mp_load_attr(mp_obj_t base, qstr attr) { @@ -1094,9 +1094,9 @@ void mp_load_method(mp_obj_t base, qstr attr, mp_obj_t *dest) { if (dest[0] == MP_OBJ_NULL) { // no attribute/method called attr - if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) { + #if MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE mp_raise_AttributeError(translate("no such attribute")); - } else { + #elif MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_DETAILED // following CPython, we give a more detailed error message for type objects if (MP_OBJ_IS_TYPE(base, &mp_type_type)) { nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_AttributeError, @@ -1107,7 +1107,11 @@ void mp_load_method(mp_obj_t base, qstr attr, mp_obj_t *dest) { translate("'%q' object has no attribute '%q'"), mp_obj_get_type_qstr(base), attr)); } - } + #else + nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_AttributeError, + translate("'%q' object has no attribute '%q'"), + mp_obj_get_type_qstr(base), attr)); + #endif } } @@ -1168,13 +1172,13 @@ void mp_store_attr(mp_obj_t base, qstr attr, mp_obj_t value) { } #endif } - if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) { + #if MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE mp_raise_AttributeError(translate("no such attribute")); - } else { + #else nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_AttributeError, translate("'%q' object cannot assign attribute '%q'"), mp_obj_get_type_qstr(base), attr)); - } + #endif } mp_obj_t mp_getiter(mp_obj_t o_in, mp_obj_iter_buf_t *iter_buf) { @@ -1209,12 +1213,12 @@ mp_obj_t mp_getiter(mp_obj_t o_in, mp_obj_iter_buf_t *iter_buf) { } // object not iterable - if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) { + #if MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE mp_raise_TypeError(translate("object not iterable")); - } else { + #else mp_raise_TypeError_varg( translate("'%q' object is not iterable"), mp_obj_get_type_qstr(o_in)); - } + #endif } // may return MP_OBJ_STOP_ITERATION as an optimisation instead of raise StopIteration() @@ -1231,12 +1235,12 @@ mp_obj_t mp_iternext_allow_raise(mp_obj_t o_in) { // __next__ exists, call it and return its result return mp_call_method_n_kw(0, 0, dest); } else { - if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) { + #if MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE mp_raise_TypeError(translate("object not an iterator")); - } else { + #else mp_raise_TypeError_varg(translate("'%q' object is not an iterator"), mp_obj_get_type_qstr(o_in)); - } + #endif } } } @@ -1267,12 +1271,12 @@ mp_obj_t mp_iternext(mp_obj_t o_in) { } } } else { - if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) { + #if MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE mp_raise_TypeError(translate("object not an iterator")); - } else { + #else mp_raise_TypeError_varg(translate("'%q' object is not an iterator"), mp_obj_get_type_qstr(o_in)); - } + #endif } } } From aaca3eccf12d4b6ea6e294af81c8d19ad330be0c Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Thu, 19 Nov 2020 16:19:37 -0600 Subject: [PATCH 085/207] samd: PDMIn: Reduce code unrolling on samd21 only Instead of unrolling the code 16 times, unroll it 4 times and loop over it 4 times. This gives the same 16 iterations, but at an expense of less flash space. --- ports/atmel-samd/common-hal/audiobusio/PDMIn.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/ports/atmel-samd/common-hal/audiobusio/PDMIn.c b/ports/atmel-samd/common-hal/audiobusio/PDMIn.c index 3c9ec05c25..8911aef2f1 100644 --- a/ports/atmel-samd/common-hal/audiobusio/PDMIn.c +++ b/ports/atmel-samd/common-hal/audiobusio/PDMIn.c @@ -337,7 +337,11 @@ const uint16_t sinc_filter [OVERSAMPLING] = { 94, 63, 39, 21, 9, 2, 0, 0 }; -#define REPEAT_16_TIMES(X) X X X X X X X X X X X X X X X X +#ifdef SAMD21 +#define REPEAT_16_TIMES(X) do { for(uint8_t j=0; j<4; j++) { X X X X } } while (0) +#else +#define REPEAT_16_TIMES(X) do { X X X X X X X X X X X X X X X X } while(0) +#endif static uint16_t filter_sample(uint32_t pdm_samples[4]) { uint16_t running_sum = 0; @@ -354,7 +358,7 @@ static uint16_t filter_sample(uint32_t pdm_samples[4]) { filter_ptr++; pdm_sample <<= 1; } - ) + ); } return running_sum; } From 982bce7259a9bbf7493f86258fc3395f31081648 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Thu, 19 Nov 2020 16:23:35 -0600 Subject: [PATCH 086/207] py.mk: allow translation to be overriden in GNUmakefile I like to use local makefile overrides, in the file GNUmakefile (or, on case-sensitive systems, makefile) to set compilation choices. However, writing TRANSLATION := de_DE include Makefile did not work, because py.mk would override the TRANSLATION := specified in an earlier part of the makefiles (but not from the commandline). By using ?= instead of := the local makefile override works, but when TRANSLATION is not specified it continues to work as before. --- py/py.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/py/py.mk b/py/py.mk index acf5d127bc..eeb3b8650f 100644 --- a/py/py.mk +++ b/py/py.mk @@ -7,7 +7,7 @@ HEADER_BUILD = $(BUILD)/genhdr # file containing qstr defs for the core Python bit PY_QSTR_DEFS = $(PY_SRC)/qstrdefs.h -TRANSLATION := en_US +TRANSLATION ?= en_US # If qstr autogeneration is not disabled we specify the output header # for all collected qstrings. From 17a8bafe0513c81565d25a6633808c639d5fa1f6 Mon Sep 17 00:00:00 2001 From: BennyE Date: Thu, 19 Nov 2020 23:39:48 +0100 Subject: [PATCH 087/207] Choose best AP in range if no channel/bssid given --- ports/esp32s2/common-hal/wifi/Radio.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/ports/esp32s2/common-hal/wifi/Radio.c b/ports/esp32s2/common-hal/wifi/Radio.c index 1945da207b..61c95dea82 100644 --- a/ports/esp32s2/common-hal/wifi/Radio.c +++ b/ports/esp32s2/common-hal/wifi/Radio.c @@ -142,6 +142,11 @@ wifi_radio_error_t common_hal_wifi_radio_connect(wifi_radio_obj_t *self, uint8_t } else { config->sta.bssid_set = 0; } + // if channel and bssid both not set, do a full scan instead of fast scan + // this will ensure that the best AP is chosen automatically + if ((self->sta.bssid_set == 0) && (self->sta.channel == NULL)) { + config.scan_method = WIFI_ALL_CHANNEL_SCAN; + } esp_wifi_set_config(ESP_IF_WIFI_STA, config); self->starting_retries = 5; self->retries_left = 5; From 39e1f52e28c620db65d59f16a29d5476c4868901 Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Thu, 19 Nov 2020 17:47:12 -0500 Subject: [PATCH 088/207] wip; not compiling yet --- main.c | 17 ++++-- ports/esp32s2/common-hal/alarm/__init__.c | 16 ++++++ shared-bindings/alarm/__init__.c | 17 ++++-- shared-bindings/alarm/__init__.h | 4 ++ shared-bindings/canio/BusState.c | 70 ----------------------- shared-bindings/canio/BusState.h | 33 ----------- shared-bindings/canio/__init__.c | 60 +++++++++++++++---- shared-bindings/canio/__init__.h | 6 ++ supervisor/shared/rgb_led_status.c | 1 + supervisor/shared/serial.c | 4 +- supervisor/shared/serial.h | 29 ---------- supervisor/shared/usb/usb.c | 4 +- supervisor/shared/workflow.c | 4 +- supervisor/shared/workflow.h | 2 + 14 files changed, 108 insertions(+), 159 deletions(-) delete mode 100644 shared-bindings/canio/BusState.c delete mode 100644 shared-bindings/canio/BusState.h delete mode 100644 supervisor/shared/serial.h diff --git a/main.c b/main.c index 251cb00a3f..30ceaeaa6d 100755 --- a/main.c +++ b/main.c @@ -56,6 +56,7 @@ #include "supervisor/shared/safe_mode.h" #include "supervisor/shared/status_leds.h" #include "supervisor/shared/stack.h" +#include "supervisor/shared/workflow.h" #include "supervisor/serial.h" #include "supervisor/usb.h" @@ -92,6 +93,12 @@ #include "common-hal/canio/CAN.h" #endif +// How long to wait for host to enumerate (secs). +#define CIRCUITPY_USB_ENUMERATION_DELAY 1 + +// How long to flash errors on the RGB status LED before going to sleep (secs) +#define CIRCUITPY_FLASH_ERROR_PERIOD 10 + void do_str(const char *src, mp_parse_input_kind_t input_kind) { mp_lexer_t *lex = mp_lexer_new_from_str_len(MP_QSTR__lt_stdin_gt_, src, strlen(src), 0); if (lex == NULL) { @@ -319,11 +326,11 @@ bool run_code_py(safe_mode_t safe_mode) { bool refreshed_epaper_display = false; #endif rgb_status_animation_t animation; - bool ok = result->return_code != PYEXEC_EXCEPTION; + bool ok = result.return_code != PYEXEC_EXCEPTION; #if CIRCUITPY_ALARM // If USB isn't enumerated then deep sleep. if (ok && !supervisor_workflow_active() && supervisor_ticks_ms64() > CIRCUITPY_USB_ENUMERATION_DELAY * 1024) { - common_hal_sleep_deep_sleep(); + common_hal_mcu_deep_sleep(); } #endif // Show the animation every N seconds. @@ -365,8 +372,8 @@ bool run_code_py(safe_mode_t safe_mode) { int64_t remaining_enumeration_wait = CIRCUITPY_USB_ENUMERATION_DELAY * 1024 - supervisor_ticks_ms64(); // If USB isn't enumerated then deep sleep after our waiting period. if (ok && remaining_enumeration_wait < 0) { - common_hal_sleep_deep_sleep(); - return; // Doesn't actually get here. + common_hal_mcu_deep_sleep(); + return false; // Doesn't actually get here. } #endif // Wake up every so often to flash the error code. @@ -424,7 +431,7 @@ void __attribute__ ((noinline)) run_boot_py(safe_mode_t safe_mode) { // Wait 1.5 seconds before opening CIRCUITPY_BOOT_OUTPUT_FILE for write, // in case power is momentary or will fail shortly due to, say a low, battery. #if CIRCUITPY_ALARM - if (common_hal_sleep_get_reset_reason() == RESET_REASON_POWER_ON) { + if (common_hal_alarm_get_reset_reason() == RESET_REASON_POWER_ON) { #endif mp_hal_delay_ms(1500); #if CIRCUITPY_ALARM diff --git a/ports/esp32s2/common-hal/alarm/__init__.c b/ports/esp32s2/common-hal/alarm/__init__.c index 552ad4452b..e8cb7b882e 100644 --- a/ports/esp32s2/common-hal/alarm/__init__.c +++ b/ports/esp32s2/common-hal/alarm/__init__.c @@ -35,6 +35,22 @@ void common_hal_alarm_disable_all(void) { esp_sleep_disable_wakeup_source(ESP_SLEEP_WAKEUP_ALL); } +mp_obj_t common_hal_alarm_get_reset_reason(void) { + switch (esp_sleep_get_wakeup_cause()) { + case ESP_SLEEP_WAKEUP_TIMER: + return RESET_REASON_DEEP_SLEEP_ALARM; + case ESP_SLEEP_WAKEUP_EXT0: + return RESET_REASON_DEEP_SLEEP_ALARM; + case ESP_SLEEP_WAKEUP_TOUCHPAD: + //TODO: implement TouchIO + case ESP_SLEEP_WAKEUP_UNDEFINED: + default: + return mp_const_none; + break; + } +} + + mp_obj_t common_hal_alarm_get_wake_alarm(void) { switch (esp_sleep_get_wakeup_cause()) { case ESP_SLEEP_WAKEUP_TIMER: ; diff --git a/shared-bindings/alarm/__init__.c b/shared-bindings/alarm/__init__.c index 20535e156b..ecbf7fe04f 100644 --- a/shared-bindings/alarm/__init__.c +++ b/shared-bindings/alarm/__init__.c @@ -34,11 +34,9 @@ #include "py/obj.h" #include "py/runtime.h" -#include "shared-bindings/alarm/pin/__init__.h" -#include "shared-bindings/alarm/time/__init__.h" - STATIC mp_obj_t alarm_sleep_until_alarm(size_t n_args, const mp_obj_t *args) { // TODO + return mp_const_none; } MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(alarm_sleep_until_alarm_obj, 1, MP_OBJ_FUN_ARGS_MAX, alarm_sleep_until_alarm); @@ -51,6 +49,7 @@ MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(alarm_sleep_until_alarm_obj, 1, MP_OBJ_FUN_A //| STATIC mp_obj_t alarm_restart_on_alarm(size_t n_args, const mp_obj_t *args) { // TODO + return mp_const_none; } MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(alarm_restart_on_alarm_obj, 1, MP_OBJ_FUN_ARGS_MAX, alarm_restart_on_alarm); @@ -102,7 +101,6 @@ mp_map_elem_t alarm_module_globals_table[] = { }; STATIC MP_DEFINE_MUTABLE_DICT(alarm_module_globals, alarm_module_globals_table); -// These are called from common_hal code to set the current wake alarm. void common_hal_alarm_set_wake_alarm(mp_obj_t alarm) { // Equivalent of: // alarm.wake_alarm = alarm @@ -113,7 +111,16 @@ void common_hal_alarm_set_wake_alarm(mp_obj_t alarm) { } } -// These are called from common hal code to set the current wake alarm. +alarm_reset_reason_t common_hal_alarm_get_reset_reason(void) { + mp_map_elem_t *elem = + mp_map_lookup(&alarm_module_globals_table, MP_ROM_QSTR(MP_QSTR_reset_reason), MP_MAP_LOOKUP); + if (elem) { + return elem->value; + } else { + return mp_const_none; + } +} + void common_hal_alarm_set_reset_reason(mp_obj_t reset_reason) { // Equivalent of: // alarm.reset_reason = reset_reason diff --git a/shared-bindings/alarm/__init__.h b/shared-bindings/alarm/__init__.h index ce9cc79f40..a0ee76e53b 100644 --- a/shared-bindings/alarm/__init__.h +++ b/shared-bindings/alarm/__init__.h @@ -29,7 +29,11 @@ #include "py/obj.h" +#include "shared-bindings/alarm/ResetReason.h" + extern void common_hal_alarm_set_wake_alarm(mp_obj_t alarm); + +extern alarm_reset_reason_t common_hal_alarm_get_reset_reason(void); extern void common_hal_alarm_set_reset_reason(mp_obj_t reset_reason); #endif // MICROPY_INCLUDED_SHARED_BINDINGS_ALARM___INIT___H diff --git a/shared-bindings/canio/BusState.c b/shared-bindings/canio/BusState.c deleted file mode 100644 index e0501b8d83..0000000000 --- a/shared-bindings/canio/BusState.c +++ /dev/null @@ -1,70 +0,0 @@ -/* - * This file is part of the MicroPython project, http://micropython.org/ - * - * The MIT License (MIT) - * - * Copyright (c) 2020 Jeff Epler for Adafruit Industries - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -#include "py/enum.h" - -#include "shared-bindings/canio/BusState.h" - -MAKE_ENUM_VALUE(canio_bus_state_type, bus_state, ERROR_ACTIVE, BUS_STATE_ERROR_ACTIVE); -MAKE_ENUM_VALUE(canio_bus_state_type, bus_state, ERROR_PASSIVE, BUS_STATE_ERROR_PASSIVE); -MAKE_ENUM_VALUE(canio_bus_state_type, bus_state, ERROR_WARNING, BUS_STATE_ERROR_WARNING); -MAKE_ENUM_VALUE(canio_bus_state_type, bus_state, BUS_OFF, BUS_STATE_OFF); - -//| class BusState: -//| """The state of the CAN bus""" -//| -//| ERROR_ACTIVE: object -//| """The bus is in the normal (active) state""" -//| -//| ERROR_WARNING: object -//| """The bus is in the normal (active) state, but a moderate number of errors have occurred recently. -//| -//| NOTE: Not all implementations may use ERROR_WARNING. Do not rely on seeing ERROR_WARNING before ERROR_PASSIVE.""" -//| -//| ERROR_PASSIVE: object -//| """The bus is in the passive state due to the number of errors that have occurred recently. -//| -//| This device will acknowledge packets it receives, but cannot transmit messages. -//| If additional errors occur, this device may progress to BUS_OFF. -//| If it successfully acknowledges other packets on the bus, it can return to ERROR_WARNING or ERROR_ACTIVE and transmit packets. -//| """ -//| -//| BUS_OFF: object -//| """The bus has turned off due to the number of errors that have -//| occurred recently. It must be restarted before it will send or receive -//| packets. This device will neither send or acknowledge packets on the bus.""" -//| -MAKE_ENUM_MAP(canio_bus_state) { - MAKE_ENUM_MAP_ENTRY(bus_state, ERROR_ACTIVE), - MAKE_ENUM_MAP_ENTRY(bus_state, ERROR_PASSIVE), - MAKE_ENUM_MAP_ENTRY(bus_state, ERROR_WARNING), - MAKE_ENUM_MAP_ENTRY(bus_state, BUS_OFF), -}; -STATIC MP_DEFINE_CONST_DICT(canio_bus_state_locals_dict, canio_bus_state_locals_table); - -MAKE_PRINTER(canio, canio_bus_state); - -MAKE_ENUM_TYPE(canio, BusState, canio_bus_state); diff --git a/shared-bindings/canio/BusState.h b/shared-bindings/canio/BusState.h deleted file mode 100644 index e24eba92c1..0000000000 --- a/shared-bindings/canio/BusState.h +++ /dev/null @@ -1,33 +0,0 @@ -/* - * This file is part of the MicroPython project, http://micropython.org/ - * - * The MIT License (MIT) - * - * Copyright (c) 2020 Jeff Epler for Adafruit Industries - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -#pragma once - -typedef enum { - BUS_STATE_ERROR_ACTIVE, BUS_STATE_ERROR_PASSIVE, BUS_STATE_ERROR_WARNING, BUS_STATE_OFF -} canio_bus_state_t; - -extern const mp_obj_type_t canio_bus_state_type; diff --git a/shared-bindings/canio/__init__.c b/shared-bindings/canio/__init__.c index 451a68c9eb..f29d3ab8ac 100644 --- a/shared-bindings/canio/__init__.c +++ b/shared-bindings/canio/__init__.c @@ -24,16 +24,6 @@ * THE SOFTWARE. */ -#include "py/obj.h" - -#include "shared-bindings/canio/__init__.h" - -#include "shared-bindings/canio/BusState.h" -#include "shared-bindings/canio/CAN.h" -#include "shared-bindings/canio/Match.h" -#include "shared-bindings/canio/Message.h" -#include "shared-bindings/canio/Listener.h" - //| """CAN bus access //| //| The `canio` module contains low level classes to support the CAN bus @@ -67,6 +57,56 @@ //| """ //| +#include "py/obj.h" +#include "py/enum.h" + +#include "shared-bindings/canio/__init__.h" +#include "shared-bindings/canio/CAN.h" +#include "shared-bindings/canio/Match.h" +#include "shared-bindings/canio/Message.h" +#include "shared-bindings/canio/Listener.h" + +MAKE_ENUM_VALUE(canio_bus_state_type, bus_state, ERROR_ACTIVE, BUS_STATE_ERROR_ACTIVE); +MAKE_ENUM_VALUE(canio_bus_state_type, bus_state, ERROR_PASSIVE, BUS_STATE_ERROR_PASSIVE); +MAKE_ENUM_VALUE(canio_bus_state_type, bus_state, ERROR_WARNING, BUS_STATE_ERROR_WARNING); +MAKE_ENUM_VALUE(canio_bus_state_type, bus_state, BUS_OFF, BUS_STATE_OFF); + +//| class BusState: +//| """The state of the CAN bus""" +//| +//| ERROR_ACTIVE: object +//| """The bus is in the normal (active) state""" +//| +//| ERROR_WARNING: object +//| """The bus is in the normal (active) state, but a moderate number of errors have occurred recently. +//| +//| NOTE: Not all implementations may use ERROR_WARNING. Do not rely on seeing ERROR_WARNING before ERROR_PASSIVE.""" +//| +//| ERROR_PASSIVE: object +//| """The bus is in the passive state due to the number of errors that have occurred recently. +//| +//| This device will acknowledge packets it receives, but cannot transmit messages. +//| If additional errors occur, this device may progress to BUS_OFF. +//| If it successfully acknowledges other packets on the bus, it can return to ERROR_WARNING or ERROR_ACTIVE and transmit packets. +//| """ +//| +//| BUS_OFF: object +//| """The bus has turned off due to the number of errors that have +//| occurred recently. It must be restarted before it will send or receive +//| packets. This device will neither send or acknowledge packets on the bus.""" +//| +MAKE_ENUM_MAP(canio_bus_state) { + MAKE_ENUM_MAP_ENTRY(bus_state, ERROR_ACTIVE), + MAKE_ENUM_MAP_ENTRY(bus_state, ERROR_PASSIVE), + MAKE_ENUM_MAP_ENTRY(bus_state, ERROR_WARNING), + MAKE_ENUM_MAP_ENTRY(bus_state, BUS_OFF), +}; +STATIC MP_DEFINE_CONST_DICT(canio_bus_state_locals_dict, canio_bus_state_locals_table); + +MAKE_PRINTER(canio, canio_bus_state); + +MAKE_ENUM_TYPE(canio, BusState, canio_bus_state); + STATIC const mp_rom_map_elem_t canio_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR_BusState), MP_ROM_PTR(&canio_bus_state_type) }, { MP_ROM_QSTR(MP_QSTR_CAN), MP_ROM_PTR(&canio_can_type) }, diff --git a/shared-bindings/canio/__init__.h b/shared-bindings/canio/__init__.h index 20b6638cd8..e24eba92c1 100644 --- a/shared-bindings/canio/__init__.h +++ b/shared-bindings/canio/__init__.h @@ -25,3 +25,9 @@ */ #pragma once + +typedef enum { + BUS_STATE_ERROR_ACTIVE, BUS_STATE_ERROR_PASSIVE, BUS_STATE_ERROR_WARNING, BUS_STATE_OFF +} canio_bus_state_t; + +extern const mp_obj_type_t canio_bus_state_type; diff --git a/supervisor/shared/rgb_led_status.c b/supervisor/shared/rgb_led_status.c index c3d33ad3ea..006bb1b34c 100644 --- a/supervisor/shared/rgb_led_status.c +++ b/supervisor/shared/rgb_led_status.c @@ -483,4 +483,5 @@ bool tick_rgb_status_animation(rgb_status_animation_t* status) { } } #endif + return false; // Animation is not finished. } diff --git a/supervisor/shared/serial.c b/supervisor/shared/serial.c index 7383cc2282..303f89e752 100644 --- a/supervisor/shared/serial.c +++ b/supervisor/shared/serial.c @@ -69,9 +69,7 @@ bool serial_connected(void) { #if defined(DEBUG_UART_TX) && defined(DEBUG_UART_RX) return true; #else - // True if DTR is asserted, and the USB connection is up. - // tud_cdc_get_line_state(): bit 0 is DTR, bit 1 is RTS - return (tud_cdc_get_line_state() & 1) && tud_ready(); + return tud_cdc_connected(); #endif } diff --git a/supervisor/shared/serial.h b/supervisor/shared/serial.h deleted file mode 100644 index 84f92c337c..0000000000 --- a/supervisor/shared/serial.h +++ /dev/null @@ -1,29 +0,0 @@ -/* - * 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. - */ - -#pragma once - -extern volatile bool _serial_connected; diff --git a/supervisor/shared/usb/usb.c b/supervisor/shared/usb/usb.c index 8a425c9907..3d76e7000a 100644 --- a/supervisor/shared/usb/usb.c +++ b/supervisor/shared/usb/usb.c @@ -31,6 +31,7 @@ #include "supervisor/port.h" #include "supervisor/serial.h" #include "supervisor/usb.h" +#include "supervisor/shared/workflow.h" #include "lib/utils/interrupt_char.h" #include "lib/mp-readline/readline.h" @@ -118,7 +119,6 @@ void tud_umount_cb(void) { // remote_wakeup_en : if host allows us to perform remote wakeup // USB Specs: Within 7ms, device must draw an average current less than 2.5 mA from bus void tud_suspend_cb(bool remote_wakeup_en) { - _serial_connected = false; _workflow_active = false; } @@ -132,8 +132,6 @@ void tud_resume_cb(void) { void tud_cdc_line_state_cb(uint8_t itf, bool dtr, bool rts) { (void) itf; // interface ID, not used - _serial_connected = dtr; - // DTR = false is counted as disconnected if ( !dtr ) { diff --git a/supervisor/shared/workflow.c b/supervisor/shared/workflow.c index adcffb319a..cd19d3aa25 100644 --- a/supervisor/shared/workflow.c +++ b/supervisor/shared/workflow.c @@ -24,9 +24,11 @@ * THE SOFTWARE. */ +#include + // Set by the shared USB code. volatile bool _workflow_active; -bool workflow_active(void) { +bool supervisor_workflow_active(void) { return _workflow_active; } diff --git a/supervisor/shared/workflow.h b/supervisor/shared/workflow.h index 4a138332a7..2968961f48 100644 --- a/supervisor/shared/workflow.h +++ b/supervisor/shared/workflow.h @@ -27,3 +27,5 @@ #pragma once extern volatile bool _workflow_active; + +extern bool supervisor_workflow_active(void); From 6760cdf678061abeaf2627e5903c8601eee6fc66 Mon Sep 17 00:00:00 2001 From: BennyE Date: Fri, 20 Nov 2020 00:11:17 +0100 Subject: [PATCH 089/207] Let connect() choose strongest AP if channel and BSSID are not given --- ports/esp32s2/common-hal/wifi/Radio.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ports/esp32s2/common-hal/wifi/Radio.c b/ports/esp32s2/common-hal/wifi/Radio.c index 61c95dea82..bcbca0ec7c 100644 --- a/ports/esp32s2/common-hal/wifi/Radio.c +++ b/ports/esp32s2/common-hal/wifi/Radio.c @@ -142,10 +142,10 @@ wifi_radio_error_t common_hal_wifi_radio_connect(wifi_radio_obj_t *self, uint8_t } else { config->sta.bssid_set = 0; } - // if channel and bssid both not set, do a full scan instead of fast scan - // this will ensure that the best AP is chosen automatically - if ((self->sta.bssid_set == 0) && (self->sta.channel == NULL)) { - config.scan_method = WIFI_ALL_CHANNEL_SCAN; + // If channel is 0 (default/unset) and BSSID is not given, do a full scan instead of fast scan + // This will ensure that the best AP in range is chosen automatically + if ((config->sta.bssid_set == 0) && (config->sta.channel == 0)) { + config->sta.scan_method = WIFI_ALL_CHANNEL_SCAN; } esp_wifi_set_config(ESP_IF_WIFI_STA, config); self->starting_retries = 5; From 123210a989eae73fb60146d707f7ba890f8311ee Mon Sep 17 00:00:00 2001 From: Scott Shawcroft Date: Thu, 19 Nov 2020 17:13:24 -0800 Subject: [PATCH 090/207] Speed up JSON parsing with readinto Get a chunk of data from readinto instead of a single byte. This speeds up the parsing by reducing the number of function calls. Fixes #3703 --- extmod/modujson.c | 35 ++++++++++++++++++++++++++--------- 1 file changed, 26 insertions(+), 9 deletions(-) diff --git a/extmod/modujson.c b/extmod/modujson.c index 431b5e0cf1..515606b70a 100644 --- a/extmod/modujson.c +++ b/extmod/modujson.c @@ -57,6 +57,8 @@ typedef struct _ujson_stream_t { int errcode; mp_obj_t python_readinto[2 + 1]; mp_obj_array_t bytearray_obj; + size_t start; + size_t end; byte cur; } ujson_stream_t; @@ -77,28 +79,43 @@ STATIC byte ujson_stream_next(ujson_stream_t *s) { return s->cur; } +// We read from an object's `readinto` method in chunks larger than the json +// parser needs to reduce the number of function calls done. + +#define CIRCUITPY_JSON_READ_CHUNK_SIZE 64 + STATIC mp_uint_t ujson_python_readinto(mp_obj_t obj, void *buf, mp_uint_t size, int *errcode) { ujson_stream_t* s = obj; - s->bytearray_obj.items = buf; - s->bytearray_obj.len = size; - *errcode = 0; - mp_obj_t ret = mp_call_method_n_kw(1, 0, s->python_readinto); - if (ret == mp_const_none) { - *errcode = MP_EAGAIN; - return MP_STREAM_ERROR; + + if (s->start == s->end) { + *errcode = 0; + mp_obj_t ret = mp_call_method_n_kw(1, 0, s->python_readinto); + if (ret == mp_const_none) { + *errcode = MP_EAGAIN; + return MP_STREAM_ERROR; + } + s->start = 0; + s->end = mp_obj_get_int(ret); } - return mp_obj_get_int(ret); + + *((uint8_t *)buf) = ((uint8_t*) s->bytearray_obj.items)[s->start]; + s->start++; + return 1; } STATIC mp_obj_t _mod_ujson_load(mp_obj_t stream_obj, bool return_first_json) { const mp_stream_p_t *stream_p = mp_proto_get(MP_QSTR_protocol_stream, stream_obj); ujson_stream_t s; + uint8_t character_buffer[CIRCUITPY_JSON_READ_CHUNK_SIZE]; if (stream_p == NULL) { + s.start = 0; + s.end = 0; mp_load_method(stream_obj, MP_QSTR_readinto, s.python_readinto); s.bytearray_obj.base.type = &mp_type_bytearray; s.bytearray_obj.typecode = BYTEARRAY_TYPECODE; + s.bytearray_obj.len = CIRCUITPY_JSON_READ_CHUNK_SIZE; s.bytearray_obj.free = 0; - // len and items are set at read time + s.bytearray_obj.items = character_buffer; s.python_readinto[2] = MP_OBJ_FROM_PTR(&s.bytearray_obj); s.stream_obj = &s; s.read = ujson_python_readinto; From 2773f534c946df46da5ba87c0968b5e4912a6b2b Mon Sep 17 00:00:00 2001 From: BennyE Date: Fri, 20 Nov 2020 09:40:32 +0100 Subject: [PATCH 091/207] Update ports/esp32s2/common-hal/wifi/Radio.c adding suggested changes --- ports/esp32s2/common-hal/wifi/Radio.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ports/esp32s2/common-hal/wifi/Radio.c b/ports/esp32s2/common-hal/wifi/Radio.c index bcbca0ec7c..f7c431a56b 100644 --- a/ports/esp32s2/common-hal/wifi/Radio.c +++ b/ports/esp32s2/common-hal/wifi/Radio.c @@ -146,6 +146,8 @@ wifi_radio_error_t common_hal_wifi_radio_connect(wifi_radio_obj_t *self, uint8_t // This will ensure that the best AP in range is chosen automatically if ((config->sta.bssid_set == 0) && (config->sta.channel == 0)) { config->sta.scan_method = WIFI_ALL_CHANNEL_SCAN; + } else { + config->sta.scan_method = WIFI_FAST_SCAN; } esp_wifi_set_config(ESP_IF_WIFI_STA, config); self->starting_retries = 5; From 0a06530d52524c76a026ed843165fa79a0526c1b Mon Sep 17 00:00:00 2001 From: Seth Kerr Date: Fri, 20 Nov 2020 15:06:57 -0500 Subject: [PATCH 092/207] adding CP-Sapling --- ports/atmel-samd/boards/CP_Sapling_m0/board.c | 40 +++++++++++++ .../boards/CP_Sapling_m0/mpconfigboard.h | 57 +++++++++++++++++++ .../boards/CP_Sapling_m0/mpconfigboard.mk | 24 ++++++++ ports/atmel-samd/boards/CP_Sapling_m0/pins.c | 38 +++++++++++++ 4 files changed, 159 insertions(+) create mode 100644 ports/atmel-samd/boards/CP_Sapling_m0/board.c create mode 100644 ports/atmel-samd/boards/CP_Sapling_m0/mpconfigboard.h create mode 100644 ports/atmel-samd/boards/CP_Sapling_m0/mpconfigboard.mk create mode 100644 ports/atmel-samd/boards/CP_Sapling_m0/pins.c diff --git a/ports/atmel-samd/boards/CP_Sapling_m0/board.c b/ports/atmel-samd/boards/CP_Sapling_m0/board.c new file mode 100644 index 0000000000..b745bd9060 --- /dev/null +++ b/ports/atmel-samd/boards/CP_Sapling_m0/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 "common-hal/microcontroller/Pin.h" +#include "supervisor/shared/board.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/CP_Sapling_m0/mpconfigboard.h b/ports/atmel-samd/boards/CP_Sapling_m0/mpconfigboard.h new file mode 100644 index 0000000000..c67f022eb8 --- /dev/null +++ b/ports/atmel-samd/boards/CP_Sapling_m0/mpconfigboard.h @@ -0,0 +1,57 @@ +#define MICROPY_HW_BOARD_NAME "CP Sapling M0" +#define MICROPY_HW_MCU_NAME "samd21e18" + +#define MICROPY_HW_NEOPIXEL (&pin_PA15) + +#define MICROPY_PORT_A (0) +#define MICROPY_PORT_B (0) +#define MICROPY_PORT_C (0) + +#define IGNORE_PIN_PA02 1 +#define IGNORE_PIN_PA03 1 +#define IGNORE_PIN_PA04 1 +#define IGNORE_PIN_PA05 1 +#define IGNORE_PIN_PA06 1 +#define IGNORE_PIN_PA07 1 +#define IGNORE_PIN_PA12 1 +#define IGNORE_PIN_PA13 1 +#define IGNORE_PIN_PA14 1 +#define IGNORE_PIN_PA20 1 +#define IGNORE_PIN_PA21 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_SS (&pin_PA22) +#define DEFAULT_SPI_BUS_SCK (&pin_PA19) +#define DEFAULT_SPI_BUS_MOSI (&pin_PA18) +#define DEFAULT_SPI_BUS_MISO (&pin_PA17) diff --git a/ports/atmel-samd/boards/CP_Sapling_m0/mpconfigboard.mk b/ports/atmel-samd/boards/CP_Sapling_m0/mpconfigboard.mk new file mode 100644 index 0000000000..861a0a5f7d --- /dev/null +++ b/ports/atmel-samd/boards/CP_Sapling_m0/mpconfigboard.mk @@ -0,0 +1,24 @@ +USB_VID = 0x1209 +USB_PID = 0x4DDD +USB_PRODUCT = "CP Sapling" +USB_MANUFACTURER = "Oak Development Technologies" + +CHIP_VARIANT = SAMD21E18A +CHIP_FAMILY = samd21 + +INTERNAL_FLASH_FILESYSTEM = 1 +LONGINT_IMPL = NONE +CIRCUITPY_FULL_BUILD = 0 + +SUPEROPT_GC = 0 + +CFLAGS_BOARD = --param max-inline-insns-auto=15 +ifeq ($(TRANSLATION), zh_Latn_pinyin) +RELEASE_NEEDS_CLEAN_BUILD = 1 +CFLAGS_INLINE_LIMIT = 35 +endif +ifeq ($(TRANSLATION), de_DE) +RELEASE_NEEDS_CLEAN_BUILD = 1 +CFLAGS_INLINE_LIMIT = 35 +SUPEROPT_VM = 0 +endif diff --git a/ports/atmel-samd/boards/CP_Sapling_m0/pins.c b/ports/atmel-samd/boards/CP_Sapling_m0/pins.c new file mode 100644 index 0000000000..ccffe2b3a1 --- /dev/null +++ b/ports/atmel-samd/boards/CP_Sapling_m0/pins.c @@ -0,0 +1,38 @@ +#include "shared-bindings/board/__init__.h" + +STATIC const mp_rom_map_elem_t board_global_dict_table[] = { + + { MP_ROM_QSTR(MP_QSTR_D5), MP_ROM_PTR(&pin_PA08) }, + { MP_ROM_QSTR(MP_QSTR_SDA), MP_ROM_PTR(&pin_PA08) }, + + { MP_ROM_QSTR(MP_QSTR_D10), MP_ROM_PTR(&pin_PA00) }, + { MP_ROM_QSTR(MP_QSTR_A4), MP_ROM_PTR(&pin_PA00) }, + + { MP_ROM_QSTR(MP_QSTR_D11), MP_ROM_PTR(&pin_PA01) }, + { MP_ROM_QSTR(MP_QSTR_A5), MP_ROM_PTR(&pin_PA01) }, + + { MP_ROM_QSTR(MP_QSTR_D4), MP_ROM_PTR(&pin_PA09) }, + { MP_ROM_QSTR(MP_QSTR_SCL), MP_ROM_PTR(&pin_PA09) }, + + { MP_ROM_QSTR(MP_QSTR_D0), MP_ROM_PTR(&pin_PA22) }, + { MP_ROM_QSTR(MP_QSTR_A0), MP_ROM_PTR(&pin_PA22) }, + { MP_ROM_QSTR(MP_QSTR_SS), MP_ROM_PTR(&pin_PA22) }, + + { MP_ROM_QSTR(MP_QSTR_D3), MP_ROM_PTR(&pin_PA19) }, + { MP_ROM_QSTR(MP_QSTR_A3), MP_ROM_PTR(&pin_PA19) }, + { MP_ROM_QSTR(MP_QSTR_SCK), MP_ROM_PTR(&pin_PA19) }, + + { MP_ROM_QSTR(MP_QSTR_D1), MP_ROM_PTR(&pin_PA17) }, + { MP_ROM_QSTR(MP_QSTR_A1), MP_ROM_PTR(&pin_PA17) }, + { MP_ROM_QSTR(MP_QSTR_MISO), MP_ROM_PTR(&pin_PA17) }, + + { MP_ROM_QSTR(MP_QSTR_D2), MP_ROM_PTR(&pin_PA18) }, + { MP_ROM_QSTR(MP_QSTR_A2), MP_ROM_PTR(&pin_PA18) }, + { MP_ROM_QSTR(MP_QSTR_MOSI), MP_ROM_PTR(&pin_PA18) }, + + { MP_ROM_QSTR(MP_QSTR_NEOPIXEL), MP_ROM_PTR(&pin_PA15) }, + + { 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); From b69bbfa3d6dbbe86216f4ea72df54cfd24612fe0 Mon Sep 17 00:00:00 2001 From: Seth Kerr Date: Fri, 20 Nov 2020 15:17:44 -0500 Subject: [PATCH 093/207] fixed issues with trailing whitespace check --- ports/atmel-samd/boards/CP_Sapling_m0/board.c | 2 +- ports/atmel-samd/boards/CP_Sapling_m0/pins.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/ports/atmel-samd/boards/CP_Sapling_m0/board.c b/ports/atmel-samd/boards/CP_Sapling_m0/board.c index b745bd9060..ce56366762 100644 --- a/ports/atmel-samd/boards/CP_Sapling_m0/board.c +++ b/ports/atmel-samd/boards/CP_Sapling_m0/board.c @@ -29,7 +29,7 @@ #include "supervisor/shared/board.h" #include "hal/include/hal_gpio.h" -void board_init(void) { +void board_init(void) { } bool board_requests_safe_mode(void) { diff --git a/ports/atmel-samd/boards/CP_Sapling_m0/pins.c b/ports/atmel-samd/boards/CP_Sapling_m0/pins.c index ccffe2b3a1..d527aaddcb 100644 --- a/ports/atmel-samd/boards/CP_Sapling_m0/pins.c +++ b/ports/atmel-samd/boards/CP_Sapling_m0/pins.c @@ -7,7 +7,7 @@ STATIC const mp_rom_map_elem_t board_global_dict_table[] = { { MP_ROM_QSTR(MP_QSTR_D10), MP_ROM_PTR(&pin_PA00) }, { MP_ROM_QSTR(MP_QSTR_A4), MP_ROM_PTR(&pin_PA00) }, - + { MP_ROM_QSTR(MP_QSTR_D11), MP_ROM_PTR(&pin_PA01) }, { MP_ROM_QSTR(MP_QSTR_A5), MP_ROM_PTR(&pin_PA01) }, @@ -31,7 +31,7 @@ STATIC const mp_rom_map_elem_t board_global_dict_table[] = { { MP_ROM_QSTR(MP_QSTR_MOSI), MP_ROM_PTR(&pin_PA18) }, { MP_ROM_QSTR(MP_QSTR_NEOPIXEL), MP_ROM_PTR(&pin_PA15) }, - + { 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 29e91424d483f0b427957be1c859f7f758f6fbea Mon Sep 17 00:00:00 2001 From: Seth Kerr Date: Fri, 20 Nov 2020 15:29:35 -0500 Subject: [PATCH 094/207] removing cp sapling temporarily to read --- ports/atmel-samd/boards/CP_Sapling_m0/board.c | 40 ------------- .../boards/CP_Sapling_m0/mpconfigboard.h | 57 ------------------- .../boards/CP_Sapling_m0/mpconfigboard.mk | 24 -------- ports/atmel-samd/boards/CP_Sapling_m0/pins.c | 38 ------------- 4 files changed, 159 deletions(-) delete mode 100644 ports/atmel-samd/boards/CP_Sapling_m0/board.c delete mode 100644 ports/atmel-samd/boards/CP_Sapling_m0/mpconfigboard.h delete mode 100644 ports/atmel-samd/boards/CP_Sapling_m0/mpconfigboard.mk delete mode 100644 ports/atmel-samd/boards/CP_Sapling_m0/pins.c diff --git a/ports/atmel-samd/boards/CP_Sapling_m0/board.c b/ports/atmel-samd/boards/CP_Sapling_m0/board.c deleted file mode 100644 index ce56366762..0000000000 --- a/ports/atmel-samd/boards/CP_Sapling_m0/board.c +++ /dev/null @@ -1,40 +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 "common-hal/microcontroller/Pin.h" -#include "supervisor/shared/board.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/CP_Sapling_m0/mpconfigboard.h b/ports/atmel-samd/boards/CP_Sapling_m0/mpconfigboard.h deleted file mode 100644 index c67f022eb8..0000000000 --- a/ports/atmel-samd/boards/CP_Sapling_m0/mpconfigboard.h +++ /dev/null @@ -1,57 +0,0 @@ -#define MICROPY_HW_BOARD_NAME "CP Sapling M0" -#define MICROPY_HW_MCU_NAME "samd21e18" - -#define MICROPY_HW_NEOPIXEL (&pin_PA15) - -#define MICROPY_PORT_A (0) -#define MICROPY_PORT_B (0) -#define MICROPY_PORT_C (0) - -#define IGNORE_PIN_PA02 1 -#define IGNORE_PIN_PA03 1 -#define IGNORE_PIN_PA04 1 -#define IGNORE_PIN_PA05 1 -#define IGNORE_PIN_PA06 1 -#define IGNORE_PIN_PA07 1 -#define IGNORE_PIN_PA12 1 -#define IGNORE_PIN_PA13 1 -#define IGNORE_PIN_PA14 1 -#define IGNORE_PIN_PA20 1 -#define IGNORE_PIN_PA21 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_SS (&pin_PA22) -#define DEFAULT_SPI_BUS_SCK (&pin_PA19) -#define DEFAULT_SPI_BUS_MOSI (&pin_PA18) -#define DEFAULT_SPI_BUS_MISO (&pin_PA17) diff --git a/ports/atmel-samd/boards/CP_Sapling_m0/mpconfigboard.mk b/ports/atmel-samd/boards/CP_Sapling_m0/mpconfigboard.mk deleted file mode 100644 index 861a0a5f7d..0000000000 --- a/ports/atmel-samd/boards/CP_Sapling_m0/mpconfigboard.mk +++ /dev/null @@ -1,24 +0,0 @@ -USB_VID = 0x1209 -USB_PID = 0x4DDD -USB_PRODUCT = "CP Sapling" -USB_MANUFACTURER = "Oak Development Technologies" - -CHIP_VARIANT = SAMD21E18A -CHIP_FAMILY = samd21 - -INTERNAL_FLASH_FILESYSTEM = 1 -LONGINT_IMPL = NONE -CIRCUITPY_FULL_BUILD = 0 - -SUPEROPT_GC = 0 - -CFLAGS_BOARD = --param max-inline-insns-auto=15 -ifeq ($(TRANSLATION), zh_Latn_pinyin) -RELEASE_NEEDS_CLEAN_BUILD = 1 -CFLAGS_INLINE_LIMIT = 35 -endif -ifeq ($(TRANSLATION), de_DE) -RELEASE_NEEDS_CLEAN_BUILD = 1 -CFLAGS_INLINE_LIMIT = 35 -SUPEROPT_VM = 0 -endif diff --git a/ports/atmel-samd/boards/CP_Sapling_m0/pins.c b/ports/atmel-samd/boards/CP_Sapling_m0/pins.c deleted file mode 100644 index d527aaddcb..0000000000 --- a/ports/atmel-samd/boards/CP_Sapling_m0/pins.c +++ /dev/null @@ -1,38 +0,0 @@ -#include "shared-bindings/board/__init__.h" - -STATIC const mp_rom_map_elem_t board_global_dict_table[] = { - - { MP_ROM_QSTR(MP_QSTR_D5), MP_ROM_PTR(&pin_PA08) }, - { MP_ROM_QSTR(MP_QSTR_SDA), MP_ROM_PTR(&pin_PA08) }, - - { MP_ROM_QSTR(MP_QSTR_D10), MP_ROM_PTR(&pin_PA00) }, - { MP_ROM_QSTR(MP_QSTR_A4), MP_ROM_PTR(&pin_PA00) }, - - { MP_ROM_QSTR(MP_QSTR_D11), MP_ROM_PTR(&pin_PA01) }, - { MP_ROM_QSTR(MP_QSTR_A5), MP_ROM_PTR(&pin_PA01) }, - - { MP_ROM_QSTR(MP_QSTR_D4), MP_ROM_PTR(&pin_PA09) }, - { MP_ROM_QSTR(MP_QSTR_SCL), MP_ROM_PTR(&pin_PA09) }, - - { MP_ROM_QSTR(MP_QSTR_D0), MP_ROM_PTR(&pin_PA22) }, - { MP_ROM_QSTR(MP_QSTR_A0), MP_ROM_PTR(&pin_PA22) }, - { MP_ROM_QSTR(MP_QSTR_SS), MP_ROM_PTR(&pin_PA22) }, - - { MP_ROM_QSTR(MP_QSTR_D3), MP_ROM_PTR(&pin_PA19) }, - { MP_ROM_QSTR(MP_QSTR_A3), MP_ROM_PTR(&pin_PA19) }, - { MP_ROM_QSTR(MP_QSTR_SCK), MP_ROM_PTR(&pin_PA19) }, - - { MP_ROM_QSTR(MP_QSTR_D1), MP_ROM_PTR(&pin_PA17) }, - { MP_ROM_QSTR(MP_QSTR_A1), MP_ROM_PTR(&pin_PA17) }, - { MP_ROM_QSTR(MP_QSTR_MISO), MP_ROM_PTR(&pin_PA17) }, - - { MP_ROM_QSTR(MP_QSTR_D2), MP_ROM_PTR(&pin_PA18) }, - { MP_ROM_QSTR(MP_QSTR_A2), MP_ROM_PTR(&pin_PA18) }, - { MP_ROM_QSTR(MP_QSTR_MOSI), MP_ROM_PTR(&pin_PA18) }, - - { MP_ROM_QSTR(MP_QSTR_NEOPIXEL), MP_ROM_PTR(&pin_PA15) }, - - { 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); From c4f4cdd8c15ef54ed05533b3f4c9d28bf9f9c46f Mon Sep 17 00:00:00 2001 From: Seth Kerr Date: Fri, 20 Nov 2020 15:31:49 -0500 Subject: [PATCH 095/207] readding cp_sapling directory --- ports/atmel-samd/boards/cp_sapling_m0/board.c | 40 +++++++++++++ .../boards/cp_sapling_m0/mpconfigboard.h | 57 +++++++++++++++++++ .../boards/cp_sapling_m0/mpconfigboard.mk | 24 ++++++++ ports/atmel-samd/boards/cp_sapling_m0/pins.c | 38 +++++++++++++ 4 files changed, 159 insertions(+) create mode 100644 ports/atmel-samd/boards/cp_sapling_m0/board.c create mode 100644 ports/atmel-samd/boards/cp_sapling_m0/mpconfigboard.h create mode 100644 ports/atmel-samd/boards/cp_sapling_m0/mpconfigboard.mk create mode 100644 ports/atmel-samd/boards/cp_sapling_m0/pins.c diff --git a/ports/atmel-samd/boards/cp_sapling_m0/board.c b/ports/atmel-samd/boards/cp_sapling_m0/board.c new file mode 100644 index 0000000000..b745bd9060 --- /dev/null +++ b/ports/atmel-samd/boards/cp_sapling_m0/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 "common-hal/microcontroller/Pin.h" +#include "supervisor/shared/board.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/cp_sapling_m0/mpconfigboard.h b/ports/atmel-samd/boards/cp_sapling_m0/mpconfigboard.h new file mode 100644 index 0000000000..c67f022eb8 --- /dev/null +++ b/ports/atmel-samd/boards/cp_sapling_m0/mpconfigboard.h @@ -0,0 +1,57 @@ +#define MICROPY_HW_BOARD_NAME "CP Sapling M0" +#define MICROPY_HW_MCU_NAME "samd21e18" + +#define MICROPY_HW_NEOPIXEL (&pin_PA15) + +#define MICROPY_PORT_A (0) +#define MICROPY_PORT_B (0) +#define MICROPY_PORT_C (0) + +#define IGNORE_PIN_PA02 1 +#define IGNORE_PIN_PA03 1 +#define IGNORE_PIN_PA04 1 +#define IGNORE_PIN_PA05 1 +#define IGNORE_PIN_PA06 1 +#define IGNORE_PIN_PA07 1 +#define IGNORE_PIN_PA12 1 +#define IGNORE_PIN_PA13 1 +#define IGNORE_PIN_PA14 1 +#define IGNORE_PIN_PA20 1 +#define IGNORE_PIN_PA21 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_SS (&pin_PA22) +#define DEFAULT_SPI_BUS_SCK (&pin_PA19) +#define DEFAULT_SPI_BUS_MOSI (&pin_PA18) +#define DEFAULT_SPI_BUS_MISO (&pin_PA17) diff --git a/ports/atmel-samd/boards/cp_sapling_m0/mpconfigboard.mk b/ports/atmel-samd/boards/cp_sapling_m0/mpconfigboard.mk new file mode 100644 index 0000000000..861a0a5f7d --- /dev/null +++ b/ports/atmel-samd/boards/cp_sapling_m0/mpconfigboard.mk @@ -0,0 +1,24 @@ +USB_VID = 0x1209 +USB_PID = 0x4DDD +USB_PRODUCT = "CP Sapling" +USB_MANUFACTURER = "Oak Development Technologies" + +CHIP_VARIANT = SAMD21E18A +CHIP_FAMILY = samd21 + +INTERNAL_FLASH_FILESYSTEM = 1 +LONGINT_IMPL = NONE +CIRCUITPY_FULL_BUILD = 0 + +SUPEROPT_GC = 0 + +CFLAGS_BOARD = --param max-inline-insns-auto=15 +ifeq ($(TRANSLATION), zh_Latn_pinyin) +RELEASE_NEEDS_CLEAN_BUILD = 1 +CFLAGS_INLINE_LIMIT = 35 +endif +ifeq ($(TRANSLATION), de_DE) +RELEASE_NEEDS_CLEAN_BUILD = 1 +CFLAGS_INLINE_LIMIT = 35 +SUPEROPT_VM = 0 +endif diff --git a/ports/atmel-samd/boards/cp_sapling_m0/pins.c b/ports/atmel-samd/boards/cp_sapling_m0/pins.c new file mode 100644 index 0000000000..ccffe2b3a1 --- /dev/null +++ b/ports/atmel-samd/boards/cp_sapling_m0/pins.c @@ -0,0 +1,38 @@ +#include "shared-bindings/board/__init__.h" + +STATIC const mp_rom_map_elem_t board_global_dict_table[] = { + + { MP_ROM_QSTR(MP_QSTR_D5), MP_ROM_PTR(&pin_PA08) }, + { MP_ROM_QSTR(MP_QSTR_SDA), MP_ROM_PTR(&pin_PA08) }, + + { MP_ROM_QSTR(MP_QSTR_D10), MP_ROM_PTR(&pin_PA00) }, + { MP_ROM_QSTR(MP_QSTR_A4), MP_ROM_PTR(&pin_PA00) }, + + { MP_ROM_QSTR(MP_QSTR_D11), MP_ROM_PTR(&pin_PA01) }, + { MP_ROM_QSTR(MP_QSTR_A5), MP_ROM_PTR(&pin_PA01) }, + + { MP_ROM_QSTR(MP_QSTR_D4), MP_ROM_PTR(&pin_PA09) }, + { MP_ROM_QSTR(MP_QSTR_SCL), MP_ROM_PTR(&pin_PA09) }, + + { MP_ROM_QSTR(MP_QSTR_D0), MP_ROM_PTR(&pin_PA22) }, + { MP_ROM_QSTR(MP_QSTR_A0), MP_ROM_PTR(&pin_PA22) }, + { MP_ROM_QSTR(MP_QSTR_SS), MP_ROM_PTR(&pin_PA22) }, + + { MP_ROM_QSTR(MP_QSTR_D3), MP_ROM_PTR(&pin_PA19) }, + { MP_ROM_QSTR(MP_QSTR_A3), MP_ROM_PTR(&pin_PA19) }, + { MP_ROM_QSTR(MP_QSTR_SCK), MP_ROM_PTR(&pin_PA19) }, + + { MP_ROM_QSTR(MP_QSTR_D1), MP_ROM_PTR(&pin_PA17) }, + { MP_ROM_QSTR(MP_QSTR_A1), MP_ROM_PTR(&pin_PA17) }, + { MP_ROM_QSTR(MP_QSTR_MISO), MP_ROM_PTR(&pin_PA17) }, + + { MP_ROM_QSTR(MP_QSTR_D2), MP_ROM_PTR(&pin_PA18) }, + { MP_ROM_QSTR(MP_QSTR_A2), MP_ROM_PTR(&pin_PA18) }, + { MP_ROM_QSTR(MP_QSTR_MOSI), MP_ROM_PTR(&pin_PA18) }, + + { MP_ROM_QSTR(MP_QSTR_NEOPIXEL), MP_ROM_PTR(&pin_PA15) }, + + { 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); From 1c92b1bf61cb0625a6ff7114623cd1cfdc6d5d75 Mon Sep 17 00:00:00 2001 From: Seth Kerr Date: Fri, 20 Nov 2020 15:35:52 -0500 Subject: [PATCH 096/207] forgot to run pre-commit local --- ports/atmel-samd/boards/cp_sapling_m0/board.c | 2 +- ports/atmel-samd/boards/cp_sapling_m0/pins.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/ports/atmel-samd/boards/cp_sapling_m0/board.c b/ports/atmel-samd/boards/cp_sapling_m0/board.c index b745bd9060..ce56366762 100644 --- a/ports/atmel-samd/boards/cp_sapling_m0/board.c +++ b/ports/atmel-samd/boards/cp_sapling_m0/board.c @@ -29,7 +29,7 @@ #include "supervisor/shared/board.h" #include "hal/include/hal_gpio.h" -void board_init(void) { +void board_init(void) { } bool board_requests_safe_mode(void) { diff --git a/ports/atmel-samd/boards/cp_sapling_m0/pins.c b/ports/atmel-samd/boards/cp_sapling_m0/pins.c index ccffe2b3a1..d527aaddcb 100644 --- a/ports/atmel-samd/boards/cp_sapling_m0/pins.c +++ b/ports/atmel-samd/boards/cp_sapling_m0/pins.c @@ -7,7 +7,7 @@ STATIC const mp_rom_map_elem_t board_global_dict_table[] = { { MP_ROM_QSTR(MP_QSTR_D10), MP_ROM_PTR(&pin_PA00) }, { MP_ROM_QSTR(MP_QSTR_A4), MP_ROM_PTR(&pin_PA00) }, - + { MP_ROM_QSTR(MP_QSTR_D11), MP_ROM_PTR(&pin_PA01) }, { MP_ROM_QSTR(MP_QSTR_A5), MP_ROM_PTR(&pin_PA01) }, @@ -31,7 +31,7 @@ STATIC const mp_rom_map_elem_t board_global_dict_table[] = { { MP_ROM_QSTR(MP_QSTR_MOSI), MP_ROM_PTR(&pin_PA18) }, { MP_ROM_QSTR(MP_QSTR_NEOPIXEL), MP_ROM_PTR(&pin_PA15) }, - + { 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 b34e36d1db127f84f4448f015406fa835cde48da Mon Sep 17 00:00:00 2001 From: Seth Kerr Date: Fri, 20 Nov 2020 15:44:53 -0500 Subject: [PATCH 097/207] fixing 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 f3e728a05c..fa60332112 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -197,6 +197,7 @@ jobs: - "circuitplayground_express_crickit" - "circuitplayground_express_displayio" - "clue_nrf52840_express" + - "cp_sapling_m0" - "cp32-m4" - "datalore_ip_m4" - "datum_distance" From 0fb075ab7e55b9cb7b84ece6a0247fd0b73dedb2 Mon Sep 17 00:00:00 2001 From: Seth Kerr Date: Fri, 20 Nov 2020 16:15:50 -0500 Subject: [PATCH 098/207] changed tab to spaces in build.yml, passes local pre-commit --- .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 fa60332112..4d04e3f93b 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -197,7 +197,7 @@ jobs: - "circuitplayground_express_crickit" - "circuitplayground_express_displayio" - "clue_nrf52840_express" - - "cp_sapling_m0" + - "cp_sapling_m0" - "cp32-m4" - "datalore_ip_m4" - "datum_distance" From 8301dcada00bdc63ac70de39ec5a0bdb6ae502ba Mon Sep 17 00:00:00 2001 From: Seth Kerr Date: Fri, 20 Nov 2020 16:26:33 -0500 Subject: [PATCH 099/207] I need to revisit the alphabet... --- .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 4d04e3f93b..8e72a40219 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -197,8 +197,8 @@ jobs: - "circuitplayground_express_crickit" - "circuitplayground_express_displayio" - "clue_nrf52840_express" - - "cp_sapling_m0" - "cp32-m4" + - "cp_sapling_m0" - "datalore_ip_m4" - "datum_distance" - "datum_imu" From f25ac45534c6bc00c4eb0d5aedb8fcdbb673a310 Mon Sep 17 00:00:00 2001 From: Noel Gaetan Date: Thu, 19 Nov 2020 17:19:09 +0000 Subject: [PATCH 100/207] Translated using Weblate (French) Currently translated at 100.0% (848 of 848 strings) Translation: CircuitPython/main Translate-URL: https://hosted.weblate.org/projects/circuitpython/main/fr/ --- locale/fr.po | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/locale/fr.po b/locale/fr.po index a15bbb8d50..b58ca6560b 100644 --- a/locale/fr.po +++ b/locale/fr.po @@ -8,8 +8,8 @@ msgstr "" "Project-Id-Version: 0.1\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2020-11-10 15:30+0530\n" -"PO-Revision-Date: 2020-11-15 16:28+0000\n" -"Last-Translator: Antonin ENFRUN \n" +"PO-Revision-Date: 2020-11-20 22:28+0000\n" +"Last-Translator: Noel Gaetan \n" "Language: fr\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=utf-8\n" @@ -1027,7 +1027,7 @@ msgstr "Taille de tampon incorrecte" #: ports/esp32s2/common-hal/watchdog/WatchDogTimer.c msgid "Initialization failed due to lack of memory" -msgstr "" +msgstr "L'initialisation a échoué par manque de mémoire" #: ports/atmel-samd/common-hal/pulseio/PulseIn.c msgid "Input taking too long" @@ -3715,7 +3715,7 @@ msgstr "les vecteurs doivent avoir la même longueur" #: ports/esp32s2/common-hal/watchdog/WatchDogTimer.c msgid "watchdog not initialized" -msgstr "" +msgstr "chien de garde non initialisé" #: shared-bindings/watchdog/WatchDogTimer.c msgid "watchdog timeout must be greater than 0" From 7b5e826b18d8777e5dcc994ea41b29e099cc9fa1 Mon Sep 17 00:00:00 2001 From: Jonny Bergdahl Date: Thu, 19 Nov 2020 22:11:10 +0000 Subject: [PATCH 101/207] Translated using Weblate (Swedish) Currently translated at 100.0% (848 of 848 strings) Translation: CircuitPython/main Translate-URL: https://hosted.weblate.org/projects/circuitpython/main/sv/ --- locale/sv.po | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/locale/sv.po b/locale/sv.po index 55e6368ae5..cc6fe8ad00 100644 --- a/locale/sv.po +++ b/locale/sv.po @@ -6,7 +6,7 @@ msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2020-11-10 15:30+0530\n" -"PO-Revision-Date: 2020-11-15 16:28+0000\n" +"PO-Revision-Date: 2020-11-20 22:28+0000\n" "Last-Translator: Jonny Bergdahl \n" "Language-Team: LANGUAGE \n" "Language: sv\n" @@ -1014,7 +1014,7 @@ msgstr "Fel buffertstorlek" #: ports/esp32s2/common-hal/watchdog/WatchDogTimer.c msgid "Initialization failed due to lack of memory" -msgstr "" +msgstr "Initieringen misslyckades på grund av minnesbrist" #: ports/atmel-samd/common-hal/pulseio/PulseIn.c msgid "Input taking too long" @@ -3672,7 +3672,7 @@ msgstr "vektorer måste ha samma längd" #: ports/esp32s2/common-hal/watchdog/WatchDogTimer.c msgid "watchdog not initialized" -msgstr "" +msgstr "watchdog är inte initierad" #: shared-bindings/watchdog/WatchDogTimer.c msgid "watchdog timeout must be greater than 0" From e4c66990e27779f43f4901d431b6c61f8da85f51 Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Fri, 20 Nov 2020 23:33:39 -0500 Subject: [PATCH 102/207] compiles --- ports/esp32s2/common-hal/alarm/__init__.c | 38 +++++++++------- ports/esp32s2/common-hal/alarm/pin/PinAlarm.c | 8 ++-- ports/esp32s2/common-hal/alarm/pin/PinAlarm.h | 2 +- .../common-hal/alarm/time/DurationAlarm.c | 5 ++- py/circuitpy_defns.mk | 11 +++-- py/enum.h | 4 +- py/genlast.py | 4 +- shared-bindings/alarm/ResetReason.c | 12 ++++- shared-bindings/alarm/ResetReason.h | 8 +++- shared-bindings/alarm/__init__.c | 45 +++++++++---------- shared-bindings/alarm/pin/PinAlarm.c | 11 ++--- shared-bindings/alarm/pin/PinAlarm.h | 5 ++- shared-bindings/alarm/time/DurationAlarm.c | 15 ++++--- shared-bindings/alarm/time/DurationAlarm.h | 2 + supervisor/shared/safe_mode.c | 1 + 15 files changed, 98 insertions(+), 73 deletions(-) diff --git a/ports/esp32s2/common-hal/alarm/__init__.c b/ports/esp32s2/common-hal/alarm/__init__.c index e8cb7b882e..d2ac3981ef 100644 --- a/ports/esp32s2/common-hal/alarm/__init__.c +++ b/ports/esp32s2/common-hal/alarm/__init__.c @@ -26,8 +26,8 @@ */ #include "shared-bindings/alarm/__init__.h" -#include "shared-bindings/alarm_io/__init__.h" -#include "shared-bindings/alarm_time/__init__.h" +#include "shared-bindings/alarm/pin/PinAlarm.h" +#include "shared-bindings/alarm/time/DurationAlarm.h" #include "esp_sleep.h" @@ -35,41 +35,47 @@ void common_hal_alarm_disable_all(void) { esp_sleep_disable_wakeup_source(ESP_SLEEP_WAKEUP_ALL); } -mp_obj_t common_hal_alarm_get_reset_reason(void) { +alarm_reset_reason_t common_hal_alarm_get_reset_reason(void) { switch (esp_sleep_get_wakeup_cause()) { case ESP_SLEEP_WAKEUP_TIMER: return RESET_REASON_DEEP_SLEEP_ALARM; + case ESP_SLEEP_WAKEUP_EXT0: return RESET_REASON_DEEP_SLEEP_ALARM; + case ESP_SLEEP_WAKEUP_TOUCHPAD: //TODO: implement TouchIO case ESP_SLEEP_WAKEUP_UNDEFINED: default: - return mp_const_none; - break; + return RESET_REASON_INVALID; } } mp_obj_t common_hal_alarm_get_wake_alarm(void) { switch (esp_sleep_get_wakeup_cause()) { - case ESP_SLEEP_WAKEUP_TIMER: ; - //Wake up from timer. - alarm_time_obj_t *timer = m_new_obj(alarm_time_obj_t); - timer->base.type = &alarm_time_type; + case ESP_SLEEP_WAKEUP_TIMER: { + // Wake up from timer. + alarm_time_duration_alarm_obj_t *timer = m_new_obj(alarm_time_duration_alarm_obj_t); + timer->base.type = &alarm_time_duration_alarm_type; return timer; - case ESP_SLEEP_WAKEUP_EXT0: ; - //Wake up from GPIO - alarm_io_obj_t *ext0 = m_new_obj(alarm_io_obj_t); - ext0->base.type = &alarm_io_type; + } + + case ESP_SLEEP_WAKEUP_EXT0: { + // Wake up from GPIO + alarm_pin_pin_alarm_obj_t *ext0 = m_new_obj(alarm_pin_pin_alarm_obj_t); + ext0->base.type = &alarm_pin_pin_alarm_type; return ext0; + } + case ESP_SLEEP_WAKEUP_TOUCHPAD: - //TODO: implement TouchIO - //Wake up from touch on pad, esp_sleep_get_touchpad_wakeup_status() + // TODO: implement TouchIO + // Wake up from touch on pad, esp_sleep_get_touchpad_wakeup_status() break; + case ESP_SLEEP_WAKEUP_UNDEFINED: default: - //Not a deep sleep reset + // Not a deep sleep reset. break; } return mp_const_none; diff --git a/ports/esp32s2/common-hal/alarm/pin/PinAlarm.c b/ports/esp32s2/common-hal/alarm/pin/PinAlarm.c index 1211406665..6ac3d05f87 100644 --- a/ports/esp32s2/common-hal/alarm/pin/PinAlarm.c +++ b/ports/esp32s2/common-hal/alarm/pin/PinAlarm.c @@ -27,15 +27,17 @@ #include "esp_sleep.h" -#include "shared-bindings/alarm/time/DurationAlarm.h" +#include "shared-bindings/alarm/pin/PinAlarm.h" +#include "shared-bindings/microcontroller/Pin.h" -void common_hal_alarm_pin_pin_pin_alarm_construct(alarm_pin_pin_alarm_obj_t *self, mcu_pin_obj_t *pin, bool level, bool edge, bool pull) { +void common_hal_alarm_pin_pin_alarm_construct(alarm_pin_pin_alarm_obj_t *self, const mcu_pin_obj_t *pin, bool level, bool edge, bool pull) { self->pin = pin; self->level = level; self->edge = edge; self->pull = pull; +} -mcu_pin_obj_t *common_hal_alarm_pin_pin_alarm_get_pin(alarm_pin_pin_alarm_obj_t *self) { +const mcu_pin_obj_t *common_hal_alarm_pin_pin_alarm_get_pin(alarm_pin_pin_alarm_obj_t *self) { return self->pin; } diff --git a/ports/esp32s2/common-hal/alarm/pin/PinAlarm.h b/ports/esp32s2/common-hal/alarm/pin/PinAlarm.h index 5273918584..c6a760b96a 100644 --- a/ports/esp32s2/common-hal/alarm/pin/PinAlarm.h +++ b/ports/esp32s2/common-hal/alarm/pin/PinAlarm.h @@ -29,7 +29,7 @@ typedef struct { mp_obj_base_t base; - mcu_pin_obj_t *pin; + const mcu_pin_obj_t *pin; bool level; bool edge; bool pull; diff --git a/ports/esp32s2/common-hal/alarm/time/DurationAlarm.c b/ports/esp32s2/common-hal/alarm/time/DurationAlarm.c index bf1a6cc421..80bf4244e3 100644 --- a/ports/esp32s2/common-hal/alarm/time/DurationAlarm.c +++ b/ports/esp32s2/common-hal/alarm/time/DurationAlarm.c @@ -27,6 +27,8 @@ #include "esp_sleep.h" +#include "py/runtime.h" + #include "shared-bindings/alarm/time/DurationAlarm.h" void common_hal_alarm_time_duration_alarm_construct(alarm_time_duration_alarm_obj_t *self, mp_float_t duration) { @@ -36,7 +38,8 @@ void common_hal_alarm_time_duration_alarm_construct(alarm_time_duration_alarm_ob mp_float_t common_hal_alarm_time_duration_alarm_get_duration(alarm_time_duration_alarm_obj_t *self) { return self->duration; } -void common_hal_alarm_time_duration_alarm_enable(alarm_time_duration_alarm_obj_t *self) + +void common_hal_alarm_time_duration_alarm_enable(alarm_time_duration_alarm_obj_t *self) { if (esp_sleep_enable_timer_wakeup((uint64_t) (self->duration * 1000000)) == ESP_ERR_INVALID_ARG) { mp_raise_ValueError(translate("duration out of range")); } diff --git a/py/circuitpy_defns.mk b/py/circuitpy_defns.mk index dbde1a34d6..d788a5411c 100644 --- a/py/circuitpy_defns.mk +++ b/py/circuitpy_defns.mk @@ -359,8 +359,6 @@ SRC_COMMON_HAL_ALL = \ rtc/__init__.c \ sdioio/SDCard.c \ sdioio/__init__.c \ - sleepio/__init__.c \ - sleepio/ResetReason.c \ socketpool/__init__.c \ socketpool/SocketPool.c \ socketpool/Socket.c \ @@ -395,9 +393,10 @@ $(filter $(SRC_PATTERNS), \ _bleio/Address.c \ _bleio/Attribute.c \ _bleio/ScanEntry.c \ - canio/Match.c \ _eve/__init__.c \ + alarm/ResetReason.c \ camera/ImageFormat.c \ + canio/Match.c \ digitalio/Direction.c \ digitalio/DriveMode.c \ digitalio/Pull.c \ @@ -414,9 +413,6 @@ SRC_SHARED_MODULE_ALL = \ _bleio/Attribute.c \ _bleio/ScanEntry.c \ _bleio/ScanResults.c \ - canio/Match.c \ - canio/Message.c \ - canio/RemoteTransmissionRequest.c \ _eve/__init__.c \ _pixelbuf/PixelBuf.c \ _pixelbuf/__init__.c \ @@ -441,6 +437,9 @@ SRC_SHARED_MODULE_ALL = \ bitbangio/__init__.c \ board/__init__.c \ busio/OneWire.c \ + canio/Match.c \ + canio/Message.c \ + canio/RemoteTransmissionRequest.c \ displayio/Bitmap.c \ displayio/ColorConverter.c \ displayio/Display.c \ diff --git a/py/enum.h b/py/enum.h index 1c38ae5ae6..708678eb69 100644 --- a/py/enum.h +++ b/py/enum.h @@ -35,12 +35,12 @@ typedef struct { } cp_enum_obj_t; #define MAKE_ENUM_VALUE(type, prefix, name, value) \ - STATIC const cp_enum_obj_t prefix ## _ ## name ## _obj = { \ + const cp_enum_obj_t prefix ## _ ## name ## _obj = { \ { &type }, value, MP_QSTR_ ## name, \ } #define MAKE_ENUM_MAP(name) \ - STATIC const mp_rom_map_elem_t name ## _locals_table[] = + const mp_rom_map_elem_t name ## _locals_table[] = #define MAKE_ENUM_MAP_ENTRY(prefix, name) \ { MP_ROM_QSTR(MP_QSTR_ ## name), MP_ROM_PTR(&prefix ## _ ## name ## _obj) } diff --git a/py/genlast.py b/py/genlast.py index 1df2a24825..5b195d23e4 100644 --- a/py/genlast.py +++ b/py/genlast.py @@ -47,7 +47,9 @@ def preprocess(command, output_dir, fn): print(e, file=sys.stderr) def maybe_preprocess(command, output_dir, fn): - if subprocess.call(["grep", "-lqE", "(MP_QSTR|translate)", fn]) == 0: + # Preprocess the source file if it contains "MP_QSTR", "translate", + # or if it uses enum.h (which generates "MP_QSTR" strings. + if subprocess.call(["grep", "-lqE", r"(MP_QSTR|translate|enum\.h)", fn]) == 0: preprocess(command, output_dir, fn) if __name__ == '__main__': diff --git a/shared-bindings/alarm/ResetReason.c b/shared-bindings/alarm/ResetReason.c index c46b2ba8f1..086562fc9c 100644 --- a/shared-bindings/alarm/ResetReason.c +++ b/shared-bindings/alarm/ResetReason.c @@ -24,18 +24,25 @@ * THE SOFTWARE. */ +#include "py/obj.h" #include "py/enum.h" #include "shared-bindings/alarm/ResetReason.h" -MAKE_ENUM_VALUE(alarm_reset_reason_type, reset_reason, POWER_VALID, RESET_REASON_POWER_ON); +MAKE_ENUM_VALUE(alarm_reset_reason_type, reset_reason, INVALID, RESET_REASON_INVALID); +MAKE_ENUM_VALUE(alarm_reset_reason_type, reset_reason, POWER_ON, RESET_REASON_POWER_ON); +MAKE_ENUM_VALUE(alarm_reset_reason_type, reset_reason, BROWNOUT, RESET_REASON_BROWNOUT); MAKE_ENUM_VALUE(alarm_reset_reason_type, reset_reason, SOFTWARE, RESET_REASON_SOFTWARE); MAKE_ENUM_VALUE(alarm_reset_reason_type, reset_reason, DEEP_SLEEP_ALARM, RESET_REASON_DEEP_SLEEP_ALARM); -MAKE_ENUM_VALUE(alarm_reset_reason_type, reset_reason, EXTERNAL, RESET_REASON_EXTERNAL); +MAKE_ENUM_VALUE(alarm_reset_reason_type, reset_reason, RESET_PIN, RESET_REASON_RESET_PIN); +MAKE_ENUM_VALUE(alarm_reset_reason_type, reset_reason, WATCHDOG, RESET_REASON_WATCHDOG); //| class ResetReason: //| """The reason the chip was last reset""" //| +//| INVALID: object +//| """Invalid reason: indicates an internal error.""" +//| //| POWER_ON: object //| """The chip was started from power off.""" //| @@ -55,6 +62,7 @@ MAKE_ENUM_VALUE(alarm_reset_reason_type, reset_reason, EXTERNAL, RESET_REASON_EX //| """The chip was reset by its watchdog timer.""" //| MAKE_ENUM_MAP(alarm_reset_reason) { + MAKE_ENUM_MAP_ENTRY(reset_reason, INVALID), MAKE_ENUM_MAP_ENTRY(reset_reason, POWER_ON), MAKE_ENUM_MAP_ENTRY(reset_reason, BROWNOUT), MAKE_ENUM_MAP_ENTRY(reset_reason, SOFTWARE), diff --git a/shared-bindings/alarm/ResetReason.h b/shared-bindings/alarm/ResetReason.h index 0325ba8e33..2d6b8bc0c3 100644 --- a/shared-bindings/alarm/ResetReason.h +++ b/shared-bindings/alarm/ResetReason.h @@ -27,7 +27,11 @@ #ifndef MICROPY_INCLUDED_SHARED_BINDINGS_ALARM__RESET_REASON__H #define MICROPY_INCLUDED_SHARED_BINDINGS_ALARM__RESET_REASON__H +#include "py/obj.h" +#include "py/enum.h" + typedef enum { + RESET_REASON_INVALID, RESET_REASON_POWER_ON, RESET_REASON_BROWNOUT, RESET_REASON_SOFTWARE, @@ -36,8 +40,8 @@ typedef enum { RESET_REASON_WATCHDOG, } alarm_reset_reason_t; +extern const cp_enum_obj_t reset_reason_INVALID_obj; + extern const mp_obj_type_t alarm_reset_reason_type; -extern alarm_reset_reason_t common_hal_alarm_get_reset_reason(void); - #endif // MICROPY_INCLUDED_SHARED_BINDINGS_ALARM__RESET_REASON__H diff --git a/shared-bindings/alarm/__init__.c b/shared-bindings/alarm/__init__.c index ecbf7fe04f..771c8ff9bf 100644 --- a/shared-bindings/alarm/__init__.c +++ b/shared-bindings/alarm/__init__.c @@ -34,6 +34,11 @@ #include "py/obj.h" #include "py/runtime.h" +#include "shared-bindings/alarm/__init__.h" +#include "shared-bindings/alarm/ResetReason.h" +#include "shared-bindings/alarm/pin/PinAlarm.h" +#include "shared-bindings/alarm/time/DurationAlarm.h" + STATIC mp_obj_t alarm_sleep_until_alarm(size_t n_args, const mp_obj_t *args) { // TODO return mp_const_none; @@ -56,47 +61,47 @@ MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(alarm_restart_on_alarm_obj, 1, MP_OBJ_FUN_AR //| """The `alarm.pin` module contains alarm attributes and classes related to pins //| """ //| -mp_map_elem_t alarm_pin_globals_table[] = { +STATIC const mp_map_elem_t alarm_pin_globals_table[] = { { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_pin) }, - { MP_ROM_QSTR(MP_QSTR_PinAlarm), MP_ROM_PTR(&alarm_pin_pin_alarm_type) }, + { MP_ROM_QSTR(MP_QSTR_PinAlarm), MP_OBJ_FROM_PTR(&alarm_pin_pin_alarm_type) }, }; STATIC MP_DEFINE_CONST_DICT(alarm_pin_globals, alarm_pin_globals_table); -const mp_obj_module_t alarm_pin_module = { +STATIC const mp_obj_module_t alarm_pin_module = { .base = { &mp_type_module }, - .globals = (mp_obj_dict_t*)&alarm_pinn_globals, + .globals = (mp_obj_dict_t*)&alarm_pin_globals, }; //| """The `alarm.time` module contains alarm attributes and classes related to time-keeping. //| """ //| -mp_map_elem_t alarm_time_globals_table[] = { +STATIC const mp_map_elem_t alarm_time_globals_table[] = { { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_time) }, - { MP_ROM_QSTR(MP_QSTR_DurationAlarm), MP_ROM_PTR(&alarm_time_duration_alarm_type) }, + { MP_ROM_QSTR(MP_QSTR_DurationAlarm), MP_OBJ_FROM_PTR(&alarm_time_duration_alarm_type) }, }; STATIC MP_DEFINE_CONST_DICT(alarm_time_globals, alarm_time_globals_table); -const mp_obj_module_t alarm_time_module = { +STATIC const mp_obj_module_t alarm_time_module = { .base = { &mp_type_module }, .globals = (mp_obj_dict_t*)&alarm_time_globals, }; -mp_map_elem_t alarm_module_globals_table[] = { +STATIC mp_map_elem_t alarm_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_alarm) }, // wake_alarm and reset_reason are mutable attributes. { MP_ROM_QSTR(MP_QSTR_wake_alarm), mp_const_none }, - { MP_ROM_QSTR(MP_QSTR_reset_reason), mp_const_none }, + { MP_ROM_QSTR(MP_QSTR_reset_reason), MP_OBJ_FROM_PTR(&reset_reason_INVALID_obj) }, - { MP_ROM_QSTR(MP_QSTR_sleep_until_alarm), MP_ROM_PTR(&alarm_sleep_until_alarm_obj) }, - { MP_ROM_QSTR(MP_QSTR_restart_on_alarm), MP_ROM_PTR(&alarm_restart_on_alarm_obj) }, + { MP_ROM_QSTR(MP_QSTR_sleep_until_alarm), MP_OBJ_FROM_PTR(&alarm_sleep_until_alarm_obj) }, + { MP_ROM_QSTR(MP_QSTR_restart_on_alarm), MP_OBJ_FROM_PTR(&alarm_restart_on_alarm_obj) }, - { MP_ROM_QSTR(MP_QSTR_pin), MP_ROM_PTR(&alarm_pin_module) }, - { MP_ROM_QSTR(MP_QSTR_time), MP_ROM_PTR(&alarm_time_module) } + { MP_ROM_QSTR(MP_QSTR_pin), MP_OBJ_FROM_PTR(&alarm_pin_module) }, + { MP_ROM_QSTR(MP_QSTR_time), MP_OBJ_FROM_PTR(&alarm_time_module) } }; STATIC MP_DEFINE_MUTABLE_DICT(alarm_module_globals, alarm_module_globals_table); @@ -105,27 +110,17 @@ void common_hal_alarm_set_wake_alarm(mp_obj_t alarm) { // Equivalent of: // alarm.wake_alarm = alarm mp_map_elem_t *elem = - mp_map_lookup(&alarm_module_globals_table, MP_ROM_QSTR(MP_QSTR_wake_alarm), MP_MAP_LOOKUP); + mp_map_lookup(&alarm_module_globals.map, MP_ROM_QSTR(MP_QSTR_wake_alarm), MP_MAP_LOOKUP); if (elem) { elem->value = alarm; } } -alarm_reset_reason_t common_hal_alarm_get_reset_reason(void) { - mp_map_elem_t *elem = - mp_map_lookup(&alarm_module_globals_table, MP_ROM_QSTR(MP_QSTR_reset_reason), MP_MAP_LOOKUP); - if (elem) { - return elem->value; - } else { - return mp_const_none; - } -} - void common_hal_alarm_set_reset_reason(mp_obj_t reset_reason) { // Equivalent of: // alarm.reset_reason = reset_reason mp_map_elem_t *elem = - mp_map_lookup(&alarm_module_globals_table, MP_ROM_QSTR(MP_QSTR_reset_reason), MP_MAP_LOOKUP); + mp_map_lookup(&alarm_module_globals.map, MP_ROM_QSTR(MP_QSTR_reset_reason), MP_MAP_LOOKUP); if (elem) { elem->value = reset_reason; } diff --git a/shared-bindings/alarm/pin/PinAlarm.c b/shared-bindings/alarm/pin/PinAlarm.c index 0146a3a1ad..fef1face76 100644 --- a/shared-bindings/alarm/pin/PinAlarm.c +++ b/shared-bindings/alarm/pin/PinAlarm.c @@ -27,6 +27,7 @@ #include "shared-bindings/board/__init__.h" #include "shared-bindings/microcontroller/__init__.h" #include "shared-bindings/microcontroller/Pin.h" +#include "shared-bindings/alarm/pin/PinAlarm.h" #include "py/nlr.h" #include "py/obj.h" @@ -58,8 +59,7 @@ //| """ //| ... //| -STATIC mp_obj_t alarm_pin_pin_alarm_make_new(const mp_obj_type_t *type, - mp_uint_t n_args, const mp_obj_t *args, mp_map_t *kw_args) { +STATIC mp_obj_t alarm_pin_pin_alarm_make_new(const mp_obj_type_t *type, mp_uint_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { alarm_pin_pin_alarm_obj_t *self = m_new_obj(alarm_pin_pin_alarm_obj_t); self->base.type = &alarm_pin_pin_alarm_type; enum { ARG_pin, ARG_level, ARG_edge, ARG_pull }; @@ -74,7 +74,7 @@ STATIC mp_obj_t alarm_pin_pin_alarm_make_new(const mp_obj_type_t *type, const mcu_pin_obj_t* pin = validate_obj_is_free_pin(args[ARG_pin].u_obj); - common_hal_alarm_pin_pin_pin_alarm_construct( + common_hal_alarm_pin_pin_alarm_construct( self, pin, args[ARG_level].u_bool, args[ARG_edge].u_bool, args[ARG_pull].u_bool); return MP_OBJ_FROM_PTR(self); @@ -110,11 +110,12 @@ STATIC mp_obj_t alarm_pin_pin_alarm_binary_op(mp_binary_op_t op, mp_obj_t lhs_in STATIC const mp_rom_map_elem_t alarm_pin_pin_alarm_locals_dict_table[] = { }; -STATIC MP_DEFINE_CONST_DICT(alarm_pin_pin_alarm_locals, alarm_pin_pin_alarm_locals_dict); +STATIC MP_DEFINE_CONST_DICT(alarm_pin_pin_alarm_locals_dict, alarm_pin_pin_alarm_locals_dict_table); const mp_obj_type_t alarm_pin_pin_alarm_type = { { &mp_type_type }, .name = MP_QSTR_PinAlarm, .make_new = alarm_pin_pin_alarm_make_new, - .locals_dict = (mp_obj_t)&alarm_pin_pin_alarm_locals, + .binary_op = alarm_pin_pin_alarm_binary_op, + .locals_dict = (mp_obj_t)&alarm_pin_pin_alarm_locals_dict, }; diff --git a/shared-bindings/alarm/pin/PinAlarm.h b/shared-bindings/alarm/pin/PinAlarm.h index b7c553ad5d..978ceaad56 100644 --- a/shared-bindings/alarm/pin/PinAlarm.h +++ b/shared-bindings/alarm/pin/PinAlarm.h @@ -29,11 +29,12 @@ #include "py/obj.h" #include "common-hal/microcontroller/Pin.h" +#include "common-hal/alarm/pin/PinAlarm.h" extern const mp_obj_type_t alarm_pin_pin_alarm_type; -extern void common_hal_alarm_pin_pin_pin_alarm_construct(alarm_pin_pin_alarm_obj_t *self, const mcu_pin_obj_t *pin, bool level, bool edge, bool pull); -extern mcu_pin_obj_t *common_hal_alarm_pin_pin_alarm_get_pin(alarm_pin_pin_alarm_obj_t *self); +extern void common_hal_alarm_pin_pin_alarm_construct(alarm_pin_pin_alarm_obj_t *self, const mcu_pin_obj_t *pin, bool level, bool edge, bool pull); +extern const mcu_pin_obj_t *common_hal_alarm_pin_pin_alarm_get_pin(alarm_pin_pin_alarm_obj_t *self); extern bool common_hal_alarm_pin_pin_alarm_get_level(alarm_pin_pin_alarm_obj_t *self); extern bool common_hal_alarm_pin_pin_alarm_get_edge(alarm_pin_pin_alarm_obj_t *self); extern bool common_hal_alarm_pin_pin_alarm_get_pull(alarm_pin_pin_alarm_obj_t *self); diff --git a/shared-bindings/alarm/time/DurationAlarm.c b/shared-bindings/alarm/time/DurationAlarm.c index c30c7f326c..5fb232f4ae 100644 --- a/shared-bindings/alarm/time/DurationAlarm.c +++ b/shared-bindings/alarm/time/DurationAlarm.c @@ -26,7 +26,7 @@ #include "shared-bindings/board/__init__.h" #include "shared-bindings/microcontroller/__init__.h" -#include "shared-bindings/microcontroller/Pin.h" +#include "shared-bindings/alarm/time/DurationAlarm.h" #include "py/nlr.h" #include "py/obj.h" @@ -49,8 +49,8 @@ STATIC mp_obj_t alarm_time_duration_alarm_make_new(const mp_obj_type_t *type, mp_uint_t n_args, const mp_obj_t *args, mp_map_t *kw_args) { mp_arg_check_num(n_args, kw_args, 1, 1, false); - alarm_pin_duration_alarm_obj_t *self = m_new_obj(alarm_pin_duration_alarm_obj_t); - self->base.type = &alarm_pin_pin_alarm_type; + alarm_time_duration_alarm_obj_t *self = m_new_obj(alarm_time_duration_alarm_obj_t); + self->base.type = &alarm_time_duration_alarm_type; mp_float_t secs = mp_obj_get_float(args[0]); @@ -60,7 +60,7 @@ STATIC mp_obj_t alarm_time_duration_alarm_make_new(const mp_obj_type_t *type, } //| def __eq__(self, other: object) -> bool: -//| """Two DurationAlarm objects are equal if their durations are the same.""" +//| """Two DurationAlarm objects are equal if their durations differ by less than a millisecond.""" //| ... //| STATIC mp_obj_t alarm_time_duration_alarm_binary_op(mp_binary_op_t op, mp_obj_t lhs_in, mp_obj_t rhs_in) { @@ -68,8 +68,8 @@ STATIC mp_obj_t alarm_time_duration_alarm_binary_op(mp_binary_op_t op, mp_obj_t case MP_BINARY_OP_EQUAL: if (MP_OBJ_IS_TYPE(rhs_in, &alarm_time_duration_alarm_type)) { return mp_obj_new_bool( - common_hal_alarm_time_duration_alarm_get_duration(lhs_in) == - common_hal_alarm_time_duration_alarm_get_duration(rhs_in)); + abs(common_hal_alarm_time_duration_alarm_get_duration(lhs_in) - + common_hal_alarm_time_duration_alarm_get_duration(rhs_in)) < 0.001f); } return mp_const_false; @@ -87,5 +87,6 @@ const mp_obj_type_t alarm_time_duration_alarm_type = { { &mp_type_type }, .name = MP_QSTR_DurationAlarm, .make_new = alarm_time_duration_alarm_make_new, - .locals_dict = (mp_obj_t)&alarm_time_duration_alarm_locals, + .binary_op = alarm_time_duration_alarm_binary_op, + .locals_dict = (mp_obj_t)&alarm_time_duration_alarm_locals_dict, }; diff --git a/shared-bindings/alarm/time/DurationAlarm.h b/shared-bindings/alarm/time/DurationAlarm.h index f6ab4f975c..87f5d9390c 100644 --- a/shared-bindings/alarm/time/DurationAlarm.h +++ b/shared-bindings/alarm/time/DurationAlarm.h @@ -29,6 +29,8 @@ #include "py/obj.h" +#include "common-hal/alarm/time/DurationAlarm.h" + extern const mp_obj_type_t alarm_time_duration_alarm_type; extern void common_hal_alarm_time_duration_alarm_construct(alarm_time_duration_alarm_obj_t *self, mp_float_t duration); diff --git a/supervisor/shared/safe_mode.c b/supervisor/shared/safe_mode.c index 7630010d03..ee8af2c2ca 100644 --- a/supervisor/shared/safe_mode.c +++ b/supervisor/shared/safe_mode.c @@ -30,6 +30,7 @@ #include "shared-bindings/digitalio/DigitalInOut.h" #if CIRCUITPY_ALARM +#include "shared-bindings/alarm/__init__.h" #include "shared-bindings/alarm/ResetReason.h" #endif From 75559f35ccc946dfd292e25671919e5d5b3bd7a6 Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Sat, 21 Nov 2020 23:29:52 -0500 Subject: [PATCH 103/207] wip: ResetReason to microcontroller.cpu --- locale/circuitpython.pot | 18 ++--- main.c | 9 +-- .../common-hal/microcontroller/Processor.c | 5 ++ .../common-hal/microcontroller/__init__.c | 4 - .../common-hal/microcontroller/Processor.c | 5 ++ .../common-hal/microcontroller/__init__.c | 4 - ports/esp32s2/common-hal/alarm/__init__.c | 17 ----- .../common-hal/microcontroller/Processor.c | 23 +++++- .../common-hal/microcontroller/__init__.c | 4 - .../common-hal/microcontroller/Processor.c | 8 +- .../common-hal/microcontroller/__init__.c | 4 - .../common-hal/microcontroller/Processor.c | 5 ++ .../common-hal/microcontroller/__init__.c | 4 - .../common-hal/microcontroller/Processor.c | 8 +- .../nrf/common-hal/microcontroller/__init__.c | 4 - .../common-hal/microcontroller/Processor.c | 9 ++- .../stm/common-hal/microcontroller/__init__.c | 4 - py/circuitpy_defns.mk | 2 +- shared-bindings/_typing/__init__.pyi | 11 ++- shared-bindings/alarm/__init__.c | 74 +++++++++++-------- shared-bindings/alarm/__init__.h | 6 +- shared-bindings/alarm/pin/PinAlarm.c | 28 +++---- shared-bindings/alarm/time/DurationAlarm.c | 11 ++- shared-bindings/microcontroller/Processor.c | 18 +++++ shared-bindings/microcontroller/Processor.h | 3 +- .../{alarm => microcontroller}/ResetReason.c | 41 +++++----- .../{alarm => microcontroller}/ResetReason.h | 18 +++-- shared-bindings/microcontroller/__init__.c | 9 --- shared-bindings/microcontroller/__init__.h | 4 +- shared-bindings/supervisor/RunReason.c | 38 +++++----- shared-bindings/supervisor/RunReason.h | 4 +- shared-bindings/supervisor/Runtime.c | 10 +-- supervisor/shared/safe_mode.c | 14 ++-- 33 files changed, 220 insertions(+), 206 deletions(-) rename shared-bindings/{alarm => microcontroller}/ResetReason.c (54%) rename shared-bindings/{alarm => microcontroller}/ResetReason.h (71%) diff --git a/locale/circuitpython.pot b/locale/circuitpython.pot index 969f3f36fb..1dae9547a3 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-11-19 00:28-0500\n" +"POT-Creation-Date: 2020-11-21 12:36-0500\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -990,7 +990,7 @@ msgstr "" msgid "I2SOut not available" msgstr "" -#: ports/esp32s2/common-hal/alarm_io/__init__.c +#: ports/esp32s2/common-hal/alarm/pin/__init__.c msgid "IOs 0, 2 & 4 do not support internal pullup in sleep" msgstr "" @@ -2449,6 +2449,10 @@ msgstr "" msgid "division by zero" msgstr "" +#: ports/esp32s2/common-hal/alarm/time/DurationAlarm.c +msgid "duration out of range" +msgstr "" + #: py/objdeque.c msgid "empty" msgstr "" @@ -2809,7 +2813,7 @@ msgstr "" msgid "invalid syntax for number" msgstr "" -#: ports/esp32s2/common-hal/alarm_io/__init__.c +#: ports/esp32s2/common-hal/alarm/pin/__init__.c msgid "io must be rtc io" msgstr "" @@ -3434,10 +3438,6 @@ msgstr "" msgid "threshold must be in the range 0-65536" msgstr "" -#: ports/esp32s2/common-hal/alarm_time/__init__.c -msgid "time out of range" -msgstr "" - #: shared-bindings/time/__init__.c msgid "time.struct_time() takes a 9-sequence" msgstr "" @@ -3484,7 +3484,7 @@ msgstr "" msgid "trapz is defined for 1D arrays of equal length" msgstr "" -#: ports/esp32s2/common-hal/alarm_io/__init__.c +#: ports/esp32s2/common-hal/alarm/pin/__init__.c msgid "trigger level must be 0 or 1" msgstr "" @@ -3630,7 +3630,7 @@ msgstr "" msgid "vectors must have same lengths" msgstr "" -#: ports/esp32s2/common-hal/alarm_io/__init__.c +#: ports/esp32s2/common-hal/alarm/pin/__init__.c msgid "wakeup conflict" msgstr "" diff --git a/main.c b/main.c index 30ceaeaa6d..8938d714af 100755 --- a/main.c +++ b/main.c @@ -330,7 +330,7 @@ bool run_code_py(safe_mode_t safe_mode) { #if CIRCUITPY_ALARM // If USB isn't enumerated then deep sleep. if (ok && !supervisor_workflow_active() && supervisor_ticks_ms64() > CIRCUITPY_USB_ENUMERATION_DELAY * 1024) { - common_hal_mcu_deep_sleep(); + common_hal_alarm_restart_on_alarm(0, NULL); } #endif // Show the animation every N seconds. @@ -430,14 +430,9 @@ void __attribute__ ((noinline)) run_boot_py(safe_mode_t safe_mode) { if (!skip_boot_output) { // Wait 1.5 seconds before opening CIRCUITPY_BOOT_OUTPUT_FILE for write, // in case power is momentary or will fail shortly due to, say a low, battery. -#if CIRCUITPY_ALARM - if (common_hal_alarm_get_reset_reason() == RESET_REASON_POWER_ON) { -#endif + if (common_hal_mcu_processor_get_reset_reason() == RESET_REASON_POWER_ON) { mp_hal_delay_ms(1500); -#if CIRCUITPY_ALARM } -#endif - // USB isn't up, so we can write the file. filesystem_set_internal_writable_by_usb(false); f_open(fs, boot_output_file, CIRCUITPY_BOOT_OUTPUT_FILE, FA_WRITE | FA_CREATE_ALWAYS); diff --git a/ports/atmel-samd/common-hal/microcontroller/Processor.c b/ports/atmel-samd/common-hal/microcontroller/Processor.c index ba8daf3fb0..9955212657 100644 --- a/ports/atmel-samd/common-hal/microcontroller/Processor.c +++ b/ports/atmel-samd/common-hal/microcontroller/Processor.c @@ -65,6 +65,7 @@ #include "py/mphal.h" #include "common-hal/microcontroller/Processor.h" +#include "shared-bindings/microcontroller/ResetReason.h" #include "samd/adc.h" @@ -349,3 +350,7 @@ void common_hal_mcu_processor_get_uid(uint8_t raw_id[]) { } } } + +mcu_reset_reason_t common_hal_mcu_processor_get_reset_reason(void) { + return RESET_REASON_POWER_ON; +} diff --git a/ports/atmel-samd/common-hal/microcontroller/__init__.c b/ports/atmel-samd/common-hal/microcontroller/__init__.c index ca39f28386..50a1ec038e 100644 --- a/ports/atmel-samd/common-hal/microcontroller/__init__.c +++ b/ports/atmel-samd/common-hal/microcontroller/__init__.c @@ -84,10 +84,6 @@ void common_hal_mcu_reset(void) { reset(); } -void common_hal_mcu_deep_sleep(void) { - //deep sleep call here -} - // 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 = { diff --git a/ports/cxd56/common-hal/microcontroller/Processor.c b/ports/cxd56/common-hal/microcontroller/Processor.c index 1eddbb01de..bd778e80dd 100644 --- a/ports/cxd56/common-hal/microcontroller/Processor.c +++ b/ports/cxd56/common-hal/microcontroller/Processor.c @@ -31,6 +31,7 @@ // For NAN: remove when not needed. #include #include "py/mphal.h" +#include "shared-bindings/microcontroller/ResetReason.h" uint32_t common_hal_mcu_processor_get_frequency(void) { return cxd56_get_cpu_baseclk(); @@ -47,3 +48,7 @@ float common_hal_mcu_processor_get_voltage(void) { void common_hal_mcu_processor_get_uid(uint8_t raw_id[]) { boardctl(BOARDIOC_UNIQUEID, (uintptr_t) raw_id); } + +mcu_reset_reason_t common_hal_mcu_processor_get_reset_reason(void) { + return RESET_REASON_POWER_ON; +} diff --git a/ports/cxd56/common-hal/microcontroller/__init__.c b/ports/cxd56/common-hal/microcontroller/__init__.c index 57140dec70..7aa3b839d7 100644 --- a/ports/cxd56/common-hal/microcontroller/__init__.c +++ b/ports/cxd56/common-hal/microcontroller/__init__.c @@ -81,10 +81,6 @@ void common_hal_mcu_reset(void) { boardctl(BOARDIOC_RESET, 0); } -void common_hal_mcu_deep_sleep(void) { - //deep sleep call here -} - STATIC const mp_rom_map_elem_t mcu_pin_globals_table[] = { { MP_ROM_QSTR(MP_QSTR_UART2_RXD), MP_ROM_PTR(&pin_UART2_RXD) }, { MP_ROM_QSTR(MP_QSTR_UART2_TXD), MP_ROM_PTR(&pin_UART2_TXD) }, diff --git a/ports/esp32s2/common-hal/alarm/__init__.c b/ports/esp32s2/common-hal/alarm/__init__.c index d2ac3981ef..e335345508 100644 --- a/ports/esp32s2/common-hal/alarm/__init__.c +++ b/ports/esp32s2/common-hal/alarm/__init__.c @@ -35,23 +35,6 @@ void common_hal_alarm_disable_all(void) { esp_sleep_disable_wakeup_source(ESP_SLEEP_WAKEUP_ALL); } -alarm_reset_reason_t common_hal_alarm_get_reset_reason(void) { - switch (esp_sleep_get_wakeup_cause()) { - case ESP_SLEEP_WAKEUP_TIMER: - return RESET_REASON_DEEP_SLEEP_ALARM; - - case ESP_SLEEP_WAKEUP_EXT0: - return RESET_REASON_DEEP_SLEEP_ALARM; - - case ESP_SLEEP_WAKEUP_TOUCHPAD: - //TODO: implement TouchIO - case ESP_SLEEP_WAKEUP_UNDEFINED: - default: - return RESET_REASON_INVALID; - } -} - - mp_obj_t common_hal_alarm_get_wake_alarm(void) { switch (esp_sleep_get_wakeup_cause()) { case ESP_SLEEP_WAKEUP_TIMER: { diff --git a/ports/esp32s2/common-hal/microcontroller/Processor.c b/ports/esp32s2/common-hal/microcontroller/Processor.c index b815216012..bd625dc6e2 100644 --- a/ports/esp32s2/common-hal/microcontroller/Processor.c +++ b/ports/esp32s2/common-hal/microcontroller/Processor.c @@ -28,8 +28,9 @@ #include #include -#include "common-hal/microcontroller/Processor.h" #include "py/runtime.h" + +#include "common-hal/microcontroller/Processor.h" #include "supervisor/shared/translate.h" #include "soc/efuse_reg.h" @@ -74,3 +75,23 @@ void common_hal_mcu_processor_get_uid(uint8_t raw_id[]) { *ptr-- = swap_nibbles(mac_address_part & 0xff); mac_address_part >>= 8; *ptr-- = swap_nibbles(mac_address_part & 0xff); } + +mcu_reset_reason_t common_hal_mcu_processor_get_reset_reason(void) { + switch (esp_sleep_get_wakeup_cause()) { + case ESP_SLEEP_WAKEUP_TIMER: + return RESET_REASON_DEEP_SLEEP_ALARM; + + case ESP_SLEEP_WAKEUP_EXT0: + return RESET_REASON_DEEP_SLEEP_ALARM; + + case ESP_SLEEP_WAKEUP_TOUCHPAD: + //TODO: implement TouchIO + case ESP_SLEEP_WAKEUP_UNDEFINED: + default: + return RESET_REASON_POWER_APPLIED; + } +} + +mcu_reset_reason_t common_hal_mcu_processor_get_reset_reason(void) { + return RESET_REASON_POWER_ON; +} diff --git a/ports/esp32s2/common-hal/microcontroller/__init__.c b/ports/esp32s2/common-hal/microcontroller/__init__.c index 79cb938939..3056c65655 100644 --- a/ports/esp32s2/common-hal/microcontroller/__init__.c +++ b/ports/esp32s2/common-hal/microcontroller/__init__.c @@ -79,10 +79,6 @@ void common_hal_mcu_reset(void) { while(1); } -void common_hal_mcu_deep_sleep(void) { - esp_deep_sleep_start(); -} - // 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 = { diff --git a/ports/litex/common-hal/microcontroller/Processor.c b/ports/litex/common-hal/microcontroller/Processor.c index 9d2b05aade..013a7ca035 100644 --- a/ports/litex/common-hal/microcontroller/Processor.c +++ b/ports/litex/common-hal/microcontroller/Processor.c @@ -26,8 +26,10 @@ */ #include -#include "common-hal/microcontroller/Processor.h" #include "py/runtime.h" + +#include "common-hal/microcontroller/Processor.h" +#include "shared-bindings/microcontroller/ResetReason.h" #include "supervisor/shared/translate.h" #include "csr.h" @@ -62,3 +64,7 @@ void common_hal_mcu_processor_get_uid(uint8_t raw_id[]) { raw_id[13] = csr_readl(CSR_VERSION_SEED_ADDR + 8); raw_id[14] = csr_readl(CSR_VERSION_SEED_ADDR + 12); } + +mcu_reset_reason_t common_hal_mcu_processor_get_reset_reason(void) { + return RESET_REASON_POWER_ON; +} diff --git a/ports/litex/common-hal/microcontroller/__init__.c b/ports/litex/common-hal/microcontroller/__init__.c index e6f50ed5a6..3c91661144 100644 --- a/ports/litex/common-hal/microcontroller/__init__.c +++ b/ports/litex/common-hal/microcontroller/__init__.c @@ -89,10 +89,6 @@ void common_hal_mcu_reset(void) { while(1); } -void common_hal_mcu_deep_sleep(void) { - //deep sleep call here -} - // 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 = { diff --git a/ports/mimxrt10xx/common-hal/microcontroller/Processor.c b/ports/mimxrt10xx/common-hal/microcontroller/Processor.c index f3a578014e..28fe67db7c 100644 --- a/ports/mimxrt10xx/common-hal/microcontroller/Processor.c +++ b/ports/mimxrt10xx/common-hal/microcontroller/Processor.c @@ -28,6 +28,7 @@ #include #include "common-hal/microcontroller/Processor.h" +#include "shared-bindings/microcontroller/ResetReason.h" #include "fsl_tempmon.h" #include "fsl_ocotp.h" @@ -70,3 +71,7 @@ void common_hal_mcu_processor_get_uid(uint8_t raw_id[]) { } OCOTP_Deinit(OCOTP); } + +mcu_reset_reason_t common_hal_mcu_processor_get_reset_reason(void) { + return RESET_REASON_POWER_ON; +} diff --git a/ports/mimxrt10xx/common-hal/microcontroller/__init__.c b/ports/mimxrt10xx/common-hal/microcontroller/__init__.c index 0329ced69b..6a8537e2da 100644 --- a/ports/mimxrt10xx/common-hal/microcontroller/__init__.c +++ b/ports/mimxrt10xx/common-hal/microcontroller/__init__.c @@ -86,10 +86,6 @@ void common_hal_mcu_reset(void) { NVIC_SystemReset(); } -void common_hal_mcu_deep_sleep(void) { - //deep sleep call here -} - // 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 = { diff --git a/ports/nrf/common-hal/microcontroller/Processor.c b/ports/nrf/common-hal/microcontroller/Processor.c index 03d9c4d3f0..e2695139c5 100644 --- a/ports/nrf/common-hal/microcontroller/Processor.c +++ b/ports/nrf/common-hal/microcontroller/Processor.c @@ -24,8 +24,10 @@ * THE SOFTWARE. */ -#include "common-hal/microcontroller/Processor.h" #include "py/runtime.h" + +#include "common-hal/microcontroller/Processor.h" +#include "shared-bindings/microcontroller/ResetReason.h" #include "supervisor/shared/translate.h" #include "nrfx_saadc.h" @@ -119,3 +121,7 @@ void common_hal_mcu_processor_get_uid(uint8_t raw_id[]) { ((uint32_t*) raw_id)[i] = NRF_FICR->DEVICEID[i]; } } + +mcu_reset_reason_t common_hal_mcu_processor_get_reset_reason(void) { + return RESET_REASON_POWER_ON; +} diff --git a/ports/nrf/common-hal/microcontroller/__init__.c b/ports/nrf/common-hal/microcontroller/__init__.c index 9911896bff..06aac9409d 100644 --- a/ports/nrf/common-hal/microcontroller/__init__.c +++ b/ports/nrf/common-hal/microcontroller/__init__.c @@ -95,10 +95,6 @@ void common_hal_mcu_reset(void) { reset_cpu(); } -void common_hal_mcu_deep_sleep(void) { - //deep sleep call here -} - // 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 = { diff --git a/ports/stm/common-hal/microcontroller/Processor.c b/ports/stm/common-hal/microcontroller/Processor.c index 8dc968b36a..d77d287a9e 100644 --- a/ports/stm/common-hal/microcontroller/Processor.c +++ b/ports/stm/common-hal/microcontroller/Processor.c @@ -25,9 +25,12 @@ */ #include -#include "common-hal/microcontroller/Processor.h" #include "py/runtime.h" + +#include "common-hal/microcontroller/Processor.h" +#include "shared-bindings/microcontroller/ResetReason.h" #include "supervisor/shared/translate.h" + #include STM32_HAL_H #if CPY_STM32F4 @@ -138,3 +141,7 @@ void common_hal_mcu_processor_get_uid(uint8_t raw_id[]) { } #endif } + +mcu_reset_reason_t common_hal_mcu_processor_get_reset_reason(void) { + return RESET_REASON_POWER_ON; +} diff --git a/ports/stm/common-hal/microcontroller/__init__.c b/ports/stm/common-hal/microcontroller/__init__.c index bc81b0e4f5..a827399ccb 100644 --- a/ports/stm/common-hal/microcontroller/__init__.c +++ b/ports/stm/common-hal/microcontroller/__init__.c @@ -81,10 +81,6 @@ void common_hal_mcu_reset(void) { NVIC_SystemReset(); } -void common_hal_mcu_deep_sleep(void) { - //deep sleep call here -} - // 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 = { diff --git a/py/circuitpy_defns.mk b/py/circuitpy_defns.mk index d788a5411c..2731f2ae8d 100644 --- a/py/circuitpy_defns.mk +++ b/py/circuitpy_defns.mk @@ -394,7 +394,6 @@ $(filter $(SRC_PATTERNS), \ _bleio/Attribute.c \ _bleio/ScanEntry.c \ _eve/__init__.c \ - alarm/ResetReason.c \ camera/ImageFormat.c \ canio/Match.c \ digitalio/Direction.c \ @@ -402,6 +401,7 @@ $(filter $(SRC_PATTERNS), \ digitalio/Pull.c \ fontio/Glyph.c \ math/__init__.c \ + microcontroller/ResetReason.c \ microcontroller/RunMode.c \ ) diff --git a/shared-bindings/_typing/__init__.pyi b/shared-bindings/_typing/__init__.pyi index 3b3f18cb9b..02839ab477 100644 --- a/shared-bindings/_typing/__init__.pyi +++ b/shared-bindings/_typing/__init__.pyi @@ -54,13 +54,12 @@ FrameBuffer = Union[rgbmatrix.RGBMatrix] """ Alarm = Union[ - alarm_time.Time, alarm_pin.PinLevel, alarm_touch.PinTouch + alarm.pin.PinAlarm, alarm.time.DurationAlarm ] -"""Classes that implement the audiosample protocol +"""Classes that implement alarms for sleeping and asynchronous notification. - - `alarm_time.Time` - - `alarm_pin.PinLevel` - - `alarm_touch.PinTouch` + - `alarm.pin.PinAlarm` + - `alarm.time.DurationAlarm` - You can play use these alarms to wake from light or deep sleep. + You can use these alarms to wake from light or deep sleep. """ diff --git a/shared-bindings/alarm/__init__.c b/shared-bindings/alarm/__init__.c index 771c8ff9bf..9345442164 100644 --- a/shared-bindings/alarm/__init__.c +++ b/shared-bindings/alarm/__init__.c @@ -1,3 +1,37 @@ +/* + * 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 "py/obj.h" +#include "py/runtime.h" + +#include "shared-bindings/alarm/__init__.h" +#include "shared-bindings/alarm/ResetReason.h" +#include "shared-bindings/alarm/pin/PinAlarm.h" +#include "shared-bindings/alarm/time/DurationAlarm.h" + //| """Power-saving light and deep sleep. Alarms can be set to wake up from sleep. //| //| The `alarm` module provides sleep related functionality. There are two supported levels of @@ -11,54 +45,43 @@ //| Deep sleep shuts down power to nearly all of the chip including the CPU and RAM. This can save //| a more significant amount of power, but CircuitPython must start ``code.py`` from the beginning when woken //| up. CircuitPython will enter deep sleep automatically when the current program exits without error -//| or calls `sys.exit(0)`. +//| or calls ``sys.exit(0)``. //| If an error causes CircuitPython to exit, error LED error flashes will be done periodically. //| An error includes an uncaught exception, or sys.exit called with a non-zero argumetn. -//| To set alarms for deep sleep use `alarm.reload_on_alarm()` they will apply to next deep sleep only.""" +//| To set alarms for deep sleep use `alarm.restart_on_alarm()` they will apply to next deep sleep only.""" //| - //| wake_alarm: Alarm //| """The most recent alarm to wake us up from a sleep (light or deep.)""" //| -//| reset_reason: ResetReason -//| """The reason the chip started up from reset state. This can may be power up or due to an alarm.""" -//| - -//| def sleep(alarm: Alarm, ...) -> Alarm: +//| def sleep_until_alarm(*alarms: Alarm) -> Alarm: //| """Performs a light sleep until woken by one of the alarms. The alarm that triggers the wake //| is returned, and is also available as `alarm.wake_alarm` +//| """ //| ... //| - -#include "py/obj.h" -#include "py/runtime.h" - -#include "shared-bindings/alarm/__init__.h" -#include "shared-bindings/alarm/ResetReason.h" -#include "shared-bindings/alarm/pin/PinAlarm.h" -#include "shared-bindings/alarm/time/DurationAlarm.h" - STATIC mp_obj_t alarm_sleep_until_alarm(size_t n_args, const mp_obj_t *args) { // TODO + common_hal_alarm_sleep_until_alarm(size_t n_args, const mp_obj_t *args); return mp_const_none; } MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(alarm_sleep_until_alarm_obj, 1, MP_OBJ_FUN_ARGS_MAX, alarm_sleep_until_alarm); -//| def restart_on_alarm(alarm: Alarm, ...) -> None: +//| def restart_on_alarm(*alarms: Alarm) -> None: //| """Set one or more alarms to wake up from a deep sleep. //| When awakened, ``code.py`` will restart from the beginning. -//| The last alarm to wake us up is available as `wake_alarm`. +//| The last alarm to wake us up is available as `alarm.wake_alarm`. //| """ //| ... //| STATIC mp_obj_t alarm_restart_on_alarm(size_t n_args, const mp_obj_t *args) { // TODO + common_hal_alarm_restart_on_alarm(size_t n_args, const mp_obj_t *args); return mp_const_none; } MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(alarm_restart_on_alarm_obj, 1, MP_OBJ_FUN_ARGS_MAX, alarm_restart_on_alarm); -//| """The `alarm.pin` module contains alarm attributes and classes related to pins +//| """The `alarm.pin` module contains alarm attributes and classes related to pins. //| """ //| STATIC const mp_map_elem_t alarm_pin_globals_table[] = { @@ -95,7 +118,6 @@ STATIC mp_map_elem_t alarm_module_globals_table[] = { // wake_alarm and reset_reason are mutable attributes. { MP_ROM_QSTR(MP_QSTR_wake_alarm), mp_const_none }, - { MP_ROM_QSTR(MP_QSTR_reset_reason), MP_OBJ_FROM_PTR(&reset_reason_INVALID_obj) }, { MP_ROM_QSTR(MP_QSTR_sleep_until_alarm), MP_OBJ_FROM_PTR(&alarm_sleep_until_alarm_obj) }, { MP_ROM_QSTR(MP_QSTR_restart_on_alarm), MP_OBJ_FROM_PTR(&alarm_restart_on_alarm_obj) }, @@ -116,16 +138,6 @@ void common_hal_alarm_set_wake_alarm(mp_obj_t alarm) { } } -void common_hal_alarm_set_reset_reason(mp_obj_t reset_reason) { - // Equivalent of: - // alarm.reset_reason = reset_reason - mp_map_elem_t *elem = - mp_map_lookup(&alarm_module_globals.map, MP_ROM_QSTR(MP_QSTR_reset_reason), MP_MAP_LOOKUP); - if (elem) { - elem->value = reset_reason; - } -} - const mp_obj_module_t alarm_module = { .base = { &mp_type_module }, .globals = (mp_obj_dict_t*)&alarm_module_globals, diff --git a/shared-bindings/alarm/__init__.h b/shared-bindings/alarm/__init__.h index a0ee76e53b..29be8716c5 100644 --- a/shared-bindings/alarm/__init__.h +++ b/shared-bindings/alarm/__init__.h @@ -29,11 +29,9 @@ #include "py/obj.h" -#include "shared-bindings/alarm/ResetReason.h" - extern void common_hal_alarm_set_wake_alarm(mp_obj_t alarm); -extern alarm_reset_reason_t common_hal_alarm_get_reset_reason(void); -extern void common_hal_alarm_set_reset_reason(mp_obj_t reset_reason); +extern mp_obj_t common_hal_alarm_restart_on_alarm(size_t n_alarms, const mp_obj_t *alarms); +extern mp_obj_t alarm_sleep_until_alarm(size_t n_alarms, const mp_obj_t *alarms); #endif // MICROPY_INCLUDED_SHARED_BINDINGS_ALARM___INIT___H diff --git a/shared-bindings/alarm/pin/PinAlarm.c b/shared-bindings/alarm/pin/PinAlarm.c index fef1face76..835a5be5ce 100644 --- a/shared-bindings/alarm/pin/PinAlarm.c +++ b/shared-bindings/alarm/pin/PinAlarm.c @@ -35,27 +35,27 @@ #include "supervisor/shared/translate.h" //| class PinAlarm: -//| """Trigger an alarm when a pin changes state. +//| """Trigger an alarm when a pin changes state.""" //| //| def __init__(self, pin: microcontroller.Pin, level: bool, *, edge: bool = False, pull: bool = False) -> None: //| """Create an alarm triggered by a `~microcontroller.Pin` level. The alarm is not active -//| until it is listed in an `alarm`-enabling function, such as `alarm.sleep()` or -//| `alarm.wake_after_exit()`. - +//| until it is listed in an `alarm`-enabling function, such as `alarm.sleep_until_alarm()` or +//| `alarm.restart_on_alarm()`. +//| //| :param ~microcontroller.Pin pin: The pin to monitor. On some ports, the choice of pin -//| may be limited due to hardware restrictions, particularly for deep-sleep alarms. +//| may be limited due to hardware restrictions, particularly for deep-sleep alarms. //| :param bool level: When active, trigger when the level is high (``True``) or low (``False``). -//| On some ports, multiple `PinAlarm` objects may need to have coordinated levels -//| for deep-sleep alarms +//| On some ports, multiple `PinAlarm` objects may need to have coordinated levels +//| for deep-sleep alarms. //| :param bool edge: If ``True``, trigger only when there is a transition to the specified -//| value of `level`. If ``True``, if the alarm becomes active when the pin level already -//| matches `level`, the alarm is not triggered: the pin must transition from ``not level`` -//| to ``level`` to trigger the alarm. On some ports, edge-triggering may not be available, -//| particularly for deep-sleep alarms. +//| value of `level`. If ``True``, if the alarm becomes active when the pin level already +//| matches `level`, the alarm is not triggered: the pin must transition from ``not level`` +//| to ``level`` to trigger the alarm. On some ports, edge-triggering may not be available, +//| particularly for deep-sleep alarms. //| :param bool pull: Enable a pull-up or pull-down which pulls the pin to level opposite -//| opposite that of `level`. For instance, if `level` is set to ``True``, setting `pull` -//| to ``True`` will enable a pull-down, to hold the pin low normally until an outside signal -//| pulls it high. +//| opposite that of `level`. For instance, if `level` is set to ``True``, setting `pull` +//| to ``True`` will enable a pull-down, to hold the pin low normally until an outside signal +//| pulls it high. //| """ //| ... //| diff --git a/shared-bindings/alarm/time/DurationAlarm.c b/shared-bindings/alarm/time/DurationAlarm.c index 5fb232f4ae..c105bbebf7 100644 --- a/shared-bindings/alarm/time/DurationAlarm.c +++ b/shared-bindings/alarm/time/DurationAlarm.c @@ -34,14 +34,13 @@ #include "supervisor/shared/translate.h" //| class DurationAlarm: -//| """Trigger an alarm at a specified interval from now. +//| """Trigger an alarm at a specified interval from now.""" //| //| def __init__(self, secs: float) -> None: -//| """Create an alarm that will be triggered in `secs` seconds **from the time -//| the alarm is created**. The alarm is not active until it is listed in an -//| `alarm`-enabling function, such as `alarm.sleep()` or -//| `alarm.wake_after_exit()`. But the interval starts immediately upon -//| instantiation. +//| """Create an alarm that will be triggered in `secs` seconds from the time +//| sleep starts. The alarm is not active until it is listed in an +//| `alarm`-enabling function, such as `alarm.sleep_until_alarm()` or +//| `alarm.restart_on_alarm()`. //| """ //| ... //| diff --git a/shared-bindings/microcontroller/Processor.c b/shared-bindings/microcontroller/Processor.c index 8c703891d7..b0ab842f4c 100644 --- a/shared-bindings/microcontroller/Processor.c +++ b/shared-bindings/microcontroller/Processor.c @@ -67,6 +67,23 @@ const mp_obj_property_t mcu_processor_frequency_obj = { }, }; +//| reset_reason: `microcontroller.ResetReason` +//| """The reason the microcontroller started up from reset state.""" +//| +STATIC mp_obj_t mcu_processor_get_reset_reason(mp_obj_t self) { + return cp_enum_find(&mcu_reset_reason_type, common_hal_mcu_processor_get_reset_reason()); +} + +MP_DEFINE_CONST_FUN_OBJ_1(mcu_processor_get_reset_reason_obj, mcu_processor_get_reset_reason); + +const mp_obj_property_t mcu_reset_reason_obj = { + .base.type = &mp_type_property, + .proxy = {(mp_obj_t)&mcu_processor_get_reason_reason_obj, // getter + (mp_obj_t)&mp_const_none_obj, // no setter + (mp_obj_t)&mp_const_none_obj, // no deleter + }, +}; + //| temperature: Optional[float] //| """The on-chip temperature, in Celsius, as a float. (read-only) //| @@ -128,6 +145,7 @@ const mp_obj_property_t mcu_processor_voltage_obj = { STATIC const mp_rom_map_elem_t mcu_processor_locals_dict_table[] = { { MP_ROM_QSTR(MP_QSTR_frequency), MP_ROM_PTR(&mcu_processor_frequency_obj) }, + { MP_ROM_QSTR(MP_QSTR_reset_reason), MP_ROM_PTR(&mcu_processor_reset_reason_obj) }, { MP_ROM_QSTR(MP_QSTR_temperature), MP_ROM_PTR(&mcu_processor_temperature_obj) }, { MP_ROM_QSTR(MP_QSTR_uid), MP_ROM_PTR(&mcu_processor_uid_obj) }, { MP_ROM_QSTR(MP_QSTR_voltage), MP_ROM_PTR(&mcu_processor_voltage_obj) }, diff --git a/shared-bindings/microcontroller/Processor.h b/shared-bindings/microcontroller/Processor.h index 0f520f940c..a842e06f32 100644 --- a/shared-bindings/microcontroller/Processor.h +++ b/shared-bindings/microcontroller/Processor.h @@ -29,11 +29,12 @@ #include "py/obj.h" -#include "common-hal/microcontroller/Processor.h" +#include "shared-bindings/microcontroller/ResetReason.h" extern const mp_obj_type_t mcu_processor_type; uint32_t common_hal_mcu_processor_get_frequency(void); +mcu_reset_reason_t common_hal_mcu_processor_get_reset_reason(void); float common_hal_mcu_processor_get_temperature(void); void common_hal_mcu_processor_get_uid(uint8_t raw_id[]); float common_hal_mcu_processor_get_voltage(void); diff --git a/shared-bindings/alarm/ResetReason.c b/shared-bindings/microcontroller/ResetReason.c similarity index 54% rename from shared-bindings/alarm/ResetReason.c rename to shared-bindings/microcontroller/ResetReason.c index 086562fc9c..151fcf3159 100644 --- a/shared-bindings/alarm/ResetReason.c +++ b/shared-bindings/microcontroller/ResetReason.c @@ -27,42 +27,37 @@ #include "py/obj.h" #include "py/enum.h" -#include "shared-bindings/alarm/ResetReason.h" +#include "shared-bindings/microcontroller/ResetReason.h" -MAKE_ENUM_VALUE(alarm_reset_reason_type, reset_reason, INVALID, RESET_REASON_INVALID); -MAKE_ENUM_VALUE(alarm_reset_reason_type, reset_reason, POWER_ON, RESET_REASON_POWER_ON); -MAKE_ENUM_VALUE(alarm_reset_reason_type, reset_reason, BROWNOUT, RESET_REASON_BROWNOUT); -MAKE_ENUM_VALUE(alarm_reset_reason_type, reset_reason, SOFTWARE, RESET_REASON_SOFTWARE); -MAKE_ENUM_VALUE(alarm_reset_reason_type, reset_reason, DEEP_SLEEP_ALARM, RESET_REASON_DEEP_SLEEP_ALARM); -MAKE_ENUM_VALUE(alarm_reset_reason_type, reset_reason, RESET_PIN, RESET_REASON_RESET_PIN); -MAKE_ENUM_VALUE(alarm_reset_reason_type, reset_reason, WATCHDOG, RESET_REASON_WATCHDOG); +MAKE_ENUM_VALUE(mcu_reset_reason_type, reset_reason, POWER_ON, RESET_REASON_POWER_ON); +MAKE_ENUM_VALUE(mcu_reset_reason_type, reset_reason, BROWNOUT, RESET_REASON_BROWNOUT); +MAKE_ENUM_VALUE(mcu_reset_reason_type, reset_reason, SOFTWARE, RESET_REASON_SOFTWARE); +MAKE_ENUM_VALUE(mcu_reset_reason_type, reset_reason, DEEP_SLEEP_ALARM, RESET_REASON_DEEP_SLEEP_ALARM); +MAKE_ENUM_VALUE(mcu_reset_reason_type, reset_reason, RESET_PIN, RESET_REASON_RESET_PIN); +MAKE_ENUM_VALUE(mcu_reset_reason_type, reset_reason, WATCHDOG, RESET_REASON_WATCHDOG); //| class ResetReason: -//| """The reason the chip was last reset""" -//| -//| INVALID: object -//| """Invalid reason: indicates an internal error.""" +//| """The reason the microntroller was last reset""" //| //| POWER_ON: object -//| """The chip was started from power off.""" +//| """The microntroller was started from power off.""" //| //| BROWNOUT: object -//| """The chip was reset due to voltage brownout.""" +//| """The microntroller was reset due to too low a voltage.""" //| //| SOFTWARE: object -//| """The chip was reset from software.""" +//| """The microntroller was reset from software.""" //| //| DEEP_SLEEP_ALARM: object -//| """The chip was reset for deep sleep and restarted by an alarm.""" +//| """The microntroller was reset for deep sleep and restarted by an alarm.""" //| //| RESET_PIN: object -//| """The chip was reset by a signal on its reset pin. The pin might be connected to a reset buton.""" +//| """The microntroller was reset by a signal on its reset pin. The pin might be connected to a reset button.""" //| //| WATCHDOG: object -//| """The chip was reset by its watchdog timer.""" +//| """The chip microcontroller reset by its watchdog timer.""" //| -MAKE_ENUM_MAP(alarm_reset_reason) { - MAKE_ENUM_MAP_ENTRY(reset_reason, INVALID), +MAKE_ENUM_MAP(mcu_reset_reason) { MAKE_ENUM_MAP_ENTRY(reset_reason, POWER_ON), MAKE_ENUM_MAP_ENTRY(reset_reason, BROWNOUT), MAKE_ENUM_MAP_ENTRY(reset_reason, SOFTWARE), @@ -70,8 +65,8 @@ MAKE_ENUM_MAP(alarm_reset_reason) { MAKE_ENUM_MAP_ENTRY(reset_reason, RESET_PIN), MAKE_ENUM_MAP_ENTRY(reset_reason, WATCHDOG), }; -STATIC MP_DEFINE_CONST_DICT(alarm_reset_reason_locals_dict, alarm_reset_reason_locals_table); +STATIC MP_DEFINE_CONST_DICT(mcu_reset_reason_locals_dict, mcu_reset_reason_locals_table); -MAKE_PRINTER(alarm, alarm_reset_reason); +MAKE_PRINTER(alarm, mcu_reset_reason); -MAKE_ENUM_TYPE(alarm, ResetReason, alarm_reset_reason); +MAKE_ENUM_TYPE(alarm, ResetReason, mcu_reset_reason); diff --git a/shared-bindings/alarm/ResetReason.h b/shared-bindings/microcontroller/ResetReason.h similarity index 71% rename from shared-bindings/alarm/ResetReason.h rename to shared-bindings/microcontroller/ResetReason.h index 2d6b8bc0c3..df1abf266e 100644 --- a/shared-bindings/alarm/ResetReason.h +++ b/shared-bindings/microcontroller/ResetReason.h @@ -24,24 +24,28 @@ * THE SOFTWARE. */ -#ifndef MICROPY_INCLUDED_SHARED_BINDINGS_ALARM__RESET_REASON__H -#define MICROPY_INCLUDED_SHARED_BINDINGS_ALARM__RESET_REASON__H +#ifndef MICROPY_INCLUDED_SHARED_BINDINGS_MCU__RESET_REASON__H +#define MICROPY_INCLUDED_SHARED_BINDINGS_MCU__RESET_REASON__H #include "py/obj.h" #include "py/enum.h" typedef enum { - RESET_REASON_INVALID, RESET_REASON_POWER_ON, RESET_REASON_BROWNOUT, RESET_REASON_SOFTWARE, RESET_REASON_DEEP_SLEEP_ALARM, RESET_REASON_RESET_PIN, RESET_REASON_WATCHDOG, -} alarm_reset_reason_t; +} mcu_reset_reason_t; -extern const cp_enum_obj_t reset_reason_INVALID_obj; +extern const cp_enum_obj_t reset_reason_POWER_ON_obj; +extern const cp_enum_obj_t reset_reason_BROWNOUT_obj; +extern const cp_enum_obj_t reset_reason_SOFTWARE_obj; +extern const cp_enum_obj_t reset_reason_DEEP_SLEEP_ALARM_obj; +extern const cp_enum_obj_t reset_reason_RESET_PIN_obj; +extern const cp_enum_obj_t reset_reason_WATCHDOG_obj; -extern const mp_obj_type_t alarm_reset_reason_type; +extern const mp_obj_type_t mcu_reset_reason_type; -#endif // MICROPY_INCLUDED_SHARED_BINDINGS_ALARM__RESET_REASON__H +#endif // MICROPY_INCLUDED_SHARED_BINDINGS_MCU__RESET_REASON__H diff --git a/shared-bindings/microcontroller/__init__.c b/shared-bindings/microcontroller/__init__.c index bfeb812d67..d09cf8f445 100644 --- a/shared-bindings/microcontroller/__init__.c +++ b/shared-bindings/microcontroller/__init__.c @@ -135,13 +135,6 @@ STATIC mp_obj_t mcu_reset(void) { } STATIC MP_DEFINE_CONST_FUN_OBJ_0(mcu_reset_obj, mcu_reset); -STATIC mp_obj_t mcu_sleep(void) { - common_hal_mcu_deep_sleep(); - // We won't actually get here because mcu is going into sleep. - return mp_const_none; -} -STATIC MP_DEFINE_CONST_FUN_OBJ_0(mcu_sleep_obj, mcu_sleep); - //| nvm: Optional[ByteArray] //| """Available non-volatile memory. //| This object is the sole instance of `nvm.ByteArray` when available or ``None`` otherwise. @@ -176,8 +169,6 @@ STATIC const mp_rom_map_elem_t mcu_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR_enable_interrupts), MP_ROM_PTR(&mcu_enable_interrupts_obj) }, { MP_ROM_QSTR(MP_QSTR_on_next_reset), MP_ROM_PTR(&mcu_on_next_reset_obj) }, { MP_ROM_QSTR(MP_QSTR_reset), MP_ROM_PTR(&mcu_reset_obj) }, - //ToDo: Remove MP_QSTR_sleep when sleep on code.py exit implemented. - { MP_ROM_QSTR(MP_QSTR_sleep), MP_ROM_PTR(&mcu_sleep_obj) }, #if CIRCUITPY_INTERNAL_NVM_SIZE > 0 { MP_ROM_QSTR(MP_QSTR_nvm), MP_ROM_PTR(&common_hal_mcu_nvm_obj) }, #else diff --git a/shared-bindings/microcontroller/__init__.h b/shared-bindings/microcontroller/__init__.h index f5bcfaa08a..ac71de4247 100644 --- a/shared-bindings/microcontroller/__init__.h +++ b/shared-bindings/microcontroller/__init__.h @@ -32,7 +32,7 @@ #include "py/mpconfig.h" #include "common-hal/microcontroller/Processor.h" - +#include "shared-bindings/microcontroller/ResetReason.h" #include "shared-bindings/microcontroller/RunMode.h" extern void common_hal_mcu_delay_us(uint32_t); @@ -43,8 +43,6 @@ extern void common_hal_mcu_enable_interrupts(void); extern void common_hal_mcu_on_next_reset(mcu_runmode_t runmode); extern void common_hal_mcu_reset(void); -extern void common_hal_mcu_deep_sleep(void); - extern const mp_obj_dict_t mcu_pin_globals; extern const mcu_processor_obj_t common_hal_mcu_processor_obj; diff --git a/shared-bindings/supervisor/RunReason.c b/shared-bindings/supervisor/RunReason.c index 5233cf959b..ee08f6d71b 100644 --- a/shared-bindings/supervisor/RunReason.c +++ b/shared-bindings/supervisor/RunReason.c @@ -28,35 +28,35 @@ #include "shared-bindings/supervisor/RunReason.h" -MAKE_ENUM_VALUE(canio_bus_state_type, run_reason, ERROR_ACTIVE, RUN_REASON_STARTUP); -MAKE_ENUM_VALUE(canio_bus_state_type, bus_state, ERROR_PASSIVE, RUN_REASON_AUTORELOAD); -MAKE_ENUM_VALUE(canio_bus_state_type, bus_state, ERROR_WARNING, RUN_REASON_SUPERVISOR_RELOAD); -MAKE_ENUM_VALUE(canio_bus_state_type, bus_state, BUS_OFF, RUN_REASON_RELOAD_HOTKEY); +MAKE_ENUM_VALUE(supervisor_run_reason_type, run_reason, STARTUP, RUN_REASON_STARTUP); +MAKE_ENUM_VALUE(supervisor_run_reason_type, run_reason, AUTORELOAD, RUN_REASON_AUTORELOAD); +MAKE_ENUM_VALUE(supervisor_run_reason_type, run_reason, SUPERVISOR_RELOAD, RUN_REASON_SUPERVISOR_RELOAD); +MAKE_ENUM_VALUE(supervisor_run_reason_type, run_reason, REPL_RELOAD, RUN_REASON_REPL_RELOAD); //| class RunReason: -//| """The state of the CAN bus""" +//| """The reason that CircuitPython started running.""" //| //| STARTUP: object -//| """The first VM was run after the microcontroller started up. See `microcontroller.start_reason` -//| for more detail why the microcontroller was started.""" +//| """CircuitPython started the microcontroller started up. See `microcontroller.cpu.reset_reason` +//| for more detail on why the microcontroller was started.""" //| //| AUTORELOAD: object -//| """The VM was run due to a USB write to the filesystem.""" +//| """CircuitPython restarted due to a USB write to the filesystem.""" //| //| SUPERVISOR_RELOAD: object -//| """The VM was run due to a call to `supervisor.reload()`.""" +//| """CircuitPython restarted due to a call to `supervisor.reload()`.""" //| -//| RELOAD_HOTKEY: object -//| """The VM was run due CTRL-D.""" +//| REPL_RELOAD: object +//| """CircuitPython started due to the user typing CTRL-D in the REPL.""" //| -MAKE_ENUM_MAP(canio_bus_state) { - MAKE_ENUM_MAP_ENTRY(bus_state, ERROR_ACTIVE), - MAKE_ENUM_MAP_ENTRY(bus_state, ERROR_PASSIVE), - MAKE_ENUM_MAP_ENTRY(bus_state, ERROR_WARNING), - MAKE_ENUM_MAP_ENTRY(bus_state, BUS_OFF), +MAKE_ENUM_MAP(run_reason) { + MAKE_ENUM_MAP_ENTRY(run_reason, STARTUP), + MAKE_ENUM_MAP_ENTRY(run_reason, AUTORELOAD), + MAKE_ENUM_MAP_ENTRY(run_reason, SUPERVISOR_RELOAD), + MAKE_ENUM_MAP_ENTRY(run_reason, REPL_RELOAD), }; -STATIC MP_DEFINE_CONST_DICT(canio_bus_state_locals_dict, canio_bus_state_locals_table); +STATIC MP_DEFINE_CONST_DICT(supervisor_run_reason_locals_dict, supervisor_run_reason_locals_table); -MAKE_PRINTER(canio, canio_bus_state); +MAKE_PRINTER(supervisor, supervisor_run_reason); -MAKE_ENUM_TYPE(canio, BusState, canio_bus_state); +MAKE_ENUM_TYPE(supervisor, RunReason, supervisor_run_reason); diff --git a/shared-bindings/supervisor/RunReason.h b/shared-bindings/supervisor/RunReason.h index f9aaacae63..934c72fd8c 100644 --- a/shared-bindings/supervisor/RunReason.h +++ b/shared-bindings/supervisor/RunReason.h @@ -30,7 +30,7 @@ typedef enum { RUN_REASON_STARTUP, RUN_REASON_AUTORELOAD, RUN_REASON_SUPERVISOR_RELOAD, - RUN_REASON_RELOAD_HOTKEY + RUN_REASON_REPL_RELOAD, } supervisor_run_reason_t; -extern const mp_obj_type_t canio_bus_state_type; +extern const mp_obj_type_t supervisor_run_reason_type; diff --git a/shared-bindings/supervisor/Runtime.c b/shared-bindings/supervisor/Runtime.c index f9db38c9b5..6500dadd59 100755 --- a/shared-bindings/supervisor/Runtime.c +++ b/shared-bindings/supervisor/Runtime.c @@ -91,15 +91,11 @@ const mp_obj_property_t supervisor_serial_bytes_available_obj = { //| run_reason: RunReason -//| """Returns why the Python VM was run this time.""" +//| """Returns why CircuitPython started running this particular time. //| STATIC mp_obj_t supervisor_get_run_reason(mp_obj_t self) { - if (!common_hal_get_serial_bytes_available()) { - return mp_const_false; - } - else { - return mp_const_true; - } + mp_raise_NotImplementedError(NULL); + return mp_const_none; } MP_DEFINE_CONST_FUN_OBJ_1(supervisor_get_run_reason_obj, supervisor_get_run_reason); diff --git a/supervisor/shared/safe_mode.c b/supervisor/shared/safe_mode.c index ee8af2c2ca..9032e40451 100644 --- a/supervisor/shared/safe_mode.c +++ b/supervisor/shared/safe_mode.c @@ -29,10 +29,8 @@ #include "mphalport.h" #include "shared-bindings/digitalio/DigitalInOut.h" -#if CIRCUITPY_ALARM -#include "shared-bindings/alarm/__init__.h" -#include "shared-bindings/alarm/ResetReason.h" -#endif +#include "shared-bindings/microcontroller/Processor.h" +#include "shared-bindings/microcontroller/ResetReason.h" #include "supervisor/serial.h" #include "supervisor/shared/rgb_led_colors.h" @@ -56,12 +54,12 @@ safe_mode_t wait_for_safe_mode_reset(void) { current_safe_mode = safe_mode; return safe_mode; } -#if CIRCUITPY_ALARM - if (common_hal_alarm_get_reset_reason() != RESET_REASON_POWER_ON && - common_hal_alarm_get_reset_reason() != RESET_REASON_RESET_PIN) { + + const mcu_reset_reason_t reset_reason = common_hal_mcu_processor_get_reset_reason(); + if (reset_reason != RESET_REASON_POWER_ON && + reset_reason != RESET_REASON_RESET_PIN) { return NO_SAFE_MODE; } -#endif port_set_saved_word(SAFE_MODE_DATA_GUARD | (MANUAL_SAFE_MODE << 8)); // Wait for a while to allow for reset. temp_status_color(SAFE_MODE); From 0b858440b0d64ede9e340de4862684c8be2b5b2b Mon Sep 17 00:00:00 2001 From: jgillick Date: Sun, 22 Nov 2020 01:15:05 -0800 Subject: [PATCH 104/207] Fix formatting. --- ports/stm/common-hal/microcontroller/Pin.c | 174 +++++++++------------ 1 file changed, 77 insertions(+), 97 deletions(-) diff --git a/ports/stm/common-hal/microcontroller/Pin.c b/ports/stm/common-hal/microcontroller/Pin.c index 547ac87ae1..4b68d205bf 100644 --- a/ports/stm/common-hal/microcontroller/Pin.c +++ b/ports/stm/common-hal/microcontroller/Pin.c @@ -41,170 +41,150 @@ bool apa102_mosi_in_use; #endif #if defined(TFBGA216) -GPIO_TypeDef *ports[] = {GPIOA, GPIOB, GPIOC, GPIOD, GPIOE, GPIOF, GPIOG, GPIOH, GPIOI, GPIOJ, GPIOK}; + GPIO_TypeDef * ports[] = {GPIOA, GPIOB, GPIOC, GPIOD, GPIOE, GPIOF, GPIOG, GPIOH, GPIOI, GPIOJ, GPIOK}; #elif defined(LQFP144) -GPIO_TypeDef *ports[] = {GPIOA, GPIOB, GPIOC, GPIOD, GPIOE, GPIOF, GPIOG}; + GPIO_TypeDef * ports[] = {GPIOA, GPIOB, GPIOC, GPIOD, GPIOE, GPIOF, GPIOG}; #elif defined(LQFP100_f4) || (LQFP100_x7) -GPIO_TypeDef *ports[] = {GPIOA, GPIOB, GPIOC, GPIOD, GPIOE}; + GPIO_TypeDef * ports[] = {GPIOA, GPIOB, GPIOC, GPIOD, GPIOE}; #elif defined(LQFP64) -GPIO_TypeDef *ports[] = {GPIOA, GPIOB, GPIOC, GPIOD}; + GPIO_TypeDef * ports[] = {GPIOA, GPIOB, GPIOC, GPIOD}; #elif defined(UFQFPN48) -GPIO_TypeDef *ports[] = {GPIOA, GPIOB, GPIOC}; + GPIO_TypeDef * ports[] = {GPIOA, GPIOB, GPIOC}; #endif + #define GPIO_PORT_COUNT (MP_ARRAY_SIZE(ports)) STATIC uint16_t claimed_pins[GPIO_PORT_COUNT]; STATIC uint16_t __ALIGNED(4) never_reset_pins[GPIO_PORT_COUNT]; -void reset_all_pins(void) -{ +void reset_all_pins(void) { // Reset claimed pins - for (uint8_t i = 0; i < GPIO_PORT_COUNT; i++) - { + for (uint8_t i = 0; i < GPIO_PORT_COUNT; i++) { claimed_pins[i] = never_reset_pins[i]; } - for (uint8_t i = 0; i < GPIO_PORT_COUNT; i++) - { + for (uint8_t i = 0; i < GPIO_PORT_COUNT; i++) { HAL_GPIO_DeInit(ports[i], ~never_reset_pins[i]); } -#ifdef MICROPY_HW_NEOPIXEL + #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 + #endif + #ifdef MICROPY_HW_APA102_MOSI + apa102_sck_in_use = false; + apa102_mosi_in_use = false; + #endif } // Mark pin as free and return it to a quiescent state. -void reset_pin_number(uint8_t pin_port, uint8_t pin_number) -{ - if (pin_number == NO_PIN) - { +void reset_pin_number(uint8_t pin_port, uint8_t pin_number) { + if ( pin_number == NO_PIN ) { return; } - if (pin_port == 0x0F) - { + if (pin_port == 0x0F) { return; } // Clear claimed bit & reset - claimed_pins[pin_port] &= ~(1 << pin_number); - never_reset_pins[pin_port] &= ~(1 << pin_number); - HAL_GPIO_DeInit(ports[pin_port], 1 << pin_number); + claimed_pins[pin_port] &= ~(1<port && pin_number == MICROPY_HW_NEOPIXEL->number) - { + #ifdef MICROPY_HW_NEOPIXEL + if (pin_port == MICROPY_HW_NEOPIXEL->port && pin_number == MICROPY_HW_NEOPIXEL->number) { neopixel_in_use = false; rgb_led_status_init(); return; } -#endif -#ifdef MICROPY_HW_APA102_MOSI - if ((pin_port == MICROPY_HW_APA102_MOSI->port && pin_number == MICROPY_HW_APA102_MOSI->number) || (pin_port == MICROPY_HW_APA102_SCK->port && pin_number == MICROPY_HW_APA102_MOSI->number)) - { - apa102_mosi_in_use = false; - apa102_sck_in_use = false; - rgb_led_status_init(); - return; - } -#endif + #endif + #ifdef MICROPY_HW_APA102_MOSI + if ((pin_port == MICROPY_HW_APA102_MOSI->port && pin_number == MICROPY_HW_APA102_MOSI->number) || (pin_port == MICROPY_HW_APA102_SCK->port && pin_number == MICROPY_HW_APA102_MOSI->number)) + { + apa102_mosi_in_use = false; + apa102_sck_in_use = false; + rgb_led_status_init(); + return; + } + #endif } -void never_reset_pin_number(uint8_t pin_port, uint8_t pin_number) -{ - if (pin_number == NO_PIN) - { +void never_reset_pin_number(uint8_t pin_port, uint8_t pin_number) { + if ( pin_number == NO_PIN ) { return; } - never_reset_pins[pin_port] |= 1 << pin_number; + never_reset_pins[pin_port] |= 1<port, pin->number); } -void common_hal_reset_pin(const mcu_pin_obj_t *pin) -{ +void common_hal_reset_pin(const mcu_pin_obj_t* pin) { reset_pin_number(pin->port, pin->number); } -void claim_pin(uint8_t pin_port, uint8_t pin_number) -{ +void claim_pin(uint8_t pin_port, uint8_t pin_number) { // Set bit in claimed_pins bitmask. - claimed_pins[pin_port] |= 1 << pin_number; + claimed_pins[pin_port] |= 1<port, pin->number); } -GPIO_TypeDef *pin_port(uint8_t pin_port) -{ +GPIO_TypeDef * pin_port(uint8_t pin_port) { return ports[pin_port]; } -uint16_t pin_mask(uint8_t pin_number) -{ - return 1 << pin_number; +uint16_t pin_mask(uint8_t pin_number) { + return 1<port * 16 + pin->number; } -void common_hal_mcu_pin_claim(const mcu_pin_obj_t *pin) -{ +void common_hal_mcu_pin_claim(const mcu_pin_obj_t* pin) { claim_pin(pin->port, pin->number); -#ifdef MICROPY_HW_NEOPIXEL - if (pin == MICROPY_HW_NEOPIXEL) - { + #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 + #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 } -void common_hal_mcu_pin_reset_number(uint8_t pin_no) -{ +void common_hal_mcu_pin_reset_number(uint8_t pin_no) { reset_pin_number(pin_no / 16, pin_no % 16); -} +} \ No newline at end of file From 381889f6bc025617fe85b248fae0f6b05ed50c01 Mon Sep 17 00:00:00 2001 From: jgillick Date: Sun, 22 Nov 2020 01:19:28 -0800 Subject: [PATCH 105/207] Cleanup --- .../boards/thunderpack_v12/mpconfigboard.h | 8 +- .../thunderpack_v12/stm32f4xx_hal_conf.h | 440 ------------------ ports/stm/common-hal/microcontroller/Pin.c | 52 +-- 3 files changed, 28 insertions(+), 472 deletions(-) delete mode 100644 ports/stm/boards/thunderpack_v12/stm32f4xx_hal_conf.h diff --git a/ports/stm/boards/thunderpack_v12/mpconfigboard.h b/ports/stm/boards/thunderpack_v12/mpconfigboard.h index 4c71b8aeb2..426e0678da 100644 --- a/ports/stm/boards/thunderpack_v12/mpconfigboard.h +++ b/ports/stm/boards/thunderpack_v12/mpconfigboard.h @@ -30,10 +30,7 @@ #define CIRCUITPY_INTERNAL_NVM_SIZE (0x4000) #define CIRCUITPY_INTERNAL_NVM_START_ADDR (0x08010000) #define CIRCUITPY_INTERNAL_NVM_SECTOR FLASH_SECTOR_4 - -// Putting the entire flash sector in the NVM byte array buffer -// would take up too much RAM. This limits how much of the sector we use. -#define NVM_BYTEARRAY_BUFFER_SIZE 512 +#define NVM_BYTEARRAY_BUFFER_SIZE 512 // Flash config #define FLASH_SIZE (0x80000) @@ -47,7 +44,6 @@ #define SPI_FLASH_CS_PIN (&pin_PB12) // Status LEDs -#define MICROPY_HW_LED_STATUS (&pin_PA02) #define MICROPY_HW_APA102_MOSI (&pin_PB08) #define MICROPY_HW_APA102_SCK (&pin_PB00) @@ -58,4 +54,4 @@ // General config #define BOARD_OSC_DIV (24) #define BOARD_OVERWRITE_SWD (1) -#define BOARD_NO_VBUS_SENSE (1) \ No newline at end of file +#define BOARD_NO_VBUS_SENSE (1) diff --git a/ports/stm/boards/thunderpack_v12/stm32f4xx_hal_conf.h b/ports/stm/boards/thunderpack_v12/stm32f4xx_hal_conf.h deleted file mode 100644 index 5cb5634223..0000000000 --- a/ports/stm/boards/thunderpack_v12/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)24000000) /*!< 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/stm/common-hal/microcontroller/Pin.c b/ports/stm/common-hal/microcontroller/Pin.c index 4b68d205bf..7d259e0521 100644 --- a/ports/stm/common-hal/microcontroller/Pin.c +++ b/ports/stm/common-hal/microcontroller/Pin.c @@ -71,8 +71,8 @@ void reset_all_pins(void) { neopixel_in_use = false; #endif #ifdef MICROPY_HW_APA102_MOSI - apa102_sck_in_use = false; - apa102_mosi_in_use = false; + apa102_sck_in_use = false; + apa102_mosi_in_use = false; #endif } @@ -98,13 +98,13 @@ void reset_pin_number(uint8_t pin_port, uint8_t pin_number) { } #endif #ifdef MICROPY_HW_APA102_MOSI - if ((pin_port == MICROPY_HW_APA102_MOSI->port && pin_number == MICROPY_HW_APA102_MOSI->number) || (pin_port == MICROPY_HW_APA102_SCK->port && pin_number == MICROPY_HW_APA102_MOSI->number)) - { - apa102_mosi_in_use = false; - apa102_sck_in_use = false; - rgb_led_status_init(); - return; - } + if ((pin_port == MICROPY_HW_APA102_MOSI->port && pin_number == MICROPY_HW_APA102_MOSI->number) || (pin_port == MICROPY_HW_APA102_SCK->port && pin_number == MICROPY_HW_APA102_MOSI->number)) + { + apa102_mosi_in_use = false; + apa102_sck_in_use = false; + rgb_led_status_init(); + return; + } #endif } @@ -141,14 +141,14 @@ bool common_hal_mcu_pin_is_free(const mcu_pin_obj_t *pin) { } #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; - } + if (pin == MICROPY_HW_APA102_MOSI) + { + return !apa102_mosi_in_use; + } + if (pin == MICROPY_HW_APA102_SCK) + { + return !apa102_sck_in_use; + } #endif return pin_number_is_free(pin->port, pin->number); @@ -174,17 +174,17 @@ void common_hal_mcu_pin_claim(const mcu_pin_obj_t* pin) { } #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; - } + if (pin == MICROPY_HW_APA102_MOSI) + { + apa102_mosi_in_use = true; + } + if (pin == MICROPY_HW_APA102_SCK) + { + apa102_sck_in_use = true; + } #endif } void common_hal_mcu_pin_reset_number(uint8_t pin_no) { reset_pin_number(pin_no / 16, pin_no % 16); -} \ No newline at end of file +} From 56634eb00e524a6f51a44f4041cd73a04528fe47 Mon Sep 17 00:00:00 2001 From: jgillick Date: Sun, 22 Nov 2020 01:31:41 -0800 Subject: [PATCH 106/207] Rename thunderpack to v11 --- .github/workflows/build.yml | 3 ++- ports/stm/boards/{thunderpack => thunderpack_v11}/board.c | 0 .../boards/{thunderpack => thunderpack_v11}/mpconfigboard.h | 0 .../boards/{thunderpack => thunderpack_v11}/mpconfigboard.mk | 0 ports/stm/boards/{thunderpack => thunderpack_v11}/pins.c | 0 5 files changed, 2 insertions(+), 1 deletion(-) rename ports/stm/boards/{thunderpack => thunderpack_v11}/board.c (100%) rename ports/stm/boards/{thunderpack => thunderpack_v11}/mpconfigboard.h (100%) rename ports/stm/boards/{thunderpack => thunderpack_v11}/mpconfigboard.mk (100%) rename ports/stm/boards/{thunderpack => thunderpack_v11}/pins.c (100%) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index f3e728a05c..c5762c4aba 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -317,7 +317,8 @@ jobs: - "teensy40" - "teensy41" - "teknikio_bluebird" - - "thunderpack" + - "thunderpack_v11" + - "thunderpack_v12" - "tinkeringtech_scoutmakes_azul" - "trellis_m4_express" - "trinket_m0" diff --git a/ports/stm/boards/thunderpack/board.c b/ports/stm/boards/thunderpack_v11/board.c similarity index 100% rename from ports/stm/boards/thunderpack/board.c rename to ports/stm/boards/thunderpack_v11/board.c diff --git a/ports/stm/boards/thunderpack/mpconfigboard.h b/ports/stm/boards/thunderpack_v11/mpconfigboard.h similarity index 100% rename from ports/stm/boards/thunderpack/mpconfigboard.h rename to ports/stm/boards/thunderpack_v11/mpconfigboard.h diff --git a/ports/stm/boards/thunderpack/mpconfigboard.mk b/ports/stm/boards/thunderpack_v11/mpconfigboard.mk similarity index 100% rename from ports/stm/boards/thunderpack/mpconfigboard.mk rename to ports/stm/boards/thunderpack_v11/mpconfigboard.mk diff --git a/ports/stm/boards/thunderpack/pins.c b/ports/stm/boards/thunderpack_v11/pins.c similarity index 100% rename from ports/stm/boards/thunderpack/pins.c rename to ports/stm/boards/thunderpack_v11/pins.c From fe6e50b770f7dffda1d49c503362c59e674224c2 Mon Sep 17 00:00:00 2001 From: jgillick Date: Sun, 22 Nov 2020 01:49:23 -0800 Subject: [PATCH 107/207] Update USB_PID --- ports/stm/boards/thunderpack_v12/mpconfigboard.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ports/stm/boards/thunderpack_v12/mpconfigboard.mk b/ports/stm/boards/thunderpack_v12/mpconfigboard.mk index d11cfb7505..7bfe273673 100644 --- a/ports/stm/boards/thunderpack_v12/mpconfigboard.mk +++ b/ports/stm/boards/thunderpack_v12/mpconfigboard.mk @@ -1,5 +1,5 @@ USB_VID = 0x239A -USB_PID = 0x806A +USB_PID = 0x8071 USB_PRODUCT = "Thunderpack STM32F411" USB_MANUFACTURER = "Jeremy Gillick" USB_DEVICES = "CDC,MSC" From 048ca2a57003d6f122db57dfc93513222380cff0 Mon Sep 17 00:00:00 2001 From: microDev <70126934+microDev1@users.noreply.github.com> Date: Sun, 22 Nov 2020 18:54:18 +0530 Subject: [PATCH 108/207] get multiple touchpad working --- ports/esp32s2/common-hal/touchio/TouchIn.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/ports/esp32s2/common-hal/touchio/TouchIn.c b/ports/esp32s2/common-hal/touchio/TouchIn.c index b44234775e..4589c46a79 100644 --- a/ports/esp32s2/common-hal/touchio/TouchIn.c +++ b/ports/esp32s2/common-hal/touchio/TouchIn.c @@ -25,10 +25,12 @@ */ #include "shared-bindings/touchio/TouchIn.h" -#include "py/runtime.h" +#include "py/runtime.h" #include "driver/touch_pad.h" +bool touch_inited = false; + static uint16_t get_raw_reading(touchio_touchin_obj_t *self) { uint32_t touch_value; touch_pad_read_raw_data((touch_pad_t)self->pin->touch_channel, &touch_value); @@ -45,11 +47,14 @@ void common_hal_touchio_touchin_construct(touchio_touchin_obj_t* self, } claim_pin(pin); - touch_pad_init(); - touch_pad_config((touch_pad_t)pin->touch_channel); + if (!touch_inited) { + touch_pad_init(); + touch_pad_set_fsm_mode(TOUCH_FSM_MODE_TIMER); + touch_pad_fsm_start(); + touch_inited = true; + } - touch_pad_set_fsm_mode(TOUCH_FSM_MODE_TIMER); - touch_pad_fsm_start(); + touch_pad_config((touch_pad_t)pin->touch_channel); // wait for "raw data" to reset mp_hal_delay_ms(10); @@ -79,8 +84,7 @@ void common_hal_touchio_touchin_deinit(touchio_touchin_obj_t* self) { } bool common_hal_touchio_touchin_get_value(touchio_touchin_obj_t *self) { - uint16_t reading = get_raw_reading(self); - return reading > self->threshold; + return get_raw_reading(self) > self->threshold; } uint16_t common_hal_touchio_touchin_get_raw_value(touchio_touchin_obj_t *self) { From f3b5ca5f01058cb1d50be09838bc55b22d3aae69 Mon Sep 17 00:00:00 2001 From: microDev <70126934+microDev1@users.noreply.github.com> Date: Sun, 22 Nov 2020 19:20:21 +0530 Subject: [PATCH 109/207] replace goto with conditional break --- ports/esp32s2/peripherals/timer.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/ports/esp32s2/peripherals/timer.c b/ports/esp32s2/peripherals/timer.c index 3aee33dc50..0ae1403874 100644 --- a/ports/esp32s2/peripherals/timer.c +++ b/ports/esp32s2/peripherals/timer.c @@ -46,6 +46,8 @@ void peripherals_timer_reset(void) { } void peripherals_timer_init(const timer_config_t * config, timer_index_t * timer) { + bool break_loop = false; + // get free timer for (uint8_t i = 0; i < 2; i++) { for (uint8_t j = 0; j < 2; j++) { @@ -53,16 +55,17 @@ void peripherals_timer_init(const timer_config_t * config, timer_index_t * timer timer->idx = (timer_idx_t)j; timer->group = (timer_group_t)i; timer_state[i][j] = TIMER_BUSY; - goto init_timer; + break_loop = true; + break; } else if (i == 1 && j == 1) { timer->idx = TIMER_MAX; timer->group = TIMER_GROUP_MAX; return; } } + if (break_loop) {break;} } -init_timer: // initialize timer module timer_init(timer->group, timer->idx, config); timer_set_counter_value(timer->group, timer->idx, 0); From f62ea25331678cc400c6149bbe3102c371540c6e Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Sun, 22 Nov 2020 19:08:27 -0500 Subject: [PATCH 110/207] ESP32S2: common_hal_mcu_delay_us() now calls mp_hal_delay_us() --- ports/esp32s2/common-hal/microcontroller/__init__.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ports/esp32s2/common-hal/microcontroller/__init__.c b/ports/esp32s2/common-hal/microcontroller/__init__.c index e5cfc7eef0..dba12b88b2 100644 --- a/ports/esp32s2/common-hal/microcontroller/__init__.c +++ b/ports/esp32s2/common-hal/microcontroller/__init__.c @@ -42,7 +42,7 @@ #include "freertos/FreeRTOS.h" void common_hal_mcu_delay_us(uint32_t delay) { - + mp_hal_delay_us(delay); } volatile uint32_t nesting_count = 0; From a0f1ec3c4a3dd52b11752e10d0dd31202e9c705f Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Sun, 22 Nov 2020 19:10:09 -0500 Subject: [PATCH 111/207] wip --- main.c | 16 +++-- .../common-hal/microcontroller/__init__.c | 4 ++ .../common-hal/microcontroller/__init__.c | 4 ++ ports/esp32s2/common-hal/alarm/__init__.c | 43 ++++++++++++ ports/esp32s2/common-hal/alarm/pin/PinAlarm.c | 19 ++++-- ports/esp32s2/common-hal/alarm/pin/PinAlarm.h | 7 +- .../common-hal/microcontroller/Processor.c | 51 ++++++++++---- .../common-hal/microcontroller/Processor.h | 6 +- .../common-hal/microcontroller/__init__.c | 8 +++ ports/esp32s2/common-hal/rtc/RTC.h | 6 +- ports/esp32s2/common-hal/supervisor/Runtime.h | 6 +- .../supervisor/internal_flash_root_pointers.h | 6 +- .../common-hal/microcontroller/__init__.c | 4 ++ .../common-hal/microcontroller/__init__.c | 4 ++ .../mimxrt10xx/MIMXRT1011/periph.h | 6 +- .../mimxrt10xx/MIMXRT1062/periph.h | 6 +- .../nrf/common-hal/microcontroller/__init__.c | 4 ++ ports/nrf/common-hal/rgbmatrix/RGBMatrix.h | 4 +- .../stm/common-hal/microcontroller/__init__.c | 4 ++ ports/stm/common-hal/rgbmatrix/RGBMatrix.h | 4 +- shared-bindings/alarm/__init__.c | 60 +++++++++++------ shared-bindings/alarm/__init__.h | 7 +- shared-bindings/alarm/pin/PinAlarm.c | 66 +++++++------------ shared-bindings/alarm/pin/PinAlarm.h | 5 +- shared-bindings/audiopwmio/__init__.h | 6 +- shared-bindings/microcontroller/Processor.c | 4 +- shared-bindings/microcontroller/Processor.h | 1 + shared-bindings/microcontroller/ResetReason.c | 7 +- shared-bindings/microcontroller/ResetReason.h | 14 ++-- shared-bindings/microcontroller/__init__.c | 14 ++++ shared-bindings/microcontroller/__init__.h | 2 + shared-bindings/supervisor/RunReason.c | 8 +-- shared-bindings/supervisor/RunReason.h | 2 +- shared-bindings/supervisor/Runtime.c | 10 ++- shared-bindings/supervisor/Runtime.h | 3 + shared-bindings/supervisor/__init__.c | 1 + supervisor/shared/usb/usb.c | 4 -- supervisor/shared/workflow.c | 8 +-- 38 files changed, 285 insertions(+), 149 deletions(-) diff --git a/main.c b/main.c index 8938d714af..f77bf41d84 100755 --- a/main.c +++ b/main.c @@ -61,6 +61,8 @@ #include "supervisor/usb.h" #include "shared-bindings/microcontroller/__init__.h" +#include "shared-bindings/microcontroller/Processor.h" +#include "shared-bindings/supervisor/Runtime.h" #include "boards/board.h" @@ -327,24 +329,27 @@ bool run_code_py(safe_mode_t safe_mode) { #endif rgb_status_animation_t animation; bool ok = result.return_code != PYEXEC_EXCEPTION; - #if CIRCUITPY_ALARM // If USB isn't enumerated then deep sleep. if (ok && !supervisor_workflow_active() && supervisor_ticks_ms64() > CIRCUITPY_USB_ENUMERATION_DELAY * 1024) { - common_hal_alarm_restart_on_alarm(0, NULL); + common_hal_mcu_deep_sleep(); } - #endif // Show the animation every N seconds. prep_rgb_status_animation(&result, found_main, safe_mode, &animation); while (true) { RUN_BACKGROUND_TASKS; if (reload_requested) { + supervisor_set_run_reason(RUN_REASON_AUTO_RELOAD); reload_requested = false; return true; } if (serial_connected() && serial_bytes_available()) { // Skip REPL if reload was requested. - return (serial_read() == CHAR_CTRL_D); + bool ctrl_d = serial_read() == CHAR_CTRL_D; + if (ctrl_d) { + supervisor_set_run_reason(RUN_REASON_REPL_RELOAD); + } + return (ctrl_d); } if (!serial_connected_before_animation && serial_connected()) { @@ -521,6 +526,9 @@ int __attribute__((used)) main(void) { reset_devices(); reset_board(); + // This is first time we are running CircuitPython after a reset or power-up. + supervisor_set_run_reason(RUN_REASON_STARTUP); + // If not in safe mode turn on autoreload by default but before boot.py in case it wants to change it. if (safe_mode == NO_SAFE_MODE) { autoreload_enable(); diff --git a/ports/atmel-samd/common-hal/microcontroller/__init__.c b/ports/atmel-samd/common-hal/microcontroller/__init__.c index 50a1ec038e..ca39f28386 100644 --- a/ports/atmel-samd/common-hal/microcontroller/__init__.c +++ b/ports/atmel-samd/common-hal/microcontroller/__init__.c @@ -84,6 +84,10 @@ void common_hal_mcu_reset(void) { reset(); } +void common_hal_mcu_deep_sleep(void) { + //deep sleep call here +} + // 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 = { diff --git a/ports/cxd56/common-hal/microcontroller/__init__.c b/ports/cxd56/common-hal/microcontroller/__init__.c index 7aa3b839d7..57140dec70 100644 --- a/ports/cxd56/common-hal/microcontroller/__init__.c +++ b/ports/cxd56/common-hal/microcontroller/__init__.c @@ -81,6 +81,10 @@ void common_hal_mcu_reset(void) { boardctl(BOARDIOC_RESET, 0); } +void common_hal_mcu_deep_sleep(void) { + //deep sleep call here +} + STATIC const mp_rom_map_elem_t mcu_pin_globals_table[] = { { MP_ROM_QSTR(MP_QSTR_UART2_RXD), MP_ROM_PTR(&pin_UART2_RXD) }, { MP_ROM_QSTR(MP_QSTR_UART2_TXD), MP_ROM_PTR(&pin_UART2_TXD) }, diff --git a/ports/esp32s2/common-hal/alarm/__init__.c b/ports/esp32s2/common-hal/alarm/__init__.c index e335345508..4a255c51cc 100644 --- a/ports/esp32s2/common-hal/alarm/__init__.c +++ b/ports/esp32s2/common-hal/alarm/__init__.c @@ -25,12 +25,20 @@ * THE SOFTWARE. */ +#include "py/objtuple.h" + #include "shared-bindings/alarm/__init__.h" #include "shared-bindings/alarm/pin/PinAlarm.h" #include "shared-bindings/alarm/time/DurationAlarm.h" #include "esp_sleep.h" +STATIC mp_obj_tuple_t *_deep_sleep_alarms; + +void alarm_reset(void) { + _deep_sleep_alarms = &mp_const_empty_tuple; +} + void common_hal_alarm_disable_all(void) { esp_sleep_disable_wakeup_source(ESP_SLEEP_WAKEUP_ALL); } @@ -63,3 +71,38 @@ mp_obj_t common_hal_alarm_get_wake_alarm(void) { } return mp_const_none; } + +mp_obj_t common_hal_alarm_sleep_until_alarms(size_t n_alarms, const mp_obj_t *alarms) { + mp_raise_NotImplementedError(NULL); +} + +void common_hal_alarm_set_deep_sleep_alarms(size_t n_alarms, const mp_obj_t *alarms) { + bool time_alarm_set = false; + for (size_t i = 0; i < n_alarms; i++) { + if (MP_OBJ_IS_TYPE(alarms[i], &alarm_pin_pin_alarm_type)) { + mp_raise_NotImplementedError(translate("PinAlarm deep sleep not yet implemented")); + } + if (MP_OBJ_IS_TYPE(alarms[i], &alarm_time_duration_alarm_type)) { + if (time_alarm_set) { + mp_raise_ValueError(translate("Only one alarm.time alarm can be set.")); + } + time_alarm_set = true; + } + } + + _deep_sleep_alarms = mp_obj_new_tuple(n_alarms, alarms); +} + +void common_hal_deep_sleep_with_alarms(void) { + for (size_t i = 0; i < _deep_sleep_alarms.len; i++) { + mp_obj_t alarm = _deep_sleep_alarms.items[i] + if (MP_OBJ_IS_TYPE(alarm, &alarm_time_duration_alarm_type)) { + alarm_time_duration_alarm_obj_t *duration_alarm = MP_OBJ_TO_PTR(alarm); + esp_sleep_enable_timer_wakeup( + (uint64_t) (duration_alarm->duration * 1000000.0f)); + } + // TODO: handle pin alarms + } + + common_hal_mcu_deep_sleep(); +} diff --git a/ports/esp32s2/common-hal/alarm/pin/PinAlarm.c b/ports/esp32s2/common-hal/alarm/pin/PinAlarm.c index 6ac3d05f87..f26c8a179a 100644 --- a/ports/esp32s2/common-hal/alarm/pin/PinAlarm.c +++ b/ports/esp32s2/common-hal/alarm/pin/PinAlarm.c @@ -30,19 +30,24 @@ #include "shared-bindings/alarm/pin/PinAlarm.h" #include "shared-bindings/microcontroller/Pin.h" -void common_hal_alarm_pin_pin_alarm_construct(alarm_pin_pin_alarm_obj_t *self, const mcu_pin_obj_t *pin, bool level, bool edge, bool pull) { - self->pin = pin; - self->level = level; +void common_hal_alarm_pin_pin_alarm_construct(alarm_pin_pin_alarm_obj_t *self, const mp_obj_t pins[], size_t num_pins, bool value, bool all_same_value, bool edge, bool pull) { + self->pins = mp_obj_new_tuple(num_pins, pins); + self->value = value; + self->all_same_value = all_same_value; self->edge = edge; self->pull = pull; } -const mcu_pin_obj_t *common_hal_alarm_pin_pin_alarm_get_pin(alarm_pin_pin_alarm_obj_t *self) { - return self->pin; +const mp_obj_tuple_t *common_hal_alarm_pin_pin_alarm_get_pins(alarm_pin_pin_alarm_obj_t *self) { + return self->pins; } -bool common_hal_alarm_pin_pin_alarm_get_level(alarm_pin_pin_alarm_obj_t *self) { - return self->level; +bool common_hal_alarm_pin_pin_alarm_get_value(alarm_pin_pin_alarm_obj_t *self) { + return self->value; +} + +bool common_hal_alarm_pin_pin_alarm_get_all_same_value(alarm_pin_pin_alarm_obj_t *self) { + return self->all_same_value; } bool common_hal_alarm_pin_pin_alarm_get_edge(alarm_pin_pin_alarm_obj_t *self) { diff --git a/ports/esp32s2/common-hal/alarm/pin/PinAlarm.h b/ports/esp32s2/common-hal/alarm/pin/PinAlarm.h index c6a760b96a..d7e7e2552a 100644 --- a/ports/esp32s2/common-hal/alarm/pin/PinAlarm.h +++ b/ports/esp32s2/common-hal/alarm/pin/PinAlarm.h @@ -24,13 +24,14 @@ * THE SOFTWARE. */ - #include "py/obj.h" +#include "py/objtuple.h" typedef struct { mp_obj_base_t base; - const mcu_pin_obj_t *pin; - bool level; + mp_obj_tuple_t *pins; + bool value; + bool all_same_value; bool edge; bool pull; } alarm_pin_pin_alarm_obj_t; diff --git a/ports/esp32s2/common-hal/microcontroller/Processor.c b/ports/esp32s2/common-hal/microcontroller/Processor.c index bd625dc6e2..fffd1a1b19 100644 --- a/ports/esp32s2/common-hal/microcontroller/Processor.c +++ b/ports/esp32s2/common-hal/microcontroller/Processor.c @@ -31,8 +31,12 @@ #include "py/runtime.h" #include "common-hal/microcontroller/Processor.h" +#include "shared-bindings/microcontroller/ResetReason.h" #include "supervisor/shared/translate.h" +#include "esp_sleep.h" +#include "esp_system.h" + #include "soc/efuse_reg.h" #include "components/driver/esp32s2/include/driver/temp_sensor.h" @@ -77,21 +81,42 @@ void common_hal_mcu_processor_get_uid(uint8_t raw_id[]) { } mcu_reset_reason_t common_hal_mcu_processor_get_reset_reason(void) { - switch (esp_sleep_get_wakeup_cause()) { - case ESP_SLEEP_WAKEUP_TIMER: - return RESET_REASON_DEEP_SLEEP_ALARM; + switch (esp_reset_reason()) { + case ESP_RST_POWERON: + return RESET_REASON_POWER_ON; - case ESP_SLEEP_WAKEUP_EXT0: - return RESET_REASON_DEEP_SLEEP_ALARM; + case ESP_RST_SW: + case ESP_RST_PANIC: + return RESET_REASON_SOFTWARE; - case ESP_SLEEP_WAKEUP_TOUCHPAD: - //TODO: implement TouchIO - case ESP_SLEEP_WAKEUP_UNDEFINED: + case ESP_RST_INT_WDT: + case ESP_RST_TASK_WDT: + case ESP_RST_WDT: + return RESET_REASON_WATCHDOG; + + case ESP_RST_BROWNOUT: + return RESET_REASON_BROWNOUT; + + case ESP_RST_SDIO: + case ESP_RST_EXT: + return RESET_REASON_RESET_PIN; + + case ESP_RST_DEEPSLEEP: + switch (esp_sleep_get_wakeup_cause()) { + case ESP_SLEEP_WAKEUP_TIMER: + case ESP_SLEEP_WAKEUP_EXT0: + case ESP_SLEEP_WAKEUP_EXT1: + case ESP_SLEEP_WAKEUP_TOUCHPAD: + return RESET_REASON_DEEP_SLEEP_ALARM; + + case ESP_SLEEP_WAKEUP_UNDEFINED: + default: + return RESET_REASON_UNKNOWN; + } + + case ESP_RST_UNKNOWN: default: - return RESET_REASON_POWER_APPLIED; + return RESET_REASON_UNKNOWN; + } } - -mcu_reset_reason_t common_hal_mcu_processor_get_reset_reason(void) { - return RESET_REASON_POWER_ON; -} diff --git a/ports/esp32s2/common-hal/microcontroller/Processor.h b/ports/esp32s2/common-hal/microcontroller/Processor.h index f6636b333c..641a11d555 100644 --- a/ports/esp32s2/common-hal/microcontroller/Processor.h +++ b/ports/esp32s2/common-hal/microcontroller/Processor.h @@ -24,8 +24,8 @@ * THE SOFTWARE. */ -#ifndef MICROPY_INCLUDED_LITEX_COMMON_HAL_MICROCONTROLLER_PROCESSOR_H -#define MICROPY_INCLUDED_LITEX_COMMON_HAL_MICROCONTROLLER_PROCESSOR_H +#ifndef MICROPY_INCLUDED_ESP32S2_COMMON_HAL_MICROCONTROLLER_PROCESSOR_H +#define MICROPY_INCLUDED_ESP32S2_COMMON_HAL_MICROCONTROLLER_PROCESSOR_H #define COMMON_HAL_MCU_PROCESSOR_UID_LENGTH 6 @@ -36,4 +36,4 @@ typedef struct { // Stores no state currently. } mcu_processor_obj_t; -#endif // MICROPY_INCLUDED_LITEX_COMMON_HAL_MICROCONTROLLER_PROCESSOR_H +#endif // MICROPY_INCLUDED_ESP32S2_COMMON_HAL_MICROCONTROLLER_PROCESSOR_H diff --git a/ports/esp32s2/common-hal/microcontroller/__init__.c b/ports/esp32s2/common-hal/microcontroller/__init__.c index 3056c65655..fdfbd65fad 100644 --- a/ports/esp32s2/common-hal/microcontroller/__init__.c +++ b/ports/esp32s2/common-hal/microcontroller/__init__.c @@ -79,6 +79,14 @@ void common_hal_mcu_reset(void) { while(1); } +void common_hal_mcu_deep_sleep(void) { + // Shut down wifi cleanly. + esp_wifi_stop(); + + // Does not return. + esp_deep_sleep_start(); +} + // 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 = { diff --git a/ports/esp32s2/common-hal/rtc/RTC.h b/ports/esp32s2/common-hal/rtc/RTC.h index e51f1f7848..233cde3fd2 100644 --- a/ports/esp32s2/common-hal/rtc/RTC.h +++ b/ports/esp32s2/common-hal/rtc/RTC.h @@ -24,11 +24,11 @@ * THE SOFTWARE. */ -#ifndef MICROPY_INCLUDED_NRF_COMMON_HAL_RTC_RTC_H -#define MICROPY_INCLUDED_NRF_COMMON_HAL_RTC_RTC_H +#ifndef MICROPY_INCLUDED_ESP32S2_COMMON_HAL_RTC_RTC_H +#define MICROPY_INCLUDED_ESP32S2_COMMON_HAL_RTC_RTC_H extern void rtc_init(void); extern void rtc_reset(void); extern void common_hal_rtc_init(void); -#endif // MICROPY_INCLUDED_NRF_COMMON_HAL_RTC_RTC_H +#endif // MICROPY_INCLUDED_ESP32S2_COMMON_HAL_RTC_RTC_H diff --git a/ports/esp32s2/common-hal/supervisor/Runtime.h b/ports/esp32s2/common-hal/supervisor/Runtime.h index d1fe246211..840ce1bbb3 100644 --- a/ports/esp32s2/common-hal/supervisor/Runtime.h +++ b/ports/esp32s2/common-hal/supervisor/Runtime.h @@ -24,8 +24,8 @@ * THE SOFTWARE. */ -#ifndef MICROPY_INCLUDED_LITEX_COMMON_HAL_SUPERVISOR_RUNTIME_H -#define MICROPY_INCLUDED_LITEX_COMMON_HAL_SUPERVISOR_RUNTIME_H +#ifndef MICROPY_INCLUDED_ESP32S2_COMMON_HAL_SUPERVISOR_RUNTIME_H +#define MICROPY_INCLUDED_ESP32S2_COMMON_HAL_SUPERVISOR_RUNTIME_H #include "py/obj.h" @@ -34,4 +34,4 @@ typedef struct { // Stores no state currently. } super_runtime_obj_t; -#endif // MICROPY_INCLUDED_LITEX_COMMON_HAL_SUPERVISOR_RUNTIME_H +#endif // MICROPY_INCLUDED_ESP32S2_COMMON_HAL_SUPERVISOR_RUNTIME_H diff --git a/ports/esp32s2/supervisor/internal_flash_root_pointers.h b/ports/esp32s2/supervisor/internal_flash_root_pointers.h index ae3e45e14c..a9a8c2a22e 100644 --- a/ports/esp32s2/supervisor/internal_flash_root_pointers.h +++ b/ports/esp32s2/supervisor/internal_flash_root_pointers.h @@ -23,9 +23,9 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ -#ifndef MICROPY_INCLUDED_LITEX_INTERNAL_FLASH_ROOT_POINTERS_H -#define MICROPY_INCLUDED_LITEX_INTERNAL_FLASH_ROOT_POINTERS_H +#ifndef MICROPY_INCLUDED_ESP32S2_INTERNAL_FLASH_ROOT_POINTERS_H +#define MICROPY_INCLUDED_ESP32S2_INTERNAL_FLASH_ROOT_POINTERS_H #define FLASH_ROOT_POINTERS -#endif // MICROPY_INCLUDED_LITEX_INTERNAL_FLASH_ROOT_POINTERS_H +#endif // MICROPY_INCLUDED_ESP32S2_INTERNAL_FLASH_ROOT_POINTERS_H diff --git a/ports/litex/common-hal/microcontroller/__init__.c b/ports/litex/common-hal/microcontroller/__init__.c index 3c91661144..e6f50ed5a6 100644 --- a/ports/litex/common-hal/microcontroller/__init__.c +++ b/ports/litex/common-hal/microcontroller/__init__.c @@ -89,6 +89,10 @@ void common_hal_mcu_reset(void) { while(1); } +void common_hal_mcu_deep_sleep(void) { + //deep sleep call here +} + // 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 = { diff --git a/ports/mimxrt10xx/common-hal/microcontroller/__init__.c b/ports/mimxrt10xx/common-hal/microcontroller/__init__.c index 6a8537e2da..0329ced69b 100644 --- a/ports/mimxrt10xx/common-hal/microcontroller/__init__.c +++ b/ports/mimxrt10xx/common-hal/microcontroller/__init__.c @@ -86,6 +86,10 @@ void common_hal_mcu_reset(void) { NVIC_SystemReset(); } +void common_hal_mcu_deep_sleep(void) { + //deep sleep call here +} + // 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 = { diff --git a/ports/mimxrt10xx/peripherals/mimxrt10xx/MIMXRT1011/periph.h b/ports/mimxrt10xx/peripherals/mimxrt10xx/MIMXRT1011/periph.h index c3f04a0490..c50d73294b 100644 --- a/ports/mimxrt10xx/peripherals/mimxrt10xx/MIMXRT1011/periph.h +++ b/ports/mimxrt10xx/peripherals/mimxrt10xx/MIMXRT1011/periph.h @@ -24,8 +24,8 @@ * THE SOFTWARE. */ -#ifndef MICROPY_INCLUDED_MIMXRT10XX_PERIPHERALS_MIMXRT1011_PERIPH_H -#define MICROPY_INCLUDED_MIMXRT10XX_PERIPHERALS_MIMXRT1011_PERIPH_H +#ifndef MICROPY_INCLUDED_MIMXRT10XX_MIMXRT1011_PERIPHERALS_MIMXRT1011_PERIPH_H +#define MICROPY_INCLUDED_MIMXRT10XX_MIMXRT1011_PERIPHERALS_MIMXRT1011_PERIPH_H extern LPI2C_Type *mcu_i2c_banks[2]; @@ -47,4 +47,4 @@ extern const mcu_periph_obj_t mcu_uart_cts_list[4]; extern const mcu_pwm_obj_t mcu_pwm_list[20]; -#endif // MICROPY_INCLUDED_MIMXRT10XX_PERIPHERALS_MIMXRT1011_PERIP_H +#endif // MICROPY_INCLUDED_MIMXRT10XX_MIMXRT1011_PERIPHERALS_MIMXRT1011_PERIPH_H diff --git a/ports/mimxrt10xx/peripherals/mimxrt10xx/MIMXRT1062/periph.h b/ports/mimxrt10xx/peripherals/mimxrt10xx/MIMXRT1062/periph.h index 4f6ab6261e..067c05d0d0 100644 --- a/ports/mimxrt10xx/peripherals/mimxrt10xx/MIMXRT1062/periph.h +++ b/ports/mimxrt10xx/peripherals/mimxrt10xx/MIMXRT1062/periph.h @@ -24,8 +24,8 @@ * THE SOFTWARE. */ -#ifndef MICROPY_INCLUDED_MIMXRT10XX_PERIPHERALS_MIMXRT1011_PERIPH_H -#define MICROPY_INCLUDED_MIMXRT10XX_PERIPHERALS_MIMXRT1011_PERIPH_H +#ifndef MICROPY_INCLUDED_MIMXRT10XX_MIMXRT1062_PERIPHERALS_MIMXRT1011_PERIPH_H +#define MICROPY_INCLUDED_MIMXRT10XX_MIMXRT1062_PERIPHERALS_MIMXRT1011_PERIPH_H extern LPI2C_Type *mcu_i2c_banks[4]; @@ -47,4 +47,4 @@ extern const mcu_periph_obj_t mcu_uart_cts_list[9]; extern const mcu_pwm_obj_t mcu_pwm_list[67]; -#endif // MICROPY_INCLUDED_MIMXRT10XX_PERIPHERALS_MIMXRT1011_PERIPH_H +#endif // MICROPY_INCLUDED_MIMXRT10XX_MIMXRT1062_PERIPHERALS_MIMXRT1011_PERIPH_H diff --git a/ports/nrf/common-hal/microcontroller/__init__.c b/ports/nrf/common-hal/microcontroller/__init__.c index 06aac9409d..9911896bff 100644 --- a/ports/nrf/common-hal/microcontroller/__init__.c +++ b/ports/nrf/common-hal/microcontroller/__init__.c @@ -95,6 +95,10 @@ void common_hal_mcu_reset(void) { reset_cpu(); } +void common_hal_mcu_deep_sleep(void) { + //deep sleep call here +} + // 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 = { diff --git a/ports/nrf/common-hal/rgbmatrix/RGBMatrix.h b/ports/nrf/common-hal/rgbmatrix/RGBMatrix.h index 48de4dcb21..24d86f1779 100644 --- a/ports/nrf/common-hal/rgbmatrix/RGBMatrix.h +++ b/ports/nrf/common-hal/rgbmatrix/RGBMatrix.h @@ -24,8 +24,8 @@ * THE SOFTWARE. */ -#ifndef MICROPY_INCLUDED_ATMEL_SAMD_COMMON_HAL_RGBMATRIX_RGBMATRIX_H -#define MICROPY_INCLUDED_ATMEL_SAMD_COMMON_HAL_RGBMATRIX_RGBMATRIX_H +#ifndef MICROPY_INCLUDED_NRF_COMMON_HAL_RGBMATRIX_RGBMATRIX_H +#define MICROPY_INCLUDED_NRF_COMMON_HAL_RGBMATRIX_RGBMATRIX_H void *common_hal_rgbmatrix_timer_allocate(void); void common_hal_rgbmatrix_timer_enable(void*); diff --git a/ports/stm/common-hal/microcontroller/__init__.c b/ports/stm/common-hal/microcontroller/__init__.c index a827399ccb..bc81b0e4f5 100644 --- a/ports/stm/common-hal/microcontroller/__init__.c +++ b/ports/stm/common-hal/microcontroller/__init__.c @@ -81,6 +81,10 @@ void common_hal_mcu_reset(void) { NVIC_SystemReset(); } +void common_hal_mcu_deep_sleep(void) { + //deep sleep call here +} + // 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 = { diff --git a/ports/stm/common-hal/rgbmatrix/RGBMatrix.h b/ports/stm/common-hal/rgbmatrix/RGBMatrix.h index 48de4dcb21..323878d202 100644 --- a/ports/stm/common-hal/rgbmatrix/RGBMatrix.h +++ b/ports/stm/common-hal/rgbmatrix/RGBMatrix.h @@ -24,8 +24,8 @@ * THE SOFTWARE. */ -#ifndef MICROPY_INCLUDED_ATMEL_SAMD_COMMON_HAL_RGBMATRIX_RGBMATRIX_H -#define MICROPY_INCLUDED_ATMEL_SAMD_COMMON_HAL_RGBMATRIX_RGBMATRIX_H +#ifndef MICROPY_INCLUDED_STM_COMMON_HAL_RGBMATRIX_RGBMATRIX_H +#define MICROPY_INCLUDED_STM_COMMON_HAL_RGBMATRIX_RGBMATRIX_H void *common_hal_rgbmatrix_timer_allocate(void); void common_hal_rgbmatrix_timer_enable(void*); diff --git a/shared-bindings/alarm/__init__.c b/shared-bindings/alarm/__init__.c index 9345442164..22b2e7f6ab 100644 --- a/shared-bindings/alarm/__init__.c +++ b/shared-bindings/alarm/__init__.c @@ -28,7 +28,6 @@ #include "py/runtime.h" #include "shared-bindings/alarm/__init__.h" -#include "shared-bindings/alarm/ResetReason.h" #include "shared-bindings/alarm/pin/PinAlarm.h" #include "shared-bindings/alarm/time/DurationAlarm.h" @@ -44,42 +43,61 @@ //| //| Deep sleep shuts down power to nearly all of the chip including the CPU and RAM. This can save //| a more significant amount of power, but CircuitPython must start ``code.py`` from the beginning when woken -//| up. CircuitPython will enter deep sleep automatically when the current program exits without error -//| or calls ``sys.exit(0)``. -//| If an error causes CircuitPython to exit, error LED error flashes will be done periodically. -//| An error includes an uncaught exception, or sys.exit called with a non-zero argumetn. +//| up. If the board is not actively connected to a host computer (usually via USB), +//| CircuitPython will enter deep sleep automatically when the current program finishes its last statement +//| or calls ``sys.exit()``. +//| If the board is connected, the board will not enter deep sleep unless `supervisor.exit_and_deep_sleep()` +//| is called explicitly. +//| +//| An error includes an uncaught exception, or sys.exit() called with a non-zero argument +//| //| To set alarms for deep sleep use `alarm.restart_on_alarm()` they will apply to next deep sleep only.""" //| //| wake_alarm: Alarm //| """The most recent alarm to wake us up from a sleep (light or deep.)""" //| -//| def sleep_until_alarm(*alarms: Alarm) -> Alarm: -//| """Performs a light sleep until woken by one of the alarms. The alarm that triggers the wake +void validate_objs_are_alarms(size_t n_args, const mp_obj_t *objs) { + for (size_t i = 0; i < n_args; i++) { + if (MP_OBJ_IS_TYPE(objs[i], &alarm_pin_pin_alarm_type) || + MP_OBJ_IS_TYPE(objs[i], &alarm_time_duration_alarm_type)) { + continue; + } + mp_raise_TypeError_varg(translate("Expected an alarm")); + } +} + +//| def sleep_until_alarms(*alarms: Alarm) -> Alarm: +//| """Performs a light sleep until woken by one of the alarms. The alarm caused the wake-up //| is returned, and is also available as `alarm.wake_alarm` //| """ //| ... //| -STATIC mp_obj_t alarm_sleep_until_alarm(size_t n_args, const mp_obj_t *args) { - // TODO - common_hal_alarm_sleep_until_alarm(size_t n_args, const mp_obj_t *args); +STATIC mp_obj_t alarm_sleep_until_alarms(size_t n_args, const mp_obj_t *args) { + validate_objs_are_alarms(n_args, args); + common_hal_alarm_sleep_until_alarms(n_args, args); return mp_const_none; } -MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(alarm_sleep_until_alarm_obj, 1, MP_OBJ_FUN_ARGS_MAX, alarm_sleep_until_alarm); +MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(alarm_sleep_until_alarms_obj, 1, MP_OBJ_FUN_ARGS_MAX, alarm_sleep_until_alarms); -//| def restart_on_alarm(*alarms: Alarm) -> None: +//| def set_deep_sleep_alarms(*alarms: Alarm) -> None: //| """Set one or more alarms to wake up from a deep sleep. -//| When awakened, ``code.py`` will restart from the beginning. -//| The last alarm to wake us up is available as `alarm.wake_alarm`. +//| +//| When awakened, the microcontroller will restart and run ``boot.py`` and ``code.py`` +//| from the beginning. +//| +//| The alarm that caused the wake-up is available as `alarm.wake_alarm`. +//| +//| If you call this routine more than once, only the last set of alarms given will be used. //| """ //| ... //| -STATIC mp_obj_t alarm_restart_on_alarm(size_t n_args, const mp_obj_t *args) { - // TODO - common_hal_alarm_restart_on_alarm(size_t n_args, const mp_obj_t *args); +STATIC mp_obj_t alarm_set_deep_sleep_alarms(size_t n_args, const mp_obj_t *args) { + validate_objs_are_alarms(n_args, args); + common_hal_alarm_set_deep_sleep_alarms(n_args, args); return mp_const_none; } -MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(alarm_restart_on_alarm_obj, 1, MP_OBJ_FUN_ARGS_MAX, alarm_restart_on_alarm); +MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(alarm_set_deep_sleep_alarms_obj, 1, MP_OBJ_FUN_ARGS_MAX, alarm_set_deep_sleep_alarms); //| """The `alarm.pin` module contains alarm attributes and classes related to pins. //| """ @@ -116,11 +134,11 @@ STATIC const mp_obj_module_t alarm_time_module = { STATIC mp_map_elem_t alarm_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_alarm) }, - // wake_alarm and reset_reason are mutable attributes. + // wake_alarm is a mutable attribute. { MP_ROM_QSTR(MP_QSTR_wake_alarm), mp_const_none }, - { MP_ROM_QSTR(MP_QSTR_sleep_until_alarm), MP_OBJ_FROM_PTR(&alarm_sleep_until_alarm_obj) }, - { MP_ROM_QSTR(MP_QSTR_restart_on_alarm), MP_OBJ_FROM_PTR(&alarm_restart_on_alarm_obj) }, + { MP_ROM_QSTR(MP_QSTR_sleep_until_alarms), MP_OBJ_FROM_PTR(&alarm_sleep_until_alarms_obj) }, + { MP_ROM_QSTR(MP_QSTR_set_deep_sleep_alarms), MP_OBJ_FROM_PTR(&alarm_set_deep_sleep_alarms_obj) }, { MP_ROM_QSTR(MP_QSTR_pin), MP_OBJ_FROM_PTR(&alarm_pin_module) }, { MP_ROM_QSTR(MP_QSTR_time), MP_OBJ_FROM_PTR(&alarm_time_module) } diff --git a/shared-bindings/alarm/__init__.h b/shared-bindings/alarm/__init__.h index 29be8716c5..4df12175d4 100644 --- a/shared-bindings/alarm/__init__.h +++ b/shared-bindings/alarm/__init__.h @@ -29,9 +29,10 @@ #include "py/obj.h" +extern mp_obj_t common_hal_alarm_sleep_until_alarms(size_t n_alarms, const mp_obj_t *alarms); +extern mp_obj_t common_hal_alarm_set_deep_sleep_alarms(size_t n_alarms, const mp_obj_t *alarms); + +// Used by wake-up code. extern void common_hal_alarm_set_wake_alarm(mp_obj_t alarm); -extern mp_obj_t common_hal_alarm_restart_on_alarm(size_t n_alarms, const mp_obj_t *alarms); -extern mp_obj_t alarm_sleep_until_alarm(size_t n_alarms, const mp_obj_t *alarms); - #endif // MICROPY_INCLUDED_SHARED_BINDINGS_ALARM___INIT___H diff --git a/shared-bindings/alarm/pin/PinAlarm.c b/shared-bindings/alarm/pin/PinAlarm.c index 835a5be5ce..a2d2e0ab7a 100644 --- a/shared-bindings/alarm/pin/PinAlarm.c +++ b/shared-bindings/alarm/pin/PinAlarm.c @@ -37,23 +37,25 @@ //| class PinAlarm: //| """Trigger an alarm when a pin changes state.""" //| -//| def __init__(self, pin: microcontroller.Pin, level: bool, *, edge: bool = False, pull: bool = False) -> None: +//| def __init__(self, *pins: microcontroller.Pin, value: bool, all_same_value: bool = False, edge: bool = False, pull: bool = False) -> None: //| """Create an alarm triggered by a `~microcontroller.Pin` level. The alarm is not active //| until it is listed in an `alarm`-enabling function, such as `alarm.sleep_until_alarm()` or //| `alarm.restart_on_alarm()`. //| -//| :param ~microcontroller.Pin pin: The pin to monitor. On some ports, the choice of pin +//| :param pins: The pins to monitor. On some ports, the choice of pins //| may be limited due to hardware restrictions, particularly for deep-sleep alarms. -//| :param bool level: When active, trigger when the level is high (``True``) or low (``False``). -//| On some ports, multiple `PinAlarm` objects may need to have coordinated levels +//| :param bool value: When active, trigger when the pin value is high (``True``) or low (``False``). +//| On some ports, multiple `PinAlarm` objects may need to have coordinated values //| for deep-sleep alarms. +//| :param bool all_same_value: If ``True``, all pins listed must be at `value` to trigger the alarm. +//| If ``False``, any one of the pins going to `value` will trigger the alarm. //| :param bool edge: If ``True``, trigger only when there is a transition to the specified -//| value of `level`. If ``True``, if the alarm becomes active when the pin level already -//| matches `level`, the alarm is not triggered: the pin must transition from ``not level`` -//| to ``level`` to trigger the alarm. On some ports, edge-triggering may not be available, +//| value of `value`. If ``True``, if the alarm becomes active when the pin value already +//| matches `value`, the alarm is not triggered: the pin must transition from ``not value`` +//| to ``value`` to trigger the alarm. On some ports, edge-triggering may not be available, //| particularly for deep-sleep alarms. -//| :param bool pull: Enable a pull-up or pull-down which pulls the pin to level opposite -//| opposite that of `level`. For instance, if `level` is set to ``True``, setting `pull` +//| :param bool pull: Enable a pull-up or pull-down which pulls the pin to value opposite +//| opposite that of `value`. For instance, if `value` is set to ``True``, setting `pull` //| to ``True`` will enable a pull-down, to hold the pin low normally until an outside signal //| pulls it high. //| """ @@ -62,51 +64,30 @@ STATIC mp_obj_t alarm_pin_pin_alarm_make_new(const mp_obj_type_t *type, mp_uint_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { alarm_pin_pin_alarm_obj_t *self = m_new_obj(alarm_pin_pin_alarm_obj_t); self->base.type = &alarm_pin_pin_alarm_type; - enum { ARG_pin, ARG_level, ARG_edge, ARG_pull }; + enum { ARG_value, ARG_all_same_value, ARG_edge, ARG_pull }; static const mp_arg_t allowed_args[] = { - { MP_QSTR_pin, MP_ARG_REQUIRED | MP_ARG_OBJ }, - { MP_QSTR_level, MP_ARG_REQUIRED | MP_ARG_BOOL }, + { MP_QSTR_value, MP_ARG_KW_ONLY | MP_ARG_REQUIRED | MP_ARG_BOOL }, + { MP_QSTR_all_same_value, MP_ARG_KW_ONLY | MP_ARG_BOOL, {.u_bool = false} }, { MP_QSTR_edge, MP_ARG_KW_ONLY | MP_ARG_BOOL, {.u_bool = false} }, { MP_QSTR_pull, 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); + mp_arg_parse_all(0, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); - const mcu_pin_obj_t* pin = validate_obj_is_free_pin(args[ARG_pin].u_obj); + for (size_t i = 0; i < n_args; i ++) { + validate_obj_is_free_pin(pos_args[i]); + } common_hal_alarm_pin_pin_alarm_construct( - self, pin, args[ARG_level].u_bool, args[ARG_edge].u_bool, args[ARG_pull].u_bool); + self, pos_args, n_args, + args[ARG_value].u_bool, + args[ARG_all_same_value].u_bool, + args[ARG_edge].u_bool, + args[ARG_pull].u_bool); return MP_OBJ_FROM_PTR(self); } -//| def __eq__(self, other: object) -> bool: -//| """Two PinAlarm objects are equal if their durations are the same if their pin, -//| level, edge, and pull attributes are all the same.""" -//| ... -//| -STATIC mp_obj_t alarm_pin_pin_alarm_binary_op(mp_binary_op_t op, mp_obj_t lhs_in, mp_obj_t rhs_in) { - switch (op) { - case MP_BINARY_OP_EQUAL: - if (MP_OBJ_IS_TYPE(rhs_in, &alarm_pin_pin_alarm_type)) { - // Pins are singletons, so we can compare them directly. - return mp_obj_new_bool( - common_hal_alarm_pin_pin_alarm_get_pin(lhs_in) == - common_hal_alarm_pin_pin_alarm_get_pin(rhs_in) && - common_hal_alarm_pin_pin_alarm_get_level(lhs_in) == - common_hal_alarm_pin_pin_alarm_get_level(rhs_in) && - common_hal_alarm_pin_pin_alarm_get_edge(lhs_in) == - common_hal_alarm_pin_pin_alarm_get_edge(rhs_in) && - common_hal_alarm_pin_pin_alarm_get_pull(lhs_in) == - common_hal_alarm_pin_pin_alarm_get_pull(rhs_in)); - } - return mp_const_false; - - default: - return MP_OBJ_NULL; // op not supported - } -} - STATIC const mp_rom_map_elem_t alarm_pin_pin_alarm_locals_dict_table[] = { }; @@ -116,6 +97,5 @@ const mp_obj_type_t alarm_pin_pin_alarm_type = { { &mp_type_type }, .name = MP_QSTR_PinAlarm, .make_new = alarm_pin_pin_alarm_make_new, - .binary_op = alarm_pin_pin_alarm_binary_op, .locals_dict = (mp_obj_t)&alarm_pin_pin_alarm_locals_dict, }; diff --git a/shared-bindings/alarm/pin/PinAlarm.h b/shared-bindings/alarm/pin/PinAlarm.h index 978ceaad56..bbf3018b5d 100644 --- a/shared-bindings/alarm/pin/PinAlarm.h +++ b/shared-bindings/alarm/pin/PinAlarm.h @@ -28,13 +28,14 @@ #define MICROPY_INCLUDED_SHARED_BINDINGS_ALARM_PIN_PIN_ALARM_H #include "py/obj.h" +#include "py/objtuple.h" #include "common-hal/microcontroller/Pin.h" #include "common-hal/alarm/pin/PinAlarm.h" extern const mp_obj_type_t alarm_pin_pin_alarm_type; -extern void common_hal_alarm_pin_pin_alarm_construct(alarm_pin_pin_alarm_obj_t *self, const mcu_pin_obj_t *pin, bool level, bool edge, bool pull); -extern const mcu_pin_obj_t *common_hal_alarm_pin_pin_alarm_get_pin(alarm_pin_pin_alarm_obj_t *self); +void common_hal_alarm_pin_pin_alarm_construct(alarm_pin_pin_alarm_obj_t *self, const mp_obj_t pins[], size_t num_pins, bool value, bool all_same_value, bool edge, bool pull); +extern const mp_obj_tuple_t *common_hal_alarm_pin_pin_alarm_get_pins(alarm_pin_pin_alarm_obj_t *self); extern bool common_hal_alarm_pin_pin_alarm_get_level(alarm_pin_pin_alarm_obj_t *self); extern bool common_hal_alarm_pin_pin_alarm_get_edge(alarm_pin_pin_alarm_obj_t *self); extern bool common_hal_alarm_pin_pin_alarm_get_pull(alarm_pin_pin_alarm_obj_t *self); diff --git a/shared-bindings/audiopwmio/__init__.h b/shared-bindings/audiopwmio/__init__.h index e4b7067d11..d7956d31e6 100644 --- a/shared-bindings/audiopwmio/__init__.h +++ b/shared-bindings/audiopwmio/__init__.h @@ -24,11 +24,11 @@ * THE SOFTWARE. */ -#ifndef MICROPY_INCLUDED_SHARED_BINDINGS_AUDIOIO___INIT___H -#define MICROPY_INCLUDED_SHARED_BINDINGS_AUDIOIO___INIT___H +#ifndef MICROPY_INCLUDED_SHARED_BINDINGS_AUDIOPWMIO___INIT___H +#define MICROPY_INCLUDED_SHARED_BINDINGS_AUDIOPWMIO___INIT___H #include "py/obj.h" // Nothing now. -#endif // MICROPY_INCLUDED_SHARED_BINDINGS_AUDIOIO___INIT___H +#endif // MICROPY_INCLUDED_SHARED_BINDINGS_AUDIOPWMIO___INIT___H diff --git a/shared-bindings/microcontroller/Processor.c b/shared-bindings/microcontroller/Processor.c index b0ab842f4c..ea43688213 100644 --- a/shared-bindings/microcontroller/Processor.c +++ b/shared-bindings/microcontroller/Processor.c @@ -76,9 +76,9 @@ STATIC mp_obj_t mcu_processor_get_reset_reason(mp_obj_t self) { MP_DEFINE_CONST_FUN_OBJ_1(mcu_processor_get_reset_reason_obj, mcu_processor_get_reset_reason); -const mp_obj_property_t mcu_reset_reason_obj = { +const mp_obj_property_t mcu_processor_reset_reason_obj = { .base.type = &mp_type_property, - .proxy = {(mp_obj_t)&mcu_processor_get_reason_reason_obj, // getter + .proxy = {(mp_obj_t)&mcu_processor_get_reset_reason_obj, // getter (mp_obj_t)&mp_const_none_obj, // no setter (mp_obj_t)&mp_const_none_obj, // no deleter }, diff --git a/shared-bindings/microcontroller/Processor.h b/shared-bindings/microcontroller/Processor.h index a842e06f32..98d4790876 100644 --- a/shared-bindings/microcontroller/Processor.h +++ b/shared-bindings/microcontroller/Processor.h @@ -29,6 +29,7 @@ #include "py/obj.h" +#include "common-hal/microcontroller/Processor.h" #include "shared-bindings/microcontroller/ResetReason.h" extern const mp_obj_type_t mcu_processor_type; diff --git a/shared-bindings/microcontroller/ResetReason.c b/shared-bindings/microcontroller/ResetReason.c index 151fcf3159..61891934ae 100644 --- a/shared-bindings/microcontroller/ResetReason.c +++ b/shared-bindings/microcontroller/ResetReason.c @@ -35,6 +35,7 @@ MAKE_ENUM_VALUE(mcu_reset_reason_type, reset_reason, SOFTWARE, RESET_REASON_SOFT MAKE_ENUM_VALUE(mcu_reset_reason_type, reset_reason, DEEP_SLEEP_ALARM, RESET_REASON_DEEP_SLEEP_ALARM); MAKE_ENUM_VALUE(mcu_reset_reason_type, reset_reason, RESET_PIN, RESET_REASON_RESET_PIN); MAKE_ENUM_VALUE(mcu_reset_reason_type, reset_reason, WATCHDOG, RESET_REASON_WATCHDOG); +MAKE_ENUM_VALUE(mcu_reset_reason_type, reset_reason, UNKNOWN, RESET_REASON_UNKNOWN); //| class ResetReason: //| """The reason the microntroller was last reset""" @@ -55,7 +56,10 @@ MAKE_ENUM_VALUE(mcu_reset_reason_type, reset_reason, WATCHDOG, RESET_REASON_WATC //| """The microntroller was reset by a signal on its reset pin. The pin might be connected to a reset button.""" //| //| WATCHDOG: object -//| """The chip microcontroller reset by its watchdog timer.""" +//| """The microcontroller was reset by its watchdog timer.""" +//| +//| UNKNOWN: object +//| """The microntroller restarted for an unknown reason.""" //| MAKE_ENUM_MAP(mcu_reset_reason) { MAKE_ENUM_MAP_ENTRY(reset_reason, POWER_ON), @@ -64,6 +68,7 @@ MAKE_ENUM_MAP(mcu_reset_reason) { MAKE_ENUM_MAP_ENTRY(reset_reason, DEEP_SLEEP_ALARM), MAKE_ENUM_MAP_ENTRY(reset_reason, RESET_PIN), MAKE_ENUM_MAP_ENTRY(reset_reason, WATCHDOG), + MAKE_ENUM_MAP_ENTRY(reset_reason, UNKNOWN), }; STATIC MP_DEFINE_CONST_DICT(mcu_reset_reason_locals_dict, mcu_reset_reason_locals_table); diff --git a/shared-bindings/microcontroller/ResetReason.h b/shared-bindings/microcontroller/ResetReason.h index df1abf266e..8ed5e48315 100644 --- a/shared-bindings/microcontroller/ResetReason.h +++ b/shared-bindings/microcontroller/ResetReason.h @@ -24,8 +24,8 @@ * THE SOFTWARE. */ -#ifndef MICROPY_INCLUDED_SHARED_BINDINGS_MCU__RESET_REASON__H -#define MICROPY_INCLUDED_SHARED_BINDINGS_MCU__RESET_REASON__H +#ifndef MICROPY_INCLUDED_SHARED_BINDINGS_MCU_RESET_REASON__H +#define MICROPY_INCLUDED_SHARED_BINDINGS_MCU_RESET_REASON__H #include "py/obj.h" #include "py/enum.h" @@ -37,15 +37,9 @@ typedef enum { RESET_REASON_DEEP_SLEEP_ALARM, RESET_REASON_RESET_PIN, RESET_REASON_WATCHDOG, + RESET_REASON_UNKNOWN, } mcu_reset_reason_t; -extern const cp_enum_obj_t reset_reason_POWER_ON_obj; -extern const cp_enum_obj_t reset_reason_BROWNOUT_obj; -extern const cp_enum_obj_t reset_reason_SOFTWARE_obj; -extern const cp_enum_obj_t reset_reason_DEEP_SLEEP_ALARM_obj; -extern const cp_enum_obj_t reset_reason_RESET_PIN_obj; -extern const cp_enum_obj_t reset_reason_WATCHDOG_obj; - extern const mp_obj_type_t mcu_reset_reason_type; -#endif // MICROPY_INCLUDED_SHARED_BINDINGS_MCU__RESET_REASON__H +#endif // MICROPY_INCLUDED_SHARED_BINDINGS_MCU_RESET_REASON__H diff --git a/shared-bindings/microcontroller/__init__.c b/shared-bindings/microcontroller/__init__.c index d09cf8f445..d6ce323c58 100644 --- a/shared-bindings/microcontroller/__init__.c +++ b/shared-bindings/microcontroller/__init__.c @@ -56,6 +56,19 @@ //| This object is the sole instance of `microcontroller.Processor`.""" //| +//| def deep_sleep() -> None: +//| Go into deep sleep. If the board is connected via USB, disconnect USB first. +//| +//| The board will awake from deep sleep only if the reset button is pressed +//| or it is awoken by an alarm set by `alarm.set_deep_sleep_alarms()`. +//| ... +//| +STATIC mp_obj_t mcu_deep_sleep(void){ + + return mp_const_none; +} +MP_DEFINE_CONST_FUN_OBJ_0(mcu_deep_sleep_obj, mcu_deep_sleep); + //| def delay_us(delay: int) -> None: //| """Dedicated delay method used for very short delays. **Do not** do long delays //| because this stops all other functions from completing. Think of this as an empty @@ -164,6 +177,7 @@ const mp_obj_module_t mcu_pin_module = { STATIC const mp_rom_map_elem_t mcu_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_microcontroller) }, { MP_ROM_QSTR(MP_QSTR_cpu), MP_ROM_PTR(&common_hal_mcu_processor_obj) }, + { MP_ROM_QSTR(MP_QSTR_deep_sleep), MP_ROM_PTR(&mcu_deep_sleep_obj) }, { MP_ROM_QSTR(MP_QSTR_delay_us), MP_ROM_PTR(&mcu_delay_us_obj) }, { MP_ROM_QSTR(MP_QSTR_disable_interrupts), MP_ROM_PTR(&mcu_disable_interrupts_obj) }, { MP_ROM_QSTR(MP_QSTR_enable_interrupts), MP_ROM_PTR(&mcu_enable_interrupts_obj) }, diff --git a/shared-bindings/microcontroller/__init__.h b/shared-bindings/microcontroller/__init__.h index ac71de4247..c6ccccea72 100644 --- a/shared-bindings/microcontroller/__init__.h +++ b/shared-bindings/microcontroller/__init__.h @@ -43,6 +43,8 @@ extern void common_hal_mcu_enable_interrupts(void); extern void common_hal_mcu_on_next_reset(mcu_runmode_t runmode); extern void common_hal_mcu_reset(void); +extern void common_hal_mcu_deep_sleep(void); + extern const mp_obj_dict_t mcu_pin_globals; extern const mcu_processor_obj_t common_hal_mcu_processor_obj; diff --git a/shared-bindings/supervisor/RunReason.c b/shared-bindings/supervisor/RunReason.c index ee08f6d71b..7e7a74d2f4 100644 --- a/shared-bindings/supervisor/RunReason.c +++ b/shared-bindings/supervisor/RunReason.c @@ -29,7 +29,7 @@ #include "shared-bindings/supervisor/RunReason.h" MAKE_ENUM_VALUE(supervisor_run_reason_type, run_reason, STARTUP, RUN_REASON_STARTUP); -MAKE_ENUM_VALUE(supervisor_run_reason_type, run_reason, AUTORELOAD, RUN_REASON_AUTORELOAD); +MAKE_ENUM_VALUE(supervisor_run_reason_type, run_reason, AUTORELOAD, RUN_REASON_AUTO_RELOAD); MAKE_ENUM_VALUE(supervisor_run_reason_type, run_reason, SUPERVISOR_RELOAD, RUN_REASON_SUPERVISOR_RELOAD); MAKE_ENUM_VALUE(supervisor_run_reason_type, run_reason, REPL_RELOAD, RUN_REASON_REPL_RELOAD); @@ -40,8 +40,8 @@ MAKE_ENUM_VALUE(supervisor_run_reason_type, run_reason, REPL_RELOAD, RUN_REASON_ //| """CircuitPython started the microcontroller started up. See `microcontroller.cpu.reset_reason` //| for more detail on why the microcontroller was started.""" //| -//| AUTORELOAD: object -//| """CircuitPython restarted due to a USB write to the filesystem.""" +//| AUTO_RELOAD: object +//| """CircuitPython restarted due to an external write to the filesystem.""" //| //| SUPERVISOR_RELOAD: object //| """CircuitPython restarted due to a call to `supervisor.reload()`.""" @@ -51,7 +51,7 @@ MAKE_ENUM_VALUE(supervisor_run_reason_type, run_reason, REPL_RELOAD, RUN_REASON_ //| MAKE_ENUM_MAP(run_reason) { MAKE_ENUM_MAP_ENTRY(run_reason, STARTUP), - MAKE_ENUM_MAP_ENTRY(run_reason, AUTORELOAD), + MAKE_ENUM_MAP_ENTRY(run_reason, AUTO_RELOAD), MAKE_ENUM_MAP_ENTRY(run_reason, SUPERVISOR_RELOAD), MAKE_ENUM_MAP_ENTRY(run_reason, REPL_RELOAD), }; diff --git a/shared-bindings/supervisor/RunReason.h b/shared-bindings/supervisor/RunReason.h index 934c72fd8c..391e6d3064 100644 --- a/shared-bindings/supervisor/RunReason.h +++ b/shared-bindings/supervisor/RunReason.h @@ -28,7 +28,7 @@ typedef enum { RUN_REASON_STARTUP, - RUN_REASON_AUTORELOAD, + RUN_REASON_AUTO_RELOAD, RUN_REASON_SUPERVISOR_RELOAD, RUN_REASON_REPL_RELOAD, } supervisor_run_reason_t; diff --git a/shared-bindings/supervisor/Runtime.c b/shared-bindings/supervisor/Runtime.c index 6500dadd59..67193e051e 100755 --- a/shared-bindings/supervisor/Runtime.c +++ b/shared-bindings/supervisor/Runtime.c @@ -25,9 +25,13 @@ */ #include +#include "py/enum.h" #include "py/objproperty.h" +#include "shared-bindings/supervisor/RunReason.h" #include "shared-bindings/supervisor/Runtime.h" +STATIC supervisor_run_reason_t _run_reason; + //TODO: add USB, REPL to description once they're operational //| class Runtime: //| """Current status of runtime objects. @@ -94,8 +98,7 @@ const mp_obj_property_t supervisor_serial_bytes_available_obj = { //| """Returns why CircuitPython started running this particular time. //| STATIC mp_obj_t supervisor_get_run_reason(mp_obj_t self) { - mp_raise_NotImplementedError(NULL); - return mp_const_none; + return cp_enum_find(&supervisor_run_reason_type, _run_reason); } MP_DEFINE_CONST_FUN_OBJ_1(supervisor_get_run_reason_obj, supervisor_get_run_reason); @@ -106,6 +109,9 @@ const mp_obj_property_t supervisor_run_reason_obj = { (mp_obj_t)&mp_const_none_obj}, }; +void supervisor_set_run_reason(supervisor_run_reason_t run_reason) { + _run_reason = run_reason; +} STATIC const mp_rom_map_elem_t supervisor_runtime_locals_dict_table[] = { { MP_ROM_QSTR(MP_QSTR_serial_connected), MP_ROM_PTR(&supervisor_serial_connected_obj) }, diff --git a/shared-bindings/supervisor/Runtime.h b/shared-bindings/supervisor/Runtime.h index 2dc59c3ab6..51ed7604df 100755 --- a/shared-bindings/supervisor/Runtime.h +++ b/shared-bindings/supervisor/Runtime.h @@ -30,9 +30,12 @@ #include #include "py/obj.h" +#include "shared-bindings/supervisor/RunReason.h" extern const mp_obj_type_t supervisor_runtime_type; +void supervisor_set_run_reason(supervisor_run_reason_t run_reason); + bool common_hal_get_serial_connected(void); bool common_hal_get_serial_bytes_available(void); diff --git a/shared-bindings/supervisor/__init__.c b/shared-bindings/supervisor/__init__.c index bc6fdbff5a..4d2d6db309 100644 --- a/shared-bindings/supervisor/__init__.c +++ b/shared-bindings/supervisor/__init__.c @@ -88,6 +88,7 @@ MP_DEFINE_CONST_FUN_OBJ_1(supervisor_set_rgb_status_brightness_obj, supervisor_s //| STATIC mp_obj_t supervisor_reload(void) { reload_requested = true; + supervisor_set_run_reason(RUN_REASON_SUPERVISOR_RELOAD); mp_raise_reload_exception(); return mp_const_none; } diff --git a/supervisor/shared/usb/usb.c b/supervisor/shared/usb/usb.c index 3d76e7000a..ff08ade18a 100644 --- a/supervisor/shared/usb/usb.c +++ b/supervisor/shared/usb/usb.c @@ -106,25 +106,21 @@ void usb_irq_handler(void) { // Invoked when device is mounted void tud_mount_cb(void) { usb_msc_mount(); - _workflow_active = true; } // Invoked when device is unmounted void tud_umount_cb(void) { usb_msc_umount(); - _workflow_active = false; } // Invoked when usb bus is suspended // remote_wakeup_en : if host allows us to perform remote wakeup // USB Specs: Within 7ms, device must draw an average current less than 2.5 mA from bus void tud_suspend_cb(bool remote_wakeup_en) { - _workflow_active = false; } // Invoked when usb bus is resumed void tud_resume_cb(void) { - _workflow_active = true; } // Invoked when cdc when line state changed e.g connected/disconnected diff --git a/supervisor/shared/workflow.c b/supervisor/shared/workflow.c index cd19d3aa25..41af22eb70 100644 --- a/supervisor/shared/workflow.c +++ b/supervisor/shared/workflow.c @@ -25,10 +25,10 @@ */ #include - -// Set by the shared USB code. -volatile bool _workflow_active; +#include "tusb.h" bool supervisor_workflow_active(void) { - return _workflow_active; + // Eventually there might be other non-USB workflows, such as BLE. + // tud_ready() checks for usb mounted and not suspended. + return tud_ready(); } From 661c20dd180343a3a5c7a52e63875888218422ba Mon Sep 17 00:00:00 2001 From: jgillick Date: Sun, 22 Nov 2020 18:25:37 -0800 Subject: [PATCH 112/207] Create a new linker script with more space for the firmware. --- ports/stm/boards/STM32F411_nvm_flash.ld | 29 +++++++++++++++++++ .../boards/thunderpack_v12/mpconfigboard.h | 12 ++++---- .../boards/thunderpack_v12/mpconfigboard.mk | 2 +- ports/stm/supervisor/internal_flash.h | 4 +++ 4 files changed, 41 insertions(+), 6 deletions(-) create mode 100644 ports/stm/boards/STM32F411_nvm_flash.ld diff --git a/ports/stm/boards/STM32F411_nvm_flash.ld b/ports/stm/boards/STM32F411_nvm_flash.ld new file mode 100644 index 0000000000..ced739765d --- /dev/null +++ b/ports/stm/boards/STM32F411_nvm_flash.ld @@ -0,0 +1,29 @@ +/* + GNU linker script for STM32F411 with nvm and an external flash chip, and reserves + more space for the CircuitPython firmware and less for the filesystem + (since the filesystem will be on the external flash chip). +*/ + +/* 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 = 32K /* sectors 1,2 are 16K */ + FLASH_NVM (rwx) : ORIGIN = 0x0800C000, LENGTH = 16K /* sector 3 is 16K */ + FLASH_FIRMWARE (rx) : ORIGIN = 0x08010000, LENGTH = 448K /* sector 4 is 64K, sectors 5,6,7 are 128K */ + RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 128K +} + +/* produce a link error if there is not this amount of RAM for these sections */ +_minimum_stack_size = 24K; +_minimum_heap_size = 16K; + +/* 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); + +/* RAM extents for the garbage collector */ +_ram_start = ORIGIN(RAM); +_ram_end = ORIGIN(RAM) + LENGTH(RAM); diff --git a/ports/stm/boards/thunderpack_v12/mpconfigboard.h b/ports/stm/boards/thunderpack_v12/mpconfigboard.h index 426e0678da..773ca297e5 100644 --- a/ports/stm/boards/thunderpack_v12/mpconfigboard.h +++ b/ports/stm/boards/thunderpack_v12/mpconfigboard.h @@ -28,14 +28,16 @@ // Non-volatile memory config #define CIRCUITPY_INTERNAL_NVM_SIZE (0x4000) -#define CIRCUITPY_INTERNAL_NVM_START_ADDR (0x08010000) -#define CIRCUITPY_INTERNAL_NVM_SECTOR FLASH_SECTOR_4 +#define CIRCUITPY_INTERNAL_NVM_START_ADDR (0x0800C000) +#define CIRCUITPY_INTERNAL_NVM_SECTOR FLASH_SECTOR_3 #define NVM_BYTEARRAY_BUFFER_SIZE 512 // Flash config -#define FLASH_SIZE (0x80000) -#define FLASH_PAGE_SIZE (0x4000) -#define BOARD_FLASH_SIZE (FLASH_SIZE - CIRCUITPY_INTERNAL_NVM_SIZE- 0x2000 - 0xC000) +#define FLASH_SIZE (0x80000) +#define FLASH_PAGE_SIZE (0x4000) +#define BOARD_FLASH_SIZE (FLASH_SIZE - CIRCUITPY_INTERNAL_NVM_SIZE- 0x2000 - 0xC000) +#define INTERNAL_FLASH_FILESYSTEM_SIZE 0x8000 +#define INTERNAL_FLASH_FILESYSTEM_START_ADDR 0x08004000 // On-board flash #define SPI_FLASH_MOSI_PIN (&pin_PB15) diff --git a/ports/stm/boards/thunderpack_v12/mpconfigboard.mk b/ports/stm/boards/thunderpack_v12/mpconfigboard.mk index 7bfe273673..744565e69b 100644 --- a/ports/stm/boards/thunderpack_v12/mpconfigboard.mk +++ b/ports/stm/boards/thunderpack_v12/mpconfigboard.mk @@ -17,4 +17,4 @@ MCU_VARIANT = STM32F411xE MCU_PACKAGE = UFQFPN48 LD_COMMON = boards/common_nvm.ld -LD_FILE = boards/STM32F411_nvm.ld +LD_FILE = boards/STM32F411_nvm_flash.ld diff --git a/ports/stm/supervisor/internal_flash.h b/ports/stm/supervisor/internal_flash.h index ad5cba62d8..5746deac84 100644 --- a/ports/stm/supervisor/internal_flash.h +++ b/ports/stm/supervisor/internal_flash.h @@ -41,9 +41,13 @@ #ifdef STM32F411xE #define STM32_FLASH_SIZE 0x80000 //512KiB +#ifndef INTERNAL_FLASH_FILESYSTEM_SIZE #define INTERNAL_FLASH_FILESYSTEM_SIZE 0xC000 //48KiB +#endif +#ifndef INTERNAL_FLASH_FILESYSTEM_START_ADDR #define INTERNAL_FLASH_FILESYSTEM_START_ADDR 0x08004000 #endif +#endif #ifdef STM32F412Zx #define STM32_FLASH_SIZE 0x100000 //1MB From 3abee9b2563f0203f3d9521631499008708bb407 Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Sun, 22 Nov 2020 21:52:37 -0500 Subject: [PATCH 113/207] compiles; maybe ready to test, or almost --- ports/esp32s2/common-hal/alarm/__init__.c | 8 +++-- ports/esp32s2/common-hal/alarm/__init__.h | 32 +++++++++++++++++++ .../common-hal/microcontroller/__init__.c | 1 + shared-bindings/alarm/__init__.h | 2 +- 4 files changed, 39 insertions(+), 4 deletions(-) create mode 100644 ports/esp32s2/common-hal/alarm/__init__.h diff --git a/ports/esp32s2/common-hal/alarm/__init__.c b/ports/esp32s2/common-hal/alarm/__init__.c index 4a255c51cc..0ea476d860 100644 --- a/ports/esp32s2/common-hal/alarm/__init__.c +++ b/ports/esp32s2/common-hal/alarm/__init__.c @@ -26,17 +26,19 @@ */ #include "py/objtuple.h" +#include "py/runtime.h" #include "shared-bindings/alarm/__init__.h" #include "shared-bindings/alarm/pin/PinAlarm.h" #include "shared-bindings/alarm/time/DurationAlarm.h" +#include "shared-bindings/microcontroller/__init__.h" #include "esp_sleep.h" STATIC mp_obj_tuple_t *_deep_sleep_alarms; void alarm_reset(void) { - _deep_sleep_alarms = &mp_const_empty_tuple; + _deep_sleep_alarms = mp_const_empty_tuple; } void common_hal_alarm_disable_all(void) { @@ -94,8 +96,8 @@ void common_hal_alarm_set_deep_sleep_alarms(size_t n_alarms, const mp_obj_t *ala } void common_hal_deep_sleep_with_alarms(void) { - for (size_t i = 0; i < _deep_sleep_alarms.len; i++) { - mp_obj_t alarm = _deep_sleep_alarms.items[i] + for (size_t i = 0; i < _deep_sleep_alarms->len; i++) { + mp_obj_t alarm = _deep_sleep_alarms->items[i]; if (MP_OBJ_IS_TYPE(alarm, &alarm_time_duration_alarm_type)) { alarm_time_duration_alarm_obj_t *duration_alarm = MP_OBJ_TO_PTR(alarm); esp_sleep_enable_timer_wakeup( diff --git a/ports/esp32s2/common-hal/alarm/__init__.h b/ports/esp32s2/common-hal/alarm/__init__.h new file mode 100644 index 0000000000..5678a0e7f1 --- /dev/null +++ b/ports/esp32s2/common-hal/alarm/__init__.h @@ -0,0 +1,32 @@ +/* + * 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_ESP32S2_COMMON_HAL_ALARM__INIT__H +#define MICROPY_INCLUDED_ESP32S2_COMMON_HAL_ALARM__INIT__H + +void alarm_reset(void); + +#endif // MICROPY_INCLUDED_ESP32S2_COMMON_HAL_ALARM__INIT__H diff --git a/ports/esp32s2/common-hal/microcontroller/__init__.c b/ports/esp32s2/common-hal/microcontroller/__init__.c index 9d87e4536f..59eb1afcc0 100644 --- a/ports/esp32s2/common-hal/microcontroller/__init__.c +++ b/ports/esp32s2/common-hal/microcontroller/__init__.c @@ -42,6 +42,7 @@ #include "freertos/FreeRTOS.h" #include "esp_sleep.h" +#include "esp_wifi.h" void common_hal_mcu_delay_us(uint32_t delay) { mp_hal_delay_us(delay); diff --git a/shared-bindings/alarm/__init__.h b/shared-bindings/alarm/__init__.h index 4df12175d4..c74dfbe5c3 100644 --- a/shared-bindings/alarm/__init__.h +++ b/shared-bindings/alarm/__init__.h @@ -30,7 +30,7 @@ #include "py/obj.h" extern mp_obj_t common_hal_alarm_sleep_until_alarms(size_t n_alarms, const mp_obj_t *alarms); -extern mp_obj_t common_hal_alarm_set_deep_sleep_alarms(size_t n_alarms, const mp_obj_t *alarms); +extern void common_hal_alarm_set_deep_sleep_alarms(size_t n_alarms, const mp_obj_t *alarms); // Used by wake-up code. extern void common_hal_alarm_set_wake_alarm(mp_obj_t alarm); From 5351a93c70fcacc50a154edac0a6d6d1028296e0 Mon Sep 17 00:00:00 2001 From: hathach Date: Mon, 23 Nov 2020 13:39:14 +0700 Subject: [PATCH 114/207] update tinyusb to fix cdc connection race issue is fixed in https://github.com/hathach/tinyusb/pull/557 --- lib/tinyusb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/tinyusb b/lib/tinyusb index 8b2c822557..b870d932e5 160000 --- a/lib/tinyusb +++ b/lib/tinyusb @@ -1 +1 @@ -Subproject commit 8b2c82255750488232eae72f3d5dcbacfd6227f3 +Subproject commit b870d932e5e1c6ece4227a5d49cc71e53a744149 From 4c5e7520f5950f831ea18866f49645c507d0f811 Mon Sep 17 00:00:00 2001 From: jgillick Date: Mon, 23 Nov 2020 00:25:41 -0800 Subject: [PATCH 115/207] Fix NVM by clearing FLASH_FLAG_PGPERR --- .../boards/thunderpack_v11/mpconfigboard.h | 2 +- .../boards/thunderpack_v12/mpconfigboard.h | 26 +++++++++---------- .../boards/thunderpack_v12/mpconfigboard.mk | 1 + ports/stm/common-hal/microcontroller/Pin.c | 15 ++++++----- ports/stm/common-hal/nvm/ByteArray.c | 2 +- ports/stm/supervisor/internal_flash.h | 4 +-- 6 files changed, 26 insertions(+), 24 deletions(-) diff --git a/ports/stm/boards/thunderpack_v11/mpconfigboard.h b/ports/stm/boards/thunderpack_v11/mpconfigboard.h index c2649e2555..7d4a8dff32 100644 --- a/ports/stm/boards/thunderpack_v11/mpconfigboard.h +++ b/ports/stm/boards/thunderpack_v11/mpconfigboard.h @@ -23,7 +23,7 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ -#define MICROPY_HW_BOARD_NAME "THUNDERPACK" +#define MICROPY_HW_BOARD_NAME "THUNDERPACK_v11" #define MICROPY_HW_MCU_NAME "STM32F411CE" // Non-volatile memory config diff --git a/ports/stm/boards/thunderpack_v12/mpconfigboard.h b/ports/stm/boards/thunderpack_v12/mpconfigboard.h index 773ca297e5..57486da280 100644 --- a/ports/stm/boards/thunderpack_v12/mpconfigboard.h +++ b/ports/stm/boards/thunderpack_v12/mpconfigboard.h @@ -27,17 +27,16 @@ #define MICROPY_HW_MCU_NAME "STM32F411CE" // Non-volatile memory config -#define CIRCUITPY_INTERNAL_NVM_SIZE (0x4000) -#define CIRCUITPY_INTERNAL_NVM_START_ADDR (0x0800C000) -#define CIRCUITPY_INTERNAL_NVM_SECTOR FLASH_SECTOR_3 -#define NVM_BYTEARRAY_BUFFER_SIZE 512 +#define CIRCUITPY_INTERNAL_NVM_SIZE (0x4000) +#define CIRCUITPY_INTERNAL_NVM_START_ADDR (0x0800C000) +#define CIRCUITPY_INTERNAL_NVM_SECTOR FLASH_SECTOR_3 +#define NVM_BYTEARRAY_BUFFER_SIZE 512 // Flash config -#define FLASH_SIZE (0x80000) -#define FLASH_PAGE_SIZE (0x4000) -#define BOARD_FLASH_SIZE (FLASH_SIZE - CIRCUITPY_INTERNAL_NVM_SIZE- 0x2000 - 0xC000) +#define FLASH_SIZE (0x80000) +#define FLASH_PAGE_SIZE (0x4000) +#define BOARD_FLASH_SIZE (FLASH_SIZE - CIRCUITPY_INTERNAL_NVM_SIZE- 0x2000 - 0xC000) #define INTERNAL_FLASH_FILESYSTEM_SIZE 0x8000 -#define INTERNAL_FLASH_FILESYSTEM_START_ADDR 0x08004000 // On-board flash #define SPI_FLASH_MOSI_PIN (&pin_PB15) @@ -45,15 +44,14 @@ #define SPI_FLASH_SCK_PIN (&pin_PB13) #define SPI_FLASH_CS_PIN (&pin_PB12) +#define HSE_VALUE ((uint32_t)24000000U) +#define BOARD_OVERWRITE_SWD (1) +#define BOARD_NO_VBUS_SENSE (1) +#define BOARD_HAS_LOW_SPEED_CRYSTAL (0) + // Status LEDs #define MICROPY_HW_APA102_MOSI (&pin_PB08) #define MICROPY_HW_APA102_SCK (&pin_PB00) - // I2C #define DEFAULT_I2C_BUS_SCL (&pin_PB06) #define DEFAULT_I2C_BUS_SDA (&pin_PB07) - -// General config -#define BOARD_OSC_DIV (24) -#define BOARD_OVERWRITE_SWD (1) -#define BOARD_NO_VBUS_SENSE (1) diff --git a/ports/stm/boards/thunderpack_v12/mpconfigboard.mk b/ports/stm/boards/thunderpack_v12/mpconfigboard.mk index 744565e69b..d0bc22680f 100644 --- a/ports/stm/boards/thunderpack_v12/mpconfigboard.mk +++ b/ports/stm/boards/thunderpack_v12/mpconfigboard.mk @@ -11,6 +11,7 @@ EXTERNAL_FLASH_DEVICE_COUNT = 1 EXTERNAL_FLASH_DEVICES = GD25Q16C CIRCUITPY_NVM = 1 +CIRCUITPY_BLEIO_HCI = 0 MCU_SERIES = F4 MCU_VARIANT = STM32F411xE diff --git a/ports/stm/common-hal/microcontroller/Pin.c b/ports/stm/common-hal/microcontroller/Pin.c index 7d259e0521..0e333c71cf 100644 --- a/ports/stm/common-hal/microcontroller/Pin.c +++ b/ports/stm/common-hal/microcontroller/Pin.c @@ -35,7 +35,7 @@ #ifdef MICROPY_HW_NEOPIXEL bool neopixel_in_use; #endif -#ifdef MICROPY_HW_APA102_MOSI +#if defined(MICROPY_HW_APA102_MOSI) && defined(MICROPY_HW_APA102_SCK) bool apa102_sck_in_use; bool apa102_mosi_in_use; #endif @@ -70,7 +70,7 @@ void reset_all_pins(void) { #ifdef MICROPY_HW_NEOPIXEL neopixel_in_use = false; #endif - #ifdef MICROPY_HW_APA102_MOSI + #if defined(MICROPY_HW_APA102_MOSI) && defined(MICROPY_HW_APA102_SCK) apa102_sck_in_use = false; apa102_mosi_in_use = false; #endif @@ -97,8 +97,11 @@ void reset_pin_number(uint8_t pin_port, uint8_t pin_number) { return; } #endif - #ifdef MICROPY_HW_APA102_MOSI - if ((pin_port == MICROPY_HW_APA102_MOSI->port && pin_number == MICROPY_HW_APA102_MOSI->number) || (pin_port == MICROPY_HW_APA102_SCK->port && pin_number == MICROPY_HW_APA102_MOSI->number)) + #if defined(MICROPY_HW_APA102_MOSI) && defined(MICROPY_HW_APA102_SCK) + if ( + (pin_port == MICROPY_HW_APA102_MOSI->port && pin_number == MICROPY_HW_APA102_MOSI->number) + || (pin_port == MICROPY_HW_APA102_SCK->port && pin_number == MICROPY_HW_APA102_MOSI->number) + ) { apa102_mosi_in_use = false; apa102_sck_in_use = false; @@ -140,7 +143,7 @@ bool common_hal_mcu_pin_is_free(const mcu_pin_obj_t *pin) { return !neopixel_in_use; } #endif - #ifdef MICROPY_HW_APA102_MOSI + #if defined(MICROPY_HW_APA102_MOSI) && defined(MICROPY_HW_APA102_SCK) if (pin == MICROPY_HW_APA102_MOSI) { return !apa102_mosi_in_use; @@ -173,7 +176,7 @@ void common_hal_mcu_pin_claim(const mcu_pin_obj_t* pin) { neopixel_in_use = true; } #endif - #ifdef MICROPY_HW_APA102_MOSI + #if defined(MICROPY_HW_APA102_MOSI) && defined(MICROPY_HW_APA102_SCK) if (pin == MICROPY_HW_APA102_MOSI) { apa102_mosi_in_use = true; diff --git a/ports/stm/common-hal/nvm/ByteArray.c b/ports/stm/common-hal/nvm/ByteArray.c index 462d3aa9de..b7a1ff0351 100644 --- a/ports/stm/common-hal/nvm/ByteArray.c +++ b/ports/stm/common-hal/nvm/ByteArray.c @@ -48,7 +48,7 @@ bool common_hal_nvm_bytearray_set_bytes(nvm_bytearray_obj_t *self, // Erase flash sector HAL_FLASH_Unlock(); - __HAL_FLASH_CLEAR_FLAG(FLASH_FLAG_EOP | FLASH_FLAG_OPERR | FLASH_FLAG_WRPERR | FLASH_FLAG_PGAERR | FLASH_FLAG_PGSERR ); + __HAL_FLASH_CLEAR_FLAG(FLASH_FLAG_EOP | FLASH_FLAG_OPERR | FLASH_FLAG_WRPERR | FLASH_FLAG_PGAERR | FLASH_FLAG_PGPERR | FLASH_FLAG_PGSERR ); FLASH_Erase_Sector(CIRCUITPY_INTERNAL_NVM_SECTOR, VOLTAGE_RANGE_3); // Write bytes to flash diff --git a/ports/stm/supervisor/internal_flash.h b/ports/stm/supervisor/internal_flash.h index 5746deac84..19ae03e0b3 100644 --- a/ports/stm/supervisor/internal_flash.h +++ b/ports/stm/supervisor/internal_flash.h @@ -42,10 +42,10 @@ #ifdef STM32F411xE #define STM32_FLASH_SIZE 0x80000 //512KiB #ifndef INTERNAL_FLASH_FILESYSTEM_SIZE -#define INTERNAL_FLASH_FILESYSTEM_SIZE 0xC000 //48KiB + #define INTERNAL_FLASH_FILESYSTEM_SIZE 0xC000 //48KiB #endif #ifndef INTERNAL_FLASH_FILESYSTEM_START_ADDR -#define INTERNAL_FLASH_FILESYSTEM_START_ADDR 0x08004000 + #define INTERNAL_FLASH_FILESYSTEM_START_ADDR 0x08004000 #endif #endif From 9d8be648eec70c36b3a461c4ff45064357d11693 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Sun, 15 Nov 2020 11:48:53 -0600 Subject: [PATCH 116/207] ulab: Update to release tag 1.1.0 Disable certain classes of diagnostic when building ulab. We should submit patches upstream to (A) fix these errors and (B) upgrade their CI so that the problems are caught before we want to integrate with CircuitPython, but not right now. --- extmod/ulab | 2 +- locale/circuitpython.pot | 147 +++++++++++++++++++++++++++------------ py/py.mk | 2 +- 3 files changed, 106 insertions(+), 45 deletions(-) diff --git a/extmod/ulab b/extmod/ulab index 8242b84753..aa7e741530 160000 --- a/extmod/ulab +++ b/extmod/ulab @@ -1 +1 @@ -Subproject commit 8242b84753355433b61230ab6631c06e5ac77f35 +Subproject commit aa7e741530df471d206a4a321823a37a913a0eb8 diff --git a/locale/circuitpython.pot b/locale/circuitpython.pot index ec232615d1..c184d69313 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-11-10 15:30+0530\n" +"POT-Creation-Date: 2020-11-23 10:10-0600\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -855,6 +855,10 @@ msgstr "" msgid "FFT is defined for ndarrays only" msgstr "" +#: extmod/ulab/code/fft/fft.c +msgid "FFT is implemented for linear arrays only" +msgstr "" + #: ports/esp32s2/common-hal/socketpool/Socket.c msgid "Failed SSL handshake" msgstr "" @@ -1951,7 +1955,7 @@ msgstr "" msgid "WARNING: Your code filename has two extensions\n" msgstr "" -#: shared-bindings/watchdog/WatchDogTimer.c +#: ports/nrf/common-hal/watchdog/WatchDogTimer.c msgid "WatchDogTimer cannot be deinitialized once mode is set to RESET" msgstr "" @@ -2030,10 +2034,6 @@ msgstr "" msgid "addresses is empty" msgstr "" -#: extmod/ulab/code/vector/vectorise.c -msgid "arctan2 is implemented for scalars and ndarrays only" -msgstr "" - #: py/modbuiltins.c msgid "arg is an empty sequence" msgstr "" @@ -2042,6 +2042,10 @@ msgstr "" msgid "argsort argument must be an ndarray" msgstr "" +#: extmod/ulab/code/numerical/numerical.c +msgid "argsort is not implemented for flattened arrays" +msgstr "" + #: py/runtime.c msgid "argument has wrong type" msgstr "" @@ -2059,14 +2063,22 @@ msgstr "" msgid "argument should be a '%q' not a '%q'" msgstr "" -#: extmod/ulab/code/linalg/linalg.c +#: extmod/ulab/code/linalg/linalg.c extmod/ulab/code/numerical/numerical.c msgid "arguments must be ndarrays" msgstr "" +#: extmod/ulab/code/ndarray.c +msgid "array and index length must be equal" +msgstr "" + #: py/objarray.c shared-bindings/nvm/ByteArray.c msgid "array/bytes required on right side" msgstr "" +#: extmod/ulab/code/numerical/numerical.c +msgid "attempt to get (arg)min/(arg)max of empty sequence" +msgstr "" + #: extmod/ulab/code/numerical/numerical.c msgid "attempt to get argmin/argmax of an empty sequence" msgstr "" @@ -2076,15 +2088,15 @@ msgid "attributes not supported yet" msgstr "" #: extmod/ulab/code/numerical/numerical.c -msgid "axis must be -1, 0, None, or 1" +msgid "axis is out of bounds" msgstr "" #: extmod/ulab/code/numerical/numerical.c -msgid "axis must be -1, 0, or 1" +msgid "axis must be None, or an integer" msgstr "" #: extmod/ulab/code/numerical/numerical.c -msgid "axis must be None, 0, or 1" +msgid "axis too long" msgstr "" #: py/builtinevex.c @@ -2288,6 +2300,10 @@ msgid "" "can't switch from manual field specification to automatic field numbering" msgstr "" +#: extmod/ulab/code/ndarray_operators.c +msgid "cannot cast output with casting rule" +msgstr "" + #: py/objtype.c msgid "cannot create '%q' instances" msgstr "" @@ -2304,10 +2320,6 @@ msgstr "" msgid "cannot perform relative import" msgstr "" -#: extmod/ulab/code/ndarray.c -msgid "cannot reshape array (incompatible input/output shape)" -msgstr "" - #: py/emitnative.c msgid "casting" msgstr "" @@ -2380,10 +2392,6 @@ msgstr "" msgid "convolve arguments must not be empty" msgstr "" -#: extmod/ulab/code/ndarray.c -msgid "could not broadast input array from shape" -msgstr "" - #: extmod/ulab/code/poly/poly.c msgid "could not invert Vandermonde matrix" msgstr "" @@ -2392,6 +2400,10 @@ msgstr "" msgid "couldn't determine SD card version" msgstr "" +#: extmod/ulab/code/numerical/numerical.c +msgid "cross is defined for 1D arrays of length 3" +msgstr "" + #: extmod/ulab/code/approx/approx.c msgid "data must be iterable" msgstr "" @@ -2400,10 +2412,6 @@ msgstr "" msgid "data must be of equal length" msgstr "" -#: extmod/ulab/code/numerical/numerical.c -msgid "ddof must be smaller than length of data set" -msgstr "" - #: py/parsenum.c msgid "decimal numbers not supported" msgstr "" @@ -2433,6 +2441,10 @@ msgstr "" msgid "diff argument must be an ndarray" msgstr "" +#: extmod/ulab/code/numerical/numerical.c +msgid "differentiation order out of range" +msgstr "" + #: py/modmath.c py/objfloat.c py/objint_longlong.c py/objint_mpz.c py/runtime.c #: shared-bindings/math/__init__.c msgid "division by zero" @@ -2548,6 +2560,10 @@ msgstr "" msgid "first argument must be a function" msgstr "" +#: extmod/ulab/code/ulab_create.c +msgid "first argument must be a tuple of ndarrays" +msgstr "" + #: extmod/ulab/code/ndarray.c msgid "first argument must be an iterable" msgstr "" @@ -2601,8 +2617,8 @@ msgstr "" msgid "function has the same sign at the ends of interval" msgstr "" -#: extmod/ulab/code/compare/compare.c -msgid "function is implemented for scalars and ndarrays only" +#: extmod/ulab/code/ndarray.c +msgid "function is defined for ndarrays only" msgstr "" #: py/argcheck.c @@ -2672,6 +2688,7 @@ msgstr "" msgid "index is out of bounds" msgstr "" +#: extmod/ulab/code/numerical/numerical.c #: ports/esp32s2/common-hal/pulseio/PulseIn.c py/obj.c msgid "index out of range" msgstr "" @@ -2696,6 +2713,10 @@ msgstr "" msgid "inline assembler must be a function" msgstr "" +#: extmod/ulab/code/ndarray.c +msgid "input and output shapes are not compatible" +msgstr "" + #: extmod/ulab/code/ulab_create.c msgid "input argument must be an integer or a 2-tuple" msgstr "" @@ -2704,6 +2725,10 @@ msgstr "" msgid "input array length must be power of 2" msgstr "" +#: extmod/ulab/code/ulab_create.c +msgid "input arrays are not compatible" +msgstr "" + #: extmod/ulab/code/poly/poly.c msgid "input data must be an iterable" msgstr "" @@ -2716,6 +2741,22 @@ msgstr "" msgid "input matrix is singular" msgstr "" +#: extmod/ulab/code/user/user.c +msgid "input must be a dense ndarray" +msgstr "" + +#: extmod/ulab/code/ulab_create.c +msgid "input must be a tensor of rank 2" +msgstr "" + +#: extmod/ulab/code/ulab_create.c extmod/ulab/code/user/user.c +msgid "input must be an ndarray" +msgstr "" + +#: extmod/ulab/code/filter/filter.c +msgid "input must be one-dimensional" +msgstr "" + #: extmod/ulab/code/linalg/linalg.c msgid "input must be square matrix" msgstr "" @@ -2728,6 +2769,10 @@ msgstr "" msgid "input vectors must be of equal length" msgstr "" +#: extmod/ulab/code/poly/poly.c +msgid "inputs are not iterable" +msgstr "" + #: py/parsenum.c msgid "int() arg 2 must be >= 2 and <= 36" msgstr "" @@ -2896,6 +2941,10 @@ msgstr "" msgid "max_length must be > 0" msgstr "" +#: extmod/ulab/code/ndarray.c +msgid "maximum number of dimensions is 4" +msgstr "" + #: py/runtime.c msgid "maximum recursion depth exceeded" msgstr "" @@ -2945,10 +2994,6 @@ msgstr "" msgid "must use keyword argument for key function" msgstr "" -#: extmod/ulab/code/numerical/numerical.c -msgid "n must be between 0, and 9" -msgstr "" - #: py/runtime.c msgid "name '%q' is not defined" msgstr "" @@ -3031,6 +3076,10 @@ msgstr "" msgid "non-keyword arg after keyword arg" msgstr "" +#: extmod/ulab/code/linalg/linalg.c +msgid "norm is defined for 1D and 2D arrays" +msgstr "" + #: shared-bindings/_bleio/UUID.c msgid "not a 128-bit UUID" msgstr "" @@ -3043,10 +3092,6 @@ msgstr "" msgid "not enough arguments for format string" msgstr "" -#: extmod/ulab/code/poly/poly.c -msgid "number of arguments must be 2, or 3" -msgstr "" - #: extmod/ulab/code/ulab_create.c msgid "number of points must be at least 2" msgstr "" @@ -3099,6 +3144,10 @@ msgstr "" msgid "odd-length string" msgstr "" +#: extmod/ulab/code/ulab_create.c +msgid "offset is too large" +msgstr "" + #: py/objstr.c py/objstrunicode.c msgid "offset out of bounds" msgstr "" @@ -3121,6 +3170,14 @@ msgstr "" msgid "operands could not be broadcast together" msgstr "" +#: extmod/ulab/code/ndarray.c +msgid "operation is implemented for 1D Boolean arrays only" +msgstr "" + +#: extmod/ulab/code/numerical/numerical.c +msgid "operation is not implemented for flattened array" +msgstr "" + #: extmod/ulab/code/numerical/numerical.c msgid "operation is not implemented on ndarrays" msgstr "" @@ -3255,6 +3312,10 @@ msgstr "" msgid "requested length %d but object has length %d" msgstr "" +#: extmod/ulab/code/ndarray_operators.c +msgid "results cannot be cast to specified type" +msgstr "" + #: py/compile.c msgid "return annotation must be an identifier" msgstr "" @@ -3273,8 +3334,8 @@ msgstr "" msgid "rgb_pins[%d] is not on the same port as clock" msgstr "" -#: extmod/ulab/code/ndarray.c -msgid "right hand side must be an ndarray, or a scalar" +#: extmod/ulab/code/numerical/numerical.c +msgid "roll argument must be an ndarray" msgstr "" #: py/objstr.c @@ -3300,7 +3361,7 @@ msgid "script compilation not supported" msgstr "" #: extmod/ulab/code/ndarray.c -msgid "shape must be a 2-tuple" +msgid "shape must be a tuple" msgstr "" #: py/objstr.c @@ -3343,10 +3404,6 @@ msgstr "" msgid "sort argument must be an ndarray" msgstr "" -#: extmod/ulab/code/numerical/numerical.c -msgid "sorted axis can't be longer than 65535" -msgstr "" - #: extmod/ulab/code/filter/filter.c msgid "sos array must be of shape (n_section, 6)" msgstr "" @@ -3452,6 +3509,10 @@ msgstr "" msgid "timestamp out of range for platform time_t" msgstr "" +#: extmod/ulab/code/ndarray.c +msgid "tobytes can be invoked for dense arrays only" +msgstr "" + #: shared-module/struct/__init__.c msgid "too many arguments provided with the given format" msgstr "" @@ -3627,12 +3688,12 @@ msgstr "" msgid "window must be <= interval" msgstr "" -#: extmod/ulab/code/linalg/linalg.c -msgid "wrong argument type" +#: extmod/ulab/code/numerical/numerical.c +msgid "wrong axis index" msgstr "" -#: extmod/ulab/code/ndarray.c -msgid "wrong index type" +#: extmod/ulab/code/ulab_create.c +msgid "wrong axis specified" msgstr "" #: extmod/ulab/code/vector/vectorise.c diff --git a/py/py.mk b/py/py.mk index acf5d127bc..eb3ba27acb 100644 --- a/py/py.mk +++ b/py/py.mk @@ -109,7 +109,7 @@ ifeq ($(CIRCUITPY_ULAB),1) SRC_MOD += $(patsubst $(TOP)/%,%,$(wildcard $(TOP)/extmod/ulab/code/*.c)) SRC_MOD += $(patsubst $(TOP)/%,%,$(wildcard $(TOP)/extmod/ulab/code/*/*.c)) CFLAGS_MOD += -DCIRCUITPY_ULAB=1 -DMODULE_ULAB_ENABLED=1 -$(BUILD)/extmod/ulab/code/%.o: CFLAGS += -Wno-float-equal -Wno-sign-compare -DCIRCUITPY +$(BUILD)/extmod/ulab/code/%.o: CFLAGS += -Wno-missing-declarations -Wno-missing-prototypes -Wno-unused-parameter -Wno-float-equal -Wno-sign-compare -Wno-cast-align -Wno-shadow -DCIRCUITPY endif # External modules written in C. From 70e978f48b587620bb1407d9717f0a8fc3d4cf26 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Mon, 16 Nov 2020 16:57:01 -0600 Subject: [PATCH 117/207] stm: disable ulab on two resource-constrained boards --- ports/stm/boards/meowbit_v121/mpconfigboard.mk | 2 ++ ports/stm/boards/thunderpack/mpconfigboard.mk | 2 ++ 2 files changed, 4 insertions(+) diff --git a/ports/stm/boards/meowbit_v121/mpconfigboard.mk b/ports/stm/boards/meowbit_v121/mpconfigboard.mk index c416700e3c..86b0cb5ab4 100644 --- a/ports/stm/boards/meowbit_v121/mpconfigboard.mk +++ b/ports/stm/boards/meowbit_v121/mpconfigboard.mk @@ -20,3 +20,5 @@ LD_COMMON = boards/common_default.ld LD_FILE = boards/STM32F401xe_boot.ld # For debugging - also comment BOOTLOADER_OFFSET and BOARD_VTOR_DEFER # LD_FILE = boards/STM32F401xe_fs.ld + +CIRCUITPY_ULAB = 0 diff --git a/ports/stm/boards/thunderpack/mpconfigboard.mk b/ports/stm/boards/thunderpack/mpconfigboard.mk index d303582e0e..8f645068d7 100644 --- a/ports/stm/boards/thunderpack/mpconfigboard.mk +++ b/ports/stm/boards/thunderpack/mpconfigboard.mk @@ -15,3 +15,5 @@ MCU_PACKAGE = UFQFPN48 LD_COMMON = boards/common_nvm.ld LD_FILE = boards/STM32F411_nvm.ld + +CIRCUITPY_ULAB = 0 From 368fa88312c14d1a74f44b7539fb00c7ef8754f8 Mon Sep 17 00:00:00 2001 From: Scott Shawcroft Date: Mon, 23 Nov 2020 12:14:58 -0800 Subject: [PATCH 118/207] Ignore size parameter --- extmod/modujson.c | 1 + 1 file changed, 1 insertion(+) diff --git a/extmod/modujson.c b/extmod/modujson.c index 515606b70a..3bb4b33017 100644 --- a/extmod/modujson.c +++ b/extmod/modujson.c @@ -85,6 +85,7 @@ STATIC byte ujson_stream_next(ujson_stream_t *s) { #define CIRCUITPY_JSON_READ_CHUNK_SIZE 64 STATIC mp_uint_t ujson_python_readinto(mp_obj_t obj, void *buf, mp_uint_t size, int *errcode) { + (void) size; // Ignore size because we know it's always 1. ujson_stream_t* s = obj; if (s->start == s->end) { From efda9124374dcbffb4f8a58d227e439d34ca7760 Mon Sep 17 00:00:00 2001 From: Kattni Rembor Date: Mon, 23 Nov 2020 15:53:28 -0500 Subject: [PATCH 119/207] Add pin names from silk --- ports/esp32s2/boards/adafruit_magtag_2.9_grayscale/pins.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/ports/esp32s2/boards/adafruit_magtag_2.9_grayscale/pins.c b/ports/esp32s2/boards/adafruit_magtag_2.9_grayscale/pins.c index 40c9e91e4d..f1ce4b8c61 100644 --- a/ports/esp32s2/boards/adafruit_magtag_2.9_grayscale/pins.c +++ b/ports/esp32s2/boards/adafruit_magtag_2.9_grayscale/pins.c @@ -16,11 +16,16 @@ STATIC const mp_rom_map_elem_t board_global_dict_table[] = { { MP_ROM_QSTR(MP_QSTR_EPD_CS), MP_ROM_PTR(&pin_GPIO8) }, { MP_ROM_QSTR(MP_QSTR_BUTTON_A), MP_ROM_PTR(&pin_GPIO15) }, + { MP_ROM_QSTR(MP_QSTR_D15), MP_ROM_PTR(&pin_GPIO15) }, { MP_ROM_QSTR(MP_QSTR_BUTTON_B), MP_ROM_PTR(&pin_GPIO14) }, + { MP_ROM_QSTR(MP_QSTR_D14), MP_ROM_PTR(&pin_GPIO14) }, { MP_ROM_QSTR(MP_QSTR_BUTTON_C), MP_ROM_PTR(&pin_GPIO12) }, + { MP_ROM_QSTR(MP_QSTR_D12), MP_ROM_PTR(&pin_GPIO12) }, { MP_ROM_QSTR(MP_QSTR_BUTTON_D), MP_ROM_PTR(&pin_GPIO11) }, + { MP_ROM_QSTR(MP_QSTR_D11), MP_ROM_PTR(&pin_GPIO11) }, { MP_ROM_QSTR(MP_QSTR_LIGHT), MP_ROM_PTR(&pin_GPIO3) }, + { MP_ROM_QSTR(MP_QSTR_A3), MP_ROM_PTR(&pin_GPIO3) }, { MP_ROM_QSTR(MP_QSTR_VOLTAGE_MONITOR), MP_ROM_PTR(&pin_GPIO4) }, { MP_ROM_QSTR(MP_QSTR_BATTERY), MP_ROM_PTR(&pin_GPIO4) }, @@ -36,6 +41,7 @@ STATIC const mp_rom_map_elem_t board_global_dict_table[] = { { MP_ROM_QSTR(MP_QSTR_NEOPIXEL_POWER), MP_ROM_PTR(&pin_GPIO21) }, { MP_ROM_QSTR(MP_QSTR_NEOPIXEL), MP_ROM_PTR(&pin_GPIO1) }, + { MP_ROM_QSTR(MP_QSTR_D4), MP_ROM_PTR(&pin_GPIO1) }, { 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 3730862362e914cc92b6977cb5d809856467f8f9 Mon Sep 17 00:00:00 2001 From: Kattni Rembor Date: Mon, 23 Nov 2020 15:56:36 -0500 Subject: [PATCH 120/207] Update to match silk rev 1 --- ports/esp32s2/boards/adafruit_magtag_2.9_grayscale/pins.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ports/esp32s2/boards/adafruit_magtag_2.9_grayscale/pins.c b/ports/esp32s2/boards/adafruit_magtag_2.9_grayscale/pins.c index f1ce4b8c61..6c2dc1151a 100644 --- a/ports/esp32s2/boards/adafruit_magtag_2.9_grayscale/pins.c +++ b/ports/esp32s2/boards/adafruit_magtag_2.9_grayscale/pins.c @@ -41,7 +41,7 @@ STATIC const mp_rom_map_elem_t board_global_dict_table[] = { { MP_ROM_QSTR(MP_QSTR_NEOPIXEL_POWER), MP_ROM_PTR(&pin_GPIO21) }, { MP_ROM_QSTR(MP_QSTR_NEOPIXEL), MP_ROM_PTR(&pin_GPIO1) }, - { MP_ROM_QSTR(MP_QSTR_D4), MP_ROM_PTR(&pin_GPIO1) }, + { MP_ROM_QSTR(MP_QSTR_D1), MP_ROM_PTR(&pin_GPIO1) }, { 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 7928a0d45419181d3f29c809aa0c3c87e58359e3 Mon Sep 17 00:00:00 2001 From: Kattni Rembor Date: Mon, 23 Nov 2020 16:02:45 -0500 Subject: [PATCH 121/207] Blank lines to group aliases. --- ports/esp32s2/boards/adafruit_magtag_2.9_grayscale/pins.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/ports/esp32s2/boards/adafruit_magtag_2.9_grayscale/pins.c b/ports/esp32s2/boards/adafruit_magtag_2.9_grayscale/pins.c index 6c2dc1151a..0cefb6dfbc 100644 --- a/ports/esp32s2/boards/adafruit_magtag_2.9_grayscale/pins.c +++ b/ports/esp32s2/boards/adafruit_magtag_2.9_grayscale/pins.c @@ -17,10 +17,13 @@ STATIC const mp_rom_map_elem_t board_global_dict_table[] = { { MP_ROM_QSTR(MP_QSTR_BUTTON_A), MP_ROM_PTR(&pin_GPIO15) }, { MP_ROM_QSTR(MP_QSTR_D15), MP_ROM_PTR(&pin_GPIO15) }, + { MP_ROM_QSTR(MP_QSTR_BUTTON_B), MP_ROM_PTR(&pin_GPIO14) }, { MP_ROM_QSTR(MP_QSTR_D14), MP_ROM_PTR(&pin_GPIO14) }, + { MP_ROM_QSTR(MP_QSTR_BUTTON_C), MP_ROM_PTR(&pin_GPIO12) }, { MP_ROM_QSTR(MP_QSTR_D12), MP_ROM_PTR(&pin_GPIO12) }, + { MP_ROM_QSTR(MP_QSTR_BUTTON_D), MP_ROM_PTR(&pin_GPIO11) }, { MP_ROM_QSTR(MP_QSTR_D11), MP_ROM_PTR(&pin_GPIO11) }, From bb064d719898568183ee9ee2b3c27c3ce5f211ff Mon Sep 17 00:00:00 2001 From: Hosted Weblate Date: Tue, 24 Nov 2020 00:17:56 +0100 Subject: [PATCH 122/207] Update translation files Updated by "Update PO files to match POT (msgmerge)" hook in Weblate. Translation: CircuitPython/main Translate-URL: https://hosted.weblate.org/projects/circuitpython/main/ --- locale/ID.po | 147 +++++++++++++++++++-------- locale/cs.po | 147 +++++++++++++++++++-------- locale/de_DE.po | 207 ++++++++++++++++++++++++++++---------- locale/el.po | 147 +++++++++++++++++++-------- locale/es.po | 206 ++++++++++++++++++++++++++++---------- locale/fil.po | 147 +++++++++++++++++++-------- locale/fr.po | 211 +++++++++++++++++++++++++++++---------- locale/hi.po | 147 +++++++++++++++++++-------- locale/it_IT.po | 147 +++++++++++++++++++-------- locale/ja.po | 196 ++++++++++++++++++++++++++---------- locale/ko.po | 147 +++++++++++++++++++-------- locale/nl.po | 205 +++++++++++++++++++++++++++---------- locale/pl.po | 160 ++++++++++++++++++++--------- locale/pt_BR.po | 210 ++++++++++++++++++++++++++++---------- locale/sv.po | 208 ++++++++++++++++++++++++++++---------- locale/zh_Latn_pinyin.po | 208 ++++++++++++++++++++++++++++---------- 16 files changed, 2083 insertions(+), 757 deletions(-) diff --git a/locale/ID.po b/locale/ID.po index d6672b1e40..782e846e99 100644 --- a/locale/ID.po +++ b/locale/ID.po @@ -5,7 +5,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-11-10 15:30+0530\n" +"POT-Creation-Date: 2020-11-23 10:10-0600\n" "PO-Revision-Date: 2020-10-10 23:51+0000\n" "Last-Translator: oon arfiandwi \n" "Language-Team: LANGUAGE \n" @@ -873,6 +873,10 @@ msgstr "Penyebaran yang diperluas dengan respon pindai tidak didukung." msgid "FFT is defined for ndarrays only" msgstr "FFT didefinisikan hanya untuk ndarrays" +#: extmod/ulab/code/fft/fft.c +msgid "FFT is implemented for linear arrays only" +msgstr "" + #: ports/esp32s2/common-hal/socketpool/Socket.c msgid "Failed SSL handshake" msgstr "" @@ -1991,7 +1995,7 @@ msgstr "" msgid "WARNING: Your code filename has two extensions\n" msgstr "PERINGATAN: Nama file kode anda mempunyai dua ekstensi\n" -#: shared-bindings/watchdog/WatchDogTimer.c +#: ports/nrf/common-hal/watchdog/WatchDogTimer.c msgid "WatchDogTimer cannot be deinitialized once mode is set to RESET" msgstr "" @@ -2076,10 +2080,6 @@ msgstr "" msgid "addresses is empty" msgstr "" -#: extmod/ulab/code/vector/vectorise.c -msgid "arctan2 is implemented for scalars and ndarrays only" -msgstr "" - #: py/modbuiltins.c msgid "arg is an empty sequence" msgstr "" @@ -2088,6 +2088,10 @@ msgstr "" msgid "argsort argument must be an ndarray" msgstr "" +#: extmod/ulab/code/numerical/numerical.c +msgid "argsort is not implemented for flattened arrays" +msgstr "" + #: py/runtime.c msgid "argument has wrong type" msgstr "" @@ -2105,14 +2109,22 @@ msgstr "argumen num/types tidak cocok" msgid "argument should be a '%q' not a '%q'" msgstr "" -#: extmod/ulab/code/linalg/linalg.c +#: extmod/ulab/code/linalg/linalg.c extmod/ulab/code/numerical/numerical.c msgid "arguments must be ndarrays" msgstr "" +#: extmod/ulab/code/ndarray.c +msgid "array and index length must be equal" +msgstr "" + #: py/objarray.c shared-bindings/nvm/ByteArray.c msgid "array/bytes required on right side" msgstr "" +#: extmod/ulab/code/numerical/numerical.c +msgid "attempt to get (arg)min/(arg)max of empty sequence" +msgstr "" + #: extmod/ulab/code/numerical/numerical.c msgid "attempt to get argmin/argmax of an empty sequence" msgstr "" @@ -2122,15 +2134,15 @@ msgid "attributes not supported yet" msgstr "" #: extmod/ulab/code/numerical/numerical.c -msgid "axis must be -1, 0, None, or 1" +msgid "axis is out of bounds" msgstr "" #: extmod/ulab/code/numerical/numerical.c -msgid "axis must be -1, 0, or 1" +msgid "axis must be None, or an integer" msgstr "" #: extmod/ulab/code/numerical/numerical.c -msgid "axis must be None, 0, or 1" +msgid "axis too long" msgstr "" #: py/builtinevex.c @@ -2335,6 +2347,10 @@ msgid "" "can't switch from manual field specification to automatic field numbering" msgstr "" +#: extmod/ulab/code/ndarray_operators.c +msgid "cannot cast output with casting rule" +msgstr "" + #: py/objtype.c msgid "cannot create '%q' instances" msgstr "" @@ -2351,10 +2367,6 @@ msgstr "" msgid "cannot perform relative import" msgstr "tidak dapat melakukan relative import" -#: extmod/ulab/code/ndarray.c -msgid "cannot reshape array (incompatible input/output shape)" -msgstr "" - #: py/emitnative.c msgid "casting" msgstr "" @@ -2427,10 +2439,6 @@ msgstr "" msgid "convolve arguments must not be empty" msgstr "" -#: extmod/ulab/code/ndarray.c -msgid "could not broadast input array from shape" -msgstr "" - #: extmod/ulab/code/poly/poly.c msgid "could not invert Vandermonde matrix" msgstr "" @@ -2439,6 +2447,10 @@ msgstr "" msgid "couldn't determine SD card version" msgstr "" +#: extmod/ulab/code/numerical/numerical.c +msgid "cross is defined for 1D arrays of length 3" +msgstr "" + #: extmod/ulab/code/approx/approx.c msgid "data must be iterable" msgstr "" @@ -2447,10 +2459,6 @@ msgstr "" msgid "data must be of equal length" msgstr "" -#: extmod/ulab/code/numerical/numerical.c -msgid "ddof must be smaller than length of data set" -msgstr "" - #: py/parsenum.c msgid "decimal numbers not supported" msgstr "" @@ -2480,6 +2488,10 @@ msgstr "" msgid "diff argument must be an ndarray" msgstr "" +#: extmod/ulab/code/numerical/numerical.c +msgid "differentiation order out of range" +msgstr "" + #: py/modmath.c py/objfloat.c py/objint_longlong.c py/objint_mpz.c py/runtime.c #: shared-bindings/math/__init__.c msgid "division by zero" @@ -2595,6 +2607,10 @@ msgstr "" msgid "first argument must be a function" msgstr "" +#: extmod/ulab/code/ulab_create.c +msgid "first argument must be a tuple of ndarrays" +msgstr "" + #: extmod/ulab/code/ndarray.c msgid "first argument must be an iterable" msgstr "" @@ -2648,8 +2664,8 @@ msgstr "fungsi mendapatkan nilai ganda untuk argumen '%q'" msgid "function has the same sign at the ends of interval" msgstr "" -#: extmod/ulab/code/compare/compare.c -msgid "function is implemented for scalars and ndarrays only" +#: extmod/ulab/code/ndarray.c +msgid "function is defined for ndarrays only" msgstr "" #: py/argcheck.c @@ -2719,6 +2735,7 @@ msgstr "lapisan (padding) tidak benar" msgid "index is out of bounds" msgstr "" +#: extmod/ulab/code/numerical/numerical.c #: ports/esp32s2/common-hal/pulseio/PulseIn.c py/obj.c msgid "index out of range" msgstr "index keluar dari jangkauan" @@ -2743,6 +2760,10 @@ msgstr "" msgid "inline assembler must be a function" msgstr "inline assembler harus sebuah fungsi" +#: extmod/ulab/code/ndarray.c +msgid "input and output shapes are not compatible" +msgstr "" + #: extmod/ulab/code/ulab_create.c msgid "input argument must be an integer or a 2-tuple" msgstr "" @@ -2751,6 +2772,10 @@ msgstr "" msgid "input array length must be power of 2" msgstr "" +#: extmod/ulab/code/ulab_create.c +msgid "input arrays are not compatible" +msgstr "" + #: extmod/ulab/code/poly/poly.c msgid "input data must be an iterable" msgstr "" @@ -2763,6 +2788,22 @@ msgstr "" msgid "input matrix is singular" msgstr "" +#: extmod/ulab/code/user/user.c +msgid "input must be a dense ndarray" +msgstr "" + +#: extmod/ulab/code/ulab_create.c +msgid "input must be a tensor of rank 2" +msgstr "" + +#: extmod/ulab/code/ulab_create.c extmod/ulab/code/user/user.c +msgid "input must be an ndarray" +msgstr "" + +#: extmod/ulab/code/filter/filter.c +msgid "input must be one-dimensional" +msgstr "" + #: extmod/ulab/code/linalg/linalg.c msgid "input must be square matrix" msgstr "" @@ -2775,6 +2816,10 @@ msgstr "" msgid "input vectors must be of equal length" msgstr "" +#: extmod/ulab/code/poly/poly.c +msgid "inputs are not iterable" +msgstr "" + #: py/parsenum.c msgid "int() arg 2 must be >= 2 and <= 36" msgstr "" @@ -2943,6 +2988,10 @@ msgstr "" msgid "max_length must be > 0" msgstr "" +#: extmod/ulab/code/ndarray.c +msgid "maximum number of dimensions is 4" +msgstr "" + #: py/runtime.c msgid "maximum recursion depth exceeded" msgstr "" @@ -2992,10 +3041,6 @@ msgstr "" msgid "must use keyword argument for key function" msgstr "" -#: extmod/ulab/code/numerical/numerical.c -msgid "n must be between 0, and 9" -msgstr "" - #: py/runtime.c msgid "name '%q' is not defined" msgstr "" @@ -3078,6 +3123,10 @@ msgstr "non-keyword arg setelah */**" msgid "non-keyword arg after keyword arg" msgstr "non-keyword arg setelah keyword arg" +#: extmod/ulab/code/linalg/linalg.c +msgid "norm is defined for 1D and 2D arrays" +msgstr "" + #: shared-bindings/_bleio/UUID.c msgid "not a 128-bit UUID" msgstr "" @@ -3090,10 +3139,6 @@ msgstr "" msgid "not enough arguments for format string" msgstr "" -#: extmod/ulab/code/poly/poly.c -msgid "number of arguments must be 2, or 3" -msgstr "" - #: extmod/ulab/code/ulab_create.c msgid "number of points must be at least 2" msgstr "" @@ -3146,6 +3191,10 @@ msgstr "" msgid "odd-length string" msgstr "panjang data string memiliki keganjilan (odd-length)" +#: extmod/ulab/code/ulab_create.c +msgid "offset is too large" +msgstr "" + #: py/objstr.c py/objstrunicode.c #, fuzzy msgid "offset out of bounds" @@ -3169,6 +3218,14 @@ msgstr "" msgid "operands could not be broadcast together" msgstr "" +#: extmod/ulab/code/ndarray.c +msgid "operation is implemented for 1D Boolean arrays only" +msgstr "" + +#: extmod/ulab/code/numerical/numerical.c +msgid "operation is not implemented for flattened array" +msgstr "" + #: extmod/ulab/code/numerical/numerical.c msgid "operation is not implemented on ndarrays" msgstr "" @@ -3303,6 +3360,10 @@ msgstr "relative import" msgid "requested length %d but object has length %d" msgstr "" +#: extmod/ulab/code/ndarray_operators.c +msgid "results cannot be cast to specified type" +msgstr "" + #: py/compile.c msgid "return annotation must be an identifier" msgstr "anotasi return harus sebuah identifier" @@ -3321,8 +3382,8 @@ msgstr "" msgid "rgb_pins[%d] is not on the same port as clock" msgstr "" -#: extmod/ulab/code/ndarray.c -msgid "right hand side must be an ndarray, or a scalar" +#: extmod/ulab/code/numerical/numerical.c +msgid "roll argument must be an ndarray" msgstr "" #: py/objstr.c @@ -3348,7 +3409,7 @@ msgid "script compilation not supported" msgstr "kompilasi script tidak didukung" #: extmod/ulab/code/ndarray.c -msgid "shape must be a 2-tuple" +msgid "shape must be a tuple" msgstr "" #: py/objstr.c @@ -3391,10 +3452,6 @@ msgstr "memulai ulang software(soft reboot)\n" msgid "sort argument must be an ndarray" msgstr "" -#: extmod/ulab/code/numerical/numerical.c -msgid "sorted axis can't be longer than 65535" -msgstr "" - #: extmod/ulab/code/filter/filter.c msgid "sos array must be of shape (n_section, 6)" msgstr "" @@ -3501,6 +3558,10 @@ msgstr "" msgid "timestamp out of range for platform time_t" msgstr "" +#: extmod/ulab/code/ndarray.c +msgid "tobytes can be invoked for dense arrays only" +msgstr "" + #: shared-module/struct/__init__.c msgid "too many arguments provided with the given format" msgstr "" @@ -3676,12 +3737,12 @@ msgstr "" msgid "window must be <= interval" msgstr "" -#: extmod/ulab/code/linalg/linalg.c -msgid "wrong argument type" +#: extmod/ulab/code/numerical/numerical.c +msgid "wrong axis index" msgstr "" -#: extmod/ulab/code/ndarray.c -msgid "wrong index type" +#: extmod/ulab/code/ulab_create.c +msgid "wrong axis specified" msgstr "" #: extmod/ulab/code/vector/vectorise.c diff --git a/locale/cs.po b/locale/cs.po index bde3a20b87..6eb69fb672 100644 --- a/locale/cs.po +++ b/locale/cs.po @@ -5,7 +5,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-11-10 15:30+0530\n" +"POT-Creation-Date: 2020-11-23 10:10-0600\n" "PO-Revision-Date: 2020-05-24 03:22+0000\n" "Last-Translator: dronecz \n" "Language-Team: LANGUAGE \n" @@ -859,6 +859,10 @@ msgstr "" msgid "FFT is defined for ndarrays only" msgstr "" +#: extmod/ulab/code/fft/fft.c +msgid "FFT is implemented for linear arrays only" +msgstr "" + #: ports/esp32s2/common-hal/socketpool/Socket.c msgid "Failed SSL handshake" msgstr "" @@ -1955,7 +1959,7 @@ msgstr "" msgid "WARNING: Your code filename has two extensions\n" msgstr "" -#: shared-bindings/watchdog/WatchDogTimer.c +#: ports/nrf/common-hal/watchdog/WatchDogTimer.c msgid "WatchDogTimer cannot be deinitialized once mode is set to RESET" msgstr "" @@ -2034,10 +2038,6 @@ msgstr "" msgid "addresses is empty" msgstr "" -#: extmod/ulab/code/vector/vectorise.c -msgid "arctan2 is implemented for scalars and ndarrays only" -msgstr "" - #: py/modbuiltins.c msgid "arg is an empty sequence" msgstr "" @@ -2046,6 +2046,10 @@ msgstr "" msgid "argsort argument must be an ndarray" msgstr "" +#: extmod/ulab/code/numerical/numerical.c +msgid "argsort is not implemented for flattened arrays" +msgstr "" + #: py/runtime.c msgid "argument has wrong type" msgstr "" @@ -2063,14 +2067,22 @@ msgstr "" msgid "argument should be a '%q' not a '%q'" msgstr "" -#: extmod/ulab/code/linalg/linalg.c +#: extmod/ulab/code/linalg/linalg.c extmod/ulab/code/numerical/numerical.c msgid "arguments must be ndarrays" msgstr "" +#: extmod/ulab/code/ndarray.c +msgid "array and index length must be equal" +msgstr "" + #: py/objarray.c shared-bindings/nvm/ByteArray.c msgid "array/bytes required on right side" msgstr "" +#: extmod/ulab/code/numerical/numerical.c +msgid "attempt to get (arg)min/(arg)max of empty sequence" +msgstr "" + #: extmod/ulab/code/numerical/numerical.c msgid "attempt to get argmin/argmax of an empty sequence" msgstr "" @@ -2080,15 +2092,15 @@ msgid "attributes not supported yet" msgstr "" #: extmod/ulab/code/numerical/numerical.c -msgid "axis must be -1, 0, None, or 1" +msgid "axis is out of bounds" msgstr "" #: extmod/ulab/code/numerical/numerical.c -msgid "axis must be -1, 0, or 1" +msgid "axis must be None, or an integer" msgstr "" #: extmod/ulab/code/numerical/numerical.c -msgid "axis must be None, 0, or 1" +msgid "axis too long" msgstr "" #: py/builtinevex.c @@ -2292,6 +2304,10 @@ msgid "" "can't switch from manual field specification to automatic field numbering" msgstr "" +#: extmod/ulab/code/ndarray_operators.c +msgid "cannot cast output with casting rule" +msgstr "" + #: py/objtype.c msgid "cannot create '%q' instances" msgstr "" @@ -2308,10 +2324,6 @@ msgstr "" msgid "cannot perform relative import" msgstr "" -#: extmod/ulab/code/ndarray.c -msgid "cannot reshape array (incompatible input/output shape)" -msgstr "" - #: py/emitnative.c msgid "casting" msgstr "" @@ -2384,10 +2396,6 @@ msgstr "" msgid "convolve arguments must not be empty" msgstr "" -#: extmod/ulab/code/ndarray.c -msgid "could not broadast input array from shape" -msgstr "" - #: extmod/ulab/code/poly/poly.c msgid "could not invert Vandermonde matrix" msgstr "" @@ -2396,6 +2404,10 @@ msgstr "" msgid "couldn't determine SD card version" msgstr "" +#: extmod/ulab/code/numerical/numerical.c +msgid "cross is defined for 1D arrays of length 3" +msgstr "" + #: extmod/ulab/code/approx/approx.c msgid "data must be iterable" msgstr "" @@ -2404,10 +2416,6 @@ msgstr "" msgid "data must be of equal length" msgstr "" -#: extmod/ulab/code/numerical/numerical.c -msgid "ddof must be smaller than length of data set" -msgstr "" - #: py/parsenum.c msgid "decimal numbers not supported" msgstr "" @@ -2437,6 +2445,10 @@ msgstr "" msgid "diff argument must be an ndarray" msgstr "" +#: extmod/ulab/code/numerical/numerical.c +msgid "differentiation order out of range" +msgstr "" + #: py/modmath.c py/objfloat.c py/objint_longlong.c py/objint_mpz.c py/runtime.c #: shared-bindings/math/__init__.c msgid "division by zero" @@ -2552,6 +2564,10 @@ msgstr "" msgid "first argument must be a function" msgstr "" +#: extmod/ulab/code/ulab_create.c +msgid "first argument must be a tuple of ndarrays" +msgstr "" + #: extmod/ulab/code/ndarray.c msgid "first argument must be an iterable" msgstr "" @@ -2605,8 +2621,8 @@ msgstr "" msgid "function has the same sign at the ends of interval" msgstr "" -#: extmod/ulab/code/compare/compare.c -msgid "function is implemented for scalars and ndarrays only" +#: extmod/ulab/code/ndarray.c +msgid "function is defined for ndarrays only" msgstr "" #: py/argcheck.c @@ -2676,6 +2692,7 @@ msgstr "" msgid "index is out of bounds" msgstr "" +#: extmod/ulab/code/numerical/numerical.c #: ports/esp32s2/common-hal/pulseio/PulseIn.c py/obj.c msgid "index out of range" msgstr "" @@ -2700,6 +2717,10 @@ msgstr "" msgid "inline assembler must be a function" msgstr "" +#: extmod/ulab/code/ndarray.c +msgid "input and output shapes are not compatible" +msgstr "" + #: extmod/ulab/code/ulab_create.c msgid "input argument must be an integer or a 2-tuple" msgstr "" @@ -2708,6 +2729,10 @@ msgstr "" msgid "input array length must be power of 2" msgstr "" +#: extmod/ulab/code/ulab_create.c +msgid "input arrays are not compatible" +msgstr "" + #: extmod/ulab/code/poly/poly.c msgid "input data must be an iterable" msgstr "" @@ -2720,6 +2745,22 @@ msgstr "" msgid "input matrix is singular" msgstr "" +#: extmod/ulab/code/user/user.c +msgid "input must be a dense ndarray" +msgstr "" + +#: extmod/ulab/code/ulab_create.c +msgid "input must be a tensor of rank 2" +msgstr "" + +#: extmod/ulab/code/ulab_create.c extmod/ulab/code/user/user.c +msgid "input must be an ndarray" +msgstr "" + +#: extmod/ulab/code/filter/filter.c +msgid "input must be one-dimensional" +msgstr "" + #: extmod/ulab/code/linalg/linalg.c msgid "input must be square matrix" msgstr "" @@ -2732,6 +2773,10 @@ msgstr "" msgid "input vectors must be of equal length" msgstr "" +#: extmod/ulab/code/poly/poly.c +msgid "inputs are not iterable" +msgstr "" + #: py/parsenum.c msgid "int() arg 2 must be >= 2 and <= 36" msgstr "" @@ -2900,6 +2945,10 @@ msgstr "" msgid "max_length must be > 0" msgstr "" +#: extmod/ulab/code/ndarray.c +msgid "maximum number of dimensions is 4" +msgstr "" + #: py/runtime.c msgid "maximum recursion depth exceeded" msgstr "" @@ -2949,10 +2998,6 @@ msgstr "" msgid "must use keyword argument for key function" msgstr "" -#: extmod/ulab/code/numerical/numerical.c -msgid "n must be between 0, and 9" -msgstr "" - #: py/runtime.c msgid "name '%q' is not defined" msgstr "" @@ -3035,6 +3080,10 @@ msgstr "" msgid "non-keyword arg after keyword arg" msgstr "" +#: extmod/ulab/code/linalg/linalg.c +msgid "norm is defined for 1D and 2D arrays" +msgstr "" + #: shared-bindings/_bleio/UUID.c msgid "not a 128-bit UUID" msgstr "" @@ -3047,10 +3096,6 @@ msgstr "" msgid "not enough arguments for format string" msgstr "" -#: extmod/ulab/code/poly/poly.c -msgid "number of arguments must be 2, or 3" -msgstr "" - #: extmod/ulab/code/ulab_create.c msgid "number of points must be at least 2" msgstr "" @@ -3103,6 +3148,10 @@ msgstr "" msgid "odd-length string" msgstr "" +#: extmod/ulab/code/ulab_create.c +msgid "offset is too large" +msgstr "" + #: py/objstr.c py/objstrunicode.c msgid "offset out of bounds" msgstr "" @@ -3125,6 +3174,14 @@ msgstr "" msgid "operands could not be broadcast together" msgstr "" +#: extmod/ulab/code/ndarray.c +msgid "operation is implemented for 1D Boolean arrays only" +msgstr "" + +#: extmod/ulab/code/numerical/numerical.c +msgid "operation is not implemented for flattened array" +msgstr "" + #: extmod/ulab/code/numerical/numerical.c msgid "operation is not implemented on ndarrays" msgstr "" @@ -3259,6 +3316,10 @@ msgstr "" msgid "requested length %d but object has length %d" msgstr "" +#: extmod/ulab/code/ndarray_operators.c +msgid "results cannot be cast to specified type" +msgstr "" + #: py/compile.c msgid "return annotation must be an identifier" msgstr "" @@ -3277,8 +3338,8 @@ msgstr "" msgid "rgb_pins[%d] is not on the same port as clock" msgstr "" -#: extmod/ulab/code/ndarray.c -msgid "right hand side must be an ndarray, or a scalar" +#: extmod/ulab/code/numerical/numerical.c +msgid "roll argument must be an ndarray" msgstr "" #: py/objstr.c @@ -3304,7 +3365,7 @@ msgid "script compilation not supported" msgstr "" #: extmod/ulab/code/ndarray.c -msgid "shape must be a 2-tuple" +msgid "shape must be a tuple" msgstr "" #: py/objstr.c @@ -3347,10 +3408,6 @@ msgstr "" msgid "sort argument must be an ndarray" msgstr "" -#: extmod/ulab/code/numerical/numerical.c -msgid "sorted axis can't be longer than 65535" -msgstr "" - #: extmod/ulab/code/filter/filter.c msgid "sos array must be of shape (n_section, 6)" msgstr "" @@ -3456,6 +3513,10 @@ msgstr "" msgid "timestamp out of range for platform time_t" msgstr "" +#: extmod/ulab/code/ndarray.c +msgid "tobytes can be invoked for dense arrays only" +msgstr "" + #: shared-module/struct/__init__.c msgid "too many arguments provided with the given format" msgstr "" @@ -3631,12 +3692,12 @@ msgstr "" msgid "window must be <= interval" msgstr "" -#: extmod/ulab/code/linalg/linalg.c -msgid "wrong argument type" +#: extmod/ulab/code/numerical/numerical.c +msgid "wrong axis index" msgstr "" -#: extmod/ulab/code/ndarray.c -msgid "wrong index type" +#: extmod/ulab/code/ulab_create.c +msgid "wrong axis specified" msgstr "" #: extmod/ulab/code/vector/vectorise.c diff --git a/locale/de_DE.po b/locale/de_DE.po index dabc486595..f103339109 100644 --- a/locale/de_DE.po +++ b/locale/de_DE.po @@ -5,7 +5,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-11-10 15:30+0530\n" +"POT-Creation-Date: 2020-11-23 10:10-0600\n" "PO-Revision-Date: 2020-06-16 18:24+0000\n" "Last-Translator: Andreas Buchen \n" "Language: de_DE\n" @@ -870,6 +870,10 @@ msgstr "" msgid "FFT is defined for ndarrays only" msgstr "FFT ist nur für ndarrays definiert" +#: extmod/ulab/code/fft/fft.c +msgid "FFT is implemented for linear arrays only" +msgstr "" + #: ports/esp32s2/common-hal/socketpool/Socket.c msgid "Failed SSL handshake" msgstr "SSL Handshake fehlgeschlagen" @@ -2004,7 +2008,7 @@ msgid "WARNING: Your code filename has two extensions\n" msgstr "" "WARNUNG: Der Dateiname deines Programms hat zwei Dateityperweiterungen\n" -#: shared-bindings/watchdog/WatchDogTimer.c +#: ports/nrf/common-hal/watchdog/WatchDogTimer.c msgid "WatchDogTimer cannot be deinitialized once mode is set to RESET" msgstr "" @@ -2093,10 +2097,6 @@ msgstr "Adresse außerhalb der Grenzen" msgid "addresses is empty" msgstr "adresses ist leer" -#: extmod/ulab/code/vector/vectorise.c -msgid "arctan2 is implemented for scalars and ndarrays only" -msgstr "arctan2 ist nur für Skalare und ndarrays implementiert" - #: py/modbuiltins.c msgid "arg is an empty sequence" msgstr "arg ist eine leere Sequenz" @@ -2105,6 +2105,10 @@ msgstr "arg ist eine leere Sequenz" msgid "argsort argument must be an ndarray" msgstr "Das Argument argsort muss ein ndarray sein" +#: extmod/ulab/code/numerical/numerical.c +msgid "argsort is not implemented for flattened arrays" +msgstr "" + #: py/runtime.c msgid "argument has wrong type" msgstr "Argument hat falschen Typ" @@ -2122,14 +2126,22 @@ msgstr "Anzahl/Typen der Argumente passen nicht" msgid "argument should be a '%q' not a '%q'" msgstr "Argument sollte '%q' sein, nicht '%q'" -#: extmod/ulab/code/linalg/linalg.c +#: extmod/ulab/code/linalg/linalg.c extmod/ulab/code/numerical/numerical.c msgid "arguments must be ndarrays" msgstr "Argumente müssen ndarrays sein" +#: extmod/ulab/code/ndarray.c +msgid "array and index length must be equal" +msgstr "" + #: py/objarray.c shared-bindings/nvm/ByteArray.c msgid "array/bytes required on right side" msgstr "Array/Bytes auf der rechten Seite erforderlich" +#: extmod/ulab/code/numerical/numerical.c +msgid "attempt to get (arg)min/(arg)max of empty sequence" +msgstr "" + #: extmod/ulab/code/numerical/numerical.c msgid "attempt to get argmin/argmax of an empty sequence" msgstr "Sie haben versucht argmin/argmax von einer leeren Sequenz zu bekommen" @@ -2139,16 +2151,16 @@ msgid "attributes not supported yet" msgstr "Attribute werden noch nicht unterstützt" #: extmod/ulab/code/numerical/numerical.c -msgid "axis must be -1, 0, None, or 1" -msgstr "Die Achse muss -1, 0, Keine oder 1 sein" +msgid "axis is out of bounds" +msgstr "" #: extmod/ulab/code/numerical/numerical.c -msgid "axis must be -1, 0, or 1" -msgstr "Die Achse muss -1, 0 oder 1 sein" +msgid "axis must be None, or an integer" +msgstr "" #: extmod/ulab/code/numerical/numerical.c -msgid "axis must be None, 0, or 1" -msgstr "Die Achse muss None, 0 oder 1 sein" +msgid "axis too long" +msgstr "" #: py/builtinevex.c msgid "bad compile mode" @@ -2359,6 +2371,10 @@ msgstr "" "kann nicht von der manuellen Feldspezifikation zur automatischen " "Feldnummerierung wechseln" +#: extmod/ulab/code/ndarray_operators.c +msgid "cannot cast output with casting rule" +msgstr "" + #: py/objtype.c msgid "cannot create '%q' instances" msgstr "Kann '%q' Instanzen nicht erstellen" @@ -2375,11 +2391,6 @@ msgstr "Name %q kann nicht importiert werden" msgid "cannot perform relative import" msgstr "kann keinen relativen Import durchführen" -#: extmod/ulab/code/ndarray.c -msgid "cannot reshape array (incompatible input/output shape)" -msgstr "" -"Array kann nicht umgeformt werden (inkompatible Eingabe- / Ausgabeform)" - #: py/emitnative.c msgid "casting" msgstr "Umwandlung (cast)" @@ -2454,10 +2465,6 @@ msgstr "Convolve-Argumente müssen ndarrays sein" msgid "convolve arguments must not be empty" msgstr "Convolve Argumente dürfen nicht leer sein" -#: extmod/ulab/code/ndarray.c -msgid "could not broadast input array from shape" -msgstr "Eingabearray konnte nicht aus der Form übertragen werden" - #: extmod/ulab/code/poly/poly.c msgid "could not invert Vandermonde matrix" msgstr "Vandermonde-Matrix konnte nicht invertiert werden" @@ -2466,6 +2473,10 @@ msgstr "Vandermonde-Matrix konnte nicht invertiert werden" msgid "couldn't determine SD card version" msgstr "" +#: extmod/ulab/code/numerical/numerical.c +msgid "cross is defined for 1D arrays of length 3" +msgstr "" + #: extmod/ulab/code/approx/approx.c msgid "data must be iterable" msgstr "" @@ -2474,10 +2485,6 @@ msgstr "" msgid "data must be of equal length" msgstr "" -#: extmod/ulab/code/numerical/numerical.c -msgid "ddof must be smaller than length of data set" -msgstr "ddof muss kleiner als die Länge des Datensatzes sein" - #: py/parsenum.c msgid "decimal numbers not supported" msgstr "Dezimalzahlen nicht unterstützt" @@ -2509,6 +2516,10 @@ msgstr "Die Wörterbuch-Aktualisierungssequenz hat eine falsche Länge" msgid "diff argument must be an ndarray" msgstr "diff Argument muss ein ndarray sein" +#: extmod/ulab/code/numerical/numerical.c +msgid "differentiation order out of range" +msgstr "" + #: py/modmath.c py/objfloat.c py/objint_longlong.c py/objint_mpz.c py/runtime.c #: shared-bindings/math/__init__.c msgid "division by zero" @@ -2624,6 +2635,10 @@ msgstr "" msgid "first argument must be a function" msgstr "" +#: extmod/ulab/code/ulab_create.c +msgid "first argument must be a tuple of ndarrays" +msgstr "" + #: extmod/ulab/code/ndarray.c msgid "first argument must be an iterable" msgstr "Das erste Argument muss iterierbar sein" @@ -2677,9 +2692,9 @@ msgstr "Funktion hat mehrere Werte für Argument '%q'" msgid "function has the same sign at the ends of interval" msgstr "" -#: extmod/ulab/code/compare/compare.c -msgid "function is implemented for scalars and ndarrays only" -msgstr "Die Funktion ist nur für Skalare und Ndarrays implementiert" +#: extmod/ulab/code/ndarray.c +msgid "function is defined for ndarrays only" +msgstr "" #: py/argcheck.c #, c-format @@ -2749,6 +2764,7 @@ msgstr "padding ist inkorrekt" msgid "index is out of bounds" msgstr "Index ist außerhalb der Grenzen" +#: extmod/ulab/code/numerical/numerical.c #: ports/esp32s2/common-hal/pulseio/PulseIn.c py/obj.c msgid "index out of range" msgstr "index außerhalb der Reichweite" @@ -2773,6 +2789,10 @@ msgstr "Länge von initial_value ist falsch" msgid "inline assembler must be a function" msgstr "inline assembler muss eine function sein" +#: extmod/ulab/code/ndarray.c +msgid "input and output shapes are not compatible" +msgstr "" + #: extmod/ulab/code/ulab_create.c msgid "input argument must be an integer or a 2-tuple" msgstr "Das Eingabeargument muss eine Ganzzahl oder ein 2-Tupel sein" @@ -2781,6 +2801,10 @@ msgstr "Das Eingabeargument muss eine Ganzzahl oder ein 2-Tupel sein" msgid "input array length must be power of 2" msgstr "Die Länge des Eingabearrays muss eine Potenz von 2 sein" +#: extmod/ulab/code/ulab_create.c +msgid "input arrays are not compatible" +msgstr "" + #: extmod/ulab/code/poly/poly.c msgid "input data must be an iterable" msgstr "Eingabedaten müssen iterierbar sein" @@ -2793,6 +2817,22 @@ msgstr "Eingabematrix ist asymmetrisch" msgid "input matrix is singular" msgstr "Eingabematrix ist singulär" +#: extmod/ulab/code/user/user.c +msgid "input must be a dense ndarray" +msgstr "" + +#: extmod/ulab/code/ulab_create.c +msgid "input must be a tensor of rank 2" +msgstr "" + +#: extmod/ulab/code/ulab_create.c extmod/ulab/code/user/user.c +msgid "input must be an ndarray" +msgstr "" + +#: extmod/ulab/code/filter/filter.c +msgid "input must be one-dimensional" +msgstr "" + #: extmod/ulab/code/linalg/linalg.c msgid "input must be square matrix" msgstr "Die Eingabe muss eine quadratische Matrix sein" @@ -2805,6 +2845,10 @@ msgstr "Die Eingabe muss Tupel, Liste, Bereich oder Ndarray sein" msgid "input vectors must be of equal length" msgstr "Eingabevektoren müssen gleich lang sein" +#: extmod/ulab/code/poly/poly.c +msgid "inputs are not iterable" +msgstr "" + #: py/parsenum.c msgid "int() arg 2 must be >= 2 and <= 36" msgstr "int() arg 2 muss >= 2 und <= 36 sein" @@ -2979,6 +3023,10 @@ msgstr "max_length muss 0-%d sein, wenn fixed_length %s ist" msgid "max_length must be > 0" msgstr "" +#: extmod/ulab/code/ndarray.c +msgid "maximum number of dimensions is 4" +msgstr "" + #: py/runtime.c msgid "maximum recursion depth exceeded" msgstr "maximale Rekursionstiefe überschritten" @@ -3028,10 +3076,6 @@ msgstr "muss ein Objekt verursachen (raise)" msgid "must use keyword argument for key function" msgstr "muss Schlüsselwortargument für key function verwenden" -#: extmod/ulab/code/numerical/numerical.c -msgid "n must be between 0, and 9" -msgstr "n muss zwischen 0 und 9 liegen" - #: py/runtime.c msgid "name '%q' is not defined" msgstr "Name '%q' ist nirgends definiert worden (Schreibweise kontrollieren)" @@ -3114,6 +3158,10 @@ msgstr "Nicht-Schlüsselwort arg nach * / **" msgid "non-keyword arg after keyword arg" msgstr "Nicht-Schlüsselwort Argument nach Schlüsselwort Argument" +#: extmod/ulab/code/linalg/linalg.c +msgid "norm is defined for 1D and 2D arrays" +msgstr "" + #: shared-bindings/_bleio/UUID.c msgid "not a 128-bit UUID" msgstr "keine 128-bit UUID" @@ -3127,10 +3175,6 @@ msgstr "" msgid "not enough arguments for format string" msgstr "Nicht genügend Argumente für den Formatierungs-String" -#: extmod/ulab/code/poly/poly.c -msgid "number of arguments must be 2, or 3" -msgstr "Die Anzahl der Argumente muss 2 oder 3 sein" - #: extmod/ulab/code/ulab_create.c msgid "number of points must be at least 2" msgstr "Die Anzahl der Punkte muss mindestens 2 betragen" @@ -3183,6 +3227,10 @@ msgstr "Objekt mit Pufferprotokoll (buffer protocol) erforderlich" msgid "odd-length string" msgstr "String mit ungerader Länge" +#: extmod/ulab/code/ulab_create.c +msgid "offset is too large" +msgstr "" + #: py/objstr.c py/objstrunicode.c msgid "offset out of bounds" msgstr "offset außerhalb der Grenzen" @@ -3206,6 +3254,14 @@ msgstr "" msgid "operands could not be broadcast together" msgstr "Operanden konnten nicht zusammen gesendet werden" +#: extmod/ulab/code/ndarray.c +msgid "operation is implemented for 1D Boolean arrays only" +msgstr "" + +#: extmod/ulab/code/numerical/numerical.c +msgid "operation is not implemented for flattened array" +msgstr "" + #: extmod/ulab/code/numerical/numerical.c msgid "operation is not implemented on ndarrays" msgstr "Die Operation ist für ndarrays nicht implementiert" @@ -3342,6 +3398,10 @@ msgstr "relativer Import" msgid "requested length %d but object has length %d" msgstr "die ersuchte Länge ist %d, aber das Objekt hat eine Länge von %d" +#: extmod/ulab/code/ndarray_operators.c +msgid "results cannot be cast to specified type" +msgstr "" + #: py/compile.c msgid "return annotation must be an identifier" msgstr "Rückgabewert-Beschreibung muss ein Identifier sein" @@ -3360,9 +3420,9 @@ msgstr "rgb_pins[%d] dupliziert eine andere Pinbelegung" msgid "rgb_pins[%d] is not on the same port as clock" msgstr "rgb_pins [%d] befindet sich nicht am selben Port wie clock" -#: extmod/ulab/code/ndarray.c -msgid "right hand side must be an ndarray, or a scalar" -msgstr "Die rechte Seite muss ein Ndarray oder ein Skalar sein" +#: extmod/ulab/code/numerical/numerical.c +msgid "roll argument must be an ndarray" +msgstr "" #: py/objstr.c msgid "rsplit(None,n)" @@ -3389,8 +3449,8 @@ msgid "script compilation not supported" msgstr "kompilieren von Skripten nicht unterstützt" #: extmod/ulab/code/ndarray.c -msgid "shape must be a 2-tuple" -msgstr "Form muss ein 2-Tupel sein" +msgid "shape must be a tuple" +msgstr "" #: py/objstr.c msgid "sign not allowed in string format specifier" @@ -3432,10 +3492,6 @@ msgstr "weicher reboot\n" msgid "sort argument must be an ndarray" msgstr "sortierungs Argument muss ein ndarray sein" -#: extmod/ulab/code/numerical/numerical.c -msgid "sorted axis can't be longer than 65535" -msgstr "" - #: extmod/ulab/code/filter/filter.c msgid "sos array must be of shape (n_section, 6)" msgstr "" @@ -3542,6 +3598,10 @@ msgstr "Zeitlimit beim warten auf v2 Karte" msgid "timestamp out of range for platform time_t" msgstr "Zeitstempel außerhalb des Bereichs für Plattform time_t" +#: extmod/ulab/code/ndarray.c +msgid "tobytes can be invoked for dense arrays only" +msgstr "" + #: shared-module/struct/__init__.c msgid "too many arguments provided with the given format" msgstr "zu viele Argumente mit dem angegebenen Format" @@ -3721,13 +3781,13 @@ msgstr "" msgid "window must be <= interval" msgstr "Fenster muss <= Intervall sein" -#: extmod/ulab/code/linalg/linalg.c -msgid "wrong argument type" -msgstr "falscher Argumenttyp" +#: extmod/ulab/code/numerical/numerical.c +msgid "wrong axis index" +msgstr "" -#: extmod/ulab/code/ndarray.c -msgid "wrong index type" -msgstr "falscher Indextyp" +#: extmod/ulab/code/ulab_create.c +msgid "wrong axis specified" +msgstr "" #: extmod/ulab/code/vector/vectorise.c msgid "wrong input type" @@ -3777,6 +3837,49 @@ msgstr "" msgid "zi must be of shape (n_section, 2)" msgstr "" +#~ msgid "arctan2 is implemented for scalars and ndarrays only" +#~ msgstr "arctan2 ist nur für Skalare und ndarrays implementiert" + +#~ msgid "axis must be -1, 0, None, or 1" +#~ msgstr "Die Achse muss -1, 0, Keine oder 1 sein" + +#~ msgid "axis must be -1, 0, or 1" +#~ msgstr "Die Achse muss -1, 0 oder 1 sein" + +#~ msgid "axis must be None, 0, or 1" +#~ msgstr "Die Achse muss None, 0 oder 1 sein" + +#~ msgid "cannot reshape array (incompatible input/output shape)" +#~ msgstr "" +#~ "Array kann nicht umgeformt werden (inkompatible Eingabe- / Ausgabeform)" + +#~ msgid "could not broadast input array from shape" +#~ msgstr "Eingabearray konnte nicht aus der Form übertragen werden" + +#~ msgid "ddof must be smaller than length of data set" +#~ msgstr "ddof muss kleiner als die Länge des Datensatzes sein" + +#~ msgid "function is implemented for scalars and ndarrays only" +#~ msgstr "Die Funktion ist nur für Skalare und Ndarrays implementiert" + +#~ msgid "n must be between 0, and 9" +#~ msgstr "n muss zwischen 0 und 9 liegen" + +#~ msgid "number of arguments must be 2, or 3" +#~ msgstr "Die Anzahl der Argumente muss 2 oder 3 sein" + +#~ msgid "right hand side must be an ndarray, or a scalar" +#~ msgstr "Die rechte Seite muss ein Ndarray oder ein Skalar sein" + +#~ msgid "shape must be a 2-tuple" +#~ msgstr "Form muss ein 2-Tupel sein" + +#~ msgid "wrong argument type" +#~ msgstr "falscher Argumenttyp" + +#~ msgid "wrong index type" +#~ msgstr "falscher Indextyp" + #~ msgid "" #~ "\n" #~ "To exit, please reset the board without " diff --git a/locale/el.po b/locale/el.po index 0d35c20ceb..85bf0ab44f 100644 --- a/locale/el.po +++ b/locale/el.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-11-10 15:30+0530\n" +"POT-Creation-Date: 2020-11-23 10:10-0600\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: Automatically generated\n" "Language-Team: none\n" @@ -854,6 +854,10 @@ msgstr "" msgid "FFT is defined for ndarrays only" msgstr "" +#: extmod/ulab/code/fft/fft.c +msgid "FFT is implemented for linear arrays only" +msgstr "" + #: ports/esp32s2/common-hal/socketpool/Socket.c msgid "Failed SSL handshake" msgstr "" @@ -1950,7 +1954,7 @@ msgstr "" msgid "WARNING: Your code filename has two extensions\n" msgstr "" -#: shared-bindings/watchdog/WatchDogTimer.c +#: ports/nrf/common-hal/watchdog/WatchDogTimer.c msgid "WatchDogTimer cannot be deinitialized once mode is set to RESET" msgstr "" @@ -2029,10 +2033,6 @@ msgstr "" msgid "addresses is empty" msgstr "" -#: extmod/ulab/code/vector/vectorise.c -msgid "arctan2 is implemented for scalars and ndarrays only" -msgstr "" - #: py/modbuiltins.c msgid "arg is an empty sequence" msgstr "" @@ -2041,6 +2041,10 @@ msgstr "" msgid "argsort argument must be an ndarray" msgstr "" +#: extmod/ulab/code/numerical/numerical.c +msgid "argsort is not implemented for flattened arrays" +msgstr "" + #: py/runtime.c msgid "argument has wrong type" msgstr "" @@ -2058,14 +2062,22 @@ msgstr "" msgid "argument should be a '%q' not a '%q'" msgstr "" -#: extmod/ulab/code/linalg/linalg.c +#: extmod/ulab/code/linalg/linalg.c extmod/ulab/code/numerical/numerical.c msgid "arguments must be ndarrays" msgstr "" +#: extmod/ulab/code/ndarray.c +msgid "array and index length must be equal" +msgstr "" + #: py/objarray.c shared-bindings/nvm/ByteArray.c msgid "array/bytes required on right side" msgstr "" +#: extmod/ulab/code/numerical/numerical.c +msgid "attempt to get (arg)min/(arg)max of empty sequence" +msgstr "" + #: extmod/ulab/code/numerical/numerical.c msgid "attempt to get argmin/argmax of an empty sequence" msgstr "" @@ -2075,15 +2087,15 @@ msgid "attributes not supported yet" msgstr "" #: extmod/ulab/code/numerical/numerical.c -msgid "axis must be -1, 0, None, or 1" +msgid "axis is out of bounds" msgstr "" #: extmod/ulab/code/numerical/numerical.c -msgid "axis must be -1, 0, or 1" +msgid "axis must be None, or an integer" msgstr "" #: extmod/ulab/code/numerical/numerical.c -msgid "axis must be None, 0, or 1" +msgid "axis too long" msgstr "" #: py/builtinevex.c @@ -2287,6 +2299,10 @@ msgid "" "can't switch from manual field specification to automatic field numbering" msgstr "" +#: extmod/ulab/code/ndarray_operators.c +msgid "cannot cast output with casting rule" +msgstr "" + #: py/objtype.c msgid "cannot create '%q' instances" msgstr "" @@ -2303,10 +2319,6 @@ msgstr "" msgid "cannot perform relative import" msgstr "" -#: extmod/ulab/code/ndarray.c -msgid "cannot reshape array (incompatible input/output shape)" -msgstr "" - #: py/emitnative.c msgid "casting" msgstr "" @@ -2379,10 +2391,6 @@ msgstr "" msgid "convolve arguments must not be empty" msgstr "" -#: extmod/ulab/code/ndarray.c -msgid "could not broadast input array from shape" -msgstr "" - #: extmod/ulab/code/poly/poly.c msgid "could not invert Vandermonde matrix" msgstr "" @@ -2391,6 +2399,10 @@ msgstr "" msgid "couldn't determine SD card version" msgstr "" +#: extmod/ulab/code/numerical/numerical.c +msgid "cross is defined for 1D arrays of length 3" +msgstr "" + #: extmod/ulab/code/approx/approx.c msgid "data must be iterable" msgstr "" @@ -2399,10 +2411,6 @@ msgstr "" msgid "data must be of equal length" msgstr "" -#: extmod/ulab/code/numerical/numerical.c -msgid "ddof must be smaller than length of data set" -msgstr "" - #: py/parsenum.c msgid "decimal numbers not supported" msgstr "" @@ -2432,6 +2440,10 @@ msgstr "" msgid "diff argument must be an ndarray" msgstr "" +#: extmod/ulab/code/numerical/numerical.c +msgid "differentiation order out of range" +msgstr "" + #: py/modmath.c py/objfloat.c py/objint_longlong.c py/objint_mpz.c py/runtime.c #: shared-bindings/math/__init__.c msgid "division by zero" @@ -2547,6 +2559,10 @@ msgstr "" msgid "first argument must be a function" msgstr "" +#: extmod/ulab/code/ulab_create.c +msgid "first argument must be a tuple of ndarrays" +msgstr "" + #: extmod/ulab/code/ndarray.c msgid "first argument must be an iterable" msgstr "" @@ -2600,8 +2616,8 @@ msgstr "" msgid "function has the same sign at the ends of interval" msgstr "" -#: extmod/ulab/code/compare/compare.c -msgid "function is implemented for scalars and ndarrays only" +#: extmod/ulab/code/ndarray.c +msgid "function is defined for ndarrays only" msgstr "" #: py/argcheck.c @@ -2671,6 +2687,7 @@ msgstr "" msgid "index is out of bounds" msgstr "" +#: extmod/ulab/code/numerical/numerical.c #: ports/esp32s2/common-hal/pulseio/PulseIn.c py/obj.c msgid "index out of range" msgstr "" @@ -2695,6 +2712,10 @@ msgstr "" msgid "inline assembler must be a function" msgstr "" +#: extmod/ulab/code/ndarray.c +msgid "input and output shapes are not compatible" +msgstr "" + #: extmod/ulab/code/ulab_create.c msgid "input argument must be an integer or a 2-tuple" msgstr "" @@ -2703,6 +2724,10 @@ msgstr "" msgid "input array length must be power of 2" msgstr "" +#: extmod/ulab/code/ulab_create.c +msgid "input arrays are not compatible" +msgstr "" + #: extmod/ulab/code/poly/poly.c msgid "input data must be an iterable" msgstr "" @@ -2715,6 +2740,22 @@ msgstr "" msgid "input matrix is singular" msgstr "" +#: extmod/ulab/code/user/user.c +msgid "input must be a dense ndarray" +msgstr "" + +#: extmod/ulab/code/ulab_create.c +msgid "input must be a tensor of rank 2" +msgstr "" + +#: extmod/ulab/code/ulab_create.c extmod/ulab/code/user/user.c +msgid "input must be an ndarray" +msgstr "" + +#: extmod/ulab/code/filter/filter.c +msgid "input must be one-dimensional" +msgstr "" + #: extmod/ulab/code/linalg/linalg.c msgid "input must be square matrix" msgstr "" @@ -2727,6 +2768,10 @@ msgstr "" msgid "input vectors must be of equal length" msgstr "" +#: extmod/ulab/code/poly/poly.c +msgid "inputs are not iterable" +msgstr "" + #: py/parsenum.c msgid "int() arg 2 must be >= 2 and <= 36" msgstr "" @@ -2895,6 +2940,10 @@ msgstr "" msgid "max_length must be > 0" msgstr "" +#: extmod/ulab/code/ndarray.c +msgid "maximum number of dimensions is 4" +msgstr "" + #: py/runtime.c msgid "maximum recursion depth exceeded" msgstr "" @@ -2944,10 +2993,6 @@ msgstr "" msgid "must use keyword argument for key function" msgstr "" -#: extmod/ulab/code/numerical/numerical.c -msgid "n must be between 0, and 9" -msgstr "" - #: py/runtime.c msgid "name '%q' is not defined" msgstr "" @@ -3030,6 +3075,10 @@ msgstr "" msgid "non-keyword arg after keyword arg" msgstr "" +#: extmod/ulab/code/linalg/linalg.c +msgid "norm is defined for 1D and 2D arrays" +msgstr "" + #: shared-bindings/_bleio/UUID.c msgid "not a 128-bit UUID" msgstr "" @@ -3042,10 +3091,6 @@ msgstr "" msgid "not enough arguments for format string" msgstr "" -#: extmod/ulab/code/poly/poly.c -msgid "number of arguments must be 2, or 3" -msgstr "" - #: extmod/ulab/code/ulab_create.c msgid "number of points must be at least 2" msgstr "" @@ -3098,6 +3143,10 @@ msgstr "" msgid "odd-length string" msgstr "" +#: extmod/ulab/code/ulab_create.c +msgid "offset is too large" +msgstr "" + #: py/objstr.c py/objstrunicode.c msgid "offset out of bounds" msgstr "" @@ -3120,6 +3169,14 @@ msgstr "" msgid "operands could not be broadcast together" msgstr "" +#: extmod/ulab/code/ndarray.c +msgid "operation is implemented for 1D Boolean arrays only" +msgstr "" + +#: extmod/ulab/code/numerical/numerical.c +msgid "operation is not implemented for flattened array" +msgstr "" + #: extmod/ulab/code/numerical/numerical.c msgid "operation is not implemented on ndarrays" msgstr "" @@ -3254,6 +3311,10 @@ msgstr "" msgid "requested length %d but object has length %d" msgstr "" +#: extmod/ulab/code/ndarray_operators.c +msgid "results cannot be cast to specified type" +msgstr "" + #: py/compile.c msgid "return annotation must be an identifier" msgstr "" @@ -3272,8 +3333,8 @@ msgstr "" msgid "rgb_pins[%d] is not on the same port as clock" msgstr "" -#: extmod/ulab/code/ndarray.c -msgid "right hand side must be an ndarray, or a scalar" +#: extmod/ulab/code/numerical/numerical.c +msgid "roll argument must be an ndarray" msgstr "" #: py/objstr.c @@ -3299,7 +3360,7 @@ msgid "script compilation not supported" msgstr "" #: extmod/ulab/code/ndarray.c -msgid "shape must be a 2-tuple" +msgid "shape must be a tuple" msgstr "" #: py/objstr.c @@ -3342,10 +3403,6 @@ msgstr "" msgid "sort argument must be an ndarray" msgstr "" -#: extmod/ulab/code/numerical/numerical.c -msgid "sorted axis can't be longer than 65535" -msgstr "" - #: extmod/ulab/code/filter/filter.c msgid "sos array must be of shape (n_section, 6)" msgstr "" @@ -3451,6 +3508,10 @@ msgstr "" msgid "timestamp out of range for platform time_t" msgstr "" +#: extmod/ulab/code/ndarray.c +msgid "tobytes can be invoked for dense arrays only" +msgstr "" + #: shared-module/struct/__init__.c msgid "too many arguments provided with the given format" msgstr "" @@ -3626,12 +3687,12 @@ msgstr "" msgid "window must be <= interval" msgstr "" -#: extmod/ulab/code/linalg/linalg.c -msgid "wrong argument type" +#: extmod/ulab/code/numerical/numerical.c +msgid "wrong axis index" msgstr "" -#: extmod/ulab/code/ndarray.c -msgid "wrong index type" +#: extmod/ulab/code/ulab_create.c +msgid "wrong axis specified" msgstr "" #: extmod/ulab/code/vector/vectorise.c diff --git a/locale/es.po b/locale/es.po index bdb4b68a5d..538a2944e6 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-11-10 15:30+0530\n" +"POT-Creation-Date: 2020-11-23 10:10-0600\n" "PO-Revision-Date: 2020-11-15 16:28+0000\n" "Last-Translator: RubenD \n" "Language-Team: \n" @@ -874,6 +874,10 @@ msgstr "No se admiten anuncios extendidos con respuesta de escaneo." msgid "FFT is defined for ndarrays only" msgstr "FFT se define solo para ndarrays" +#: extmod/ulab/code/fft/fft.c +msgid "FFT is implemented for linear arrays only" +msgstr "" + #: ports/esp32s2/common-hal/socketpool/Socket.c msgid "Failed SSL handshake" msgstr "Fallo en saludo SSL" @@ -2004,7 +2008,7 @@ msgstr "Tiempo de espera agotado para lectura de voltaje" msgid "WARNING: Your code filename has two extensions\n" msgstr "ADVERTENCIA: El nombre de archivo de tu código tiene dos extensiones\n" -#: shared-bindings/watchdog/WatchDogTimer.c +#: ports/nrf/common-hal/watchdog/WatchDogTimer.c msgid "WatchDogTimer cannot be deinitialized once mode is set to RESET" msgstr "" "WatchDogTimer no se puede desinicializar luego de definirse en modo RESET" @@ -2092,10 +2096,6 @@ msgstr "address fuera de límites" msgid "addresses is empty" msgstr "addresses esta vacío" -#: extmod/ulab/code/vector/vectorise.c -msgid "arctan2 is implemented for scalars and ndarrays only" -msgstr "arctan2 se encuentra implementado solo para escalares y ndarrays" - #: py/modbuiltins.c msgid "arg is an empty sequence" msgstr "argumento es una secuencia vacía" @@ -2104,6 +2104,10 @@ msgstr "argumento es una secuencia vacía" msgid "argsort argument must be an ndarray" msgstr "El argumento para argsort debe ser un ndarray" +#: extmod/ulab/code/numerical/numerical.c +msgid "argsort is not implemented for flattened arrays" +msgstr "" + #: py/runtime.c msgid "argument has wrong type" msgstr "el argumento tiene un tipo erroneo" @@ -2121,14 +2125,22 @@ msgstr "argumento número/tipos no coinciden" msgid "argument should be a '%q' not a '%q'" msgstr "argumento deberia ser un '%q' no un '%q'" -#: extmod/ulab/code/linalg/linalg.c +#: extmod/ulab/code/linalg/linalg.c extmod/ulab/code/numerical/numerical.c msgid "arguments must be ndarrays" msgstr "argumentos deben ser ndarrays" +#: extmod/ulab/code/ndarray.c +msgid "array and index length must be equal" +msgstr "" + #: py/objarray.c shared-bindings/nvm/ByteArray.c msgid "array/bytes required on right side" msgstr "array/bytes requeridos en el lado derecho" +#: extmod/ulab/code/numerical/numerical.c +msgid "attempt to get (arg)min/(arg)max of empty sequence" +msgstr "" + #: extmod/ulab/code/numerical/numerical.c msgid "attempt to get argmin/argmax of an empty sequence" msgstr "se trató de traer argmin/argmax de una secuencia vacía" @@ -2138,16 +2150,16 @@ msgid "attributes not supported yet" msgstr "atributos aún no soportados" #: extmod/ulab/code/numerical/numerical.c -msgid "axis must be -1, 0, None, or 1" -msgstr "eje debe ser -1, 0, None o 1" +msgid "axis is out of bounds" +msgstr "" #: extmod/ulab/code/numerical/numerical.c -msgid "axis must be -1, 0, or 1" -msgstr "eje debe ser -1, 0, o 1" +msgid "axis must be None, or an integer" +msgstr "" #: extmod/ulab/code/numerical/numerical.c -msgid "axis must be None, 0, or 1" -msgstr "eje debe ser None, 0, o 1" +msgid "axis too long" +msgstr "" #: py/builtinevex.c msgid "bad compile mode" @@ -2355,6 +2367,10 @@ msgstr "" "no se puede cambiar de especificación de campo manual a numeración " "automática de campos" +#: extmod/ulab/code/ndarray_operators.c +msgid "cannot cast output with casting rule" +msgstr "" + #: py/objtype.c msgid "cannot create '%q' instances" msgstr "no se pueden crear '%q' instancias" @@ -2371,10 +2387,6 @@ msgstr "no se puede importar name '%q'" msgid "cannot perform relative import" msgstr "no se puedo realizar importación relativa" -#: extmod/ulab/code/ndarray.c -msgid "cannot reshape array (incompatible input/output shape)" -msgstr "no se puede reformar el arreglo (forma de entrada/salida incompatible)" - #: py/emitnative.c msgid "casting" msgstr "convirtiendo tipo" @@ -2447,10 +2459,6 @@ msgstr "los argumentos para convolve deben ser ndarrays" msgid "convolve arguments must not be empty" msgstr "los argumentos para convolve no deben estar vacíos" -#: extmod/ulab/code/ndarray.c -msgid "could not broadast input array from shape" -msgstr "no se pudo anunciar la matriz de entrada desde la forma" - #: extmod/ulab/code/poly/poly.c msgid "could not invert Vandermonde matrix" msgstr "no se pudo invertir la matriz de Vandermonde" @@ -2459,6 +2467,10 @@ msgstr "no se pudo invertir la matriz de Vandermonde" msgid "couldn't determine SD card version" msgstr "no se pudo determinar la versión de la tarjeta SD" +#: extmod/ulab/code/numerical/numerical.c +msgid "cross is defined for 1D arrays of length 3" +msgstr "" + #: extmod/ulab/code/approx/approx.c msgid "data must be iterable" msgstr "los datos deben permitir iteración" @@ -2467,10 +2479,6 @@ msgstr "los datos deben permitir iteración" msgid "data must be of equal length" msgstr "los datos deben ser de igual tamaño" -#: extmod/ulab/code/numerical/numerical.c -msgid "ddof must be smaller than length of data set" -msgstr "ddof debe ser menor que la longitud del conjunto de datos" - #: py/parsenum.c msgid "decimal numbers not supported" msgstr "números decimales no soportados" @@ -2502,6 +2510,10 @@ msgstr "la secuencia de actualizacion del dict tiene una longitud incorrecta" msgid "diff argument must be an ndarray" msgstr "El argumento diff debe ser un ndarray" +#: extmod/ulab/code/numerical/numerical.c +msgid "differentiation order out of range" +msgstr "" + #: py/modmath.c py/objfloat.c py/objint_longlong.c py/objint_mpz.c py/runtime.c #: shared-bindings/math/__init__.c msgid "division by zero" @@ -2617,6 +2629,10 @@ msgstr "se debe poder llamar al primer argumento" msgid "first argument must be a function" msgstr "el primer argumento debe ser una función" +#: extmod/ulab/code/ulab_create.c +msgid "first argument must be a tuple of ndarrays" +msgstr "" + #: extmod/ulab/code/ndarray.c msgid "first argument must be an iterable" msgstr "el primer argumento debe permitir iteración" @@ -2670,9 +2686,9 @@ msgstr "la función tiene múltiples valores para el argumento '%q'" msgid "function has the same sign at the ends of interval" msgstr "la función tiene el mismo signo a extremos del intervalo" -#: extmod/ulab/code/compare/compare.c -msgid "function is implemented for scalars and ndarrays only" -msgstr "la función está implementada solo para escalares y ndarrays" +#: extmod/ulab/code/ndarray.c +msgid "function is defined for ndarrays only" +msgstr "" #: py/argcheck.c #, c-format @@ -2741,6 +2757,7 @@ msgstr "relleno (padding) incorrecto" msgid "index is out of bounds" msgstr "el índice está fuera de límites" +#: extmod/ulab/code/numerical/numerical.c #: ports/esp32s2/common-hal/pulseio/PulseIn.c py/obj.c msgid "index out of range" msgstr "index fuera de rango" @@ -2765,6 +2782,10 @@ msgstr "el tamaño de initial_value es incorrecto" msgid "inline assembler must be a function" msgstr "ensamblador en línea debe ser una función" +#: extmod/ulab/code/ndarray.c +msgid "input and output shapes are not compatible" +msgstr "" + #: extmod/ulab/code/ulab_create.c msgid "input argument must be an integer or a 2-tuple" msgstr "el argumento de entrada debe ser un entero o una tupla de par" @@ -2773,6 +2794,10 @@ msgstr "el argumento de entrada debe ser un entero o una tupla de par" msgid "input array length must be power of 2" msgstr "el tamaño del arreglo de entrada debe ser potencia de 2" +#: extmod/ulab/code/ulab_create.c +msgid "input arrays are not compatible" +msgstr "" + #: extmod/ulab/code/poly/poly.c msgid "input data must be an iterable" msgstr "los datos de entrada deben permitir iteración" @@ -2785,6 +2810,22 @@ msgstr "la matriz de entrada es asimétrica" msgid "input matrix is singular" msgstr "la matriz de entrada es singular" +#: extmod/ulab/code/user/user.c +msgid "input must be a dense ndarray" +msgstr "" + +#: extmod/ulab/code/ulab_create.c +msgid "input must be a tensor of rank 2" +msgstr "" + +#: extmod/ulab/code/ulab_create.c extmod/ulab/code/user/user.c +msgid "input must be an ndarray" +msgstr "" + +#: extmod/ulab/code/filter/filter.c +msgid "input must be one-dimensional" +msgstr "" + #: extmod/ulab/code/linalg/linalg.c msgid "input must be square matrix" msgstr "la entrada debe ser una matriz cuadrada" @@ -2797,6 +2838,10 @@ msgstr "la entrada debe ser una tupla, lista, rango o ndarray" msgid "input vectors must be of equal length" msgstr "los vectores de entrada deben ser de igual tamaño" +#: extmod/ulab/code/poly/poly.c +msgid "inputs are not iterable" +msgstr "" + #: py/parsenum.c msgid "int() arg 2 must be >= 2 and <= 36" msgstr "int() arg 2 debe ser >= 2 y <= 36" @@ -2968,6 +3013,10 @@ msgstr "max_length debe ser 0-%d cuando fixed_length es %s" msgid "max_length must be > 0" msgstr "max_lenght debe ser > 0" +#: extmod/ulab/code/ndarray.c +msgid "maximum number of dimensions is 4" +msgstr "" + #: py/runtime.c msgid "maximum recursion depth exceeded" msgstr "profundidad máxima de recursión excedida" @@ -3017,10 +3066,6 @@ msgstr "debe hacer un raise de un objeto" msgid "must use keyword argument for key function" msgstr "debe utilizar argumento de palabra clave para la función clave" -#: extmod/ulab/code/numerical/numerical.c -msgid "n must be between 0, and 9" -msgstr "n debe estar entre 0 y 9" - #: py/runtime.c msgid "name '%q' is not defined" msgstr "name '%q' no esta definido" @@ -3105,6 +3150,10 @@ msgstr "" "no deberia estar/tener agumento por palabra clave despues de argumento por " "palabra clave" +#: extmod/ulab/code/linalg/linalg.c +msgid "norm is defined for 1D and 2D arrays" +msgstr "" + #: shared-bindings/_bleio/UUID.c msgid "not a 128-bit UUID" msgstr "no es 128-bit UUID" @@ -3118,10 +3167,6 @@ msgstr "" msgid "not enough arguments for format string" msgstr "no suficientes argumentos para format string" -#: extmod/ulab/code/poly/poly.c -msgid "number of arguments must be 2, or 3" -msgstr "el número de argumentos debe ser 2 o 3" - #: extmod/ulab/code/ulab_create.c msgid "number of points must be at least 2" msgstr "el número de puntos debe ser al menos 2" @@ -3174,6 +3219,10 @@ msgstr "objeto con protocolo de buffer requerido" msgid "odd-length string" msgstr "string de longitud impar" +#: extmod/ulab/code/ulab_create.c +msgid "offset is too large" +msgstr "" + #: py/objstr.c py/objstrunicode.c msgid "offset out of bounds" msgstr "offset fuera de límites" @@ -3196,6 +3245,14 @@ msgstr "solo se admiten segmentos con step=1 (alias None)" msgid "operands could not be broadcast together" msgstr "los operandos no se pueden transmitir juntos" +#: extmod/ulab/code/ndarray.c +msgid "operation is implemented for 1D Boolean arrays only" +msgstr "" + +#: extmod/ulab/code/numerical/numerical.c +msgid "operation is not implemented for flattened array" +msgstr "" + #: extmod/ulab/code/numerical/numerical.c msgid "operation is not implemented on ndarrays" msgstr "la operación no está implementada para ndarrays" @@ -3330,6 +3387,10 @@ msgstr "import relativo" msgid "requested length %d but object has length %d" msgstr "longitud solicitada %d pero el objeto tiene longitud %d" +#: extmod/ulab/code/ndarray_operators.c +msgid "results cannot be cast to specified type" +msgstr "" + #: py/compile.c msgid "return annotation must be an identifier" msgstr "la anotación de retorno debe ser un identificador" @@ -3348,9 +3409,9 @@ msgstr "rgb_pins[%d] duplica otra asignación de pin" msgid "rgb_pins[%d] is not on the same port as clock" msgstr "rgb_pins[%d] no está en el mismo puerto que el reloj" -#: extmod/ulab/code/ndarray.c -msgid "right hand side must be an ndarray, or a scalar" -msgstr "el lado derecho debe ser un ndarray o escalar" +#: extmod/ulab/code/numerical/numerical.c +msgid "roll argument must be an ndarray" +msgstr "" #: py/objstr.c msgid "rsplit(None,n)" @@ -3377,8 +3438,8 @@ msgid "script compilation not supported" msgstr "script de compilación no soportado" #: extmod/ulab/code/ndarray.c -msgid "shape must be a 2-tuple" -msgstr "la forma debe ser una tupla de 2" +msgid "shape must be a tuple" +msgstr "" #: py/objstr.c msgid "sign not allowed in string format specifier" @@ -3420,10 +3481,6 @@ msgstr "reinicio suave\n" msgid "sort argument must be an ndarray" msgstr "argumento de ordenado debe ser un ndarray" -#: extmod/ulab/code/numerical/numerical.c -msgid "sorted axis can't be longer than 65535" -msgstr "" - #: extmod/ulab/code/filter/filter.c msgid "sos array must be of shape (n_section, 6)" msgstr "el arreglo sos debe de forma (n_section, 6)" @@ -3530,6 +3587,10 @@ msgstr "tiempo de espera agotado esperando a tarjeta v2" msgid "timestamp out of range for platform time_t" msgstr "timestamp fuera de rango para plataform time_t" +#: extmod/ulab/code/ndarray.c +msgid "tobytes can be invoked for dense arrays only" +msgstr "" + #: shared-module/struct/__init__.c msgid "too many arguments provided with the given format" msgstr "demasiados argumentos provistos con el formato dado" @@ -3705,13 +3766,13 @@ msgstr "el ancho debe ser mayor que cero" msgid "window must be <= interval" msgstr "la ventana debe ser <= intervalo" -#: extmod/ulab/code/linalg/linalg.c -msgid "wrong argument type" -msgstr "tipo de argumento incorrecto" +#: extmod/ulab/code/numerical/numerical.c +msgid "wrong axis index" +msgstr "" -#: extmod/ulab/code/ndarray.c -msgid "wrong index type" -msgstr "tipo de índice incorrecto" +#: extmod/ulab/code/ulab_create.c +msgid "wrong axis specified" +msgstr "" #: extmod/ulab/code/vector/vectorise.c msgid "wrong input type" @@ -3761,6 +3822,49 @@ msgstr "zi debe ser de tipo flotante" msgid "zi must be of shape (n_section, 2)" msgstr "zi debe ser una forma (n_section,2)" +#~ msgid "arctan2 is implemented for scalars and ndarrays only" +#~ msgstr "arctan2 se encuentra implementado solo para escalares y ndarrays" + +#~ msgid "axis must be -1, 0, None, or 1" +#~ msgstr "eje debe ser -1, 0, None o 1" + +#~ msgid "axis must be -1, 0, or 1" +#~ msgstr "eje debe ser -1, 0, o 1" + +#~ msgid "axis must be None, 0, or 1" +#~ msgstr "eje debe ser None, 0, o 1" + +#~ msgid "cannot reshape array (incompatible input/output shape)" +#~ msgstr "" +#~ "no se puede reformar el arreglo (forma de entrada/salida incompatible)" + +#~ msgid "could not broadast input array from shape" +#~ msgstr "no se pudo anunciar la matriz de entrada desde la forma" + +#~ msgid "ddof must be smaller than length of data set" +#~ msgstr "ddof debe ser menor que la longitud del conjunto de datos" + +#~ msgid "function is implemented for scalars and ndarrays only" +#~ msgstr "la función está implementada solo para escalares y ndarrays" + +#~ msgid "n must be between 0, and 9" +#~ msgstr "n debe estar entre 0 y 9" + +#~ msgid "number of arguments must be 2, or 3" +#~ msgstr "el número de argumentos debe ser 2 o 3" + +#~ msgid "right hand side must be an ndarray, or a scalar" +#~ msgstr "el lado derecho debe ser un ndarray o escalar" + +#~ msgid "shape must be a 2-tuple" +#~ msgstr "la forma debe ser una tupla de 2" + +#~ msgid "wrong argument type" +#~ msgstr "tipo de argumento incorrecto" + +#~ msgid "wrong index type" +#~ msgstr "tipo de índice incorrecto" + #~ msgid "specify size or data, but not both" #~ msgstr "especifique o tamaño o datos, pero no ambos" diff --git a/locale/fil.po b/locale/fil.po index c74e13c6c8..86178a9a14 100644 --- a/locale/fil.po +++ b/locale/fil.po @@ -5,7 +5,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-11-10 15:30+0530\n" +"POT-Creation-Date: 2020-11-23 10:10-0600\n" "PO-Revision-Date: 2018-12-20 22:15-0800\n" "Last-Translator: Timothy \n" "Language-Team: fil\n" @@ -867,6 +867,10 @@ msgstr "" msgid "FFT is defined for ndarrays only" msgstr "" +#: extmod/ulab/code/fft/fft.c +msgid "FFT is implemented for linear arrays only" +msgstr "" + #: ports/esp32s2/common-hal/socketpool/Socket.c msgid "Failed SSL handshake" msgstr "" @@ -1976,7 +1980,7 @@ msgstr "" msgid "WARNING: Your code filename has two extensions\n" msgstr "BABALA: Ang pangalan ng file ay may dalawang extension\n" -#: shared-bindings/watchdog/WatchDogTimer.c +#: ports/nrf/common-hal/watchdog/WatchDogTimer.c msgid "WatchDogTimer cannot be deinitialized once mode is set to RESET" msgstr "" @@ -2061,10 +2065,6 @@ msgstr "wala sa sakop ang address" msgid "addresses is empty" msgstr "walang laman ang address" -#: extmod/ulab/code/vector/vectorise.c -msgid "arctan2 is implemented for scalars and ndarrays only" -msgstr "" - #: py/modbuiltins.c msgid "arg is an empty sequence" msgstr "arg ay walang laman na sequence" @@ -2073,6 +2073,10 @@ msgstr "arg ay walang laman na sequence" msgid "argsort argument must be an ndarray" msgstr "" +#: extmod/ulab/code/numerical/numerical.c +msgid "argsort is not implemented for flattened arrays" +msgstr "" + #: py/runtime.c msgid "argument has wrong type" msgstr "may maling type ang argument" @@ -2090,14 +2094,22 @@ msgstr "hindi tugma ang argument num/types" msgid "argument should be a '%q' not a '%q'" msgstr "argument ay dapat na '%q' hindi '%q'" -#: extmod/ulab/code/linalg/linalg.c +#: extmod/ulab/code/linalg/linalg.c extmod/ulab/code/numerical/numerical.c msgid "arguments must be ndarrays" msgstr "" +#: extmod/ulab/code/ndarray.c +msgid "array and index length must be equal" +msgstr "" + #: py/objarray.c shared-bindings/nvm/ByteArray.c msgid "array/bytes required on right side" msgstr "array/bytes kinakailangan sa kanang bahagi" +#: extmod/ulab/code/numerical/numerical.c +msgid "attempt to get (arg)min/(arg)max of empty sequence" +msgstr "" + #: extmod/ulab/code/numerical/numerical.c msgid "attempt to get argmin/argmax of an empty sequence" msgstr "" @@ -2107,15 +2119,15 @@ msgid "attributes not supported yet" msgstr "attributes hindi sinusuportahan" #: extmod/ulab/code/numerical/numerical.c -msgid "axis must be -1, 0, None, or 1" +msgid "axis is out of bounds" msgstr "" #: extmod/ulab/code/numerical/numerical.c -msgid "axis must be -1, 0, or 1" +msgid "axis must be None, or an integer" msgstr "" #: extmod/ulab/code/numerical/numerical.c -msgid "axis must be None, 0, or 1" +msgid "axis too long" msgstr "" #: py/builtinevex.c @@ -2326,6 +2338,10 @@ msgstr "" "hindi mapalitan ang manual field specification sa awtomatikong field " "numbering" +#: extmod/ulab/code/ndarray_operators.c +msgid "cannot cast output with casting rule" +msgstr "" + #: py/objtype.c msgid "cannot create '%q' instances" msgstr "hindi magawa '%q' instances" @@ -2342,10 +2358,6 @@ msgstr "hindi ma-import ang name %q" msgid "cannot perform relative import" msgstr "hindi maaring isagawa ang relative import" -#: extmod/ulab/code/ndarray.c -msgid "cannot reshape array (incompatible input/output shape)" -msgstr "" - #: py/emitnative.c msgid "casting" msgstr "casting" @@ -2418,10 +2430,6 @@ msgstr "" msgid "convolve arguments must not be empty" msgstr "" -#: extmod/ulab/code/ndarray.c -msgid "could not broadast input array from shape" -msgstr "" - #: extmod/ulab/code/poly/poly.c msgid "could not invert Vandermonde matrix" msgstr "" @@ -2430,6 +2438,10 @@ msgstr "" msgid "couldn't determine SD card version" msgstr "" +#: extmod/ulab/code/numerical/numerical.c +msgid "cross is defined for 1D arrays of length 3" +msgstr "" + #: extmod/ulab/code/approx/approx.c msgid "data must be iterable" msgstr "" @@ -2438,10 +2450,6 @@ msgstr "" msgid "data must be of equal length" msgstr "" -#: extmod/ulab/code/numerical/numerical.c -msgid "ddof must be smaller than length of data set" -msgstr "" - #: py/parsenum.c msgid "decimal numbers not supported" msgstr "decimal numbers hindi sinusuportahan" @@ -2475,6 +2483,10 @@ msgstr "may mali sa haba ng dict update sequence" msgid "diff argument must be an ndarray" msgstr "" +#: extmod/ulab/code/numerical/numerical.c +msgid "differentiation order out of range" +msgstr "" + #: py/modmath.c py/objfloat.c py/objint_longlong.c py/objint_mpz.c py/runtime.c #: shared-bindings/math/__init__.c msgid "division by zero" @@ -2591,6 +2603,10 @@ msgstr "" msgid "first argument must be a function" msgstr "" +#: extmod/ulab/code/ulab_create.c +msgid "first argument must be a tuple of ndarrays" +msgstr "" + #: extmod/ulab/code/ndarray.c msgid "first argument must be an iterable" msgstr "" @@ -2644,8 +2660,8 @@ msgstr "ang function ay nakakuha ng maraming values para sa argument '%q'" msgid "function has the same sign at the ends of interval" msgstr "" -#: extmod/ulab/code/compare/compare.c -msgid "function is implemented for scalars and ndarrays only" +#: extmod/ulab/code/ndarray.c +msgid "function is defined for ndarrays only" msgstr "" #: py/argcheck.c @@ -2716,6 +2732,7 @@ msgstr "mali ang padding" msgid "index is out of bounds" msgstr "" +#: extmod/ulab/code/numerical/numerical.c #: ports/esp32s2/common-hal/pulseio/PulseIn.c py/obj.c msgid "index out of range" msgstr "index wala sa sakop" @@ -2740,6 +2757,10 @@ msgstr "" msgid "inline assembler must be a function" msgstr "inline assembler ay dapat na function" +#: extmod/ulab/code/ndarray.c +msgid "input and output shapes are not compatible" +msgstr "" + #: extmod/ulab/code/ulab_create.c msgid "input argument must be an integer or a 2-tuple" msgstr "" @@ -2748,6 +2769,10 @@ msgstr "" msgid "input array length must be power of 2" msgstr "" +#: extmod/ulab/code/ulab_create.c +msgid "input arrays are not compatible" +msgstr "" + #: extmod/ulab/code/poly/poly.c msgid "input data must be an iterable" msgstr "" @@ -2760,6 +2785,22 @@ msgstr "" msgid "input matrix is singular" msgstr "" +#: extmod/ulab/code/user/user.c +msgid "input must be a dense ndarray" +msgstr "" + +#: extmod/ulab/code/ulab_create.c +msgid "input must be a tensor of rank 2" +msgstr "" + +#: extmod/ulab/code/ulab_create.c extmod/ulab/code/user/user.c +msgid "input must be an ndarray" +msgstr "" + +#: extmod/ulab/code/filter/filter.c +msgid "input must be one-dimensional" +msgstr "" + #: extmod/ulab/code/linalg/linalg.c msgid "input must be square matrix" msgstr "" @@ -2772,6 +2813,10 @@ msgstr "" msgid "input vectors must be of equal length" msgstr "" +#: extmod/ulab/code/poly/poly.c +msgid "inputs are not iterable" +msgstr "" + #: py/parsenum.c msgid "int() arg 2 must be >= 2 and <= 36" msgstr "int() arg 2 ay dapat >=2 at <= 36" @@ -2944,6 +2989,10 @@ msgstr "" msgid "max_length must be > 0" msgstr "" +#: extmod/ulab/code/ndarray.c +msgid "maximum number of dimensions is 4" +msgstr "" + #: py/runtime.c msgid "maximum recursion depth exceeded" msgstr "lumagpas ang maximum recursion depth" @@ -2993,10 +3042,6 @@ msgstr "dapat itaas ang isang object" msgid "must use keyword argument for key function" msgstr "dapat gumamit ng keyword argument para sa key function" -#: extmod/ulab/code/numerical/numerical.c -msgid "n must be between 0, and 9" -msgstr "" - #: py/runtime.c msgid "name '%q' is not defined" msgstr "name '%q' ay hindi defined" @@ -3079,6 +3124,10 @@ msgstr "non-keyword arg sa huli ng */**" msgid "non-keyword arg after keyword arg" msgstr "non-keyword arg sa huli ng keyword arg" +#: extmod/ulab/code/linalg/linalg.c +msgid "norm is defined for 1D and 2D arrays" +msgstr "" + #: shared-bindings/_bleio/UUID.c msgid "not a 128-bit UUID" msgstr "" @@ -3091,10 +3140,6 @@ msgstr "hindi lahat ng arguments na i-convert habang string formatting" msgid "not enough arguments for format string" msgstr "kulang sa arguments para sa format string" -#: extmod/ulab/code/poly/poly.c -msgid "number of arguments must be 2, or 3" -msgstr "" - #: extmod/ulab/code/ulab_create.c msgid "number of points must be at least 2" msgstr "" @@ -3147,6 +3192,10 @@ msgstr "object na may buffer protocol kinakailangan" msgid "odd-length string" msgstr "odd-length string" +#: extmod/ulab/code/ulab_create.c +msgid "offset is too large" +msgstr "" + #: py/objstr.c py/objstrunicode.c #, fuzzy msgid "offset out of bounds" @@ -3170,6 +3219,14 @@ msgstr "ang mga slices lamang na may hakbang = 1 (aka None) ang sinusuportahan" msgid "operands could not be broadcast together" msgstr "" +#: extmod/ulab/code/ndarray.c +msgid "operation is implemented for 1D Boolean arrays only" +msgstr "" + +#: extmod/ulab/code/numerical/numerical.c +msgid "operation is not implemented for flattened array" +msgstr "" + #: extmod/ulab/code/numerical/numerical.c msgid "operation is not implemented on ndarrays" msgstr "" @@ -3305,6 +3362,10 @@ msgstr "relative import" msgid "requested length %d but object has length %d" msgstr "hiniling ang haba %d ngunit may haba ang object na %d" +#: extmod/ulab/code/ndarray_operators.c +msgid "results cannot be cast to specified type" +msgstr "" + #: py/compile.c msgid "return annotation must be an identifier" msgstr "return annotation ay dapat na identifier" @@ -3323,8 +3384,8 @@ msgstr "" msgid "rgb_pins[%d] is not on the same port as clock" msgstr "" -#: extmod/ulab/code/ndarray.c -msgid "right hand side must be an ndarray, or a scalar" +#: extmod/ulab/code/numerical/numerical.c +msgid "roll argument must be an ndarray" msgstr "" #: py/objstr.c @@ -3352,7 +3413,7 @@ msgid "script compilation not supported" msgstr "script kompilasyon hindi supportado" #: extmod/ulab/code/ndarray.c -msgid "shape must be a 2-tuple" +msgid "shape must be a tuple" msgstr "" #: py/objstr.c @@ -3395,10 +3456,6 @@ msgstr "malambot na reboot\n" msgid "sort argument must be an ndarray" msgstr "" -#: extmod/ulab/code/numerical/numerical.c -msgid "sorted axis can't be longer than 65535" -msgstr "" - #: extmod/ulab/code/filter/filter.c msgid "sos array must be of shape (n_section, 6)" msgstr "" @@ -3506,6 +3563,10 @@ msgstr "" msgid "timestamp out of range for platform time_t" msgstr "wala sa sakop ng timestamp ang platform time_t" +#: extmod/ulab/code/ndarray.c +msgid "tobytes can be invoked for dense arrays only" +msgstr "" + #: shared-module/struct/__init__.c msgid "too many arguments provided with the given format" msgstr "masyadong maraming mga argumento na ibinigay sa ibinigay na format" @@ -3681,12 +3742,12 @@ msgstr "" msgid "window must be <= interval" msgstr "" -#: extmod/ulab/code/linalg/linalg.c -msgid "wrong argument type" +#: extmod/ulab/code/numerical/numerical.c +msgid "wrong axis index" msgstr "" -#: extmod/ulab/code/ndarray.c -msgid "wrong index type" +#: extmod/ulab/code/ulab_create.c +msgid "wrong axis specified" msgstr "" #: extmod/ulab/code/vector/vectorise.c diff --git a/locale/fr.po b/locale/fr.po index b58ca6560b..17e6e905d1 100644 --- a/locale/fr.po +++ b/locale/fr.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: 0.1\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-11-10 15:30+0530\n" +"POT-Creation-Date: 2020-11-23 10:10-0600\n" "PO-Revision-Date: 2020-11-20 22:28+0000\n" "Last-Translator: Noel Gaetan \n" "Language: fr\n" @@ -879,6 +879,10 @@ msgstr "" msgid "FFT is defined for ndarrays only" msgstr "La FFT est définie pour les ndarrays uniquement" +#: extmod/ulab/code/fft/fft.c +msgid "FFT is implemented for linear arrays only" +msgstr "" + #: ports/esp32s2/common-hal/socketpool/Socket.c msgid "Failed SSL handshake" msgstr "Échec du handshake SSL" @@ -2014,7 +2018,7 @@ msgstr "La lecture de la tension a expiré" msgid "WARNING: Your code filename has two extensions\n" msgstr "ATTENTION : le nom de fichier de votre code a deux extensions\n" -#: shared-bindings/watchdog/WatchDogTimer.c +#: ports/nrf/common-hal/watchdog/WatchDogTimer.c msgid "WatchDogTimer cannot be deinitialized once mode is set to RESET" msgstr "" "WatchDogTimer ne peut pas être désinitialisé une fois que le mode est réglé " @@ -2102,10 +2106,6 @@ msgstr "adresse hors limites" msgid "addresses is empty" msgstr "adresses vides" -#: extmod/ulab/code/vector/vectorise.c -msgid "arctan2 is implemented for scalars and ndarrays only" -msgstr "arctan2 est implémenté uniquement pour les scalaires et les ndarrays" - #: py/modbuiltins.c msgid "arg is an empty sequence" msgstr "l'argument est une séquence vide" @@ -2114,6 +2114,10 @@ msgstr "l'argument est une séquence vide" msgid "argsort argument must be an ndarray" msgstr "L'argument argsort doit être un ndarray" +#: extmod/ulab/code/numerical/numerical.c +msgid "argsort is not implemented for flattened arrays" +msgstr "" + #: py/runtime.c msgid "argument has wrong type" msgstr "l'argument est d'un mauvais type" @@ -2131,14 +2135,22 @@ msgstr "argument num/types ne correspond pas" msgid "argument should be a '%q' not a '%q'" msgstr "l'argument devrait être un(e) '%q', pas '%q'" -#: extmod/ulab/code/linalg/linalg.c +#: extmod/ulab/code/linalg/linalg.c extmod/ulab/code/numerical/numerical.c msgid "arguments must be ndarrays" msgstr "les arguments doivent être des ndarrays" +#: extmod/ulab/code/ndarray.c +msgid "array and index length must be equal" +msgstr "" + #: py/objarray.c shared-bindings/nvm/ByteArray.c msgid "array/bytes required on right side" msgstr "tableau/octets requis à droite" +#: extmod/ulab/code/numerical/numerical.c +msgid "attempt to get (arg)min/(arg)max of empty sequence" +msgstr "" + #: extmod/ulab/code/numerical/numerical.c msgid "attempt to get argmin/argmax of an empty sequence" msgstr "tenter d'obtenir argmin / argmax d'une séquence vide" @@ -2148,16 +2160,16 @@ msgid "attributes not supported yet" msgstr "attribut pas encore supporté" #: extmod/ulab/code/numerical/numerical.c -msgid "axis must be -1, 0, None, or 1" -msgstr "l'axe doit être -1, 0, None ou 1" +msgid "axis is out of bounds" +msgstr "" #: extmod/ulab/code/numerical/numerical.c -msgid "axis must be -1, 0, or 1" -msgstr "l'axe doit être -1, 0 ou 1" +msgid "axis must be None, or an integer" +msgstr "" #: extmod/ulab/code/numerical/numerical.c -msgid "axis must be None, 0, or 1" -msgstr "l'axe doit être None, 0 ou 1" +msgid "axis too long" +msgstr "" #: py/builtinevex.c msgid "bad compile mode" @@ -2369,6 +2381,10 @@ msgstr "" "impossible de passer d'une spécification manuelle des champs à une " "énumération auto" +#: extmod/ulab/code/ndarray_operators.c +msgid "cannot cast output with casting rule" +msgstr "" + #: py/objtype.c msgid "cannot create '%q' instances" msgstr "ne peut pas créer une instance de '%q'" @@ -2385,11 +2401,6 @@ msgstr "ne peut pas importer le nom %q" msgid "cannot perform relative import" msgstr "ne peut pas réaliser un import relatif" -#: extmod/ulab/code/ndarray.c -msgid "cannot reshape array (incompatible input/output shape)" -msgstr "" -"ne peut pas remodeler le tableau (forme d'entrée / sortie incompatible)" - #: py/emitnative.c msgid "casting" msgstr "typage" @@ -2464,10 +2475,6 @@ msgstr "les arguments convolve doivent être des ndarrays" msgid "convolve arguments must not be empty" msgstr "les arguments convolve ne doivent pas être vides" -#: extmod/ulab/code/ndarray.c -msgid "could not broadast input array from shape" -msgstr "n'a pas pu diffuser le tableau d'entrée à partir de la forme" - #: extmod/ulab/code/poly/poly.c msgid "could not invert Vandermonde matrix" msgstr "n'a pas pu inverser la matrice Vandermonde" @@ -2476,6 +2483,10 @@ msgstr "n'a pas pu inverser la matrice Vandermonde" msgid "couldn't determine SD card version" msgstr "impossible de déterminer la version de la carte SD" +#: extmod/ulab/code/numerical/numerical.c +msgid "cross is defined for 1D arrays of length 3" +msgstr "" + #: extmod/ulab/code/approx/approx.c msgid "data must be iterable" msgstr "les données doivent être les objets iterables" @@ -2484,10 +2495,6 @@ msgstr "les données doivent être les objets iterables" msgid "data must be of equal length" msgstr "les données doivent être de longueur égale" -#: extmod/ulab/code/numerical/numerical.c -msgid "ddof must be smaller than length of data set" -msgstr "ddof doit être inférieur à la longueur de l'ensemble de données" - #: py/parsenum.c msgid "decimal numbers not supported" msgstr "nombres décimaux non supportés" @@ -2519,6 +2526,10 @@ msgstr "la séquence de mise à jour de dict a une mauvaise longueur" msgid "diff argument must be an ndarray" msgstr "l'argument diff doit être un ndarray" +#: extmod/ulab/code/numerical/numerical.c +msgid "differentiation order out of range" +msgstr "" + #: py/modmath.c py/objfloat.c py/objint_longlong.c py/objint_mpz.c py/runtime.c #: shared-bindings/math/__init__.c msgid "division by zero" @@ -2636,6 +2647,10 @@ msgstr "le premier argument doit être un appelable" msgid "first argument must be a function" msgstr "le premier argument doit être une fonction" +#: extmod/ulab/code/ulab_create.c +msgid "first argument must be a tuple of ndarrays" +msgstr "" + #: extmod/ulab/code/ndarray.c msgid "first argument must be an iterable" msgstr "le premier argument doit être un itérable" @@ -2689,10 +2704,9 @@ msgstr "la fonction a reçu plusieurs valeurs pour l'argument '%q'" msgid "function has the same sign at the ends of interval" msgstr "la fonction a le même signe aux extrémités de l’intervalle" -#: extmod/ulab/code/compare/compare.c -msgid "function is implemented for scalars and ndarrays only" +#: extmod/ulab/code/ndarray.c +msgid "function is defined for ndarrays only" msgstr "" -"la fonction est implémentée pour les scalaires et les ndarrays uniquement" #: py/argcheck.c #, c-format @@ -2761,6 +2775,7 @@ msgstr "espacement incorrect" msgid "index is out of bounds" msgstr "l'index est hors limites" +#: extmod/ulab/code/numerical/numerical.c #: ports/esp32s2/common-hal/pulseio/PulseIn.c py/obj.c msgid "index out of range" msgstr "index hors gamme" @@ -2786,6 +2801,10 @@ msgstr "la longueur de initial_value est incorrecte" msgid "inline assembler must be a function" msgstr "l'assembleur doit être une fonction" +#: extmod/ulab/code/ndarray.c +msgid "input and output shapes are not compatible" +msgstr "" + #: extmod/ulab/code/ulab_create.c msgid "input argument must be an integer or a 2-tuple" msgstr "l'argument d'entrée doit être un entier ou un tuple 2" @@ -2794,6 +2813,10 @@ msgstr "l'argument d'entrée doit être un entier ou un tuple 2" msgid "input array length must be power of 2" msgstr "la longueur du tableau d'entrée doit être une puissance de 2" +#: extmod/ulab/code/ulab_create.c +msgid "input arrays are not compatible" +msgstr "" + #: extmod/ulab/code/poly/poly.c msgid "input data must be an iterable" msgstr "les données d'entrée doivent être un itérable" @@ -2806,6 +2829,22 @@ msgstr "la matrice d'entrée est asymétrique" msgid "input matrix is singular" msgstr "la matrice d'entrée est singulière" +#: extmod/ulab/code/user/user.c +msgid "input must be a dense ndarray" +msgstr "" + +#: extmod/ulab/code/ulab_create.c +msgid "input must be a tensor of rank 2" +msgstr "" + +#: extmod/ulab/code/ulab_create.c extmod/ulab/code/user/user.c +msgid "input must be an ndarray" +msgstr "" + +#: extmod/ulab/code/filter/filter.c +msgid "input must be one-dimensional" +msgstr "" + #: extmod/ulab/code/linalg/linalg.c msgid "input must be square matrix" msgstr "l'entrée doit être une matrice carrée" @@ -2818,6 +2857,10 @@ msgstr "l'entrée doit être tuple, list, range ou ndarray" msgid "input vectors must be of equal length" msgstr "les vecteurs d'entrée doivent être de longueur égale" +#: extmod/ulab/code/poly/poly.c +msgid "inputs are not iterable" +msgstr "" + #: py/parsenum.c msgid "int() arg 2 must be >= 2 and <= 36" msgstr "l'argument 2 de int() doit être >=2 et <=36" @@ -2990,6 +3033,10 @@ msgstr "max_length doit être 0-%d lorsque fixed_length est %s" msgid "max_length must be > 0" msgstr "max_length doit être > 0" +#: extmod/ulab/code/ndarray.c +msgid "maximum number of dimensions is 4" +msgstr "" + #: py/runtime.c msgid "maximum recursion depth exceeded" msgstr "profondeur maximale de récursivité dépassée" @@ -3039,10 +3086,6 @@ msgstr "doit lever un objet" msgid "must use keyword argument for key function" msgstr "doit utiliser un argument nommé pour une fonction key" -#: extmod/ulab/code/numerical/numerical.c -msgid "n must be between 0, and 9" -msgstr "n doit être compris entre 0 et 9" - #: py/runtime.c msgid "name '%q' is not defined" msgstr "nom '%q' non défini" @@ -3126,6 +3169,10 @@ msgstr "argument non-nommé après */**" msgid "non-keyword arg after keyword arg" msgstr "argument non-nommé après argument nommé" +#: extmod/ulab/code/linalg/linalg.c +msgid "norm is defined for 1D and 2D arrays" +msgstr "" + #: shared-bindings/_bleio/UUID.c msgid "not a 128-bit UUID" msgstr "n'est pas un UUID 128 bits" @@ -3139,10 +3186,6 @@ msgstr "" msgid "not enough arguments for format string" msgstr "pas assez d'arguments pour la chaîne de format" -#: extmod/ulab/code/poly/poly.c -msgid "number of arguments must be 2, or 3" -msgstr "le nombre d'arguments doit être 2 ou 3" - #: extmod/ulab/code/ulab_create.c msgid "number of points must be at least 2" msgstr "le nombre de points doit être d'au moins 2" @@ -3195,6 +3238,10 @@ msgstr "un objet avec un protocole de tampon est nécessaire" msgid "odd-length string" msgstr "chaîne de longueur impaire" +#: extmod/ulab/code/ulab_create.c +msgid "offset is too large" +msgstr "" + #: py/objstr.c py/objstrunicode.c msgid "offset out of bounds" msgstr "décalage hors limites" @@ -3217,6 +3264,14 @@ msgstr "seules les tranches avec 'step=1' (cad None) sont supportées" msgid "operands could not be broadcast together" msgstr "les opérandes ne pouvaient pas être diffusés ensemble" +#: extmod/ulab/code/ndarray.c +msgid "operation is implemented for 1D Boolean arrays only" +msgstr "" + +#: extmod/ulab/code/numerical/numerical.c +msgid "operation is not implemented for flattened array" +msgstr "" + #: extmod/ulab/code/numerical/numerical.c msgid "operation is not implemented on ndarrays" msgstr "l'opération n'est pas implémentée sur les ndarrays" @@ -3354,6 +3409,10 @@ msgstr "import relatif" msgid "requested length %d but object has length %d" msgstr "la longueur requise est %d mais l'objet est long de %d" +#: extmod/ulab/code/ndarray_operators.c +msgid "results cannot be cast to specified type" +msgstr "" + #: py/compile.c msgid "return annotation must be an identifier" msgstr "l'annotation de return doit être un identifiant" @@ -3372,9 +3431,9 @@ msgstr "rgb_pins[%d] duplique une autre affectation de broches" msgid "rgb_pins[%d] is not on the same port as clock" msgstr "rgb_pins[%d] n'est pas sur le même port que l'horloge" -#: extmod/ulab/code/ndarray.c -msgid "right hand side must be an ndarray, or a scalar" -msgstr "le côté droit doit être un ndarray ou un scalaire" +#: extmod/ulab/code/numerical/numerical.c +msgid "roll argument must be an ndarray" +msgstr "" #: py/objstr.c msgid "rsplit(None,n)" @@ -3401,8 +3460,8 @@ msgid "script compilation not supported" msgstr "compilation de script non supportée" #: extmod/ulab/code/ndarray.c -msgid "shape must be a 2-tuple" -msgstr "la forme doit être un tuple 2" +msgid "shape must be a tuple" +msgstr "" #: py/objstr.c msgid "sign not allowed in string format specifier" @@ -3444,10 +3503,6 @@ msgstr "redémarrage logiciel\n" msgid "sort argument must be an ndarray" msgstr "l'argument de «sort» doit être un ndarray" -#: extmod/ulab/code/numerical/numerical.c -msgid "sorted axis can't be longer than 65535" -msgstr "sorted axis ne peut pas dépasser 65535" - #: extmod/ulab/code/filter/filter.c msgid "sos array must be of shape (n_section, 6)" msgstr "le tableau sos doit être de forme (n_section, 6)" @@ -3554,6 +3609,10 @@ msgstr "Délai d’expiration dépassé en attendant une carte v2" msgid "timestamp out of range for platform time_t" msgstr "'timestamp' hors bornes pour 'time_t' de la plateforme" +#: extmod/ulab/code/ndarray.c +msgid "tobytes can be invoked for dense arrays only" +msgstr "" + #: shared-module/struct/__init__.c msgid "too many arguments provided with the given format" msgstr "trop d'arguments fournis avec ce format" @@ -3729,13 +3788,13 @@ msgstr "width doit être plus grand que zero" msgid "window must be <= interval" msgstr "la fenêtre doit être <= intervalle" -#: extmod/ulab/code/linalg/linalg.c -msgid "wrong argument type" -msgstr "type d'argument incorrect" +#: extmod/ulab/code/numerical/numerical.c +msgid "wrong axis index" +msgstr "" -#: extmod/ulab/code/ndarray.c -msgid "wrong index type" -msgstr "type d'index incorrect" +#: extmod/ulab/code/ulab_create.c +msgid "wrong axis specified" +msgstr "" #: extmod/ulab/code/vector/vectorise.c msgid "wrong input type" @@ -3785,6 +3844,54 @@ msgstr "zi doit être de type float" msgid "zi must be of shape (n_section, 2)" msgstr "zi doit être de forme (n_section, 2)" +#~ msgid "arctan2 is implemented for scalars and ndarrays only" +#~ msgstr "" +#~ "arctan2 est implémenté uniquement pour les scalaires et les ndarrays" + +#~ msgid "axis must be -1, 0, None, or 1" +#~ msgstr "l'axe doit être -1, 0, None ou 1" + +#~ msgid "axis must be -1, 0, or 1" +#~ msgstr "l'axe doit être -1, 0 ou 1" + +#~ msgid "axis must be None, 0, or 1" +#~ msgstr "l'axe doit être None, 0 ou 1" + +#~ msgid "cannot reshape array (incompatible input/output shape)" +#~ msgstr "" +#~ "ne peut pas remodeler le tableau (forme d'entrée / sortie incompatible)" + +#~ msgid "could not broadast input array from shape" +#~ msgstr "n'a pas pu diffuser le tableau d'entrée à partir de la forme" + +#~ msgid "ddof must be smaller than length of data set" +#~ msgstr "ddof doit être inférieur à la longueur de l'ensemble de données" + +#~ msgid "function is implemented for scalars and ndarrays only" +#~ msgstr "" +#~ "la fonction est implémentée pour les scalaires et les ndarrays uniquement" + +#~ msgid "n must be between 0, and 9" +#~ msgstr "n doit être compris entre 0 et 9" + +#~ msgid "number of arguments must be 2, or 3" +#~ msgstr "le nombre d'arguments doit être 2 ou 3" + +#~ msgid "right hand side must be an ndarray, or a scalar" +#~ msgstr "le côté droit doit être un ndarray ou un scalaire" + +#~ msgid "shape must be a 2-tuple" +#~ msgstr "la forme doit être un tuple 2" + +#~ msgid "sorted axis can't be longer than 65535" +#~ msgstr "sorted axis ne peut pas dépasser 65535" + +#~ msgid "wrong argument type" +#~ msgstr "type d'argument incorrect" + +#~ msgid "wrong index type" +#~ msgstr "type d'index incorrect" + #~ msgid "Must provide SCK pin" #~ msgstr "Vous devez fournir un code PIN SCK" diff --git a/locale/hi.po b/locale/hi.po index 6c49e1f01f..3b006f1989 100644 --- a/locale/hi.po +++ b/locale/hi.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-11-10 15:30+0530\n" +"POT-Creation-Date: 2020-11-23 10:10-0600\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: Automatically generated\n" "Language-Team: none\n" @@ -854,6 +854,10 @@ msgstr "" msgid "FFT is defined for ndarrays only" msgstr "" +#: extmod/ulab/code/fft/fft.c +msgid "FFT is implemented for linear arrays only" +msgstr "" + #: ports/esp32s2/common-hal/socketpool/Socket.c msgid "Failed SSL handshake" msgstr "" @@ -1950,7 +1954,7 @@ msgstr "" msgid "WARNING: Your code filename has two extensions\n" msgstr "" -#: shared-bindings/watchdog/WatchDogTimer.c +#: ports/nrf/common-hal/watchdog/WatchDogTimer.c msgid "WatchDogTimer cannot be deinitialized once mode is set to RESET" msgstr "" @@ -2029,10 +2033,6 @@ msgstr "" msgid "addresses is empty" msgstr "" -#: extmod/ulab/code/vector/vectorise.c -msgid "arctan2 is implemented for scalars and ndarrays only" -msgstr "" - #: py/modbuiltins.c msgid "arg is an empty sequence" msgstr "" @@ -2041,6 +2041,10 @@ msgstr "" msgid "argsort argument must be an ndarray" msgstr "" +#: extmod/ulab/code/numerical/numerical.c +msgid "argsort is not implemented for flattened arrays" +msgstr "" + #: py/runtime.c msgid "argument has wrong type" msgstr "" @@ -2058,14 +2062,22 @@ msgstr "" msgid "argument should be a '%q' not a '%q'" msgstr "" -#: extmod/ulab/code/linalg/linalg.c +#: extmod/ulab/code/linalg/linalg.c extmod/ulab/code/numerical/numerical.c msgid "arguments must be ndarrays" msgstr "" +#: extmod/ulab/code/ndarray.c +msgid "array and index length must be equal" +msgstr "" + #: py/objarray.c shared-bindings/nvm/ByteArray.c msgid "array/bytes required on right side" msgstr "" +#: extmod/ulab/code/numerical/numerical.c +msgid "attempt to get (arg)min/(arg)max of empty sequence" +msgstr "" + #: extmod/ulab/code/numerical/numerical.c msgid "attempt to get argmin/argmax of an empty sequence" msgstr "" @@ -2075,15 +2087,15 @@ msgid "attributes not supported yet" msgstr "" #: extmod/ulab/code/numerical/numerical.c -msgid "axis must be -1, 0, None, or 1" +msgid "axis is out of bounds" msgstr "" #: extmod/ulab/code/numerical/numerical.c -msgid "axis must be -1, 0, or 1" +msgid "axis must be None, or an integer" msgstr "" #: extmod/ulab/code/numerical/numerical.c -msgid "axis must be None, 0, or 1" +msgid "axis too long" msgstr "" #: py/builtinevex.c @@ -2287,6 +2299,10 @@ msgid "" "can't switch from manual field specification to automatic field numbering" msgstr "" +#: extmod/ulab/code/ndarray_operators.c +msgid "cannot cast output with casting rule" +msgstr "" + #: py/objtype.c msgid "cannot create '%q' instances" msgstr "" @@ -2303,10 +2319,6 @@ msgstr "" msgid "cannot perform relative import" msgstr "" -#: extmod/ulab/code/ndarray.c -msgid "cannot reshape array (incompatible input/output shape)" -msgstr "" - #: py/emitnative.c msgid "casting" msgstr "" @@ -2379,10 +2391,6 @@ msgstr "" msgid "convolve arguments must not be empty" msgstr "" -#: extmod/ulab/code/ndarray.c -msgid "could not broadast input array from shape" -msgstr "" - #: extmod/ulab/code/poly/poly.c msgid "could not invert Vandermonde matrix" msgstr "" @@ -2391,6 +2399,10 @@ msgstr "" msgid "couldn't determine SD card version" msgstr "" +#: extmod/ulab/code/numerical/numerical.c +msgid "cross is defined for 1D arrays of length 3" +msgstr "" + #: extmod/ulab/code/approx/approx.c msgid "data must be iterable" msgstr "" @@ -2399,10 +2411,6 @@ msgstr "" msgid "data must be of equal length" msgstr "" -#: extmod/ulab/code/numerical/numerical.c -msgid "ddof must be smaller than length of data set" -msgstr "" - #: py/parsenum.c msgid "decimal numbers not supported" msgstr "" @@ -2432,6 +2440,10 @@ msgstr "" msgid "diff argument must be an ndarray" msgstr "" +#: extmod/ulab/code/numerical/numerical.c +msgid "differentiation order out of range" +msgstr "" + #: py/modmath.c py/objfloat.c py/objint_longlong.c py/objint_mpz.c py/runtime.c #: shared-bindings/math/__init__.c msgid "division by zero" @@ -2547,6 +2559,10 @@ msgstr "" msgid "first argument must be a function" msgstr "" +#: extmod/ulab/code/ulab_create.c +msgid "first argument must be a tuple of ndarrays" +msgstr "" + #: extmod/ulab/code/ndarray.c msgid "first argument must be an iterable" msgstr "" @@ -2600,8 +2616,8 @@ msgstr "" msgid "function has the same sign at the ends of interval" msgstr "" -#: extmod/ulab/code/compare/compare.c -msgid "function is implemented for scalars and ndarrays only" +#: extmod/ulab/code/ndarray.c +msgid "function is defined for ndarrays only" msgstr "" #: py/argcheck.c @@ -2671,6 +2687,7 @@ msgstr "" msgid "index is out of bounds" msgstr "" +#: extmod/ulab/code/numerical/numerical.c #: ports/esp32s2/common-hal/pulseio/PulseIn.c py/obj.c msgid "index out of range" msgstr "" @@ -2695,6 +2712,10 @@ msgstr "" msgid "inline assembler must be a function" msgstr "" +#: extmod/ulab/code/ndarray.c +msgid "input and output shapes are not compatible" +msgstr "" + #: extmod/ulab/code/ulab_create.c msgid "input argument must be an integer or a 2-tuple" msgstr "" @@ -2703,6 +2724,10 @@ msgstr "" msgid "input array length must be power of 2" msgstr "" +#: extmod/ulab/code/ulab_create.c +msgid "input arrays are not compatible" +msgstr "" + #: extmod/ulab/code/poly/poly.c msgid "input data must be an iterable" msgstr "" @@ -2715,6 +2740,22 @@ msgstr "" msgid "input matrix is singular" msgstr "" +#: extmod/ulab/code/user/user.c +msgid "input must be a dense ndarray" +msgstr "" + +#: extmod/ulab/code/ulab_create.c +msgid "input must be a tensor of rank 2" +msgstr "" + +#: extmod/ulab/code/ulab_create.c extmod/ulab/code/user/user.c +msgid "input must be an ndarray" +msgstr "" + +#: extmod/ulab/code/filter/filter.c +msgid "input must be one-dimensional" +msgstr "" + #: extmod/ulab/code/linalg/linalg.c msgid "input must be square matrix" msgstr "" @@ -2727,6 +2768,10 @@ msgstr "" msgid "input vectors must be of equal length" msgstr "" +#: extmod/ulab/code/poly/poly.c +msgid "inputs are not iterable" +msgstr "" + #: py/parsenum.c msgid "int() arg 2 must be >= 2 and <= 36" msgstr "" @@ -2895,6 +2940,10 @@ msgstr "" msgid "max_length must be > 0" msgstr "" +#: extmod/ulab/code/ndarray.c +msgid "maximum number of dimensions is 4" +msgstr "" + #: py/runtime.c msgid "maximum recursion depth exceeded" msgstr "" @@ -2944,10 +2993,6 @@ msgstr "" msgid "must use keyword argument for key function" msgstr "" -#: extmod/ulab/code/numerical/numerical.c -msgid "n must be between 0, and 9" -msgstr "" - #: py/runtime.c msgid "name '%q' is not defined" msgstr "" @@ -3030,6 +3075,10 @@ msgstr "" msgid "non-keyword arg after keyword arg" msgstr "" +#: extmod/ulab/code/linalg/linalg.c +msgid "norm is defined for 1D and 2D arrays" +msgstr "" + #: shared-bindings/_bleio/UUID.c msgid "not a 128-bit UUID" msgstr "" @@ -3042,10 +3091,6 @@ msgstr "" msgid "not enough arguments for format string" msgstr "" -#: extmod/ulab/code/poly/poly.c -msgid "number of arguments must be 2, or 3" -msgstr "" - #: extmod/ulab/code/ulab_create.c msgid "number of points must be at least 2" msgstr "" @@ -3098,6 +3143,10 @@ msgstr "" msgid "odd-length string" msgstr "" +#: extmod/ulab/code/ulab_create.c +msgid "offset is too large" +msgstr "" + #: py/objstr.c py/objstrunicode.c msgid "offset out of bounds" msgstr "" @@ -3120,6 +3169,14 @@ msgstr "" msgid "operands could not be broadcast together" msgstr "" +#: extmod/ulab/code/ndarray.c +msgid "operation is implemented for 1D Boolean arrays only" +msgstr "" + +#: extmod/ulab/code/numerical/numerical.c +msgid "operation is not implemented for flattened array" +msgstr "" + #: extmod/ulab/code/numerical/numerical.c msgid "operation is not implemented on ndarrays" msgstr "" @@ -3254,6 +3311,10 @@ msgstr "" msgid "requested length %d but object has length %d" msgstr "" +#: extmod/ulab/code/ndarray_operators.c +msgid "results cannot be cast to specified type" +msgstr "" + #: py/compile.c msgid "return annotation must be an identifier" msgstr "" @@ -3272,8 +3333,8 @@ msgstr "" msgid "rgb_pins[%d] is not on the same port as clock" msgstr "" -#: extmod/ulab/code/ndarray.c -msgid "right hand side must be an ndarray, or a scalar" +#: extmod/ulab/code/numerical/numerical.c +msgid "roll argument must be an ndarray" msgstr "" #: py/objstr.c @@ -3299,7 +3360,7 @@ msgid "script compilation not supported" msgstr "" #: extmod/ulab/code/ndarray.c -msgid "shape must be a 2-tuple" +msgid "shape must be a tuple" msgstr "" #: py/objstr.c @@ -3342,10 +3403,6 @@ msgstr "" msgid "sort argument must be an ndarray" msgstr "" -#: extmod/ulab/code/numerical/numerical.c -msgid "sorted axis can't be longer than 65535" -msgstr "" - #: extmod/ulab/code/filter/filter.c msgid "sos array must be of shape (n_section, 6)" msgstr "" @@ -3451,6 +3508,10 @@ msgstr "" msgid "timestamp out of range for platform time_t" msgstr "" +#: extmod/ulab/code/ndarray.c +msgid "tobytes can be invoked for dense arrays only" +msgstr "" + #: shared-module/struct/__init__.c msgid "too many arguments provided with the given format" msgstr "" @@ -3626,12 +3687,12 @@ msgstr "" msgid "window must be <= interval" msgstr "" -#: extmod/ulab/code/linalg/linalg.c -msgid "wrong argument type" +#: extmod/ulab/code/numerical/numerical.c +msgid "wrong axis index" msgstr "" -#: extmod/ulab/code/ndarray.c -msgid "wrong index type" +#: extmod/ulab/code/ulab_create.c +msgid "wrong axis specified" msgstr "" #: extmod/ulab/code/vector/vectorise.c diff --git a/locale/it_IT.po b/locale/it_IT.po index fc0f016752..652bc56fd5 100644 --- a/locale/it_IT.po +++ b/locale/it_IT.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-11-10 15:30+0530\n" +"POT-Creation-Date: 2020-11-23 10:10-0600\n" "PO-Revision-Date: 2018-10-02 16:27+0200\n" "Last-Translator: Enrico Paganin \n" "Language-Team: \n" @@ -867,6 +867,10 @@ msgstr "" msgid "FFT is defined for ndarrays only" msgstr "" +#: extmod/ulab/code/fft/fft.c +msgid "FFT is implemented for linear arrays only" +msgstr "" + #: ports/esp32s2/common-hal/socketpool/Socket.c msgid "Failed SSL handshake" msgstr "" @@ -1985,7 +1989,7 @@ msgstr "" msgid "WARNING: Your code filename has two extensions\n" msgstr "ATTENZIONE: Il nome del sorgente ha due estensioni\n" -#: shared-bindings/watchdog/WatchDogTimer.c +#: ports/nrf/common-hal/watchdog/WatchDogTimer.c msgid "WatchDogTimer cannot be deinitialized once mode is set to RESET" msgstr "" @@ -2064,10 +2068,6 @@ msgstr "indirizzo fuori limite" msgid "addresses is empty" msgstr "gli indirizzi sono vuoti" -#: extmod/ulab/code/vector/vectorise.c -msgid "arctan2 is implemented for scalars and ndarrays only" -msgstr "" - #: py/modbuiltins.c msgid "arg is an empty sequence" msgstr "l'argomento è una sequenza vuota" @@ -2076,6 +2076,10 @@ msgstr "l'argomento è una sequenza vuota" msgid "argsort argument must be an ndarray" msgstr "" +#: extmod/ulab/code/numerical/numerical.c +msgid "argsort is not implemented for flattened arrays" +msgstr "" + #: py/runtime.c msgid "argument has wrong type" msgstr "il tipo dell'argomento è errato" @@ -2093,14 +2097,22 @@ msgstr "discrepanza di numero/tipo di argomenti" msgid "argument should be a '%q' not a '%q'" msgstr "l'argomento dovrebbe essere un '%q' e non un '%q'" -#: extmod/ulab/code/linalg/linalg.c +#: extmod/ulab/code/linalg/linalg.c extmod/ulab/code/numerical/numerical.c msgid "arguments must be ndarrays" msgstr "" +#: extmod/ulab/code/ndarray.c +msgid "array and index length must be equal" +msgstr "" + #: py/objarray.c shared-bindings/nvm/ByteArray.c msgid "array/bytes required on right side" msgstr "" +#: extmod/ulab/code/numerical/numerical.c +msgid "attempt to get (arg)min/(arg)max of empty sequence" +msgstr "" + #: extmod/ulab/code/numerical/numerical.c msgid "attempt to get argmin/argmax of an empty sequence" msgstr "" @@ -2110,15 +2122,15 @@ msgid "attributes not supported yet" msgstr "attributi non ancora supportati" #: extmod/ulab/code/numerical/numerical.c -msgid "axis must be -1, 0, None, or 1" +msgid "axis is out of bounds" msgstr "" #: extmod/ulab/code/numerical/numerical.c -msgid "axis must be -1, 0, or 1" +msgid "axis must be None, or an integer" msgstr "" #: extmod/ulab/code/numerical/numerical.c -msgid "axis must be None, 0, or 1" +msgid "axis too long" msgstr "" #: py/builtinevex.c @@ -2326,6 +2338,10 @@ msgid "" "can't switch from manual field specification to automatic field numbering" msgstr "" +#: extmod/ulab/code/ndarray_operators.c +msgid "cannot cast output with casting rule" +msgstr "" + #: py/objtype.c msgid "cannot create '%q' instances" msgstr "creare '%q' istanze" @@ -2342,10 +2358,6 @@ msgstr "impossibile imporate il nome %q" msgid "cannot perform relative import" msgstr "impossibile effettuare l'importazione relativa" -#: extmod/ulab/code/ndarray.c -msgid "cannot reshape array (incompatible input/output shape)" -msgstr "" - #: py/emitnative.c msgid "casting" msgstr "casting" @@ -2420,10 +2432,6 @@ msgstr "" msgid "convolve arguments must not be empty" msgstr "" -#: extmod/ulab/code/ndarray.c -msgid "could not broadast input array from shape" -msgstr "" - #: extmod/ulab/code/poly/poly.c msgid "could not invert Vandermonde matrix" msgstr "" @@ -2432,6 +2440,10 @@ msgstr "" msgid "couldn't determine SD card version" msgstr "" +#: extmod/ulab/code/numerical/numerical.c +msgid "cross is defined for 1D arrays of length 3" +msgstr "" + #: extmod/ulab/code/approx/approx.c msgid "data must be iterable" msgstr "" @@ -2440,10 +2452,6 @@ msgstr "" msgid "data must be of equal length" msgstr "" -#: extmod/ulab/code/numerical/numerical.c -msgid "ddof must be smaller than length of data set" -msgstr "" - #: py/parsenum.c msgid "decimal numbers not supported" msgstr "numeri decimali non supportati" @@ -2476,6 +2484,10 @@ msgstr "sequanza di aggiornamento del dizionario ha la lunghezza errata" msgid "diff argument must be an ndarray" msgstr "" +#: extmod/ulab/code/numerical/numerical.c +msgid "differentiation order out of range" +msgstr "" + #: py/modmath.c py/objfloat.c py/objint_longlong.c py/objint_mpz.c py/runtime.c #: shared-bindings/math/__init__.c msgid "division by zero" @@ -2592,6 +2604,10 @@ msgstr "" msgid "first argument must be a function" msgstr "" +#: extmod/ulab/code/ulab_create.c +msgid "first argument must be a tuple of ndarrays" +msgstr "" + #: extmod/ulab/code/ndarray.c msgid "first argument must be an iterable" msgstr "" @@ -2645,8 +2661,8 @@ msgstr "la funzione ha ricevuto valori multipli per l'argomento '%q'" msgid "function has the same sign at the ends of interval" msgstr "" -#: extmod/ulab/code/compare/compare.c -msgid "function is implemented for scalars and ndarrays only" +#: extmod/ulab/code/ndarray.c +msgid "function is defined for ndarrays only" msgstr "" #: py/argcheck.c @@ -2717,6 +2733,7 @@ msgstr "padding incorretto" msgid "index is out of bounds" msgstr "" +#: extmod/ulab/code/numerical/numerical.c #: ports/esp32s2/common-hal/pulseio/PulseIn.c py/obj.c msgid "index out of range" msgstr "indice fuori intervallo" @@ -2741,6 +2758,10 @@ msgstr "" msgid "inline assembler must be a function" msgstr "inline assembler deve essere una funzione" +#: extmod/ulab/code/ndarray.c +msgid "input and output shapes are not compatible" +msgstr "" + #: extmod/ulab/code/ulab_create.c msgid "input argument must be an integer or a 2-tuple" msgstr "" @@ -2749,6 +2770,10 @@ msgstr "" msgid "input array length must be power of 2" msgstr "" +#: extmod/ulab/code/ulab_create.c +msgid "input arrays are not compatible" +msgstr "" + #: extmod/ulab/code/poly/poly.c msgid "input data must be an iterable" msgstr "" @@ -2761,6 +2786,22 @@ msgstr "" msgid "input matrix is singular" msgstr "" +#: extmod/ulab/code/user/user.c +msgid "input must be a dense ndarray" +msgstr "" + +#: extmod/ulab/code/ulab_create.c +msgid "input must be a tensor of rank 2" +msgstr "" + +#: extmod/ulab/code/ulab_create.c extmod/ulab/code/user/user.c +msgid "input must be an ndarray" +msgstr "" + +#: extmod/ulab/code/filter/filter.c +msgid "input must be one-dimensional" +msgstr "" + #: extmod/ulab/code/linalg/linalg.c msgid "input must be square matrix" msgstr "" @@ -2773,6 +2814,10 @@ msgstr "" msgid "input vectors must be of equal length" msgstr "" +#: extmod/ulab/code/poly/poly.c +msgid "inputs are not iterable" +msgstr "" + #: py/parsenum.c msgid "int() arg 2 must be >= 2 and <= 36" msgstr "il secondo argomanto di int() deve essere >= 2 e <= 36" @@ -2946,6 +2991,10 @@ msgstr "" msgid "max_length must be > 0" msgstr "" +#: extmod/ulab/code/ndarray.c +msgid "maximum number of dimensions is 4" +msgstr "" + #: py/runtime.c msgid "maximum recursion depth exceeded" msgstr "profondità massima di ricorsione superata" @@ -2995,10 +3044,6 @@ msgstr "deve lanciare un oggetto" msgid "must use keyword argument for key function" msgstr "" -#: extmod/ulab/code/numerical/numerical.c -msgid "n must be between 0, and 9" -msgstr "" - #: py/runtime.c msgid "name '%q' is not defined" msgstr "nome '%q'non definito" @@ -3082,6 +3127,10 @@ msgstr "argomento non nominato dopo */**" msgid "non-keyword arg after keyword arg" msgstr "argomento non nominato seguito da argomento nominato" +#: extmod/ulab/code/linalg/linalg.c +msgid "norm is defined for 1D and 2D arrays" +msgstr "" + #: shared-bindings/_bleio/UUID.c msgid "not a 128-bit UUID" msgstr "" @@ -3096,10 +3145,6 @@ msgstr "" msgid "not enough arguments for format string" msgstr "argomenti non sufficienti per la stringa di formattazione" -#: extmod/ulab/code/poly/poly.c -msgid "number of arguments must be 2, or 3" -msgstr "" - #: extmod/ulab/code/ulab_create.c msgid "number of points must be at least 2" msgstr "" @@ -3152,6 +3197,10 @@ msgstr "" msgid "odd-length string" msgstr "stringa di lunghezza dispari" +#: extmod/ulab/code/ulab_create.c +msgid "offset is too large" +msgstr "" + #: py/objstr.c py/objstrunicode.c #, fuzzy msgid "offset out of bounds" @@ -3175,6 +3224,14 @@ msgstr "solo slice con step=1 (aka None) sono supportate" msgid "operands could not be broadcast together" msgstr "" +#: extmod/ulab/code/ndarray.c +msgid "operation is implemented for 1D Boolean arrays only" +msgstr "" + +#: extmod/ulab/code/numerical/numerical.c +msgid "operation is not implemented for flattened array" +msgstr "" + #: extmod/ulab/code/numerical/numerical.c msgid "operation is not implemented on ndarrays" msgstr "" @@ -3312,6 +3369,10 @@ msgstr "importazione relativa" msgid "requested length %d but object has length %d" msgstr "lunghezza %d richiesta ma l'oggetto ha lunghezza %d" +#: extmod/ulab/code/ndarray_operators.c +msgid "results cannot be cast to specified type" +msgstr "" + #: py/compile.c msgid "return annotation must be an identifier" msgstr "" @@ -3330,8 +3391,8 @@ msgstr "" msgid "rgb_pins[%d] is not on the same port as clock" msgstr "" -#: extmod/ulab/code/ndarray.c -msgid "right hand side must be an ndarray, or a scalar" +#: extmod/ulab/code/numerical/numerical.c +msgid "roll argument must be an ndarray" msgstr "" #: py/objstr.c @@ -3359,7 +3420,7 @@ msgid "script compilation not supported" msgstr "compilazione dello scrip non suportata" #: extmod/ulab/code/ndarray.c -msgid "shape must be a 2-tuple" +msgid "shape must be a tuple" msgstr "" #: py/objstr.c @@ -3402,10 +3463,6 @@ msgstr "soft reboot\n" msgid "sort argument must be an ndarray" msgstr "" -#: extmod/ulab/code/numerical/numerical.c -msgid "sorted axis can't be longer than 65535" -msgstr "" - #: extmod/ulab/code/filter/filter.c msgid "sos array must be of shape (n_section, 6)" msgstr "" @@ -3513,6 +3570,10 @@ msgstr "" msgid "timestamp out of range for platform time_t" msgstr "timestamp è fuori intervallo per il time_t della piattaforma" +#: extmod/ulab/code/ndarray.c +msgid "tobytes can be invoked for dense arrays only" +msgstr "" + #: shared-module/struct/__init__.c msgid "too many arguments provided with the given format" msgstr "troppi argomenti forniti con il formato specificato" @@ -3688,12 +3749,12 @@ msgstr "" msgid "window must be <= interval" msgstr "" -#: extmod/ulab/code/linalg/linalg.c -msgid "wrong argument type" +#: extmod/ulab/code/numerical/numerical.c +msgid "wrong axis index" msgstr "" -#: extmod/ulab/code/ndarray.c -msgid "wrong index type" +#: extmod/ulab/code/ulab_create.c +msgid "wrong axis specified" msgstr "" #: extmod/ulab/code/vector/vectorise.c diff --git a/locale/ja.po b/locale/ja.po index f3dfc6c900..26025c19e4 100644 --- a/locale/ja.po +++ b/locale/ja.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-11-10 15:30+0530\n" +"POT-Creation-Date: 2020-11-23 10:10-0600\n" "PO-Revision-Date: 2020-11-12 22:51+0000\n" "Last-Translator: sporeball \n" "Language-Team: none\n" @@ -867,6 +867,10 @@ msgstr "" msgid "FFT is defined for ndarrays only" msgstr "FFTはndarrayでのみ使えます" +#: extmod/ulab/code/fft/fft.c +msgid "FFT is implemented for linear arrays only" +msgstr "" + #: ports/esp32s2/common-hal/socketpool/Socket.c msgid "Failed SSL handshake" msgstr "" @@ -1975,7 +1979,7 @@ msgstr "電圧読み取りがタイムアウト" msgid "WARNING: Your code filename has two extensions\n" msgstr "" -#: shared-bindings/watchdog/WatchDogTimer.c +#: ports/nrf/common-hal/watchdog/WatchDogTimer.c msgid "WatchDogTimer cannot be deinitialized once mode is set to RESET" msgstr "" @@ -2054,10 +2058,6 @@ msgstr "アドレスが範囲外" msgid "addresses is empty" msgstr "" -#: extmod/ulab/code/vector/vectorise.c -msgid "arctan2 is implemented for scalars and ndarrays only" -msgstr "" - #: py/modbuiltins.c msgid "arg is an empty sequence" msgstr "" @@ -2066,6 +2066,10 @@ msgstr "" msgid "argsort argument must be an ndarray" msgstr "argsortの引数はndarrayでなければなりません" +#: extmod/ulab/code/numerical/numerical.c +msgid "argsort is not implemented for flattened arrays" +msgstr "" + #: py/runtime.c msgid "argument has wrong type" msgstr "" @@ -2083,14 +2087,22 @@ msgstr "" msgid "argument should be a '%q' not a '%q'" msgstr "引数には '%q' が必要('%q' ではなく)" -#: extmod/ulab/code/linalg/linalg.c +#: extmod/ulab/code/linalg/linalg.c extmod/ulab/code/numerical/numerical.c msgid "arguments must be ndarrays" msgstr "引数はndarrayでなければなりません" +#: extmod/ulab/code/ndarray.c +msgid "array and index length must be equal" +msgstr "" + #: py/objarray.c shared-bindings/nvm/ByteArray.c msgid "array/bytes required on right side" msgstr "右辺にはarray/bytesが必要" +#: extmod/ulab/code/numerical/numerical.c +msgid "attempt to get (arg)min/(arg)max of empty sequence" +msgstr "" + #: extmod/ulab/code/numerical/numerical.c msgid "attempt to get argmin/argmax of an empty sequence" msgstr "" @@ -2100,16 +2112,16 @@ msgid "attributes not supported yet" msgstr "属性は未対応です" #: extmod/ulab/code/numerical/numerical.c -msgid "axis must be -1, 0, None, or 1" -msgstr "axisは -1, 0, 1, None のいずれかでなければなりません" +msgid "axis is out of bounds" +msgstr "" #: extmod/ulab/code/numerical/numerical.c -msgid "axis must be -1, 0, or 1" -msgstr "axisは -1, 0, 1 のいずれかでなければなりません" +msgid "axis must be None, or an integer" +msgstr "" #: extmod/ulab/code/numerical/numerical.c -msgid "axis must be None, 0, or 1" -msgstr "axisは None, 0, 1 のいずれか" +msgid "axis too long" +msgstr "" #: py/builtinevex.c msgid "bad compile mode" @@ -2312,6 +2324,10 @@ msgid "" "can't switch from manual field specification to automatic field numbering" msgstr "手動と自動のフィールド指定は混在できません" +#: extmod/ulab/code/ndarray_operators.c +msgid "cannot cast output with casting rule" +msgstr "" + #: py/objtype.c msgid "cannot create '%q' instances" msgstr "" @@ -2328,10 +2344,6 @@ msgstr "" msgid "cannot perform relative import" msgstr "相対インポートはできません" -#: extmod/ulab/code/ndarray.c -msgid "cannot reshape array (incompatible input/output shape)" -msgstr "入力/出力シェイプが互換でなくreshapeできません" - #: py/emitnative.c msgid "casting" msgstr "" @@ -2406,10 +2418,6 @@ msgstr "convolve引数はndarrayでなければなりません" msgid "convolve arguments must not be empty" msgstr "" -#: extmod/ulab/code/ndarray.c -msgid "could not broadast input array from shape" -msgstr "" - #: extmod/ulab/code/poly/poly.c msgid "could not invert Vandermonde matrix" msgstr "ヴァンデルモンド行列の逆行列を求められません" @@ -2418,6 +2426,10 @@ msgstr "ヴァンデルモンド行列の逆行列を求められません" msgid "couldn't determine SD card version" msgstr "" +#: extmod/ulab/code/numerical/numerical.c +msgid "cross is defined for 1D arrays of length 3" +msgstr "" + #: extmod/ulab/code/approx/approx.c msgid "data must be iterable" msgstr "dataはイテレート可能でなければなりません" @@ -2426,10 +2438,6 @@ msgstr "dataはイテレート可能でなければなりません" msgid "data must be of equal length" msgstr "dataは同じ長さでなければなりません" -#: extmod/ulab/code/numerical/numerical.c -msgid "ddof must be smaller than length of data set" -msgstr "" - #: py/parsenum.c msgid "decimal numbers not supported" msgstr "" @@ -2461,6 +2469,10 @@ msgstr "" msgid "diff argument must be an ndarray" msgstr "引数はndarrayでなければなりません" +#: extmod/ulab/code/numerical/numerical.c +msgid "differentiation order out of range" +msgstr "" + #: py/modmath.c py/objfloat.c py/objint_longlong.c py/objint_mpz.c py/runtime.c #: shared-bindings/math/__init__.c msgid "division by zero" @@ -2576,6 +2588,10 @@ msgstr "1つ目の引数は呼び出し可能でなければなりません" msgid "first argument must be a function" msgstr "1つ目の引数は関数でなければなりません" +#: extmod/ulab/code/ulab_create.c +msgid "first argument must be a tuple of ndarrays" +msgstr "" + #: extmod/ulab/code/ndarray.c msgid "first argument must be an iterable" msgstr "1つ目の引数はイテレート可能でなければなりません" @@ -2629,9 +2645,9 @@ msgstr "" msgid "function has the same sign at the ends of interval" msgstr "" -#: extmod/ulab/code/compare/compare.c -msgid "function is implemented for scalars and ndarrays only" -msgstr "スカラ値およびndarrayのみを受け取ります" +#: extmod/ulab/code/ndarray.c +msgid "function is defined for ndarrays only" +msgstr "" #: py/argcheck.c #, c-format @@ -2700,6 +2716,7 @@ msgstr "" msgid "index is out of bounds" msgstr "" +#: extmod/ulab/code/numerical/numerical.c #: ports/esp32s2/common-hal/pulseio/PulseIn.c py/obj.c msgid "index out of range" msgstr "インデクスが範囲外" @@ -2725,6 +2742,10 @@ msgstr "" msgid "inline assembler must be a function" msgstr "インラインアセンブラは関数でなければなりません" +#: extmod/ulab/code/ndarray.c +msgid "input and output shapes are not compatible" +msgstr "" + #: extmod/ulab/code/ulab_create.c msgid "input argument must be an integer or a 2-tuple" msgstr "" @@ -2733,6 +2754,10 @@ msgstr "" msgid "input array length must be power of 2" msgstr "入力array長は2の累乗でなければなりません" +#: extmod/ulab/code/ulab_create.c +msgid "input arrays are not compatible" +msgstr "" + #: extmod/ulab/code/poly/poly.c msgid "input data must be an iterable" msgstr "" @@ -2745,6 +2770,22 @@ msgstr "入力行列が非対称" msgid "input matrix is singular" msgstr "入力が非正則行列" +#: extmod/ulab/code/user/user.c +msgid "input must be a dense ndarray" +msgstr "" + +#: extmod/ulab/code/ulab_create.c +msgid "input must be a tensor of rank 2" +msgstr "" + +#: extmod/ulab/code/ulab_create.c extmod/ulab/code/user/user.c +msgid "input must be an ndarray" +msgstr "" + +#: extmod/ulab/code/filter/filter.c +msgid "input must be one-dimensional" +msgstr "" + #: extmod/ulab/code/linalg/linalg.c msgid "input must be square matrix" msgstr "入力は正方行列でなければなりません" @@ -2757,6 +2798,10 @@ msgstr "入力はtuple, list, range, ndarrayでなければなりません" msgid "input vectors must be of equal length" msgstr "" +#: extmod/ulab/code/poly/poly.c +msgid "inputs are not iterable" +msgstr "" + #: py/parsenum.c msgid "int() arg 2 must be >= 2 and <= 36" msgstr "int()の第2引数は2以上36以下でなければなりません" @@ -2925,6 +2970,10 @@ msgstr "" msgid "max_length must be > 0" msgstr "max_lengthは0より大きくなければなりません" +#: extmod/ulab/code/ndarray.c +msgid "maximum number of dimensions is 4" +msgstr "" + #: py/runtime.c msgid "maximum recursion depth exceeded" msgstr "最大の再帰深度を超えました" @@ -2974,10 +3023,6 @@ msgstr "" msgid "must use keyword argument for key function" msgstr "" -#: extmod/ulab/code/numerical/numerical.c -msgid "n must be between 0, and 9" -msgstr "nは0から9まで" - #: py/runtime.c msgid "name '%q' is not defined" msgstr "名前 '%q' は定義されていません" @@ -3060,6 +3105,10 @@ msgstr "*/** の後に非キーワード引数は置けません" msgid "non-keyword arg after keyword arg" msgstr "キーワード引数の後に非キーワード引数は置けません" +#: extmod/ulab/code/linalg/linalg.c +msgid "norm is defined for 1D and 2D arrays" +msgstr "" + #: shared-bindings/_bleio/UUID.c msgid "not a 128-bit UUID" msgstr "128ビットのUUIDではありません" @@ -3072,10 +3121,6 @@ msgstr "文字列書式化で全ての引数が使われていません" msgid "not enough arguments for format string" msgstr "書式化文字列への引数が足りません" -#: extmod/ulab/code/poly/poly.c -msgid "number of arguments must be 2, or 3" -msgstr "引数は2個または3個でなければなりません" - #: extmod/ulab/code/ulab_create.c msgid "number of points must be at least 2" msgstr "" @@ -3128,6 +3173,10 @@ msgstr "" msgid "odd-length string" msgstr "奇数長の文字列" +#: extmod/ulab/code/ulab_create.c +msgid "offset is too large" +msgstr "" + #: py/objstr.c py/objstrunicode.c msgid "offset out of bounds" msgstr "" @@ -3150,6 +3199,14 @@ msgstr "" msgid "operands could not be broadcast together" msgstr "" +#: extmod/ulab/code/ndarray.c +msgid "operation is implemented for 1D Boolean arrays only" +msgstr "" + +#: extmod/ulab/code/numerical/numerical.c +msgid "operation is not implemented for flattened array" +msgstr "" + #: extmod/ulab/code/numerical/numerical.c msgid "operation is not implemented on ndarrays" msgstr "この演算はndarray上で実装されていません" @@ -3286,6 +3343,10 @@ msgstr "相対インポート" msgid "requested length %d but object has length %d" msgstr "必要な長さは%dですがオブジェクトの長さは%d" +#: extmod/ulab/code/ndarray_operators.c +msgid "results cannot be cast to specified type" +msgstr "" + #: py/compile.c msgid "return annotation must be an identifier" msgstr "戻り値のアノテーションは識別子でなければなりません" @@ -3304,9 +3365,9 @@ msgstr "" msgid "rgb_pins[%d] is not on the same port as clock" msgstr "rgb_pins[%d]はクロックと同じポートではありません" -#: extmod/ulab/code/ndarray.c -msgid "right hand side must be an ndarray, or a scalar" -msgstr "右辺は ndarray またはスカラ値でなければなりません" +#: extmod/ulab/code/numerical/numerical.c +msgid "roll argument must be an ndarray" +msgstr "" #: py/objstr.c msgid "rsplit(None,n)" @@ -3332,8 +3393,8 @@ msgid "script compilation not supported" msgstr "スクリプトのコンパイルは非対応" #: extmod/ulab/code/ndarray.c -msgid "shape must be a 2-tuple" -msgstr "shapeは2値のタプルでなければなりません" +msgid "shape must be a tuple" +msgstr "" #: py/objstr.c msgid "sign not allowed in string format specifier" @@ -3375,10 +3436,6 @@ msgstr "ソフトリブート\n" msgid "sort argument must be an ndarray" msgstr "" -#: extmod/ulab/code/numerical/numerical.c -msgid "sorted axis can't be longer than 65535" -msgstr "" - #: extmod/ulab/code/filter/filter.c msgid "sos array must be of shape (n_section, 6)" msgstr "" @@ -3484,6 +3541,10 @@ msgstr "v2カードの待機がタイムアウトしました" msgid "timestamp out of range for platform time_t" msgstr "timestampがプラットフォームのtime_tの範囲外" +#: extmod/ulab/code/ndarray.c +msgid "tobytes can be invoked for dense arrays only" +msgstr "" + #: shared-module/struct/__init__.c msgid "too many arguments provided with the given format" msgstr "指定された書式に対して引数が多すぎます" @@ -3659,13 +3720,13 @@ msgstr "" msgid "window must be <= interval" msgstr "windowはinterval以下でなければなりません" -#: extmod/ulab/code/linalg/linalg.c -msgid "wrong argument type" -msgstr "引数の型が不正" +#: extmod/ulab/code/numerical/numerical.c +msgid "wrong axis index" +msgstr "" -#: extmod/ulab/code/ndarray.c -msgid "wrong index type" -msgstr "インデクスの型が不正" +#: extmod/ulab/code/ulab_create.c +msgid "wrong axis specified" +msgstr "" #: extmod/ulab/code/vector/vectorise.c msgid "wrong input type" @@ -3715,6 +3776,39 @@ msgstr "ziはfloat値でなければなりません" msgid "zi must be of shape (n_section, 2)" msgstr "" +#~ msgid "axis must be -1, 0, None, or 1" +#~ msgstr "axisは -1, 0, 1, None のいずれかでなければなりません" + +#~ msgid "axis must be -1, 0, or 1" +#~ msgstr "axisは -1, 0, 1 のいずれかでなければなりません" + +#~ msgid "axis must be None, 0, or 1" +#~ msgstr "axisは None, 0, 1 のいずれか" + +#~ msgid "cannot reshape array (incompatible input/output shape)" +#~ msgstr "入力/出力シェイプが互換でなくreshapeできません" + +#~ msgid "function is implemented for scalars and ndarrays only" +#~ msgstr "スカラ値およびndarrayのみを受け取ります" + +#~ msgid "n must be between 0, and 9" +#~ msgstr "nは0から9まで" + +#~ msgid "number of arguments must be 2, or 3" +#~ msgstr "引数は2個または3個でなければなりません" + +#~ msgid "right hand side must be an ndarray, or a scalar" +#~ msgstr "右辺は ndarray またはスカラ値でなければなりません" + +#~ msgid "shape must be a 2-tuple" +#~ msgstr "shapeは2値のタプルでなければなりません" + +#~ msgid "wrong argument type" +#~ msgstr "引数の型が不正" + +#~ msgid "wrong index type" +#~ msgstr "インデクスの型が不正" + #~ msgid "Must provide SCK pin" #~ msgstr "SCKピンが必要" diff --git a/locale/ko.po b/locale/ko.po index bfa49ab70c..a7967210d3 100644 --- a/locale/ko.po +++ b/locale/ko.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-11-10 15:30+0530\n" +"POT-Creation-Date: 2020-11-23 10:10-0600\n" "PO-Revision-Date: 2020-10-05 12:12+0000\n" "Last-Translator: Michal Čihař \n" "Language-Team: LANGUAGE \n" @@ -859,6 +859,10 @@ msgstr "" msgid "FFT is defined for ndarrays only" msgstr "" +#: extmod/ulab/code/fft/fft.c +msgid "FFT is implemented for linear arrays only" +msgstr "" + #: ports/esp32s2/common-hal/socketpool/Socket.c msgid "Failed SSL handshake" msgstr "" @@ -1956,7 +1960,7 @@ msgstr "" msgid "WARNING: Your code filename has two extensions\n" msgstr "" -#: shared-bindings/watchdog/WatchDogTimer.c +#: ports/nrf/common-hal/watchdog/WatchDogTimer.c msgid "WatchDogTimer cannot be deinitialized once mode is set to RESET" msgstr "" @@ -2035,10 +2039,6 @@ msgstr "" msgid "addresses is empty" msgstr "" -#: extmod/ulab/code/vector/vectorise.c -msgid "arctan2 is implemented for scalars and ndarrays only" -msgstr "" - #: py/modbuiltins.c msgid "arg is an empty sequence" msgstr "" @@ -2047,6 +2047,10 @@ msgstr "" msgid "argsort argument must be an ndarray" msgstr "" +#: extmod/ulab/code/numerical/numerical.c +msgid "argsort is not implemented for flattened arrays" +msgstr "" + #: py/runtime.c msgid "argument has wrong type" msgstr "" @@ -2064,14 +2068,22 @@ msgstr "" msgid "argument should be a '%q' not a '%q'" msgstr "" -#: extmod/ulab/code/linalg/linalg.c +#: extmod/ulab/code/linalg/linalg.c extmod/ulab/code/numerical/numerical.c msgid "arguments must be ndarrays" msgstr "" +#: extmod/ulab/code/ndarray.c +msgid "array and index length must be equal" +msgstr "" + #: py/objarray.c shared-bindings/nvm/ByteArray.c msgid "array/bytes required on right side" msgstr "" +#: extmod/ulab/code/numerical/numerical.c +msgid "attempt to get (arg)min/(arg)max of empty sequence" +msgstr "" + #: extmod/ulab/code/numerical/numerical.c msgid "attempt to get argmin/argmax of an empty sequence" msgstr "" @@ -2081,15 +2093,15 @@ msgid "attributes not supported yet" msgstr "" #: extmod/ulab/code/numerical/numerical.c -msgid "axis must be -1, 0, None, or 1" +msgid "axis is out of bounds" msgstr "" #: extmod/ulab/code/numerical/numerical.c -msgid "axis must be -1, 0, or 1" +msgid "axis must be None, or an integer" msgstr "" #: extmod/ulab/code/numerical/numerical.c -msgid "axis must be None, 0, or 1" +msgid "axis too long" msgstr "" #: py/builtinevex.c @@ -2293,6 +2305,10 @@ msgid "" "can't switch from manual field specification to automatic field numbering" msgstr "" +#: extmod/ulab/code/ndarray_operators.c +msgid "cannot cast output with casting rule" +msgstr "" + #: py/objtype.c msgid "cannot create '%q' instances" msgstr "" @@ -2309,10 +2325,6 @@ msgstr "" msgid "cannot perform relative import" msgstr "" -#: extmod/ulab/code/ndarray.c -msgid "cannot reshape array (incompatible input/output shape)" -msgstr "" - #: py/emitnative.c msgid "casting" msgstr "" @@ -2385,10 +2397,6 @@ msgstr "" msgid "convolve arguments must not be empty" msgstr "" -#: extmod/ulab/code/ndarray.c -msgid "could not broadast input array from shape" -msgstr "" - #: extmod/ulab/code/poly/poly.c msgid "could not invert Vandermonde matrix" msgstr "" @@ -2397,6 +2405,10 @@ msgstr "" msgid "couldn't determine SD card version" msgstr "" +#: extmod/ulab/code/numerical/numerical.c +msgid "cross is defined for 1D arrays of length 3" +msgstr "" + #: extmod/ulab/code/approx/approx.c msgid "data must be iterable" msgstr "" @@ -2405,10 +2417,6 @@ msgstr "" msgid "data must be of equal length" msgstr "" -#: extmod/ulab/code/numerical/numerical.c -msgid "ddof must be smaller than length of data set" -msgstr "" - #: py/parsenum.c msgid "decimal numbers not supported" msgstr "" @@ -2438,6 +2446,10 @@ msgstr "" msgid "diff argument must be an ndarray" msgstr "" +#: extmod/ulab/code/numerical/numerical.c +msgid "differentiation order out of range" +msgstr "" + #: py/modmath.c py/objfloat.c py/objint_longlong.c py/objint_mpz.c py/runtime.c #: shared-bindings/math/__init__.c msgid "division by zero" @@ -2553,6 +2565,10 @@ msgstr "" msgid "first argument must be a function" msgstr "" +#: extmod/ulab/code/ulab_create.c +msgid "first argument must be a tuple of ndarrays" +msgstr "" + #: extmod/ulab/code/ndarray.c msgid "first argument must be an iterable" msgstr "" @@ -2606,8 +2622,8 @@ msgstr "" msgid "function has the same sign at the ends of interval" msgstr "" -#: extmod/ulab/code/compare/compare.c -msgid "function is implemented for scalars and ndarrays only" +#: extmod/ulab/code/ndarray.c +msgid "function is defined for ndarrays only" msgstr "" #: py/argcheck.c @@ -2677,6 +2693,7 @@ msgstr "" msgid "index is out of bounds" msgstr "" +#: extmod/ulab/code/numerical/numerical.c #: ports/esp32s2/common-hal/pulseio/PulseIn.c py/obj.c msgid "index out of range" msgstr "" @@ -2701,6 +2718,10 @@ msgstr "" msgid "inline assembler must be a function" msgstr "" +#: extmod/ulab/code/ndarray.c +msgid "input and output shapes are not compatible" +msgstr "" + #: extmod/ulab/code/ulab_create.c msgid "input argument must be an integer or a 2-tuple" msgstr "" @@ -2709,6 +2730,10 @@ msgstr "" msgid "input array length must be power of 2" msgstr "" +#: extmod/ulab/code/ulab_create.c +msgid "input arrays are not compatible" +msgstr "" + #: extmod/ulab/code/poly/poly.c msgid "input data must be an iterable" msgstr "" @@ -2721,6 +2746,22 @@ msgstr "" msgid "input matrix is singular" msgstr "" +#: extmod/ulab/code/user/user.c +msgid "input must be a dense ndarray" +msgstr "" + +#: extmod/ulab/code/ulab_create.c +msgid "input must be a tensor of rank 2" +msgstr "" + +#: extmod/ulab/code/ulab_create.c extmod/ulab/code/user/user.c +msgid "input must be an ndarray" +msgstr "" + +#: extmod/ulab/code/filter/filter.c +msgid "input must be one-dimensional" +msgstr "" + #: extmod/ulab/code/linalg/linalg.c msgid "input must be square matrix" msgstr "" @@ -2733,6 +2774,10 @@ msgstr "" msgid "input vectors must be of equal length" msgstr "" +#: extmod/ulab/code/poly/poly.c +msgid "inputs are not iterable" +msgstr "" + #: py/parsenum.c msgid "int() arg 2 must be >= 2 and <= 36" msgstr "" @@ -2901,6 +2946,10 @@ msgstr "" msgid "max_length must be > 0" msgstr "" +#: extmod/ulab/code/ndarray.c +msgid "maximum number of dimensions is 4" +msgstr "" + #: py/runtime.c msgid "maximum recursion depth exceeded" msgstr "" @@ -2950,10 +2999,6 @@ msgstr "" msgid "must use keyword argument for key function" msgstr "" -#: extmod/ulab/code/numerical/numerical.c -msgid "n must be between 0, and 9" -msgstr "" - #: py/runtime.c msgid "name '%q' is not defined" msgstr "" @@ -3036,6 +3081,10 @@ msgstr "" msgid "non-keyword arg after keyword arg" msgstr "" +#: extmod/ulab/code/linalg/linalg.c +msgid "norm is defined for 1D and 2D arrays" +msgstr "" + #: shared-bindings/_bleio/UUID.c msgid "not a 128-bit UUID" msgstr "" @@ -3048,10 +3097,6 @@ msgstr "" msgid "not enough arguments for format string" msgstr "" -#: extmod/ulab/code/poly/poly.c -msgid "number of arguments must be 2, or 3" -msgstr "" - #: extmod/ulab/code/ulab_create.c msgid "number of points must be at least 2" msgstr "" @@ -3104,6 +3149,10 @@ msgstr "" msgid "odd-length string" msgstr "" +#: extmod/ulab/code/ulab_create.c +msgid "offset is too large" +msgstr "" + #: py/objstr.c py/objstrunicode.c msgid "offset out of bounds" msgstr "" @@ -3126,6 +3175,14 @@ msgstr "" msgid "operands could not be broadcast together" msgstr "" +#: extmod/ulab/code/ndarray.c +msgid "operation is implemented for 1D Boolean arrays only" +msgstr "" + +#: extmod/ulab/code/numerical/numerical.c +msgid "operation is not implemented for flattened array" +msgstr "" + #: extmod/ulab/code/numerical/numerical.c msgid "operation is not implemented on ndarrays" msgstr "" @@ -3260,6 +3317,10 @@ msgstr "" msgid "requested length %d but object has length %d" msgstr "" +#: extmod/ulab/code/ndarray_operators.c +msgid "results cannot be cast to specified type" +msgstr "" + #: py/compile.c msgid "return annotation must be an identifier" msgstr "" @@ -3278,8 +3339,8 @@ msgstr "" msgid "rgb_pins[%d] is not on the same port as clock" msgstr "" -#: extmod/ulab/code/ndarray.c -msgid "right hand side must be an ndarray, or a scalar" +#: extmod/ulab/code/numerical/numerical.c +msgid "roll argument must be an ndarray" msgstr "" #: py/objstr.c @@ -3305,7 +3366,7 @@ msgid "script compilation not supported" msgstr "" #: extmod/ulab/code/ndarray.c -msgid "shape must be a 2-tuple" +msgid "shape must be a tuple" msgstr "" #: py/objstr.c @@ -3348,10 +3409,6 @@ msgstr "" msgid "sort argument must be an ndarray" msgstr "" -#: extmod/ulab/code/numerical/numerical.c -msgid "sorted axis can't be longer than 65535" -msgstr "" - #: extmod/ulab/code/filter/filter.c msgid "sos array must be of shape (n_section, 6)" msgstr "" @@ -3457,6 +3514,10 @@ msgstr "" msgid "timestamp out of range for platform time_t" msgstr "" +#: extmod/ulab/code/ndarray.c +msgid "tobytes can be invoked for dense arrays only" +msgstr "" + #: shared-module/struct/__init__.c msgid "too many arguments provided with the given format" msgstr "" @@ -3632,12 +3693,12 @@ msgstr "" msgid "window must be <= interval" msgstr "" -#: extmod/ulab/code/linalg/linalg.c -msgid "wrong argument type" +#: extmod/ulab/code/numerical/numerical.c +msgid "wrong axis index" msgstr "" -#: extmod/ulab/code/ndarray.c -msgid "wrong index type" +#: extmod/ulab/code/ulab_create.c +msgid "wrong axis specified" msgstr "" #: extmod/ulab/code/vector/vectorise.c diff --git a/locale/nl.po b/locale/nl.po index 7625cdb26b..f9847fd81f 100644 --- a/locale/nl.po +++ b/locale/nl.po @@ -5,7 +5,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-11-10 15:30+0530\n" +"POT-Creation-Date: 2020-11-23 10:10-0600\n" "PO-Revision-Date: 2020-10-27 16:47+0000\n" "Last-Translator: Jelle Jager \n" "Language-Team: none\n" @@ -867,6 +867,10 @@ msgstr "Extended advertisements met scan antwoord niet ondersteund." msgid "FFT is defined for ndarrays only" msgstr "FFT alleen voor ndarrays gedefineerd" +#: extmod/ulab/code/fft/fft.c +msgid "FFT is implemented for linear arrays only" +msgstr "" + #: ports/esp32s2/common-hal/socketpool/Socket.c msgid "Failed SSL handshake" msgstr "SSL handdruk mislukt" @@ -1997,7 +2001,7 @@ msgstr "Voltage lees time-out" msgid "WARNING: Your code filename has two extensions\n" msgstr "WAARSCHUWING: De bestandsnaam van de code heeft twee extensies\n" -#: shared-bindings/watchdog/WatchDogTimer.c +#: ports/nrf/common-hal/watchdog/WatchDogTimer.c msgid "WatchDogTimer cannot be deinitialized once mode is set to RESET" msgstr "" "WatchDogTimer kan niet worden gedeïnitialiseerd zodra de modus in ingesteld " @@ -2085,10 +2089,6 @@ msgstr "adres buiten bereik" msgid "addresses is empty" msgstr "adressen zijn leeg" -#: extmod/ulab/code/vector/vectorise.c -msgid "arctan2 is implemented for scalars and ndarrays only" -msgstr "arctan2 is alleen geïmplementeerd voor scalars en ndarrays" - #: py/modbuiltins.c msgid "arg is an empty sequence" msgstr "arg is een lege sequentie" @@ -2097,6 +2097,10 @@ msgstr "arg is een lege sequentie" msgid "argsort argument must be an ndarray" msgstr "argsort argument moet een ndarray zijn" +#: extmod/ulab/code/numerical/numerical.c +msgid "argsort is not implemented for flattened arrays" +msgstr "" + #: py/runtime.c msgid "argument has wrong type" msgstr "argument heeft onjuist type" @@ -2114,14 +2118,22 @@ msgstr "argument num/typen komen niet overeen" msgid "argument should be a '%q' not a '%q'" msgstr "argument moet een '%q' zijn en niet een '%q'" -#: extmod/ulab/code/linalg/linalg.c +#: extmod/ulab/code/linalg/linalg.c extmod/ulab/code/numerical/numerical.c msgid "arguments must be ndarrays" msgstr "argumenten moeten ndarrays zijn" +#: extmod/ulab/code/ndarray.c +msgid "array and index length must be equal" +msgstr "" + #: py/objarray.c shared-bindings/nvm/ByteArray.c msgid "array/bytes required on right side" msgstr "array/bytes vereist aan de rechterkant" +#: extmod/ulab/code/numerical/numerical.c +msgid "attempt to get (arg)min/(arg)max of empty sequence" +msgstr "" + #: extmod/ulab/code/numerical/numerical.c msgid "attempt to get argmin/argmax of an empty sequence" msgstr "poging om argmin/argmax van een lege sequentie te krijgen" @@ -2131,16 +2143,16 @@ msgid "attributes not supported yet" msgstr "attributen nog niet ondersteund" #: extmod/ulab/code/numerical/numerical.c -msgid "axis must be -1, 0, None, or 1" -msgstr "as moet -1, 0, None, of 1 zijn" +msgid "axis is out of bounds" +msgstr "" #: extmod/ulab/code/numerical/numerical.c -msgid "axis must be -1, 0, or 1" -msgstr "as moet -1, 0, of 1 zijn" +msgid "axis must be None, or an integer" +msgstr "" #: extmod/ulab/code/numerical/numerical.c -msgid "axis must be None, 0, or 1" -msgstr "as moet None, 0, of 1 zijn" +msgid "axis too long" +msgstr "" #: py/builtinevex.c msgid "bad compile mode" @@ -2344,6 +2356,10 @@ msgid "" "can't switch from manual field specification to automatic field numbering" msgstr "kan niet schakelen tussen handmatige en automatische veld specificatie" +#: extmod/ulab/code/ndarray_operators.c +msgid "cannot cast output with casting rule" +msgstr "" + #: py/objtype.c msgid "cannot create '%q' instances" msgstr "kan geen instanties van '%q' creëren" @@ -2360,10 +2376,6 @@ msgstr "kan naam %q niet importeren" msgid "cannot perform relative import" msgstr "kan geen relatieve import uitvoeren" -#: extmod/ulab/code/ndarray.c -msgid "cannot reshape array (incompatible input/output shape)" -msgstr "kan de array niet hervormen (niet verenigbare input/output vorm)" - #: py/emitnative.c msgid "casting" msgstr "casting" @@ -2437,10 +2449,6 @@ msgstr "convolutie argumenten moeten ndarrays zijn" msgid "convolve arguments must not be empty" msgstr "convolutie argumenten mogen niet leeg zijn" -#: extmod/ulab/code/ndarray.c -msgid "could not broadast input array from shape" -msgstr "kon de invoerarray niet vanuit vorm uitzenden" - #: extmod/ulab/code/poly/poly.c msgid "could not invert Vandermonde matrix" msgstr "kon de Vandermonde matrix niet omkeren" @@ -2449,6 +2457,10 @@ msgstr "kon de Vandermonde matrix niet omkeren" msgid "couldn't determine SD card version" msgstr "kon SD kaart versie niet bepalen" +#: extmod/ulab/code/numerical/numerical.c +msgid "cross is defined for 1D arrays of length 3" +msgstr "" + #: extmod/ulab/code/approx/approx.c msgid "data must be iterable" msgstr "data moet itereerbaar zijn" @@ -2457,10 +2469,6 @@ msgstr "data moet itereerbaar zijn" msgid "data must be of equal length" msgstr "data moet van gelijke lengte zijn" -#: extmod/ulab/code/numerical/numerical.c -msgid "ddof must be smaller than length of data set" -msgstr "ddof kleiner dan de lengte van de data set" - #: py/parsenum.c msgid "decimal numbers not supported" msgstr "decimale getallen zijn niet ondersteund" @@ -2492,6 +2500,10 @@ msgstr "dict update sequence heeft de verkeerde lengte" msgid "diff argument must be an ndarray" msgstr "diff argument moet een ndarray zijn" +#: extmod/ulab/code/numerical/numerical.c +msgid "differentiation order out of range" +msgstr "" + #: py/modmath.c py/objfloat.c py/objint_longlong.c py/objint_mpz.c py/runtime.c #: shared-bindings/math/__init__.c msgid "division by zero" @@ -2607,6 +2619,10 @@ msgstr "eerste argument moet een aanroepbare (callable) zijn" msgid "first argument must be a function" msgstr "eerste argument moet een functie zijn" +#: extmod/ulab/code/ulab_create.c +msgid "first argument must be a tuple of ndarrays" +msgstr "" + #: extmod/ulab/code/ndarray.c msgid "first argument must be an iterable" msgstr "eerst argument moet een iterabel zijn" @@ -2660,9 +2676,9 @@ msgstr "functie kreeg meedere waarden voor argument '%q'" msgid "function has the same sign at the ends of interval" msgstr "functie heeft hetzelfde teken aan beide uiteinden van het interval" -#: extmod/ulab/code/compare/compare.c -msgid "function is implemented for scalars and ndarrays only" -msgstr "funtie is alleen geïmplementeerd voor scalars en ndarrays" +#: extmod/ulab/code/ndarray.c +msgid "function is defined for ndarrays only" +msgstr "" #: py/argcheck.c #, c-format @@ -2732,6 +2748,7 @@ msgstr "vulling (padding) is onjuist" msgid "index is out of bounds" msgstr "index is buiten bereik" +#: extmod/ulab/code/numerical/numerical.c #: ports/esp32s2/common-hal/pulseio/PulseIn.c py/obj.c msgid "index out of range" msgstr "index is buiten bereik" @@ -2756,6 +2773,10 @@ msgstr "lengte van initial_value is onjuist" msgid "inline assembler must be a function" msgstr "inline assembler moet een functie zijn" +#: extmod/ulab/code/ndarray.c +msgid "input and output shapes are not compatible" +msgstr "" + #: extmod/ulab/code/ulab_create.c msgid "input argument must be an integer or a 2-tuple" msgstr "invoerargument moet een integer of 2-tuple zijn" @@ -2764,6 +2785,10 @@ msgstr "invoerargument moet een integer of 2-tuple zijn" msgid "input array length must be power of 2" msgstr "invoer array lengte moet een macht van 2 zijn" +#: extmod/ulab/code/ulab_create.c +msgid "input arrays are not compatible" +msgstr "" + #: extmod/ulab/code/poly/poly.c msgid "input data must be an iterable" msgstr "invoerdata moet itereerbaar zijn" @@ -2776,6 +2801,22 @@ msgstr "invoermatrix is asymmetrisch" msgid "input matrix is singular" msgstr "invoermatrix is singulier" +#: extmod/ulab/code/user/user.c +msgid "input must be a dense ndarray" +msgstr "" + +#: extmod/ulab/code/ulab_create.c +msgid "input must be a tensor of rank 2" +msgstr "" + +#: extmod/ulab/code/ulab_create.c extmod/ulab/code/user/user.c +msgid "input must be an ndarray" +msgstr "" + +#: extmod/ulab/code/filter/filter.c +msgid "input must be one-dimensional" +msgstr "" + #: extmod/ulab/code/linalg/linalg.c msgid "input must be square matrix" msgstr "invoer moet een vierkante matrix zijn" @@ -2788,6 +2829,10 @@ msgstr "invoer moet een tuple, lijst, bereik of ndarray zijn" msgid "input vectors must be of equal length" msgstr "invoervectors moeten van gelijke lengte zijn" +#: extmod/ulab/code/poly/poly.c +msgid "inputs are not iterable" +msgstr "" + #: py/parsenum.c msgid "int() arg 2 must be >= 2 and <= 36" msgstr "int() argument 2 moet >=2 en <= 36 zijn" @@ -2959,6 +3004,10 @@ msgstr "max_length moet 0-%d zijn als fixed_length %s is" msgid "max_length must be > 0" msgstr "max_length moet >0 zijn" +#: extmod/ulab/code/ndarray.c +msgid "maximum number of dimensions is 4" +msgstr "" + #: py/runtime.c msgid "maximum recursion depth exceeded" msgstr "maximale recursiediepte overschreden" @@ -3008,10 +3057,6 @@ msgstr "moet een object oproepen (raise)" msgid "must use keyword argument for key function" msgstr "voor sleutelfunctie moet een trefwoordargument gebruikt worden" -#: extmod/ulab/code/numerical/numerical.c -msgid "n must be between 0, and 9" -msgstr "n moet tussen 0 en 9 liggen" - #: py/runtime.c msgid "name '%q' is not defined" msgstr "naam '%q' is niet gedefinieerd" @@ -3094,6 +3139,10 @@ msgstr "niet-trefwoord argument na */**" msgid "non-keyword arg after keyword arg" msgstr "niet-trefwoord argument na trefwoord argument" +#: extmod/ulab/code/linalg/linalg.c +msgid "norm is defined for 1D and 2D arrays" +msgstr "" + #: shared-bindings/_bleio/UUID.c msgid "not a 128-bit UUID" msgstr "geen 128-bit UUID" @@ -3106,10 +3155,6 @@ msgstr "niet alle argumenten omgezet bij formattering van string" msgid "not enough arguments for format string" msgstr "niet genoeg argumenten om string te formatteren" -#: extmod/ulab/code/poly/poly.c -msgid "number of arguments must be 2, or 3" -msgstr "aantal argumenten moet 2 of 3 zijn" - #: extmod/ulab/code/ulab_create.c msgid "number of points must be at least 2" msgstr "aantal punten moet minimaal 2 zijn" @@ -3162,6 +3207,10 @@ msgstr "object met buffer protocol vereist" msgid "odd-length string" msgstr "string met oneven lengte" +#: extmod/ulab/code/ulab_create.c +msgid "offset is too large" +msgstr "" + #: py/objstr.c py/objstrunicode.c msgid "offset out of bounds" msgstr "offset buiten bereik" @@ -3184,6 +3233,14 @@ msgstr "alleen segmenten met step=1 (ook wel None) worden ondersteund" msgid "operands could not be broadcast together" msgstr "operands konden niet samen verzonden worden" +#: extmod/ulab/code/ndarray.c +msgid "operation is implemented for 1D Boolean arrays only" +msgstr "" + +#: extmod/ulab/code/numerical/numerical.c +msgid "operation is not implemented for flattened array" +msgstr "" + #: extmod/ulab/code/numerical/numerical.c msgid "operation is not implemented on ndarrays" msgstr "bewerking is voor ndarrays niet geïmplementeerd" @@ -3319,6 +3376,10 @@ msgstr "relatieve import" msgid "requested length %d but object has length %d" msgstr "gevraagde lengte is %d maar object heeft lengte %d" +#: extmod/ulab/code/ndarray_operators.c +msgid "results cannot be cast to specified type" +msgstr "" + #: py/compile.c msgid "return annotation must be an identifier" msgstr "return annotatie moet een identifier zijn" @@ -3337,9 +3398,9 @@ msgstr "rgb_pins[%d] is hetzelfde als een andere pintoewijzing" msgid "rgb_pins[%d] is not on the same port as clock" msgstr "rgb_pins[%d] bevindt zich niet op dezelfde poort als klok" -#: extmod/ulab/code/ndarray.c -msgid "right hand side must be an ndarray, or a scalar" -msgstr "de rechterkant moet een ndarray of scalar zijn" +#: extmod/ulab/code/numerical/numerical.c +msgid "roll argument must be an ndarray" +msgstr "" #: py/objstr.c msgid "rsplit(None,n)" @@ -3366,8 +3427,8 @@ msgid "script compilation not supported" msgstr "scriptcompilatie wordt niet ondersteund" #: extmod/ulab/code/ndarray.c -msgid "shape must be a 2-tuple" -msgstr "vorm moet een 2-tuple zijn" +msgid "shape must be a tuple" +msgstr "" #: py/objstr.c msgid "sign not allowed in string format specifier" @@ -3409,10 +3470,6 @@ msgstr "zachte herstart\n" msgid "sort argument must be an ndarray" msgstr "sorteerargument moet een ndarray zijn" -#: extmod/ulab/code/numerical/numerical.c -msgid "sorted axis can't be longer than 65535" -msgstr "" - #: extmod/ulab/code/filter/filter.c msgid "sos array must be of shape (n_section, 6)" msgstr "sos array moet vorm (n_section, 6) hebben" @@ -3518,6 +3575,10 @@ msgstr "timeout bij wachten op v2 kaart" msgid "timestamp out of range for platform time_t" msgstr "timestamp buiten bereik voor platform time_t" +#: extmod/ulab/code/ndarray.c +msgid "tobytes can be invoked for dense arrays only" +msgstr "" + #: shared-module/struct/__init__.c msgid "too many arguments provided with the given format" msgstr "te veel argumenten opgegeven bij dit formaat" @@ -3693,13 +3754,13 @@ msgstr "breedte moet groter dan nul zijn" msgid "window must be <= interval" msgstr "window moet <= interval zijn" -#: extmod/ulab/code/linalg/linalg.c -msgid "wrong argument type" -msgstr "onjuist argumenttype" +#: extmod/ulab/code/numerical/numerical.c +msgid "wrong axis index" +msgstr "" -#: extmod/ulab/code/ndarray.c -msgid "wrong index type" -msgstr "onjuist indextype" +#: extmod/ulab/code/ulab_create.c +msgid "wrong axis specified" +msgstr "" #: extmod/ulab/code/vector/vectorise.c msgid "wrong input type" @@ -3749,6 +3810,48 @@ msgstr "zi moet van type float zijn" msgid "zi must be of shape (n_section, 2)" msgstr "zi moet vorm (n_section, 2) hebben" +#~ msgid "arctan2 is implemented for scalars and ndarrays only" +#~ msgstr "arctan2 is alleen geïmplementeerd voor scalars en ndarrays" + +#~ msgid "axis must be -1, 0, None, or 1" +#~ msgstr "as moet -1, 0, None, of 1 zijn" + +#~ msgid "axis must be -1, 0, or 1" +#~ msgstr "as moet -1, 0, of 1 zijn" + +#~ msgid "axis must be None, 0, or 1" +#~ msgstr "as moet None, 0, of 1 zijn" + +#~ msgid "cannot reshape array (incompatible input/output shape)" +#~ msgstr "kan de array niet hervormen (niet verenigbare input/output vorm)" + +#~ msgid "could not broadast input array from shape" +#~ msgstr "kon de invoerarray niet vanuit vorm uitzenden" + +#~ msgid "ddof must be smaller than length of data set" +#~ msgstr "ddof kleiner dan de lengte van de data set" + +#~ msgid "function is implemented for scalars and ndarrays only" +#~ msgstr "funtie is alleen geïmplementeerd voor scalars en ndarrays" + +#~ msgid "n must be between 0, and 9" +#~ msgstr "n moet tussen 0 en 9 liggen" + +#~ msgid "number of arguments must be 2, or 3" +#~ msgstr "aantal argumenten moet 2 of 3 zijn" + +#~ msgid "right hand side must be an ndarray, or a scalar" +#~ msgstr "de rechterkant moet een ndarray of scalar zijn" + +#~ msgid "shape must be a 2-tuple" +#~ msgstr "vorm moet een 2-tuple zijn" + +#~ msgid "wrong argument type" +#~ msgstr "onjuist argumenttype" + +#~ msgid "wrong index type" +#~ msgstr "onjuist indextype" + #~ msgid "Must provide SCK pin" #~ msgstr "SCK pin moet opgegeven worden" diff --git a/locale/pl.po b/locale/pl.po index f04887e682..1873af488f 100644 --- a/locale/pl.po +++ b/locale/pl.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-11-10 15:30+0530\n" +"POT-Creation-Date: 2020-11-23 10:10-0600\n" "PO-Revision-Date: 2020-11-11 19:13+0000\n" "Last-Translator: Maciej Stankiewicz \n" "Language-Team: pl\n" @@ -867,6 +867,10 @@ msgstr "" msgid "FFT is defined for ndarrays only" msgstr "" +#: extmod/ulab/code/fft/fft.c +msgid "FFT is implemented for linear arrays only" +msgstr "" + #: ports/esp32s2/common-hal/socketpool/Socket.c msgid "Failed SSL handshake" msgstr "" @@ -1966,7 +1970,7 @@ msgstr "" msgid "WARNING: Your code filename has two extensions\n" msgstr "UWAGA: Nazwa pliku ma dwa rozszerzenia\n" -#: shared-bindings/watchdog/WatchDogTimer.c +#: ports/nrf/common-hal/watchdog/WatchDogTimer.c msgid "WatchDogTimer cannot be deinitialized once mode is set to RESET" msgstr "" @@ -2051,10 +2055,6 @@ msgstr "adres poza zakresem" msgid "addresses is empty" msgstr "adres jest pusty" -#: extmod/ulab/code/vector/vectorise.c -msgid "arctan2 is implemented for scalars and ndarrays only" -msgstr "" - #: py/modbuiltins.c msgid "arg is an empty sequence" msgstr "arg jest puste" @@ -2063,6 +2063,10 @@ msgstr "arg jest puste" msgid "argsort argument must be an ndarray" msgstr "" +#: extmod/ulab/code/numerical/numerical.c +msgid "argsort is not implemented for flattened arrays" +msgstr "" + #: py/runtime.c msgid "argument has wrong type" msgstr "argument ma zły typ" @@ -2080,14 +2084,22 @@ msgstr "zła liczba lub typ argumentów" msgid "argument should be a '%q' not a '%q'" msgstr "argument powinien być '%q' a nie '%q'" -#: extmod/ulab/code/linalg/linalg.c +#: extmod/ulab/code/linalg/linalg.c extmod/ulab/code/numerical/numerical.c msgid "arguments must be ndarrays" msgstr "" +#: extmod/ulab/code/ndarray.c +msgid "array and index length must be equal" +msgstr "" + #: py/objarray.c shared-bindings/nvm/ByteArray.c msgid "array/bytes required on right side" msgstr "tablica/bytes wymagane po prawej stronie" +#: extmod/ulab/code/numerical/numerical.c +msgid "attempt to get (arg)min/(arg)max of empty sequence" +msgstr "" + #: extmod/ulab/code/numerical/numerical.c msgid "attempt to get argmin/argmax of an empty sequence" msgstr "" @@ -2097,15 +2109,15 @@ msgid "attributes not supported yet" msgstr "atrybuty nie są jeszcze obsługiwane" #: extmod/ulab/code/numerical/numerical.c -msgid "axis must be -1, 0, None, or 1" +msgid "axis is out of bounds" msgstr "" #: extmod/ulab/code/numerical/numerical.c -msgid "axis must be -1, 0, or 1" +msgid "axis must be None, or an integer" msgstr "" #: extmod/ulab/code/numerical/numerical.c -msgid "axis must be None, 0, or 1" +msgid "axis too long" msgstr "" #: py/builtinevex.c @@ -2309,6 +2321,10 @@ msgid "" "can't switch from manual field specification to automatic field numbering" msgstr "nie można zmienić z ręcznego numerowaniu pól do automatycznego" +#: extmod/ulab/code/ndarray_operators.c +msgid "cannot cast output with casting rule" +msgstr "" + #: py/objtype.c msgid "cannot create '%q' instances" msgstr "nie można tworzyć instancji '%q'" @@ -2325,10 +2341,6 @@ msgstr "nie można zaimportować nazwy %q" msgid "cannot perform relative import" msgstr "nie można wykonać relatywnego importu" -#: extmod/ulab/code/ndarray.c -msgid "cannot reshape array (incompatible input/output shape)" -msgstr "" - #: py/emitnative.c msgid "casting" msgstr "rzutowanie" @@ -2401,10 +2413,6 @@ msgstr "" msgid "convolve arguments must not be empty" msgstr "" -#: extmod/ulab/code/ndarray.c -msgid "could not broadast input array from shape" -msgstr "" - #: extmod/ulab/code/poly/poly.c msgid "could not invert Vandermonde matrix" msgstr "" @@ -2413,6 +2421,10 @@ msgstr "" msgid "couldn't determine SD card version" msgstr "nie można określić wersji karty SD" +#: extmod/ulab/code/numerical/numerical.c +msgid "cross is defined for 1D arrays of length 3" +msgstr "" + #: extmod/ulab/code/approx/approx.c msgid "data must be iterable" msgstr "" @@ -2421,10 +2433,6 @@ msgstr "" msgid "data must be of equal length" msgstr "" -#: extmod/ulab/code/numerical/numerical.c -msgid "ddof must be smaller than length of data set" -msgstr "" - #: py/parsenum.c msgid "decimal numbers not supported" msgstr "liczby dziesiętne nieobsługiwane" @@ -2455,6 +2463,10 @@ msgstr "sekwencja ma złą długość" msgid "diff argument must be an ndarray" msgstr "" +#: extmod/ulab/code/numerical/numerical.c +msgid "differentiation order out of range" +msgstr "" + #: py/modmath.c py/objfloat.c py/objint_longlong.c py/objint_mpz.c py/runtime.c #: shared-bindings/math/__init__.c msgid "division by zero" @@ -2570,6 +2582,10 @@ msgstr "" msgid "first argument must be a function" msgstr "pierwszy argument musi być funkcją" +#: extmod/ulab/code/ulab_create.c +msgid "first argument must be a tuple of ndarrays" +msgstr "" + #: extmod/ulab/code/ndarray.c msgid "first argument must be an iterable" msgstr "pierwszy argument musi być iterowalny" @@ -2623,8 +2639,8 @@ msgstr "funkcja dostała wiele wartości dla argumentu '%q'" msgid "function has the same sign at the ends of interval" msgstr "" -#: extmod/ulab/code/compare/compare.c -msgid "function is implemented for scalars and ndarrays only" +#: extmod/ulab/code/ndarray.c +msgid "function is defined for ndarrays only" msgstr "" #: py/argcheck.c @@ -2694,6 +2710,7 @@ msgstr "złe wypełnienie" msgid "index is out of bounds" msgstr "indeks jest poza zakresem" +#: extmod/ulab/code/numerical/numerical.c #: ports/esp32s2/common-hal/pulseio/PulseIn.c py/obj.c msgid "index out of range" msgstr "indeks poza zakresem" @@ -2718,6 +2735,10 @@ msgstr "długość initial_value jest nieprawidłowa" msgid "inline assembler must be a function" msgstr "wtrącony asembler musi być funkcją" +#: extmod/ulab/code/ndarray.c +msgid "input and output shapes are not compatible" +msgstr "" + #: extmod/ulab/code/ulab_create.c msgid "input argument must be an integer or a 2-tuple" msgstr "" @@ -2726,6 +2747,10 @@ msgstr "" msgid "input array length must be power of 2" msgstr "długość tablicy wejściowej musi być potęgą 2" +#: extmod/ulab/code/ulab_create.c +msgid "input arrays are not compatible" +msgstr "" + #: extmod/ulab/code/poly/poly.c msgid "input data must be an iterable" msgstr "" @@ -2738,6 +2763,22 @@ msgstr "" msgid "input matrix is singular" msgstr "" +#: extmod/ulab/code/user/user.c +msgid "input must be a dense ndarray" +msgstr "" + +#: extmod/ulab/code/ulab_create.c +msgid "input must be a tensor of rank 2" +msgstr "" + +#: extmod/ulab/code/ulab_create.c extmod/ulab/code/user/user.c +msgid "input must be an ndarray" +msgstr "" + +#: extmod/ulab/code/filter/filter.c +msgid "input must be one-dimensional" +msgstr "" + #: extmod/ulab/code/linalg/linalg.c msgid "input must be square matrix" msgstr "wejście musi być macierzą kwadratową" @@ -2750,6 +2791,10 @@ msgstr "" msgid "input vectors must be of equal length" msgstr "wektory wejściowe muszą być równej długości" +#: extmod/ulab/code/poly/poly.c +msgid "inputs are not iterable" +msgstr "" + #: py/parsenum.c msgid "int() arg 2 must be >= 2 and <= 36" msgstr "argument 2 do int() busi być pomiędzy 2 a 36" @@ -2918,6 +2963,10 @@ msgstr "" msgid "max_length must be > 0" msgstr "max_length musi być > 0" +#: extmod/ulab/code/ndarray.c +msgid "maximum number of dimensions is 4" +msgstr "" + #: py/runtime.c msgid "maximum recursion depth exceeded" msgstr "przekroczono dozwoloną głębokość rekurencji" @@ -2967,10 +3016,6 @@ msgstr "wyjątek musi być obiektem" msgid "must use keyword argument for key function" msgstr "funkcja key musi być podana jako argument nazwany" -#: extmod/ulab/code/numerical/numerical.c -msgid "n must be between 0, and 9" -msgstr "" - #: py/runtime.c msgid "name '%q' is not defined" msgstr "nazwa '%q' niezdefiniowana" @@ -3053,6 +3098,10 @@ msgstr "argument nienazwany po */**" msgid "non-keyword arg after keyword arg" msgstr "argument nienazwany po nazwanym" +#: extmod/ulab/code/linalg/linalg.c +msgid "norm is defined for 1D and 2D arrays" +msgstr "" + #: shared-bindings/_bleio/UUID.c msgid "not a 128-bit UUID" msgstr "to nie jest 128-bitowy UUID" @@ -3065,10 +3114,6 @@ msgstr "nie wszystkie argumenty wykorzystane w formatowaniu" msgid "not enough arguments for format string" msgstr "nie dość argumentów przy formatowaniu" -#: extmod/ulab/code/poly/poly.c -msgid "number of arguments must be 2, or 3" -msgstr "liczba argumentów musi wynosić 2 lub 3" - #: extmod/ulab/code/ulab_create.c msgid "number of points must be at least 2" msgstr "liczba punktów musi wynosić co najmniej 2" @@ -3121,6 +3166,10 @@ msgstr "wymagany obiekt z protokołem buforu" msgid "odd-length string" msgstr "łańcuch o nieparzystej długości" +#: extmod/ulab/code/ulab_create.c +msgid "offset is too large" +msgstr "" + #: py/objstr.c py/objstrunicode.c msgid "offset out of bounds" msgstr "offset poza zakresem" @@ -3143,6 +3192,14 @@ msgstr "tylko fragmenty ze step=1 (lub None) są wspierane" msgid "operands could not be broadcast together" msgstr "" +#: extmod/ulab/code/ndarray.c +msgid "operation is implemented for 1D Boolean arrays only" +msgstr "" + +#: extmod/ulab/code/numerical/numerical.c +msgid "operation is not implemented for flattened array" +msgstr "" + #: extmod/ulab/code/numerical/numerical.c msgid "operation is not implemented on ndarrays" msgstr "" @@ -3278,6 +3335,10 @@ msgstr "relatywny import" msgid "requested length %d but object has length %d" msgstr "zażądano długości %d ale obiekt ma długość %d" +#: extmod/ulab/code/ndarray_operators.c +msgid "results cannot be cast to specified type" +msgstr "" + #: py/compile.c msgid "return annotation must be an identifier" msgstr "anotacja wartości musi być identyfikatorem" @@ -3296,8 +3357,8 @@ msgstr "" msgid "rgb_pins[%d] is not on the same port as clock" msgstr "" -#: extmod/ulab/code/ndarray.c -msgid "right hand side must be an ndarray, or a scalar" +#: extmod/ulab/code/numerical/numerical.c +msgid "roll argument must be an ndarray" msgstr "" #: py/objstr.c @@ -3324,7 +3385,7 @@ msgid "script compilation not supported" msgstr "kompilowanie skryptów nieobsługiwane" #: extmod/ulab/code/ndarray.c -msgid "shape must be a 2-tuple" +msgid "shape must be a tuple" msgstr "" #: py/objstr.c @@ -3367,10 +3428,6 @@ msgstr "programowy reset\n" msgid "sort argument must be an ndarray" msgstr "" -#: extmod/ulab/code/numerical/numerical.c -msgid "sorted axis can't be longer than 65535" -msgstr "" - #: extmod/ulab/code/filter/filter.c msgid "sos array must be of shape (n_section, 6)" msgstr "" @@ -3476,6 +3533,10 @@ msgstr "" msgid "timestamp out of range for platform time_t" msgstr "timestamp poza zakresem dla time_t na tej platformie" +#: extmod/ulab/code/ndarray.c +msgid "tobytes can be invoked for dense arrays only" +msgstr "" + #: shared-module/struct/__init__.c msgid "too many arguments provided with the given format" msgstr "zbyt wiele argumentów podanych dla tego formatu" @@ -3651,13 +3712,13 @@ msgstr "" msgid "window must be <= interval" msgstr "" -#: extmod/ulab/code/linalg/linalg.c -msgid "wrong argument type" -msgstr "zły typ argumentu" +#: extmod/ulab/code/numerical/numerical.c +msgid "wrong axis index" +msgstr "" -#: extmod/ulab/code/ndarray.c -msgid "wrong index type" -msgstr "zły typ indeksu" +#: extmod/ulab/code/ulab_create.c +msgid "wrong axis specified" +msgstr "" #: extmod/ulab/code/vector/vectorise.c msgid "wrong input type" @@ -3707,6 +3768,15 @@ msgstr "" msgid "zi must be of shape (n_section, 2)" msgstr "" +#~ msgid "number of arguments must be 2, or 3" +#~ msgstr "liczba argumentów musi wynosić 2 lub 3" + +#~ msgid "wrong argument type" +#~ msgstr "zły typ argumentu" + +#~ msgid "wrong index type" +#~ msgstr "zły typ indeksu" + #~ msgid "Must provide SCK pin" #~ msgstr "Należy podać pin SCK" diff --git a/locale/pt_BR.po b/locale/pt_BR.po index 4cf204ae81..baa125f1d1 100644 --- a/locale/pt_BR.po +++ b/locale/pt_BR.po @@ -5,7 +5,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-11-10 15:30+0530\n" +"POT-Creation-Date: 2020-11-23 10:10-0600\n" "PO-Revision-Date: 2020-11-18 00:28+0000\n" "Last-Translator: Wellington Terumi Uemura \n" "Language-Team: \n" @@ -876,6 +876,10 @@ msgstr "Anúncios estendidos não compatíveis com a resposta da varredura." msgid "FFT is defined for ndarrays only" msgstr "O FFT é definido apenas para ndarrays" +#: extmod/ulab/code/fft/fft.c +msgid "FFT is implemented for linear arrays only" +msgstr "" + #: ports/esp32s2/common-hal/socketpool/Socket.c msgid "Failed SSL handshake" msgstr "Houve uma falha no handshake do SSL" @@ -2011,7 +2015,7 @@ msgstr "O tempo limite de leitura da tensão expirou" msgid "WARNING: Your code filename has two extensions\n" msgstr "AVISO: Seu arquivo de código tem duas extensões\n" -#: shared-bindings/watchdog/WatchDogTimer.c +#: ports/nrf/common-hal/watchdog/WatchDogTimer.c msgid "WatchDogTimer cannot be deinitialized once mode is set to RESET" msgstr "" "O WatchDogTimer não pode ser não-inicializado uma vez que o modo é definido " @@ -2100,10 +2104,6 @@ msgstr "endereço fora dos limites" msgid "addresses is empty" msgstr "os endereços estão vazios" -#: extmod/ulab/code/vector/vectorise.c -msgid "arctan2 is implemented for scalars and ndarrays only" -msgstr "O arctan2 está implementado apenas para escalares e ndarrays" - #: py/modbuiltins.c msgid "arg is an empty sequence" msgstr "o arg é uma sequência vazia" @@ -2112,6 +2112,10 @@ msgstr "o arg é uma sequência vazia" msgid "argsort argument must be an ndarray" msgstr "O argumento argsort deve ser um ndarray" +#: extmod/ulab/code/numerical/numerical.c +msgid "argsort is not implemented for flattened arrays" +msgstr "" + #: py/runtime.c msgid "argument has wrong type" msgstr "argumento tem tipo errado" @@ -2129,14 +2133,22 @@ msgstr "o argumento num/tipos não combinam" msgid "argument should be a '%q' not a '%q'" msgstr "o argumento deve ser um '%q' e não um '%q'" -#: extmod/ulab/code/linalg/linalg.c +#: extmod/ulab/code/linalg/linalg.c extmod/ulab/code/numerical/numerical.c msgid "arguments must be ndarrays" msgstr "os argumentos devem ser ndarrays" +#: extmod/ulab/code/ndarray.c +msgid "array and index length must be equal" +msgstr "" + #: py/objarray.c shared-bindings/nvm/ByteArray.c msgid "array/bytes required on right side" msgstr "matriz/bytes são necessários no lado direito" +#: extmod/ulab/code/numerical/numerical.c +msgid "attempt to get (arg)min/(arg)max of empty sequence" +msgstr "" + #: extmod/ulab/code/numerical/numerical.c msgid "attempt to get argmin/argmax of an empty sequence" msgstr "tente obter argmin/argmax de uma sequência vazia" @@ -2146,16 +2158,16 @@ msgid "attributes not supported yet" msgstr "atributos ainda não suportados" #: extmod/ulab/code/numerical/numerical.c -msgid "axis must be -1, 0, None, or 1" -msgstr "o eixo deve ser -1, 0, Nenhum ou 1" +msgid "axis is out of bounds" +msgstr "" #: extmod/ulab/code/numerical/numerical.c -msgid "axis must be -1, 0, or 1" -msgstr "o eixo deve ser -1, 0 ou 1" +msgid "axis must be None, or an integer" +msgstr "" #: extmod/ulab/code/numerical/numerical.c -msgid "axis must be None, 0, or 1" -msgstr "o eixo deve ser Nenhum, 0 ou 1" +msgid "axis too long" +msgstr "" #: py/builtinevex.c msgid "bad compile mode" @@ -2362,6 +2374,10 @@ msgid "" msgstr "" "não é possível alternar da especificação de campo manual para a automática" +#: extmod/ulab/code/ndarray_operators.c +msgid "cannot cast output with casting rule" +msgstr "" + #: py/objtype.c msgid "cannot create '%q' instances" msgstr "não é possível criar instâncias '%q'" @@ -2378,11 +2394,6 @@ msgstr "não pode importar nome %q" msgid "cannot perform relative import" msgstr "não pode executar a importação relativa" -#: extmod/ulab/code/ndarray.c -msgid "cannot reshape array (incompatible input/output shape)" -msgstr "" -"não é possível remodelar a matriz (formato de entrada/saída incompatível)" - #: py/emitnative.c msgid "casting" msgstr "fundição" @@ -2457,10 +2468,6 @@ msgstr "os argumentos convolutivos devem ser ndarrays" msgid "convolve arguments must not be empty" msgstr "os argumentos convolutivos não devem estar vazios" -#: extmod/ulab/code/ndarray.c -msgid "could not broadast input array from shape" -msgstr "não foi possível transmitir a matriz da entrada a partir da forma" - #: extmod/ulab/code/poly/poly.c msgid "could not invert Vandermonde matrix" msgstr "não foi possível inverter a matriz Vandermonde" @@ -2469,6 +2476,10 @@ msgstr "não foi possível inverter a matriz Vandermonde" msgid "couldn't determine SD card version" msgstr "não foi possível determinar a versão do cartão SD" +#: extmod/ulab/code/numerical/numerical.c +msgid "cross is defined for 1D arrays of length 3" +msgstr "" + #: extmod/ulab/code/approx/approx.c msgid "data must be iterable" msgstr "os dados devem ser iteráveis" @@ -2477,10 +2488,6 @@ msgstr "os dados devem ser iteráveis" msgid "data must be of equal length" msgstr "os dados devem ser de igual comprimento" -#: extmod/ulab/code/numerical/numerical.c -msgid "ddof must be smaller than length of data set" -msgstr "O ddof deve ser menor que o comprimento do conjunto dos dados" - #: py/parsenum.c msgid "decimal numbers not supported" msgstr "os números decimais não são compatíveis" @@ -2513,6 +2520,10 @@ msgstr "sequência da atualização dict tem o comprimento errado" msgid "diff argument must be an ndarray" msgstr "O argumento diff deve ser um ndarray" +#: extmod/ulab/code/numerical/numerical.c +msgid "differentiation order out of range" +msgstr "" + #: py/modmath.c py/objfloat.c py/objint_longlong.c py/objint_mpz.c py/runtime.c #: shared-bindings/math/__init__.c msgid "division by zero" @@ -2628,6 +2639,10 @@ msgstr "o primeiro argumento deve ser chamável" msgid "first argument must be a function" msgstr "o primeiro argumento deve ser uma função" +#: extmod/ulab/code/ulab_create.c +msgid "first argument must be a tuple of ndarrays" +msgstr "" + #: extmod/ulab/code/ndarray.c msgid "first argument must be an iterable" msgstr "o primeiro argumento deve ser um iterável" @@ -2681,9 +2696,9 @@ msgstr "A função obteve vários valores para o argumento '%q'" msgid "function has the same sign at the ends of interval" msgstr "a função tem o mesmo sinal nas extremidades do intervalo" -#: extmod/ulab/code/compare/compare.c -msgid "function is implemented for scalars and ndarrays only" -msgstr "A função foi implementada apenas para escalares e ndarrays" +#: extmod/ulab/code/ndarray.c +msgid "function is defined for ndarrays only" +msgstr "" #: py/argcheck.c #, c-format @@ -2752,6 +2767,7 @@ msgstr "preenchimento incorreto" msgid "index is out of bounds" msgstr "o índice está fora dos limites" +#: extmod/ulab/code/numerical/numerical.c #: ports/esp32s2/common-hal/pulseio/PulseIn.c py/obj.c msgid "index out of range" msgstr "Índice fora do intervalo" @@ -2776,6 +2792,10 @@ msgstr "O comprimento do initial_value está errado" msgid "inline assembler must be a function" msgstr "o assembler em linha deve ser uma função" +#: extmod/ulab/code/ndarray.c +msgid "input and output shapes are not compatible" +msgstr "" + #: extmod/ulab/code/ulab_create.c msgid "input argument must be an integer or a 2-tuple" msgstr "o argumento da entrada deve ser um número inteiro ou uma tupla de 2" @@ -2784,6 +2804,10 @@ msgstr "o argumento da entrada deve ser um número inteiro ou uma tupla de 2" msgid "input array length must be power of 2" msgstr "comprimento da matriz da entrada deve ter potência de 2" +#: extmod/ulab/code/ulab_create.c +msgid "input arrays are not compatible" +msgstr "" + #: extmod/ulab/code/poly/poly.c msgid "input data must be an iterable" msgstr "os dados da entrada devem ser iteráveis" @@ -2796,6 +2820,22 @@ msgstr "a matriz da entrada é assimétrica" msgid "input matrix is singular" msgstr "a matriz da entrada é singular" +#: extmod/ulab/code/user/user.c +msgid "input must be a dense ndarray" +msgstr "" + +#: extmod/ulab/code/ulab_create.c +msgid "input must be a tensor of rank 2" +msgstr "" + +#: extmod/ulab/code/ulab_create.c extmod/ulab/code/user/user.c +msgid "input must be an ndarray" +msgstr "" + +#: extmod/ulab/code/filter/filter.c +msgid "input must be one-dimensional" +msgstr "" + #: extmod/ulab/code/linalg/linalg.c msgid "input must be square matrix" msgstr "a entrada deve ser uma matriz quadrada" @@ -2808,6 +2848,10 @@ msgstr "A entrada deve ser tupla, lista, intervalo ou matriz" msgid "input vectors must be of equal length" msgstr "os vetores da entrada devem ter o mesmo comprimento" +#: extmod/ulab/code/poly/poly.c +msgid "inputs are not iterable" +msgstr "" + #: py/parsenum.c msgid "int() arg 2 must be >= 2 and <= 36" msgstr "int() arg 2 deve ser >= 2 e <= 36" @@ -2979,6 +3023,10 @@ msgstr "o max_length deve ser 0-%d quando Fixed_length for %s" msgid "max_length must be > 0" msgstr "max_length deve ser > 0" +#: extmod/ulab/code/ndarray.c +msgid "maximum number of dimensions is 4" +msgstr "" + #: py/runtime.c msgid "maximum recursion depth exceeded" msgstr "a recursão máxima da profundidade foi excedida" @@ -3030,10 +3078,6 @@ msgstr "deve levantar um objeto" msgid "must use keyword argument for key function" msgstr "deve usar o argumento da palavra-chave para a função da chave" -#: extmod/ulab/code/numerical/numerical.c -msgid "n must be between 0, and 9" -msgstr "n deve estar entre 0 e 9" - #: py/runtime.c msgid "name '%q' is not defined" msgstr "o nome '%q' não está definido" @@ -3116,6 +3160,10 @@ msgstr "um arg sem palavra-chave após */ **" msgid "non-keyword arg after keyword arg" msgstr "um arg não-palavra-chave após a palavra-chave arg" +#: extmod/ulab/code/linalg/linalg.c +msgid "norm is defined for 1D and 2D arrays" +msgstr "" + #: shared-bindings/_bleio/UUID.c msgid "not a 128-bit UUID" msgstr "não é um UUID com 128 bits" @@ -3128,10 +3176,6 @@ msgstr "nem todos os argumentos são convertidos durante a formatação da strin msgid "not enough arguments for format string" msgstr "argumentos insuficientes para o formato da string" -#: extmod/ulab/code/poly/poly.c -msgid "number of arguments must be 2, or 3" -msgstr "a quantidade dos argumentos deve ser 2 ou 3" - #: extmod/ulab/code/ulab_create.c msgid "number of points must be at least 2" msgstr "a quantidade dos pontos deve ser pelo menos 2" @@ -3184,6 +3228,10 @@ msgstr "é necessário objeto com protocolo do buffer" msgid "odd-length string" msgstr "sequência com comprimento ímpar" +#: extmod/ulab/code/ulab_create.c +msgid "offset is too large" +msgstr "" + #: py/objstr.c py/objstrunicode.c msgid "offset out of bounds" msgstr "desvio fora dos limites" @@ -3207,6 +3255,14 @@ msgstr "" msgid "operands could not be broadcast together" msgstr "os operandos não puderam ser transmitidos juntos" +#: extmod/ulab/code/ndarray.c +msgid "operation is implemented for 1D Boolean arrays only" +msgstr "" + +#: extmod/ulab/code/numerical/numerical.c +msgid "operation is not implemented for flattened array" +msgstr "" + #: extmod/ulab/code/numerical/numerical.c msgid "operation is not implemented on ndarrays" msgstr "a operação não foi implementada nos ndarrays" @@ -3345,6 +3401,10 @@ msgstr "importação relativa" msgid "requested length %d but object has length %d" msgstr "o comprimento solicitado %d, porém o objeto tem comprimento %d" +#: extmod/ulab/code/ndarray_operators.c +msgid "results cannot be cast to specified type" +msgstr "" + #: py/compile.c msgid "return annotation must be an identifier" msgstr "a anotação do retorno deve ser um identificador" @@ -3363,9 +3423,9 @@ msgstr "rgb_pins[%d] duplica outra atribuição dos pinos" msgid "rgb_pins[%d] is not on the same port as clock" msgstr "rgb_pins[%d] não está na mesma porta que o clock" -#: extmod/ulab/code/ndarray.c -msgid "right hand side must be an ndarray, or a scalar" -msgstr "o lado direito deve ser um ndarray ou um escalar" +#: extmod/ulab/code/numerical/numerical.c +msgid "roll argument must be an ndarray" +msgstr "" #: py/objstr.c msgid "rsplit(None,n)" @@ -3392,8 +3452,8 @@ msgid "script compilation not supported" msgstr "compilação de script não suportada" #: extmod/ulab/code/ndarray.c -msgid "shape must be a 2-tuple" -msgstr "a forma deve ser uma tupla de 2" +msgid "shape must be a tuple" +msgstr "" #: py/objstr.c msgid "sign not allowed in string format specifier" @@ -3435,10 +3495,6 @@ msgstr "reinicialização soft\n" msgid "sort argument must be an ndarray" msgstr "o argumento da classificação deve ser um ndarray" -#: extmod/ulab/code/numerical/numerical.c -msgid "sorted axis can't be longer than 65535" -msgstr "o eixo ordenado não pode ser maior do que 65535" - #: extmod/ulab/code/filter/filter.c msgid "sos array must be of shape (n_section, 6)" msgstr "o sos da matriz deve estar na forma (n_section, 6)" @@ -3544,6 +3600,10 @@ msgstr "o tempo limite na espera pelo cartão v2" msgid "timestamp out of range for platform time_t" msgstr "timestamp fora do intervalo para a plataforma time_t" +#: extmod/ulab/code/ndarray.c +msgid "tobytes can be invoked for dense arrays only" +msgstr "" + #: shared-module/struct/__init__.c msgid "too many arguments provided with the given format" msgstr "Muitos argumentos fornecidos com o formato dado" @@ -3719,13 +3779,13 @@ msgstr "a largura deve ser maior que zero" msgid "window must be <= interval" msgstr "a janela deve ser <= intervalo" -#: extmod/ulab/code/linalg/linalg.c -msgid "wrong argument type" -msgstr "tipo do argumento errado" +#: extmod/ulab/code/numerical/numerical.c +msgid "wrong axis index" +msgstr "" -#: extmod/ulab/code/ndarray.c -msgid "wrong index type" -msgstr "tipo do índice errado" +#: extmod/ulab/code/ulab_create.c +msgid "wrong axis specified" +msgstr "" #: extmod/ulab/code/vector/vectorise.c msgid "wrong input type" @@ -3775,6 +3835,52 @@ msgstr "zi deve ser de um tipo float" msgid "zi must be of shape (n_section, 2)" msgstr "zi deve estar na forma (n_section, 2)" +#~ msgid "arctan2 is implemented for scalars and ndarrays only" +#~ msgstr "O arctan2 está implementado apenas para escalares e ndarrays" + +#~ msgid "axis must be -1, 0, None, or 1" +#~ msgstr "o eixo deve ser -1, 0, Nenhum ou 1" + +#~ msgid "axis must be -1, 0, or 1" +#~ msgstr "o eixo deve ser -1, 0 ou 1" + +#~ msgid "axis must be None, 0, or 1" +#~ msgstr "o eixo deve ser Nenhum, 0 ou 1" + +#~ msgid "cannot reshape array (incompatible input/output shape)" +#~ msgstr "" +#~ "não é possível remodelar a matriz (formato de entrada/saída incompatível)" + +#~ msgid "could not broadast input array from shape" +#~ msgstr "não foi possível transmitir a matriz da entrada a partir da forma" + +#~ msgid "ddof must be smaller than length of data set" +#~ msgstr "O ddof deve ser menor que o comprimento do conjunto dos dados" + +#~ msgid "function is implemented for scalars and ndarrays only" +#~ msgstr "A função foi implementada apenas para escalares e ndarrays" + +#~ msgid "n must be between 0, and 9" +#~ msgstr "n deve estar entre 0 e 9" + +#~ msgid "number of arguments must be 2, or 3" +#~ msgstr "a quantidade dos argumentos deve ser 2 ou 3" + +#~ msgid "right hand side must be an ndarray, or a scalar" +#~ msgstr "o lado direito deve ser um ndarray ou um escalar" + +#~ msgid "shape must be a 2-tuple" +#~ msgstr "a forma deve ser uma tupla de 2" + +#~ msgid "sorted axis can't be longer than 65535" +#~ msgstr "o eixo ordenado não pode ser maior do que 65535" + +#~ msgid "wrong argument type" +#~ msgstr "tipo do argumento errado" + +#~ msgid "wrong index type" +#~ msgstr "tipo do índice errado" + #~ msgid "specify size or data, but not both" #~ msgstr "defina o tamanho ou os dados, porém não ambos" diff --git a/locale/sv.po b/locale/sv.po index cc6fe8ad00..02847044fb 100644 --- a/locale/sv.po +++ b/locale/sv.po @@ -5,7 +5,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-11-10 15:30+0530\n" +"POT-Creation-Date: 2020-11-23 10:10-0600\n" "PO-Revision-Date: 2020-11-20 22:28+0000\n" "Last-Translator: Jonny Bergdahl \n" "Language-Team: LANGUAGE \n" @@ -867,6 +867,10 @@ msgstr "Utökad annonsering i kombination med skanningssvar stöds inte." msgid "FFT is defined for ndarrays only" msgstr "FFT är enbart definierade för ndarrays" +#: extmod/ulab/code/fft/fft.c +msgid "FFT is implemented for linear arrays only" +msgstr "" + #: ports/esp32s2/common-hal/socketpool/Socket.c msgid "Failed SSL handshake" msgstr "Misslyckad SSL-handskakning" @@ -1993,7 +1997,7 @@ msgstr "Avläsning av spänning tog för lång tid" msgid "WARNING: Your code filename has two extensions\n" msgstr "VARNING: Ditt filnamn för kod har två tillägg\n" -#: shared-bindings/watchdog/WatchDogTimer.c +#: ports/nrf/common-hal/watchdog/WatchDogTimer.c msgid "WatchDogTimer cannot be deinitialized once mode is set to RESET" msgstr "WatchDogTimer kan inte avinitialiseras när läget är inställt på RESET" @@ -2078,10 +2082,6 @@ msgstr "adress utanför gränsen" msgid "addresses is empty" msgstr "adresserna är tomma" -#: extmod/ulab/code/vector/vectorise.c -msgid "arctan2 is implemented for scalars and ndarrays only" -msgstr "arctan2 är enbart implementerad för scalar och ndarray" - #: py/modbuiltins.c msgid "arg is an empty sequence" msgstr "arg är en tom sekvens" @@ -2090,6 +2090,10 @@ msgstr "arg är en tom sekvens" msgid "argsort argument must be an ndarray" msgstr "argumentet argsort måste vara en ndarray" +#: extmod/ulab/code/numerical/numerical.c +msgid "argsort is not implemented for flattened arrays" +msgstr "" + #: py/runtime.c msgid "argument has wrong type" msgstr "argumentet har fel typ" @@ -2107,14 +2111,22 @@ msgstr "argument antal/typ matchar inte" msgid "argument should be a '%q' not a '%q'" msgstr "argumentet skall vara en '%q', inte en '%q'" -#: extmod/ulab/code/linalg/linalg.c +#: extmod/ulab/code/linalg/linalg.c extmod/ulab/code/numerical/numerical.c msgid "arguments must be ndarrays" msgstr "argumenten måste vara ndarray" +#: extmod/ulab/code/ndarray.c +msgid "array and index length must be equal" +msgstr "" + #: py/objarray.c shared-bindings/nvm/ByteArray.c msgid "array/bytes required on right side" msgstr "array/bytes krävs på höger sida" +#: extmod/ulab/code/numerical/numerical.c +msgid "attempt to get (arg)min/(arg)max of empty sequence" +msgstr "" + #: extmod/ulab/code/numerical/numerical.c msgid "attempt to get argmin/argmax of an empty sequence" msgstr "försök att få argmin/argmax för en tom sekvens" @@ -2124,16 +2136,16 @@ msgid "attributes not supported yet" msgstr "attribut stöds inte än" #: extmod/ulab/code/numerical/numerical.c -msgid "axis must be -1, 0, None, or 1" -msgstr "axis ska vara -1, 0, None eller 1" +msgid "axis is out of bounds" +msgstr "" #: extmod/ulab/code/numerical/numerical.c -msgid "axis must be -1, 0, or 1" -msgstr "axis ska vara -1, 0 eller 1" +msgid "axis must be None, or an integer" +msgstr "" #: extmod/ulab/code/numerical/numerical.c -msgid "axis must be None, 0, or 1" -msgstr "axis ska vara None, 0, eller 1" +msgid "axis too long" +msgstr "" #: py/builtinevex.c msgid "bad compile mode" @@ -2338,6 +2350,10 @@ msgid "" msgstr "" "kan inte byta från manuell fältspecifikation till automatisk fältnumrering" +#: extmod/ulab/code/ndarray_operators.c +msgid "cannot cast output with casting rule" +msgstr "" + #: py/objtype.c msgid "cannot create '%q' instances" msgstr "kan inte skapa instanser av '%q'" @@ -2354,10 +2370,6 @@ msgstr "kan inte importera namn %q" msgid "cannot perform relative import" msgstr "kan inte utföra relativ import" -#: extmod/ulab/code/ndarray.c -msgid "cannot reshape array (incompatible input/output shape)" -msgstr "kan inte omforma matris (inkompatibel indata-/utdataform)" - #: py/emitnative.c msgid "casting" msgstr "casting inte implementerad" @@ -2430,10 +2442,6 @@ msgstr "Argumenten convolve måste vara ndarray:er" msgid "convolve arguments must not be empty" msgstr "Argumenten convolve kan inte vara tomma" -#: extmod/ulab/code/ndarray.c -msgid "could not broadast input array from shape" -msgstr "Kan inte sända indatamatris från form" - #: extmod/ulab/code/poly/poly.c msgid "could not invert Vandermonde matrix" msgstr "kan inte invertera Vandermonde-matris" @@ -2442,6 +2450,10 @@ msgstr "kan inte invertera Vandermonde-matris" msgid "couldn't determine SD card version" msgstr "kan inte avgöra SD-kortversion" +#: extmod/ulab/code/numerical/numerical.c +msgid "cross is defined for 1D arrays of length 3" +msgstr "" + #: extmod/ulab/code/approx/approx.c msgid "data must be iterable" msgstr "data måste vara itererbar" @@ -2450,10 +2462,6 @@ msgstr "data måste vara itererbar" msgid "data must be of equal length" msgstr "data måste vara av samma längd" -#: extmod/ulab/code/numerical/numerical.c -msgid "ddof must be smaller than length of data set" -msgstr "ddof måste vara mindre än längden på datauppsättningen" - #: py/parsenum.c msgid "decimal numbers not supported" msgstr "decimaltal stöds inte" @@ -2486,6 +2494,10 @@ msgstr "uppdateringssekvensen för dict har fel längd" msgid "diff argument must be an ndarray" msgstr "argumentet diff måste vara en ndarray" +#: extmod/ulab/code/numerical/numerical.c +msgid "differentiation order out of range" +msgstr "" + #: py/modmath.c py/objfloat.c py/objint_longlong.c py/objint_mpz.c py/runtime.c #: shared-bindings/math/__init__.c msgid "division by zero" @@ -2601,6 +2613,10 @@ msgstr "första argumentet måste vara en callable" msgid "first argument must be a function" msgstr "första argumentet måste vara en funktion" +#: extmod/ulab/code/ulab_create.c +msgid "first argument must be a tuple of ndarrays" +msgstr "" + #: extmod/ulab/code/ndarray.c msgid "first argument must be an iterable" msgstr "första argumentet måste vara en iterable" @@ -2654,9 +2670,9 @@ msgstr "funktionen fick flera värden för argumentet '%q'" msgid "function has the same sign at the ends of interval" msgstr "funktionen har samma teckenvärden vid slutet av intervall" -#: extmod/ulab/code/compare/compare.c -msgid "function is implemented for scalars and ndarrays only" -msgstr "funktionen är endast implementerad för scalar och ndarray" +#: extmod/ulab/code/ndarray.c +msgid "function is defined for ndarrays only" +msgstr "" #: py/argcheck.c #, c-format @@ -2725,6 +2741,7 @@ msgstr "felaktig utfyllnad" msgid "index is out of bounds" msgstr "index är utanför gränserna" +#: extmod/ulab/code/numerical/numerical.c #: ports/esp32s2/common-hal/pulseio/PulseIn.c py/obj.c msgid "index out of range" msgstr "index utanför intervallet" @@ -2749,6 +2766,10 @@ msgstr "initial_value-längd är fel" msgid "inline assembler must be a function" msgstr "inline assembler måste vara en funktion" +#: extmod/ulab/code/ndarray.c +msgid "input and output shapes are not compatible" +msgstr "" + #: extmod/ulab/code/ulab_create.c msgid "input argument must be an integer or a 2-tuple" msgstr "indataargumentet måste vara ett heltal eller en 2-tupel" @@ -2757,6 +2778,10 @@ msgstr "indataargumentet måste vara ett heltal eller en 2-tupel" msgid "input array length must be power of 2" msgstr "indataarraylängden måste vara en multipel av 2" +#: extmod/ulab/code/ulab_create.c +msgid "input arrays are not compatible" +msgstr "" + #: extmod/ulab/code/poly/poly.c msgid "input data must be an iterable" msgstr "indata måste vara en iterable" @@ -2769,6 +2794,22 @@ msgstr "indatamatrisen är asymmetrisk" msgid "input matrix is singular" msgstr "indatamatrisen är singulär" +#: extmod/ulab/code/user/user.c +msgid "input must be a dense ndarray" +msgstr "" + +#: extmod/ulab/code/ulab_create.c +msgid "input must be a tensor of rank 2" +msgstr "" + +#: extmod/ulab/code/ulab_create.c extmod/ulab/code/user/user.c +msgid "input must be an ndarray" +msgstr "" + +#: extmod/ulab/code/filter/filter.c +msgid "input must be one-dimensional" +msgstr "" + #: extmod/ulab/code/linalg/linalg.c msgid "input must be square matrix" msgstr "indata måste vara kvadratmatris" @@ -2781,6 +2822,10 @@ msgstr "indata måste vara tupel, lista, range, eller ndarray" msgid "input vectors must be of equal length" msgstr "indatavektorer måste ha samma längd" +#: extmod/ulab/code/poly/poly.c +msgid "inputs are not iterable" +msgstr "" + #: py/parsenum.c msgid "int() arg 2 must be >= 2 and <= 36" msgstr "int() arg 2 måste vara >= 2 och <= 36" @@ -2952,6 +2997,10 @@ msgstr "max_length måste vara 0-%d när fixed_length är %s" msgid "max_length must be > 0" msgstr "max_length måste vara > 0" +#: extmod/ulab/code/ndarray.c +msgid "maximum number of dimensions is 4" +msgstr "" + #: py/runtime.c msgid "maximum recursion depth exceeded" msgstr "maximal rekursionsdjup överskriden" @@ -3001,10 +3050,6 @@ msgstr "måste ge ett objekt" msgid "must use keyword argument for key function" msgstr "måste använda nyckelordsargument för nyckelfunktion" -#: extmod/ulab/code/numerical/numerical.c -msgid "n must be between 0, and 9" -msgstr "n måste vara mellan 0 och 9" - #: py/runtime.c msgid "name '%q' is not defined" msgstr "namnet '%q' är inte definierat" @@ -3087,6 +3132,10 @@ msgstr "icke nyckelord arg efter * / **" msgid "non-keyword arg after keyword arg" msgstr "icke nyckelord arg efter nyckelord arg" +#: extmod/ulab/code/linalg/linalg.c +msgid "norm is defined for 1D and 2D arrays" +msgstr "" + #: shared-bindings/_bleio/UUID.c msgid "not a 128-bit UUID" msgstr "inte en 128-bitars UUID" @@ -3099,10 +3148,6 @@ msgstr "inte alla argument omvandlade under strängformatering" msgid "not enough arguments for format string" msgstr "inte tillräckligt med argument för formatsträng" -#: extmod/ulab/code/poly/poly.c -msgid "number of arguments must be 2, or 3" -msgstr "antal argument måste vara 2 eller 3" - #: extmod/ulab/code/ulab_create.c msgid "number of points must be at least 2" msgstr "antal punkter måste vara minst 2" @@ -3155,6 +3200,10 @@ msgstr "objekt med buffertprotokoll krävs" msgid "odd-length string" msgstr "sträng har udda längd" +#: extmod/ulab/code/ulab_create.c +msgid "offset is too large" +msgstr "" + #: py/objstr.c py/objstrunicode.c msgid "offset out of bounds" msgstr "offset utanför gränserna" @@ -3177,6 +3226,14 @@ msgstr "endast segment med steg=1 (aka Ingen) stöds" msgid "operands could not be broadcast together" msgstr "operander kan inte sändas tillsammans" +#: extmod/ulab/code/ndarray.c +msgid "operation is implemented for 1D Boolean arrays only" +msgstr "" + +#: extmod/ulab/code/numerical/numerical.c +msgid "operation is not implemented for flattened array" +msgstr "" + #: extmod/ulab/code/numerical/numerical.c msgid "operation is not implemented on ndarrays" msgstr "åtgärden är inte implementerad för ndarray:er" @@ -3312,6 +3369,10 @@ msgstr "relativ import" msgid "requested length %d but object has length %d" msgstr "begärd längd %d men objektet har längden %d" +#: extmod/ulab/code/ndarray_operators.c +msgid "results cannot be cast to specified type" +msgstr "" + #: py/compile.c msgid "return annotation must be an identifier" msgstr "retur-annotation måste vara en identifierare" @@ -3330,9 +3391,9 @@ msgstr "rgb_pins[%d] duplicerar en annan pinntilldelning" msgid "rgb_pins[%d] is not on the same port as clock" msgstr "rgb_pins[%d] är inte på samma port som en klocka" -#: extmod/ulab/code/ndarray.c -msgid "right hand side must be an ndarray, or a scalar" -msgstr "höger sida måste vara en ndarray, eller en scalar" +#: extmod/ulab/code/numerical/numerical.c +msgid "roll argument must be an ndarray" +msgstr "" #: py/objstr.c msgid "rsplit(None,n)" @@ -3359,8 +3420,8 @@ msgid "script compilation not supported" msgstr "skriptkompilering stöds inte" #: extmod/ulab/code/ndarray.c -msgid "shape must be a 2-tuple" -msgstr "shape måste vara en 2-tupel" +msgid "shape must be a tuple" +msgstr "" #: py/objstr.c msgid "sign not allowed in string format specifier" @@ -3402,10 +3463,6 @@ msgstr "mjuk omstart\n" msgid "sort argument must be an ndarray" msgstr "argumentet sort måste vara en ndarray" -#: extmod/ulab/code/numerical/numerical.c -msgid "sorted axis can't be longer than 65535" -msgstr "sorterad axel kan inte vara längre än 65535" - #: extmod/ulab/code/filter/filter.c msgid "sos array must be of shape (n_section, 6)" msgstr "sos array måste ha form (n_section, 6)" @@ -3511,6 +3568,10 @@ msgstr "timeout för v2-kort" msgid "timestamp out of range for platform time_t" msgstr "timestamp utom räckvidd för plattformens \"time_t\"" +#: extmod/ulab/code/ndarray.c +msgid "tobytes can be invoked for dense arrays only" +msgstr "" + #: shared-module/struct/__init__.c msgid "too many arguments provided with the given format" msgstr "för många argument för det givna formatet" @@ -3686,13 +3747,13 @@ msgstr "width måste vara större än noll" msgid "window must be <= interval" msgstr "window måste vara <= interval" -#: extmod/ulab/code/linalg/linalg.c -msgid "wrong argument type" -msgstr "fel typ av argument" +#: extmod/ulab/code/numerical/numerical.c +msgid "wrong axis index" +msgstr "" -#: extmod/ulab/code/ndarray.c -msgid "wrong index type" -msgstr "fel indextyp" +#: extmod/ulab/code/ulab_create.c +msgid "wrong axis specified" +msgstr "" #: extmod/ulab/code/vector/vectorise.c msgid "wrong input type" @@ -3742,6 +3803,51 @@ msgstr "zi måste vara av typ float" msgid "zi must be of shape (n_section, 2)" msgstr "zi måste vara i formen (n_section, 2)" +#~ msgid "arctan2 is implemented for scalars and ndarrays only" +#~ msgstr "arctan2 är enbart implementerad för scalar och ndarray" + +#~ msgid "axis must be -1, 0, None, or 1" +#~ msgstr "axis ska vara -1, 0, None eller 1" + +#~ msgid "axis must be -1, 0, or 1" +#~ msgstr "axis ska vara -1, 0 eller 1" + +#~ msgid "axis must be None, 0, or 1" +#~ msgstr "axis ska vara None, 0, eller 1" + +#~ msgid "cannot reshape array (incompatible input/output shape)" +#~ msgstr "kan inte omforma matris (inkompatibel indata-/utdataform)" + +#~ msgid "could not broadast input array from shape" +#~ msgstr "Kan inte sända indatamatris från form" + +#~ msgid "ddof must be smaller than length of data set" +#~ msgstr "ddof måste vara mindre än längden på datauppsättningen" + +#~ msgid "function is implemented for scalars and ndarrays only" +#~ msgstr "funktionen är endast implementerad för scalar och ndarray" + +#~ msgid "n must be between 0, and 9" +#~ msgstr "n måste vara mellan 0 och 9" + +#~ msgid "number of arguments must be 2, or 3" +#~ msgstr "antal argument måste vara 2 eller 3" + +#~ msgid "right hand side must be an ndarray, or a scalar" +#~ msgstr "höger sida måste vara en ndarray, eller en scalar" + +#~ msgid "shape must be a 2-tuple" +#~ msgstr "shape måste vara en 2-tupel" + +#~ msgid "sorted axis can't be longer than 65535" +#~ msgstr "sorterad axel kan inte vara längre än 65535" + +#~ msgid "wrong argument type" +#~ msgstr "fel typ av argument" + +#~ msgid "wrong index type" +#~ msgstr "fel indextyp" + #~ msgid "specify size or data, but not both" #~ msgstr "ange storlek eller data, men inte båda" diff --git a/locale/zh_Latn_pinyin.po b/locale/zh_Latn_pinyin.po index e94ae8173f..134efec903 100644 --- a/locale/zh_Latn_pinyin.po +++ b/locale/zh_Latn_pinyin.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: circuitpython-cn\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-11-10 15:30+0530\n" +"POT-Creation-Date: 2020-11-23 10:10-0600\n" "PO-Revision-Date: 2020-11-19 01:28+0000\n" "Last-Translator: hexthat \n" "Language-Team: Chinese Hanyu Pinyin\n" @@ -865,6 +865,10 @@ msgstr "Bù zhīchí dài yǒu sǎomiáo xiǎngyìng de kuòzhǎn guǎngbò." msgid "FFT is defined for ndarrays only" msgstr "FFT jǐn wéi ndarrays dìng yì" +#: extmod/ulab/code/fft/fft.c +msgid "FFT is implemented for linear arrays only" +msgstr "" + #: ports/esp32s2/common-hal/socketpool/Socket.c msgid "Failed SSL handshake" msgstr "SSL wòshǒu shībài" @@ -1984,7 +1988,7 @@ msgstr "Diànyā dòu qǔ chāoshí" 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" -#: shared-bindings/watchdog/WatchDogTimer.c +#: ports/nrf/common-hal/watchdog/WatchDogTimer.c msgid "WatchDogTimer cannot be deinitialized once mode is set to RESET" msgstr "Yīdàn jiāng móshì shèzhì wèi RESET, jiù wúfǎ chūshǐhuà WatchDog Timer" @@ -2070,10 +2074,6 @@ msgstr "dìzhǐ chāochū biānjiè" msgid "addresses is empty" msgstr "dìzhǐ wèi kōng" -#: extmod/ulab/code/vector/vectorise.c -msgid "arctan2 is implemented for scalars and ndarrays only" -msgstr "arctan2 jǐn zhēnduì biāoliàng hé ndarray shíxiàn" - #: py/modbuiltins.c msgid "arg is an empty sequence" msgstr "cānshù shì yīgè kōng de xùliè" @@ -2082,6 +2082,10 @@ msgstr "cānshù shì yīgè kōng de xùliè" msgid "argsort argument must be an ndarray" msgstr "argsort cānshù bìxū shì ndarray" +#: extmod/ulab/code/numerical/numerical.c +msgid "argsort is not implemented for flattened arrays" +msgstr "" + #: py/runtime.c msgid "argument has wrong type" msgstr "cānshù lèixíng cuòwù" @@ -2099,14 +2103,22 @@ msgstr "cānshù biānhào/lèixíng bù pǐpèi" msgid "argument should be a '%q' not a '%q'" msgstr "cānshù yīnggāi shì '%q', 'bùshì '%q'" -#: extmod/ulab/code/linalg/linalg.c +#: extmod/ulab/code/linalg/linalg.c extmod/ulab/code/numerical/numerical.c msgid "arguments must be ndarrays" msgstr "cānshù bìxū shì ndarrays" +#: extmod/ulab/code/ndarray.c +msgid "array and index length must be equal" +msgstr "" + #: py/objarray.c shared-bindings/nvm/ByteArray.c msgid "array/bytes required on right side" msgstr "yòu cè xūyào shùzǔ/zì jié" +#: extmod/ulab/code/numerical/numerical.c +msgid "attempt to get (arg)min/(arg)max of empty sequence" +msgstr "" + #: extmod/ulab/code/numerical/numerical.c msgid "attempt to get argmin/argmax of an empty sequence" msgstr "chángshì huòqǔ kōng xùliè de argmin/ argmax" @@ -2116,16 +2128,16 @@ msgid "attributes not supported yet" msgstr "shǔxìng shàngwèi zhīchí" #: extmod/ulab/code/numerical/numerical.c -msgid "axis must be -1, 0, None, or 1" -msgstr "zhóu bìxū wèi-1,0, wú huò 1" +msgid "axis is out of bounds" +msgstr "" #: extmod/ulab/code/numerical/numerical.c -msgid "axis must be -1, 0, or 1" -msgstr "zhóu bìxū wèi-1,0 huò 1" +msgid "axis must be None, or an integer" +msgstr "" #: extmod/ulab/code/numerical/numerical.c -msgid "axis must be None, 0, or 1" -msgstr "zhóu bìxū wèi None,0 huò 1" +msgid "axis too long" +msgstr "" #: py/builtinevex.c msgid "bad compile mode" @@ -2328,6 +2340,10 @@ msgid "" "can't switch from manual field specification to automatic field numbering" msgstr "wúfǎ cóng shǒudòng zìduàn guīgé qiēhuàn dào zìdòng zìduàn biānhào" +#: extmod/ulab/code/ndarray_operators.c +msgid "cannot cast output with casting rule" +msgstr "" + #: py/objtype.c msgid "cannot create '%q' instances" msgstr "wúfǎ chuàngjiàn '%q' ' shílì" @@ -2344,10 +2360,6 @@ msgstr "wúfǎ dǎorù míngchēng %q" msgid "cannot perform relative import" msgstr "wúfǎ zhíxíng xiāngguān dǎorù" -#: extmod/ulab/code/ndarray.c -msgid "cannot reshape array (incompatible input/output shape)" -msgstr "wúfǎ zhěngxíng shùzǔ (bù jiānróng de shūrù/shūchū xíngzhuàng)" - #: py/emitnative.c msgid "casting" msgstr "tóuyǐng" @@ -2423,10 +2435,6 @@ msgstr "juàn jī cānshù bìxū shì ndarrays" msgid "convolve arguments must not be empty" msgstr "juàn jī cān shǔ bùnéng wéi kōng" -#: extmod/ulab/code/ndarray.c -msgid "could not broadast input array from shape" -msgstr "wúfǎ guǎngbò xíngzhuàng de shūrù shùzǔ" - #: extmod/ulab/code/poly/poly.c msgid "could not invert Vandermonde matrix" msgstr "wúfǎ fǎn zhuǎn fàndéméng dé jǔzhèn" @@ -2435,6 +2443,10 @@ msgstr "wúfǎ fǎn zhuǎn fàndéméng dé jǔzhèn" msgid "couldn't determine SD card version" msgstr "wúfǎ quèdìng SD kǎ bǎnběn" +#: extmod/ulab/code/numerical/numerical.c +msgid "cross is defined for 1D arrays of length 3" +msgstr "" + #: extmod/ulab/code/approx/approx.c msgid "data must be iterable" msgstr "shùjù bìxū shì kě diédài de" @@ -2443,10 +2455,6 @@ msgstr "shùjù bìxū shì kě diédài de" msgid "data must be of equal length" msgstr "shùjù chángdù bìxū xiāngděng" -#: extmod/ulab/code/numerical/numerical.c -msgid "ddof must be smaller than length of data set" -msgstr "ddof bìxū xiǎoyú shùjù jí de chángdù" - #: py/parsenum.c msgid "decimal numbers not supported" msgstr "bù zhīchí xiǎoshù shù" @@ -2478,6 +2486,10 @@ msgstr "yǔfǎ gēngxīn xùliè de chángdù cuòwù" msgid "diff argument must be an ndarray" msgstr "bùtóng de cānshù bìxū shì ndarray" +#: extmod/ulab/code/numerical/numerical.c +msgid "differentiation order out of range" +msgstr "" + #: py/modmath.c py/objfloat.c py/objint_longlong.c py/objint_mpz.c py/runtime.c #: shared-bindings/math/__init__.c msgid "division by zero" @@ -2593,6 +2605,10 @@ msgstr "dì yī gè cānshù bìxū shì kě tiáo yòng de" msgid "first argument must be a function" msgstr "dì yīgè cānshù bìxū shì yī gè hánshù" +#: extmod/ulab/code/ulab_create.c +msgid "first argument must be a tuple of ndarrays" +msgstr "" + #: extmod/ulab/code/ndarray.c msgid "first argument must be an iterable" msgstr "dì yī gè cānshù bìxū shì kě diédài de" @@ -2646,9 +2662,9 @@ msgstr "hánshù huòdé cānshù '%q' de duōchóng zhí" msgid "function has the same sign at the ends of interval" msgstr "hánshù zài jiàngé mòwěi jùyǒu xiāngtóng de fúhào" -#: extmod/ulab/code/compare/compare.c -msgid "function is implemented for scalars and ndarrays only" -msgstr "gāi hánshù jǐn zhēnduì biāoliàng hé ndarray shíxiàn" +#: extmod/ulab/code/ndarray.c +msgid "function is defined for ndarrays only" +msgstr "" #: py/argcheck.c #, c-format @@ -2717,6 +2733,7 @@ msgstr "bù zhèngquè de tiánchōng" msgid "index is out of bounds" msgstr "suǒyǐn chāochū fànwéi" +#: extmod/ulab/code/numerical/numerical.c #: ports/esp32s2/common-hal/pulseio/PulseIn.c py/obj.c msgid "index out of range" msgstr "suǒyǐn chāochū fànwéi" @@ -2741,6 +2758,10 @@ msgstr "Initial_value chángdù cuòwù" msgid "inline assembler must be a function" msgstr "nèi lián jíhé bìxū shì yīgè hánshù" +#: extmod/ulab/code/ndarray.c +msgid "input and output shapes are not compatible" +msgstr "" + #: extmod/ulab/code/ulab_create.c msgid "input argument must be an integer or a 2-tuple" msgstr "shūrù cānshù bìxū shì zhěngshù huò 2 yuán zǔ" @@ -2749,6 +2770,10 @@ msgstr "shūrù cānshù bìxū shì zhěngshù huò 2 yuán zǔ" msgid "input array length must be power of 2" msgstr "shūrù shùzǔ de chángdù bìxū shì 2 de mì" +#: extmod/ulab/code/ulab_create.c +msgid "input arrays are not compatible" +msgstr "" + #: extmod/ulab/code/poly/poly.c msgid "input data must be an iterable" msgstr "shūrù shùjù bìxū shì kě diédài de" @@ -2761,6 +2786,22 @@ msgstr "shūrù jǔzhèn bù duìchèn" msgid "input matrix is singular" msgstr "shūrù jǔzhèn shì qíyì de" +#: extmod/ulab/code/user/user.c +msgid "input must be a dense ndarray" +msgstr "" + +#: extmod/ulab/code/ulab_create.c +msgid "input must be a tensor of rank 2" +msgstr "" + +#: extmod/ulab/code/ulab_create.c extmod/ulab/code/user/user.c +msgid "input must be an ndarray" +msgstr "" + +#: extmod/ulab/code/filter/filter.c +msgid "input must be one-dimensional" +msgstr "" + #: extmod/ulab/code/linalg/linalg.c msgid "input must be square matrix" msgstr "shūrù bìxū wèi fāng jǔzhèn" @@ -2773,6 +2814,10 @@ msgstr "shūrù bìxū shì yuán zǔ, lièbiǎo, fànwéi huò ndarray" msgid "input vectors must be of equal length" msgstr "shūrù xiàngliàng de chángdù bìxū xiāngděng" +#: extmod/ulab/code/poly/poly.c +msgid "inputs are not iterable" +msgstr "" + #: py/parsenum.c msgid "int() arg 2 must be >= 2 and <= 36" msgstr "zhěngshù() cānshù 2 bìxū > = 2 qiě <= 36" @@ -2942,6 +2987,10 @@ msgstr "Dāng gùdìng chángdù wèi %s shí, zuìdà chángdù bìxū wèi 0-% msgid "max_length must be > 0" msgstr "Max_length bìxū > 0" +#: extmod/ulab/code/ndarray.c +msgid "maximum number of dimensions is 4" +msgstr "" + #: py/runtime.c msgid "maximum recursion depth exceeded" msgstr "chāochū zuìdà dìguī shēndù" @@ -2991,10 +3040,6 @@ msgstr "bìxū tíchū duìxiàng" msgid "must use keyword argument for key function" msgstr "bìxū shǐyòng guānjiàn cí cānshù" -#: extmod/ulab/code/numerical/numerical.c -msgid "n must be between 0, and 9" -msgstr "n bìxū jiè yú 0 dào 9 zhī jiān" - #: py/runtime.c msgid "name '%q' is not defined" msgstr "míngchēng '%q' wèi dìngyì" @@ -3077,6 +3122,10 @@ msgstr "zài */** zhīhòu fēi guānjiàn cí cānshù" msgid "non-keyword arg after keyword arg" msgstr "guānjiàn zì cānshù zhīhòu de fēi guānjiàn zì cānshù" +#: extmod/ulab/code/linalg/linalg.c +msgid "norm is defined for 1D and 2D arrays" +msgstr "" + #: shared-bindings/_bleio/UUID.c msgid "not a 128-bit UUID" msgstr "bùshì 128 wèi UUID" @@ -3089,10 +3138,6 @@ msgstr "bùshì zì chuàn géshì huà guòchéng zhōng zhuǎnhuàn de suǒyǒ msgid "not enough arguments for format string" msgstr "géshì zìfú chuàn cān shǔ bùzú" -#: extmod/ulab/code/poly/poly.c -msgid "number of arguments must be 2, or 3" -msgstr "cānshù shùliàng bìxū wèi 2 huò 3" - #: extmod/ulab/code/ulab_create.c msgid "number of points must be at least 2" msgstr "diǎnshù bìxū zhìshǎo wèi 2" @@ -3145,6 +3190,10 @@ msgstr "xūyào huǎnchōng qū xiéyì de duìxiàng" msgid "odd-length string" msgstr "jīshù zìfú chuàn" +#: extmod/ulab/code/ulab_create.c +msgid "offset is too large" +msgstr "" + #: py/objstr.c py/objstrunicode.c msgid "offset out of bounds" msgstr "piānlí biānjiè" @@ -3167,6 +3216,14 @@ msgstr "jǐn zhīchí bù zhǎng = 1(jí wú) de qiēpiàn" msgid "operands could not be broadcast together" msgstr "cāozuò shǔ bùnéng yīqǐ guǎngbò" +#: extmod/ulab/code/ndarray.c +msgid "operation is implemented for 1D Boolean arrays only" +msgstr "" + +#: extmod/ulab/code/numerical/numerical.c +msgid "operation is not implemented for flattened array" +msgstr "" + #: extmod/ulab/code/numerical/numerical.c msgid "operation is not implemented on ndarrays" msgstr "cāozuò wèi zài ndarrays shàng shíxiàn" @@ -3301,6 +3358,10 @@ msgstr "xiāngduì dǎorù" msgid "requested length %d but object has length %d" msgstr "qǐngqiú chángdù %d dàn duìxiàng chángdù %d" +#: extmod/ulab/code/ndarray_operators.c +msgid "results cannot be cast to specified type" +msgstr "" + #: py/compile.c msgid "return annotation must be an identifier" msgstr "fǎnhuí zhùshì bìxū shì biāozhì fú" @@ -3319,9 +3380,9 @@ msgstr "rgb_pins[%d] fùzhì lìng yīgè yǐn jiǎo fēnpèi" msgid "rgb_pins[%d] is not on the same port as clock" msgstr "rgb_pins[%d] yǔ shízhōng bùzài tóng yīgè duānkǒu shàng" -#: extmod/ulab/code/ndarray.c -msgid "right hand side must be an ndarray, or a scalar" -msgstr "yòubiān bìxū shì ndarray huò biāoliàng" +#: extmod/ulab/code/numerical/numerical.c +msgid "roll argument must be an ndarray" +msgstr "" #: py/objstr.c msgid "rsplit(None,n)" @@ -3348,8 +3409,8 @@ msgid "script compilation not supported" msgstr "bù zhīchí jiǎoběn biānyì" #: extmod/ulab/code/ndarray.c -msgid "shape must be a 2-tuple" -msgstr "xíngzhuàng bìxū shì 2 yuán zǔ" +msgid "shape must be a tuple" +msgstr "" #: py/objstr.c msgid "sign not allowed in string format specifier" @@ -3391,10 +3452,6 @@ msgstr "ruǎn chóngqǐ\n" msgid "sort argument must be an ndarray" msgstr "páixù cānshù bìxū shì ndarray" -#: extmod/ulab/code/numerical/numerical.c -msgid "sorted axis can't be longer than 65535" -msgstr "pái xù zhóu bù néng chāo guò 65535" - #: extmod/ulab/code/filter/filter.c msgid "sos array must be of shape (n_section, 6)" msgstr "sos shùzǔ de xíngzhuàng bìxū wèi (n_section, 6)" @@ -3500,6 +3557,10 @@ msgstr "děngdài v2 kǎ chāoshí" msgid "timestamp out of range for platform time_t" msgstr "time_t shíjiān chuō chāochū píngtái fànwéi" +#: extmod/ulab/code/ndarray.c +msgid "tobytes can be invoked for dense arrays only" +msgstr "" + #: shared-module/struct/__init__.c msgid "too many arguments provided with the given format" msgstr "tígōng jǐ dìng géshì de cānshù tài duō" @@ -3675,13 +3736,13 @@ msgstr "kuāndù bìxū dàyú líng" msgid "window must be <= interval" msgstr "Chuāngkǒu bìxū shì <= jiàngé" -#: extmod/ulab/code/linalg/linalg.c -msgid "wrong argument type" -msgstr "cuòwù de cānshù lèixíng" +#: extmod/ulab/code/numerical/numerical.c +msgid "wrong axis index" +msgstr "" -#: extmod/ulab/code/ndarray.c -msgid "wrong index type" -msgstr "cuòwù de suǒyǐn lèixíng" +#: extmod/ulab/code/ulab_create.c +msgid "wrong axis specified" +msgstr "" #: extmod/ulab/code/vector/vectorise.c msgid "wrong input type" @@ -3731,6 +3792,51 @@ msgstr "zi bìxū wèi fú diǎn xíng" msgid "zi must be of shape (n_section, 2)" msgstr "zi bìxū jùyǒu xíngzhuàng (n_section,2)" +#~ msgid "arctan2 is implemented for scalars and ndarrays only" +#~ msgstr "arctan2 jǐn zhēnduì biāoliàng hé ndarray shíxiàn" + +#~ msgid "axis must be -1, 0, None, or 1" +#~ msgstr "zhóu bìxū wèi-1,0, wú huò 1" + +#~ msgid "axis must be -1, 0, or 1" +#~ msgstr "zhóu bìxū wèi-1,0 huò 1" + +#~ msgid "axis must be None, 0, or 1" +#~ msgstr "zhóu bìxū wèi None,0 huò 1" + +#~ msgid "cannot reshape array (incompatible input/output shape)" +#~ msgstr "wúfǎ zhěngxíng shùzǔ (bù jiānróng de shūrù/shūchū xíngzhuàng)" + +#~ msgid "could not broadast input array from shape" +#~ msgstr "wúfǎ guǎngbò xíngzhuàng de shūrù shùzǔ" + +#~ msgid "ddof must be smaller than length of data set" +#~ msgstr "ddof bìxū xiǎoyú shùjù jí de chángdù" + +#~ msgid "function is implemented for scalars and ndarrays only" +#~ msgstr "gāi hánshù jǐn zhēnduì biāoliàng hé ndarray shíxiàn" + +#~ msgid "n must be between 0, and 9" +#~ msgstr "n bìxū jiè yú 0 dào 9 zhī jiān" + +#~ msgid "number of arguments must be 2, or 3" +#~ msgstr "cānshù shùliàng bìxū wèi 2 huò 3" + +#~ msgid "right hand side must be an ndarray, or a scalar" +#~ msgstr "yòubiān bìxū shì ndarray huò biāoliàng" + +#~ msgid "shape must be a 2-tuple" +#~ msgstr "xíngzhuàng bìxū shì 2 yuán zǔ" + +#~ msgid "sorted axis can't be longer than 65535" +#~ msgstr "pái xù zhóu bù néng chāo guò 65535" + +#~ msgid "wrong argument type" +#~ msgstr "cuòwù de cānshù lèixíng" + +#~ msgid "wrong index type" +#~ msgstr "cuòwù de suǒyǐn lèixíng" + #~ msgid "Must provide SCK pin" #~ msgstr "bì xū tí gòng SCK yǐn jiǎo" From 2635132ce590a44e79dbee8230fe92dbba8e3667 Mon Sep 17 00:00:00 2001 From: Seth Kerr Date: Mon, 23 Nov 2020 19:21:12 -0500 Subject: [PATCH 123/207] adding 'haxpress' kind of build for CP Sapling for use with SPI Flash --- .../boards/cp_sapling_m0_spiflash/board.c | 40 ++++++++++++ .../cp_sapling_m0_spiflash/mpconfigboard.h | 62 +++++++++++++++++++ .../cp_sapling_m0_spiflash/mpconfigboard.mk | 33 ++++++++++ .../boards/cp_sapling_m0_spiflash/pins.c | 38 ++++++++++++ .../atmel-samd/boards/icy-tree-sof-m0/board.c | 44 +++++++++++++ .../boards/icy-tree-sof-m0/mpconfigboard.h | 55 ++++++++++++++++ .../boards/icy-tree-sof-m0/mpconfigboard.mk | 24 +++++++ .../atmel-samd/boards/icy-tree-sof-m0/pins.c | 49 +++++++++++++++ 8 files changed, 345 insertions(+) create mode 100644 ports/atmel-samd/boards/cp_sapling_m0_spiflash/board.c create mode 100644 ports/atmel-samd/boards/cp_sapling_m0_spiflash/mpconfigboard.h create mode 100644 ports/atmel-samd/boards/cp_sapling_m0_spiflash/mpconfigboard.mk create mode 100644 ports/atmel-samd/boards/cp_sapling_m0_spiflash/pins.c create mode 100644 ports/atmel-samd/boards/icy-tree-sof-m0/board.c create mode 100644 ports/atmel-samd/boards/icy-tree-sof-m0/mpconfigboard.h create mode 100644 ports/atmel-samd/boards/icy-tree-sof-m0/mpconfigboard.mk create mode 100644 ports/atmel-samd/boards/icy-tree-sof-m0/pins.c diff --git a/ports/atmel-samd/boards/cp_sapling_m0_spiflash/board.c b/ports/atmel-samd/boards/cp_sapling_m0_spiflash/board.c new file mode 100644 index 0000000000..ce56366762 --- /dev/null +++ b/ports/atmel-samd/boards/cp_sapling_m0_spiflash/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 "common-hal/microcontroller/Pin.h" +#include "supervisor/shared/board.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/cp_sapling_m0_spiflash/mpconfigboard.h b/ports/atmel-samd/boards/cp_sapling_m0_spiflash/mpconfigboard.h new file mode 100644 index 0000000000..a129566d2d --- /dev/null +++ b/ports/atmel-samd/boards/cp_sapling_m0_spiflash/mpconfigboard.h @@ -0,0 +1,62 @@ +#define MICROPY_HW_BOARD_NAME "CP Sapling M0" +#define MICROPY_HW_MCU_NAME "samd21e18" + +#define MICROPY_HW_NEOPIXEL (&pin_PA15) + +#define MICROPY_PORT_A (0) +#define MICROPY_PORT_B (0) +#define MICROPY_PORT_C (0) + +#define SPI_FLASH_MOSI_PIN &pin_PA18 +#define SPI_FLASH_MISO_PIN &pin_PA17 +#define SPI_FLASH_SCK_PIN &pin_PA19 +#define SPI_FLASH_CS_PIN &pin_PA22 + +#define IGNORE_PIN_PA02 1 +#define IGNORE_PIN_PA03 1 +#define IGNORE_PIN_PA04 1 +#define IGNORE_PIN_PA05 1 +#define IGNORE_PIN_PA06 1 +#define IGNORE_PIN_PA07 1 +#define IGNORE_PIN_PA12 1 +#define IGNORE_PIN_PA13 1 +#define IGNORE_PIN_PA14 1 +#define IGNORE_PIN_PA20 1 +#define IGNORE_PIN_PA21 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_SS (&pin_PA22) +#define DEFAULT_SPI_BUS_SCK (&pin_PA19) +#define DEFAULT_SPI_BUS_MOSI (&pin_PA18) +#define DEFAULT_SPI_BUS_MISO (&pin_PA17) diff --git a/ports/atmel-samd/boards/cp_sapling_m0_spiflash/mpconfigboard.mk b/ports/atmel-samd/boards/cp_sapling_m0_spiflash/mpconfigboard.mk new file mode 100644 index 0000000000..c81209db3b --- /dev/null +++ b/ports/atmel-samd/boards/cp_sapling_m0_spiflash/mpconfigboard.mk @@ -0,0 +1,33 @@ +USB_VID = 0x1209 +USB_PID = 0x4DDD +USB_PRODUCT = "CP Sapling" +USB_MANUFACTURER = "Oak Development Technologies" + +CHIP_VARIANT = SAMD21E18A +CHIP_FAMILY = samd21 + +INTERNAL_FLASH_FILESYSTEM = 0 +LONGINT_IMPL = MPZ +SPI_FLASH_FILESYSTEM = 1 +EXTERNAL_FLASH_DEVICE_COUNT = 1 +EXTERNAL_FLASH_DEVICES = AT25DF081A + +CIRCUITPY_AUDIOIO = 0 +CIRCUITPY_AUDIOBUSIO = 0 +CIRCUITPY_BITBANGIO = 0 +CIRCUITPY_COUNTIO = 0 +CIRCUITPY_FREQUENCYIO = 0 +CIRCUITPY_I2CPERIPHERAL = 0 + +SUPEROPT_GC = 0 + +CFLAGS_BOARD = --param max-inline-insns-auto=15 +ifeq ($(TRANSLATION), zh_Latn_pinyin) +RELEASE_NEEDS_CLEAN_BUILD = 1 +CFLAGS_INLINE_LIMIT = 35 +endif +ifeq ($(TRANSLATION), de_DE) +RELEASE_NEEDS_CLEAN_BUILD = 1 +CFLAGS_INLINE_LIMIT = 35 +SUPEROPT_VM = 0 +endif diff --git a/ports/atmel-samd/boards/cp_sapling_m0_spiflash/pins.c b/ports/atmel-samd/boards/cp_sapling_m0_spiflash/pins.c new file mode 100644 index 0000000000..d527aaddcb --- /dev/null +++ b/ports/atmel-samd/boards/cp_sapling_m0_spiflash/pins.c @@ -0,0 +1,38 @@ +#include "shared-bindings/board/__init__.h" + +STATIC const mp_rom_map_elem_t board_global_dict_table[] = { + + { MP_ROM_QSTR(MP_QSTR_D5), MP_ROM_PTR(&pin_PA08) }, + { MP_ROM_QSTR(MP_QSTR_SDA), MP_ROM_PTR(&pin_PA08) }, + + { MP_ROM_QSTR(MP_QSTR_D10), MP_ROM_PTR(&pin_PA00) }, + { MP_ROM_QSTR(MP_QSTR_A4), MP_ROM_PTR(&pin_PA00) }, + + { MP_ROM_QSTR(MP_QSTR_D11), MP_ROM_PTR(&pin_PA01) }, + { MP_ROM_QSTR(MP_QSTR_A5), MP_ROM_PTR(&pin_PA01) }, + + { MP_ROM_QSTR(MP_QSTR_D4), MP_ROM_PTR(&pin_PA09) }, + { MP_ROM_QSTR(MP_QSTR_SCL), MP_ROM_PTR(&pin_PA09) }, + + { MP_ROM_QSTR(MP_QSTR_D0), MP_ROM_PTR(&pin_PA22) }, + { MP_ROM_QSTR(MP_QSTR_A0), MP_ROM_PTR(&pin_PA22) }, + { MP_ROM_QSTR(MP_QSTR_SS), MP_ROM_PTR(&pin_PA22) }, + + { MP_ROM_QSTR(MP_QSTR_D3), MP_ROM_PTR(&pin_PA19) }, + { MP_ROM_QSTR(MP_QSTR_A3), MP_ROM_PTR(&pin_PA19) }, + { MP_ROM_QSTR(MP_QSTR_SCK), MP_ROM_PTR(&pin_PA19) }, + + { MP_ROM_QSTR(MP_QSTR_D1), MP_ROM_PTR(&pin_PA17) }, + { MP_ROM_QSTR(MP_QSTR_A1), MP_ROM_PTR(&pin_PA17) }, + { MP_ROM_QSTR(MP_QSTR_MISO), MP_ROM_PTR(&pin_PA17) }, + + { MP_ROM_QSTR(MP_QSTR_D2), MP_ROM_PTR(&pin_PA18) }, + { MP_ROM_QSTR(MP_QSTR_A2), MP_ROM_PTR(&pin_PA18) }, + { MP_ROM_QSTR(MP_QSTR_MOSI), MP_ROM_PTR(&pin_PA18) }, + + { MP_ROM_QSTR(MP_QSTR_NEOPIXEL), MP_ROM_PTR(&pin_PA15) }, + + { 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); diff --git a/ports/atmel-samd/boards/icy-tree-sof-m0/board.c b/ports/atmel-samd/boards/icy-tree-sof-m0/board.c new file mode 100644 index 0000000000..1a65a561f7 --- /dev/null +++ b/ports/atmel-samd/boards/icy-tree-sof-m0/board.c @@ -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 + * + * 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" +#include "supervisor/shared/board.h" +#include "hal/include/hal_gpio.h" + +void board_init(void) { + gpio_set_pin_function(PIN_PA15, GPIO_PIN_FUNCTION_OFF); + gpio_set_pin_direction(PIN_PA15, GPIO_DIRECTION_OUT); + gpio_set_pin_level(PIN_PA15, true); // Turn on neopixel by default + never_reset_pin_number(PIN_PA15); +} + +bool board_requests_safe_mode(void) { + return false; +} + +void reset_board(void) { +} diff --git a/ports/atmel-samd/boards/icy-tree-sof-m0/mpconfigboard.h b/ports/atmel-samd/boards/icy-tree-sof-m0/mpconfigboard.h new file mode 100644 index 0000000000..713d2c03eb --- /dev/null +++ b/ports/atmel-samd/boards/icy-tree-sof-m0/mpconfigboard.h @@ -0,0 +1,55 @@ +#define MICROPY_HW_BOARD_NAME "Adafruit QT Py M0" +#define MICROPY_HW_MCU_NAME "samd21e18" + +#define MICROPY_HW_NEOPIXEL (&pin_PA18) + +#define MICROPY_PORT_A (0) +#define MICROPY_PORT_B (0) +#define MICROPY_PORT_C (0) + +#define IGNORE_PIN_PA00 1 +#define IGNORE_PIN_PA01 1 +#define IGNORE_PIN_PA12 1 +#define IGNORE_PIN_PA13 1 +#define IGNORE_PIN_PA14 1 +#define IGNORE_PIN_PA20 1 +#define IGNORE_PIN_PA21 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_PA17) +#define DEFAULT_I2C_BUS_SDA (&pin_PA16) + +#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) diff --git a/ports/atmel-samd/boards/icy-tree-sof-m0/mpconfigboard.mk b/ports/atmel-samd/boards/icy-tree-sof-m0/mpconfigboard.mk new file mode 100644 index 0000000000..964cbe643a --- /dev/null +++ b/ports/atmel-samd/boards/icy-tree-sof-m0/mpconfigboard.mk @@ -0,0 +1,24 @@ +USB_VID = 0x239A +USB_PID = 0x80CC +USB_PRODUCT = "QT Py M0" +USB_MANUFACTURER = "Adafruit Industries LLC" + +CHIP_VARIANT = SAMD21E18A +CHIP_FAMILY = samd21 + +INTERNAL_FLASH_FILESYSTEM = 1 +LONGINT_IMPL = NONE +CIRCUITPY_FULL_BUILD = 0 + +SUPEROPT_GC = 0 + +CFLAGS_BOARD = --param max-inline-insns-auto=15 +ifeq ($(TRANSLATION), zh_Latn_pinyin) +RELEASE_NEEDS_CLEAN_BUILD = 1 +CFLAGS_INLINE_LIMIT = 35 +endif +ifeq ($(TRANSLATION), de_DE) +RELEASE_NEEDS_CLEAN_BUILD = 1 +CFLAGS_INLINE_LIMIT = 35 +SUPEROPT_VM = 0 +endif diff --git a/ports/atmel-samd/boards/icy-tree-sof-m0/pins.c b/ports/atmel-samd/boards/icy-tree-sof-m0/pins.c new file mode 100644 index 0000000000..636c48bffc --- /dev/null +++ b/ports/atmel-samd/boards/icy-tree-sof-m0/pins.c @@ -0,0 +1,49 @@ +#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_PA02) }, + { MP_ROM_QSTR(MP_QSTR_A0), MP_ROM_PTR(&pin_PA02) }, + + { MP_ROM_QSTR(MP_QSTR_D1), MP_ROM_PTR(&pin_PA03) }, + { MP_ROM_QSTR(MP_QSTR_A1), MP_ROM_PTR(&pin_PA03) }, + + { MP_ROM_QSTR(MP_QSTR_D2), MP_ROM_PTR(&pin_PA04) }, + { MP_ROM_QSTR(MP_QSTR_A2), MP_ROM_PTR(&pin_PA04) }, + + { MP_ROM_QSTR(MP_QSTR_D3), MP_ROM_PTR(&pin_PA05) }, + { MP_ROM_QSTR(MP_QSTR_A3), MP_ROM_PTR(&pin_PA05) }, + + { MP_ROM_QSTR(MP_QSTR_D4), MP_ROM_PTR(&pin_PA16) }, + { MP_ROM_QSTR(MP_QSTR_SDA), MP_ROM_PTR(&pin_PA16) }, + + { MP_ROM_QSTR(MP_QSTR_D5), MP_ROM_PTR(&pin_PA17) }, + { MP_ROM_QSTR(MP_QSTR_SCL), MP_ROM_PTR(&pin_PA17) }, + + { MP_ROM_QSTR(MP_QSTR_D6), MP_ROM_PTR(&pin_PA06) }, + { MP_ROM_QSTR(MP_QSTR_A6), MP_ROM_PTR(&pin_PA06) }, + { MP_ROM_QSTR(MP_QSTR_TX), MP_ROM_PTR(&pin_PA06) }, + + { MP_ROM_QSTR(MP_QSTR_D7), MP_ROM_PTR(&pin_PA07) }, + { MP_ROM_QSTR(MP_QSTR_A7), MP_ROM_PTR(&pin_PA07) }, + { MP_ROM_QSTR(MP_QSTR_RX), MP_ROM_PTR(&pin_PA07) }, + + { MP_ROM_QSTR(MP_QSTR_D8), MP_ROM_PTR(&pin_PA11) }, + { MP_ROM_QSTR(MP_QSTR_A8), MP_ROM_PTR(&pin_PA11) }, + { MP_ROM_QSTR(MP_QSTR_SCK), MP_ROM_PTR(&pin_PA11) }, + + { MP_ROM_QSTR(MP_QSTR_D9), MP_ROM_PTR(&pin_PA09) }, + { MP_ROM_QSTR(MP_QSTR_A9), MP_ROM_PTR(&pin_PA09) }, + { MP_ROM_QSTR(MP_QSTR_MISO), MP_ROM_PTR(&pin_PA09) }, + + { MP_ROM_QSTR(MP_QSTR_D10), MP_ROM_PTR(&pin_PA10) }, + { MP_ROM_QSTR(MP_QSTR_A10), MP_ROM_PTR(&pin_PA10) }, + { MP_ROM_QSTR(MP_QSTR_MOSI), MP_ROM_PTR(&pin_PA10) }, + + { MP_ROM_QSTR(MP_QSTR_NEOPIXEL), MP_ROM_PTR(&pin_PA18) }, + { MP_ROM_QSTR(MP_QSTR_NEOPIXEL_POWER), MP_ROM_PTR(&pin_PA15) }, + + { 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 0e628caa6f0697ee8747df50c6ad3bfd9a76e4f6 Mon Sep 17 00:00:00 2001 From: Seth Kerr Date: Mon, 23 Nov 2020 19:23:22 -0500 Subject: [PATCH 124/207] forgot the build.yml files --- .github/workflows/build.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 8e72a40219..06cc49923d 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -199,6 +199,7 @@ jobs: - "clue_nrf52840_express" - "cp32-m4" - "cp_sapling_m0" + - "cp_sapling_m0_spiflash" - "datalore_ip_m4" - "datum_distance" - "datum_imu" From e5cee989771f6c79b91e8c3a039d167bf7022fa4 Mon Sep 17 00:00:00 2001 From: Seth Kerr Date: Mon, 23 Nov 2020 19:31:06 -0500 Subject: [PATCH 125/207] removing icy tree files/directory --- .../atmel-samd/boards/icy-tree-sof-m0/board.c | 44 --------------- .../boards/icy-tree-sof-m0/mpconfigboard.h | 55 ------------------- .../boards/icy-tree-sof-m0/mpconfigboard.mk | 24 -------- .../atmel-samd/boards/icy-tree-sof-m0/pins.c | 49 ----------------- 4 files changed, 172 deletions(-) delete mode 100644 ports/atmel-samd/boards/icy-tree-sof-m0/board.c delete mode 100644 ports/atmel-samd/boards/icy-tree-sof-m0/mpconfigboard.h delete mode 100644 ports/atmel-samd/boards/icy-tree-sof-m0/mpconfigboard.mk delete mode 100644 ports/atmel-samd/boards/icy-tree-sof-m0/pins.c diff --git a/ports/atmel-samd/boards/icy-tree-sof-m0/board.c b/ports/atmel-samd/boards/icy-tree-sof-m0/board.c deleted file mode 100644 index 1a65a561f7..0000000000 --- a/ports/atmel-samd/boards/icy-tree-sof-m0/board.c +++ /dev/null @@ -1,44 +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 "common-hal/microcontroller/Pin.h" -#include "supervisor/shared/board.h" -#include "hal/include/hal_gpio.h" - -void board_init(void) { - gpio_set_pin_function(PIN_PA15, GPIO_PIN_FUNCTION_OFF); - gpio_set_pin_direction(PIN_PA15, GPIO_DIRECTION_OUT); - gpio_set_pin_level(PIN_PA15, true); // Turn on neopixel by default - never_reset_pin_number(PIN_PA15); -} - -bool board_requests_safe_mode(void) { - return false; -} - -void reset_board(void) { -} diff --git a/ports/atmel-samd/boards/icy-tree-sof-m0/mpconfigboard.h b/ports/atmel-samd/boards/icy-tree-sof-m0/mpconfigboard.h deleted file mode 100644 index 713d2c03eb..0000000000 --- a/ports/atmel-samd/boards/icy-tree-sof-m0/mpconfigboard.h +++ /dev/null @@ -1,55 +0,0 @@ -#define MICROPY_HW_BOARD_NAME "Adafruit QT Py M0" -#define MICROPY_HW_MCU_NAME "samd21e18" - -#define MICROPY_HW_NEOPIXEL (&pin_PA18) - -#define MICROPY_PORT_A (0) -#define MICROPY_PORT_B (0) -#define MICROPY_PORT_C (0) - -#define IGNORE_PIN_PA00 1 -#define IGNORE_PIN_PA01 1 -#define IGNORE_PIN_PA12 1 -#define IGNORE_PIN_PA13 1 -#define IGNORE_PIN_PA14 1 -#define IGNORE_PIN_PA20 1 -#define IGNORE_PIN_PA21 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_PA17) -#define DEFAULT_I2C_BUS_SDA (&pin_PA16) - -#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) diff --git a/ports/atmel-samd/boards/icy-tree-sof-m0/mpconfigboard.mk b/ports/atmel-samd/boards/icy-tree-sof-m0/mpconfigboard.mk deleted file mode 100644 index 964cbe643a..0000000000 --- a/ports/atmel-samd/boards/icy-tree-sof-m0/mpconfigboard.mk +++ /dev/null @@ -1,24 +0,0 @@ -USB_VID = 0x239A -USB_PID = 0x80CC -USB_PRODUCT = "QT Py M0" -USB_MANUFACTURER = "Adafruit Industries LLC" - -CHIP_VARIANT = SAMD21E18A -CHIP_FAMILY = samd21 - -INTERNAL_FLASH_FILESYSTEM = 1 -LONGINT_IMPL = NONE -CIRCUITPY_FULL_BUILD = 0 - -SUPEROPT_GC = 0 - -CFLAGS_BOARD = --param max-inline-insns-auto=15 -ifeq ($(TRANSLATION), zh_Latn_pinyin) -RELEASE_NEEDS_CLEAN_BUILD = 1 -CFLAGS_INLINE_LIMIT = 35 -endif -ifeq ($(TRANSLATION), de_DE) -RELEASE_NEEDS_CLEAN_BUILD = 1 -CFLAGS_INLINE_LIMIT = 35 -SUPEROPT_VM = 0 -endif diff --git a/ports/atmel-samd/boards/icy-tree-sof-m0/pins.c b/ports/atmel-samd/boards/icy-tree-sof-m0/pins.c deleted file mode 100644 index 636c48bffc..0000000000 --- a/ports/atmel-samd/boards/icy-tree-sof-m0/pins.c +++ /dev/null @@ -1,49 +0,0 @@ -#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_PA02) }, - { MP_ROM_QSTR(MP_QSTR_A0), MP_ROM_PTR(&pin_PA02) }, - - { MP_ROM_QSTR(MP_QSTR_D1), MP_ROM_PTR(&pin_PA03) }, - { MP_ROM_QSTR(MP_QSTR_A1), MP_ROM_PTR(&pin_PA03) }, - - { MP_ROM_QSTR(MP_QSTR_D2), MP_ROM_PTR(&pin_PA04) }, - { MP_ROM_QSTR(MP_QSTR_A2), MP_ROM_PTR(&pin_PA04) }, - - { MP_ROM_QSTR(MP_QSTR_D3), MP_ROM_PTR(&pin_PA05) }, - { MP_ROM_QSTR(MP_QSTR_A3), MP_ROM_PTR(&pin_PA05) }, - - { MP_ROM_QSTR(MP_QSTR_D4), MP_ROM_PTR(&pin_PA16) }, - { MP_ROM_QSTR(MP_QSTR_SDA), MP_ROM_PTR(&pin_PA16) }, - - { MP_ROM_QSTR(MP_QSTR_D5), MP_ROM_PTR(&pin_PA17) }, - { MP_ROM_QSTR(MP_QSTR_SCL), MP_ROM_PTR(&pin_PA17) }, - - { MP_ROM_QSTR(MP_QSTR_D6), MP_ROM_PTR(&pin_PA06) }, - { MP_ROM_QSTR(MP_QSTR_A6), MP_ROM_PTR(&pin_PA06) }, - { MP_ROM_QSTR(MP_QSTR_TX), MP_ROM_PTR(&pin_PA06) }, - - { MP_ROM_QSTR(MP_QSTR_D7), MP_ROM_PTR(&pin_PA07) }, - { MP_ROM_QSTR(MP_QSTR_A7), MP_ROM_PTR(&pin_PA07) }, - { MP_ROM_QSTR(MP_QSTR_RX), MP_ROM_PTR(&pin_PA07) }, - - { MP_ROM_QSTR(MP_QSTR_D8), MP_ROM_PTR(&pin_PA11) }, - { MP_ROM_QSTR(MP_QSTR_A8), MP_ROM_PTR(&pin_PA11) }, - { MP_ROM_QSTR(MP_QSTR_SCK), MP_ROM_PTR(&pin_PA11) }, - - { MP_ROM_QSTR(MP_QSTR_D9), MP_ROM_PTR(&pin_PA09) }, - { MP_ROM_QSTR(MP_QSTR_A9), MP_ROM_PTR(&pin_PA09) }, - { MP_ROM_QSTR(MP_QSTR_MISO), MP_ROM_PTR(&pin_PA09) }, - - { MP_ROM_QSTR(MP_QSTR_D10), MP_ROM_PTR(&pin_PA10) }, - { MP_ROM_QSTR(MP_QSTR_A10), MP_ROM_PTR(&pin_PA10) }, - { MP_ROM_QSTR(MP_QSTR_MOSI), MP_ROM_PTR(&pin_PA10) }, - - { MP_ROM_QSTR(MP_QSTR_NEOPIXEL), MP_ROM_PTR(&pin_PA18) }, - { MP_ROM_QSTR(MP_QSTR_NEOPIXEL_POWER), MP_ROM_PTR(&pin_PA15) }, - - { 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 7a45afc54919162df342fab421ed113ff1771d01 Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Mon, 23 Nov 2020 22:44:53 -0500 Subject: [PATCH 126/207] working, but need to avoid deep sleeping too fast before USB ready --- main.c | 104 ++++++++++-------- ports/esp32s2/Makefile | 4 +- ports/esp32s2/common-hal/alarm/__init__.c | 4 +- .../common-hal/microcontroller/__init__.c | 4 +- py/circuitpy_defns.mk | 1 + shared-bindings/alarm/__init__.h | 3 + shared-bindings/microcontroller/__init__.c | 14 --- shared-bindings/microcontroller/__init__.h | 2 +- shared-bindings/supervisor/RunReason.c | 4 +- shared-bindings/supervisor/Runtime.c | 3 + shared-bindings/supervisor/__init__.c | 51 ++++++++- supervisor/shared/workflow.c | 26 +++++ supervisor/shared/workflow.h | 8 +- 13 files changed, 153 insertions(+), 75 deletions(-) diff --git a/main.c b/main.c index f77bf41d84..b2e527ddef 100755 --- a/main.c +++ b/main.c @@ -47,17 +47,17 @@ #include "mpconfigboard.h" #include "supervisor/background_callback.h" #include "supervisor/cpu.h" +#include "supervisor/filesystem.h" #include "supervisor/memory.h" #include "supervisor/port.h" -#include "supervisor/filesystem.h" +#include "supervisor/serial.h" #include "supervisor/shared/autoreload.h" -#include "supervisor/shared/translate.h" #include "supervisor/shared/rgb_led_status.h" #include "supervisor/shared/safe_mode.h" -#include "supervisor/shared/status_leds.h" #include "supervisor/shared/stack.h" +#include "supervisor/shared/status_leds.h" +#include "supervisor/shared/translate.h" #include "supervisor/shared/workflow.h" -#include "supervisor/serial.h" #include "supervisor/usb.h" #include "shared-bindings/microcontroller/__init__.h" @@ -66,6 +66,8 @@ #include "boards/board.h" +#include "esp_log.h" + #if CIRCUITPY_ALARM #include "shared-bindings/alarm/__init__.h" #endif @@ -101,26 +103,6 @@ // How long to flash errors on the RGB status LED before going to sleep (secs) #define CIRCUITPY_FLASH_ERROR_PERIOD 10 -void do_str(const char *src, mp_parse_input_kind_t input_kind) { - mp_lexer_t *lex = mp_lexer_new_from_str_len(MP_QSTR__lt_stdin_gt_, src, strlen(src), 0); - if (lex == NULL) { - //printf("MemoryError: lexer could not allocate memory\n"); - return; - } - - nlr_buf_t nlr; - if (nlr_push(&nlr) == 0) { - qstr source_name = lex->source_name; - mp_parse_tree_t parse_tree = mp_parse(lex, input_kind); - mp_obj_t module_fun = mp_compile(&parse_tree, source_name, MP_EMIT_OPT_NONE, true); - mp_call_function_0(module_fun); - nlr_pop(); - } else { - // uncaught exception - mp_obj_print_exception(&mp_plat_print, (mp_obj_t)nlr.ret_val); - } -} - #if MICROPY_ENABLE_PYSTACK static size_t PLACE_IN_DTCM_BSS(_pystack[CIRCUITPY_PYSTACK_SIZE / sizeof(size_t)]); #endif @@ -131,9 +113,13 @@ static void reset_devices(void) { #endif } -void start_mp(supervisor_allocation* heap) { +STATIC void start_mp(supervisor_allocation* heap) { reset_status_led(); autoreload_stop(); + supervisor_workflow_reset(); +#if CIRCUITPY_ALARM + alarm_reset(); +#endif // Stack limit should be less than real stack size, so we have a chance // to recover from limit hit. (Limit is measured in bytes.) @@ -182,7 +168,7 @@ void start_mp(supervisor_allocation* heap) { #endif } -void stop_mp(void) { +STATIC void stop_mp(void) { #if CIRCUITPY_NETWORK network_module_deinit(); #endif @@ -207,7 +193,7 @@ void stop_mp(void) { // Look for the first file that exists in the list of filenames, using mp_import_stat(). // Return its index. If no file found, return -1. -const char* first_existing_file_in_list(const char * const * filenames) { +STATIC const char* first_existing_file_in_list(const char * const * filenames) { for (int i = 0; filenames[i] != (char*)""; i++) { mp_import_stat_t stat = mp_import_stat(filenames[i]); if (stat == MP_IMPORT_STAT_FILE) { @@ -217,7 +203,7 @@ const char* first_existing_file_in_list(const char * const * filenames) { return NULL; } -bool maybe_run_list(const char * const * filenames, pyexec_result_t* exec_result) { +STATIC bool maybe_run_list(const char * const * filenames, pyexec_result_t* exec_result) { const char* filename = first_existing_file_in_list(filenames); if (filename == NULL) { return false; @@ -231,7 +217,7 @@ bool maybe_run_list(const char * const * filenames, pyexec_result_t* exec_result return true; } -void cleanup_after_vm(supervisor_allocation* heap) { +STATIC void cleanup_after_vm(supervisor_allocation* heap) { // Reset port-independent devices, like CIRCUITPY_BLEIO_HCI. reset_devices(); // Turn off the display and flush the fileystem before the heap disappears. @@ -260,7 +246,7 @@ void cleanup_after_vm(supervisor_allocation* heap) { reset_status_led(); } -void print_code_py_status_message(safe_mode_t safe_mode) { +STATIC void print_code_py_status_message(safe_mode_t safe_mode) { if (autoreload_is_enabled()) { serial_write_compressed(translate("Auto-reload is on. Simply save files over USB to run them or enter REPL to disable.\n")); } else { @@ -272,7 +258,7 @@ void print_code_py_status_message(safe_mode_t safe_mode) { } } -bool run_code_py(safe_mode_t safe_mode) { +STATIC bool run_code_py(safe_mode_t safe_mode) { bool serial_connected_at_start = serial_connected(); #if CIRCUITPY_AUTORELOAD_DELAY_MS > 0 if (serial_connected_at_start) { @@ -318,6 +304,8 @@ bool run_code_py(safe_mode_t safe_mode) { } } + // Program has finished running. + // Display a different completion message if the user has no USB attached (cannot save files) if (!serial_connected_at_start) { serial_write_compressed(translate("\nCode done running. Waiting for reload.\n")); @@ -329,11 +317,26 @@ bool run_code_py(safe_mode_t safe_mode) { #endif rgb_status_animation_t animation; bool ok = result.return_code != PYEXEC_EXCEPTION; - // If USB isn't enumerated then deep sleep. - if (ok && !supervisor_workflow_active() && supervisor_ticks_ms64() > CIRCUITPY_USB_ENUMERATION_DELAY * 1024) { - common_hal_mcu_deep_sleep(); - } - // Show the animation every N seconds. + + ESP_LOGI("main", "common_hal_alarm_enable_deep_sleep_alarms()"); + // Decide whether to deep sleep. + #if CIRCUITPY_ALARM + // Enable pin or time alarms before sleeping. + common_hal_alarm_enable_deep_sleep_alarms(); + #endif + + // Normally we won't deep sleep if there was an error or if we are connected to a host + // but either of those can be enabled. + // *********DON'T SLEEP IF USB HASN'T HAD TIME TO ENUMERATE. + bool will_deep_sleep = + (ok || supervisor_workflow_get_allow_deep_sleep_on_error()) && + (!supervisor_workflow_active() || supervisor_workflow_get_allow_deep_sleep_when_connected()); + + ESP_LOGI("main", "ok %d", will_deep_sleep); + ESP_LOGI("main", "...on_error() %d", supervisor_workflow_get_allow_deep_sleep_on_error()); + ESP_LOGI("main", "supervisor_workflow_active() %d", supervisor_workflow_active()); + ESP_LOGI("main", "...when_connected() %d", supervisor_workflow_get_allow_deep_sleep_when_connected()); + will_deep_sleep = false; prep_rgb_status_animation(&result, found_main, safe_mode, &animation); while (true) { RUN_BACKGROUND_TASKS; @@ -356,9 +359,12 @@ bool run_code_py(safe_mode_t safe_mode) { if (!serial_connected_at_start) { print_code_py_status_message(safe_mode); } - print_safe_mode_message(safe_mode); - serial_write("\n"); - serial_write_compressed(translate("Press any key to enter the REPL. Use CTRL-D to reload.")); + // We won't be going into the REPL if we're going to sleep. + if (!will_deep_sleep) { + print_safe_mode_message(safe_mode); + serial_write("\n"); + serial_write_compressed(translate("Press any key to enter the REPL. Use CTRL-D to reload.")); + } } if (serial_connected_before_animation && !serial_connected()) { serial_connected_at_start = false; @@ -371,16 +377,22 @@ bool run_code_py(safe_mode_t safe_mode) { refreshed_epaper_display = maybe_refresh_epaperdisplay(); } #endif - bool animation_done = tick_rgb_status_animation(&animation); - if (animation_done && supervisor_workflow_active()) { - #if CIRCUITPY_ALARM + + bool animation_done = false; + if (will_deep_sleep && ok) { + // Skip animation if everything is OK. + animation_done = true; + } else { + animation_done = tick_rgb_status_animation(&animation); + } + // Do an error animation only once before deep-sleeping. + if (animation_done && will_deep_sleep) { int64_t remaining_enumeration_wait = CIRCUITPY_USB_ENUMERATION_DELAY * 1024 - supervisor_ticks_ms64(); // If USB isn't enumerated then deep sleep after our waiting period. if (ok && remaining_enumeration_wait < 0) { common_hal_mcu_deep_sleep(); - return false; // Doesn't actually get here. + // Does not return. } - #endif // Wake up every so often to flash the error code. if (!ok) { port_interrupt_after_ticks(CIRCUITPY_FLASH_ERROR_PERIOD * 1024); @@ -394,7 +406,7 @@ bool run_code_py(safe_mode_t safe_mode) { FIL* boot_output_file; -void __attribute__ ((noinline)) run_boot_py(safe_mode_t safe_mode) { +STATIC void __attribute__ ((noinline)) run_boot_py(safe_mode_t safe_mode) { // If not in safe mode, run boot before initing USB and capture output in a // file. if (filesystem_present() && safe_mode == NO_SAFE_MODE && MP_STATE_VM(vfs_mount_table) != NULL) { @@ -473,7 +485,7 @@ void __attribute__ ((noinline)) run_boot_py(safe_mode_t safe_mode) { } } -int run_repl(void) { +STATIC int run_repl(void) { int exit_code = PYEXEC_FORCED_EXIT; stack_resize(); filesystem_flush(); diff --git a/ports/esp32s2/Makefile b/ports/esp32s2/Makefile index 55d6e91d44..794df0daba 100644 --- a/ports/esp32s2/Makefile +++ b/ports/esp32s2/Makefile @@ -332,10 +332,10 @@ $(BUILD)/firmware.uf2: $(BUILD)/circuitpython-firmware.bin $(Q)$(PYTHON3) $(TOP)/tools/uf2/utils/uf2conv.py -f 0xbfdd4eee -b 0x0000 -c -o $@ $^ flash: $(BUILD)/firmware.bin - esptool.py --chip esp32s2 -p $(PORT) --no-stub -b 460800 --before=default_reset --after=hard_reset write_flash $(FLASH_FLAGS) 0x0000 $^ + esptool.py --chip esp32s2 -p $(PORT) --no-stub -b 460800 --before=default_reset --after=no_reset write_flash $(FLASH_FLAGS) 0x0000 $^ flash-circuitpython-only: $(BUILD)/circuitpython-firmware.bin - esptool.py --chip esp32s2 -p $(PORT) --no-stub -b 460800 --before=default_reset --after=hard_reset write_flash $(FLASH_FLAGS) 0x10000 $^ + esptool.py --chip esp32s2 -p $(PORT) --no-stub -b 460800 --before=default_reset --after=no_reset write_flash $(FLASH_FLAGS) 0x10000 $^ include $(TOP)/py/mkrules.mk diff --git a/ports/esp32s2/common-hal/alarm/__init__.c b/ports/esp32s2/common-hal/alarm/__init__.c index 0ea476d860..87276bdaf0 100644 --- a/ports/esp32s2/common-hal/alarm/__init__.c +++ b/ports/esp32s2/common-hal/alarm/__init__.c @@ -95,7 +95,7 @@ void common_hal_alarm_set_deep_sleep_alarms(size_t n_alarms, const mp_obj_t *ala _deep_sleep_alarms = mp_obj_new_tuple(n_alarms, alarms); } -void common_hal_deep_sleep_with_alarms(void) { +void common_hal_alarm_enable_deep_sleep_alarms(void) { for (size_t i = 0; i < _deep_sleep_alarms->len; i++) { mp_obj_t alarm = _deep_sleep_alarms->items[i]; if (MP_OBJ_IS_TYPE(alarm, &alarm_time_duration_alarm_type)) { @@ -105,6 +105,4 @@ void common_hal_deep_sleep_with_alarms(void) { } // TODO: handle pin alarms } - - common_hal_mcu_deep_sleep(); } diff --git a/ports/esp32s2/common-hal/microcontroller/__init__.c b/ports/esp32s2/common-hal/microcontroller/__init__.c index 59eb1afcc0..5aa0ff8eda 100644 --- a/ports/esp32s2/common-hal/microcontroller/__init__.c +++ b/ports/esp32s2/common-hal/microcontroller/__init__.c @@ -80,11 +80,9 @@ void common_hal_mcu_reset(void) { while(1); } -void common_hal_mcu_deep_sleep(void) { +void NORETURN common_hal_mcu_deep_sleep(void) { // Shut down wifi cleanly. esp_wifi_stop(); - - // Does not return. esp_deep_sleep_start(); } diff --git a/py/circuitpy_defns.mk b/py/circuitpy_defns.mk index 2731f2ae8d..27466282a8 100644 --- a/py/circuitpy_defns.mk +++ b/py/circuitpy_defns.mk @@ -403,6 +403,7 @@ $(filter $(SRC_PATTERNS), \ math/__init__.c \ microcontroller/ResetReason.c \ microcontroller/RunMode.c \ + supervisor/RunReason.c \ ) SRC_BINDINGS_ENUMS += \ diff --git a/shared-bindings/alarm/__init__.h b/shared-bindings/alarm/__init__.h index c74dfbe5c3..d8d6812c90 100644 --- a/shared-bindings/alarm/__init__.h +++ b/shared-bindings/alarm/__init__.h @@ -29,7 +29,10 @@ #include "py/obj.h" +#include "common-hal/alarm/__init__.h" + extern mp_obj_t common_hal_alarm_sleep_until_alarms(size_t n_alarms, const mp_obj_t *alarms); +extern void common_hal_alarm_enable_deep_sleep_alarms(void); extern void common_hal_alarm_set_deep_sleep_alarms(size_t n_alarms, const mp_obj_t *alarms); // Used by wake-up code. diff --git a/shared-bindings/microcontroller/__init__.c b/shared-bindings/microcontroller/__init__.c index d6ce323c58..d09cf8f445 100644 --- a/shared-bindings/microcontroller/__init__.c +++ b/shared-bindings/microcontroller/__init__.c @@ -56,19 +56,6 @@ //| This object is the sole instance of `microcontroller.Processor`.""" //| -//| def deep_sleep() -> None: -//| Go into deep sleep. If the board is connected via USB, disconnect USB first. -//| -//| The board will awake from deep sleep only if the reset button is pressed -//| or it is awoken by an alarm set by `alarm.set_deep_sleep_alarms()`. -//| ... -//| -STATIC mp_obj_t mcu_deep_sleep(void){ - - return mp_const_none; -} -MP_DEFINE_CONST_FUN_OBJ_0(mcu_deep_sleep_obj, mcu_deep_sleep); - //| def delay_us(delay: int) -> None: //| """Dedicated delay method used for very short delays. **Do not** do long delays //| because this stops all other functions from completing. Think of this as an empty @@ -177,7 +164,6 @@ const mp_obj_module_t mcu_pin_module = { STATIC const mp_rom_map_elem_t mcu_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_microcontroller) }, { MP_ROM_QSTR(MP_QSTR_cpu), MP_ROM_PTR(&common_hal_mcu_processor_obj) }, - { MP_ROM_QSTR(MP_QSTR_deep_sleep), MP_ROM_PTR(&mcu_deep_sleep_obj) }, { MP_ROM_QSTR(MP_QSTR_delay_us), MP_ROM_PTR(&mcu_delay_us_obj) }, { MP_ROM_QSTR(MP_QSTR_disable_interrupts), MP_ROM_PTR(&mcu_disable_interrupts_obj) }, { MP_ROM_QSTR(MP_QSTR_enable_interrupts), MP_ROM_PTR(&mcu_enable_interrupts_obj) }, diff --git a/shared-bindings/microcontroller/__init__.h b/shared-bindings/microcontroller/__init__.h index c6ccccea72..87284fc2e5 100644 --- a/shared-bindings/microcontroller/__init__.h +++ b/shared-bindings/microcontroller/__init__.h @@ -43,7 +43,7 @@ extern void common_hal_mcu_enable_interrupts(void); extern void common_hal_mcu_on_next_reset(mcu_runmode_t runmode); extern void common_hal_mcu_reset(void); -extern void common_hal_mcu_deep_sleep(void); +extern void NORETURN common_hal_mcu_deep_sleep(void); extern const mp_obj_dict_t mcu_pin_globals; diff --git a/shared-bindings/supervisor/RunReason.c b/shared-bindings/supervisor/RunReason.c index 7e7a74d2f4..73f62fed6d 100644 --- a/shared-bindings/supervisor/RunReason.c +++ b/shared-bindings/supervisor/RunReason.c @@ -29,7 +29,7 @@ #include "shared-bindings/supervisor/RunReason.h" MAKE_ENUM_VALUE(supervisor_run_reason_type, run_reason, STARTUP, RUN_REASON_STARTUP); -MAKE_ENUM_VALUE(supervisor_run_reason_type, run_reason, AUTORELOAD, RUN_REASON_AUTO_RELOAD); +MAKE_ENUM_VALUE(supervisor_run_reason_type, run_reason, AUTO_RELOAD, RUN_REASON_AUTO_RELOAD); MAKE_ENUM_VALUE(supervisor_run_reason_type, run_reason, SUPERVISOR_RELOAD, RUN_REASON_SUPERVISOR_RELOAD); MAKE_ENUM_VALUE(supervisor_run_reason_type, run_reason, REPL_RELOAD, RUN_REASON_REPL_RELOAD); @@ -49,7 +49,7 @@ MAKE_ENUM_VALUE(supervisor_run_reason_type, run_reason, REPL_RELOAD, RUN_REASON_ //| REPL_RELOAD: object //| """CircuitPython started due to the user typing CTRL-D in the REPL.""" //| -MAKE_ENUM_MAP(run_reason) { +MAKE_ENUM_MAP(supervisor_run_reason) { MAKE_ENUM_MAP_ENTRY(run_reason, STARTUP), MAKE_ENUM_MAP_ENTRY(run_reason, AUTO_RELOAD), MAKE_ENUM_MAP_ENTRY(run_reason, SUPERVISOR_RELOAD), diff --git a/shared-bindings/supervisor/Runtime.c b/shared-bindings/supervisor/Runtime.c index 67193e051e..1a283b35c0 100755 --- a/shared-bindings/supervisor/Runtime.c +++ b/shared-bindings/supervisor/Runtime.c @@ -25,8 +25,11 @@ */ #include +#include "py/obj.h" #include "py/enum.h" +#include "py/runtime.h" #include "py/objproperty.h" + #include "shared-bindings/supervisor/RunReason.h" #include "shared-bindings/supervisor/Runtime.h" diff --git a/shared-bindings/supervisor/__init__.c b/shared-bindings/supervisor/__init__.c index 4d2d6db309..c13b19e48e 100644 --- a/shared-bindings/supervisor/__init__.c +++ b/shared-bindings/supervisor/__init__.c @@ -32,7 +32,9 @@ #include "supervisor/shared/rgb_led_status.h" #include "supervisor/shared/stack.h" #include "supervisor/shared/translate.h" +#include "supervisor/shared/workflow.h" +#include "shared-bindings/microcontroller/__init__.h" #include "shared-bindings/supervisor/__init__.h" #include "shared-bindings/supervisor/Runtime.h" @@ -45,6 +47,47 @@ //| This object is the sole instance of `supervisor.Runtime`.""" //| +//| def allow_deep_sleep(*, when_connected: bool = False, on_error: bool = False): +//| """Configure when CircuitPython can go into deep sleep. Deep sleep can occur +//| after a program has finished running or when `supervisor.deep_sleep_now()` is called. +//| +//| :param bool when_connected: If ``True``, CircuitPython will go into deep sleep +//| when a program finishes, even if it is connected to a host computer over USB or other means. +//| It will disconnect from the host before sleeping. +//| If ``False``, deep sleep will not be entered if connected. +//| :param bool on_error: If ``True``, deep sleep will be entered if even a program +//| terminated due to an exception or fatal error. If ``False``, an error will cause +//| CircuitPython to stay awake, flashing error codes on the status RGB LED, if available. +//| ... +//| +STATIC mp_obj_t supervisor_allow_deep_sleep(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { + enum { ARG_when_connected, ARG_on_error }; + static const mp_arg_t allowed_args[] = { + { MP_QSTR_when_connected, MP_ARG_KW_ONLY | MP_ARG_BOOL, {.u_bool = false} }, + { MP_QSTR_on_error, 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); + + supervisor_workflow_set_allow_deep_sleep_when_connected(args[ARG_when_connected].u_bool); + supervisor_workflow_set_allow_deep_sleep_on_error(args[ARG_on_error].u_bool); + + return mp_const_none; +} +MP_DEFINE_CONST_FUN_OBJ_KW(supervisor_allow_deep_sleep_obj, 0, supervisor_allow_deep_sleep); + +//| def deep_sleep(): -> None +//| """Go into deep sleep mode immediately, if not connected to a host computer. +//| But if connected and `supervisor.runtime.allow_deep_sleep(when_connected=true)` +//| has not been called, simply restart. +//| + +STATIC mp_obj_t supervisor_deep_sleep(void) { + common_hal_mcu_deep_sleep(); +} +MP_DEFINE_CONST_FUN_OBJ_0(supervisor_deep_sleep_obj, supervisor_deep_sleep); + //| def enable_autoreload() -> None: //| """Enable autoreload based on USB file write activity.""" //| ... @@ -112,9 +155,11 @@ MP_DEFINE_CONST_FUN_OBJ_1(supervisor_set_next_stack_limit_obj, supervisor_set_ne STATIC const mp_rom_map_elem_t supervisor_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_supervisor) }, - { MP_OBJ_NEW_QSTR(MP_QSTR_enable_autoreload), MP_ROM_PTR(&supervisor_enable_autoreload_obj) }, - { MP_OBJ_NEW_QSTR(MP_QSTR_disable_autoreload), MP_ROM_PTR(&supervisor_disable_autoreload_obj) }, - { MP_OBJ_NEW_QSTR(MP_QSTR_set_rgb_status_brightness), MP_ROM_PTR(&supervisor_set_rgb_status_brightness_obj) }, + { MP_ROM_QSTR(MP_QSTR_allow_deep_sleep), MP_ROM_PTR(&supervisor_allow_deep_sleep_obj) }, + { MP_ROM_QSTR(MP_QSTR_deep_sleep), MP_ROM_PTR(&supervisor_deep_sleep_obj) }, + { MP_ROM_QSTR(MP_QSTR_enable_autoreload), MP_ROM_PTR(&supervisor_enable_autoreload_obj) }, + { MP_ROM_QSTR(MP_QSTR_disable_autoreload), MP_ROM_PTR(&supervisor_disable_autoreload_obj) }, + { MP_ROM_QSTR(MP_QSTR_set_rgb_status_brightness), MP_ROM_PTR(&supervisor_set_rgb_status_brightness_obj) }, { MP_ROM_QSTR(MP_QSTR_runtime), MP_ROM_PTR(&common_hal_supervisor_runtime_obj) }, { MP_ROM_QSTR(MP_QSTR_reload), MP_ROM_PTR(&supervisor_reload_obj) }, { MP_ROM_QSTR(MP_QSTR_set_next_stack_limit), MP_ROM_PTR(&supervisor_set_next_stack_limit_obj) }, diff --git a/supervisor/shared/workflow.c b/supervisor/shared/workflow.c index 41af22eb70..67d191172f 100644 --- a/supervisor/shared/workflow.c +++ b/supervisor/shared/workflow.c @@ -25,10 +25,36 @@ */ #include +#include "py/mpconfig.h" #include "tusb.h" +STATIC bool _allow_deep_sleep_when_connected; +STATIC bool _allow_deep_sleep_on_error; + + +void supervisor_workflow_reset(void) { + _allow_deep_sleep_when_connected = false; + _allow_deep_sleep_on_error = false; +} + bool supervisor_workflow_active(void) { // Eventually there might be other non-USB workflows, such as BLE. // tud_ready() checks for usb mounted and not suspended. return tud_ready(); } + +bool supervisor_workflow_get_allow_deep_sleep_when_connected(void) { + return _allow_deep_sleep_when_connected; +} + +void supervisor_workflow_set_allow_deep_sleep_when_connected(bool allow) { + _allow_deep_sleep_when_connected = allow; +} + +bool supervisor_workflow_get_allow_deep_sleep_on_error(void) { + return _allow_deep_sleep_on_error; +} + +void supervisor_workflow_set_allow_deep_sleep_on_error(bool allow) { + _allow_deep_sleep_on_error = allow; +} diff --git a/supervisor/shared/workflow.h b/supervisor/shared/workflow.h index 2968961f48..97584a1f46 100644 --- a/supervisor/shared/workflow.h +++ b/supervisor/shared/workflow.h @@ -26,6 +26,12 @@ #pragma once -extern volatile bool _workflow_active; +extern void supervisor_workflow_reset(void); extern bool supervisor_workflow_active(void); + +extern bool supervisor_workflow_get_allow_deep_sleep_when_connected(void); +extern void supervisor_workflow_set_allow_deep_sleep_when_connected(bool allow); + +extern bool supervisor_workflow_get_allow_deep_sleep_on_error(void); +extern void supervisor_workflow_set_allow_deep_sleep_on_error(bool allow); From 6ff24410ebe9e75456b9d5d64f37fbe019caf42c Mon Sep 17 00:00:00 2001 From: microDev <70126934+microDev1@users.noreply.github.com> Date: Tue, 24 Nov 2020 11:44:11 +0530 Subject: [PATCH 127/207] use values pointer directly --- ports/esp32s2/common-hal/nvm/ByteArray.c | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/ports/esp32s2/common-hal/nvm/ByteArray.c b/ports/esp32s2/common-hal/nvm/ByteArray.c index e304dd8302..71321e7e65 100644 --- a/ports/esp32s2/common-hal/nvm/ByteArray.c +++ b/ports/esp32s2/common-hal/nvm/ByteArray.c @@ -26,8 +26,6 @@ #include "common-hal/nvm/ByteArray.h" -#include - #include "py/runtime.h" #include "nvs_flash.h" @@ -56,9 +54,6 @@ bool common_hal_nvm_bytearray_set_bytes(nvm_bytearray_obj_t *self, uint32_t start_index, uint8_t* values, uint32_t len) { char index[9]; - uint8_t buffer[len]; - memcpy(buffer, values, len); - // start nvs nvs_handle_t handle; get_nvs_handle(&handle); @@ -66,7 +61,7 @@ bool common_hal_nvm_bytearray_set_bytes(nvm_bytearray_obj_t *self, // stage flash changes for (uint32_t i = 0; i < len; i++) { sprintf(index, "%i", start_index + i); - if (nvs_set_u8(handle, (const char *)index, buffer[i]) != ESP_OK) { + if (nvs_set_u8(handle, (const char *)index, values[i]) != ESP_OK) { return false; } } @@ -84,7 +79,6 @@ 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) { char index[9]; - uint8_t buffer[len]; // start nvs nvs_handle_t handle; @@ -93,14 +87,11 @@ void common_hal_nvm_bytearray_get_bytes(nvm_bytearray_obj_t *self, // get from flash for (uint32_t i = 0; i < len; i++) { sprintf(index, "%i", start_index + i); - if (nvs_get_u8(handle, (const char *)index, &buffer[i]) != ESP_OK) { + if (nvs_get_u8(handle, (const char *)index, &values[i]) != ESP_OK) { mp_raise_RuntimeError(translate("NVS Error")); } } - // set into values - memcpy(values, buffer, len); - // close nvs nvs_close(handle); } From f8499a468e79999decdf5002016bbfe99994f47b Mon Sep 17 00:00:00 2001 From: jgillick Date: Mon, 23 Nov 2020 22:56:38 -0800 Subject: [PATCH 128/207] Remove filesystem from linker script. --- .../{STM32F411_nvm_flash.ld => STM32F411_nvm_nofs.ld} | 10 ++++------ ports/stm/boards/thunderpack_v12/mpconfigboard.h | 4 ++-- ports/stm/boards/thunderpack_v12/mpconfigboard.mk | 2 +- 3 files changed, 7 insertions(+), 9 deletions(-) rename ports/stm/boards/{STM32F411_nvm_flash.ld => STM32F411_nvm_nofs.ld} (64%) diff --git a/ports/stm/boards/STM32F411_nvm_flash.ld b/ports/stm/boards/STM32F411_nvm_nofs.ld similarity index 64% rename from ports/stm/boards/STM32F411_nvm_flash.ld rename to ports/stm/boards/STM32F411_nvm_nofs.ld index ced739765d..e4630518cd 100644 --- a/ports/stm/boards/STM32F411_nvm_flash.ld +++ b/ports/stm/boards/STM32F411_nvm_nofs.ld @@ -1,7 +1,6 @@ /* - GNU linker script for STM32F411 with nvm and an external flash chip, and reserves - more space for the CircuitPython firmware and less for the filesystem - (since the filesystem will be on the external flash chip). + GNU linker script for STM32F411 with nvm and an external flash chip. + No space is reserved for a filesystem. */ /* Specify the memory areas */ @@ -9,9 +8,8 @@ MEMORY { FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 512K /* entire flash */ FLASH_ISR (rx) : ORIGIN = 0x08000000, LENGTH = 16K /* sector 0 */ - FLASH_FS (rx) : ORIGIN = 0x08004000, LENGTH = 32K /* sectors 1,2 are 16K */ - FLASH_NVM (rwx) : ORIGIN = 0x0800C000, LENGTH = 16K /* sector 3 is 16K */ - FLASH_FIRMWARE (rx) : ORIGIN = 0x08010000, LENGTH = 448K /* sector 4 is 64K, sectors 5,6,7 are 128K */ + FLASH_NVM (rwx) : ORIGIN = 0x08004000, LENGTH = 16K /* sector 1 is 16K */ + FLASH_FIRMWARE (rx) : ORIGIN = 0x08008000, LENGTH = 480K /* sector 2,3 is 16k, sector 4 is 64K, sectors 5,6,7 are 128K */ RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 128K } diff --git a/ports/stm/boards/thunderpack_v12/mpconfigboard.h b/ports/stm/boards/thunderpack_v12/mpconfigboard.h index 57486da280..fb5f389a37 100644 --- a/ports/stm/boards/thunderpack_v12/mpconfigboard.h +++ b/ports/stm/boards/thunderpack_v12/mpconfigboard.h @@ -28,8 +28,8 @@ // Non-volatile memory config #define CIRCUITPY_INTERNAL_NVM_SIZE (0x4000) -#define CIRCUITPY_INTERNAL_NVM_START_ADDR (0x0800C000) -#define CIRCUITPY_INTERNAL_NVM_SECTOR FLASH_SECTOR_3 +#define CIRCUITPY_INTERNAL_NVM_START_ADDR (0x08004000) +#define CIRCUITPY_INTERNAL_NVM_SECTOR FLASH_SECTOR_1 #define NVM_BYTEARRAY_BUFFER_SIZE 512 // Flash config diff --git a/ports/stm/boards/thunderpack_v12/mpconfigboard.mk b/ports/stm/boards/thunderpack_v12/mpconfigboard.mk index d0bc22680f..a2e1da1011 100644 --- a/ports/stm/boards/thunderpack_v12/mpconfigboard.mk +++ b/ports/stm/boards/thunderpack_v12/mpconfigboard.mk @@ -18,4 +18,4 @@ MCU_VARIANT = STM32F411xE MCU_PACKAGE = UFQFPN48 LD_COMMON = boards/common_nvm.ld -LD_FILE = boards/STM32F411_nvm_flash.ld +LD_FILE = boards/STM32F411_nvm_nofs.ld From 686edcef3f392ce96ae86bd66e91b6c93f2f986f Mon Sep 17 00:00:00 2001 From: Seth Kerr Date: Tue, 24 Nov 2020 07:41:32 -0500 Subject: [PATCH 129/207] fixing PID issues with CI Test (whoops) --- .../atmel-samd/boards/cp_sapling_m0_spiflash/mpconfigboard.h | 2 +- .../atmel-samd/boards/cp_sapling_m0_spiflash/mpconfigboard.mk | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/ports/atmel-samd/boards/cp_sapling_m0_spiflash/mpconfigboard.h b/ports/atmel-samd/boards/cp_sapling_m0_spiflash/mpconfigboard.h index a129566d2d..9c69c48026 100644 --- a/ports/atmel-samd/boards/cp_sapling_m0_spiflash/mpconfigboard.h +++ b/ports/atmel-samd/boards/cp_sapling_m0_spiflash/mpconfigboard.h @@ -1,4 +1,4 @@ -#define MICROPY_HW_BOARD_NAME "CP Sapling M0" +#define MICROPY_HW_BOARD_NAME "CP Sapling M0 w/ SPI Flash" #define MICROPY_HW_MCU_NAME "samd21e18" #define MICROPY_HW_NEOPIXEL (&pin_PA15) diff --git a/ports/atmel-samd/boards/cp_sapling_m0_spiflash/mpconfigboard.mk b/ports/atmel-samd/boards/cp_sapling_m0_spiflash/mpconfigboard.mk index c81209db3b..99e13f7910 100644 --- a/ports/atmel-samd/boards/cp_sapling_m0_spiflash/mpconfigboard.mk +++ b/ports/atmel-samd/boards/cp_sapling_m0_spiflash/mpconfigboard.mk @@ -1,6 +1,6 @@ USB_VID = 0x1209 -USB_PID = 0x4DDD -USB_PRODUCT = "CP Sapling" +USB_PID = 0x4DDE +USB_PRODUCT = "CP Sapling M0 w/ SPI Flash" USB_MANUFACTURER = "Oak Development Technologies" CHIP_VARIANT = SAMD21E18A From bafa0501d17eb55726a8decfe19d6f055190d6b1 Mon Sep 17 00:00:00 2001 From: hathach Date: Tue, 24 Nov 2020 22:06:59 +0700 Subject: [PATCH 130/207] update to have tud_connected() --- lib/tinyusb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/tinyusb b/lib/tinyusb index b870d932e5..218b80e63a 160000 --- a/lib/tinyusb +++ b/lib/tinyusb @@ -1 +1 @@ -Subproject commit b870d932e5e1c6ece4227a5d49cc71e53a744149 +Subproject commit 218b80e63ab6ff87c1851e403f08b3d716d68f5e From ba6e15b0700093933826c054ea44d45993751036 Mon Sep 17 00:00:00 2001 From: Lucian Copeland Date: Tue, 24 Nov 2020 11:32:18 -0500 Subject: [PATCH 131/207] Fix stubs --- shared-bindings/socketpool/Socket.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/shared-bindings/socketpool/Socket.c b/shared-bindings/socketpool/Socket.c index 99e2c8fccb..0e6968d5f4 100644 --- a/shared-bindings/socketpool/Socket.c +++ b/shared-bindings/socketpool/Socket.c @@ -276,7 +276,7 @@ STATIC mp_obj_t socketpool_socket_recv_into(size_t n_args, const mp_obj_t *args) } STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(socketpool_socket_recv_into_obj, 2, 3, socketpool_socket_recv_into); -//| def sendto(self, bytes: ReadableBuffer, address: tuple) -> int: +//| def sendto(self, bytes: ReadableBuffer, address: Tuple[str, int]) -> int: //| """Send some bytes to a specific address. //| Suits sockets of type SOCK_DGRAM //| @@ -308,7 +308,7 @@ STATIC mp_obj_t socketpool_socket_sendto(mp_obj_t self_in, mp_obj_t data_in, mp_ } STATIC MP_DEFINE_CONST_FUN_OBJ_3(socketpool_socket_sendto_obj, socketpool_socket_sendto); -//| def recvfrom_into(self, buffer) -> Tuple[int, tuple]: +//| def recvfrom_into(self, buffer: WriteableBuffer) -> Tuple[int, Tuple[str, int]]: //| """Reads some bytes from a remote address. //| //| Returns a tuple containing From 1031fe299254e0b46afa9d500fd298e2382f2183 Mon Sep 17 00:00:00 2001 From: Lucian Copeland Date: Tue, 24 Nov 2020 14:46:43 -0500 Subject: [PATCH 132/207] correct submodule --- ports/esp32s2/esp-idf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ports/esp32s2/esp-idf b/ports/esp32s2/esp-idf index 8bc19ba893..d06744f5ef 160000 --- a/ports/esp32s2/esp-idf +++ b/ports/esp32s2/esp-idf @@ -1 +1 @@ -Subproject commit 8bc19ba893e5544d571a753d82b44a84799b94b1 +Subproject commit d06744f5efc382c61cbad8758107cec308feef09 From 0c5e0954dbf2c725cadf12260e56f51a967f9e50 Mon Sep 17 00:00:00 2001 From: Lucian Copeland Date: Tue, 24 Nov 2020 14:51:06 -0500 Subject: [PATCH 133/207] Add closed socket identification --- ports/esp32s2/common-hal/socketpool/Socket.c | 1 + 1 file changed, 1 insertion(+) diff --git a/ports/esp32s2/common-hal/socketpool/Socket.c b/ports/esp32s2/common-hal/socketpool/Socket.c index 937d199f21..1e22193330 100644 --- a/ports/esp32s2/common-hal/socketpool/Socket.c +++ b/ports/esp32s2/common-hal/socketpool/Socket.c @@ -187,6 +187,7 @@ void common_hal_socketpool_socket_close(socketpool_socket_obj_t* self) { if (self->num >= 0) { lwip_shutdown(self->num, 0); lwip_close(self->num); + self->num = -1; } } From e83c481f0fbf6d1ed052b7bba12163e80d64ad4a Mon Sep 17 00:00:00 2001 From: Lucian Copeland Date: Tue, 24 Nov 2020 15:40:27 -0500 Subject: [PATCH 134/207] translations --- locale/circuitpython.pot | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/locale/circuitpython.pot b/locale/circuitpython.pot index c184d69313..034fc2ab24 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-11-23 10:10-0600\n" +"POT-Creation-Date: 2020-11-24 15:40-0500\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -297,6 +297,7 @@ msgid "All I2C peripherals are in use" msgstr "" #: ports/esp32s2/common-hal/countio/Counter.c +#: ports/esp32s2/common-hal/frequencyio/FrequencyIn.c #: ports/esp32s2/common-hal/rotaryio/IncrementalEncoder.c msgid "All PCNT units in use" msgstr "" @@ -333,6 +334,7 @@ msgstr "" #: ports/atmel-samd/common-hal/pulseio/PulseIn.c #: ports/atmel-samd/common-hal/pulseio/PulseOut.c #: ports/cxd56/common-hal/pulseio/PulseOut.c +#: ports/esp32s2/common-hal/frequencyio/FrequencyIn.c #: ports/esp32s2/common-hal/neopixel_write/__init__.c #: ports/esp32s2/common-hal/pulseio/PulseIn.c #: ports/esp32s2/common-hal/pulseio/PulseOut.c @@ -1086,6 +1088,7 @@ msgid "Invalid byteorder string" msgstr "" #: ports/atmel-samd/common-hal/frequencyio/FrequencyIn.c +#: ports/esp32s2/common-hal/frequencyio/FrequencyIn.c msgid "Invalid capture period. Valid range: 1 - 500" msgstr "" @@ -1412,14 +1415,14 @@ msgstr "" msgid "Only 8 or 16 bit mono with " msgstr "" -#: ports/esp32s2/common-hal/socketpool/SocketPool.c -msgid "Only IPv4 SOCK_STREAM sockets supported" -msgstr "" - #: ports/esp32s2/common-hal/wifi/__init__.c msgid "Only IPv4 addresses supported" msgstr "" +#: ports/esp32s2/common-hal/socketpool/SocketPool.c +msgid "Only IPv4 sockets supported" +msgstr "" + #: shared-module/displayio/OnDiskBitmap.c #, c-format msgid "" From 59458a9013786f79c78a36ce5d6298f16fdd6a1a Mon Sep 17 00:00:00 2001 From: Lucian Copeland Date: Tue, 24 Nov 2020 16:46:11 -0500 Subject: [PATCH 135/207] Add pin claiming to SPI construct --- ports/esp32s2/common-hal/busio/SPI.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/ports/esp32s2/common-hal/busio/SPI.c b/ports/esp32s2/common-hal/busio/SPI.c index 490419f34a..da738bbfdd 100644 --- a/ports/esp32s2/common-hal/busio/SPI.c +++ b/ports/esp32s2/common-hal/busio/SPI.c @@ -204,6 +204,14 @@ void common_hal_busio_spi_construct(busio_spi_obj_t *self, // hal->dummy_bits = 0; // hal->addr = 0; + claim_pin(self->clock_pin); + if (self->MOSI_pin != NULL) { + claim_pin(self->MOSI_pin); + } + if (self->MISO_pin != NULL) { + claim_pin(self->MISO_pin); + } + hal->io_mode = SPI_LL_IO_MODE_NORMAL; common_hal_busio_spi_configure(self, 250000, 0, 0, 8); From 966e0b256c6b75fb6a4d8a4debceb9b5dbf902b2 Mon Sep 17 00:00:00 2001 From: Antonin ENFRUN Date: Tue, 24 Nov 2020 17:19:41 +0000 Subject: [PATCH 136/207] Translated using Weblate (French) Currently translated at 98.2% (848 of 863 strings) Translation: CircuitPython/main Translate-URL: https://hosted.weblate.org/projects/circuitpython/main/fr/ --- locale/fr.po | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/locale/fr.po b/locale/fr.po index 17e6e905d1..87c79cde9a 100644 --- a/locale/fr.po +++ b/locale/fr.po @@ -8,8 +8,8 @@ msgstr "" "Project-Id-Version: 0.1\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2020-11-23 10:10-0600\n" -"PO-Revision-Date: 2020-11-20 22:28+0000\n" -"Last-Translator: Noel Gaetan \n" +"PO-Revision-Date: 2020-11-24 22:45+0000\n" +"Last-Translator: Antonin ENFRUN \n" "Language: fr\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=utf-8\n" @@ -881,7 +881,7 @@ msgstr "La FFT est définie pour les ndarrays uniquement" #: extmod/ulab/code/fft/fft.c msgid "FFT is implemented for linear arrays only" -msgstr "" +msgstr "FFT n'est implémenté que pour les tableaux linéaires" #: ports/esp32s2/common-hal/socketpool/Socket.c msgid "Failed SSL handshake" @@ -2116,7 +2116,7 @@ msgstr "L'argument argsort doit être un ndarray" #: extmod/ulab/code/numerical/numerical.c msgid "argsort is not implemented for flattened arrays" -msgstr "" +msgstr "argsort n'est pas mis en œuvre pour les tableaux aplatis" #: py/runtime.c msgid "argument has wrong type" @@ -2141,7 +2141,7 @@ msgstr "les arguments doivent être des ndarrays" #: extmod/ulab/code/ndarray.c msgid "array and index length must be equal" -msgstr "" +msgstr "la longueur du tableau et de l'index doit être égale" #: py/objarray.c shared-bindings/nvm/ByteArray.c msgid "array/bytes required on right side" @@ -2149,7 +2149,7 @@ msgstr "tableau/octets requis à droite" #: extmod/ulab/code/numerical/numerical.c msgid "attempt to get (arg)min/(arg)max of empty sequence" -msgstr "" +msgstr "tentative d’obtenir (arg)min/(arg)max d'une séquence vide" #: extmod/ulab/code/numerical/numerical.c msgid "attempt to get argmin/argmax of an empty sequence" @@ -2161,15 +2161,15 @@ msgstr "attribut pas encore supporté" #: extmod/ulab/code/numerical/numerical.c msgid "axis is out of bounds" -msgstr "" +msgstr "axis est hors limites" #: extmod/ulab/code/numerical/numerical.c msgid "axis must be None, or an integer" -msgstr "" +msgstr "axis doit être None ou un entier" #: extmod/ulab/code/numerical/numerical.c msgid "axis too long" -msgstr "" +msgstr "axis trop long" #: py/builtinevex.c msgid "bad compile mode" @@ -2485,7 +2485,7 @@ msgstr "impossible de déterminer la version de la carte SD" #: extmod/ulab/code/numerical/numerical.c msgid "cross is defined for 1D arrays of length 3" -msgstr "" +msgstr "cross est défini pour les tableaux 1D de longueur 3" #: extmod/ulab/code/approx/approx.c msgid "data must be iterable" @@ -2528,7 +2528,7 @@ msgstr "l'argument diff doit être un ndarray" #: extmod/ulab/code/numerical/numerical.c msgid "differentiation order out of range" -msgstr "" +msgstr "differentiation order hors plage" #: py/modmath.c py/objfloat.c py/objint_longlong.c py/objint_mpz.c py/runtime.c #: shared-bindings/math/__init__.c @@ -2649,7 +2649,7 @@ msgstr "le premier argument doit être une fonction" #: extmod/ulab/code/ulab_create.c msgid "first argument must be a tuple of ndarrays" -msgstr "" +msgstr "le premier argument doit être un tuple de ndarrays" #: extmod/ulab/code/ndarray.c msgid "first argument must be an iterable" @@ -2706,7 +2706,7 @@ msgstr "la fonction a le même signe aux extrémités de l’intervalle" #: extmod/ulab/code/ndarray.c msgid "function is defined for ndarrays only" -msgstr "" +msgstr "La fonction n'est définie que pour les ndarrays" #: py/argcheck.c #, c-format @@ -2803,7 +2803,7 @@ msgstr "l'assembleur doit être une fonction" #: extmod/ulab/code/ndarray.c msgid "input and output shapes are not compatible" -msgstr "" +msgstr "les formes d'entrée et de sortie ne sont pas compatibles" #: extmod/ulab/code/ulab_create.c msgid "input argument must be an integer or a 2-tuple" @@ -2815,7 +2815,7 @@ msgstr "la longueur du tableau d'entrée doit être une puissance de 2" #: extmod/ulab/code/ulab_create.c msgid "input arrays are not compatible" -msgstr "" +msgstr "les tableaux d'entrée ne sont pas compatibles" #: extmod/ulab/code/poly/poly.c msgid "input data must be an iterable" @@ -2831,11 +2831,11 @@ msgstr "la matrice d'entrée est singulière" #: extmod/ulab/code/user/user.c msgid "input must be a dense ndarray" -msgstr "" +msgstr "l'entrée doit être un tableau dense" #: extmod/ulab/code/ulab_create.c msgid "input must be a tensor of rank 2" -msgstr "" +msgstr "l'entrée doit être un tenseur de rang 2" #: extmod/ulab/code/ulab_create.c extmod/ulab/code/user/user.c msgid "input must be an ndarray" From 241d9207578cbab3584349cd37327efe9910f36c Mon Sep 17 00:00:00 2001 From: Wellington Terumi Uemura Date: Tue, 24 Nov 2020 04:06:38 +0000 Subject: [PATCH 137/207] Translated using Weblate (Portuguese (Brazil)) Currently translated at 100.0% (863 of 863 strings) Translation: CircuitPython/main Translate-URL: https://hosted.weblate.org/projects/circuitpython/main/pt_BR/ --- locale/pt_BR.po | 62 ++++++++++++++++++++++++------------------------- 1 file changed, 31 insertions(+), 31 deletions(-) diff --git a/locale/pt_BR.po b/locale/pt_BR.po index baa125f1d1..028dad31c1 100644 --- a/locale/pt_BR.po +++ b/locale/pt_BR.po @@ -6,7 +6,7 @@ msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2020-11-23 10:10-0600\n" -"PO-Revision-Date: 2020-11-18 00:28+0000\n" +"PO-Revision-Date: 2020-11-24 22:45+0000\n" "Last-Translator: Wellington Terumi Uemura \n" "Language-Team: \n" "Language: pt_BR\n" @@ -878,7 +878,7 @@ msgstr "O FFT é definido apenas para ndarrays" #: extmod/ulab/code/fft/fft.c msgid "FFT is implemented for linear arrays only" -msgstr "" +msgstr "O FFT é implementado apenas para matrizes lineares" #: ports/esp32s2/common-hal/socketpool/Socket.c msgid "Failed SSL handshake" @@ -2114,7 +2114,7 @@ msgstr "O argumento argsort deve ser um ndarray" #: extmod/ulab/code/numerical/numerical.c msgid "argsort is not implemented for flattened arrays" -msgstr "" +msgstr "argsort não é implementado para matrizes achatadas" #: py/runtime.c msgid "argument has wrong type" @@ -2139,7 +2139,7 @@ msgstr "os argumentos devem ser ndarrays" #: extmod/ulab/code/ndarray.c msgid "array and index length must be equal" -msgstr "" +msgstr "a matriz e comprimento do índice devem ser iguais" #: py/objarray.c shared-bindings/nvm/ByteArray.c msgid "array/bytes required on right side" @@ -2147,7 +2147,7 @@ msgstr "matriz/bytes são necessários no lado direito" #: extmod/ulab/code/numerical/numerical.c msgid "attempt to get (arg)min/(arg)max of empty sequence" -msgstr "" +msgstr "tentativa de obter (arg)min/(arg)max da sequência vazia" #: extmod/ulab/code/numerical/numerical.c msgid "attempt to get argmin/argmax of an empty sequence" @@ -2159,15 +2159,15 @@ msgstr "atributos ainda não suportados" #: extmod/ulab/code/numerical/numerical.c msgid "axis is out of bounds" -msgstr "" +msgstr "o eixo está fora dos limites" #: extmod/ulab/code/numerical/numerical.c msgid "axis must be None, or an integer" -msgstr "" +msgstr "eixo deve ser Nenhum ou um número inteiro" #: extmod/ulab/code/numerical/numerical.c msgid "axis too long" -msgstr "" +msgstr "o eixo é muito longo" #: py/builtinevex.c msgid "bad compile mode" @@ -2376,7 +2376,7 @@ msgstr "" #: extmod/ulab/code/ndarray_operators.c msgid "cannot cast output with casting rule" -msgstr "" +msgstr "não pode lançar a saída com a regra de fundição" #: py/objtype.c msgid "cannot create '%q' instances" @@ -2478,7 +2478,7 @@ msgstr "não foi possível determinar a versão do cartão SD" #: extmod/ulab/code/numerical/numerical.c msgid "cross is defined for 1D arrays of length 3" -msgstr "" +msgstr "a cruz é definida para matrizes 1D de comprimento 3" #: extmod/ulab/code/approx/approx.c msgid "data must be iterable" @@ -2522,7 +2522,7 @@ msgstr "O argumento diff deve ser um ndarray" #: extmod/ulab/code/numerical/numerical.c msgid "differentiation order out of range" -msgstr "" +msgstr "ordem de diferenciação fora do alcance" #: py/modmath.c py/objfloat.c py/objint_longlong.c py/objint_mpz.c py/runtime.c #: shared-bindings/math/__init__.c @@ -2641,7 +2641,7 @@ msgstr "o primeiro argumento deve ser uma função" #: extmod/ulab/code/ulab_create.c msgid "first argument must be a tuple of ndarrays" -msgstr "" +msgstr "o primeiro argumento deve ser um tuple de ndarrays" #: extmod/ulab/code/ndarray.c msgid "first argument must be an iterable" @@ -2698,7 +2698,7 @@ msgstr "a função tem o mesmo sinal nas extremidades do intervalo" #: extmod/ulab/code/ndarray.c msgid "function is defined for ndarrays only" -msgstr "" +msgstr "A função é definida apenas para ndarrays" #: py/argcheck.c #, c-format @@ -2794,7 +2794,7 @@ msgstr "o assembler em linha deve ser uma função" #: extmod/ulab/code/ndarray.c msgid "input and output shapes are not compatible" -msgstr "" +msgstr "as formas de entrada e saída não são compatíveis" #: extmod/ulab/code/ulab_create.c msgid "input argument must be an integer or a 2-tuple" @@ -2806,7 +2806,7 @@ msgstr "comprimento da matriz da entrada deve ter potência de 2" #: extmod/ulab/code/ulab_create.c msgid "input arrays are not compatible" -msgstr "" +msgstr "as matrizes da entrada não são compatíveis" #: extmod/ulab/code/poly/poly.c msgid "input data must be an iterable" @@ -2822,19 +2822,19 @@ msgstr "a matriz da entrada é singular" #: extmod/ulab/code/user/user.c msgid "input must be a dense ndarray" -msgstr "" +msgstr "a entrada deve ser um ndarray denso" #: extmod/ulab/code/ulab_create.c msgid "input must be a tensor of rank 2" -msgstr "" +msgstr "a entrada dos dados deve ser um tensor de nível 2" #: extmod/ulab/code/ulab_create.c extmod/ulab/code/user/user.c msgid "input must be an ndarray" -msgstr "" +msgstr "a entrada deve ser um ndarray" #: extmod/ulab/code/filter/filter.c msgid "input must be one-dimensional" -msgstr "" +msgstr "a entrada deve ser unidimensional" #: extmod/ulab/code/linalg/linalg.c msgid "input must be square matrix" @@ -2850,7 +2850,7 @@ msgstr "os vetores da entrada devem ter o mesmo comprimento" #: extmod/ulab/code/poly/poly.c msgid "inputs are not iterable" -msgstr "" +msgstr "as entradas não são iteráveis" #: py/parsenum.c msgid "int() arg 2 must be >= 2 and <= 36" @@ -3025,7 +3025,7 @@ msgstr "max_length deve ser > 0" #: extmod/ulab/code/ndarray.c msgid "maximum number of dimensions is 4" -msgstr "" +msgstr "O número máximo de dimensões são 4" #: py/runtime.c msgid "maximum recursion depth exceeded" @@ -3162,7 +3162,7 @@ msgstr "um arg não-palavra-chave após a palavra-chave arg" #: extmod/ulab/code/linalg/linalg.c msgid "norm is defined for 1D and 2D arrays" -msgstr "" +msgstr "a norma é definida para matrizes 1D e 2D" #: shared-bindings/_bleio/UUID.c msgid "not a 128-bit UUID" @@ -3230,7 +3230,7 @@ msgstr "sequência com comprimento ímpar" #: extmod/ulab/code/ulab_create.c msgid "offset is too large" -msgstr "" +msgstr "o offset é muito grande" #: py/objstr.c py/objstrunicode.c msgid "offset out of bounds" @@ -3257,11 +3257,11 @@ msgstr "os operandos não puderam ser transmitidos juntos" #: extmod/ulab/code/ndarray.c msgid "operation is implemented for 1D Boolean arrays only" -msgstr "" +msgstr "A operação é implementada apenas para matrizes booleanas 1D" #: extmod/ulab/code/numerical/numerical.c msgid "operation is not implemented for flattened array" -msgstr "" +msgstr "a operação não é implementada para a matriz achatada" #: extmod/ulab/code/numerical/numerical.c msgid "operation is not implemented on ndarrays" @@ -3403,7 +3403,7 @@ msgstr "o comprimento solicitado %d, porém o objeto tem comprimento %d" #: extmod/ulab/code/ndarray_operators.c msgid "results cannot be cast to specified type" -msgstr "" +msgstr "os resultados não podem ser lançados para um determinado tipo" #: py/compile.c msgid "return annotation must be an identifier" @@ -3425,7 +3425,7 @@ msgstr "rgb_pins[%d] não está na mesma porta que o clock" #: extmod/ulab/code/numerical/numerical.c msgid "roll argument must be an ndarray" -msgstr "" +msgstr "argumento de enrolar deve ser um ndarray" #: py/objstr.c msgid "rsplit(None,n)" @@ -3453,7 +3453,7 @@ msgstr "compilação de script não suportada" #: extmod/ulab/code/ndarray.c msgid "shape must be a tuple" -msgstr "" +msgstr "a forma deve ser uma tupla" #: py/objstr.c msgid "sign not allowed in string format specifier" @@ -3602,7 +3602,7 @@ msgstr "timestamp fora do intervalo para a plataforma time_t" #: extmod/ulab/code/ndarray.c msgid "tobytes can be invoked for dense arrays only" -msgstr "" +msgstr "os tobytes podem ser invocados apenas nas matrizes densas" #: shared-module/struct/__init__.c msgid "too many arguments provided with the given format" @@ -3781,11 +3781,11 @@ msgstr "a janela deve ser <= intervalo" #: extmod/ulab/code/numerical/numerical.c msgid "wrong axis index" -msgstr "" +msgstr "índice do eixo errado" #: extmod/ulab/code/ulab_create.c msgid "wrong axis specified" -msgstr "" +msgstr "um eixo errado foi definido" #: extmod/ulab/code/vector/vectorise.c msgid "wrong input type" From ff7bab12aa0fb131b8056cd1b20b1e17bba8306a Mon Sep 17 00:00:00 2001 From: Hosted Weblate Date: Tue, 24 Nov 2020 23:45:47 +0100 Subject: [PATCH 138/207] Update translation files Updated by "Update PO files to match POT (msgmerge)" hook in Weblate. Translation: CircuitPython/main Translate-URL: https://hosted.weblate.org/projects/circuitpython/main/ --- locale/ID.po | 6 +++++- locale/cs.po | 6 +++++- locale/de_DE.po | 6 +++++- locale/el.po | 6 +++++- locale/es.po | 6 +++++- locale/fil.po | 6 +++++- locale/fr.po | 6 +++++- locale/hi.po | 6 +++++- locale/it_IT.po | 6 +++++- locale/ja.po | 6 +++++- locale/ko.po | 6 +++++- locale/nl.po | 6 +++++- locale/pl.po | 6 +++++- locale/pt_BR.po | 6 +++++- locale/sv.po | 6 +++++- locale/zh_Latn_pinyin.po | 6 +++++- 16 files changed, 80 insertions(+), 16 deletions(-) diff --git a/locale/ID.po b/locale/ID.po index 782e846e99..cf23970d88 100644 --- a/locale/ID.po +++ b/locale/ID.po @@ -5,7 +5,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-11-23 10:10-0600\n" +"POT-Creation-Date: 2020-11-11 16:30+0530\n" "PO-Revision-Date: 2020-10-10 23:51+0000\n" "Last-Translator: oon arfiandwi \n" "Language-Team: LANGUAGE \n" @@ -1283,6 +1283,10 @@ msgstr "Harus menyediakan pin MISO atau MOSI" msgid "Must use a multiple of 6 rgb pins, not %d" msgstr "Harus menggunakan kelipatan 6 pin rgb, bukan %d" +#: ports/esp32s2/common-hal/nvm/ByteArray.c +msgid "NVS Error" +msgstr "" + #: py/parse.c msgid "Name too long" msgstr "Nama terlalu panjang" diff --git a/locale/cs.po b/locale/cs.po index 6eb69fb672..3249792e70 100644 --- a/locale/cs.po +++ b/locale/cs.po @@ -5,7 +5,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-11-23 10:10-0600\n" +"POT-Creation-Date: 2020-11-11 16:30+0530\n" "PO-Revision-Date: 2020-05-24 03:22+0000\n" "Last-Translator: dronecz \n" "Language-Team: LANGUAGE \n" @@ -1266,6 +1266,10 @@ msgstr "" msgid "Must use a multiple of 6 rgb pins, not %d" msgstr "" +#: ports/esp32s2/common-hal/nvm/ByteArray.c +msgid "NVS Error" +msgstr "" + #: py/parse.c msgid "Name too long" msgstr "" diff --git a/locale/de_DE.po b/locale/de_DE.po index f103339109..3b6bc8e217 100644 --- a/locale/de_DE.po +++ b/locale/de_DE.po @@ -5,7 +5,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-11-23 10:10-0600\n" +"POT-Creation-Date: 2020-11-11 16:30+0530\n" "PO-Revision-Date: 2020-06-16 18:24+0000\n" "Last-Translator: Andreas Buchen \n" "Language: de_DE\n" @@ -1285,6 +1285,10 @@ msgstr "Muss MISO- oder MOSI-Pin bereitstellen" msgid "Must use a multiple of 6 rgb pins, not %d" msgstr "Muss ein Vielfaches von 6 RGB-Pins verwenden, nicht %d" +#: ports/esp32s2/common-hal/nvm/ByteArray.c +msgid "NVS Error" +msgstr "" + #: py/parse.c msgid "Name too long" msgstr "Name zu lang" diff --git a/locale/el.po b/locale/el.po index 85bf0ab44f..71f6e6102b 100644 --- a/locale/el.po +++ b/locale/el.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-11-23 10:10-0600\n" +"POT-Creation-Date: 2020-11-11 16:30+0530\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: Automatically generated\n" "Language-Team: none\n" @@ -1261,6 +1261,10 @@ msgstr "" msgid "Must use a multiple of 6 rgb pins, not %d" msgstr "" +#: ports/esp32s2/common-hal/nvm/ByteArray.c +msgid "NVS Error" +msgstr "" + #: py/parse.c msgid "Name too long" msgstr "" diff --git a/locale/es.po b/locale/es.po index 538a2944e6..b0314ae198 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-11-23 10:10-0600\n" +"POT-Creation-Date: 2020-11-11 16:30+0530\n" "PO-Revision-Date: 2020-11-15 16:28+0000\n" "Last-Translator: RubenD \n" "Language-Team: \n" @@ -1284,6 +1284,10 @@ msgstr "Debe proporcionar un pin MISO o MOSI" msgid "Must use a multiple of 6 rgb pins, not %d" msgstr "Debe usar un múltiplo de 6 pines rgb, no %d" +#: ports/esp32s2/common-hal/nvm/ByteArray.c +msgid "NVS Error" +msgstr "" + #: py/parse.c msgid "Name too long" msgstr "Nombre muy largo" diff --git a/locale/fil.po b/locale/fil.po index 86178a9a14..50067c6d4f 100644 --- a/locale/fil.po +++ b/locale/fil.po @@ -5,7 +5,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-11-23 10:10-0600\n" +"POT-Creation-Date: 2020-11-11 16:30+0530\n" "PO-Revision-Date: 2018-12-20 22:15-0800\n" "Last-Translator: Timothy \n" "Language-Team: fil\n" @@ -1276,6 +1276,10 @@ msgstr "" msgid "Must use a multiple of 6 rgb pins, not %d" msgstr "" +#: ports/esp32s2/common-hal/nvm/ByteArray.c +msgid "NVS Error" +msgstr "" + #: py/parse.c msgid "Name too long" msgstr "" diff --git a/locale/fr.po b/locale/fr.po index 87c79cde9a..359595c723 100644 --- a/locale/fr.po +++ b/locale/fr.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: 0.1\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-11-23 10:10-0600\n" +"POT-Creation-Date: 2020-11-11 16:30+0530\n" "PO-Revision-Date: 2020-11-24 22:45+0000\n" "Last-Translator: Antonin ENFRUN \n" "Language: fr\n" @@ -1289,6 +1289,10 @@ msgstr "Doit fournir une broche MISO ou MOSI" msgid "Must use a multiple of 6 rgb pins, not %d" msgstr "Doit utiliser un multiple de 6 broches RVB, pas %d" +#: ports/esp32s2/common-hal/nvm/ByteArray.c +msgid "NVS Error" +msgstr "" + #: py/parse.c msgid "Name too long" msgstr "Nom trop long" diff --git a/locale/hi.po b/locale/hi.po index 3b006f1989..de77cec46b 100644 --- a/locale/hi.po +++ b/locale/hi.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-11-23 10:10-0600\n" +"POT-Creation-Date: 2020-11-11 16:30+0530\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: Automatically generated\n" "Language-Team: none\n" @@ -1261,6 +1261,10 @@ msgstr "" msgid "Must use a multiple of 6 rgb pins, not %d" msgstr "" +#: ports/esp32s2/common-hal/nvm/ByteArray.c +msgid "NVS Error" +msgstr "" + #: py/parse.c msgid "Name too long" msgstr "" diff --git a/locale/it_IT.po b/locale/it_IT.po index 652bc56fd5..15c83cd53a 100644 --- a/locale/it_IT.po +++ b/locale/it_IT.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-11-23 10:10-0600\n" +"POT-Creation-Date: 2020-11-11 16:30+0530\n" "PO-Revision-Date: 2018-10-02 16:27+0200\n" "Last-Translator: Enrico Paganin \n" "Language-Team: \n" @@ -1280,6 +1280,10 @@ msgstr "" msgid "Must use a multiple of 6 rgb pins, not %d" msgstr "" +#: ports/esp32s2/common-hal/nvm/ByteArray.c +msgid "NVS Error" +msgstr "" + #: py/parse.c msgid "Name too long" msgstr "" diff --git a/locale/ja.po b/locale/ja.po index 26025c19e4..0132783026 100644 --- a/locale/ja.po +++ b/locale/ja.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-11-23 10:10-0600\n" +"POT-Creation-Date: 2020-11-11 16:30+0530\n" "PO-Revision-Date: 2020-11-12 22:51+0000\n" "Last-Translator: sporeball \n" "Language-Team: none\n" @@ -1276,6 +1276,10 @@ msgstr "MISOピンまたはMOSIピンが必要" msgid "Must use a multiple of 6 rgb pins, not %d" msgstr "%d個でなく6の倍数個のrgbピンを使ってください" +#: ports/esp32s2/common-hal/nvm/ByteArray.c +msgid "NVS Error" +msgstr "" + #: py/parse.c msgid "Name too long" msgstr "名前が長すぎます" diff --git a/locale/ko.po b/locale/ko.po index a7967210d3..fc08bdeaac 100644 --- a/locale/ko.po +++ b/locale/ko.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-11-23 10:10-0600\n" +"POT-Creation-Date: 2020-11-11 16:30+0530\n" "PO-Revision-Date: 2020-10-05 12:12+0000\n" "Last-Translator: Michal Čihař \n" "Language-Team: LANGUAGE \n" @@ -1266,6 +1266,10 @@ msgstr "" msgid "Must use a multiple of 6 rgb pins, not %d" msgstr "" +#: ports/esp32s2/common-hal/nvm/ByteArray.c +msgid "NVS Error" +msgstr "" + #: py/parse.c msgid "Name too long" msgstr "" diff --git a/locale/nl.po b/locale/nl.po index f9847fd81f..ee7a3fd545 100644 --- a/locale/nl.po +++ b/locale/nl.po @@ -5,7 +5,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-11-23 10:10-0600\n" +"POT-Creation-Date: 2020-11-11 16:30+0530\n" "PO-Revision-Date: 2020-10-27 16:47+0000\n" "Last-Translator: Jelle Jager \n" "Language-Team: none\n" @@ -1278,6 +1278,10 @@ msgstr "MISO of MOSI moeten worden gegeven" msgid "Must use a multiple of 6 rgb pins, not %d" msgstr "Een meervoud van 6 rgb pinnen moet worden gebruikt, niet %d" +#: ports/esp32s2/common-hal/nvm/ByteArray.c +msgid "NVS Error" +msgstr "" + #: py/parse.c msgid "Name too long" msgstr "Naam te lang" diff --git a/locale/pl.po b/locale/pl.po index 1873af488f..4d8c9d84cc 100644 --- a/locale/pl.po +++ b/locale/pl.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-11-23 10:10-0600\n" +"POT-Creation-Date: 2020-11-11 16:30+0530\n" "PO-Revision-Date: 2020-11-11 19:13+0000\n" "Last-Translator: Maciej Stankiewicz \n" "Language-Team: pl\n" @@ -1277,6 +1277,10 @@ msgstr "Należy podać pin MISO lub MOSI" msgid "Must use a multiple of 6 rgb pins, not %d" msgstr "" +#: ports/esp32s2/common-hal/nvm/ByteArray.c +msgid "NVS Error" +msgstr "" + #: py/parse.c msgid "Name too long" msgstr "Za długa nazwa" diff --git a/locale/pt_BR.po b/locale/pt_BR.po index 028dad31c1..5d8ac39f3b 100644 --- a/locale/pt_BR.po +++ b/locale/pt_BR.po @@ -5,7 +5,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-11-23 10:10-0600\n" +"POT-Creation-Date: 2020-11-11 16:30+0530\n" "PO-Revision-Date: 2020-11-24 22:45+0000\n" "Last-Translator: Wellington Terumi Uemura \n" "Language-Team: \n" @@ -1287,6 +1287,10 @@ msgstr "Deve informar os pinos MISO ou MOSI" msgid "Must use a multiple of 6 rgb pins, not %d" msgstr "Deve utilizar um múltiplo de 6 pinos rgb, não %d" +#: ports/esp32s2/common-hal/nvm/ByteArray.c +msgid "NVS Error" +msgstr "" + #: py/parse.c msgid "Name too long" msgstr "Nome muito longo" diff --git a/locale/sv.po b/locale/sv.po index 02847044fb..db05a557ae 100644 --- a/locale/sv.po +++ b/locale/sv.po @@ -5,7 +5,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-11-23 10:10-0600\n" +"POT-Creation-Date: 2020-11-11 16:30+0530\n" "PO-Revision-Date: 2020-11-20 22:28+0000\n" "Last-Translator: Jonny Bergdahl \n" "Language-Team: LANGUAGE \n" @@ -1277,6 +1277,10 @@ msgstr "Måste ange MISO- eller MOSI-pinne" msgid "Must use a multiple of 6 rgb pins, not %d" msgstr "Måste använda ett multipel av 6 rgb-pinnar, inte %d" +#: ports/esp32s2/common-hal/nvm/ByteArray.c +msgid "NVS Error" +msgstr "" + #: py/parse.c msgid "Name too long" msgstr "Name är för långt" diff --git a/locale/zh_Latn_pinyin.po b/locale/zh_Latn_pinyin.po index 134efec903..2f0673a7d0 100644 --- a/locale/zh_Latn_pinyin.po +++ b/locale/zh_Latn_pinyin.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: circuitpython-cn\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-11-23 10:10-0600\n" +"POT-Creation-Date: 2020-11-11 16:30+0530\n" "PO-Revision-Date: 2020-11-19 01:28+0000\n" "Last-Translator: hexthat \n" "Language-Team: Chinese Hanyu Pinyin\n" @@ -1274,6 +1274,10 @@ msgstr "Bìxū tígōng MISO huò MOSI yǐn jiǎo" msgid "Must use a multiple of 6 rgb pins, not %d" msgstr "bì xū shǐ yòng 6 RGB yǐn jiǎo de bèi shù, ér bù shì %d" +#: ports/esp32s2/common-hal/nvm/ByteArray.c +msgid "NVS Error" +msgstr "" + #: py/parse.c msgid "Name too long" msgstr "Míngchēng tài zhǎng" From c451b22255706989f58cfd88be486e5117979a28 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Tue, 24 Nov 2020 10:26:47 -0600 Subject: [PATCH 139/207] Disable 3-arg pow() function on m0 boards `pow(a, b, c)` can compute `(a ** b) % c` efficiently (in time and memory). This can be useful for extremely specific applications, like implementing the RSA cryptosystem. For typical uses of CircuitPython, this is not an important feature. A survey of the bundle and learn system didn't find any uses. Disable it on M0 builds so that we can fit in needed upgrades to the USB stack. --- ports/atmel-samd/mpconfigport.mk | 4 ++++ py/circuitpy_mpconfig.h | 2 +- py/circuitpy_mpconfig.mk | 3 +++ 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/ports/atmel-samd/mpconfigport.mk b/ports/atmel-samd/mpconfigport.mk index 1929e146d3..17e3995bf5 100644 --- a/ports/atmel-samd/mpconfigport.mk +++ b/ports/atmel-samd/mpconfigport.mk @@ -29,6 +29,10 @@ ifndef CIRCUITPY_AUDIOMP3 CIRCUITPY_AUDIOMP3 = 0 endif +ifndef CIRCUITPY_BUILTINS_POW3 +CIRCUITPY_BUILTINS_POW3 = 0 +endif + ifndef CIRCUITPY_FREQUENCYIO CIRCUITPY_FREQUENCYIO = 0 endif diff --git a/py/circuitpy_mpconfig.h b/py/circuitpy_mpconfig.h index 85e152670a..28fd4095c4 100644 --- a/py/circuitpy_mpconfig.h +++ b/py/circuitpy_mpconfig.h @@ -184,7 +184,7 @@ typedef long mp_off_t; // Turning off FULL_BUILD removes some functionality to reduce flash size on tiny SAMD21s #define MICROPY_BUILTIN_METHOD_CHECK_SELF_ARG (CIRCUITPY_FULL_BUILD) #define MICROPY_CPYTHON_COMPAT (CIRCUITPY_FULL_BUILD) -#define MICROPY_PY_BUILTINS_POW3 (CIRCUITPY_FULL_BUILD) +#define MICROPY_PY_BUILTINS_POW3 (CIRCUITPY_BUILTINS_POW3) #define MICROPY_COMP_FSTRING_LITERAL (MICROPY_CPYTHON_COMPAT) #define MICROPY_MODULE_WEAK_LINKS (0) #define MICROPY_PY_ALL_SPECIAL_METHODS (CIRCUITPY_FULL_BUILD) diff --git a/py/circuitpy_mpconfig.mk b/py/circuitpy_mpconfig.mk index a6aabec33d..08e7737180 100644 --- a/py/circuitpy_mpconfig.mk +++ b/py/circuitpy_mpconfig.mk @@ -90,6 +90,9 @@ CFLAGS += -DCIRCUITPY_BLEIO=$(CIRCUITPY_BLEIO) CIRCUITPY_BOARD ?= 1 CFLAGS += -DCIRCUITPY_BOARD=$(CIRCUITPY_BOARD) +CIRCUITPY_BUILTINS_POW3 ?= $(CIRCUITPY_FULL_BUILD) +CFLAGS += -DCIRCUITPY_BUILTINS_POW3=$(CIRCUITPY_BUILTINS_POW3) + CIRCUITPY_BUSIO ?= 1 CFLAGS += -DCIRCUITPY_BUSIO=$(CIRCUITPY_BUSIO) From 4ca50982b75678ad38c234202fbc1904df32cf57 Mon Sep 17 00:00:00 2001 From: Wellington Terumi Uemura Date: Tue, 24 Nov 2020 23:15:25 +0000 Subject: [PATCH 140/207] Translated using Weblate (Portuguese (Brazil)) Currently translated at 100.0% (864 of 864 strings) Translation: CircuitPython/main Translate-URL: https://hosted.weblate.org/projects/circuitpython/main/pt_BR/ --- locale/pt_BR.po | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/locale/pt_BR.po b/locale/pt_BR.po index 5d8ac39f3b..49ac502e29 100644 --- a/locale/pt_BR.po +++ b/locale/pt_BR.po @@ -6,7 +6,7 @@ msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2020-11-11 16:30+0530\n" -"PO-Revision-Date: 2020-11-24 22:45+0000\n" +"PO-Revision-Date: 2020-11-24 23:22+0000\n" "Last-Translator: Wellington Terumi Uemura \n" "Language-Team: \n" "Language: pt_BR\n" @@ -1289,7 +1289,7 @@ msgstr "Deve utilizar um múltiplo de 6 pinos rgb, não %d" #: ports/esp32s2/common-hal/nvm/ByteArray.c msgid "NVS Error" -msgstr "" +msgstr "Erro NVS" #: py/parse.c msgid "Name too long" From be44c16e253c7694930419974dc1dcdb5258fe23 Mon Sep 17 00:00:00 2001 From: Mitsuharu Aoyama Date: Tue, 24 Nov 2020 23:45:29 +0000 Subject: [PATCH 141/207] Translated using Weblate (Japanese) Currently translated at 69.0% (597 of 864 strings) Translation: CircuitPython/main Translate-URL: https://hosted.weblate.org/projects/circuitpython/main/ja/ --- locale/ja.po | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/locale/ja.po b/locale/ja.po index 0132783026..d0322be773 100644 --- a/locale/ja.po +++ b/locale/ja.po @@ -8,8 +8,8 @@ msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2020-11-11 16:30+0530\n" -"PO-Revision-Date: 2020-11-12 22:51+0000\n" -"Last-Translator: sporeball \n" +"PO-Revision-Date: 2020-11-25 01:11+0000\n" +"Last-Translator: Mitsuharu Aoyama \n" "Language-Team: none\n" "Language: ja\n" "MIME-Version: 1.0\n" @@ -182,7 +182,7 @@ msgstr "" #: py/emitinlinethumb.c py/emitinlinextensa.c #, c-format msgid "'%s' expects an integer" -msgstr "" +msgstr "'%s' には整数が必要" #: py/emitinlinethumb.c #, c-format From fc344bc818f8172ff36ee646459d7d060a51289a Mon Sep 17 00:00:00 2001 From: James Bowman Date: Tue, 24 Nov 2020 17:26:39 -0800 Subject: [PATCH 142/207] Fix opcode typo in VertexFormat() --- shared-module/_eve/__init__.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/shared-module/_eve/__init__.c b/shared-module/_eve/__init__.c index 0f1e12d9fd..d95c777dc4 100644 --- a/shared-module/_eve/__init__.c +++ b/shared-module/_eve/__init__.c @@ -70,8 +70,8 @@ void common_hal__eve_Vertex2f(common_hal__eve_t *eve, mp_float_t x, mp_float_t y void common_hal__eve_VertexFormat(common_hal__eve_t *eve, uint32_t frac) { - C4(eve, ((27 << 24) | ((frac & 7)))); - eve->vscale = 1 << eve->vscale; + C4(eve, ((39 << 24) | ((frac & 7)))); + eve->vscale = 1 << frac; } From 4ac11c8d31311651b77d13bec0a765aa2439cfb2 Mon Sep 17 00:00:00 2001 From: Scott Shawcroft Date: Tue, 24 Nov 2020 17:54:39 -0800 Subject: [PATCH 143/207] Update wifi.Radio.connect doc Now it includes bssid info. --- ports/esp32s2/common-hal/wifi/Radio.c | 4 ++-- shared-bindings/wifi/Radio.c | 20 ++++++++++++++++++-- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/ports/esp32s2/common-hal/wifi/Radio.c b/ports/esp32s2/common-hal/wifi/Radio.c index f7c431a56b..bc987bc1c9 100644 --- a/ports/esp32s2/common-hal/wifi/Radio.c +++ b/ports/esp32s2/common-hal/wifi/Radio.c @@ -138,9 +138,9 @@ wifi_radio_error_t common_hal_wifi_radio_connect(wifi_radio_obj_t *self, uint8_t if (bssid_len > 0){ memcpy(&config->sta.bssid, bssid, bssid_len); config->sta.bssid[bssid_len] = 0; - config->sta.bssid_set = 1; + config->sta.bssid_set = true; } else { - config->sta.bssid_set = 0; + config->sta.bssid_set = false; } // If channel is 0 (default/unset) and BSSID is not given, do a full scan instead of fast scan // This will ensure that the best AP in range is chosen automatically diff --git a/shared-bindings/wifi/Radio.c b/shared-bindings/wifi/Radio.c index e81e8793c4..991abd4f12 100644 --- a/shared-bindings/wifi/Radio.c +++ b/shared-bindings/wifi/Radio.c @@ -142,9 +142,25 @@ const mp_obj_property_t wifi_radio_hostname_obj = { (mp_obj_t)&mp_const_none_obj}, }; -//| def connect(self, ssid: ReadableBuffer, password: ReadableBuffer = b"", *, channel: Optional[int] = 0, timeout: Optional[float] = None) -> bool: +//| def connect(self, +//| ssid: ReadableBuffer, +//| password: ReadableBuffer = b"", +//| *, +//| channel: Optional[int] = 0, +//| bssid: Optional[ReadableBuffer] = b"", +//| timeout: Optional[float] = None) -> bool: //| """Connects to the given ssid and waits for an ip address. Reconnections are handled -//| automatically once one connection succeeds.""" +//| automatically once one connection succeeds. +//| +//| By default, this will scan all channels and connect to the access point (AP) with the +//| given ``ssid`` and greatest signal strength (rssi). +//| +//| If ``channel`` is given, the scan will begin with the given channel and connect to +//| the first AP with the given ``ssid``. This can speed up the connection time +//| significantly because a full scan doesn't occur. +//| +//| If ``bssid`` is given, the scan will start at the first channel or the one given and +//| connect to the AP with the given ``bssid`` and ``ssid``.""" //| ... //| STATIC mp_obj_t wifi_radio_connect(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { From 9a692c3222013efdbcedea95cadf29c0379ca17c Mon Sep 17 00:00:00 2001 From: Scott Shawcroft Date: Tue, 24 Nov 2020 18:14:22 -0800 Subject: [PATCH 144/207] Exit faster on recv when TLS connection closed When a TLS connection is closed by the server it usually sends a notice. We see this incoming byte with lwip_ioctl and try to read it. The read returns 0 but we keep trying anyway. Now, we quit trying when we get zero back. If the connection was still alive it'd either read a byte or delay until a byte could be read. --- ports/esp32s2/common-hal/socketpool/Socket.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/ports/esp32s2/common-hal/socketpool/Socket.c b/ports/esp32s2/common-hal/socketpool/Socket.c index 750415dc7b..999d399902 100644 --- a/ports/esp32s2/common-hal/socketpool/Socket.c +++ b/ports/esp32s2/common-hal/socketpool/Socket.c @@ -103,6 +103,11 @@ mp_uint_t common_hal_socketpool_socket_recv_into(socketpool_socket_obj_t* self, } if (available > 0) { status = esp_tls_conn_read(self->tcp, (void*) buf + received, available); + if (status == 0) { + // Reading zero when something is available indicates a closed + // connection. (The available bytes could have been TLS internal.) + break; + } if (status > 0) { received += status; } From ca1a85c47f333b640188713f868a364d60bc75d5 Mon Sep 17 00:00:00 2001 From: arturo182 Date: Wed, 25 Nov 2020 03:34:01 +0100 Subject: [PATCH 145/207] displayio: Fix ColorConverter make_* methods --- shared-bindings/displayio/ColorConverter.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/shared-bindings/displayio/ColorConverter.c b/shared-bindings/displayio/ColorConverter.c index 0e6e9bfd94..88d3a1ba8f 100644 --- a/shared-bindings/displayio/ColorConverter.c +++ b/shared-bindings/displayio/ColorConverter.c @@ -116,7 +116,7 @@ const mp_obj_property_t displayio_colorconverter_dither_obj = { STATIC mp_obj_t displayio_colorconverter_make_transparent(mp_obj_t self_in, mp_obj_t transparent_color_obj) { displayio_colorconverter_t *self = MP_OBJ_TO_PTR(self_in); - mp_int_t transparent_color = mp_obj_get_int(&transparent_color); + mp_int_t transparent_color = mp_obj_get_int(transparent_color_obj); common_hal_displayio_colorconverter_make_transparent(self, transparent_color); return mp_const_none; } @@ -128,7 +128,7 @@ MP_DEFINE_CONST_FUN_OBJ_2(displayio_colorconverter_make_transparent_obj, display STATIC mp_obj_t displayio_colorconverter_make_opaque(mp_obj_t self_in, mp_obj_t transparent_color_obj) { displayio_colorconverter_t *self = MP_OBJ_TO_PTR(self_in); - mp_int_t transparent_color = mp_obj_get_int(&transparent_color); + mp_int_t transparent_color = mp_obj_get_int(transparent_color_obj); common_hal_displayio_colorconverter_make_opaque(self, transparent_color); return mp_const_none; } From 0d9a0235a29fdf82725606cc7a1362d55da003a7 Mon Sep 17 00:00:00 2001 From: arturo182 Date: Wed, 25 Nov 2020 03:48:50 +0100 Subject: [PATCH 146/207] Update the requests frozen library --- frozen/Adafruit_CircuitPython_Requests | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frozen/Adafruit_CircuitPython_Requests b/frozen/Adafruit_CircuitPython_Requests index 43017e30a1..531e845152 160000 --- a/frozen/Adafruit_CircuitPython_Requests +++ b/frozen/Adafruit_CircuitPython_Requests @@ -1 +1 @@ -Subproject commit 43017e30a1e772b67ac68293a944e863c031e389 +Subproject commit 531e8451522e3bba3e571610e4ac70efcb0cae5a From f868cc5dd02319957500180541281f41ec0d0573 Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Tue, 24 Nov 2020 23:36:59 -0500 Subject: [PATCH 147/207] some API renaming and bug fixes; fix docs --- main.c | 48 ++++++++++++--------- shared-bindings/alarm/__init__.c | 4 +- shared-bindings/alarm/pin/PinAlarm.c | 34 +++++++-------- shared-bindings/alarm/time/DurationAlarm.c | 6 +-- shared-bindings/microcontroller/Processor.c | 4 +- shared-bindings/supervisor/RunReason.c | 2 +- shared-bindings/supervisor/Runtime.c | 2 +- shared-bindings/supervisor/__init__.c | 37 ++++++++-------- 8 files changed, 72 insertions(+), 65 deletions(-) diff --git a/main.c b/main.c index b2e527ddef..10066bd92f 100755 --- a/main.c +++ b/main.c @@ -98,7 +98,7 @@ #endif // How long to wait for host to enumerate (secs). -#define CIRCUITPY_USB_ENUMERATION_DELAY 1 +#define CIRCUITPY_USB_ENUMERATION_DELAY 5 // How long to flash errors on the RGB status LED before going to sleep (secs) #define CIRCUITPY_FLASH_ERROR_PERIOD 10 @@ -319,26 +319,28 @@ STATIC bool run_code_py(safe_mode_t safe_mode) { bool ok = result.return_code != PYEXEC_EXCEPTION; ESP_LOGI("main", "common_hal_alarm_enable_deep_sleep_alarms()"); - // Decide whether to deep sleep. #if CIRCUITPY_ALARM // Enable pin or time alarms before sleeping. common_hal_alarm_enable_deep_sleep_alarms(); #endif - // Normally we won't deep sleep if there was an error or if we are connected to a host - // but either of those can be enabled. - // *********DON'T SLEEP IF USB HASN'T HAD TIME TO ENUMERATE. - bool will_deep_sleep = - (ok || supervisor_workflow_get_allow_deep_sleep_on_error()) && - (!supervisor_workflow_active() || supervisor_workflow_get_allow_deep_sleep_when_connected()); - ESP_LOGI("main", "ok %d", will_deep_sleep); - ESP_LOGI("main", "...on_error() %d", supervisor_workflow_get_allow_deep_sleep_on_error()); - ESP_LOGI("main", "supervisor_workflow_active() %d", supervisor_workflow_active()); - ESP_LOGI("main", "...when_connected() %d", supervisor_workflow_get_allow_deep_sleep_when_connected()); - will_deep_sleep = false; prep_rgb_status_animation(&result, found_main, safe_mode, &animation); while (true) { + // Normally we won't deep sleep if there was an error or if we are connected to a host + // but either of those can be enabled. + // It's ok to deep sleep if we're not connected to a host, but we need to make sure + // we're giving enough time for USB enumeration to happen. + bool deep_sleep_allowed = + (ok || supervisor_workflow_get_allow_deep_sleep_on_error()) && + (!supervisor_workflow_active() || supervisor_workflow_get_allow_deep_sleep_when_connected()) && + (supervisor_ticks_ms64() > CIRCUITPY_USB_ENUMERATION_DELAY * 1024); + + ESP_LOGI("main", "ok %d", deep_sleep_allowed); + ESP_LOGI("main", "...on_error() %d", supervisor_workflow_get_allow_deep_sleep_on_error()); + ESP_LOGI("main", "supervisor_workflow_active() %d", supervisor_workflow_active()); + ESP_LOGI("main", "...when_connected() %d", supervisor_workflow_get_allow_deep_sleep_when_connected()); + ESP_LOGI("main", "supervisor_ticks_ms64() %lld", supervisor_ticks_ms64()); RUN_BACKGROUND_TASKS; if (reload_requested) { supervisor_set_run_reason(RUN_REASON_AUTO_RELOAD); @@ -360,7 +362,7 @@ STATIC bool run_code_py(safe_mode_t safe_mode) { print_code_py_status_message(safe_mode); } // We won't be going into the REPL if we're going to sleep. - if (!will_deep_sleep) { + if (!deep_sleep_allowed) { print_safe_mode_message(safe_mode); serial_write("\n"); serial_write_compressed(translate("Press any key to enter the REPL. Use CTRL-D to reload.")); @@ -379,27 +381,31 @@ STATIC bool run_code_py(safe_mode_t safe_mode) { #endif bool animation_done = false; - if (will_deep_sleep && ok) { + + if (deep_sleep_allowed && ok) { // Skip animation if everything is OK. animation_done = true; } else { animation_done = tick_rgb_status_animation(&animation); } // Do an error animation only once before deep-sleeping. - if (animation_done && will_deep_sleep) { - int64_t remaining_enumeration_wait = CIRCUITPY_USB_ENUMERATION_DELAY * 1024 - supervisor_ticks_ms64(); - // If USB isn't enumerated then deep sleep after our waiting period. - if (ok && remaining_enumeration_wait < 0) { + if (animation_done) { + if (deep_sleep_allowed) { common_hal_mcu_deep_sleep(); // Does not return. } + // Wake up every so often to flash the error code. if (!ok) { port_interrupt_after_ticks(CIRCUITPY_FLASH_ERROR_PERIOD * 1024); } else { - port_interrupt_after_ticks(remaining_enumeration_wait); + int64_t remaining_enumeration_wait = + CIRCUITPY_USB_ENUMERATION_DELAY * 1024 - supervisor_ticks_ms64(); + if (remaining_enumeration_wait > 0) { + port_interrupt_after_ticks(remaining_enumeration_wait); + } + port_sleep_until_interrupt(); } - port_sleep_until_interrupt(); } } } diff --git a/shared-bindings/alarm/__init__.c b/shared-bindings/alarm/__init__.c index 22b2e7f6ab..b6b86c8354 100644 --- a/shared-bindings/alarm/__init__.c +++ b/shared-bindings/alarm/__init__.c @@ -38,7 +38,7 @@ //| //| Light sleep leaves the CPU and RAM powered so that CircuitPython can resume where it left off //| after being woken up. CircuitPython automatically goes into a light sleep when `time.sleep()` is -//| called. To light sleep until a non-time alarm use `alarm.sleep_until_alarm()`. Any active +//| called. To light sleep until a non-time alarm use `alarm.sleep_until_alarms()`. Any active //| peripherals, such as I2C, are left on. //| //| Deep sleep shuts down power to nearly all of the chip including the CPU and RAM. This can save @@ -51,7 +51,7 @@ //| //| An error includes an uncaught exception, or sys.exit() called with a non-zero argument //| -//| To set alarms for deep sleep use `alarm.restart_on_alarm()` they will apply to next deep sleep only.""" +//| To set alarms for deep sleep use `alarm.set_deep_sleep_alarms()` they will apply to next deep sleep only.""" //| //| wake_alarm: Alarm //| """The most recent alarm to wake us up from a sleep (light or deep.)""" diff --git a/shared-bindings/alarm/pin/PinAlarm.c b/shared-bindings/alarm/pin/PinAlarm.c index a2d2e0ab7a..bb48b93c42 100644 --- a/shared-bindings/alarm/pin/PinAlarm.c +++ b/shared-bindings/alarm/pin/PinAlarm.c @@ -38,26 +38,26 @@ //| """Trigger an alarm when a pin changes state.""" //| //| def __init__(self, *pins: microcontroller.Pin, value: bool, all_same_value: bool = False, edge: bool = False, pull: bool = False) -> None: -//| """Create an alarm triggered by a `~microcontroller.Pin` level. The alarm is not active -//| until it is listed in an `alarm`-enabling function, such as `alarm.sleep_until_alarm()` or -//| `alarm.restart_on_alarm()`. +//| """Create an alarm triggered by a `microcontroller.Pin` level. The alarm is not active +//| until it is listed in an `alarm`-enabling function, such as `alarm.sleep_until_alarms()` or +//| `alarm.set_deep_sleep_alarms()`. //| -//| :param pins: The pins to monitor. On some ports, the choice of pins -//| may be limited due to hardware restrictions, particularly for deep-sleep alarms. +//| :param microcontroller.Pin \*pins: The pins to monitor. On some ports, the choice of pins +//| may be limited due to hardware restrictions, particularly for deep-sleep alarms. //| :param bool value: When active, trigger when the pin value is high (``True``) or low (``False``). -//| On some ports, multiple `PinAlarm` objects may need to have coordinated values -//| for deep-sleep alarms. -//| :param bool all_same_value: If ``True``, all pins listed must be at `value` to trigger the alarm. -//| If ``False``, any one of the pins going to `value` will trigger the alarm. +//| On some ports, multiple `PinAlarm` objects may need to have coordinated values +//| for deep-sleep alarms. +//| :param bool all_same_value: If ``True``, all pins listed must be at ``value`` to trigger the alarm. +//| If ``False``, any one of the pins going to ``value`` will trigger the alarm. //| :param bool edge: If ``True``, trigger only when there is a transition to the specified -//| value of `value`. If ``True``, if the alarm becomes active when the pin value already -//| matches `value`, the alarm is not triggered: the pin must transition from ``not value`` -//| to ``value`` to trigger the alarm. On some ports, edge-triggering may not be available, -//| particularly for deep-sleep alarms. -//| :param bool pull: Enable a pull-up or pull-down which pulls the pin to value opposite -//| opposite that of `value`. For instance, if `value` is set to ``True``, setting `pull` -//| to ``True`` will enable a pull-down, to hold the pin low normally until an outside signal -//| pulls it high. +//| value of ``value``. If ``True``, if the alarm becomes active when the pin value already +//| matches ``value``, the alarm is not triggered: the pin must transition from ``not value`` +//| to ``value`` to trigger the alarm. On some ports, edge-triggering may not be available, +//| particularly for deep-sleep alarms. +//| :param bool pull: Enable a pull-up or pull-down which pulls the pin to the level opposite +//| opposite that of ``value``. For instance, if ``value`` is set to ``True``, setting ``pull`` +//| to ``True`` will enable a pull-down, to hold the pin low normally until an outside signal +//| pulls it high. //| """ //| ... //| diff --git a/shared-bindings/alarm/time/DurationAlarm.c b/shared-bindings/alarm/time/DurationAlarm.c index c105bbebf7..6831aba5db 100644 --- a/shared-bindings/alarm/time/DurationAlarm.c +++ b/shared-bindings/alarm/time/DurationAlarm.c @@ -37,10 +37,10 @@ //| """Trigger an alarm at a specified interval from now.""" //| //| def __init__(self, secs: float) -> None: -//| """Create an alarm that will be triggered in `secs` seconds from the time +//| """Create an alarm that will be triggered in ``secs`` seconds from the time //| sleep starts. The alarm is not active until it is listed in an -//| `alarm`-enabling function, such as `alarm.sleep_until_alarm()` or -//| `alarm.restart_on_alarm()`. +//| `alarm`-enabling function, such as `alarm.sleep_until_alarms()` or +//| `alarm.set_deep_sleep_alarms()`. //| """ //| ... //| diff --git a/shared-bindings/microcontroller/Processor.c b/shared-bindings/microcontroller/Processor.c index ea43688213..90cc02fe39 100644 --- a/shared-bindings/microcontroller/Processor.c +++ b/shared-bindings/microcontroller/Processor.c @@ -67,8 +67,8 @@ const mp_obj_property_t mcu_processor_frequency_obj = { }, }; -//| reset_reason: `microcontroller.ResetReason` -//| """The reason the microcontroller started up from reset state.""" +//| reset_reason: microcontroller.ResetReason +//| """The reason the microcontroller started up from reset state.""" //| STATIC mp_obj_t mcu_processor_get_reset_reason(mp_obj_t self) { return cp_enum_find(&mcu_reset_reason_type, common_hal_mcu_processor_get_reset_reason()); diff --git a/shared-bindings/supervisor/RunReason.c b/shared-bindings/supervisor/RunReason.c index 73f62fed6d..a2a5fe13ef 100644 --- a/shared-bindings/supervisor/RunReason.c +++ b/shared-bindings/supervisor/RunReason.c @@ -37,7 +37,7 @@ MAKE_ENUM_VALUE(supervisor_run_reason_type, run_reason, REPL_RELOAD, RUN_REASON_ //| """The reason that CircuitPython started running.""" //| //| STARTUP: object -//| """CircuitPython started the microcontroller started up. See `microcontroller.cpu.reset_reason` +//| """CircuitPython started the microcontroller started up. See `microcontroller.Processor.reset_reason` //| for more detail on why the microcontroller was started.""" //| //| AUTO_RELOAD: object diff --git a/shared-bindings/supervisor/Runtime.c b/shared-bindings/supervisor/Runtime.c index 1a283b35c0..8e0259a3b3 100755 --- a/shared-bindings/supervisor/Runtime.c +++ b/shared-bindings/supervisor/Runtime.c @@ -98,7 +98,7 @@ const mp_obj_property_t supervisor_serial_bytes_available_obj = { //| run_reason: RunReason -//| """Returns why CircuitPython started running this particular time. +//| """Returns why CircuitPython started running this particular time.""" //| STATIC mp_obj_t supervisor_get_run_reason(mp_obj_t self) { return cp_enum_find(&supervisor_run_reason_type, _run_reason); diff --git a/shared-bindings/supervisor/__init__.c b/shared-bindings/supervisor/__init__.c index c13b19e48e..9a7890a87d 100644 --- a/shared-bindings/supervisor/__init__.c +++ b/shared-bindings/supervisor/__init__.c @@ -47,18 +47,19 @@ //| This object is the sole instance of `supervisor.Runtime`.""" //| -//| def allow_deep_sleep(*, when_connected: bool = False, on_error: bool = False): -//| """Configure when CircuitPython can go into deep sleep. Deep sleep can occur -//| after a program has finished running or when `supervisor.deep_sleep_now()` is called. +//| def allow_deep_sleep(*, when_connected: bool = False, on_error: bool = False) -> None: +//| """Configure when CircuitPython can go into deep sleep. Deep sleep can occur +//| after a program has finished running or when `supervisor.exit_and_deep_sleep()` is called. //| -//| :param bool when_connected: If ``True``, CircuitPython will go into deep sleep -//| when a program finishes, even if it is connected to a host computer over USB or other means. -//| It will disconnect from the host before sleeping. -//| If ``False``, deep sleep will not be entered if connected. -//| :param bool on_error: If ``True``, deep sleep will be entered if even a program -//| terminated due to an exception or fatal error. If ``False``, an error will cause -//| CircuitPython to stay awake, flashing error codes on the status RGB LED, if available. -//| ... +//| :param bool when_connected: If ``True``, CircuitPython will go into deep sleep +//| when a program finishes, even if it is connected to a host computer over USB or other means. +//| It will disconnect from the host before sleeping. +//| If ``False``, deep sleep will not be entered if connected. +//| :param bool on_error: If ``True``, deep sleep will be entered if even a program +//| terminated due to an exception or fatal error. If ``False``, an error will cause +//| CircuitPython to stay awake, flashing error codes on the status RGB LED, if available. +//| """ +//| ... //| STATIC mp_obj_t supervisor_allow_deep_sleep(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum { ARG_when_connected, ARG_on_error }; @@ -77,16 +78,16 @@ STATIC mp_obj_t supervisor_allow_deep_sleep(size_t n_args, const mp_obj_t *pos_a } MP_DEFINE_CONST_FUN_OBJ_KW(supervisor_allow_deep_sleep_obj, 0, supervisor_allow_deep_sleep); -//| def deep_sleep(): -> None +//| def exit_and_deep_sleep() -> None: //| """Go into deep sleep mode immediately, if not connected to a host computer. -//| But if connected and `supervisor.runtime.allow_deep_sleep(when_connected=true)` -//| has not been called, simply restart. -//| +//| But if connected and ``supervisor.allow_deep_sleep(when_connected=true)`` +//| has not been called, simply restart.""" +//| ... -STATIC mp_obj_t supervisor_deep_sleep(void) { +STATIC mp_obj_t supervisor_exit_and_deep_sleep(void) { common_hal_mcu_deep_sleep(); } -MP_DEFINE_CONST_FUN_OBJ_0(supervisor_deep_sleep_obj, supervisor_deep_sleep); +MP_DEFINE_CONST_FUN_OBJ_0(supervisor_exit_and_deep_sleep_obj, supervisor_exit_and_deep_sleep); //| def enable_autoreload() -> None: //| """Enable autoreload based on USB file write activity.""" @@ -156,7 +157,7 @@ MP_DEFINE_CONST_FUN_OBJ_1(supervisor_set_next_stack_limit_obj, supervisor_set_ne STATIC const mp_rom_map_elem_t supervisor_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_supervisor) }, { MP_ROM_QSTR(MP_QSTR_allow_deep_sleep), MP_ROM_PTR(&supervisor_allow_deep_sleep_obj) }, - { MP_ROM_QSTR(MP_QSTR_deep_sleep), MP_ROM_PTR(&supervisor_deep_sleep_obj) }, + { MP_ROM_QSTR(MP_QSTR_exit_and_deep_sleep), MP_ROM_PTR(&supervisor_exit_and_deep_sleep_obj) }, { MP_ROM_QSTR(MP_QSTR_enable_autoreload), MP_ROM_PTR(&supervisor_enable_autoreload_obj) }, { MP_ROM_QSTR(MP_QSTR_disable_autoreload), MP_ROM_PTR(&supervisor_disable_autoreload_obj) }, { MP_ROM_QSTR(MP_QSTR_set_rgb_status_brightness), MP_ROM_PTR(&supervisor_set_rgb_status_brightness_obj) }, From a854da35d33f1bc1673b4de08b2efa9f4823b805 Mon Sep 17 00:00:00 2001 From: Lucian Copeland Date: Wed, 25 Nov 2020 12:14:56 -0500 Subject: [PATCH 148/207] Fix masking issue causing pin claim problems --- ports/esp32s2/common-hal/microcontroller/Pin.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ports/esp32s2/common-hal/microcontroller/Pin.c b/ports/esp32s2/common-hal/microcontroller/Pin.c index 3c2611efeb..394a19e695 100644 --- a/ports/esp32s2/common-hal/microcontroller/Pin.c +++ b/ports/esp32s2/common-hal/microcontroller/Pin.c @@ -96,7 +96,7 @@ void reset_all_pins(void) { } void claim_pin(const mcu_pin_obj_t* pin) { - in_use[pin->number / 32] |= (1 << pin->number % 32); + in_use[pin->number / 32] |= (1 << (pin->number % 32)); #ifdef MICROPY_HW_NEOPIXEL if (pin == MICROPY_HW_NEOPIXEL) { neopixel_in_use = true; @@ -116,7 +116,7 @@ bool pin_number_is_free(gpio_num_t pin_number) { #endif uint8_t offset = pin_number / 32; - uint8_t mask = 1 << pin_number % 32; + uint32_t mask = 1 << (pin_number % 32); return (never_reset_pins[offset] & mask) == 0 && (in_use[offset] & mask) == 0; } From 9dbea36eac9a78cf324bba8d32a5cb2c9940d411 Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Wed, 25 Nov 2020 15:07:57 -0500 Subject: [PATCH 149/207] changed alarm.time API --- locale/circuitpython.pot | 29 +++--- main.c | 7 +- ports/esp32s2/common-hal/alarm/__init__.c | 33 +++++-- ports/esp32s2/common-hal/alarm/pin/PinAlarm.c | 3 +- .../{DurationAlarm.c => MonotonicTimeAlarm.c} | 22 +---- .../{DurationAlarm.h => MonotonicTimeAlarm.h} | 5 +- py/circuitpy_defns.mk | 2 +- py/obj.h | 1 + py/objfloat.c | 7 ++ shared-bindings/alarm/__init__.c | 10 +- shared-bindings/alarm/__init__.h | 2 +- shared-bindings/alarm/pin/PinAlarm.c | 37 +++++++- shared-bindings/alarm/pin/PinAlarm.h | 4 +- shared-bindings/alarm/time/DurationAlarm.c | 91 ------------------ .../alarm/time/MonotonicTimeAlarm.c | 93 +++++++++++++++++++ .../{DurationAlarm.h => MonotonicTimeAlarm.h} | 17 ++-- shared-bindings/time/__init__.c | 4 +- 17 files changed, 209 insertions(+), 158 deletions(-) rename ports/esp32s2/common-hal/alarm/time/{DurationAlarm.c => MonotonicTimeAlarm.c} (61%) rename ports/esp32s2/common-hal/alarm/time/{DurationAlarm.h => MonotonicTimeAlarm.h} (91%) delete mode 100644 shared-bindings/alarm/time/DurationAlarm.c create mode 100644 shared-bindings/alarm/time/MonotonicTimeAlarm.c rename shared-bindings/alarm/time/{DurationAlarm.h => MonotonicTimeAlarm.h} (63%) diff --git a/locale/circuitpython.pot b/locale/circuitpython.pot index 1dae9547a3..b59a5f77e4 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-11-21 12:36-0500\n" +"POT-Creation-Date: 2020-11-25 15:08-0500\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -17,13 +17,6 @@ msgstr "" "Content-Type: text/plain; charset=CHARSET\n" "Content-Transfer-Encoding: 8bit\n" -#: main.c -msgid "" -"\n" -"\n" -"------ soft reboot ------\n" -msgstr "" - #: main.c msgid "" "\n" @@ -849,6 +842,10 @@ msgstr "" msgid "Expected an Address" msgstr "" +#: shared-bindings/alarm/__init__.c +msgid "Expected an alarm" +msgstr "" + #: shared-module/_pixelbuf/PixelBuf.c #, c-format msgid "Expected tuple of length %d, got %d" @@ -1440,6 +1437,10 @@ msgid "" "%d bpp given" msgstr "" +#: ports/esp32s2/common-hal/alarm/__init__.c +msgid "Only one alarm.time alarm can be set." +msgstr "" + #: shared-module/displayio/ColorConverter.c msgid "Only one color can be transparent at a time" msgstr "" @@ -1497,6 +1498,10 @@ msgstr "" msgid "Pin number already reserved by EXTI" msgstr "" +#: ports/esp32s2/common-hal/alarm/__init__.c +msgid "PinAlarm deep sleep not yet implemented" +msgstr "" + #: shared-bindings/rgbmatrix/RGBMatrix.c #, c-format msgid "" @@ -2449,10 +2454,6 @@ msgstr "" msgid "division by zero" msgstr "" -#: ports/esp32s2/common-hal/alarm/time/DurationAlarm.c -msgid "duration out of range" -msgstr "" - #: py/objdeque.c msgid "empty" msgstr "" @@ -3354,6 +3355,10 @@ msgstr "" msgid "small int overflow" msgstr "" +#: main.c +msgid "soft reboot\n" +msgstr "" + #: extmod/ulab/code/numerical/numerical.c msgid "sort argument must be an ndarray" msgstr "" diff --git a/main.c b/main.c index 10066bd92f..d52f840185 100755 --- a/main.c +++ b/main.c @@ -321,7 +321,9 @@ STATIC bool run_code_py(safe_mode_t safe_mode) { ESP_LOGI("main", "common_hal_alarm_enable_deep_sleep_alarms()"); #if CIRCUITPY_ALARM // Enable pin or time alarms before sleeping. - common_hal_alarm_enable_deep_sleep_alarms(); + // If immediate_wake is true, then there's alarm that would trigger immediately, + // so don't sleep. + bool immediate_wake = !common_hal_alarm_enable_deep_sleep_alarms(); #endif @@ -332,6 +334,7 @@ STATIC bool run_code_py(safe_mode_t safe_mode) { // It's ok to deep sleep if we're not connected to a host, but we need to make sure // we're giving enough time for USB enumeration to happen. bool deep_sleep_allowed = + !immediate_wake && (ok || supervisor_workflow_get_allow_deep_sleep_on_error()) && (!supervisor_workflow_active() || supervisor_workflow_get_allow_deep_sleep_when_connected()) && (supervisor_ticks_ms64() > CIRCUITPY_USB_ENUMERATION_DELAY * 1024); @@ -576,7 +579,7 @@ int __attribute__((used)) main(void) { } if (exit_code == PYEXEC_FORCED_EXIT) { if (!first_run) { - serial_write_compressed(translate("\n\n------ soft reboot ------\n")); + serial_write_compressed(translate("soft reboot\n")); } first_run = false; skip_repl = run_code_py(safe_mode); diff --git a/ports/esp32s2/common-hal/alarm/__init__.c b/ports/esp32s2/common-hal/alarm/__init__.c index 87276bdaf0..37d74c0be3 100644 --- a/ports/esp32s2/common-hal/alarm/__init__.c +++ b/ports/esp32s2/common-hal/alarm/__init__.c @@ -25,13 +25,15 @@ * THE SOFTWARE. */ +#include "py/obj.h" #include "py/objtuple.h" #include "py/runtime.h" #include "shared-bindings/alarm/__init__.h" #include "shared-bindings/alarm/pin/PinAlarm.h" -#include "shared-bindings/alarm/time/DurationAlarm.h" +#include "shared-bindings/alarm/time/MonotonicTimeAlarm.h" #include "shared-bindings/microcontroller/__init__.h" +#include "shared-bindings/time/__init__.h" #include "esp_sleep.h" @@ -49,8 +51,8 @@ mp_obj_t common_hal_alarm_get_wake_alarm(void) { switch (esp_sleep_get_wakeup_cause()) { case ESP_SLEEP_WAKEUP_TIMER: { // Wake up from timer. - alarm_time_duration_alarm_obj_t *timer = m_new_obj(alarm_time_duration_alarm_obj_t); - timer->base.type = &alarm_time_duration_alarm_type; + alarm_time_monotonic_time_alarm_obj_t *timer = m_new_obj(alarm_time_monotonic_time_alarm_obj_t); + timer->base.type = &alarm_time_monotonic_time_alarm_type; return timer; } @@ -84,7 +86,7 @@ void common_hal_alarm_set_deep_sleep_alarms(size_t n_alarms, const mp_obj_t *ala if (MP_OBJ_IS_TYPE(alarms[i], &alarm_pin_pin_alarm_type)) { mp_raise_NotImplementedError(translate("PinAlarm deep sleep not yet implemented")); } - if (MP_OBJ_IS_TYPE(alarms[i], &alarm_time_duration_alarm_type)) { + else if (MP_OBJ_IS_TYPE(alarms[i], &alarm_time_monotonic_time_alarm_type)) { if (time_alarm_set) { mp_raise_ValueError(translate("Only one alarm.time alarm can be set.")); } @@ -95,14 +97,25 @@ void common_hal_alarm_set_deep_sleep_alarms(size_t n_alarms, const mp_obj_t *ala _deep_sleep_alarms = mp_obj_new_tuple(n_alarms, alarms); } -void common_hal_alarm_enable_deep_sleep_alarms(void) { +// Return false if we should wake up immediately because a time alarm is in the past +// or otherwise already triggered. +bool common_hal_alarm_enable_deep_sleep_alarms(void) { for (size_t i = 0; i < _deep_sleep_alarms->len; i++) { mp_obj_t alarm = _deep_sleep_alarms->items[i]; - if (MP_OBJ_IS_TYPE(alarm, &alarm_time_duration_alarm_type)) { - alarm_time_duration_alarm_obj_t *duration_alarm = MP_OBJ_TO_PTR(alarm); - esp_sleep_enable_timer_wakeup( - (uint64_t) (duration_alarm->duration * 1000000.0f)); + if (MP_OBJ_IS_TYPE(alarm, &alarm_pin_pin_alarm_type)) { + // TODO: handle pin alarms + mp_raise_NotImplementedError(translate("PinAlarm deep sleep not yet implemented")); + } + else if (MP_OBJ_IS_TYPE(alarm, &alarm_time_monotonic_time_alarm_type)) { + alarm_time_monotonic_time_alarm_obj_t *monotonic_time_alarm = MP_OBJ_TO_PTR(alarm); + mp_float_t now = uint64_to_float(common_hal_time_monotonic()); + // Compute a relative time in the future from now. + mp_float_t duration_secs = now - monotonic_time_alarm->monotonic_time; + if (duration_secs <= 0.0f) { + return false; + } + esp_sleep_enable_timer_wakeup((uint64_t) (duration_secs * 1000000)); } - // TODO: handle pin alarms } + return true; } diff --git a/ports/esp32s2/common-hal/alarm/pin/PinAlarm.c b/ports/esp32s2/common-hal/alarm/pin/PinAlarm.c index f26c8a179a..438d6885dc 100644 --- a/ports/esp32s2/common-hal/alarm/pin/PinAlarm.c +++ b/ports/esp32s2/common-hal/alarm/pin/PinAlarm.c @@ -3,7 +3,6 @@ * * The MIT License (MIT) * - * Copyright (c) 2020 @microDev1 (GitHub) * Copyright (c) 2020 Dan Halbert for Adafruit Industries * * Permission is hereby granted, free of charge, to any person obtaining a copy @@ -38,7 +37,7 @@ void common_hal_alarm_pin_pin_alarm_construct(alarm_pin_pin_alarm_obj_t *self, c self->pull = pull; } -const mp_obj_tuple_t *common_hal_alarm_pin_pin_alarm_get_pins(alarm_pin_pin_alarm_obj_t *self) { +mp_obj_tuple_t *common_hal_alarm_pin_pin_alarm_get_pins(alarm_pin_pin_alarm_obj_t *self) { return self->pins; } diff --git a/ports/esp32s2/common-hal/alarm/time/DurationAlarm.c b/ports/esp32s2/common-hal/alarm/time/MonotonicTimeAlarm.c similarity index 61% rename from ports/esp32s2/common-hal/alarm/time/DurationAlarm.c rename to ports/esp32s2/common-hal/alarm/time/MonotonicTimeAlarm.c index 80bf4244e3..81864d99ed 100644 --- a/ports/esp32s2/common-hal/alarm/time/DurationAlarm.c +++ b/ports/esp32s2/common-hal/alarm/time/MonotonicTimeAlarm.c @@ -3,7 +3,6 @@ * * The MIT License (MIT) * - * Copyright (c) 2020 @microDev1 (GitHub) * Copyright (c) 2020 Dan Halbert for Adafruit Industries * * Permission is hereby granted, free of charge, to any person obtaining a copy @@ -29,23 +28,12 @@ #include "py/runtime.h" -#include "shared-bindings/alarm/time/DurationAlarm.h" +#include "shared-bindings/alarm/time/MonotonicTimeAlarm.h" -void common_hal_alarm_time_duration_alarm_construct(alarm_time_duration_alarm_obj_t *self, mp_float_t duration) { - self->duration = duration; +void common_hal_alarm_time_monotonic_time_alarm_construct(alarm_time_monotonic_time_alarm_obj_t *self, mp_float_t monotonic_time) { + self->monotonic_time = monotonic_time; } -mp_float_t common_hal_alarm_time_duration_alarm_get_duration(alarm_time_duration_alarm_obj_t *self) { - return self->duration; -} - -void common_hal_alarm_time_duration_alarm_enable(alarm_time_duration_alarm_obj_t *self) { - if (esp_sleep_enable_timer_wakeup((uint64_t) (self->duration * 1000000)) == ESP_ERR_INVALID_ARG) { - mp_raise_ValueError(translate("duration out of range")); - } -} - -void common_hal_alarm_time_duration_alarm_disable (alarm_time_duration_alarm_obj_t *self) { - (void) self; - esp_sleep_disable_wakeup_source(ESP_SLEEP_WAKEUP_TIMER); +mp_float_t common_hal_alarm_time_monotonic_time_alarm_get_monotonic_time(alarm_time_monotonic_time_alarm_obj_t *self) { + return self->monotonic_time; } diff --git a/ports/esp32s2/common-hal/alarm/time/DurationAlarm.h b/ports/esp32s2/common-hal/alarm/time/MonotonicTimeAlarm.h similarity index 91% rename from ports/esp32s2/common-hal/alarm/time/DurationAlarm.h rename to ports/esp32s2/common-hal/alarm/time/MonotonicTimeAlarm.h index 3e81cbac2f..5ff8294506 100644 --- a/ports/esp32s2/common-hal/alarm/time/DurationAlarm.h +++ b/ports/esp32s2/common-hal/alarm/time/MonotonicTimeAlarm.h @@ -3,7 +3,6 @@ * * The MIT License (MIT) * - * Copyright (c) 2020 @microDev1 (GitHub) * Copyright (c) 2020 Dan Halbert for Adafruit Industries * * Permission is hereby granted, free of charge, to any person obtaining a copy @@ -30,5 +29,5 @@ typedef struct { mp_obj_base_t base; - mp_float_t duration; // seconds -} alarm_time_duration_alarm_obj_t; + mp_float_t monotonic_time; // values compatible with time.monotonic_time() +} alarm_time_monotonic_time_alarm_obj_t; diff --git a/py/circuitpy_defns.mk b/py/circuitpy_defns.mk index 27466282a8..14b658df4a 100644 --- a/py/circuitpy_defns.mk +++ b/py/circuitpy_defns.mk @@ -303,7 +303,7 @@ SRC_COMMON_HAL_ALL = \ _pew/__init__.c \ alarm/__init__.c \ alarm/pin/PinAlarm.c \ - alarm/time/DurationAlarm.c \ + alarm/time/MonotonicTimeAlarm.c \ analogio/AnalogIn.c \ analogio/AnalogOut.c \ analogio/__init__.c \ diff --git a/py/obj.h b/py/obj.h index 805b26e487..e055c97506 100644 --- a/py/obj.h +++ b/py/obj.h @@ -679,6 +679,7 @@ mp_obj_t mp_obj_new_bytearray_by_ref(size_t n, void *items); #if MICROPY_PY_BUILTINS_FLOAT mp_obj_t mp_obj_new_int_from_float(mp_float_t val); mp_obj_t mp_obj_new_complex(mp_float_t real, mp_float_t imag); +extern mp_float_t uint64_to_float(uint64_t ui64); #endif mp_obj_t mp_obj_new_exception(const mp_obj_type_t *exc_type); mp_obj_t mp_obj_new_exception_arg1(const mp_obj_type_t *exc_type, mp_obj_t arg); diff --git a/py/objfloat.c b/py/objfloat.c index 59f1eb2f69..80f10e816e 100644 --- a/py/objfloat.c +++ b/py/objfloat.c @@ -333,6 +333,13 @@ mp_obj_t mp_obj_float_binary_op(mp_binary_op_t op, mp_float_t lhs_val, mp_obj_t return mp_obj_new_float(lhs_val); } +// Convert a uint64_t to a 32-bit float without invoking the double-precision math routines, +// which are large. +mp_float_t uint64_to_float(uint64_t ui64) { + // 4294967296 = 2^32 + return (mp_float_t) ((uint32_t) (ui64 >> 32) * 4294967296.0f + (uint32_t) (ui64 & 0xffffffff)); +} + #pragma GCC diagnostic pop #endif // MICROPY_PY_BUILTINS_FLOAT diff --git a/shared-bindings/alarm/__init__.c b/shared-bindings/alarm/__init__.c index b6b86c8354..a3ecdd2ba0 100644 --- a/shared-bindings/alarm/__init__.c +++ b/shared-bindings/alarm/__init__.c @@ -29,7 +29,7 @@ #include "shared-bindings/alarm/__init__.h" #include "shared-bindings/alarm/pin/PinAlarm.h" -#include "shared-bindings/alarm/time/DurationAlarm.h" +#include "shared-bindings/alarm/time/MonotonicTimeAlarm.h" //| """Power-saving light and deep sleep. Alarms can be set to wake up from sleep. //| @@ -60,7 +60,7 @@ void validate_objs_are_alarms(size_t n_args, const mp_obj_t *objs) { for (size_t i = 0; i < n_args; i++) { if (MP_OBJ_IS_TYPE(objs[i], &alarm_pin_pin_alarm_type) || - MP_OBJ_IS_TYPE(objs[i], &alarm_time_duration_alarm_type)) { + MP_OBJ_IS_TYPE(objs[i], &alarm_time_monotonic_time_alarm_type)) { continue; } mp_raise_TypeError_varg(translate("Expected an alarm")); @@ -86,7 +86,9 @@ MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(alarm_sleep_until_alarms_obj, 1, MP_OBJ_FUN_ //| When awakened, the microcontroller will restart and run ``boot.py`` and ``code.py`` //| from the beginning. //| -//| The alarm that caused the wake-up is available as `alarm.wake_alarm`. +//| An alarm equivalent to the one that caused the wake-up is available as `alarm.wake_alarm`. +//| Its type and/or attributes may not correspond exactly to the original alarm. +//| For time-base alarms, currently, an `alarm.time.MonotonicTimeAlarm()` is created. //| //| If you call this routine more than once, only the last set of alarms given will be used. //| """ @@ -121,7 +123,7 @@ STATIC const mp_obj_module_t alarm_pin_module = { STATIC const mp_map_elem_t alarm_time_globals_table[] = { { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_time) }, - { MP_ROM_QSTR(MP_QSTR_DurationAlarm), MP_OBJ_FROM_PTR(&alarm_time_duration_alarm_type) }, + { MP_ROM_QSTR(MP_QSTR_MonotonicTimeAlarm), MP_OBJ_FROM_PTR(&alarm_time_monotonic_time_alarm_type) }, }; STATIC MP_DEFINE_CONST_DICT(alarm_time_globals, alarm_time_globals_table); diff --git a/shared-bindings/alarm/__init__.h b/shared-bindings/alarm/__init__.h index d8d6812c90..0f084c78e8 100644 --- a/shared-bindings/alarm/__init__.h +++ b/shared-bindings/alarm/__init__.h @@ -32,7 +32,7 @@ #include "common-hal/alarm/__init__.h" extern mp_obj_t common_hal_alarm_sleep_until_alarms(size_t n_alarms, const mp_obj_t *alarms); -extern void common_hal_alarm_enable_deep_sleep_alarms(void); +extern bool common_hal_alarm_enable_deep_sleep_alarms(void); extern void common_hal_alarm_set_deep_sleep_alarms(size_t n_alarms, const mp_obj_t *alarms); // Used by wake-up code. diff --git a/shared-bindings/alarm/pin/PinAlarm.c b/shared-bindings/alarm/pin/PinAlarm.c index bb48b93c42..ff7b19ca1f 100644 --- a/shared-bindings/alarm/pin/PinAlarm.c +++ b/shared-bindings/alarm/pin/PinAlarm.c @@ -31,6 +31,7 @@ #include "py/nlr.h" #include "py/obj.h" +#include "py/objproperty.h" #include "py/runtime.h" #include "supervisor/shared/translate.h" @@ -39,7 +40,7 @@ //| //| def __init__(self, *pins: microcontroller.Pin, value: bool, all_same_value: bool = False, edge: bool = False, pull: bool = False) -> None: //| """Create an alarm triggered by a `microcontroller.Pin` level. The alarm is not active -//| until it is listed in an `alarm`-enabling function, such as `alarm.sleep_until_alarms()` or +//| until it is passed to an `alarm`-enabling function, such as `alarm.sleep_until_alarms()` or //| `alarm.set_deep_sleep_alarms()`. //| //| :param microcontroller.Pin \*pins: The pins to monitor. On some ports, the choice of pins @@ -88,7 +89,41 @@ STATIC mp_obj_t alarm_pin_pin_alarm_make_new(const mp_obj_type_t *type, mp_uint_ return MP_OBJ_FROM_PTR(self); } +//| pins: Tuple[microcontroller.pin] +//| """The trigger pins.""" +//| +STATIC mp_obj_t alarm_pin_pin_alarm_obj_get_pins(mp_obj_t self_in) { + alarm_pin_pin_alarm_obj_t *self = MP_OBJ_TO_PTR(self_in); + return common_hal_alarm_pin_pin_alarm_get_pins(self); +} +MP_DEFINE_CONST_FUN_OBJ_1(alarm_pin_pin_alarm_get_pins_obj, alarm_pin_pin_alarm_obj_get_pins); + +const mp_obj_property_t alarm_pin_pin_alarm_pins_obj = { + .base.type = &mp_type_property, + .proxy = {(mp_obj_t)&alarm_pin_pin_alarm_get_pins_obj, + (mp_obj_t)&mp_const_none_obj, + (mp_obj_t)&mp_const_none_obj}, +}; + +//| value: Tuple[microcontroller.pin] +//| """The value on which to trigger.""" +//| +STATIC mp_obj_t alarm_pin_pin_alarm_obj_get_value(mp_obj_t self_in) { + alarm_pin_pin_alarm_obj_t *self = MP_OBJ_TO_PTR(self_in); + return mp_obj_new_bool(common_hal_alarm_pin_pin_alarm_get_value(self)); +} +MP_DEFINE_CONST_FUN_OBJ_1(alarm_pin_pin_alarm_get_value_obj, alarm_pin_pin_alarm_obj_get_value); + +const mp_obj_property_t alarm_pin_pin_alarm_value_obj = { + .base.type = &mp_type_property, + .proxy = {(mp_obj_t)&alarm_pin_pin_alarm_get_value_obj, + (mp_obj_t)&mp_const_none_obj, + (mp_obj_t)&mp_const_none_obj}, +}; + STATIC const mp_rom_map_elem_t alarm_pin_pin_alarm_locals_dict_table[] = { + { MP_ROM_QSTR(MP_QSTR_pins), MP_ROM_PTR(&alarm_pin_pin_alarm_pins_obj) }, + { MP_ROM_QSTR(MP_QSTR_value), MP_ROM_PTR(&alarm_pin_pin_alarm_value_obj) }, }; STATIC MP_DEFINE_CONST_DICT(alarm_pin_pin_alarm_locals_dict, alarm_pin_pin_alarm_locals_dict_table); diff --git a/shared-bindings/alarm/pin/PinAlarm.h b/shared-bindings/alarm/pin/PinAlarm.h index bbf3018b5d..cb69468124 100644 --- a/shared-bindings/alarm/pin/PinAlarm.h +++ b/shared-bindings/alarm/pin/PinAlarm.h @@ -35,8 +35,8 @@ extern const mp_obj_type_t alarm_pin_pin_alarm_type; void common_hal_alarm_pin_pin_alarm_construct(alarm_pin_pin_alarm_obj_t *self, const mp_obj_t pins[], size_t num_pins, bool value, bool all_same_value, bool edge, bool pull); -extern const mp_obj_tuple_t *common_hal_alarm_pin_pin_alarm_get_pins(alarm_pin_pin_alarm_obj_t *self); -extern bool common_hal_alarm_pin_pin_alarm_get_level(alarm_pin_pin_alarm_obj_t *self); +extern mp_obj_tuple_t *common_hal_alarm_pin_pin_alarm_get_pins(alarm_pin_pin_alarm_obj_t *self); +extern bool common_hal_alarm_pin_pin_alarm_get_value(alarm_pin_pin_alarm_obj_t *self); extern bool common_hal_alarm_pin_pin_alarm_get_edge(alarm_pin_pin_alarm_obj_t *self); extern bool common_hal_alarm_pin_pin_alarm_get_pull(alarm_pin_pin_alarm_obj_t *self); diff --git a/shared-bindings/alarm/time/DurationAlarm.c b/shared-bindings/alarm/time/DurationAlarm.c deleted file mode 100644 index 6831aba5db..0000000000 --- a/shared-bindings/alarm/time/DurationAlarm.c +++ /dev/null @@ -1,91 +0,0 @@ -/* - * 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 "shared-bindings/board/__init__.h" -#include "shared-bindings/microcontroller/__init__.h" -#include "shared-bindings/alarm/time/DurationAlarm.h" - -#include "py/nlr.h" -#include "py/obj.h" -#include "py/runtime.h" -#include "supervisor/shared/translate.h" - -//| class DurationAlarm: -//| """Trigger an alarm at a specified interval from now.""" -//| -//| def __init__(self, secs: float) -> None: -//| """Create an alarm that will be triggered in ``secs`` seconds from the time -//| sleep starts. The alarm is not active until it is listed in an -//| `alarm`-enabling function, such as `alarm.sleep_until_alarms()` or -//| `alarm.set_deep_sleep_alarms()`. -//| """ -//| ... -//| -STATIC mp_obj_t alarm_time_duration_alarm_make_new(const mp_obj_type_t *type, - mp_uint_t n_args, const mp_obj_t *args, mp_map_t *kw_args) { - mp_arg_check_num(n_args, kw_args, 1, 1, false); - - alarm_time_duration_alarm_obj_t *self = m_new_obj(alarm_time_duration_alarm_obj_t); - self->base.type = &alarm_time_duration_alarm_type; - - mp_float_t secs = mp_obj_get_float(args[0]); - - common_hal_alarm_time_duration_alarm_construct(self, secs); - - return MP_OBJ_FROM_PTR(self); -} - -//| def __eq__(self, other: object) -> bool: -//| """Two DurationAlarm objects are equal if their durations differ by less than a millisecond.""" -//| ... -//| -STATIC mp_obj_t alarm_time_duration_alarm_binary_op(mp_binary_op_t op, mp_obj_t lhs_in, mp_obj_t rhs_in) { - switch (op) { - case MP_BINARY_OP_EQUAL: - if (MP_OBJ_IS_TYPE(rhs_in, &alarm_time_duration_alarm_type)) { - return mp_obj_new_bool( - abs(common_hal_alarm_time_duration_alarm_get_duration(lhs_in) - - common_hal_alarm_time_duration_alarm_get_duration(rhs_in)) < 0.001f); - } - return mp_const_false; - - default: - return MP_OBJ_NULL; // op not supported - } -} - -STATIC const mp_rom_map_elem_t alarm_time_duration_alarm_locals_dict_table[] = { -}; - -STATIC MP_DEFINE_CONST_DICT(alarm_time_duration_alarm_locals_dict, alarm_time_duration_alarm_locals_dict_table); - -const mp_obj_type_t alarm_time_duration_alarm_type = { - { &mp_type_type }, - .name = MP_QSTR_DurationAlarm, - .make_new = alarm_time_duration_alarm_make_new, - .binary_op = alarm_time_duration_alarm_binary_op, - .locals_dict = (mp_obj_t)&alarm_time_duration_alarm_locals_dict, -}; diff --git a/shared-bindings/alarm/time/MonotonicTimeAlarm.c b/shared-bindings/alarm/time/MonotonicTimeAlarm.c new file mode 100644 index 0000000000..6ee411e883 --- /dev/null +++ b/shared-bindings/alarm/time/MonotonicTimeAlarm.c @@ -0,0 +1,93 @@ +/* + * 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 "shared-bindings/board/__init__.h" +#include "shared-bindings/microcontroller/__init__.h" +#include "shared-bindings/alarm/time/MonotonicTimeAlarm.h" + +#include "py/nlr.h" +#include "py/obj.h" +#include "py/objproperty.h" +#include "py/runtime.h" +#include "supervisor/shared/translate.h" + +//| class MonotonicTimeAlarm: +//| """Trigger an alarm when `time.monotonic()` reaches the given value.""" +//| +//| def __init__(self, monotonic_time: float) -> None: +//| """Create an alarm that will be triggered when `time.monotonic()` would equal +//| ``monotonic_time``. +//| The alarm is not active until it is passed to an +//| `alarm`-enabling function, such as `alarm.sleep_until_alarms()` or +//| `alarm.set_deep_sleep_alarms()`. +//| +//| If the given time is in the past when sleep occurs, the alarm will be triggered +//| immediately. +//| """ +//| ... +//| +STATIC mp_obj_t alarm_time_monotonic_time_alarm_make_new(const mp_obj_type_t *type, + mp_uint_t n_args, const mp_obj_t *args, mp_map_t *kw_args) { + mp_arg_check_num(n_args, kw_args, 1, 1, false); + + alarm_time_monotonic_time_alarm_obj_t *self = m_new_obj(alarm_time_monotonic_time_alarm_obj_t); + self->base.type = &alarm_time_monotonic_time_alarm_type; + + mp_float_t secs = mp_obj_get_float(args[0]); + + common_hal_alarm_time_monotonic_time_alarm_construct(self, secs); + + return MP_OBJ_FROM_PTR(self); +} + +//| monotonic_time: float +//| """The time at which to trigger, based on the `time.monotonic()` clock.""" +//| +STATIC mp_obj_t alarm_time_monotonic_time_alarm_obj_get_monotonic_time(mp_obj_t self_in) { + alarm_time_monotonic_time_alarm_obj_t *self = MP_OBJ_TO_PTR(self_in); + return mp_obj_new_float(common_hal_alarm_time_monotonic_time_alarm_get_monotonic_time(self)); +} +MP_DEFINE_CONST_FUN_OBJ_1(alarm_time_monotonic_time_alarm_get_monotonic_time_obj, alarm_time_monotonic_time_alarm_obj_get_monotonic_time); + +const mp_obj_property_t alarm_time_monotonic_time_alarm_monotonic_time_obj = { + .base.type = &mp_type_property, + .proxy = {(mp_obj_t)&alarm_time_monotonic_time_alarm_get_monotonic_time_obj, + (mp_obj_t)&mp_const_none_obj, + (mp_obj_t)&mp_const_none_obj}, +}; + +STATIC const mp_rom_map_elem_t alarm_time_monotonic_time_alarm_locals_dict_table[] = { + { MP_ROM_QSTR(MP_QSTR_monotonic_time), MP_ROM_PTR(&alarm_time_monotonic_time_alarm_monotonic_time_obj) }, +}; + +STATIC MP_DEFINE_CONST_DICT(alarm_time_monotonic_time_alarm_locals_dict, alarm_time_monotonic_time_alarm_locals_dict_table); + +const mp_obj_type_t alarm_time_monotonic_time_alarm_type = { + { &mp_type_type }, + .name = MP_QSTR_TimeAlarm, + .make_new = alarm_time_monotonic_time_alarm_make_new, + .locals_dict = (mp_obj_t)&alarm_time_monotonic_time_alarm_locals_dict, +}; diff --git a/shared-bindings/alarm/time/DurationAlarm.h b/shared-bindings/alarm/time/MonotonicTimeAlarm.h similarity index 63% rename from shared-bindings/alarm/time/DurationAlarm.h rename to shared-bindings/alarm/time/MonotonicTimeAlarm.h index 87f5d9390c..6eb2738ab5 100644 --- a/shared-bindings/alarm/time/DurationAlarm.h +++ b/shared-bindings/alarm/time/MonotonicTimeAlarm.h @@ -24,19 +24,16 @@ * THE SOFTWARE. */ -#ifndef MICROPY_INCLUDED_SHARED_BINDINGS_ALARM_TIME_DURATION_ALARM_H -#define MICROPY_INCLUDED_SHARED_BINDINGS_ALARM_TIME_DURATION_ALARM_H +#ifndef MICROPY_INCLUDED_SHARED_BINDINGS_ALARM_TIME_MONOTONIC_TIME_ALARM_H +#define MICROPY_INCLUDED_SHARED_BINDINGS_ALARM_TIME_MONOTINIC_TIME_ALARM_H #include "py/obj.h" -#include "common-hal/alarm/time/DurationAlarm.h" +#include "common-hal/alarm/time/MonotonicTimeAlarm.h" -extern const mp_obj_type_t alarm_time_duration_alarm_type; +extern const mp_obj_type_t alarm_time_monotonic_time_alarm_type; -extern void common_hal_alarm_time_duration_alarm_construct(alarm_time_duration_alarm_obj_t *self, mp_float_t duration); -extern mp_float_t common_hal_alarm_time_duration_alarm_get_duration(alarm_time_duration_alarm_obj_t *self); +extern void common_hal_alarm_time_monotonic_time_alarm_construct(alarm_time_monotonic_time_alarm_obj_t *self, mp_float_t monotonic_time); +extern mp_float_t common_hal_alarm_time_monotonic_time_alarm_get_monotonic_time(alarm_time_monotonic_time_alarm_obj_t *self); -extern void common_hal_alarm_time_duration_alarm_enable(alarm_time_duration_alarm_obj_t *self); -extern void common_hal_alarm_time_duration_alarm_disable (alarm_time_duration_alarm_obj_t *self); - -#endif // MICROPY_INCLUDED_SHARED_BINDINGS_ALARM_TIME_DURATION_ALARM_H +#endif // MICROPY_INCLUDED_SHARED_BINDINGS_ALARM_TIME_MONOTONIC_TIME_ALARM_H diff --git a/shared-bindings/time/__init__.c b/shared-bindings/time/__init__.c index 44f82c62e7..804d5ecd89 100644 --- a/shared-bindings/time/__init__.c +++ b/shared-bindings/time/__init__.c @@ -51,9 +51,9 @@ //| ... //| STATIC mp_obj_t time_monotonic(void) { + // Returns ms ticks. uint64_t time64 = common_hal_time_monotonic(); - // 4294967296 = 2^32 - return mp_obj_new_float(((uint32_t) (time64 >> 32) * 4294967296.0f + (uint32_t) (time64 & 0xffffffff)) / 1000.0f); + return mp_obj_new_float(uint64_to_float(time64) / 1000.0f); } MP_DEFINE_CONST_FUN_OBJ_0(time_monotonic_obj, time_monotonic); From 715b09bff29fd10c5d0de87ed3ae98a0a78df62d Mon Sep 17 00:00:00 2001 From: Daniel Bravo Darriba Date: Thu, 26 Nov 2020 00:00:11 +0000 Subject: [PATCH 150/207] Translated using Weblate (German) Currently translated at 85.8% (742 of 864 strings) Translation: CircuitPython/main Translate-URL: https://hosted.weblate.org/projects/circuitpython/main/de/ --- locale/de_DE.po | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/locale/de_DE.po b/locale/de_DE.po index 3b6bc8e217..56bf286701 100644 --- a/locale/de_DE.po +++ b/locale/de_DE.po @@ -6,14 +6,14 @@ msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2020-11-11 16:30+0530\n" -"PO-Revision-Date: 2020-06-16 18:24+0000\n" -"Last-Translator: Andreas Buchen \n" +"PO-Revision-Date: 2020-11-26 03:11+0000\n" +"Last-Translator: Daniel Bravo Darriba \n" "Language: de_DE\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=2; plural=n != 1;\n" -"X-Generator: Weblate 4.1.1-dev\n" +"X-Generator: Weblate 4.4-dev\n" #: main.c msgid "" @@ -57,7 +57,7 @@ msgstr "%d Adress-Pins und %d rgb-Pins zeigen eine Höhe von %d, nicht von %d" #: ports/atmel-samd/common-hal/sdioio/SDCard.c msgid "%q failure: %d" -msgstr "" +msgstr "%q Fehler: %d" #: shared-bindings/microcontroller/Pin.c msgid "%q in use" From cb14a2a82477c771e0349fc155e4281bde7300aa Mon Sep 17 00:00:00 2001 From: Daniel Bravo Darriba Date: Wed, 25 Nov 2020 23:50:39 +0000 Subject: [PATCH 151/207] Translated using Weblate (Spanish) Currently translated at 100.0% (864 of 864 strings) Translation: CircuitPython/main Translate-URL: https://hosted.weblate.org/projects/circuitpython/main/es/ --- locale/es.po | 147 ++++++++++++++++++++++++++------------------------- 1 file changed, 74 insertions(+), 73 deletions(-) diff --git a/locale/es.po b/locale/es.po index b0314ae198..db3a630c84 100644 --- a/locale/es.po +++ b/locale/es.po @@ -8,8 +8,8 @@ msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2020-11-11 16:30+0530\n" -"PO-Revision-Date: 2020-11-15 16:28+0000\n" -"Last-Translator: RubenD \n" +"PO-Revision-Date: 2020-11-26 03:11+0000\n" +"Last-Translator: Daniel Bravo Darriba \n" "Language-Team: \n" "Language: es\n" "MIME-Version: 1.0\n" @@ -437,7 +437,7 @@ msgstr "El periférico no maneja el Baudrate" #: shared-module/displayio/Display.c #: shared-module/framebufferio/FramebufferDisplay.c msgid "Below minimum frame rate" -msgstr "Por debajo de taza mínima de refrescamiento" +msgstr "Por debajo de la tasa mínima de refrescamiento" #: ports/atmel-samd/common-hal/audiobusio/I2SOut.c msgid "Bit clock and word select must share a clock unit" @@ -498,7 +498,7 @@ msgstr "El buffer es muy pequeño" #: ports/nrf/common-hal/audiopwmio/PWMAudioOut.c #, c-format msgid "Buffer length %d too big. It must be less than %d" -msgstr "La longitud del buffer %d es muy grande. Debe ser menor a %d" +msgstr "Longitud del buffer %d es demasiado grande. Tiene que ser menor a %d" #: ports/atmel-samd/common-hal/sdioio/SDCard.c #: ports/cxd56/common-hal/sdioio/SDCard.c shared-module/sdcardio/SDCard.c @@ -520,7 +520,7 @@ msgstr "Buffer demasiado grande e incapaz de asignar" #: shared-bindings/_bleio/PacketBuffer.c #, c-format msgid "Buffer too short by %d bytes" -msgstr "Búfer muy corto por %d bytes" +msgstr "Búffer muy corto por %d bytes" #: ports/atmel-samd/common-hal/displayio/ParallelBus.c #: ports/nrf/common-hal/displayio/ParallelBus.c @@ -729,7 +729,7 @@ msgstr "No se puede definir la dirección" #: ports/stm/common-hal/pwmio/PWMOut.c msgid "Could not start PWM" -msgstr "No se pudo iniciar el PWM" +msgstr "No se pudo iniciar PWM" #: ports/stm/common-hal/busio/UART.c msgid "Could not start interrupt, RX busy" @@ -746,7 +746,7 @@ msgstr "No se pudo asignar el primer buffer" #: shared-module/audiomp3/MP3Decoder.c msgid "Couldn't allocate input buffer" -msgstr "No se pudo encontrar el búfer de entrada" +msgstr "No se pudo encontrar el buffer de entrada" #: shared-module/audiocore/WaveFile.c shared-module/audiomixer/Mixer.c #: shared-module/audiomp3/MP3Decoder.c @@ -876,7 +876,7 @@ msgstr "FFT se define solo para ndarrays" #: extmod/ulab/code/fft/fft.c msgid "FFT is implemented for linear arrays only" -msgstr "" +msgstr "FFT solo esta implementado para arrays lineales" #: ports/esp32s2/common-hal/socketpool/Socket.c msgid "Failed SSL handshake" @@ -936,7 +936,7 @@ msgstr "No se puede liberar el mutex, err 0x%04x" #: supervisor/shared/safe_mode.c msgid "Failed to write internal flash." -msgstr "Error al escribir al flash interno." +msgstr "Error al escribir el flash interno." #: py/moduerrno.c msgid "File exists" @@ -975,7 +975,7 @@ msgstr "La función requiere lock" #: shared-bindings/displayio/EPaperDisplay.c #: shared-bindings/framebufferio/FramebufferDisplay.c msgid "Group already used" -msgstr "El grupo ya está siendo utilizado" +msgstr "Grupo ya está siendo utilizado" #: shared-module/displayio/Group.c msgid "Group full" @@ -1001,7 +1001,7 @@ msgstr "Operación I/O en archivo cerrado" #: ports/stm/common-hal/busio/I2C.c msgid "I2C Init Error" -msgstr "Error de inicio de I2C" +msgstr "I2C Error de inicio" #: shared-bindings/audiobusio/I2SOut.c msgid "I2SOut not available" @@ -1026,7 +1026,7 @@ msgstr "Tamaño incorrecto del buffer" #: ports/esp32s2/common-hal/watchdog/WatchDogTimer.c msgid "Initialization failed due to lack of memory" -msgstr "" +msgstr "Inicializacion fallida por falta de memoria" #: ports/atmel-samd/common-hal/pulseio/PulseIn.c msgid "Input taking too long" @@ -1286,7 +1286,7 @@ msgstr "Debe usar un múltiplo de 6 pines rgb, no %d" #: ports/esp32s2/common-hal/nvm/ByteArray.c msgid "NVS Error" -msgstr "" +msgstr "Error NVS" #: py/parse.c msgid "Name too long" @@ -1401,7 +1401,7 @@ msgstr "No hay temporizador disponible" #: supervisor/shared/safe_mode.c msgid "Nordic Soft Device failure assertion." -msgstr "fallo de aserción de dispositivo Nordic Soft." +msgstr "Fallo de aserción de dispositivo Nordic Soft." #: shared-bindings/ipaddress/IPv4Address.c shared-bindings/ipaddress/__init__.c msgid "Not a valid IP string" @@ -1497,7 +1497,7 @@ msgstr "" #: ports/mimxrt10xx/common-hal/displayio/ParallelBus.c #: ports/stm/common-hal/displayio/ParallelBus.c msgid "ParallelBus not yet supported" -msgstr "ParallelBus no soportado aún" +msgstr "ParallelBus todavía no soportado" #: py/moduerrno.c msgid "Permission denied" @@ -1531,8 +1531,9 @@ msgid "" "bytes. If this cannot be avoided, pass allow_inefficient=True to the " "constructor" msgstr "" -"El pinout utiliza %d bytes por elemento, lo que consume más del ideal de %d " -"bytes. Si esto no se puede evitar, pase allow_inefficient=True al constructor" +"El pinout utiliza %d bytes por elemento, lo que consume más de los %d bytes " +"ideales. Si esto no se puede evitar, pase allow_inefficient=True al " +"constructor" #: py/builtinhelp.c msgid "Plus any modules on the filesystem\n" @@ -1563,7 +1564,7 @@ msgstr "" #: shared-bindings/_bleio/Adapter.c msgid "Prefix buffer must be on the heap" -msgstr "El búfer de prefijo debe estar en el montículo" +msgstr "El prefijo del buffer debe estar en el heap" #: main.c msgid "Press any key to enter the REPL. Use CTRL-D to reload." @@ -1576,7 +1577,7 @@ msgstr "Pull no se usa cuando la dirección es output." #: ports/stm/common-hal/os/__init__.c msgid "RNG DeInit Error" -msgstr "Error de desinicializado del RNG" +msgstr "Error de desinicialización de RNG" #: ports/stm/common-hal/os/__init__.c msgid "RNG Init Error" @@ -1585,7 +1586,7 @@ msgstr "Error de inicialización de RNG" #: ports/esp32s2/common-hal/busio/UART.c #: ports/mimxrt10xx/common-hal/busio/UART.c msgid "RS485 inversion specified when not in RS485 mode" -msgstr "Se especifica inversión de RS485 sin estar en modo RS485" +msgstr "Se especifica inversión de RS485 si no está en modo RS485" #: ports/cxd56/common-hal/rtc/RTC.c ports/esp32s2/common-hal/rtc/RTC.c #: ports/mimxrt10xx/common-hal/rtc/RTC.c ports/nrf/common-hal/rtc/RTC.c @@ -1620,7 +1621,7 @@ msgstr "Objeto de solo-lectura" #: shared-bindings/displayio/EPaperDisplay.c msgid "Refresh too soon" -msgstr "Actualizando demasiado pronto" +msgstr "Refresco demasiado pronto" #: shared-bindings/canio/RemoteTransmissionRequest.c msgid "RemoteTransmissionRequests limited to 8 bytes" @@ -1680,7 +1681,7 @@ msgstr "Frecuencia de muestreo demasiado alta. Debe ser menor a %d" #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Scan already in progess. Stop with stop_scan." -msgstr "Escaneo en progreso. Use stop_scan para detener." +msgstr "Escaneo en progreso. Usa stop_scan para detener." #: ports/mimxrt10xx/common-hal/busio/UART.c msgid "Selected CTS pin not valid" @@ -1720,7 +1721,7 @@ msgstr "SocketPool solo se puede usar con wifi.radio" #: shared-bindings/aesio/aes.c msgid "Source and destination buffers must be the same length" -msgstr "Los búferes de fuente y destino deben ser del mismo tamaño" +msgstr "Los buffers de fuente y destino deben ser del mismo tamaño" #: extmod/modure.c msgid "Splitting with sub-captures" @@ -1751,7 +1752,7 @@ 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 "" -"El montículo de CircuitPython se dañó porque la pila era demasiado pequeña.\n" +"El heap de CircuitPython se dañó porque la pila era demasiado pequeña.\n" "Aumente el tamaño de la pila si sabe cómo, o si no:" #: supervisor/shared/safe_mode.c @@ -1759,8 +1760,8 @@ msgid "" "The `microcontroller` module was used to boot into safe mode. Press reset to " "exit safe mode.\n" msgstr "" -"El módulo de `microcontroller` fue utilizado para bootear en modo seguro. " -"Presione reset para salir del modo seguro.\n" +"El módulo de `microcontroller` fue utilizado para arrancar en modo seguro. " +"Presiona reset para salir del modo seguro.\n" #: shared-bindings/rgbmatrix/RGBMatrix.c msgid "The length of rgb_pins must be 6, 12, 18, 24, or 30" @@ -1772,10 +1773,10 @@ msgid "" "enough power for the whole circuit and press reset (after ejecting " "CIRCUITPY).\n" msgstr "" -"La alimentación de la microntroladora bajó. Asegúrate que tu fuente de " -"poder\n" -"pueda suplir suficiente energía para todo el circuito y presione reset " -"(luego de\n" +"La alimentación del microntrolador cayó. Asegúrate que tu fuente de " +"alimentación\n" +"pueda aportar suficiente energía para todo el circuito y presiona reset (" +"luego de\n" "expulsar CIRCUITPY)\n" #: shared-module/audiomixer/MixerVoice.c @@ -1954,7 +1955,7 @@ msgstr "Error de seguridad desconocido: 0x%04x" #: ports/nrf/common-hal/_bleio/__init__.c #, c-format msgid "Unknown soft device error: %04x" -msgstr "Error suave desconocido en dispositivo: %04x" +msgstr "Error leve desconocido en dispositivo: %04x" #: shared-bindings/_pixelbuf/PixelBuf.c #, c-format @@ -1967,7 +1968,7 @@ msgid "" "declined or ignored." msgstr "" "Problema no especificado. Puede ser que la señal de emparejamiento del otro " -"dispositivo fue declinada o ignorada." +"dispositivo fue denegada o ignorada." #: ports/atmel-samd/common-hal/busio/I2C.c ports/cxd56/common-hal/busio/I2C.c #: ports/esp32s2/common-hal/busio/UART.c ports/stm/common-hal/busio/I2C.c @@ -2057,7 +2058,7 @@ msgstr "La clave de WiFi debe ser entre 8 y 63 caracteres" #: ports/nrf/common-hal/_bleio/PacketBuffer.c msgid "Writes not supported on Characteristic" -msgstr "Escrituras no admitidas en la característica" +msgstr "Escrituras no admitidas en Characteristic" #: supervisor/shared/safe_mode.c msgid "You are in safe mode: something unanticipated happened.\n" @@ -2110,7 +2111,7 @@ msgstr "El argumento para argsort debe ser un ndarray" #: extmod/ulab/code/numerical/numerical.c msgid "argsort is not implemented for flattened arrays" -msgstr "" +msgstr "El argot no está implementado para arrays aplanados" #: py/runtime.c msgid "argument has wrong type" @@ -2135,7 +2136,7 @@ msgstr "argumentos deben ser ndarrays" #: extmod/ulab/code/ndarray.c msgid "array and index length must be equal" -msgstr "" +msgstr "Longitud del array e índice tienen que ser iguales" #: py/objarray.c shared-bindings/nvm/ByteArray.c msgid "array/bytes required on right side" @@ -2143,11 +2144,11 @@ msgstr "array/bytes requeridos en el lado derecho" #: extmod/ulab/code/numerical/numerical.c msgid "attempt to get (arg)min/(arg)max of empty sequence" -msgstr "" +msgstr "Intendo de obteber (arg)min/(arg)max de secuencia vacía" #: extmod/ulab/code/numerical/numerical.c msgid "attempt to get argmin/argmax of an empty sequence" -msgstr "se trató de traer argmin/argmax de una secuencia vacía" +msgstr "intento de obtener argmin/argmax de una secuencia vacía" #: py/objstr.c msgid "attributes not supported yet" @@ -2155,15 +2156,15 @@ msgstr "atributos aún no soportados" #: extmod/ulab/code/numerical/numerical.c msgid "axis is out of bounds" -msgstr "" +msgstr "Eje está fuera de sus límites" #: extmod/ulab/code/numerical/numerical.c msgid "axis must be None, or an integer" -msgstr "" +msgstr "Eje tiene que ser None, o un entero" #: extmod/ulab/code/numerical/numerical.c msgid "axis too long" -msgstr "" +msgstr "Eje demasiado largo" #: py/builtinevex.c msgid "bad compile mode" @@ -2373,7 +2374,7 @@ msgstr "" #: extmod/ulab/code/ndarray_operators.c msgid "cannot cast output with casting rule" -msgstr "" +msgstr "No se puede realizar cast de la salida sin una regla de cast" #: py/objtype.c msgid "cannot create '%q' instances" @@ -2409,7 +2410,7 @@ msgstr "El argumento de chr() no esta en el rango(256)" #: shared-module/vectorio/Circle.c msgid "circle can only be registered in one parent" -msgstr "circle solo puede ser registrado con un pariente" +msgstr "circulo solo puede ser registrado con un pariente" #: shared-bindings/displayio/Palette.c msgid "color buffer must be 3 bytes (RGB) or 4 bytes (RGB + pad byte)" @@ -2473,7 +2474,7 @@ msgstr "no se pudo determinar la versión de la tarjeta SD" #: extmod/ulab/code/numerical/numerical.c msgid "cross is defined for 1D arrays of length 3" -msgstr "" +msgstr "Cruce está definido para un array 1D de longitud 3" #: extmod/ulab/code/approx/approx.c msgid "data must be iterable" @@ -2516,7 +2517,7 @@ msgstr "El argumento diff debe ser un ndarray" #: extmod/ulab/code/numerical/numerical.c msgid "differentiation order out of range" -msgstr "" +msgstr "Orden de diferenciación fuera de rango" #: py/modmath.c py/objfloat.c py/objint_longlong.c py/objint_mpz.c py/runtime.c #: shared-bindings/math/__init__.c @@ -2635,11 +2636,11 @@ msgstr "el primer argumento debe ser una función" #: extmod/ulab/code/ulab_create.c msgid "first argument must be a tuple of ndarrays" -msgstr "" +msgstr "Primer argumento tiene que ser una tupla de ndarrays" #: extmod/ulab/code/ndarray.c msgid "first argument must be an iterable" -msgstr "el primer argumento debe permitir iteración" +msgstr "el primer argumento debe ser un iterable" #: extmod/ulab/code/vector/vectorise.c msgid "first argument must be an ndarray" @@ -2659,7 +2660,7 @@ msgstr "el argumento invertido debe ser un ndarray" #: py/objint.c msgid "float too big" -msgstr "punto flotante muy grande" +msgstr "punto flotante demasiado grande" #: shared-bindings/_stage/Text.c msgid "font must be 2048 bytes long" @@ -2692,7 +2693,7 @@ msgstr "la función tiene el mismo signo a extremos del intervalo" #: extmod/ulab/code/ndarray.c msgid "function is defined for ndarrays only" -msgstr "" +msgstr "Función solo definida para ndarrays" #: py/argcheck.c #, c-format @@ -2788,7 +2789,7 @@ msgstr "ensamblador en línea debe ser una función" #: extmod/ulab/code/ndarray.c msgid "input and output shapes are not compatible" -msgstr "" +msgstr "Formas de entrada y salida no son compactibles" #: extmod/ulab/code/ulab_create.c msgid "input argument must be an integer or a 2-tuple" @@ -2800,11 +2801,11 @@ msgstr "el tamaño del arreglo de entrada debe ser potencia de 2" #: extmod/ulab/code/ulab_create.c msgid "input arrays are not compatible" -msgstr "" +msgstr "Arrays de entrada no son compactibles" #: extmod/ulab/code/poly/poly.c msgid "input data must be an iterable" -msgstr "los datos de entrada deben permitir iteración" +msgstr "los datos de entrada deben ser iterables" #: extmod/ulab/code/linalg/linalg.c msgid "input matrix is asymmetric" @@ -2816,19 +2817,19 @@ msgstr "la matriz de entrada es singular" #: extmod/ulab/code/user/user.c msgid "input must be a dense ndarray" -msgstr "" +msgstr "Entrada tiene que ser un ndarray denso" #: extmod/ulab/code/ulab_create.c msgid "input must be a tensor of rank 2" -msgstr "" +msgstr "Entrada tiene que ser un tensor de rango 2" #: extmod/ulab/code/ulab_create.c extmod/ulab/code/user/user.c msgid "input must be an ndarray" -msgstr "" +msgstr "Entrada tiene que ser un ndarray" #: extmod/ulab/code/filter/filter.c msgid "input must be one-dimensional" -msgstr "" +msgstr "Entrada tiene que ser unidimensional" #: extmod/ulab/code/linalg/linalg.c msgid "input must be square matrix" @@ -2844,7 +2845,7 @@ msgstr "los vectores de entrada deben ser de igual tamaño" #: extmod/ulab/code/poly/poly.c msgid "inputs are not iterable" -msgstr "" +msgstr "Entradas no son iterables" #: py/parsenum.c msgid "int() arg 2 must be >= 2 and <= 36" @@ -2985,7 +2986,7 @@ msgstr "long int no soportado en esta compilación" #: ports/esp32s2/common-hal/canio/CAN.c msgid "loopback + silent mode not supported by peripheral" -msgstr "" +msgstr "Loopback + modo silencioso no están soportados por periférico" #: py/parse.c msgid "malformed f-string" @@ -3019,7 +3020,7 @@ msgstr "max_lenght debe ser > 0" #: extmod/ulab/code/ndarray.c msgid "maximum number of dimensions is 4" -msgstr "" +msgstr "Máximo número de dimensiones es 4" #: py/runtime.c msgid "maximum recursion depth exceeded" @@ -3027,11 +3028,11 @@ msgstr "profundidad máxima de recursión excedida" #: extmod/ulab/code/approx/approx.c msgid "maxiter must be > 0" -msgstr "" +msgstr "maxiter tiene que ser > 0" #: extmod/ulab/code/approx/approx.c msgid "maxiter should be > 0" -msgstr "" +msgstr "maxiter debe ser > 0" #: py/runtime.c #, c-format @@ -3156,7 +3157,7 @@ msgstr "" #: extmod/ulab/code/linalg/linalg.c msgid "norm is defined for 1D and 2D arrays" -msgstr "" +msgstr "norma está definida para arrays 1D y 2D" #: shared-bindings/_bleio/UUID.c msgid "not a 128-bit UUID" @@ -3225,7 +3226,7 @@ msgstr "string de longitud impar" #: extmod/ulab/code/ulab_create.c msgid "offset is too large" -msgstr "" +msgstr "offset es demasiado grande" #: py/objstr.c py/objstrunicode.c msgid "offset out of bounds" @@ -3251,11 +3252,11 @@ msgstr "los operandos no se pueden transmitir juntos" #: extmod/ulab/code/ndarray.c msgid "operation is implemented for 1D Boolean arrays only" -msgstr "" +msgstr "operación solo está implementada para arrays booleanos de 1D" #: extmod/ulab/code/numerical/numerical.c msgid "operation is not implemented for flattened array" -msgstr "" +msgstr "operación no está implementada para arrays aplanados" #: extmod/ulab/code/numerical/numerical.c msgid "operation is not implemented on ndarrays" @@ -3393,7 +3394,7 @@ msgstr "longitud solicitada %d pero el objeto tiene longitud %d" #: extmod/ulab/code/ndarray_operators.c msgid "results cannot be cast to specified type" -msgstr "" +msgstr "resultados no pueden aplicar cast a un tipo específico" #: py/compile.c msgid "return annotation must be an identifier" @@ -3415,7 +3416,7 @@ msgstr "rgb_pins[%d] no está en el mismo puerto que el reloj" #: extmod/ulab/code/numerical/numerical.c msgid "roll argument must be an ndarray" -msgstr "" +msgstr "Argumento enrolado tiene que ser un ndarray" #: py/objstr.c msgid "rsplit(None,n)" @@ -3443,7 +3444,7 @@ msgstr "script de compilación no soportado" #: extmod/ulab/code/ndarray.c msgid "shape must be a tuple" -msgstr "" +msgstr "forma tiene que ser una tupla" #: py/objstr.c msgid "sign not allowed in string format specifier" @@ -3593,7 +3594,7 @@ msgstr "timestamp fuera de rango para plataform time_t" #: extmod/ulab/code/ndarray.c msgid "tobytes can be invoked for dense arrays only" -msgstr "" +msgstr "tobytes solo pueden ser invocados por arrays densos" #: shared-module/struct/__init__.c msgid "too many arguments provided with the given format" @@ -3623,12 +3624,12 @@ msgstr "tupla/lista tiene una longitud incorrecta" #: ports/esp32s2/common-hal/canio/CAN.c #, c-format msgid "twai_driver_install returned esp-idf error #%d" -msgstr "" +msgstr "twai_driver_install devolvió esp-idf error #%d" #: ports/esp32s2/common-hal/canio/CAN.c #, c-format msgid "twai_start returned esp-idf error #%d" -msgstr "" +msgstr "twai_start devolvió esp-idf error #%d" #: ports/atmel-samd/common-hal/busio/UART.c #: ports/esp32s2/common-hal/busio/UART.c ports/nrf/common-hal/busio/UART.c @@ -3756,7 +3757,7 @@ msgstr "los vectores deben tener el mismo tamaño" #: ports/esp32s2/common-hal/watchdog/WatchDogTimer.c msgid "watchdog not initialized" -msgstr "" +msgstr "watchdog no inicializado" #: shared-bindings/watchdog/WatchDogTimer.c msgid "watchdog timeout must be greater than 0" @@ -3772,11 +3773,11 @@ msgstr "la ventana debe ser <= intervalo" #: extmod/ulab/code/numerical/numerical.c msgid "wrong axis index" -msgstr "" +msgstr "indice de eje erróneo" #: extmod/ulab/code/ulab_create.c msgid "wrong axis specified" -msgstr "" +msgstr "eje especificado erróneo" #: extmod/ulab/code/vector/vectorise.c msgid "wrong input type" From 9c779c7ab79212c19e5533f8d096242fe282e980 Mon Sep 17 00:00:00 2001 From: Hosted Weblate Date: Thu, 26 Nov 2020 04:11:29 +0100 Subject: [PATCH 152/207] Update translation files Updated by "Update PO files to match POT (msgmerge)" hook in Weblate. Translation: CircuitPython/main Translate-URL: https://hosted.weblate.org/projects/circuitpython/main/ --- locale/ID.po | 13 ++++++++----- locale/cs.po | 13 ++++++++----- locale/de_DE.po | 13 ++++++++----- locale/el.po | 13 ++++++++----- locale/es.po | 20 +++++++++++++------- locale/fil.po | 13 ++++++++----- locale/fr.po | 16 +++++++++++----- locale/hi.po | 13 ++++++++----- locale/it_IT.po | 13 ++++++++----- locale/ja.po | 13 ++++++++----- locale/ko.po | 13 ++++++++----- locale/nl.po | 16 +++++++++++----- locale/pl.po | 13 ++++++++----- locale/pt_BR.po | 16 +++++++++++----- locale/sv.po | 16 +++++++++++----- locale/zh_Latn_pinyin.po | 16 +++++++++++----- 16 files changed, 148 insertions(+), 82 deletions(-) diff --git a/locale/ID.po b/locale/ID.po index cf23970d88..6073b6a462 100644 --- a/locale/ID.po +++ b/locale/ID.po @@ -5,7 +5,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-11-11 16:30+0530\n" +"POT-Creation-Date: 2020-11-24 15:40-0500\n" "PO-Revision-Date: 2020-10-10 23:51+0000\n" "Last-Translator: oon arfiandwi \n" "Language-Team: LANGUAGE \n" @@ -301,6 +301,7 @@ msgid "All I2C peripherals are in use" msgstr "Semua perangkat I2C sedang digunakan" #: ports/esp32s2/common-hal/countio/Counter.c +#: ports/esp32s2/common-hal/frequencyio/FrequencyIn.c #: ports/esp32s2/common-hal/rotaryio/IncrementalEncoder.c msgid "All PCNT units in use" msgstr "" @@ -337,6 +338,7 @@ msgstr "Semua timer untuk pin ini sedang digunakan" #: ports/atmel-samd/common-hal/pulseio/PulseIn.c #: ports/atmel-samd/common-hal/pulseio/PulseOut.c #: ports/cxd56/common-hal/pulseio/PulseOut.c +#: ports/esp32s2/common-hal/frequencyio/FrequencyIn.c #: ports/esp32s2/common-hal/neopixel_write/__init__.c #: ports/esp32s2/common-hal/pulseio/PulseIn.c #: ports/esp32s2/common-hal/pulseio/PulseOut.c @@ -1107,6 +1109,7 @@ msgid "Invalid byteorder string" msgstr "String byteorder tidak valid" #: ports/atmel-samd/common-hal/frequencyio/FrequencyIn.c +#: ports/esp32s2/common-hal/frequencyio/FrequencyIn.c msgid "Invalid capture period. Valid range: 1 - 500" msgstr "Periode penangkapan tidak valid. Kisaran yang valid: 1 - 500" @@ -1439,14 +1442,14 @@ msgstr "Parity ganjil tidak didukung" msgid "Only 8 or 16 bit mono with " msgstr "Hanya 8 atau 16 bit mono dengan " -#: ports/esp32s2/common-hal/socketpool/SocketPool.c -msgid "Only IPv4 SOCK_STREAM sockets supported" -msgstr "" - #: ports/esp32s2/common-hal/wifi/__init__.c msgid "Only IPv4 addresses supported" msgstr "" +#: ports/esp32s2/common-hal/socketpool/SocketPool.c +msgid "Only IPv4 sockets supported" +msgstr "" + #: shared-module/displayio/OnDiskBitmap.c #, c-format msgid "" diff --git a/locale/cs.po b/locale/cs.po index 3249792e70..a77a655a62 100644 --- a/locale/cs.po +++ b/locale/cs.po @@ -5,7 +5,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-11-11 16:30+0530\n" +"POT-Creation-Date: 2020-11-24 15:40-0500\n" "PO-Revision-Date: 2020-05-24 03:22+0000\n" "Last-Translator: dronecz \n" "Language-Team: LANGUAGE \n" @@ -301,6 +301,7 @@ msgid "All I2C peripherals are in use" msgstr "" #: ports/esp32s2/common-hal/countio/Counter.c +#: ports/esp32s2/common-hal/frequencyio/FrequencyIn.c #: ports/esp32s2/common-hal/rotaryio/IncrementalEncoder.c msgid "All PCNT units in use" msgstr "" @@ -337,6 +338,7 @@ msgstr "" #: ports/atmel-samd/common-hal/pulseio/PulseIn.c #: ports/atmel-samd/common-hal/pulseio/PulseOut.c #: ports/cxd56/common-hal/pulseio/PulseOut.c +#: ports/esp32s2/common-hal/frequencyio/FrequencyIn.c #: ports/esp32s2/common-hal/neopixel_write/__init__.c #: ports/esp32s2/common-hal/pulseio/PulseIn.c #: ports/esp32s2/common-hal/pulseio/PulseOut.c @@ -1090,6 +1092,7 @@ msgid "Invalid byteorder string" msgstr "" #: ports/atmel-samd/common-hal/frequencyio/FrequencyIn.c +#: ports/esp32s2/common-hal/frequencyio/FrequencyIn.c msgid "Invalid capture period. Valid range: 1 - 500" msgstr "" @@ -1420,14 +1423,14 @@ msgstr "" msgid "Only 8 or 16 bit mono with " msgstr "" -#: ports/esp32s2/common-hal/socketpool/SocketPool.c -msgid "Only IPv4 SOCK_STREAM sockets supported" -msgstr "" - #: ports/esp32s2/common-hal/wifi/__init__.c msgid "Only IPv4 addresses supported" msgstr "" +#: ports/esp32s2/common-hal/socketpool/SocketPool.c +msgid "Only IPv4 sockets supported" +msgstr "" + #: shared-module/displayio/OnDiskBitmap.c #, c-format msgid "" diff --git a/locale/de_DE.po b/locale/de_DE.po index 56bf286701..7dd79d9151 100644 --- a/locale/de_DE.po +++ b/locale/de_DE.po @@ -5,7 +5,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-11-11 16:30+0530\n" +"POT-Creation-Date: 2020-11-24 15:40-0500\n" "PO-Revision-Date: 2020-11-26 03:11+0000\n" "Last-Translator: Daniel Bravo Darriba \n" "Language: de_DE\n" @@ -300,6 +300,7 @@ msgid "All I2C peripherals are in use" msgstr "Alle I2C-Peripheriegeräte sind in Benutzung" #: ports/esp32s2/common-hal/countio/Counter.c +#: ports/esp32s2/common-hal/frequencyio/FrequencyIn.c #: ports/esp32s2/common-hal/rotaryio/IncrementalEncoder.c msgid "All PCNT units in use" msgstr "" @@ -336,6 +337,7 @@ msgstr "Alle timer für diesen Pin werden bereits benutzt" #: ports/atmel-samd/common-hal/pulseio/PulseIn.c #: ports/atmel-samd/common-hal/pulseio/PulseOut.c #: ports/cxd56/common-hal/pulseio/PulseOut.c +#: ports/esp32s2/common-hal/frequencyio/FrequencyIn.c #: ports/esp32s2/common-hal/neopixel_write/__init__.c #: ports/esp32s2/common-hal/pulseio/PulseIn.c #: ports/esp32s2/common-hal/pulseio/PulseOut.c @@ -1107,6 +1109,7 @@ msgid "Invalid byteorder string" msgstr "Ungültige Byteorder String" #: ports/atmel-samd/common-hal/frequencyio/FrequencyIn.c +#: ports/esp32s2/common-hal/frequencyio/FrequencyIn.c msgid "Invalid capture period. Valid range: 1 - 500" msgstr "Ungültiger Aufnahmezeitraum. Gültiger Bereich: 1 - 500" @@ -1441,14 +1444,14 @@ msgstr "Eine ungerade Parität wird nicht unterstützt" msgid "Only 8 or 16 bit mono with " msgstr "Nur 8 oder 16 bit mono mit " -#: ports/esp32s2/common-hal/socketpool/SocketPool.c -msgid "Only IPv4 SOCK_STREAM sockets supported" -msgstr "" - #: ports/esp32s2/common-hal/wifi/__init__.c msgid "Only IPv4 addresses supported" msgstr "" +#: ports/esp32s2/common-hal/socketpool/SocketPool.c +msgid "Only IPv4 sockets supported" +msgstr "" + #: shared-module/displayio/OnDiskBitmap.c #, c-format msgid "" diff --git a/locale/el.po b/locale/el.po index 71f6e6102b..8d6dad828e 100644 --- a/locale/el.po +++ b/locale/el.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-11-11 16:30+0530\n" +"POT-Creation-Date: 2020-11-24 15:40-0500\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: Automatically generated\n" "Language-Team: none\n" @@ -296,6 +296,7 @@ msgid "All I2C peripherals are in use" msgstr "" #: ports/esp32s2/common-hal/countio/Counter.c +#: ports/esp32s2/common-hal/frequencyio/FrequencyIn.c #: ports/esp32s2/common-hal/rotaryio/IncrementalEncoder.c msgid "All PCNT units in use" msgstr "" @@ -332,6 +333,7 @@ msgstr "" #: ports/atmel-samd/common-hal/pulseio/PulseIn.c #: ports/atmel-samd/common-hal/pulseio/PulseOut.c #: ports/cxd56/common-hal/pulseio/PulseOut.c +#: ports/esp32s2/common-hal/frequencyio/FrequencyIn.c #: ports/esp32s2/common-hal/neopixel_write/__init__.c #: ports/esp32s2/common-hal/pulseio/PulseIn.c #: ports/esp32s2/common-hal/pulseio/PulseOut.c @@ -1085,6 +1087,7 @@ msgid "Invalid byteorder string" msgstr "" #: ports/atmel-samd/common-hal/frequencyio/FrequencyIn.c +#: ports/esp32s2/common-hal/frequencyio/FrequencyIn.c msgid "Invalid capture period. Valid range: 1 - 500" msgstr "" @@ -1415,14 +1418,14 @@ msgstr "" msgid "Only 8 or 16 bit mono with " msgstr "" -#: ports/esp32s2/common-hal/socketpool/SocketPool.c -msgid "Only IPv4 SOCK_STREAM sockets supported" -msgstr "" - #: ports/esp32s2/common-hal/wifi/__init__.c msgid "Only IPv4 addresses supported" msgstr "" +#: ports/esp32s2/common-hal/socketpool/SocketPool.c +msgid "Only IPv4 sockets supported" +msgstr "" + #: shared-module/displayio/OnDiskBitmap.c #, c-format msgid "" diff --git a/locale/es.po b/locale/es.po index db3a630c84..1a02843ed7 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-11-11 16:30+0530\n" +"POT-Creation-Date: 2020-11-24 15:40-0500\n" "PO-Revision-Date: 2020-11-26 03:11+0000\n" "Last-Translator: Daniel Bravo Darriba \n" "Language-Team: \n" @@ -304,6 +304,7 @@ msgid "All I2C peripherals are in use" msgstr "Todos los periféricos I2C están siendo usados" #: ports/esp32s2/common-hal/countio/Counter.c +#: ports/esp32s2/common-hal/frequencyio/FrequencyIn.c #: ports/esp32s2/common-hal/rotaryio/IncrementalEncoder.c msgid "All PCNT units in use" msgstr "Todas las unidades PCNT en uso" @@ -342,6 +343,7 @@ msgstr "Todos los timers para este pin están siendo utilizados" #: ports/atmel-samd/common-hal/pulseio/PulseIn.c #: ports/atmel-samd/common-hal/pulseio/PulseOut.c #: ports/cxd56/common-hal/pulseio/PulseOut.c +#: ports/esp32s2/common-hal/frequencyio/FrequencyIn.c #: ports/esp32s2/common-hal/neopixel_write/__init__.c #: ports/esp32s2/common-hal/pulseio/PulseIn.c #: ports/esp32s2/common-hal/pulseio/PulseOut.c @@ -1108,6 +1110,7 @@ msgid "Invalid byteorder string" msgstr "Cadena de byteorder inválida" #: ports/atmel-samd/common-hal/frequencyio/FrequencyIn.c +#: ports/esp32s2/common-hal/frequencyio/FrequencyIn.c msgid "Invalid capture period. Valid range: 1 - 500" msgstr "Inválido periodo de captura. Rango válido: 1 - 500" @@ -1440,14 +1443,14 @@ msgstr "Paridad impar no soportada" msgid "Only 8 or 16 bit mono with " msgstr "Solo mono de 8 ó 16 bit con " -#: ports/esp32s2/common-hal/socketpool/SocketPool.c -msgid "Only IPv4 SOCK_STREAM sockets supported" -msgstr "Solo hay capacidad para enchufes IPv4 SOCK_STREAM" - #: ports/esp32s2/common-hal/wifi/__init__.c msgid "Only IPv4 addresses supported" msgstr "Solo hay capacidad para direcciones IPv4" +#: ports/esp32s2/common-hal/socketpool/SocketPool.c +msgid "Only IPv4 sockets supported" +msgstr "" + #: shared-module/displayio/OnDiskBitmap.c #, c-format msgid "" @@ -1775,8 +1778,8 @@ msgid "" msgstr "" "La alimentación del microntrolador cayó. Asegúrate que tu fuente de " "alimentación\n" -"pueda aportar suficiente energía para todo el circuito y presiona reset (" -"luego de\n" +"pueda aportar suficiente energía para todo el circuito y presiona reset " +"(luego de\n" "expulsar CIRCUITPY)\n" #: shared-module/audiomixer/MixerVoice.c @@ -3827,6 +3830,9 @@ msgstr "zi debe ser de tipo flotante" msgid "zi must be of shape (n_section, 2)" msgstr "zi debe ser una forma (n_section,2)" +#~ msgid "Only IPv4 SOCK_STREAM sockets supported" +#~ msgstr "Solo hay capacidad para enchufes IPv4 SOCK_STREAM" + #~ msgid "arctan2 is implemented for scalars and ndarrays only" #~ msgstr "arctan2 se encuentra implementado solo para escalares y ndarrays" diff --git a/locale/fil.po b/locale/fil.po index 50067c6d4f..9178623a29 100644 --- a/locale/fil.po +++ b/locale/fil.po @@ -5,7 +5,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-11-11 16:30+0530\n" +"POT-Creation-Date: 2020-11-24 15:40-0500\n" "PO-Revision-Date: 2018-12-20 22:15-0800\n" "Last-Translator: Timothy \n" "Language-Team: fil\n" @@ -298,6 +298,7 @@ msgid "All I2C peripherals are in use" msgstr "Lahat ng I2C peripherals ginagamit" #: ports/esp32s2/common-hal/countio/Counter.c +#: ports/esp32s2/common-hal/frequencyio/FrequencyIn.c #: ports/esp32s2/common-hal/rotaryio/IncrementalEncoder.c msgid "All PCNT units in use" msgstr "" @@ -335,6 +336,7 @@ msgstr "Lahat ng timers para sa pin na ito ay ginagamit" #: ports/atmel-samd/common-hal/pulseio/PulseIn.c #: ports/atmel-samd/common-hal/pulseio/PulseOut.c #: ports/cxd56/common-hal/pulseio/PulseOut.c +#: ports/esp32s2/common-hal/frequencyio/FrequencyIn.c #: ports/esp32s2/common-hal/neopixel_write/__init__.c #: ports/esp32s2/common-hal/pulseio/PulseIn.c #: ports/esp32s2/common-hal/pulseio/PulseOut.c @@ -1100,6 +1102,7 @@ msgid "Invalid byteorder string" msgstr "" #: ports/atmel-samd/common-hal/frequencyio/FrequencyIn.c +#: ports/esp32s2/common-hal/frequencyio/FrequencyIn.c msgid "Invalid capture period. Valid range: 1 - 500" msgstr "" @@ -1433,14 +1436,14 @@ msgstr "Odd na parity ay hindi supportado" msgid "Only 8 or 16 bit mono with " msgstr "Tanging 8 o 16 na bit mono na may " -#: ports/esp32s2/common-hal/socketpool/SocketPool.c -msgid "Only IPv4 SOCK_STREAM sockets supported" -msgstr "" - #: ports/esp32s2/common-hal/wifi/__init__.c msgid "Only IPv4 addresses supported" msgstr "" +#: ports/esp32s2/common-hal/socketpool/SocketPool.c +msgid "Only IPv4 sockets supported" +msgstr "" + #: shared-module/displayio/OnDiskBitmap.c #, c-format msgid "" diff --git a/locale/fr.po b/locale/fr.po index 359595c723..bb9b6ea98d 100644 --- a/locale/fr.po +++ b/locale/fr.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: 0.1\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-11-11 16:30+0530\n" +"POT-Creation-Date: 2020-11-24 15:40-0500\n" "PO-Revision-Date: 2020-11-24 22:45+0000\n" "Last-Translator: Antonin ENFRUN \n" "Language: fr\n" @@ -305,6 +305,7 @@ msgid "All I2C peripherals are in use" msgstr "Tous les périphériques I2C sont utilisés" #: ports/esp32s2/common-hal/countio/Counter.c +#: ports/esp32s2/common-hal/frequencyio/FrequencyIn.c #: ports/esp32s2/common-hal/rotaryio/IncrementalEncoder.c msgid "All PCNT units in use" msgstr "Toutes les unités PCNT sont utilisées" @@ -341,6 +342,7 @@ msgstr "Tous les timers pour cette broche sont utilisés" #: ports/atmel-samd/common-hal/pulseio/PulseIn.c #: ports/atmel-samd/common-hal/pulseio/PulseOut.c #: ports/cxd56/common-hal/pulseio/PulseOut.c +#: ports/esp32s2/common-hal/frequencyio/FrequencyIn.c #: ports/esp32s2/common-hal/neopixel_write/__init__.c #: ports/esp32s2/common-hal/pulseio/PulseIn.c #: ports/esp32s2/common-hal/pulseio/PulseOut.c @@ -1113,6 +1115,7 @@ msgid "Invalid byteorder string" msgstr "Chaîne d'octets non valide" #: ports/atmel-samd/common-hal/frequencyio/FrequencyIn.c +#: ports/esp32s2/common-hal/frequencyio/FrequencyIn.c msgid "Invalid capture period. Valid range: 1 - 500" msgstr "Période de capture invalide. Gamme valide : 1 à 500" @@ -1445,14 +1448,14 @@ msgstr "Parité impaire non supportée" msgid "Only 8 or 16 bit mono with " msgstr "Uniquement 8 ou 16 bit mono avec " -#: ports/esp32s2/common-hal/socketpool/SocketPool.c -msgid "Only IPv4 SOCK_STREAM sockets supported" -msgstr "Seules les sockets IPv4 SOCK_STREAM sont prises en charge" - #: ports/esp32s2/common-hal/wifi/__init__.c msgid "Only IPv4 addresses supported" msgstr "Seules les adresses IPv4 sont prises en charge" +#: ports/esp32s2/common-hal/socketpool/SocketPool.c +msgid "Only IPv4 sockets supported" +msgstr "" + #: shared-module/displayio/OnDiskBitmap.c #, c-format msgid "" @@ -3848,6 +3851,9 @@ msgstr "zi doit être de type float" msgid "zi must be of shape (n_section, 2)" msgstr "zi doit être de forme (n_section, 2)" +#~ msgid "Only IPv4 SOCK_STREAM sockets supported" +#~ msgstr "Seules les sockets IPv4 SOCK_STREAM sont prises en charge" + #~ msgid "arctan2 is implemented for scalars and ndarrays only" #~ msgstr "" #~ "arctan2 est implémenté uniquement pour les scalaires et les ndarrays" diff --git a/locale/hi.po b/locale/hi.po index de77cec46b..025664069d 100644 --- a/locale/hi.po +++ b/locale/hi.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-11-11 16:30+0530\n" +"POT-Creation-Date: 2020-11-24 15:40-0500\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: Automatically generated\n" "Language-Team: none\n" @@ -296,6 +296,7 @@ msgid "All I2C peripherals are in use" msgstr "" #: ports/esp32s2/common-hal/countio/Counter.c +#: ports/esp32s2/common-hal/frequencyio/FrequencyIn.c #: ports/esp32s2/common-hal/rotaryio/IncrementalEncoder.c msgid "All PCNT units in use" msgstr "" @@ -332,6 +333,7 @@ msgstr "" #: ports/atmel-samd/common-hal/pulseio/PulseIn.c #: ports/atmel-samd/common-hal/pulseio/PulseOut.c #: ports/cxd56/common-hal/pulseio/PulseOut.c +#: ports/esp32s2/common-hal/frequencyio/FrequencyIn.c #: ports/esp32s2/common-hal/neopixel_write/__init__.c #: ports/esp32s2/common-hal/pulseio/PulseIn.c #: ports/esp32s2/common-hal/pulseio/PulseOut.c @@ -1085,6 +1087,7 @@ msgid "Invalid byteorder string" msgstr "" #: ports/atmel-samd/common-hal/frequencyio/FrequencyIn.c +#: ports/esp32s2/common-hal/frequencyio/FrequencyIn.c msgid "Invalid capture period. Valid range: 1 - 500" msgstr "" @@ -1415,14 +1418,14 @@ msgstr "" msgid "Only 8 or 16 bit mono with " msgstr "" -#: ports/esp32s2/common-hal/socketpool/SocketPool.c -msgid "Only IPv4 SOCK_STREAM sockets supported" -msgstr "" - #: ports/esp32s2/common-hal/wifi/__init__.c msgid "Only IPv4 addresses supported" msgstr "" +#: ports/esp32s2/common-hal/socketpool/SocketPool.c +msgid "Only IPv4 sockets supported" +msgstr "" + #: shared-module/displayio/OnDiskBitmap.c #, c-format msgid "" diff --git a/locale/it_IT.po b/locale/it_IT.po index 15c83cd53a..bb77d71cc3 100644 --- a/locale/it_IT.po +++ b/locale/it_IT.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-11-11 16:30+0530\n" +"POT-Creation-Date: 2020-11-24 15:40-0500\n" "PO-Revision-Date: 2018-10-02 16:27+0200\n" "Last-Translator: Enrico Paganin \n" "Language-Team: \n" @@ -297,6 +297,7 @@ msgid "All I2C peripherals are in use" msgstr "Tutte le periferiche I2C sono in uso" #: ports/esp32s2/common-hal/countio/Counter.c +#: ports/esp32s2/common-hal/frequencyio/FrequencyIn.c #: ports/esp32s2/common-hal/rotaryio/IncrementalEncoder.c msgid "All PCNT units in use" msgstr "" @@ -334,6 +335,7 @@ msgstr "Tutti i timer per questo pin sono in uso" #: ports/atmel-samd/common-hal/pulseio/PulseIn.c #: ports/atmel-samd/common-hal/pulseio/PulseOut.c #: ports/cxd56/common-hal/pulseio/PulseOut.c +#: ports/esp32s2/common-hal/frequencyio/FrequencyIn.c #: ports/esp32s2/common-hal/neopixel_write/__init__.c #: ports/esp32s2/common-hal/pulseio/PulseIn.c #: ports/esp32s2/common-hal/pulseio/PulseOut.c @@ -1101,6 +1103,7 @@ msgid "Invalid byteorder string" msgstr "" #: ports/atmel-samd/common-hal/frequencyio/FrequencyIn.c +#: ports/esp32s2/common-hal/frequencyio/FrequencyIn.c msgid "Invalid capture period. Valid range: 1 - 500" msgstr "periodo di cattura invalido. Zona valida: 1 - 500" @@ -1438,14 +1441,14 @@ msgstr "operazione I2C non supportata" msgid "Only 8 or 16 bit mono with " msgstr "" -#: ports/esp32s2/common-hal/socketpool/SocketPool.c -msgid "Only IPv4 SOCK_STREAM sockets supported" -msgstr "" - #: ports/esp32s2/common-hal/wifi/__init__.c msgid "Only IPv4 addresses supported" msgstr "" +#: ports/esp32s2/common-hal/socketpool/SocketPool.c +msgid "Only IPv4 sockets supported" +msgstr "" + #: shared-module/displayio/OnDiskBitmap.c #, c-format msgid "" diff --git a/locale/ja.po b/locale/ja.po index d0322be773..2076bbabfd 100644 --- a/locale/ja.po +++ b/locale/ja.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-11-11 16:30+0530\n" +"POT-Creation-Date: 2020-11-24 15:40-0500\n" "PO-Revision-Date: 2020-11-25 01:11+0000\n" "Last-Translator: Mitsuharu Aoyama \n" "Language-Team: none\n" @@ -303,6 +303,7 @@ msgid "All I2C peripherals are in use" msgstr "全てのI2C周辺機器が使用中" #: ports/esp32s2/common-hal/countio/Counter.c +#: ports/esp32s2/common-hal/frequencyio/FrequencyIn.c #: ports/esp32s2/common-hal/rotaryio/IncrementalEncoder.c msgid "All PCNT units in use" msgstr "" @@ -339,6 +340,7 @@ msgstr "このピン用の全てのタイマが使用中" #: ports/atmel-samd/common-hal/pulseio/PulseIn.c #: ports/atmel-samd/common-hal/pulseio/PulseOut.c #: ports/cxd56/common-hal/pulseio/PulseOut.c +#: ports/esp32s2/common-hal/frequencyio/FrequencyIn.c #: ports/esp32s2/common-hal/neopixel_write/__init__.c #: ports/esp32s2/common-hal/pulseio/PulseIn.c #: ports/esp32s2/common-hal/pulseio/PulseOut.c @@ -1100,6 +1102,7 @@ msgid "Invalid byteorder string" msgstr "不正なバイトオーダー文字列" #: ports/atmel-samd/common-hal/frequencyio/FrequencyIn.c +#: ports/esp32s2/common-hal/frequencyio/FrequencyIn.c msgid "Invalid capture period. Valid range: 1 - 500" msgstr "不正なキャプチャ周期。有効な周期は1-500" @@ -1432,14 +1435,14 @@ msgstr "奇数パリティには対応していません" msgid "Only 8 or 16 bit mono with " msgstr "8または16ビットの " -#: ports/esp32s2/common-hal/socketpool/SocketPool.c -msgid "Only IPv4 SOCK_STREAM sockets supported" -msgstr "" - #: ports/esp32s2/common-hal/wifi/__init__.c msgid "Only IPv4 addresses supported" msgstr "" +#: ports/esp32s2/common-hal/socketpool/SocketPool.c +msgid "Only IPv4 sockets supported" +msgstr "" + #: shared-module/displayio/OnDiskBitmap.c #, c-format msgid "" diff --git a/locale/ko.po b/locale/ko.po index fc08bdeaac..9e6cbb0c2a 100644 --- a/locale/ko.po +++ b/locale/ko.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-11-11 16:30+0530\n" +"POT-Creation-Date: 2020-11-24 15:40-0500\n" "PO-Revision-Date: 2020-10-05 12:12+0000\n" "Last-Translator: Michal Čihař \n" "Language-Team: LANGUAGE \n" @@ -299,6 +299,7 @@ msgid "All I2C peripherals are in use" msgstr "사용중인 모든 I2C주변 기기" #: ports/esp32s2/common-hal/countio/Counter.c +#: ports/esp32s2/common-hal/frequencyio/FrequencyIn.c #: ports/esp32s2/common-hal/rotaryio/IncrementalEncoder.c msgid "All PCNT units in use" msgstr "" @@ -335,6 +336,7 @@ msgstr "핀의 모든 타이머가 사용 중입니다" #: ports/atmel-samd/common-hal/pulseio/PulseIn.c #: ports/atmel-samd/common-hal/pulseio/PulseOut.c #: ports/cxd56/common-hal/pulseio/PulseOut.c +#: ports/esp32s2/common-hal/frequencyio/FrequencyIn.c #: ports/esp32s2/common-hal/neopixel_write/__init__.c #: ports/esp32s2/common-hal/pulseio/PulseIn.c #: ports/esp32s2/common-hal/pulseio/PulseOut.c @@ -1090,6 +1092,7 @@ msgid "Invalid byteorder string" msgstr "" #: ports/atmel-samd/common-hal/frequencyio/FrequencyIn.c +#: ports/esp32s2/common-hal/frequencyio/FrequencyIn.c msgid "Invalid capture period. Valid range: 1 - 500" msgstr "" @@ -1420,14 +1423,14 @@ msgstr "" msgid "Only 8 or 16 bit mono with " msgstr "" -#: ports/esp32s2/common-hal/socketpool/SocketPool.c -msgid "Only IPv4 SOCK_STREAM sockets supported" -msgstr "" - #: ports/esp32s2/common-hal/wifi/__init__.c msgid "Only IPv4 addresses supported" msgstr "" +#: ports/esp32s2/common-hal/socketpool/SocketPool.c +msgid "Only IPv4 sockets supported" +msgstr "" + #: shared-module/displayio/OnDiskBitmap.c #, c-format msgid "" diff --git a/locale/nl.po b/locale/nl.po index ee7a3fd545..41a3ace76b 100644 --- a/locale/nl.po +++ b/locale/nl.po @@ -5,7 +5,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-11-11 16:30+0530\n" +"POT-Creation-Date: 2020-11-24 15:40-0500\n" "PO-Revision-Date: 2020-10-27 16:47+0000\n" "Last-Translator: Jelle Jager \n" "Language-Team: none\n" @@ -301,6 +301,7 @@ msgid "All I2C peripherals are in use" msgstr "Alle I2C peripherals zijn in gebruik" #: ports/esp32s2/common-hal/countio/Counter.c +#: ports/esp32s2/common-hal/frequencyio/FrequencyIn.c #: ports/esp32s2/common-hal/rotaryio/IncrementalEncoder.c msgid "All PCNT units in use" msgstr "" @@ -337,6 +338,7 @@ msgstr "Alle timers voor deze pin zijn in gebruik" #: ports/atmel-samd/common-hal/pulseio/PulseIn.c #: ports/atmel-samd/common-hal/pulseio/PulseOut.c #: ports/cxd56/common-hal/pulseio/PulseOut.c +#: ports/esp32s2/common-hal/frequencyio/FrequencyIn.c #: ports/esp32s2/common-hal/neopixel_write/__init__.c #: ports/esp32s2/common-hal/pulseio/PulseIn.c #: ports/esp32s2/common-hal/pulseio/PulseOut.c @@ -1102,6 +1104,7 @@ msgid "Invalid byteorder string" msgstr "Ongeldige byteorder string" #: ports/atmel-samd/common-hal/frequencyio/FrequencyIn.c +#: ports/esp32s2/common-hal/frequencyio/FrequencyIn.c msgid "Invalid capture period. Valid range: 1 - 500" msgstr "Ongeldige vastlegging periode. Geldig bereik: 1 - 500" @@ -1434,14 +1437,14 @@ msgstr "Oneven pariteit is niet ondersteund" msgid "Only 8 or 16 bit mono with " msgstr "Alleen 8 of 16 bit mono met " -#: ports/esp32s2/common-hal/socketpool/SocketPool.c -msgid "Only IPv4 SOCK_STREAM sockets supported" -msgstr "Alleen IPv4 SOCK_STREAM sockets worden ondersteund" - #: ports/esp32s2/common-hal/wifi/__init__.c msgid "Only IPv4 addresses supported" msgstr "Alleen IPv4 adressen worden ondersteund" +#: ports/esp32s2/common-hal/socketpool/SocketPool.c +msgid "Only IPv4 sockets supported" +msgstr "" + #: shared-module/displayio/OnDiskBitmap.c #, c-format msgid "" @@ -3814,6 +3817,9 @@ msgstr "zi moet van type float zijn" msgid "zi must be of shape (n_section, 2)" msgstr "zi moet vorm (n_section, 2) hebben" +#~ msgid "Only IPv4 SOCK_STREAM sockets supported" +#~ msgstr "Alleen IPv4 SOCK_STREAM sockets worden ondersteund" + #~ msgid "arctan2 is implemented for scalars and ndarrays only" #~ msgstr "arctan2 is alleen geïmplementeerd voor scalars en ndarrays" diff --git a/locale/pl.po b/locale/pl.po index 4d8c9d84cc..5fbe727efa 100644 --- a/locale/pl.po +++ b/locale/pl.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-11-11 16:30+0530\n" +"POT-Creation-Date: 2020-11-24 15:40-0500\n" "PO-Revision-Date: 2020-11-11 19:13+0000\n" "Last-Translator: Maciej Stankiewicz \n" "Language-Team: pl\n" @@ -303,6 +303,7 @@ msgid "All I2C peripherals are in use" msgstr "Wszystkie peryferia I2C w użyciu" #: ports/esp32s2/common-hal/countio/Counter.c +#: ports/esp32s2/common-hal/frequencyio/FrequencyIn.c #: ports/esp32s2/common-hal/rotaryio/IncrementalEncoder.c msgid "All PCNT units in use" msgstr "" @@ -339,6 +340,7 @@ msgstr "Wszystkie timery tej nóżki w użyciu" #: ports/atmel-samd/common-hal/pulseio/PulseIn.c #: ports/atmel-samd/common-hal/pulseio/PulseOut.c #: ports/cxd56/common-hal/pulseio/PulseOut.c +#: ports/esp32s2/common-hal/frequencyio/FrequencyIn.c #: ports/esp32s2/common-hal/neopixel_write/__init__.c #: ports/esp32s2/common-hal/pulseio/PulseIn.c #: ports/esp32s2/common-hal/pulseio/PulseOut.c @@ -1100,6 +1102,7 @@ msgid "Invalid byteorder string" msgstr "" #: ports/atmel-samd/common-hal/frequencyio/FrequencyIn.c +#: ports/esp32s2/common-hal/frequencyio/FrequencyIn.c msgid "Invalid capture period. Valid range: 1 - 500" msgstr "Zły okres. Poprawny zakres to: 1 - 500" @@ -1431,14 +1434,14 @@ msgstr "Nieparzysta parzystość nie jest wspierana" msgid "Only 8 or 16 bit mono with " msgstr "Tylko 8 lub 16 bitów mono z " -#: ports/esp32s2/common-hal/socketpool/SocketPool.c -msgid "Only IPv4 SOCK_STREAM sockets supported" -msgstr "" - #: ports/esp32s2/common-hal/wifi/__init__.c msgid "Only IPv4 addresses supported" msgstr "" +#: ports/esp32s2/common-hal/socketpool/SocketPool.c +msgid "Only IPv4 sockets supported" +msgstr "" + #: shared-module/displayio/OnDiskBitmap.c #, c-format msgid "" diff --git a/locale/pt_BR.po b/locale/pt_BR.po index 49ac502e29..8f899a12c4 100644 --- a/locale/pt_BR.po +++ b/locale/pt_BR.po @@ -5,7 +5,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-11-11 16:30+0530\n" +"POT-Creation-Date: 2020-11-24 15:40-0500\n" "PO-Revision-Date: 2020-11-24 23:22+0000\n" "Last-Translator: Wellington Terumi Uemura \n" "Language-Team: \n" @@ -305,6 +305,7 @@ msgid "All I2C peripherals are in use" msgstr "Todos os periféricos I2C estão em uso" #: ports/esp32s2/common-hal/countio/Counter.c +#: ports/esp32s2/common-hal/frequencyio/FrequencyIn.c #: ports/esp32s2/common-hal/rotaryio/IncrementalEncoder.c msgid "All PCNT units in use" msgstr "Todas as unidades PCNT estão em uso" @@ -341,6 +342,7 @@ msgstr "Todos os temporizadores para este pino estão em uso" #: ports/atmel-samd/common-hal/pulseio/PulseIn.c #: ports/atmel-samd/common-hal/pulseio/PulseOut.c #: ports/cxd56/common-hal/pulseio/PulseOut.c +#: ports/esp32s2/common-hal/frequencyio/FrequencyIn.c #: ports/esp32s2/common-hal/neopixel_write/__init__.c #: ports/esp32s2/common-hal/pulseio/PulseIn.c #: ports/esp32s2/common-hal/pulseio/PulseOut.c @@ -1111,6 +1113,7 @@ msgid "Invalid byteorder string" msgstr "A cadeia de bytes é inválida" #: ports/atmel-samd/common-hal/frequencyio/FrequencyIn.c +#: ports/esp32s2/common-hal/frequencyio/FrequencyIn.c msgid "Invalid capture period. Valid range: 1 - 500" msgstr "O período de captura é inválido. O intervalo válido é: 1 - 500" @@ -1442,14 +1445,14 @@ msgstr "A paridade ímpar não é compatível" msgid "Only 8 or 16 bit mono with " msgstr "Apenas mono com 8 ou 16 bits com " -#: ports/esp32s2/common-hal/socketpool/SocketPool.c -msgid "Only IPv4 SOCK_STREAM sockets supported" -msgstr "São suportados apenas soquetes IPv4 SOCK_STREAM" - #: ports/esp32s2/common-hal/wifi/__init__.c msgid "Only IPv4 addresses supported" msgstr "Somente os endereços IPv4 são suportados" +#: ports/esp32s2/common-hal/socketpool/SocketPool.c +msgid "Only IPv4 sockets supported" +msgstr "" + #: shared-module/displayio/OnDiskBitmap.c #, c-format msgid "" @@ -3839,6 +3842,9 @@ msgstr "zi deve ser de um tipo float" msgid "zi must be of shape (n_section, 2)" msgstr "zi deve estar na forma (n_section, 2)" +#~ msgid "Only IPv4 SOCK_STREAM sockets supported" +#~ msgstr "São suportados apenas soquetes IPv4 SOCK_STREAM" + #~ msgid "arctan2 is implemented for scalars and ndarrays only" #~ msgstr "O arctan2 está implementado apenas para escalares e ndarrays" diff --git a/locale/sv.po b/locale/sv.po index db05a557ae..66c1f345a2 100644 --- a/locale/sv.po +++ b/locale/sv.po @@ -5,7 +5,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-11-11 16:30+0530\n" +"POT-Creation-Date: 2020-11-24 15:40-0500\n" "PO-Revision-Date: 2020-11-20 22:28+0000\n" "Last-Translator: Jonny Bergdahl \n" "Language-Team: LANGUAGE \n" @@ -301,6 +301,7 @@ msgid "All I2C peripherals are in use" msgstr "All I2C-kringutrustning används" #: ports/esp32s2/common-hal/countio/Counter.c +#: ports/esp32s2/common-hal/frequencyio/FrequencyIn.c #: ports/esp32s2/common-hal/rotaryio/IncrementalEncoder.c msgid "All PCNT units in use" msgstr "Alla PCNT-enheter används" @@ -337,6 +338,7 @@ msgstr "Alla timers för denna pinne är i bruk" #: ports/atmel-samd/common-hal/pulseio/PulseIn.c #: ports/atmel-samd/common-hal/pulseio/PulseOut.c #: ports/cxd56/common-hal/pulseio/PulseOut.c +#: ports/esp32s2/common-hal/frequencyio/FrequencyIn.c #: ports/esp32s2/common-hal/neopixel_write/__init__.c #: ports/esp32s2/common-hal/pulseio/PulseIn.c #: ports/esp32s2/common-hal/pulseio/PulseOut.c @@ -1100,6 +1102,7 @@ msgid "Invalid byteorder string" msgstr "Ogiltig byteorder-sträng" #: ports/atmel-samd/common-hal/frequencyio/FrequencyIn.c +#: ports/esp32s2/common-hal/frequencyio/FrequencyIn.c msgid "Invalid capture period. Valid range: 1 - 500" msgstr "Ogiltig inspelningsperiod. Giltigt intervall: 1 - 500" @@ -1433,14 +1436,14 @@ msgstr "Udda paritet stöds inte" msgid "Only 8 or 16 bit mono with " msgstr "Endast 8 eller 16 bitars mono med " -#: ports/esp32s2/common-hal/socketpool/SocketPool.c -msgid "Only IPv4 SOCK_STREAM sockets supported" -msgstr "Endast IPv4 SOCK_STREAM sockets stöds" - #: ports/esp32s2/common-hal/wifi/__init__.c msgid "Only IPv4 addresses supported" msgstr "Endast IPv4-adresser stöds" +#: ports/esp32s2/common-hal/socketpool/SocketPool.c +msgid "Only IPv4 sockets supported" +msgstr "" + #: shared-module/displayio/OnDiskBitmap.c #, c-format msgid "" @@ -3807,6 +3810,9 @@ msgstr "zi måste vara av typ float" msgid "zi must be of shape (n_section, 2)" msgstr "zi måste vara i formen (n_section, 2)" +#~ msgid "Only IPv4 SOCK_STREAM sockets supported" +#~ msgstr "Endast IPv4 SOCK_STREAM sockets stöds" + #~ msgid "arctan2 is implemented for scalars and ndarrays only" #~ msgstr "arctan2 är enbart implementerad för scalar och ndarray" diff --git a/locale/zh_Latn_pinyin.po b/locale/zh_Latn_pinyin.po index 2f0673a7d0..7a08bc6e8c 100644 --- a/locale/zh_Latn_pinyin.po +++ b/locale/zh_Latn_pinyin.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: circuitpython-cn\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-11-11 16:30+0530\n" +"POT-Creation-Date: 2020-11-24 15:40-0500\n" "PO-Revision-Date: 2020-11-19 01:28+0000\n" "Last-Translator: hexthat \n" "Language-Team: Chinese Hanyu Pinyin\n" @@ -303,6 +303,7 @@ msgid "All I2C peripherals are in use" msgstr "Suǒyǒu I2C wàiwéi qì zhèngzài shǐyòng" #: ports/esp32s2/common-hal/countio/Counter.c +#: ports/esp32s2/common-hal/frequencyio/FrequencyIn.c #: ports/esp32s2/common-hal/rotaryio/IncrementalEncoder.c msgid "All PCNT units in use" msgstr "suǒ yǒu zhèng zài shǐ yòng zhōng de PCNT dān yuán" @@ -339,6 +340,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/pulseio/PulseIn.c #: ports/atmel-samd/common-hal/pulseio/PulseOut.c #: ports/cxd56/common-hal/pulseio/PulseOut.c +#: ports/esp32s2/common-hal/frequencyio/FrequencyIn.c #: ports/esp32s2/common-hal/neopixel_write/__init__.c #: ports/esp32s2/common-hal/pulseio/PulseIn.c #: ports/esp32s2/common-hal/pulseio/PulseOut.c @@ -1098,6 +1100,7 @@ msgid "Invalid byteorder string" msgstr "Wúxiào de zì jié shùnxù zìfú chuàn" #: ports/atmel-samd/common-hal/frequencyio/FrequencyIn.c +#: ports/esp32s2/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" @@ -1429,14 +1432,14 @@ msgstr "Bù zhīchí jīshù" msgid "Only 8 or 16 bit mono with " msgstr "Zhǐyǒu 8 huò 16 wèi dānwèi " -#: ports/esp32s2/common-hal/socketpool/SocketPool.c -msgid "Only IPv4 SOCK_STREAM sockets supported" -msgstr "Jǐn zhīchí IPv4 SOCK_STREAM tào jiē zì" - #: ports/esp32s2/common-hal/wifi/__init__.c msgid "Only IPv4 addresses supported" msgstr "Jǐn zhīchí IPv4 dìzhǐ" +#: ports/esp32s2/common-hal/socketpool/SocketPool.c +msgid "Only IPv4 sockets supported" +msgstr "" + #: shared-module/displayio/OnDiskBitmap.c #, c-format msgid "" @@ -3796,6 +3799,9 @@ msgstr "zi bìxū wèi fú diǎn xíng" msgid "zi must be of shape (n_section, 2)" msgstr "zi bìxū jùyǒu xíngzhuàng (n_section,2)" +#~ msgid "Only IPv4 SOCK_STREAM sockets supported" +#~ msgstr "Jǐn zhīchí IPv4 SOCK_STREAM tào jiē zì" + #~ msgid "arctan2 is implemented for scalars and ndarrays only" #~ msgstr "arctan2 jǐn zhēnduì biāoliàng hé ndarray shíxiàn" From 6af48bb24cc12a9547aef8d18d56acf8e0f5695d Mon Sep 17 00:00:00 2001 From: microDev <70126934+microDev1@users.noreply.github.com> Date: Thu, 26 Nov 2020 11:22:44 +0530 Subject: [PATCH 153/207] reset touchin on every vm run --- ports/esp32s2/common-hal/touchio/TouchIn.c | 8 +++++++- ports/esp32s2/supervisor/port.c | 5 +++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/ports/esp32s2/common-hal/touchio/TouchIn.c b/ports/esp32s2/common-hal/touchio/TouchIn.c index 4589c46a79..b27cbcf86d 100644 --- a/ports/esp32s2/common-hal/touchio/TouchIn.c +++ b/ports/esp32s2/common-hal/touchio/TouchIn.c @@ -31,6 +31,13 @@ bool touch_inited = false; +void touchin_reset(void) { + if (touch_inited) { + touch_pad_deinit(); + touch_inited = false; + } +} + static uint16_t get_raw_reading(touchio_touchin_obj_t *self) { uint32_t touch_value; touch_pad_read_raw_data((touch_pad_t)self->pin->touch_channel, &touch_value); @@ -78,7 +85,6 @@ void common_hal_touchio_touchin_deinit(touchio_touchin_obj_t* self) { if (common_hal_touchio_touchin_deinited(self)) { return; } - touch_pad_deinit(); reset_pin_number(self->pin->touch_channel); self->pin = NULL; } diff --git a/ports/esp32s2/supervisor/port.c b/ports/esp32s2/supervisor/port.c index 876ad739d6..e2defc5af3 100644 --- a/ports/esp32s2/supervisor/port.c +++ b/ports/esp32s2/supervisor/port.c @@ -43,6 +43,7 @@ #include "common-hal/busio/UART.h" #include "common-hal/pulseio/PulseIn.h" #include "common-hal/pwmio/PWMOut.h" +#include "common-hal/touchio/TouchIn.h" #include "common-hal/watchdog/WatchDogTimer.h" #include "common-hal/wifi/__init__.h" #include "supervisor/memory.h" @@ -127,6 +128,10 @@ void reset_port(void) { rtc_reset(); #endif +#if CIRCUITPY_TOUCHIO_USE_NATIVE + touchin_reset(); +#endif + #if CIRCUITPY_WATCHDOG watchdog_reset(); #endif From 104a089677d62de3554deea7850796dfbb29b1fc Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Thu, 26 Nov 2020 22:06:37 -0500 Subject: [PATCH 154/207] deep sleep working; deep sleep delay when connected --- main.c | 82 +++---------------- .../common-hal/microcontroller/__init__.c | 4 - .../common-hal/microcontroller/__init__.c | 4 - ports/esp32s2/common-hal/alarm/__init__.c | 54 ++++++------ .../common-hal/microcontroller/__init__.c | 6 -- .../common-hal/microcontroller/__init__.c | 4 - .../common-hal/microcontroller/__init__.c | 4 - .../nrf/common-hal/microcontroller/__init__.c | 4 - .../stm/common-hal/microcontroller/__init__.c | 4 - shared-bindings/_typing/__init__.pyi | 4 +- shared-bindings/alarm/__init__.c | 43 ++++++++-- shared-bindings/alarm/__init__.h | 3 +- shared-bindings/alarm/pin/PinAlarm.c | 2 +- shared-bindings/alarm/time/TimeAlarm.c | 78 ++++++++++++++---- shared-bindings/microcontroller/__init__.h | 2 - 15 files changed, 143 insertions(+), 155 deletions(-) diff --git a/main.c b/main.c index a9dbb1b7c3..dda439d6de 100755 --- a/main.c +++ b/main.c @@ -66,9 +66,6 @@ #include "boards/board.h" -// REMOVE *********** -#include "esp_log.h" - #if CIRCUITPY_ALARM #include "shared-bindings/alarm/__init__.h" #endif @@ -98,12 +95,6 @@ #include "common-hal/canio/CAN.h" #endif -// How long to wait for host to start connecting.. -#define CIRCUITPY_USB_CONNECTING_DELAY 1 - -// How long to flash errors on the RGB status LED before going to sleep (secs) -#define CIRCUITPY_FLASH_ERROR_PERIOD 10 - #if MICROPY_ENABLE_PYSTACK static size_t PLACE_IN_DTCM_BSS(_pystack[CIRCUITPY_PYSTACK_SIZE / sizeof(size_t)]); #endif @@ -259,17 +250,6 @@ STATIC void print_code_py_status_message(safe_mode_t safe_mode) { } } -// Should we go into deep sleep when program finishes? -// Normally we won't deep sleep if there was an error or if we are connected to a host -// but either of those can be enabled. -// It's ok to deep sleep if we're not connected to a host, but we need to make sure -// we're giving enough time for USB to start to connect -STATIC bool deep_sleep_allowed(void) { - return - (ok || supervisor_workflow_get_allow_deep_sleep_on_error()) && - !supervisor_workflow_connecting() - (supervisor_ticks_ms64() > CIRCUITPY_USB_CONNECTING_DELAY * 1024); - STATIC bool run_code_py(safe_mode_t safe_mode) { bool serial_connected_at_start = serial_connected(); #if CIRCUITPY_AUTORELOAD_DELAY_MS > 0 @@ -290,10 +270,12 @@ STATIC bool run_code_py(safe_mode_t safe_mode) { if (safe_mode == NO_SAFE_MODE) { new_status_color(MAIN_RUNNING); - static const char * const supported_filenames[] = STRING_LIST("code.txt", "code.py", "main.py", "main.txt"); + static const char * const supported_filenames[] = STRING_LIST( + "code.txt", "code.py", "main.py", "main.txt"); #if CIRCUITPY_FULL_BUILD - static const char * const double_extension_filenames[] = STRING_LIST("code.txt.py", "code.py.txt", "code.txt.txt","code.py.py", - "main.txt.py", "main.py.txt", "main.txt.txt","main.py.py"); + static const char * const double_extension_filenames[] = STRING_LIST( + "code.txt.py", "code.py.txt", "code.txt.txt","code.py.py", + "main.txt.py", "main.py.txt", "main.txt.txt","main.py.py"); #endif stack_resize(); @@ -319,7 +301,7 @@ STATIC bool run_code_py(safe_mode_t safe_mode) { // Program has finished running. // Display a different completion message if the user has no USB attached (cannot save files) - if (!serial_connected_at_start && !deep_sleep_allowed()) { + if (!serial_connected_at_start) { serial_write_compressed(translate("\nCode done running. Waiting for reload.\n")); } @@ -327,16 +309,8 @@ STATIC bool run_code_py(safe_mode_t safe_mode) { #if CIRCUITPY_DISPLAYIO bool refreshed_epaper_display = false; #endif + rgb_status_animation_t animation; - bool ok = result.return_code != PYEXEC_EXCEPTION; - - #if CIRCUITPY_ALARM - // Enable pin or time alarms before sleeping. - // If immediate_wake is true, then there's an alarm that would trigger immediately, - // so don't sleep. - bool immediate_wake = !common_hal_alarm_enable_deep_sleep_alarms(); - #endif - prep_rgb_status_animation(&result, found_main, safe_mode, &animation); while (true) { @@ -360,12 +334,10 @@ STATIC bool run_code_py(safe_mode_t safe_mode) { if (!serial_connected_at_start) { print_code_py_status_message(safe_mode); } - // We won't be going into the REPL if we're going to sleep. - if (!deep_sleep_allowed()) { - print_safe_mode_message(safe_mode); - serial_write("\n"); - serial_write_compressed(translate("Press any key to enter the REPL. Use CTRL-D to reload.")); - } + + print_safe_mode_message(safe_mode); + serial_write("\n"); + serial_write_compressed(translate("Press any key to enter the REPL. Use CTRL-D to reload.")); } if (serial_connected_before_animation && !serial_connected()) { serial_connected_at_start = false; @@ -379,37 +351,7 @@ STATIC bool run_code_py(safe_mode_t safe_mode) { } #endif - bool animation_done = false; - - if (deep_sleep_allowed() && ok) { - // Skip animation if everything is OK. - animation_done = true; - } else { - animation_done = tick_rgb_status_animation(&animation); - } - // Do an error animation only once before deep-sleeping. - if (animation_done) { - if (immediate_wake) { - // Don't sleep, we are already supposed to wake up. - return true; - } - if (deep_sleep_allowed()) { - common_hal_mcu_deep_sleep(); - // Does not return. - } - - // Wake up every so often to flash the error code. - if (!ok) { - port_interrupt_after_ticks(CIRCUITPY_FLASH_ERROR_PERIOD * 1024); - } else { - int64_t remaining_connecting_wait = - CIRCUITPY_USB_CONNECTING_DELAY * 1024 - supervisor_ticks_ms64(); - if (remaining_connecting_wait > 0) { - port_interrupt_after_ticks(remaining_connecting_wait); - } - port_sleep_until_interrupt(); - } - } + tick_rgb_status_animation(&animation); } } diff --git a/ports/atmel-samd/common-hal/microcontroller/__init__.c b/ports/atmel-samd/common-hal/microcontroller/__init__.c index ca39f28386..50a1ec038e 100644 --- a/ports/atmel-samd/common-hal/microcontroller/__init__.c +++ b/ports/atmel-samd/common-hal/microcontroller/__init__.c @@ -84,10 +84,6 @@ void common_hal_mcu_reset(void) { reset(); } -void common_hal_mcu_deep_sleep(void) { - //deep sleep call here -} - // 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 = { diff --git a/ports/cxd56/common-hal/microcontroller/__init__.c b/ports/cxd56/common-hal/microcontroller/__init__.c index 57140dec70..7aa3b839d7 100644 --- a/ports/cxd56/common-hal/microcontroller/__init__.c +++ b/ports/cxd56/common-hal/microcontroller/__init__.c @@ -81,10 +81,6 @@ void common_hal_mcu_reset(void) { boardctl(BOARDIOC_RESET, 0); } -void common_hal_mcu_deep_sleep(void) { - //deep sleep call here -} - STATIC const mp_rom_map_elem_t mcu_pin_globals_table[] = { { MP_ROM_QSTR(MP_QSTR_UART2_RXD), MP_ROM_PTR(&pin_UART2_RXD) }, { MP_ROM_QSTR(MP_QSTR_UART2_TXD), MP_ROM_PTR(&pin_UART2_TXD) }, diff --git a/ports/esp32s2/common-hal/alarm/__init__.c b/ports/esp32s2/common-hal/alarm/__init__.c index 7cf74a0efc..767b0de70e 100644 --- a/ports/esp32s2/common-hal/alarm/__init__.c +++ b/ports/esp32s2/common-hal/alarm/__init__.c @@ -1,4 +1,4 @@ -/* + /* * This file is part of the MicroPython project, http://micropython.org/ * * The MIT License (MIT) @@ -77,12 +77,10 @@ mp_obj_t common_hal_alarm_get_wake_alarm(void) { return mp_const_none; } -mp_obj_t common_hal_alarm_sleep_until_alarms(size_t n_alarms, const mp_obj_t *alarms) { - mp_raise_NotImplementedError(NULL); -} - -void common_hal_alarm_set_deep_sleep_alarms(size_t n_alarms, const mp_obj_t *alarms) { +STATIC void setup_alarms(size_t n_alarms, const mp_obj_t *alarms) { bool time_alarm_set = false; + alarm_time_time_alarm_obj_t *time_alarm = MP_OBJ_NULL; + for (size_t i = 0; i < n_alarms; i++) { if (MP_OBJ_IS_TYPE(alarms[i], &alarm_pin_pin_alarm_type)) { mp_raise_NotImplementedError(translate("PinAlarm deep sleep not yet implemented")); @@ -91,32 +89,32 @@ void common_hal_alarm_set_deep_sleep_alarms(size_t n_alarms, const mp_obj_t *ala if (time_alarm_set) { mp_raise_ValueError(translate("Only one alarm.time alarm can be set.")); } + time_alarm = MP_OBJ_TO_PTR(alarms[i]); time_alarm_set = true; } } - _deep_sleep_alarms = mp_obj_new_tuple(n_alarms, alarms); + if (time_alarm != MP_OBJ_NULL) { + // Compute how long to actually sleep, considering the time now. + mp_float_t now_secs = uint64_to_float(common_hal_time_monotonic_ms()) / 1000.0f; + mp_float_t wakeup_in_secs = MAX(0.0f, time_alarm->monotonic_time - now_secs); + esp_sleep_enable_timer_wakeup((uint64_t) (wakeup_in_secs * 1000000)); + } } -// Return false if we should wake up immediately because a time alarm is in the past -// or otherwise already triggered. -bool common_hal_alarm_enable_deep_sleep_alarms(void) { - for (size_t i = 0; i < _deep_sleep_alarms->len; i++) { - mp_obj_t alarm = _deep_sleep_alarms->items[i]; - if (MP_OBJ_IS_TYPE(alarm, &alarm_pin_pin_alarm_type)) { - // TODO: handle pin alarms - mp_raise_NotImplementedError(translate("PinAlarm deep sleep not yet implemented")); - } - else if (MP_OBJ_IS_TYPE(alarm, &alarm_time_time_alarm_type)) { - alarm_time_time_alarm_obj_t *time_alarm = MP_OBJ_TO_PTR(alarm); - mp_float_t now_secs = uint64_to_float(common_hal_time_monotonic_ms()) / 1000.0f; - // Compute how long to actually sleep, considering hte time now. - mp_float_t wakeup_in_secs = time_alarm->monotonic_time - now_secs; - if (wakeup_in_secs <= 0.0f) { - return false; - } - esp_sleep_enable_timer_wakeup((uint64_t) (wakeup_in_secs * 1000000)); - } - } - return true; +mp_obj_t common_hal_alarm_sleep_until_alarms(size_t n_alarms, const mp_obj_t *alarms) { + setup_alarms(n_alarms, alarms); + + // Shut down wifi cleanly. + esp_wifi_stop(); + esp_light_sleep_start(); + return common_hal_alarm_get_wake_alarm(); +} + +void common_hal_alarm_exit_and_deep_sleep_until_alarms(size_t n_alarms, const mp_obj_t *alarms) { + setup_alarms(n_alarms, alarms); + + // Shut down wifi cleanly. + esp_wifi_stop(); + esp_deep_sleep_start(); } diff --git a/ports/esp32s2/common-hal/microcontroller/__init__.c b/ports/esp32s2/common-hal/microcontroller/__init__.c index 3578b86d02..184f5be696 100644 --- a/ports/esp32s2/common-hal/microcontroller/__init__.c +++ b/ports/esp32s2/common-hal/microcontroller/__init__.c @@ -81,12 +81,6 @@ void common_hal_mcu_reset(void) { while(1); } -void NORETURN common_hal_mcu_deep_sleep(void) { - // Shut down wifi cleanly. - esp_wifi_stop(); - esp_deep_sleep_start(); -} - // 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 = { diff --git a/ports/litex/common-hal/microcontroller/__init__.c b/ports/litex/common-hal/microcontroller/__init__.c index e6f50ed5a6..3c91661144 100644 --- a/ports/litex/common-hal/microcontroller/__init__.c +++ b/ports/litex/common-hal/microcontroller/__init__.c @@ -89,10 +89,6 @@ void common_hal_mcu_reset(void) { while(1); } -void common_hal_mcu_deep_sleep(void) { - //deep sleep call here -} - // 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 = { diff --git a/ports/mimxrt10xx/common-hal/microcontroller/__init__.c b/ports/mimxrt10xx/common-hal/microcontroller/__init__.c index 0329ced69b..6a8537e2da 100644 --- a/ports/mimxrt10xx/common-hal/microcontroller/__init__.c +++ b/ports/mimxrt10xx/common-hal/microcontroller/__init__.c @@ -86,10 +86,6 @@ void common_hal_mcu_reset(void) { NVIC_SystemReset(); } -void common_hal_mcu_deep_sleep(void) { - //deep sleep call here -} - // 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 = { diff --git a/ports/nrf/common-hal/microcontroller/__init__.c b/ports/nrf/common-hal/microcontroller/__init__.c index 9911896bff..06aac9409d 100644 --- a/ports/nrf/common-hal/microcontroller/__init__.c +++ b/ports/nrf/common-hal/microcontroller/__init__.c @@ -95,10 +95,6 @@ void common_hal_mcu_reset(void) { reset_cpu(); } -void common_hal_mcu_deep_sleep(void) { - //deep sleep call here -} - // 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 = { diff --git a/ports/stm/common-hal/microcontroller/__init__.c b/ports/stm/common-hal/microcontroller/__init__.c index bc81b0e4f5..a827399ccb 100644 --- a/ports/stm/common-hal/microcontroller/__init__.c +++ b/ports/stm/common-hal/microcontroller/__init__.c @@ -81,10 +81,6 @@ void common_hal_mcu_reset(void) { NVIC_SystemReset(); } -void common_hal_mcu_deep_sleep(void) { - //deep sleep call here -} - // 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 = { diff --git a/shared-bindings/_typing/__init__.pyi b/shared-bindings/_typing/__init__.pyi index 02839ab477..2716936860 100644 --- a/shared-bindings/_typing/__init__.pyi +++ b/shared-bindings/_typing/__init__.pyi @@ -54,12 +54,12 @@ FrameBuffer = Union[rgbmatrix.RGBMatrix] """ Alarm = Union[ - alarm.pin.PinAlarm, alarm.time.DurationAlarm + alarm.pin.PinAlarm, alarm.time.TimeAlarm ] """Classes that implement alarms for sleeping and asynchronous notification. - `alarm.pin.PinAlarm` - - `alarm.time.DurationAlarm` + - `alarm.time.TimeAlarm` You can use these alarms to wake from light or deep sleep. """ diff --git a/shared-bindings/alarm/__init__.c b/shared-bindings/alarm/__init__.c index 4aa6c8457d..4c2189c0d0 100644 --- a/shared-bindings/alarm/__init__.c +++ b/shared-bindings/alarm/__init__.c @@ -30,6 +30,15 @@ #include "shared-bindings/alarm/__init__.h" #include "shared-bindings/alarm/pin/PinAlarm.h" #include "shared-bindings/alarm/time/TimeAlarm.h" +#include "shared-bindings/time/__init__.h" +#include "supervisor/shared/rgb_led_status.h" +#include "supervisor/shared/workflow.h" + +// Wait this long to see if USB is being connected (enumeration starting). +#define CIRCUITPY_USB_CONNECTING_DELAY 1 +// Wait this long before going into deep sleep if connected. This +// allows the user to ctrl-C before deep sleep starts. +#define CIRCUITPY_USB_CONNECTED_DEEP_SLEEP_DELAY 5 //| """Power-saving light and deep sleep. Alarms can be set to wake up from sleep. //| @@ -44,16 +53,12 @@ //| Deep sleep shuts down power to nearly all of the chip including the CPU and RAM. This can save //| a more significant amount of power, but CircuitPython must start ``code.py`` from the beginning when //| awakened. +//| """ -//| -//| An error includes an uncaught exception, or sys.exit() called with a non-zero argument -//| -//| To set alarms for deep sleep use `alarm.set_deep_sleep_alarms()` they will apply to next deep sleep only.""" //| //| wake_alarm: Alarm //| """The most recent alarm to wake us up from a sleep (light or deep.)""" //| - void validate_objs_are_alarms(size_t n_args, const mp_obj_t *objs) { for (size_t i = 0; i < n_args; i++) { if (MP_OBJ_IS_TYPE(objs[i], &alarm_pin_pin_alarm_type) || @@ -88,12 +93,38 @@ MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(alarm_sleep_until_alarms_obj, 1, MP_OBJ_FUN_ //| For time-base alarms, currently, an `alarm.time.TimeAlarm()` is created. //| //| If no alarms are specified, the microcontroller will deep sleep until reset. +//| +//| If CircuitPython is unconnected to a host computer, go into deep sleep immediately. +//| But if it already connected or in the process of connecting to a host computer, wait at least +//| five seconds after starting code.py before entering deep sleep. +//| This allows interrupting a program that would otherwise go into deep sleep too quickly +//| to interrupt from the keyboard. //| """ //| ... //| STATIC mp_obj_t alarm_exit_and_deep_sleep_until_alarms(size_t n_args, const mp_obj_t *args) { validate_objs_are_alarms(n_args, args); - common_hal_exit_and_deep_sleep_until_alarms(n_args, args); + + int64_t connecting_delay_msec = CIRCUITPY_USB_CONNECTING_DELAY * 1024 - supervisor_ticks_ms64(); + if (connecting_delay_msec > 0) { + common_hal_time_delay_ms(connecting_delay_msec * 1000 / 1024); + } + + // If connected, wait for the program to be running at least as long as + // CIRCUITPY_USB_CONNECTED_DEEP_SLEEP_DELAY. This allows a user to ctrl-C the running + // program in case it is in a tight deep sleep loop that would otherwise be difficult + // or impossible to interrupt. + // Indicate that we're delaying with the SAFE_MODE color. + int64_t delay_before_sleeping_msec = + supervisor_ticks_ms64() - CIRCUITPY_USB_CONNECTED_DEEP_SLEEP_DELAY * 1000; + if (supervisor_workflow_connecting() && delay_before_sleeping_msec > 0) { + temp_status_color(SAFE_MODE); + common_hal_time_delay_ms(delay_before_sleeping_msec); + clear_temp_status(); + } + + common_hal_alarm_exit_and_deep_sleep_until_alarms(n_args, args); + // Does not return. return mp_const_none; } MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(alarm_exit_and_deep_sleep_until_alarms_obj, 1, MP_OBJ_FUN_ARGS_MAX, alarm_exit_and_deep_sleep_until_alarms); diff --git a/shared-bindings/alarm/__init__.h b/shared-bindings/alarm/__init__.h index 0f084c78e8..968136345c 100644 --- a/shared-bindings/alarm/__init__.h +++ b/shared-bindings/alarm/__init__.h @@ -32,8 +32,7 @@ #include "common-hal/alarm/__init__.h" extern mp_obj_t common_hal_alarm_sleep_until_alarms(size_t n_alarms, const mp_obj_t *alarms); -extern bool common_hal_alarm_enable_deep_sleep_alarms(void); -extern void common_hal_alarm_set_deep_sleep_alarms(size_t n_alarms, const mp_obj_t *alarms); +extern void common_hal_alarm_exit_and_deep_sleep_until_alarms(size_t n_alarms, const mp_obj_t *alarms); // Used by wake-up code. extern void common_hal_alarm_set_wake_alarm(mp_obj_t alarm); diff --git a/shared-bindings/alarm/pin/PinAlarm.c b/shared-bindings/alarm/pin/PinAlarm.c index ff7b19ca1f..fadd1b0d4a 100644 --- a/shared-bindings/alarm/pin/PinAlarm.c +++ b/shared-bindings/alarm/pin/PinAlarm.c @@ -41,7 +41,7 @@ //| def __init__(self, *pins: microcontroller.Pin, value: bool, all_same_value: bool = False, edge: bool = False, pull: bool = False) -> None: //| """Create an alarm triggered by a `microcontroller.Pin` level. The alarm is not active //| until it is passed to an `alarm`-enabling function, such as `alarm.sleep_until_alarms()` or -//| `alarm.set_deep_sleep_alarms()`. +//| `alarm.exit_and_deep_sleep_until_alarms()`. //| //| :param microcontroller.Pin \*pins: The pins to monitor. On some ports, the choice of pins //| may be limited due to hardware restrictions, particularly for deep-sleep alarms. diff --git a/shared-bindings/alarm/time/TimeAlarm.c b/shared-bindings/alarm/time/TimeAlarm.c index 864ece284e..6339b850c6 100644 --- a/shared-bindings/alarm/time/TimeAlarm.c +++ b/shared-bindings/alarm/time/TimeAlarm.c @@ -24,25 +24,32 @@ * THE SOFTWARE. */ -#include "shared-bindings/board/__init__.h" -#include "shared-bindings/microcontroller/__init__.h" -#include "shared-bindings/alarm/time/TimeAlarm.h" - #include "py/nlr.h" #include "py/obj.h" #include "py/objproperty.h" #include "py/runtime.h" + +#include "shared-bindings/time/__init__.h" +#include "shared-bindings/alarm/time/TimeAlarm.h" + #include "supervisor/shared/translate.h" +#if MICROPY_LONGINT_IMPL != MICROPY_LONGINT_IMPL_NONE +mp_obj_t MP_WEAK rtc_get_time_source_time(void) { + mp_raise_RuntimeError(translate("RTC is not supported on this board")); +} +#endif + //| class TimeAlarm: -//| """Trigger an alarm when `time.monotonic()` reaches the given value.""" +//| """Trigger an alarm when the specified time is reached.""" //| -//| def __init__(self, monotonic_time: float) -> None: +//| def __init__(self, monotonic_time: Optional[Float] = None, epoch_time: Optional[int] = None) -> None: //| """Create an alarm that will be triggered when `time.monotonic()` would equal -//| ``monotonic_time``. +//| ``monotonic_time``, or when `time.time()` would equal ``epoch_time``. +//| Only one of the two arguments can be given. //| The alarm is not active until it is passed to an //| `alarm`-enabling function, such as `alarm.sleep_until_alarms()` or -//| `alarm.set_deep_sleep_alarms()`. +//| `alarm.exit_and_deep_sleep_until_alarms()`. //| //| If the given time is in the past when sleep occurs, the alarm will be triggered //| immediately. @@ -50,21 +57,64 @@ //| ... //| STATIC mp_obj_t alarm_time_time_alarm_make_new(const mp_obj_type_t *type, - mp_uint_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_uint_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { alarm_time_time_alarm_obj_t *self = m_new_obj(alarm_time_time_alarm_obj_t); self->base.type = &alarm_time_time_alarm_type; - mp_float_t secs = mp_obj_get_float(args[0]); + enum { ARG_monotonic_time, ARG_epoch_time }; + static const mp_arg_t allowed_args[] = { + { MP_QSTR_monotonic_time, MP_ARG_KW_ONLY | MP_ARG_OBJ, {.u_obj = mp_const_none} }, + { MP_QSTR_epoch_time, MP_ARG_KW_ONLY | MP_ARG_OBJ, {.u_obj = mp_const_none} }, + }; - common_hal_alarm_time_time_alarm_construct(self, secs); + 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); + + bool have_monotonic = args[ARG_monotonic_time].u_obj != mp_const_none; + bool have_epoch = args[ARG_epoch_time].u_obj != mp_const_none; + + if (!(have_monotonic ^ have_epoch)) { + mp_raise_ValueError(translate("Supply one of monotonic_time or epoch_time")); + } + + mp_float_t monotonic_time = 0; // To avoid compiler warning. + if (have_monotonic) { + monotonic_time = mp_obj_get_float(args[ARG_monotonic_time].u_obj); + } + + mp_float_t monotonic_time_now = common_hal_time_monotonic_ms() / 1000.0; + + if (have_epoch) { +#if MICROPY_LONGINT_IMPL == MICROPY_LONGINT_IMPL_NONE + mp_raise_ValueError(translate("epoch_time not supported on this board")); +#else + mp_uint_t epoch_time_secs = mp_obj_int_get_checked(args[ARG_epoch_time].u_obj); + + timeutils_struct_time_t tm; + struct_time_to_tm(rtc_get_time_source_time(), &tm); + mp_uint_t epoch_secs_now = timeutils_seconds_since_epoch(tm.tm_year, tm.tm_mon, tm.tm_mday, + tm.tm_hour, tm.tm_min, tm.tm_sec); + // How far in the future (in secs) is the requested time? + mp_int_t epoch_diff = epoch_time_secs - epoch_secs_now; + // Convert it to a future monotonic time. + monotonic_time = monotonic_time_now + epoch_diff; +#endif + } + + if (monotonic_time < monotonic_time_now) { + mp_raise_ValueError(translate("Time is in the past.")); + } + + common_hal_alarm_time_time_alarm_construct(self, monotonic_time); return MP_OBJ_FROM_PTR(self); } //| monotonic_time: float -//| """The time at which to trigger, based on the `time.monotonic()` clock.""" +//| """When this time is reached, the alarm will trigger, based on the `time.monotonic()` clock. +//| The time may be given as ``epoch_time`` in the constructor, but it is returned +//| by this property only as a `time.monotonic()` time. +//| """ //| STATIC mp_obj_t alarm_time_time_alarm_obj_get_monotonic_time(mp_obj_t self_in) { alarm_time_time_alarm_obj_t *self = MP_OBJ_TO_PTR(self_in); diff --git a/shared-bindings/microcontroller/__init__.h b/shared-bindings/microcontroller/__init__.h index 87284fc2e5..ac71de4247 100644 --- a/shared-bindings/microcontroller/__init__.h +++ b/shared-bindings/microcontroller/__init__.h @@ -43,8 +43,6 @@ extern void common_hal_mcu_enable_interrupts(void); extern void common_hal_mcu_on_next_reset(mcu_runmode_t runmode); extern void common_hal_mcu_reset(void); -extern void NORETURN common_hal_mcu_deep_sleep(void); - extern const mp_obj_dict_t mcu_pin_globals; extern const mcu_processor_obj_t common_hal_mcu_processor_obj; From 3cde6c3fdc46e3641748d5be25c9ee03a2528a64 Mon Sep 17 00:00:00 2001 From: Ernie Hershey Date: Fri, 27 Nov 2020 12:07:49 -0500 Subject: [PATCH 155/207] README typos --- README.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.rst b/README.rst index d21e8d8d3c..19992d284b 100644 --- a/README.rst +++ b/README.rst @@ -114,14 +114,14 @@ Behavior finishes or is interrupted. After it is done running, the vm and hardware is reinitialized. **This means you cannot read state from** ``code.py`` **in the REPL anymore.** CircuitPython's goal for this - change includes reduce confusion about pins and memory being used. + change includes reducing confusion about pins and memory being used. - After ``code.py`` the REPL can be entered by pressing any key. It no longer shares state with ``code.py`` so it is a fresh vm. - Autoreload state will be maintained across reload. - Adds a safe mode that does not run user code after a hard crash or brown out. The hope is that this will make it easier to fix code that causes nasty crashes by making it available through mass storage - after the crash. A reset (the button) is needed after its fixed to + after the crash. A reset (the button) is needed after it's fixed to get back into normal mode. - RGB status LED indicating CircuitPython state, and errors through a sequence of colored flashes. - Re-runs ``code.py`` or other main file after file system writes over USB mass storage. (Disable with From 518328c71e5fc0c81218d7ee7dfbf9d0f3cb0ea6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iv=C3=A1n=20Montiel=20Cardona?= Date: Thu, 26 Nov 2020 23:24:10 +0000 Subject: [PATCH 156/207] Translated using Weblate (Spanish) Currently translated at 100.0% (864 of 864 strings) Translation: CircuitPython/main Translate-URL: https://hosted.weblate.org/projects/circuitpython/main/es/ --- locale/es.po | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/locale/es.po b/locale/es.po index 1a02843ed7..6b0fde563c 100644 --- a/locale/es.po +++ b/locale/es.po @@ -8,8 +8,8 @@ msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2020-11-24 15:40-0500\n" -"PO-Revision-Date: 2020-11-26 03:11+0000\n" -"Last-Translator: Daniel Bravo Darriba \n" +"PO-Revision-Date: 2020-11-27 18:34+0000\n" +"Last-Translator: Iván Montiel Cardona \n" "Language-Team: \n" "Language: es\n" "MIME-Version: 1.0\n" @@ -1449,7 +1449,7 @@ msgstr "Solo hay capacidad para direcciones IPv4" #: ports/esp32s2/common-hal/socketpool/SocketPool.c msgid "Only IPv4 sockets supported" -msgstr "" +msgstr "Solo se admiten sockets IPv4" #: shared-module/displayio/OnDiskBitmap.c #, c-format From 884028c7483e33ff10b8cffc9eceeac397dcae09 Mon Sep 17 00:00:00 2001 From: sporeball Date: Thu, 26 Nov 2020 18:20:45 +0000 Subject: [PATCH 157/207] Translated using Weblate (Japanese) Currently translated at 69.2% (598 of 864 strings) Translation: CircuitPython/main Translate-URL: https://hosted.weblate.org/projects/circuitpython/main/ja/ --- locale/ja.po | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/locale/ja.po b/locale/ja.po index 2076bbabfd..bacf0df812 100644 --- a/locale/ja.po +++ b/locale/ja.po @@ -8,8 +8,8 @@ msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2020-11-24 15:40-0500\n" -"PO-Revision-Date: 2020-11-25 01:11+0000\n" -"Last-Translator: Mitsuharu Aoyama \n" +"PO-Revision-Date: 2020-11-27 18:34+0000\n" +"Last-Translator: sporeball \n" "Language-Team: none\n" "Language: ja\n" "MIME-Version: 1.0\n" @@ -3757,7 +3757,7 @@ msgstr "" #: shared-module/displayio/Shape.c msgid "x value out of bounds" -msgstr "" +msgstr "xが範囲外" #: shared-bindings/displayio/Shape.c msgid "y should be an int" From e308a9ec1134412f6194358790176d17b0724ef1 Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Fri, 27 Nov 2020 16:02:17 -0500 Subject: [PATCH 158/207] working! PinAlarm not implemented yet. --- locale/circuitpython.pot | 25 +++- ports/esp32s2/common-hal/alarm/__init__.c | 71 +++++++++- .../common-hal/microcontroller/__init__.c | 3 - shared-bindings/alarm/__init__.c | 122 ++++++++++++------ shared-bindings/alarm/__init__.h | 1 + shared-bindings/alarm/pin/PinAlarm.c | 6 +- supervisor/shared/workflow.c | 4 +- 7 files changed, 175 insertions(+), 57 deletions(-) diff --git a/locale/circuitpython.pot b/locale/circuitpython.pot index 1532a67b54..36fd5f647c 100644 --- a/locale/circuitpython.pot +++ b/locale/circuitpython.pot @@ -8,11 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -<<<<<<< HEAD -"POT-Creation-Date: 2020-11-25 15:08-0500\n" -======= -"POT-Creation-Date: 2020-11-11 16:30+0530\n" ->>>>>>> adafruit/main +"POT-Creation-Date: 2020-11-27 16:03-0500\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -301,6 +297,7 @@ msgid "All I2C peripherals are in use" msgstr "" #: ports/esp32s2/common-hal/countio/Counter.c +#: ports/esp32s2/common-hal/frequencyio/FrequencyIn.c #: ports/esp32s2/common-hal/rotaryio/IncrementalEncoder.c msgid "All PCNT units in use" msgstr "" @@ -337,6 +334,7 @@ msgstr "" #: ports/atmel-samd/common-hal/pulseio/PulseIn.c #: ports/atmel-samd/common-hal/pulseio/PulseOut.c #: ports/cxd56/common-hal/pulseio/PulseOut.c +#: ports/esp32s2/common-hal/frequencyio/FrequencyIn.c #: ports/esp32s2/common-hal/neopixel_write/__init__.c #: ports/esp32s2/common-hal/pulseio/PulseIn.c #: ports/esp32s2/common-hal/pulseio/PulseOut.c @@ -1098,6 +1096,7 @@ msgid "Invalid byteorder string" msgstr "" #: ports/atmel-samd/common-hal/frequencyio/FrequencyIn.c +#: ports/esp32s2/common-hal/frequencyio/FrequencyIn.c msgid "Invalid capture period. Valid range: 1 - 500" msgstr "" @@ -1511,7 +1510,7 @@ msgid "Pin number already reserved by EXTI" msgstr "" #: ports/esp32s2/common-hal/alarm/__init__.c -msgid "PinAlarm deep sleep not yet implemented" +msgid "PinAlarm not yet implemented" msgstr "" #: shared-bindings/rgbmatrix/RGBMatrix.c @@ -1575,7 +1574,7 @@ msgstr "" msgid "RTC calibration is not supported on this board" msgstr "" -#: shared-bindings/time/__init__.c +#: shared-bindings/alarm/time/TimeAlarm.c shared-bindings/time/__init__.c msgid "RTC is not supported on this board" msgstr "" @@ -1721,6 +1720,10 @@ msgstr "" msgid "Supply at least one UART pin" msgstr "" +#: shared-bindings/alarm/time/TimeAlarm.c +msgid "Supply one of monotonic_time or epoch_time" +msgstr "" + #: shared-bindings/gnss/GNSS.c msgid "System entry must be gnss.SatelliteSystem" msgstr "" @@ -1784,6 +1787,10 @@ msgstr "" msgid "Tile width must exactly divide bitmap width" msgstr "" +#: shared-bindings/alarm/time/TimeAlarm.c +msgid "Time is in the past." +msgstr "" + #: ports/nrf/common-hal/_bleio/Adapter.c #, c-format msgid "Timeout is too long: Maximum timeout length is %d seconds" @@ -2498,6 +2505,10 @@ msgstr "" msgid "end_x should be an int" msgstr "" +#: shared-bindings/alarm/time/TimeAlarm.c +msgid "epoch_time not supported on this board" +msgstr "" + #: ports/nrf/common-hal/busio/UART.c #, c-format msgid "error = 0x%08lX" diff --git a/ports/esp32s2/common-hal/alarm/__init__.c b/ports/esp32s2/common-hal/alarm/__init__.c index 767b0de70e..e044103bce 100644 --- a/ports/esp32s2/common-hal/alarm/__init__.c +++ b/ports/esp32s2/common-hal/alarm/__init__.c @@ -37,6 +37,7 @@ #include "esp_log.h" #include "esp_sleep.h" +#include "esp_wifi.h" STATIC mp_obj_tuple_t *_deep_sleep_alarms; @@ -77,13 +78,14 @@ mp_obj_t common_hal_alarm_get_wake_alarm(void) { return mp_const_none; } -STATIC void setup_alarms(size_t n_alarms, const mp_obj_t *alarms) { +// Set up light sleep or deep sleep alarms. +STATIC void setup_sleep_alarms(size_t n_alarms, const mp_obj_t *alarms) { bool time_alarm_set = false; alarm_time_time_alarm_obj_t *time_alarm = MP_OBJ_NULL; for (size_t i = 0; i < n_alarms; i++) { if (MP_OBJ_IS_TYPE(alarms[i], &alarm_pin_pin_alarm_type)) { - mp_raise_NotImplementedError(translate("PinAlarm deep sleep not yet implemented")); + mp_raise_NotImplementedError(translate("PinAlarm not yet implemented")); } else if (MP_OBJ_IS_TYPE(alarms[i], &alarm_time_time_alarm_type)) { if (time_alarm_set) { @@ -98,23 +100,82 @@ STATIC void setup_alarms(size_t n_alarms, const mp_obj_t *alarms) { // Compute how long to actually sleep, considering the time now. mp_float_t now_secs = uint64_to_float(common_hal_time_monotonic_ms()) / 1000.0f; mp_float_t wakeup_in_secs = MAX(0.0f, time_alarm->monotonic_time - now_secs); - esp_sleep_enable_timer_wakeup((uint64_t) (wakeup_in_secs * 1000000)); + const uint64_t sleep_for_us = (uint64_t) (wakeup_in_secs * 1000000); + ESP_LOGI("ALARM", "Sleep for us: %lld", sleep_for_us); + esp_sleep_enable_timer_wakeup(sleep_for_us); } } +mp_obj_t common_hal_alarm_wait_until_alarms(size_t n_alarms, const mp_obj_t *alarms) { + if (n_alarms == 0) { + return mp_const_none; + } + + bool time_alarm_set = false; + alarm_time_time_alarm_obj_t *time_alarm = MP_OBJ_NULL; + + for (size_t i = 0; i < n_alarms; i++) { + if (MP_OBJ_IS_TYPE(alarms[i], &alarm_pin_pin_alarm_type)) { + mp_raise_NotImplementedError(translate("PinAlarm not yet implemented")); + } + else if (MP_OBJ_IS_TYPE(alarms[i], &alarm_time_time_alarm_type)) { + if (time_alarm_set) { + mp_raise_ValueError(translate("Only one alarm.time alarm can be set.")); + } + time_alarm = MP_OBJ_TO_PTR(alarms[i]); + time_alarm_set = true; + } + } + + ESP_LOGI("ALARM", "waiting for alarms"); + + if (time_alarm_set && n_alarms == 1) { + // If we're only checking time, avoid a polling loop, so maybe we can save some power. + const mp_float_t now_secs = uint64_to_float(common_hal_time_monotonic_ms()) / 1000.0f; + const mp_float_t wakeup_in_secs = MAX(0.0f, time_alarm->monotonic_time - now_secs); + const uint32_t delay_ms = (uint32_t) (wakeup_in_secs * 1000.0f); + ESP_LOGI("ALARM", "Delay for ms: %d", delay_ms); + common_hal_time_delay_ms((uint32_t) delay_ms); + } else { + // Poll for alarms. + while (true) { + RUN_BACKGROUND_TASKS; + // Allow ctrl-C interrupt. + if (mp_hal_is_interrupted()) { + return mp_const_none; + } + + // TODO: Check PinAlarms. + + if (time_alarm != MP_OBJ_NULL && + common_hal_time_monotonic_ms() * 1000.f >= time_alarm->monotonic_time) { + return time_alarm; + } + } + } + + return mp_const_none; +} + mp_obj_t common_hal_alarm_sleep_until_alarms(size_t n_alarms, const mp_obj_t *alarms) { - setup_alarms(n_alarms, alarms); + if (n_alarms == 0) { + return mp_const_none; + } + + setup_sleep_alarms(n_alarms, alarms); // Shut down wifi cleanly. esp_wifi_stop(); + ESP_LOGI("ALARM", "start light sleep"); esp_light_sleep_start(); return common_hal_alarm_get_wake_alarm(); } void common_hal_alarm_exit_and_deep_sleep_until_alarms(size_t n_alarms, const mp_obj_t *alarms) { - setup_alarms(n_alarms, alarms); + setup_sleep_alarms(n_alarms, alarms); // Shut down wifi cleanly. esp_wifi_stop(); + ESP_LOGI("ALARM", "start deep sleep"); esp_deep_sleep_start(); } diff --git a/ports/esp32s2/common-hal/microcontroller/__init__.c b/ports/esp32s2/common-hal/microcontroller/__init__.c index 184f5be696..b7bea4e6b8 100644 --- a/ports/esp32s2/common-hal/microcontroller/__init__.c +++ b/ports/esp32s2/common-hal/microcontroller/__init__.c @@ -42,9 +42,6 @@ #include "freertos/FreeRTOS.h" -#include "esp_sleep.h" -#include "esp_wifi.h" - void common_hal_mcu_delay_us(uint32_t delay) { mp_hal_delay_us(delay); } diff --git a/shared-bindings/alarm/__init__.c b/shared-bindings/alarm/__init__.c index 4c2189c0d0..195ec63745 100644 --- a/shared-bindings/alarm/__init__.c +++ b/shared-bindings/alarm/__init__.c @@ -25,40 +25,46 @@ */ #include "py/obj.h" +#include "py/reload.h" #include "py/runtime.h" #include "shared-bindings/alarm/__init__.h" #include "shared-bindings/alarm/pin/PinAlarm.h" #include "shared-bindings/alarm/time/TimeAlarm.h" +#include "shared-bindings/supervisor/Runtime.h" #include "shared-bindings/time/__init__.h" -#include "supervisor/shared/rgb_led_status.h" +#include "supervisor/shared/autoreload.h" #include "supervisor/shared/workflow.h" -// Wait this long to see if USB is being connected (enumeration starting). -#define CIRCUITPY_USB_CONNECTING_DELAY 1 -// Wait this long before going into deep sleep if connected. This -// allows the user to ctrl-C before deep sleep starts. -#define CIRCUITPY_USB_CONNECTED_DEEP_SLEEP_DELAY 5 +// Wait this long imediately after startup to see if we are connected to USB. +#define CIRCUITPY_USB_CONNECTED_SLEEP_DELAY 5 -//| """Power-saving light and deep sleep. Alarms can be set to wake up from sleep. +//| """Alarms and sleep //| -//| The `alarm` module provides sleep related functionality. There are two supported levels of -//| sleep, light and deep. +//| Provides alarms that trigger based on time intervals or on external events, such as pin +//| changes. +//| The program can simply wait for these alarms, or go into a sleep state and +//| and be awoken when they trigger. //| -//| Light sleep leaves the CPU and RAM powered so that CircuitPython can resume where it left off -//| after being woken up. CircuitPython automatically goes into a light sleep when `time.sleep()` is -//| called. To light sleep until a non-time alarm use `alarm.sleep_until_alarms()`. Any active -//| peripherals, such as I2C, are left on. +//| There are two supported levels of sleep: light sleep and deep sleep. //| -//| Deep sleep shuts down power to nearly all of the chip including the CPU and RAM. This can save -//| a more significant amount of power, but CircuitPython must start ``code.py`` from the beginning when +//| Light sleep leaves the CPU and RAM powered so the program can resume after sleeping. +//| +//| *However, note that on some platforms, light sleep will shut down some communications, including +//| WiFi and/or Bluetooth.* +//| +//| Deep sleep shuts down power to nearly all of the microcontroller including the CPU and RAM. This can save +//| a more significant amount of power, but CircuitPython must restart ``code.py`` from the beginning when //| awakened. //| """ //| //| wake_alarm: Alarm -//| """The most recent alarm to wake us up from a sleep (light or deep.)""" +//| """The most recently triggered alarm. If CircuitPython was sleeping, the alarm the woke it from sleep.""" //| + +// wake_alarm is implemented as a dictionary entry, so there's no code here. + void validate_objs_are_alarms(size_t n_args, const mp_obj_t *objs) { for (size_t i = 0; i < n_args; i++) { if (MP_OBJ_IS_TYPE(objs[i], &alarm_pin_pin_alarm_type) || @@ -69,9 +75,36 @@ void validate_objs_are_alarms(size_t n_args, const mp_obj_t *objs) { } } +//| def wait_until_alarms(*alarms: Alarm) -> Alarm: +//| """Wait for one of the alarms to trigger. The triggering alarm is returned. +//| is returned, and is also available as `alarm.wake_alarm`. Nothing is shut down +//| or interrupted. Power consumption will be reduced if possible. +//| +//| If no alarms are specified, return immediately. +//| """ +//| ... +//| +STATIC mp_obj_t alarm_wait_until_alarms(size_t n_args, const mp_obj_t *args) { + validate_objs_are_alarms(n_args, args); + common_hal_alarm_wait_until_alarms(n_args, args); + return mp_const_none; +} +MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(alarm_wait_until_alarms_obj, 1, MP_OBJ_FUN_ARGS_MAX, alarm_wait_until_alarms); + //| def sleep_until_alarms(*alarms: Alarm) -> Alarm: //| """Go into a light sleep until awakened one of the alarms. The alarm causing the wake-up -//| is returned, and is also available as `alarm.wake_alarm`. +//| is returned, and is also available as `alarm.wake_alarm`. +//| +//| Some functionality may be shut down during sleep. On ESP32-S2, WiFi is turned off, +//| and existing connections are broken. +//| +//| If no alarms are specified, return immediately. +//| +//| **If CircuitPython is connected to a host computer,** `alarm.sleep_until_alarms()` +//| **does not go into light sleep.** +//| Instead, light sleep is simulated by doing `alarm.wait_until_alarms()`, +//| This allows the user to interrupt an existing program with ctrl-C, +//| and to edit the files in CIRCUITPY, which would not be possible in true light sleep //| """ //| ... //| @@ -84,47 +117,60 @@ MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(alarm_sleep_until_alarms_obj, 1, MP_OBJ_FUN_ //| def exit_and_deep_sleep_until_alarms(*alarms: Alarm) -> None: //| """Exit the program and go into a deep sleep, until awakened by one of the alarms. +//| This function does not return. //| //| When awakened, the microcontroller will restart and will run ``boot.py`` and ``code.py`` //| from the beginning. //| -//| An alarm equivalent to the one that caused the wake-up is available as `alarm.wake_alarm`. +//| After restart, an alarm *equivalent* to the one that caused the wake-up +//| will be available as `alarm.wake_alarm`. //| Its type and/or attributes may not correspond exactly to the original alarm. //| For time-base alarms, currently, an `alarm.time.TimeAlarm()` is created. //| //| If no alarms are specified, the microcontroller will deep sleep until reset. //| -//| If CircuitPython is unconnected to a host computer, go into deep sleep immediately. -//| But if it already connected or in the process of connecting to a host computer, wait at least -//| five seconds after starting code.py before entering deep sleep. -//| This allows interrupting a program that would otherwise go into deep sleep too quickly -//| to interrupt from the keyboard. +//| **If CircuitPython is connected to a host computer, `alarm.exit_and_deep_sleep_until_alarms()` +//| does not go into deep sleep.** +//| Instead, deep sleep is simulated by first doing `alarm.wait_until_alarms()`, +//| and then, when an alarm triggers, by restarting CircuitPython. +//| This allows the user to interrupt an existing program with ctrl-C, +//| and to edit the files in CIRCUITPY, which would not be possible in true deep sleep. +//| +//| Here is skeletal example that deep-sleeps and restarts every 60 seconds: +//| +//| .. code-block:: python +//| +//| import alarm +//| import time +//| +//| print("Waking up") +//| +//| # Set an alarm for 60 seconds from now. +//| time_alarm = alarm.time.TimeAlarm(monotonic_time=time.monotonic() + 60) +//| +//| # Deep sleep until the alarm goes off. Then restart the program. +//| alarm.exit_and_deep_sleep_until_alarms(time_alarm) //| """ //| ... //| STATIC mp_obj_t alarm_exit_and_deep_sleep_until_alarms(size_t n_args, const mp_obj_t *args) { validate_objs_are_alarms(n_args, args); - int64_t connecting_delay_msec = CIRCUITPY_USB_CONNECTING_DELAY * 1024 - supervisor_ticks_ms64(); + // Make sure we have been awake long enough for USB to connect (enumeration delay). + int64_t connecting_delay_msec = CIRCUITPY_USB_CONNECTED_SLEEP_DELAY * 1024 - supervisor_ticks_ms64(); if (connecting_delay_msec > 0) { common_hal_time_delay_ms(connecting_delay_msec * 1000 / 1024); } - // If connected, wait for the program to be running at least as long as - // CIRCUITPY_USB_CONNECTED_DEEP_SLEEP_DELAY. This allows a user to ctrl-C the running - // program in case it is in a tight deep sleep loop that would otherwise be difficult - // or impossible to interrupt. - // Indicate that we're delaying with the SAFE_MODE color. - int64_t delay_before_sleeping_msec = - supervisor_ticks_ms64() - CIRCUITPY_USB_CONNECTED_DEEP_SLEEP_DELAY * 1000; - if (supervisor_workflow_connecting() && delay_before_sleeping_msec > 0) { - temp_status_color(SAFE_MODE); - common_hal_time_delay_ms(delay_before_sleeping_msec); - clear_temp_status(); + if (supervisor_workflow_active()) { + common_hal_alarm_wait_until_alarms(n_args, args); + reload_requested = true; + supervisor_set_run_reason(RUN_REASON_STARTUP); + mp_raise_reload_exception(); + } else { + common_hal_alarm_exit_and_deep_sleep_until_alarms(n_args, args); + // Does not return. } - - common_hal_alarm_exit_and_deep_sleep_until_alarms(n_args, args); - // Does not return. return mp_const_none; } MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(alarm_exit_and_deep_sleep_until_alarms_obj, 1, MP_OBJ_FUN_ARGS_MAX, alarm_exit_and_deep_sleep_until_alarms); diff --git a/shared-bindings/alarm/__init__.h b/shared-bindings/alarm/__init__.h index 968136345c..26dbb2897c 100644 --- a/shared-bindings/alarm/__init__.h +++ b/shared-bindings/alarm/__init__.h @@ -31,6 +31,7 @@ #include "common-hal/alarm/__init__.h" +extern mp_obj_t common_hal_alarm_wait_until_alarms(size_t n_alarms, const mp_obj_t *alarms); extern mp_obj_t common_hal_alarm_sleep_until_alarms(size_t n_alarms, const mp_obj_t *alarms); extern void common_hal_alarm_exit_and_deep_sleep_until_alarms(size_t n_alarms, const mp_obj_t *alarms); diff --git a/shared-bindings/alarm/pin/PinAlarm.c b/shared-bindings/alarm/pin/PinAlarm.c index fadd1b0d4a..a6497d4cde 100644 --- a/shared-bindings/alarm/pin/PinAlarm.c +++ b/shared-bindings/alarm/pin/PinAlarm.c @@ -56,7 +56,7 @@ //| to ``value`` to trigger the alarm. On some ports, edge-triggering may not be available, //| particularly for deep-sleep alarms. //| :param bool pull: Enable a pull-up or pull-down which pulls the pin to the level opposite -//| opposite that of ``value``. For instance, if ``value`` is set to ``True``, setting ``pull`` +//| that of ``value``. For instance, if ``value`` is set to ``True``, setting ``pull`` //| to ``True`` will enable a pull-down, to hold the pin low normally until an outside signal //| pulls it high. //| """ @@ -89,7 +89,7 @@ STATIC mp_obj_t alarm_pin_pin_alarm_make_new(const mp_obj_type_t *type, mp_uint_ return MP_OBJ_FROM_PTR(self); } -//| pins: Tuple[microcontroller.pin] +//| pins: Tuple[microcontroller.Pin] //| """The trigger pins.""" //| STATIC mp_obj_t alarm_pin_pin_alarm_obj_get_pins(mp_obj_t self_in) { @@ -105,7 +105,7 @@ const mp_obj_property_t alarm_pin_pin_alarm_pins_obj = { (mp_obj_t)&mp_const_none_obj}, }; -//| value: Tuple[microcontroller.pin] +//| value: Tuple[microcontroller.Pin] //| """The value on which to trigger.""" //| STATIC mp_obj_t alarm_pin_pin_alarm_obj_get_value(mp_obj_t self_in) { diff --git a/supervisor/shared/workflow.c b/supervisor/shared/workflow.c index 8e4ec16c0b..4986c09570 100644 --- a/supervisor/shared/workflow.c +++ b/supervisor/shared/workflow.c @@ -33,8 +33,10 @@ void supervisor_workflow_reset(void) { // Return true as soon as USB communication with host has started, // even before enumeration is done. +// Not that some chips don't notice when USB is unplugged after first being plugged in, +// so this is not perfect, but tud_suspended() check helps. bool supervisor_workflow_connecting(void) { - return tud_connected(); + return tud_connected() && !tud_suspended(); } // Return true if host has completed connection to us (such as USB enumeration). From f96475cbbf5417531bbdd302b720658c5fa0f541 Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Fri, 27 Nov 2020 16:24:36 -0500 Subject: [PATCH 159/207] update Requests; rolled back by accident --- frozen/Adafruit_CircuitPython_Requests | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frozen/Adafruit_CircuitPython_Requests b/frozen/Adafruit_CircuitPython_Requests index 43017e30a1..53902152c6 160000 --- a/frozen/Adafruit_CircuitPython_Requests +++ b/frozen/Adafruit_CircuitPython_Requests @@ -1 +1 @@ -Subproject commit 43017e30a1e772b67ac68293a944e863c031e389 +Subproject commit 53902152c674b0ba31536b50291f7ddd28960f47 From 65e2fe46540abc09f341c39d877eafeb791933f1 Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Fri, 27 Nov 2020 23:27:15 -0500 Subject: [PATCH 160/207] fix stub problems; touch up doc --- shared-bindings/_typing/__init__.pyi | 5 ++++- shared-bindings/alarm/time/TimeAlarm.c | 2 +- shared-bindings/microcontroller/__init__.c | 9 --------- tools/extract_pyi.py | 2 +- 4 files changed, 6 insertions(+), 12 deletions(-) diff --git a/shared-bindings/_typing/__init__.pyi b/shared-bindings/_typing/__init__.pyi index 2716936860..cc4a0a4391 100644 --- a/shared-bindings/_typing/__init__.pyi +++ b/shared-bindings/_typing/__init__.pyi @@ -2,6 +2,9 @@ from typing import Union +import alarm +import alarm.pin +import alarm.time import array import audiocore import audiomixer @@ -61,5 +64,5 @@ Alarm = Union[ - `alarm.pin.PinAlarm` - `alarm.time.TimeAlarm` - You can use these alarms to wake from light or deep sleep. + You can use these alarms to wake up from light or deep sleep. """ diff --git a/shared-bindings/alarm/time/TimeAlarm.c b/shared-bindings/alarm/time/TimeAlarm.c index 6339b850c6..17a4faac25 100644 --- a/shared-bindings/alarm/time/TimeAlarm.c +++ b/shared-bindings/alarm/time/TimeAlarm.c @@ -43,7 +43,7 @@ mp_obj_t MP_WEAK rtc_get_time_source_time(void) { //| class TimeAlarm: //| """Trigger an alarm when the specified time is reached.""" //| -//| def __init__(self, monotonic_time: Optional[Float] = None, epoch_time: Optional[int] = None) -> None: +//| def __init__(self, monotonic_time: Optional[float] = None, epoch_time: Optional[int] = None) -> None: //| """Create an alarm that will be triggered when `time.monotonic()` would equal //| ``monotonic_time``, or when `time.time()` would equal ``epoch_time``. //| Only one of the two arguments can be given. diff --git a/shared-bindings/microcontroller/__init__.c b/shared-bindings/microcontroller/__init__.c index d09cf8f445..8a77d1df5b 100644 --- a/shared-bindings/microcontroller/__init__.c +++ b/shared-bindings/microcontroller/__init__.c @@ -147,15 +147,6 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_0(mcu_reset_obj, mcu_reset); //| This object is the sole instance of `watchdog.WatchDogTimer` when available or ``None`` otherwise.""" //| - -//| """:mod:`microcontroller.pin` --- Microcontroller pin names -//| -------------------------------------------------------- -//| -//| .. module:: microcontroller.pin -//| :synopsis: Microcontroller pin names -//| -//| References to pins as named by the microcontroller""" -//| const mp_obj_module_t mcu_pin_module = { .base = { &mp_type_module }, .globals = (mp_obj_dict_t*)&mcu_pin_globals, diff --git a/tools/extract_pyi.py b/tools/extract_pyi.py index b7ce584a1e..2730102ac0 100644 --- a/tools/extract_pyi.py +++ b/tools/extract_pyi.py @@ -19,7 +19,7 @@ import black IMPORTS_IGNORE = frozenset({'int', 'float', 'bool', 'str', 'bytes', 'tuple', 'list', 'set', 'dict', 'bytearray', 'slice', 'file', 'buffer', 'range', 'array', 'struct_time'}) IMPORTS_TYPING = frozenset({'Any', 'Optional', 'Union', 'Tuple', 'List', 'Sequence', 'NamedTuple', 'Iterable', 'Iterator', 'Callable', 'AnyStr', 'overload', 'Type'}) IMPORTS_TYPES = frozenset({'TracebackType'}) -CPY_TYPING = frozenset({'ReadableBuffer', 'WriteableBuffer', 'AudioSample', 'FrameBuffer'}) +CPY_TYPING = frozenset({'ReadableBuffer', 'WriteableBuffer', 'AudioSample', 'FrameBuffer', 'Alarm'}) def is_typed(node, allow_any=False): From 2830cc9433dc9954c781c5351f3051dcacaaa467 Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Fri, 27 Nov 2020 23:57:59 -0500 Subject: [PATCH 161/207] make translate --- locale/circuitpython.pot | 36 ++++++++++++++++++++++++++++++++++-- 1 file changed, 34 insertions(+), 2 deletions(-) diff --git a/locale/circuitpython.pot b/locale/circuitpython.pot index 38deb62d70..63d818da9c 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-11-24 15:40-0500\n" +"POT-Creation-Date: 2020-11-27 23:57-0500\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -1448,6 +1448,10 @@ msgid "" "%d bpp given" msgstr "" +#: ports/esp32s2/common-hal/alarm/__init__.c +msgid "Only one alarm.time alarm can be set." +msgstr "" + #: shared-module/displayio/ColorConverter.c msgid "Only one color can be transparent at a time" msgstr "" @@ -1505,6 +1509,10 @@ msgstr "" msgid "Pin number already reserved by EXTI" msgstr "" +#: ports/esp32s2/common-hal/alarm/__init__.c +msgid "PinAlarm not yet implemented" +msgstr "" + #: shared-bindings/rgbmatrix/RGBMatrix.c #, c-format msgid "" @@ -1566,7 +1574,7 @@ msgstr "" msgid "RTC calibration is not supported on this board" msgstr "" -#: shared-bindings/time/__init__.c +#: shared-bindings/alarm/time/TimeAlarm.c shared-bindings/time/__init__.c msgid "RTC is not supported on this board" msgstr "" @@ -1712,6 +1720,10 @@ msgstr "" msgid "Supply at least one UART pin" msgstr "" +#: shared-bindings/alarm/time/TimeAlarm.c +msgid "Supply one of monotonic_time or epoch_time" +msgstr "" + #: shared-bindings/gnss/GNSS.c msgid "System entry must be gnss.SatelliteSystem" msgstr "" @@ -1775,6 +1787,10 @@ msgstr "" msgid "Tile width must exactly divide bitmap width" msgstr "" +#: shared-bindings/alarm/time/TimeAlarm.c +msgid "Time is in the past." +msgstr "" + #: ports/nrf/common-hal/_bleio/Adapter.c #, c-format msgid "Timeout is too long: Maximum timeout length is %d seconds" @@ -2489,6 +2505,10 @@ msgstr "" msgid "end_x should be an int" msgstr "" +#: shared-bindings/alarm/time/TimeAlarm.c +msgid "epoch_time not supported on this board" +msgstr "" + #: ports/nrf/common-hal/busio/UART.c #, c-format msgid "error = 0x%08lX" @@ -2858,6 +2878,10 @@ msgstr "" msgid "invalid syntax for number" msgstr "" +#: ports/esp32s2/common-hal/alarm/pin/__init__.c +msgid "io must be rtc io" +msgstr "" + #: py/objtype.c msgid "issubclass() arg 1 must be a class" msgstr "" @@ -3545,6 +3569,10 @@ msgstr "" msgid "trapz is defined for 1D arrays of equal length" msgstr "" +#: ports/esp32s2/common-hal/alarm/pin/__init__.c +msgid "trigger level must be 0 or 1" +msgstr "" + #: extmod/ulab/code/linalg/linalg.c msgid "tuple index out of range" msgstr "" @@ -3687,6 +3715,10 @@ msgstr "" msgid "vectors must have same lengths" msgstr "" +#: ports/esp32s2/common-hal/alarm/pin/__init__.c +msgid "wakeup conflict" +msgstr "" + #: ports/esp32s2/common-hal/watchdog/WatchDogTimer.c msgid "watchdog not initialized" msgstr "" From 28d9e9186e6a9a153217535bd2d9f144672846bb Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Sat, 28 Nov 2020 10:12:46 -0500 Subject: [PATCH 162/207] Disable complex arithmetic on SAMD21 builds to make space --- ports/atmel-samd/mpconfigport.h | 1 + py/circuitpy_mpconfig.h | 2 ++ 2 files changed, 3 insertions(+) diff --git a/ports/atmel-samd/mpconfigport.h b/ports/atmel-samd/mpconfigport.h index ed10da9b9d..bce89e0b99 100644 --- a/ports/atmel-samd/mpconfigport.h +++ b/ports/atmel-samd/mpconfigport.h @@ -42,6 +42,7 @@ #define CIRCUITPY_MCU_FAMILY samd21 #define MICROPY_PY_SYS_PLATFORM "Atmel SAMD21" #define SPI_FLASH_MAX_BAUDRATE 8000000 +#define MICROPY_PY_BUILTINS_COMPLEX (0) #define MICROPY_PY_BUILTINS_NOTIMPLEMENTED (0) #define MICROPY_PY_FUNCTION_ATTRS (0) // MICROPY_PY_UJSON depends on MICROPY_PY_IO diff --git a/py/circuitpy_mpconfig.h b/py/circuitpy_mpconfig.h index 799217777c..4b847de38b 100644 --- a/py/circuitpy_mpconfig.h +++ b/py/circuitpy_mpconfig.h @@ -188,7 +188,9 @@ typedef long mp_off_t; #define MICROPY_COMP_FSTRING_LITERAL (MICROPY_CPYTHON_COMPAT) #define MICROPY_MODULE_WEAK_LINKS (0) #define MICROPY_PY_ALL_SPECIAL_METHODS (CIRCUITPY_FULL_BUILD) +#ifndef MICROPY_PY_BUILTINS_COMPLEX #define MICROPY_PY_BUILTINS_COMPLEX (CIRCUITPY_FULL_BUILD) +#endif #define MICROPY_PY_BUILTINS_FROZENSET (CIRCUITPY_FULL_BUILD) #define MICROPY_PY_BUILTINS_STR_CENTER (CIRCUITPY_FULL_BUILD) #define MICROPY_PY_BUILTINS_STR_PARTITION (CIRCUITPY_FULL_BUILD) From c7404a3ff89c738c002ec63448a58d56330dfcc3 Mon Sep 17 00:00:00 2001 From: Christian Walther Date: Sun, 11 Oct 2020 14:59:33 +0200 Subject: [PATCH 163/207] Add movable allocation system. This allows calls to `allocate_memory()` while the VM is running, it will then allocate from the GC heap (unless there is a suitable hole among the supervisor allocations), and when the VM exits and the GC heap is freed, the allocation will be moved to the bottom of the former GC heap and transformed into a proper supervisor allocation. Existing movable allocations will also be moved to defragment the supervisor heap and ensure that the next VM run gets as much memory as possible for the GC heap. By itself this breaks terminalio because it violates the assumption that supervisor_display_move_memory() still has access to an undisturbed heap to copy the tilegrid from. It will work in many cases, but if you're unlucky you will get garbled terminal contents after exiting from the vm run that created the display. This will be fixed in the following commit, which is separate to simplify review. --- main.c | 13 +- ports/atmel-samd/supervisor/port.c | 4 +- ports/cxd56/supervisor/port.c | 8 +- ports/esp32s2/supervisor/port.c | 8 +- ports/litex/supervisor/port.c | 4 +- ports/mimxrt10xx/supervisor/port.c | 7 +- ports/nrf/supervisor/port.c | 4 +- ports/stm/supervisor/port.c | 4 +- py/circuitpy_mpconfig.h | 4 + shared-module/rgbmatrix/RGBMatrix.c | 2 +- .../sharpdisplay/SharpMemoryFramebuffer.c | 2 +- shared-module/usb_midi/__init__.c | 2 +- supervisor/memory.h | 26 +- supervisor/port.h | 5 +- supervisor/shared/display.c | 4 +- .../shared/external_flash/external_flash.c | 2 +- supervisor/shared/memory.c | 279 +++++++++++++----- supervisor/shared/stack.c | 38 ++- supervisor/shared/stack.h | 6 +- 19 files changed, 284 insertions(+), 138 deletions(-) diff --git a/main.c b/main.c index 80b163f607..1389f524b6 100755 --- a/main.c +++ b/main.c @@ -123,15 +123,15 @@ void start_mp(supervisor_allocation* heap) { // to recover from limit hit. (Limit is measured in bytes.) mp_stack_ctrl_init(); - if (stack_alloc != NULL) { - mp_stack_set_limit(stack_alloc->length - 1024); + if (stack_get_bottom() != NULL) { + mp_stack_set_limit(stack_get_length() - 1024); } #if MICROPY_MAX_STACK_USAGE // _ezero (same as _ebss) is an int, so start 4 bytes above it. - if (stack_alloc != NULL) { - mp_stack_set_bottom(stack_alloc->ptr); + if (stack_get_bottom() != NULL) { + mp_stack_set_bottom(stack_get_bottom()); mp_stack_fill_with_sentinel(); } #endif @@ -148,7 +148,7 @@ void start_mp(supervisor_allocation* heap) { #endif #if MICROPY_ENABLE_GC - gc_init(heap->ptr, heap->ptr + heap->length / 4); + gc_init(heap->ptr, heap->ptr + get_allocation_length(heap) / 4); #endif mp_init(); mp_obj_list_init(mp_sys_path, 0); @@ -451,9 +451,6 @@ int __attribute__((used)) main(void) { // initialise the cpu and peripherals safe_mode_t safe_mode = port_init(); - // Init memory after the port in case the port needs to set aside memory. - memory_init(); - // Turn on LEDs init_status_leds(); rgb_led_status_init(); diff --git a/ports/atmel-samd/supervisor/port.c b/ports/atmel-samd/supervisor/port.c index d65d098257..fc1d1198e2 100644 --- a/ports/atmel-samd/supervisor/port.c +++ b/ports/atmel-samd/supervisor/port.c @@ -390,8 +390,8 @@ void reset_cpu(void) { reset(); } -supervisor_allocation* port_fixed_stack(void) { - return NULL; +bool port_has_fixed_stack(void) { + return false; } uint32_t *port_stack_get_limit(void) { diff --git a/ports/cxd56/supervisor/port.c b/ports/cxd56/supervisor/port.c index 086c2d198e..d69f357799 100644 --- a/ports/cxd56/supervisor/port.c +++ b/ports/cxd56/supervisor/port.c @@ -98,12 +98,8 @@ void reset_to_bootloader(void) { } } -supervisor_allocation _fixed_stack; - -supervisor_allocation* port_fixed_stack(void) { - _fixed_stack.ptr = port_stack_get_limit(); - _fixed_stack.length = (port_stack_get_top() - port_stack_get_limit()) * sizeof(uint32_t); - return &_fixed_stack; +bool port_has_fixed_stack(void) { + return true; } uint32_t *port_stack_get_limit(void) { diff --git a/ports/esp32s2/supervisor/port.c b/ports/esp32s2/supervisor/port.c index aff7dbda4d..264bdee974 100644 --- a/ports/esp32s2/supervisor/port.c +++ b/ports/esp32s2/supervisor/port.c @@ -193,12 +193,8 @@ uint32_t *port_stack_get_top(void) { return port_stack_get_limit() + ESP_TASK_MAIN_STACK / (sizeof(uint32_t) / sizeof(StackType_t)); } -supervisor_allocation _fixed_stack; - -supervisor_allocation* port_fixed_stack(void) { - _fixed_stack.ptr = port_stack_get_limit(); - _fixed_stack.length = (port_stack_get_top() - port_stack_get_limit()) * sizeof(uint32_t); - return &_fixed_stack; +bool port_has_fixed_stack(void) { + return true; } // Place the word to save just after our BSS section that gets blanked. diff --git a/ports/litex/supervisor/port.c b/ports/litex/supervisor/port.c index 02617b9af7..f5c362ea6e 100644 --- a/ports/litex/supervisor/port.c +++ b/ports/litex/supervisor/port.c @@ -98,8 +98,8 @@ void reset_cpu(void) { for(;;) {} } -supervisor_allocation* port_fixed_stack(void) { - return NULL; +bool port_has_fixed_stack(void) { + return false; } uint32_t *port_heap_get_bottom(void) { diff --git a/ports/mimxrt10xx/supervisor/port.c b/ports/mimxrt10xx/supervisor/port.c index e3fef373f8..1be2b10396 100644 --- a/ports/mimxrt10xx/supervisor/port.c +++ b/ports/mimxrt10xx/supervisor/port.c @@ -334,11 +334,8 @@ uint32_t *port_stack_get_top(void) { return &_ld_stack_top; } -supervisor_allocation _fixed_stack; -supervisor_allocation* port_fixed_stack(void) { - _fixed_stack.ptr = port_stack_get_limit(); - _fixed_stack.length = (port_stack_get_top() - port_stack_get_limit()) * sizeof(uint32_t); - return &_fixed_stack; +bool port_has_fixed_stack(void) { + return true; } uint32_t *port_heap_get_bottom(void) { diff --git a/ports/nrf/supervisor/port.c b/ports/nrf/supervisor/port.c index 493de43e0f..5f1c9f1ba9 100644 --- a/ports/nrf/supervisor/port.c +++ b/ports/nrf/supervisor/port.c @@ -251,8 +251,8 @@ uint32_t *port_heap_get_top(void) { return port_stack_get_top(); } -supervisor_allocation* port_fixed_stack(void) { - return NULL; +bool port_has_fixed_stack(void) { + return false; } uint32_t *port_stack_get_limit(void) { diff --git a/ports/stm/supervisor/port.c b/ports/stm/supervisor/port.c index a8aab00ff2..dba1cf21ee 100644 --- a/ports/stm/supervisor/port.c +++ b/ports/stm/supervisor/port.c @@ -267,8 +267,8 @@ uint32_t *port_heap_get_top(void) { return &_ld_heap_end; } -supervisor_allocation* port_fixed_stack(void) { - return NULL; +bool port_has_fixed_stack(void) { + return false; } uint32_t *port_stack_get_limit(void) { diff --git a/py/circuitpy_mpconfig.h b/py/circuitpy_mpconfig.h index 28fd4095c4..28fd6e9b00 100644 --- a/py/circuitpy_mpconfig.h +++ b/py/circuitpy_mpconfig.h @@ -858,6 +858,9 @@ extern const struct _mp_obj_module_t wifi_module; #include "supervisor/flash_root_pointers.h" +// From supervisor/memory.c +struct _supervisor_allocation_node; + #define CIRCUITPY_COMMON_ROOT_POINTERS \ const char *readline_hist[8]; \ vstr_t *repl_line; \ @@ -869,6 +872,7 @@ extern const struct _mp_obj_module_t wifi_module; FLASH_ROOT_POINTERS \ MEMORYMONITOR_ROOT_POINTERS \ NETWORK_ROOT_POINTERS \ + struct _supervisor_allocation_node* first_embedded_allocation; \ void supervisor_run_background_tasks_if_tick(void); #define RUN_BACKGROUND_TASKS (supervisor_run_background_tasks_if_tick()) diff --git a/shared-module/rgbmatrix/RGBMatrix.c b/shared-module/rgbmatrix/RGBMatrix.c index 94c3eda27f..1f144aedb5 100644 --- a/shared-module/rgbmatrix/RGBMatrix.c +++ b/shared-module/rgbmatrix/RGBMatrix.c @@ -220,7 +220,7 @@ void *common_hal_rgbmatrix_allocator_impl(size_t sz) { if (gc_alloc_possible()) { return m_malloc_maybe(sz + sizeof(void*), true); } else { - supervisor_allocation *allocation = allocate_memory(align32_size(sz), false); + supervisor_allocation *allocation = allocate_memory(align32_size(sz), false, false); return allocation ? allocation->ptr : NULL; } } diff --git a/shared-module/sharpdisplay/SharpMemoryFramebuffer.c b/shared-module/sharpdisplay/SharpMemoryFramebuffer.c index b199e98d63..aefb6b18de 100644 --- a/shared-module/sharpdisplay/SharpMemoryFramebuffer.c +++ b/shared-module/sharpdisplay/SharpMemoryFramebuffer.c @@ -40,7 +40,7 @@ #define SHARPMEM_BIT_VCOM_LSB (0x40) static void *hybrid_alloc(size_t sz) { - supervisor_allocation *allocation = allocate_memory(align32_size(sz), false); + supervisor_allocation *allocation = allocate_memory(align32_size(sz), false, false); if (allocation) { memset(allocation->ptr, 0, sz); return allocation->ptr; diff --git a/shared-module/usb_midi/__init__.c b/shared-module/usb_midi/__init__.c index 73a314b997..5afdd18213 100644 --- a/shared-module/usb_midi/__init__.c +++ b/shared-module/usb_midi/__init__.c @@ -45,7 +45,7 @@ void usb_midi_init(void) { uint16_t portout_size = align32_size(sizeof(usb_midi_portout_obj_t)); // For each embedded MIDI Jack in the descriptor we create a Port - usb_midi_allocation = allocate_memory(tuple_size + portin_size + portout_size, false); + usb_midi_allocation = allocate_memory(tuple_size + portin_size + portout_size, false, false); mp_obj_tuple_t *ports = (mp_obj_tuple_t *) usb_midi_allocation->ptr; ports->base.type = &mp_type_tuple; diff --git a/supervisor/memory.h b/supervisor/memory.h index f4359ca46e..4307e3f21d 100755 --- a/supervisor/memory.h +++ b/supervisor/memory.h @@ -33,23 +33,36 @@ #include #include +#include typedef struct { uint32_t* ptr; - uint32_t length; // in bytes } supervisor_allocation; -void memory_init(void); void free_memory(supervisor_allocation* allocation); + +// Find the allocation with the given ptr, NULL if not found. When called from the context of a +// supervisor_move_memory() callback, finds the allocation that had that ptr *before* the move, but +// the returned allocation already contains the ptr after the move. +// When called with NULL, may return either NULL or an unused allocation whose ptr is NULL (this is +// a feature used internally in allocate_memory to save code size). Passing the return value to +// free_memory() is a permissible no-op in either case. supervisor_allocation* allocation_from_ptr(void *ptr); + supervisor_allocation* allocate_remaining_memory(void); // Allocate a piece of a given length in bytes. If high_address is true then it should be allocated // at a lower address from the top of the stack. Otherwise, addresses will increase starting after -// statically allocated memory. -supervisor_allocation* allocate_memory(uint32_t length, bool high_address); +// statically allocated memory. If movable is false, memory will be taken from outside the GC heap +// and will stay stationary until freed. While the VM is running, this will fail unless a previous +// allocation of exactly matching length has recently been freed. If movable is true, memory will be +// taken from either outside or inside the GC heap, and when the VM exits, will be moved outside. +// The ptr of the returned supervisor_allocation will change at that point. If you need to be +// notified of that, add your own callback function at the designated place near the end of +// supervisor_move_memory(). +supervisor_allocation* allocate_memory(uint32_t length, bool high_address, bool movable); static inline uint16_t align32_size(uint16_t size) { if (size % 4 != 0) { @@ -58,7 +71,10 @@ static inline uint16_t align32_size(uint16_t size) { return size; } -// Called after the heap is freed in case the supervisor wants to save some values. +size_t get_allocation_length(supervisor_allocation* allocation); + +// Called after the GC heap is freed, transfers movable allocations from the GC heap to the +// supervisor heap and compacts the supervisor heap. void supervisor_move_memory(void); #endif // MICROPY_INCLUDED_SUPERVISOR_MEMORY_H diff --git a/supervisor/port.h b/supervisor/port.h index f5b3c15d14..5bc06bc4e1 100644 --- a/supervisor/port.h +++ b/supervisor/port.h @@ -61,7 +61,8 @@ uint32_t *port_stack_get_limit(void); // Get stack top address uint32_t *port_stack_get_top(void); -supervisor_allocation* port_fixed_stack(void); +// True if stack is not located inside heap (at the top) +bool port_has_fixed_stack(void); // Get heap bottom address uint32_t *port_heap_get_bottom(void); @@ -69,8 +70,6 @@ uint32_t *port_heap_get_bottom(void); // Get heap top address uint32_t *port_heap_get_top(void); -supervisor_allocation* port_fixed_heap(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/display.c b/supervisor/shared/display.c index a9ae258842..de45e2672f 100644 --- a/supervisor/shared/display.c +++ b/supervisor/shared/display.c @@ -82,7 +82,7 @@ void supervisor_start_terminal(uint16_t width_px, uint16_t height_px) { uint16_t total_tiles = width_in_tiles * height_in_tiles; // First try to allocate outside the heap. This will fail when the VM is running. - tilegrid_tiles = allocate_memory(align32_size(total_tiles), false); + tilegrid_tiles = allocate_memory(align32_size(total_tiles), false, false); uint8_t* tiles; if (tilegrid_tiles == NULL) { tiles = m_malloc(total_tiles, true); @@ -133,7 +133,7 @@ void supervisor_display_move_memory(void) { grid->tiles == MP_STATE_VM(terminal_tilegrid_tiles)) { uint16_t total_tiles = grid->width_in_tiles * grid->height_in_tiles; - tilegrid_tiles = allocate_memory(align32_size(total_tiles), false); + tilegrid_tiles = allocate_memory(align32_size(total_tiles), false, false); if (tilegrid_tiles != NULL) { memcpy(tilegrid_tiles->ptr, grid->tiles, total_tiles); grid->tiles = (uint8_t*) tilegrid_tiles->ptr; diff --git a/supervisor/shared/external_flash/external_flash.c b/supervisor/shared/external_flash/external_flash.c index 5bde7fd485..e2d767235e 100644 --- a/supervisor/shared/external_flash/external_flash.c +++ b/supervisor/shared/external_flash/external_flash.c @@ -338,7 +338,7 @@ static bool allocate_ram_cache(void) { uint32_t table_size = blocks_per_sector * pages_per_block * sizeof(uint32_t); // Attempt to allocate outside the heap first. - supervisor_cache = allocate_memory(table_size + SPI_FLASH_ERASE_SIZE, false); + supervisor_cache = allocate_memory(table_size + SPI_FLASH_ERASE_SIZE, false, false); if (supervisor_cache != NULL) { MP_STATE_VM(flash_ram_cache) = (uint8_t **) supervisor_cache->ptr; uint8_t* page_start = (uint8_t *) supervisor_cache->ptr + table_size; diff --git a/supervisor/shared/memory.c b/supervisor/shared/memory.c index 0f96ae2734..2be3b42d63 100755 --- a/supervisor/shared/memory.c +++ b/supervisor/shared/memory.c @@ -27,78 +27,81 @@ #include "supervisor/memory.h" #include "supervisor/port.h" -#include +#include +#include "py/gc.h" #include "supervisor/shared/display.h" #define CIRCUITPY_SUPERVISOR_ALLOC_COUNT (12) -// Using a zero length to mark an unused allocation makes the code a bit shorter (but makes it -// impossible to support zero-length allocations). -#define FREE 0 - // The lowest two bits of a valid length are always zero, so we can use them to mark an allocation -// as freed by the client but not yet reclaimed into the FREE middle. +// as a hole (freed by the client but not yet reclaimed into the free middle) and as movable. +#define FLAGS 3 #define HOLE 1 +#define MOVABLE 2 static supervisor_allocation allocations[CIRCUITPY_SUPERVISOR_ALLOC_COUNT]; -// We use uint32_t* to ensure word (4 byte) alignment. -uint32_t* low_address; -uint32_t* high_address; +supervisor_allocation* old_allocations; -void memory_init(void) { - low_address = port_heap_get_bottom(); - high_address = port_heap_get_top(); -} +typedef struct _supervisor_allocation_node { + struct _supervisor_allocation_node* next; + size_t length; + // We use uint32_t to ensure word (4 byte) alignment. + uint32_t data[]; +} supervisor_allocation_node; + +supervisor_allocation_node* low_head; +supervisor_allocation_node* high_head; + +// Intermediate (void*) is to suppress -Wcast-align warning. Alignment will always be correct +// because this only reverses how (alloc)->ptr was obtained as &(node->data[0]). +#define ALLOCATION_NODE(alloc) ((supervisor_allocation_node*)(void*)((char*)((alloc)->ptr) - sizeof(supervisor_allocation_node))) void free_memory(supervisor_allocation* allocation) { - if (allocation == NULL) { + if (allocation == NULL || allocation->ptr == NULL) { return; } - int32_t index = 0; - bool found = false; - for (index = 0; index < CIRCUITPY_SUPERVISOR_ALLOC_COUNT; index++) { - found = allocation == &allocations[index]; - if (found) { - break; - } + supervisor_allocation_node* node = ALLOCATION_NODE(allocation); + if (node == low_head) { + do { + low_head = low_head->next; + } while (low_head != NULL && (low_head->length & HOLE)); } - if (!found) { - // Bad! - // TODO(tannewt): Add a way to escape into safe mode on error. + else if (node == high_head) { + do { + high_head = high_head->next; + } while (high_head != NULL && (high_head->length & HOLE)); } - if (allocation->ptr == high_address) { - high_address += allocation->length / 4; - allocation->length = FREE; - for (index++; index < CIRCUITPY_SUPERVISOR_ALLOC_COUNT; index++) { - if (!(allocations[index].length & HOLE)) { - break; + else { + // Check if it's in the list of embedded allocations. + supervisor_allocation_node** emb = &MP_STATE_VM(first_embedded_allocation); + while (*emb != NULL) { + if (*emb == node) { + // Found, remove it from the list. + *emb = node->next; + m_free(node +#if MICROPY_MALLOC_USES_ALLOCATED_SIZE + , sizeof(supervisor_allocation_node) + (node->length & ~FLAGS) +#endif + ); + goto done; } - // Division automatically shifts out the HOLE bit. - high_address += allocations[index].length / 4; - allocations[index].length = FREE; + emb = &((*emb)->next); } - } else if (allocation->ptr + allocation->length / 4 == low_address) { - low_address = allocation->ptr; - allocation->length = FREE; - for (index--; index >= 0; index--) { - if (!(allocations[index].length & HOLE)) { - break; - } - low_address -= allocations[index].length / 4; - allocations[index].length = FREE; - } - } else { - // Freed memory isn't in the middle so skip updating bounds. The memory will be added to the - // middle when the memory to the inside is freed. We still need its length, but setting - // only the lowest bit is nondestructive. - allocation->length |= HOLE; + // Else it must be within the low or high ranges and becomes a hole. + node->length = ((node->length & ~FLAGS) | HOLE); } +done: + allocation->ptr = NULL; } supervisor_allocation* allocation_from_ptr(void *ptr) { + // When called from the context of supervisor_move_memory() (old_allocations != NULL), search + // by old pointer to give clients a way of mapping from old to new pointer. But not if + // ptr == NULL, then the caller wants an allocation whose current ptr is NULL. + supervisor_allocation* list = (old_allocations && ptr) ? old_allocations : &allocations[0]; for (size_t index = 0; index < CIRCUITPY_SUPERVISOR_ALLOC_COUNT; index++) { - if (allocations[index].ptr == ptr) { + if (list[index].ptr == ptr) { return &allocations[index]; } } @@ -106,50 +109,172 @@ supervisor_allocation* allocation_from_ptr(void *ptr) { } supervisor_allocation* allocate_remaining_memory(void) { - if (low_address == high_address) { - return NULL; - } - return allocate_memory((high_address - low_address) * 4, false); + uint32_t* low_address = low_head ? low_head->data + low_head->length / 4 : port_heap_get_bottom(); + uint32_t* high_address = high_head ? (uint32_t*)high_head : port_heap_get_top(); + return allocate_memory((high_address - low_address) * 4 - sizeof(supervisor_allocation_node), false, false); } -supervisor_allocation* allocate_memory(uint32_t length, bool high) { +static supervisor_allocation_node* find_hole(supervisor_allocation_node* node, size_t length) { + for (; node != NULL; node = node->next) { + if (node->length == (length | HOLE)) { + break; + } + } + return node; +} + +static supervisor_allocation_node* allocate_memory_node(uint32_t length, bool high, bool movable) { + // supervisor_move_memory() currently does not support movable allocations on the high side, it + // must be extended first if this is ever needed. + assert(!(high && movable)); if (length == 0 || length % 4 != 0) { return NULL; } - uint8_t index = 0; - int8_t direction = 1; - if (high) { - index = CIRCUITPY_SUPERVISOR_ALLOC_COUNT - 1; - direction = -1; - } - supervisor_allocation* alloc; - for (; index < CIRCUITPY_SUPERVISOR_ALLOC_COUNT; index += direction) { - alloc = &allocations[index]; - if (alloc->length == FREE && (high_address - low_address) * 4 >= (int32_t) length) { - break; + // 1. Matching hole on the requested side? + supervisor_allocation_node* node = find_hole(high ? high_head : low_head, length); + if (!node) { + // 2. Enough free space in the middle? + uint32_t* low_address = low_head ? low_head->data + low_head->length / 4 : port_heap_get_bottom(); + uint32_t* high_address = high_head ? (uint32_t*)high_head : port_heap_get_top(); + if ((high_address - low_address) * 4 >= (int32_t)(sizeof(supervisor_allocation_node) + length)) { + if (high) { + high_address -= (sizeof(supervisor_allocation_node) + length) / 4; + node = (supervisor_allocation_node*)high_address; + node->next = high_head; + high_head = node; + } + else { + node = (supervisor_allocation_node*)low_address; + node->next = low_head; + low_head = node; + } } - // If a hole matches in length exactly, we can reuse it. - if (alloc->length == (length | HOLE)) { - alloc->length = length; - return alloc; + else { + // 3. Matching hole on the other side? + node = find_hole(high ? low_head : high_head, length); + if (!node) { + // 4. GC allocation? + if (movable && gc_alloc_possible()) { + node = m_malloc_maybe(sizeof(supervisor_allocation_node) + length, true); + if (node) { + node->next = MP_STATE_VM(first_embedded_allocation); + MP_STATE_VM(first_embedded_allocation) = node; + } + } + if (!node) { + // 5. Give up. + return NULL; + } + } } } - if (index >= CIRCUITPY_SUPERVISOR_ALLOC_COUNT) { + node->length = length; + if (movable) { + node->length |= MOVABLE; + } + return node; +} + +supervisor_allocation* allocate_memory(uint32_t length, bool high, bool movable) { + supervisor_allocation_node* node = allocate_memory_node(length, high, movable); + if (!node) { return NULL; } - if (high) { - high_address -= length / 4; - alloc->ptr = high_address; - } else { - alloc->ptr = low_address; - low_address += length / 4; + // Find the first free allocation. + supervisor_allocation* alloc = allocation_from_ptr(NULL); + if (!alloc) { + // We should free node again to avoid leaking, but something is wrong anyway if clients try + // to make more allocations than available, so don't bother. + return NULL; } - alloc->length = length; + alloc->ptr = &(node->data[0]); return alloc; } +size_t get_allocation_length(supervisor_allocation* allocation) { + return ALLOCATION_NODE(allocation)->length & ~FLAGS; +} + void supervisor_move_memory(void) { + // This must be called exactly after freeing the heap, so that the embedded allocations, if any, + // are now in the free region. + assert(MP_STATE_VM(first_embedded_allocation) == NULL || (low_head < MP_STATE_VM(first_embedded_allocation) && MP_STATE_VM(first_embedded_allocation) < high_head)); + + // Save the old pointers for allocation_from_ptr(). + supervisor_allocation old_allocations_array[CIRCUITPY_SUPERVISOR_ALLOC_COUNT]; + memcpy(old_allocations_array, allocations, sizeof(allocations)); + + // Compact the low side. Traverse the list repeatedly, finding movable allocations preceded by a + // hole and swapping them, until no more are found. This is not the most runtime-efficient way, + // but probably the shortest and simplest code. + bool acted; + do { + acted = false; + supervisor_allocation_node** nodep = &low_head; + while (*nodep != NULL && (*nodep)->next != NULL) { + if (((*nodep)->length & MOVABLE) && ((*nodep)->next->length & HOLE)) { + supervisor_allocation_node* oldnode = *nodep; + supervisor_allocation_node* start = oldnode->next; + supervisor_allocation* alloc = allocation_from_ptr(&(oldnode->data[0])); + assert(alloc != NULL); + alloc->ptr = &(start->data[0]); + oldnode->next = start->next; + size_t holelength = start->length; + size_t size = sizeof(supervisor_allocation_node) + (oldnode->length & ~FLAGS); + memmove(start, oldnode, size); + supervisor_allocation_node* newhole = (supervisor_allocation_node*)(void*)((char*)start + size); + newhole->next = start; + newhole->length = holelength; + *nodep = newhole; + acted = true; + } + nodep = &((*nodep)->next); + } + } while (acted); + // Any holes bubbled to the top can be absorbed into the free middle. + while (low_head != NULL && (low_head->length & HOLE)) { + low_head = low_head->next; + }; + + // Don't bother compacting the high side, there are no movable allocations and no holes there in + // current usage. + + // Promote the embedded allocations to top-level ones, compacting them at the beginning of the + // now free region (or possibly in matching holes). + // The linked list is unordered, but allocations must be processed in order to avoid risking + // overwriting each other. To that end, repeatedly find the lowest element of the list, remove + // it from the list, and process it. This ad-hoc selection sort results in substantially shorter + // code than using the qsort() function from the C library. + while (MP_STATE_VM(first_embedded_allocation)) { + // First element is first candidate. + supervisor_allocation_node** pminnode = &MP_STATE_VM(first_embedded_allocation); + // Iterate from second element (if any) on. + for (supervisor_allocation_node** pnode = &(MP_STATE_VM(first_embedded_allocation)->next); *pnode != NULL; pnode = &(*pnode)->next) { + if (*pnode < *pminnode) { + pminnode = pnode; + } + } + // Remove from list. + supervisor_allocation_node* node = *pminnode; + *pminnode = node->next; + // Process. + size_t length = (node->length & ~FLAGS); + supervisor_allocation* alloc = allocation_from_ptr(&(node->data[0])); + assert(alloc != NULL); + // This may overwrite the header of node if it happened to be there already, but not the + // data. + supervisor_allocation_node* new_node = allocate_memory_node(length, false, true); + // There must be enough free space. + assert(new_node != NULL); + memmove(&(new_node->data[0]), &(node->data[0]), length); + alloc->ptr = &(new_node->data[0]); + } + + // Notify clients that their movable allocations may have moved. + old_allocations = &old_allocations_array[0]; #if CIRCUITPY_DISPLAYIO supervisor_display_move_memory(); #endif + // Add calls to further clients here. + old_allocations = NULL; } diff --git a/supervisor/shared/stack.c b/supervisor/shared/stack.c index e7aa956b01..afea204010 100755 --- a/supervisor/shared/stack.c +++ b/supervisor/shared/stack.c @@ -34,36 +34,42 @@ extern uint32_t _estack; +// Requested size. static uint32_t next_stack_size = CIRCUITPY_DEFAULT_STACK_SIZE; static uint32_t current_stack_size = 0; -supervisor_allocation* stack_alloc = NULL; +// Actual location and size, may be larger than requested. +static uint32_t* stack_limit = NULL; +static size_t stack_length = 0; #define EXCEPTION_STACK_SIZE 1024 void allocate_stack(void) { - if (port_fixed_stack() != NULL) { - stack_alloc = port_fixed_stack(); - current_stack_size = stack_alloc->length; + if (port_has_fixed_stack()) { + stack_limit = port_stack_get_limit(); + stack_length = (port_stack_get_top() - stack_limit)*sizeof(uint32_t); + current_stack_size = stack_length; } else { mp_uint_t regs[10]; mp_uint_t sp = cpu_get_regs_and_sp(regs); mp_uint_t c_size = (uint32_t) port_stack_get_top() - sp; - stack_alloc = allocate_memory(c_size + next_stack_size + EXCEPTION_STACK_SIZE, true); + supervisor_allocation* stack_alloc = allocate_memory(c_size + next_stack_size + EXCEPTION_STACK_SIZE, true, false); if (stack_alloc == NULL) { - stack_alloc = allocate_memory(c_size + CIRCUITPY_DEFAULT_STACK_SIZE + EXCEPTION_STACK_SIZE, true); + stack_alloc = allocate_memory(c_size + CIRCUITPY_DEFAULT_STACK_SIZE + EXCEPTION_STACK_SIZE, true, false); current_stack_size = CIRCUITPY_DEFAULT_STACK_SIZE; } else { current_stack_size = next_stack_size; } + stack_limit = stack_alloc->ptr; + stack_length = get_allocation_length(stack_alloc); } - *stack_alloc->ptr = STACK_CANARY_VALUE; + *stack_limit = STACK_CANARY_VALUE; } inline bool stack_ok(void) { - return stack_alloc == NULL || *stack_alloc->ptr == STACK_CANARY_VALUE; + return stack_limit == NULL || *stack_limit == STACK_CANARY_VALUE; } inline void assert_heap_ok(void) { @@ -77,18 +83,26 @@ void stack_init(void) { } void stack_resize(void) { - if (stack_alloc == NULL) { + if (stack_limit == NULL) { return; } if (next_stack_size == current_stack_size) { - *stack_alloc->ptr = STACK_CANARY_VALUE; + *stack_limit = STACK_CANARY_VALUE; return; } - free_memory(stack_alloc); - stack_alloc = NULL; + free_memory(allocation_from_ptr(stack_limit)); + stack_limit = NULL; allocate_stack(); } +uint32_t* stack_get_bottom(void) { + return stack_limit; +} + +size_t stack_get_length(void) { + return stack_length; +} + void set_next_stack_size(uint32_t size) { next_stack_size = size; } diff --git a/supervisor/shared/stack.h b/supervisor/shared/stack.h index 7096f0b3ed..1c75de5f78 100755 --- a/supervisor/shared/stack.h +++ b/supervisor/shared/stack.h @@ -31,10 +31,12 @@ #include "supervisor/memory.h" -extern supervisor_allocation* stack_alloc; - void stack_init(void); void stack_resize(void); +// Actual stack location and size, may be larger than requested. +uint32_t* stack_get_bottom(void); +size_t stack_get_length(void); +// Next/current requested stack size. void set_next_stack_size(uint32_t size); uint32_t get_current_stack_size(void); bool stack_ok(void); From 2ba9805f845e000fa3299e95e93a063471751ecd Mon Sep 17 00:00:00 2001 From: Christian Walther Date: Sun, 11 Oct 2020 20:39:19 +0200 Subject: [PATCH 164/207] Use movable allocation system for terminal tilegrid. Moving memory is now done by the infrastructure and neither necessary nor correct here anymore. --- py/circuitpy_mpconfig.h | 1 - supervisor/shared/display.c | 43 +++++++++++++++---------------------- 2 files changed, 17 insertions(+), 27 deletions(-) diff --git a/py/circuitpy_mpconfig.h b/py/circuitpy_mpconfig.h index 28fd6e9b00..34ea9b022f 100644 --- a/py/circuitpy_mpconfig.h +++ b/py/circuitpy_mpconfig.h @@ -867,7 +867,6 @@ struct _supervisor_allocation_node; mp_obj_t rtc_time_source; \ GAMEPAD_ROOT_POINTERS \ mp_obj_t pew_singleton; \ - mp_obj_t terminal_tilegrid_tiles; \ BOARD_UART_ROOT_POINTER \ FLASH_ROOT_POINTERS \ MEMORYMONITOR_ROOT_POINTERS \ diff --git a/supervisor/shared/display.c b/supervisor/shared/display.c index de45e2672f..9c9c66cd7f 100644 --- a/supervisor/shared/display.c +++ b/supervisor/shared/display.c @@ -81,19 +81,21 @@ void supervisor_start_terminal(uint16_t width_px, uint16_t height_px) { uint16_t total_tiles = width_in_tiles * height_in_tiles; - // First try to allocate outside the heap. This will fail when the VM is running. - tilegrid_tiles = allocate_memory(align32_size(total_tiles), false, false); - uint8_t* tiles; - if (tilegrid_tiles == NULL) { - tiles = m_malloc(total_tiles, true); - MP_STATE_VM(terminal_tilegrid_tiles) = tiles; - } else { - tiles = (uint8_t*) tilegrid_tiles->ptr; + // Reuse the previous allocation if possible + if (tilegrid_tiles) { + if (get_allocation_length(tilegrid_tiles) != align32_size(total_tiles)) { + free_memory(tilegrid_tiles); + tilegrid_tiles = NULL; + } } + if (!tilegrid_tiles) { + tilegrid_tiles = allocate_memory(align32_size(total_tiles), false, true); + if (!tilegrid_tiles) { + return; + } + } + uint8_t* tiles = (uint8_t*) tilegrid_tiles->ptr; - if (tiles == NULL) { - return; - } grid->y = tall ? blinka_bitmap.height : 0; grid->x = tall ? 0 : blinka_bitmap.width; grid->top_left_y = 0; @@ -120,7 +122,6 @@ void supervisor_stop_terminal(void) { if (tilegrid_tiles != NULL) { free_memory(tilegrid_tiles); tilegrid_tiles = NULL; - supervisor_terminal_text_grid.inline_tiles = false; supervisor_terminal_text_grid.tiles = NULL; } #endif @@ -128,20 +129,10 @@ void supervisor_stop_terminal(void) { void supervisor_display_move_memory(void) { #if CIRCUITPY_TERMINALIO - displayio_tilegrid_t* grid = &supervisor_terminal_text_grid; - if (MP_STATE_VM(terminal_tilegrid_tiles) != NULL && - grid->tiles == MP_STATE_VM(terminal_tilegrid_tiles)) { - uint16_t total_tiles = grid->width_in_tiles * grid->height_in_tiles; - - tilegrid_tiles = allocate_memory(align32_size(total_tiles), false, false); - if (tilegrid_tiles != NULL) { - memcpy(tilegrid_tiles->ptr, grid->tiles, total_tiles); - grid->tiles = (uint8_t*) tilegrid_tiles->ptr; - } else { - grid->tiles = NULL; - grid->inline_tiles = false; - } - MP_STATE_VM(terminal_tilegrid_tiles) = NULL; + if (tilegrid_tiles != NULL) { + supervisor_terminal_text_grid.tiles = (uint8_t*) tilegrid_tiles->ptr; + } else { + supervisor_terminal_text_grid.tiles = NULL; } #endif From ac91220361e402bbf6ebb741a9b6ea258a05da99 Mon Sep 17 00:00:00 2001 From: Christian Walther Date: Fri, 16 Oct 2020 23:08:29 +0200 Subject: [PATCH 165/207] Use movable allocation system for Sharp display framebuffer. Hybrid allocation is now part of the infrastructure. Moving memory contents would not be necessary because displayio can recreate them, but does not hurt. --- .../sharpdisplay/SharpMemoryFramebuffer.c | 57 +++++-------------- .../sharpdisplay/SharpMemoryFramebuffer.h | 1 - 2 files changed, 14 insertions(+), 44 deletions(-) diff --git a/shared-module/sharpdisplay/SharpMemoryFramebuffer.c b/shared-module/sharpdisplay/SharpMemoryFramebuffer.c index aefb6b18de..4b92bd637a 100644 --- a/shared-module/sharpdisplay/SharpMemoryFramebuffer.c +++ b/shared-module/sharpdisplay/SharpMemoryFramebuffer.c @@ -34,32 +34,10 @@ #include "shared-module/sharpdisplay/SharpMemoryFramebuffer.h" #include "supervisor/memory.h" -#include "supervisor/shared/safe_mode.h" #define SHARPMEM_BIT_WRITECMD_LSB (0x80) #define SHARPMEM_BIT_VCOM_LSB (0x40) -static void *hybrid_alloc(size_t sz) { - supervisor_allocation *allocation = allocate_memory(align32_size(sz), false, false); - if (allocation) { - memset(allocation->ptr, 0, sz); - return allocation->ptr; - } - if (gc_alloc_possible()) { - return m_malloc(sz, true); - } - reset_into_safe_mode(MEM_MANAGE); - return NULL; // unreached -} - -static inline void hybrid_free(void *ptr_in) { - supervisor_allocation *allocation = allocation_from_ptr(ptr_in); - - if (allocation) { - free_memory(allocation); - } -} - STATIC uint8_t bitrev(uint8_t n) { uint8_t r = 0; for(int i=0;i<8;i++) r |= ((n>>i) & 1)<<(7-i); @@ -102,9 +80,9 @@ void common_hal_sharpdisplay_framebuffer_reset(sharpdisplay_framebuffer_obj_t *s } void common_hal_sharpdisplay_framebuffer_reconstruct(sharpdisplay_framebuffer_obj_t *self) { - if (!allocation_from_ptr(self->bufinfo.buf)) { - self->bufinfo.buf = NULL; - } + // Look up the allocation by the old pointer and get the new pointer from it. + supervisor_allocation* alloc = allocation_from_ptr(self->bufinfo.buf); + self->bufinfo.buf = alloc ? alloc->ptr : NULL; } void common_hal_sharpdisplay_framebuffer_get_bufinfo(sharpdisplay_framebuffer_obj_t *self, mp_buffer_info_t *bufinfo) { @@ -112,7 +90,12 @@ void common_hal_sharpdisplay_framebuffer_get_bufinfo(sharpdisplay_framebuffer_ob int row_stride = common_hal_sharpdisplay_framebuffer_get_row_stride(self); int height = common_hal_sharpdisplay_framebuffer_get_height(self); self->bufinfo.len = row_stride * height + 2; - self->bufinfo.buf = hybrid_alloc(self->bufinfo.len); + supervisor_allocation* alloc = allocate_memory(align32_size(self->bufinfo.len), false, true); + if (alloc == NULL) { + m_malloc_fail(self->bufinfo.len); + } + self->bufinfo.buf = alloc->ptr; + memset(alloc->ptr, 0, self->bufinfo.len); uint8_t *data = self->bufinfo.buf; *data++ = SHARPMEM_BIT_WRITECMD_LSB; @@ -123,7 +106,9 @@ void common_hal_sharpdisplay_framebuffer_get_bufinfo(sharpdisplay_framebuffer_ob } self->full_refresh = true; } - *bufinfo = self->bufinfo; + if (bufinfo) { + *bufinfo = self->bufinfo; + } } void common_hal_sharpdisplay_framebuffer_deinit(sharpdisplay_framebuffer_obj_t *self) { @@ -137,7 +122,7 @@ void common_hal_sharpdisplay_framebuffer_deinit(sharpdisplay_framebuffer_obj_t * common_hal_reset_pin(self->chip_select.pin); - hybrid_free(self->bufinfo.buf); + free_memory(allocation_from_ptr(self->bufinfo.buf)); memset(self, 0, sizeof(*self)); } @@ -154,19 +139,7 @@ void common_hal_sharpdisplay_framebuffer_construct(sharpdisplay_framebuffer_obj_ self->height = height; self->baudrate = baudrate; - int row_stride = common_hal_sharpdisplay_framebuffer_get_row_stride(self); - self->bufinfo.len = row_stride * height + 2; - // re-use a supervisor allocation if possible - self->bufinfo.buf = hybrid_alloc(self->bufinfo.len); - - uint8_t *data = self->bufinfo.buf; - *data++ = SHARPMEM_BIT_WRITECMD_LSB; - - for(int y=0; yheight; y++) { - *data = bitrev(y+1); - data += row_stride; - } - self->full_refresh = true; + common_hal_sharpdisplay_framebuffer_get_bufinfo(self, NULL); } void common_hal_sharpdisplay_framebuffer_swapbuffers(sharpdisplay_framebuffer_obj_t *self, uint8_t *dirty_row_bitmask) { @@ -271,7 +244,5 @@ const framebuffer_p_t sharpdisplay_framebuffer_proto = { }; void common_hal_sharpdisplay_framebuffer_collect_ptrs(sharpdisplay_framebuffer_obj_t *self) { - gc_collect_ptr(self->framebuffer); gc_collect_ptr(self->bus); - gc_collect_ptr(self->bufinfo.buf); } diff --git a/shared-module/sharpdisplay/SharpMemoryFramebuffer.h b/shared-module/sharpdisplay/SharpMemoryFramebuffer.h index 8acacc94e1..08966a89c1 100644 --- a/shared-module/sharpdisplay/SharpMemoryFramebuffer.h +++ b/shared-module/sharpdisplay/SharpMemoryFramebuffer.h @@ -33,7 +33,6 @@ typedef struct { mp_obj_base_t base; - mp_obj_t framebuffer; busio_spi_obj_t* bus; busio_spi_obj_t inline_bus; digitalio_digitalinout_obj_t chip_select; From a4b84cf0e118f06cc3b563866d5c594b94b9b3fb Mon Sep 17 00:00:00 2001 From: Christian Walther Date: Sat, 17 Oct 2020 13:49:10 +0200 Subject: [PATCH 166/207] Use movable allocation system for RGBMatrix allocations. Hybrid allocation is now part of the infrastructure. Moving memory contents would not be necessary because displayio can recreate them, but does not hurt. --- shared-module/rgbmatrix/RGBMatrix.c | 25 +++++++------------------ 1 file changed, 7 insertions(+), 18 deletions(-) diff --git a/shared-module/rgbmatrix/RGBMatrix.c b/shared-module/rgbmatrix/RGBMatrix.c index 1f144aedb5..a09767b622 100644 --- a/shared-module/rgbmatrix/RGBMatrix.c +++ b/shared-module/rgbmatrix/RGBMatrix.c @@ -78,10 +78,10 @@ void common_hal_rgbmatrix_rgbmatrix_reconstruct(rgbmatrix_rgbmatrix_obj_t* self, // verify that the matrix is big enough mp_get_index(mp_obj_get_type(self->framebuffer), self->bufinfo.len, MP_OBJ_NEW_SMALL_INT(self->bufsize-1), false); } else { - _PM_free(self->bufinfo.buf); - _PM_free(self->protomatter.rgbPins); - _PM_free(self->protomatter.addr); - _PM_free(self->protomatter.screenData); + common_hal_rgbmatrix_free_impl(self->bufinfo.buf); + common_hal_rgbmatrix_free_impl(self->protomatter.rgbPins); + common_hal_rgbmatrix_free_impl(self->protomatter.addr); + common_hal_rgbmatrix_free_impl(self->protomatter.screenData); self->framebuffer = NULL; self->bufinfo.buf = common_hal_rgbmatrix_allocator_impl(self->bufsize); @@ -180,9 +180,6 @@ void common_hal_rgbmatrix_rgbmatrix_deinit(rgbmatrix_rgbmatrix_obj_t* self) { void rgbmatrix_rgbmatrix_collect_ptrs(rgbmatrix_rgbmatrix_obj_t* self) { gc_collect_ptr(self->framebuffer); - gc_collect_ptr(self->protomatter.rgbPins); - gc_collect_ptr(self->protomatter.addr); - gc_collect_ptr(self->protomatter.screenData); } void common_hal_rgbmatrix_rgbmatrix_set_paused(rgbmatrix_rgbmatrix_obj_t* self, bool paused) { @@ -217,18 +214,10 @@ int common_hal_rgbmatrix_rgbmatrix_get_height(rgbmatrix_rgbmatrix_obj_t* self) { } void *common_hal_rgbmatrix_allocator_impl(size_t sz) { - if (gc_alloc_possible()) { - return m_malloc_maybe(sz + sizeof(void*), true); - } else { - supervisor_allocation *allocation = allocate_memory(align32_size(sz), false, false); - return allocation ? allocation->ptr : NULL; - } + supervisor_allocation *allocation = allocate_memory(align32_size(sz), false, true); + return allocation ? allocation->ptr : NULL; } void common_hal_rgbmatrix_free_impl(void *ptr_in) { - supervisor_allocation *allocation = allocation_from_ptr(ptr_in); - - if (allocation) { - free_memory(allocation); - } + free_memory(allocation_from_ptr(ptr_in)); } From 7ca36d45a4ffe40c70814d62cb970007b7f40fee Mon Sep 17 00:00:00 2001 From: Christian Walther Date: Fri, 23 Oct 2020 22:35:56 +0200 Subject: [PATCH 167/207] Fix align32_size(). It not only caused crashes with requests larger than 64K (can happen with RGBMatrix), but also generated a lot longer code than necessary. --- shared-module/usb_midi/__init__.c | 6 +++--- supervisor/memory.h | 7 ++----- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/shared-module/usb_midi/__init__.c b/shared-module/usb_midi/__init__.c index 5afdd18213..3fb3f836cd 100644 --- a/shared-module/usb_midi/__init__.c +++ b/shared-module/usb_midi/__init__.c @@ -40,9 +40,9 @@ supervisor_allocation* usb_midi_allocation; void usb_midi_init(void) { // TODO(tannewt): Make this dynamic. - uint16_t tuple_size = align32_size(sizeof(mp_obj_tuple_t) + sizeof(mp_obj_t*) * 2); - uint16_t portin_size = align32_size(sizeof(usb_midi_portin_obj_t)); - uint16_t portout_size = align32_size(sizeof(usb_midi_portout_obj_t)); + size_t tuple_size = align32_size(sizeof(mp_obj_tuple_t) + sizeof(mp_obj_t*) * 2); + size_t portin_size = align32_size(sizeof(usb_midi_portin_obj_t)); + size_t portout_size = align32_size(sizeof(usb_midi_portout_obj_t)); // For each embedded MIDI Jack in the descriptor we create a Port usb_midi_allocation = allocate_memory(tuple_size + portin_size + portout_size, false, false); diff --git a/supervisor/memory.h b/supervisor/memory.h index 4307e3f21d..0f820eac1c 100755 --- a/supervisor/memory.h +++ b/supervisor/memory.h @@ -64,11 +64,8 @@ supervisor_allocation* allocate_remaining_memory(void); // supervisor_move_memory(). supervisor_allocation* allocate_memory(uint32_t length, bool high_address, bool movable); -static inline uint16_t align32_size(uint16_t size) { - if (size % 4 != 0) { - return (size & 0xfffc) + 0x4; - } - return size; +static inline size_t align32_size(size_t size) { + return (size + 3) & ~3; } size_t get_allocation_length(supervisor_allocation* allocation); From 993a581f5e8c039b562bbacdf17615162d8a85f6 Mon Sep 17 00:00:00 2001 From: Christian Walther Date: Wed, 28 Oct 2020 21:50:28 +0100 Subject: [PATCH 168/207] Make CIRCUITPY_SUPERVISOR_ALLOC_COUNT dependent on enabled features. Avoids wasted memory and makes it easier to keep track of who needs how much for future additions. --- supervisor/shared/memory.c | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/supervisor/shared/memory.c b/supervisor/shared/memory.c index 2be3b42d63..1760b9bd67 100755 --- a/supervisor/shared/memory.c +++ b/supervisor/shared/memory.c @@ -32,7 +32,32 @@ #include "py/gc.h" #include "supervisor/shared/display.h" -#define CIRCUITPY_SUPERVISOR_ALLOC_COUNT (12) +enum { + CIRCUITPY_SUPERVISOR_ALLOC_COUNT = + // stack + heap + 2 +#ifdef EXTERNAL_FLASH_DEVICES + + 1 +#endif +#if CIRCUITPY_USB_MIDI + + 1 +#endif +#if CIRCUITPY_DISPLAYIO + #if CIRCUITPY_TERMINALIO + + 1 + #endif + + CIRCUITPY_DISPLAY_LIMIT * ( + // Maximum needs of one display: max(4 if RGBMATRIX, 1 if SHARPDISPLAY, 0) + #if CIRCUITPY_RGBMATRIX + 4 + #elif CIRCUITPY_SHARPDISPLAY + 1 + #else + 0 + #endif + ) +#endif +}; // The lowest two bits of a valid length are always zero, so we can use them to mark an allocation // as a hole (freed by the client but not yet reclaimed into the free middle) and as movable. From 848eb2813247edc555bbef34ff2505f12094ef4e Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Sat, 28 Nov 2020 14:52:56 -0500 Subject: [PATCH 169/207] esp-uart-pins --- ports/atmel-samd/boards/pybadge_airlift/pins.c | 4 +++- ports/atmel-samd/boards/pyportal/pins.c | 2 ++ ports/atmel-samd/boards/pyportal_titano/pins.c | 5 ++++- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/ports/atmel-samd/boards/pybadge_airlift/pins.c b/ports/atmel-samd/boards/pybadge_airlift/pins.c index d396502460..399c634413 100644 --- a/ports/atmel-samd/boards/pybadge_airlift/pins.c +++ b/ports/atmel-samd/boards/pybadge_airlift/pins.c @@ -30,8 +30,10 @@ STATIC const mp_rom_map_elem_t board_global_dict_table[] = { {MP_OBJ_NEW_QSTR(MP_QSTR_D12), MP_ROM_PTR(&pin_PA22)}, {MP_OBJ_NEW_QSTR(MP_QSTR_D13), MP_ROM_PTR(&pin_PA23)}, - // UART + // ESP UART + {MP_OBJ_NEW_QSTR(MP_QSTR_ESP_RX), MP_ROM_PTR(&pin_PB17)}, {MP_OBJ_NEW_QSTR(MP_QSTR_RX), MP_ROM_PTR(&pin_PB17)}, + {MP_OBJ_NEW_QSTR(MP_QSTR_ESP_TX), MP_ROM_PTR(&pin_PB16)}, {MP_OBJ_NEW_QSTR(MP_QSTR_TX), MP_ROM_PTR(&pin_PB16)}, // I2C diff --git a/ports/atmel-samd/boards/pyportal/pins.c b/ports/atmel-samd/boards/pyportal/pins.c index 14699a209d..36140427cb 100644 --- a/ports/atmel-samd/boards/pyportal/pins.c +++ b/ports/atmel-samd/boards/pyportal/pins.c @@ -61,7 +61,9 @@ STATIC const mp_rom_map_elem_t board_global_dict_table[] = { // UART { MP_OBJ_NEW_QSTR(MP_QSTR_TX), MP_ROM_PTR(&pin_PB12) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_ESP_TX), MP_ROM_PTR(&pin_PB12) }, { MP_OBJ_NEW_QSTR(MP_QSTR_RX), MP_ROM_PTR(&pin_PB13) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_ESP_RX), MP_ROM_PTR(&pin_PB13) }, // SPI { MP_OBJ_NEW_QSTR(MP_QSTR_MOSI),MP_ROM_PTR(&pin_PA12) }, diff --git a/ports/atmel-samd/boards/pyportal_titano/pins.c b/ports/atmel-samd/boards/pyportal_titano/pins.c index 14699a209d..cf8dfbbb27 100644 --- a/ports/atmel-samd/boards/pyportal_titano/pins.c +++ b/ports/atmel-samd/boards/pyportal_titano/pins.c @@ -59,8 +59,11 @@ STATIC const mp_rom_map_elem_t board_global_dict_table[] = { { MP_OBJ_NEW_QSTR(MP_QSTR_ESP_RESET), MP_ROM_PTR(&pin_PB17) }, { MP_OBJ_NEW_QSTR(MP_QSTR_ESP_RTS), MP_ROM_PTR(&pin_PA15) }, - // UART + // ESP UART + { MP_OBJ_NEW_QSTR(MP_QSTR_ESP_TX), MP_ROM_PTR(&pin_PB12) }, { MP_OBJ_NEW_QSTR(MP_QSTR_TX), MP_ROM_PTR(&pin_PB12) }, + + { MP_OBJ_NEW_QSTR(MP_QSTR_ESP_RX), MP_ROM_PTR(&pin_PB13) }, { MP_OBJ_NEW_QSTR(MP_QSTR_RX), MP_ROM_PTR(&pin_PB13) }, // SPI From 9ecaa16eced40f3f56ba67737aed3f0950c5164f Mon Sep 17 00:00:00 2001 From: Christian Walther Date: Sun, 29 Nov 2020 16:04:31 +0100 Subject: [PATCH 170/207] Unify redundant low/high_address computation to save a bit of code size. --- supervisor/shared/memory.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/supervisor/shared/memory.c b/supervisor/shared/memory.c index 1760b9bd67..acace7f890 100755 --- a/supervisor/shared/memory.c +++ b/supervisor/shared/memory.c @@ -134,9 +134,7 @@ supervisor_allocation* allocation_from_ptr(void *ptr) { } supervisor_allocation* allocate_remaining_memory(void) { - uint32_t* low_address = low_head ? low_head->data + low_head->length / 4 : port_heap_get_bottom(); - uint32_t* high_address = high_head ? (uint32_t*)high_head : port_heap_get_top(); - return allocate_memory((high_address - low_address) * 4 - sizeof(supervisor_allocation_node), false, false); + return allocate_memory((uint32_t)-1, false, false); } static supervisor_allocation_node* find_hole(supervisor_allocation_node* node, size_t length) { @@ -152,6 +150,12 @@ static supervisor_allocation_node* allocate_memory_node(uint32_t length, bool hi // supervisor_move_memory() currently does not support movable allocations on the high side, it // must be extended first if this is ever needed. assert(!(high && movable)); + uint32_t* low_address = low_head ? low_head->data + low_head->length / 4 : port_heap_get_bottom(); + uint32_t* high_address = high_head ? (uint32_t*)high_head : port_heap_get_top(); + // Special case for allocate_remaining_memory(), avoids computing low/high_address twice. + if (length == (uint32_t)-1) { + length = (high_address - low_address) * 4 - sizeof(supervisor_allocation_node); + } if (length == 0 || length % 4 != 0) { return NULL; } @@ -159,8 +163,6 @@ static supervisor_allocation_node* allocate_memory_node(uint32_t length, bool hi supervisor_allocation_node* node = find_hole(high ? high_head : low_head, length); if (!node) { // 2. Enough free space in the middle? - uint32_t* low_address = low_head ? low_head->data + low_head->length / 4 : port_heap_get_bottom(); - uint32_t* high_address = high_head ? (uint32_t*)high_head : port_heap_get_top(); if ((high_address - low_address) * 4 >= (int32_t)(sizeof(supervisor_allocation_node) + length)) { if (high) { high_address -= (sizeof(supervisor_allocation_node) + length) / 4; From 11ed6f86f02f61ace55951d2fff62a9d36cf3ac7 Mon Sep 17 00:00:00 2001 From: Christian Walther Date: Sun, 29 Nov 2020 16:27:36 +0100 Subject: [PATCH 171/207] Optimize out allocation moving code on boards that don't need it. When no features are enabled that use movable allocations, supervisor_move_memory() is not needed. --- supervisor/shared/memory.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/supervisor/shared/memory.c b/supervisor/shared/memory.c index acace7f890..bc82804b70 100755 --- a/supervisor/shared/memory.c +++ b/supervisor/shared/memory.c @@ -33,7 +33,7 @@ #include "supervisor/shared/display.h" enum { - CIRCUITPY_SUPERVISOR_ALLOC_COUNT = + CIRCUITPY_SUPERVISOR_IMMOVABLE_ALLOC_COUNT = // stack + heap 2 #ifdef EXTERNAL_FLASH_DEVICES @@ -42,6 +42,9 @@ enum { #if CIRCUITPY_USB_MIDI + 1 #endif + , + CIRCUITPY_SUPERVISOR_MOVABLE_ALLOC_COUNT = + 0 #if CIRCUITPY_DISPLAYIO #if CIRCUITPY_TERMINALIO + 1 @@ -57,6 +60,8 @@ enum { #endif ) #endif + , + CIRCUITPY_SUPERVISOR_ALLOC_COUNT = CIRCUITPY_SUPERVISOR_IMMOVABLE_ALLOC_COUNT + CIRCUITPY_SUPERVISOR_MOVABLE_ALLOC_COUNT }; // The lowest two bits of a valid length are always zero, so we can use them to mark an allocation @@ -147,6 +152,9 @@ static supervisor_allocation_node* find_hole(supervisor_allocation_node* node, s } static supervisor_allocation_node* allocate_memory_node(uint32_t length, bool high, bool movable) { + if (CIRCUITPY_SUPERVISOR_MOVABLE_ALLOC_COUNT == 0) { + assert(!movable); + } // supervisor_move_memory() currently does not support movable allocations on the high side, it // must be extended first if this is ever needed. assert(!(high && movable)); @@ -223,6 +231,11 @@ size_t get_allocation_length(supervisor_allocation* allocation) { } void supervisor_move_memory(void) { + // This whole function is not needed when there are no movable allocations, let it be optimized + // out. + if (CIRCUITPY_SUPERVISOR_MOVABLE_ALLOC_COUNT == 0) { + return; + } // This must be called exactly after freeing the heap, so that the embedded allocations, if any, // are now in the free region. assert(MP_STATE_VM(first_embedded_allocation) == NULL || (low_head < MP_STATE_VM(first_embedded_allocation) && MP_STATE_VM(first_embedded_allocation) < high_head)); From 9768951a2a42fd69f1f1adb0378a47e781d2fad7 Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Sat, 28 Nov 2020 10:12:46 -0500 Subject: [PATCH 172/207] Disable complex arithmetic on SAMD21 builds to make space --- ports/atmel-samd/mpconfigport.h | 1 + py/circuitpy_mpconfig.h | 2 ++ 2 files changed, 3 insertions(+) diff --git a/ports/atmel-samd/mpconfigport.h b/ports/atmel-samd/mpconfigport.h index ed10da9b9d..bce89e0b99 100644 --- a/ports/atmel-samd/mpconfigport.h +++ b/ports/atmel-samd/mpconfigport.h @@ -42,6 +42,7 @@ #define CIRCUITPY_MCU_FAMILY samd21 #define MICROPY_PY_SYS_PLATFORM "Atmel SAMD21" #define SPI_FLASH_MAX_BAUDRATE 8000000 +#define MICROPY_PY_BUILTINS_COMPLEX (0) #define MICROPY_PY_BUILTINS_NOTIMPLEMENTED (0) #define MICROPY_PY_FUNCTION_ATTRS (0) // MICROPY_PY_UJSON depends on MICROPY_PY_IO diff --git a/py/circuitpy_mpconfig.h b/py/circuitpy_mpconfig.h index 28fd4095c4..fa7095c78d 100644 --- a/py/circuitpy_mpconfig.h +++ b/py/circuitpy_mpconfig.h @@ -188,7 +188,9 @@ typedef long mp_off_t; #define MICROPY_COMP_FSTRING_LITERAL (MICROPY_CPYTHON_COMPAT) #define MICROPY_MODULE_WEAK_LINKS (0) #define MICROPY_PY_ALL_SPECIAL_METHODS (CIRCUITPY_FULL_BUILD) +#ifndef MICROPY_PY_BUILTINS_COMPLEX #define MICROPY_PY_BUILTINS_COMPLEX (CIRCUITPY_FULL_BUILD) +#endif #define MICROPY_PY_BUILTINS_FROZENSET (CIRCUITPY_FULL_BUILD) #define MICROPY_PY_BUILTINS_STR_CENTER (CIRCUITPY_FULL_BUILD) #define MICROPY_PY_BUILTINS_STR_PARTITION (CIRCUITPY_FULL_BUILD) From dbfabddf58338c5442ee725c9c904d7960c03b1a Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Mon, 30 Nov 2020 11:11:04 -0500 Subject: [PATCH 173/207] rename ESP TX and RX pins; remove support --- ports/atmel-samd/boards/pybadge_airlift/mpconfigboard.h | 3 --- ports/atmel-samd/boards/pybadge_airlift/pins.c | 9 ++------- ports/atmel-samd/boards/pyportal/mpconfigboard.h | 3 --- ports/atmel-samd/boards/pyportal/pins.c | 5 ----- ports/atmel-samd/boards/pyportal_titano/mpconfigboard.h | 3 --- ports/atmel-samd/boards/pyportal_titano/pins.c | 6 ------ 6 files changed, 2 insertions(+), 27 deletions(-) diff --git a/ports/atmel-samd/boards/pybadge_airlift/mpconfigboard.h b/ports/atmel-samd/boards/pybadge_airlift/mpconfigboard.h index c6ab4ed8e0..a37d7ceec4 100644 --- a/ports/atmel-samd/boards/pybadge_airlift/mpconfigboard.h +++ b/ports/atmel-samd/boards/pybadge_airlift/mpconfigboard.h @@ -23,9 +23,6 @@ #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/pybadge_airlift/pins.c b/ports/atmel-samd/boards/pybadge_airlift/pins.c index 399c634413..9ee579be14 100644 --- a/ports/atmel-samd/boards/pybadge_airlift/pins.c +++ b/ports/atmel-samd/boards/pybadge_airlift/pins.c @@ -30,12 +30,6 @@ STATIC const mp_rom_map_elem_t board_global_dict_table[] = { {MP_OBJ_NEW_QSTR(MP_QSTR_D12), MP_ROM_PTR(&pin_PA22)}, {MP_OBJ_NEW_QSTR(MP_QSTR_D13), MP_ROM_PTR(&pin_PA23)}, - // ESP UART - {MP_OBJ_NEW_QSTR(MP_QSTR_ESP_RX), MP_ROM_PTR(&pin_PB17)}, - {MP_OBJ_NEW_QSTR(MP_QSTR_RX), MP_ROM_PTR(&pin_PB17)}, - {MP_OBJ_NEW_QSTR(MP_QSTR_ESP_TX), MP_ROM_PTR(&pin_PB16)}, - {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)}, @@ -60,6 +54,8 @@ STATIC const mp_rom_map_elem_t board_global_dict_table[] = { {MP_OBJ_NEW_QSTR(MP_QSTR_ESP_GPIO0), MP_ROM_PTR(&pin_PA31)}, {MP_OBJ_NEW_QSTR(MP_QSTR_ESP_BUSY), MP_ROM_PTR(&pin_PA00)}, {MP_OBJ_NEW_QSTR(MP_QSTR_ESP_RESET), MP_ROM_PTR(&pin_PB12)}, + {MP_OBJ_NEW_QSTR(MP_QSTR_ESP_TX), MP_ROM_PTR(&pin_PB16)}, + {MP_OBJ_NEW_QSTR(MP_QSTR_ESP_RX), MP_ROM_PTR(&pin_PB17)}, // TFT control pins {MP_OBJ_NEW_QSTR(MP_QSTR_TFT_LITE), MP_ROM_PTR(&pin_PA01)}, @@ -71,7 +67,6 @@ 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_ROM_QSTR(MP_QSTR_DISPLAY), MP_ROM_PTR(&displays[0].display)}}; MP_DEFINE_CONST_DICT(board_module_globals, board_global_dict_table); diff --git a/ports/atmel-samd/boards/pyportal/mpconfigboard.h b/ports/atmel-samd/boards/pyportal/mpconfigboard.h index 2c4cf4f580..00c376ad90 100644 --- a/ports/atmel-samd/boards/pyportal/mpconfigboard.h +++ b/ports/atmel-samd/boards/pyportal/mpconfigboard.h @@ -24,9 +24,6 @@ #define DEFAULT_SPI_BUS_MOSI (&pin_PA12) #define DEFAULT_SPI_BUS_MISO (&pin_PA14) -#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 #define IGNORE_PIN_PA25 1 diff --git a/ports/atmel-samd/boards/pyportal/pins.c b/ports/atmel-samd/boards/pyportal/pins.c index 36140427cb..461ee98da5 100644 --- a/ports/atmel-samd/boards/pyportal/pins.c +++ b/ports/atmel-samd/boards/pyportal/pins.c @@ -58,11 +58,7 @@ STATIC const mp_rom_map_elem_t board_global_dict_table[] = { { MP_OBJ_NEW_QSTR(MP_QSTR_ESP_BUSY), MP_ROM_PTR(&pin_PB16) }, { MP_OBJ_NEW_QSTR(MP_QSTR_ESP_RESET), MP_ROM_PTR(&pin_PB17) }, { MP_OBJ_NEW_QSTR(MP_QSTR_ESP_RTS), MP_ROM_PTR(&pin_PA15) }, - - // UART - { MP_OBJ_NEW_QSTR(MP_QSTR_TX), MP_ROM_PTR(&pin_PB12) }, { MP_OBJ_NEW_QSTR(MP_QSTR_ESP_TX), MP_ROM_PTR(&pin_PB12) }, - { MP_OBJ_NEW_QSTR(MP_QSTR_RX), MP_ROM_PTR(&pin_PB13) }, { MP_OBJ_NEW_QSTR(MP_QSTR_ESP_RX), MP_ROM_PTR(&pin_PB13) }, // SPI @@ -80,7 +76,6 @@ 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_ROM_QSTR(MP_QSTR_DISPLAY), MP_ROM_PTR(&displays[0].display) }, }; diff --git a/ports/atmel-samd/boards/pyportal_titano/mpconfigboard.h b/ports/atmel-samd/boards/pyportal_titano/mpconfigboard.h index 4d58b81839..a76f1db5c8 100644 --- a/ports/atmel-samd/boards/pyportal_titano/mpconfigboard.h +++ b/ports/atmel-samd/boards/pyportal_titano/mpconfigboard.h @@ -22,9 +22,6 @@ #define DEFAULT_SPI_BUS_MOSI (&pin_PA12) #define DEFAULT_SPI_BUS_MISO (&pin_PA14) -#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 #define IGNORE_PIN_PA25 1 diff --git a/ports/atmel-samd/boards/pyportal_titano/pins.c b/ports/atmel-samd/boards/pyportal_titano/pins.c index cf8dfbbb27..461ee98da5 100644 --- a/ports/atmel-samd/boards/pyportal_titano/pins.c +++ b/ports/atmel-samd/boards/pyportal_titano/pins.c @@ -58,13 +58,8 @@ STATIC const mp_rom_map_elem_t board_global_dict_table[] = { { MP_OBJ_NEW_QSTR(MP_QSTR_ESP_BUSY), MP_ROM_PTR(&pin_PB16) }, { MP_OBJ_NEW_QSTR(MP_QSTR_ESP_RESET), MP_ROM_PTR(&pin_PB17) }, { MP_OBJ_NEW_QSTR(MP_QSTR_ESP_RTS), MP_ROM_PTR(&pin_PA15) }, - - // ESP UART { MP_OBJ_NEW_QSTR(MP_QSTR_ESP_TX), MP_ROM_PTR(&pin_PB12) }, - { MP_OBJ_NEW_QSTR(MP_QSTR_TX), MP_ROM_PTR(&pin_PB12) }, - { MP_OBJ_NEW_QSTR(MP_QSTR_ESP_RX), MP_ROM_PTR(&pin_PB13) }, - { MP_OBJ_NEW_QSTR(MP_QSTR_RX), MP_ROM_PTR(&pin_PB13) }, // SPI { MP_OBJ_NEW_QSTR(MP_QSTR_MOSI),MP_ROM_PTR(&pin_PA12) }, @@ -81,7 +76,6 @@ 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_ROM_QSTR(MP_QSTR_DISPLAY), MP_ROM_PTR(&displays[0].display) }, }; From 5e5045ddf1ed0ca88fface94c17c7af123ee6ff4 Mon Sep 17 00:00:00 2001 From: Wellington Terumi Uemura Date: Sun, 29 Nov 2020 10:02:13 +0000 Subject: [PATCH 174/207] Translated using Weblate (Portuguese (Brazil)) Currently translated at 100.0% (864 of 864 strings) Translation: CircuitPython/main Translate-URL: https://hosted.weblate.org/projects/circuitpython/main/pt_BR/ --- locale/pt_BR.po | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/locale/pt_BR.po b/locale/pt_BR.po index 8f899a12c4..36b1317d7a 100644 --- a/locale/pt_BR.po +++ b/locale/pt_BR.po @@ -6,7 +6,7 @@ msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2020-11-24 15:40-0500\n" -"PO-Revision-Date: 2020-11-24 23:22+0000\n" +"PO-Revision-Date: 2020-11-30 18:06+0000\n" "Last-Translator: Wellington Terumi Uemura \n" "Language-Team: \n" "Language: pt_BR\n" @@ -1451,7 +1451,7 @@ msgstr "Somente os endereços IPv4 são suportados" #: ports/esp32s2/common-hal/socketpool/SocketPool.c msgid "Only IPv4 sockets supported" -msgstr "" +msgstr "Apenas soquetes IPv4 são suportados" #: shared-module/displayio/OnDiskBitmap.c #, c-format From f65449027a037627cd639501a11d3a754abb0ddf Mon Sep 17 00:00:00 2001 From: Jonny Bergdahl Date: Mon, 30 Nov 2020 14:49:04 +0000 Subject: [PATCH 175/207] Translated using Weblate (Swedish) Currently translated at 100.0% (864 of 864 strings) Translation: CircuitPython/main Translate-URL: https://hosted.weblate.org/projects/circuitpython/main/sv/ --- locale/sv.po | 66 ++++++++++++++++++++++++++-------------------------- 1 file changed, 33 insertions(+), 33 deletions(-) diff --git a/locale/sv.po b/locale/sv.po index 66c1f345a2..47739e4aa1 100644 --- a/locale/sv.po +++ b/locale/sv.po @@ -6,7 +6,7 @@ msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2020-11-24 15:40-0500\n" -"PO-Revision-Date: 2020-11-20 22:28+0000\n" +"PO-Revision-Date: 2020-11-30 18:06+0000\n" "Last-Translator: Jonny Bergdahl \n" "Language-Team: LANGUAGE \n" "Language: sv\n" @@ -871,7 +871,7 @@ msgstr "FFT är enbart definierade för ndarrays" #: extmod/ulab/code/fft/fft.c msgid "FFT is implemented for linear arrays only" -msgstr "" +msgstr "FTT är enbart implementerad för linjära matriser" #: ports/esp32s2/common-hal/socketpool/Socket.c msgid "Failed SSL handshake" @@ -1282,7 +1282,7 @@ msgstr "Måste använda ett multipel av 6 rgb-pinnar, inte %d" #: ports/esp32s2/common-hal/nvm/ByteArray.c msgid "NVS Error" -msgstr "" +msgstr "NVS-fel" #: py/parse.c msgid "Name too long" @@ -1442,7 +1442,7 @@ msgstr "Endast IPv4-adresser stöds" #: ports/esp32s2/common-hal/socketpool/SocketPool.c msgid "Only IPv4 sockets supported" -msgstr "" +msgstr "Endast IPv4-socket stöds" #: shared-module/displayio/OnDiskBitmap.c #, c-format @@ -2099,7 +2099,7 @@ msgstr "argumentet argsort måste vara en ndarray" #: extmod/ulab/code/numerical/numerical.c msgid "argsort is not implemented for flattened arrays" -msgstr "" +msgstr "argsort är inte implementerad för tillplattade matriser" #: py/runtime.c msgid "argument has wrong type" @@ -2124,7 +2124,7 @@ msgstr "argumenten måste vara ndarray" #: extmod/ulab/code/ndarray.c msgid "array and index length must be equal" -msgstr "" +msgstr "array och indexlängd måste vara lika" #: py/objarray.c shared-bindings/nvm/ByteArray.c msgid "array/bytes required on right side" @@ -2132,7 +2132,7 @@ msgstr "array/bytes krävs på höger sida" #: extmod/ulab/code/numerical/numerical.c msgid "attempt to get (arg)min/(arg)max of empty sequence" -msgstr "" +msgstr "försök att läsa (arg)min/(arg)max av tom sekvens" #: extmod/ulab/code/numerical/numerical.c msgid "attempt to get argmin/argmax of an empty sequence" @@ -2144,15 +2144,15 @@ msgstr "attribut stöds inte än" #: extmod/ulab/code/numerical/numerical.c msgid "axis is out of bounds" -msgstr "" +msgstr "axis är utanför gränsen" #: extmod/ulab/code/numerical/numerical.c msgid "axis must be None, or an integer" -msgstr "" +msgstr "axis måste vara None eller ett heltal" #: extmod/ulab/code/numerical/numerical.c msgid "axis too long" -msgstr "" +msgstr "axis för lång" #: py/builtinevex.c msgid "bad compile mode" @@ -2359,7 +2359,7 @@ msgstr "" #: extmod/ulab/code/ndarray_operators.c msgid "cannot cast output with casting rule" -msgstr "" +msgstr "kan inte casta utdata med regel" #: py/objtype.c msgid "cannot create '%q' instances" @@ -2459,7 +2459,7 @@ msgstr "kan inte avgöra SD-kortversion" #: extmod/ulab/code/numerical/numerical.c msgid "cross is defined for 1D arrays of length 3" -msgstr "" +msgstr "cross är definierad för 1D-matriser med längd 3" #: extmod/ulab/code/approx/approx.c msgid "data must be iterable" @@ -2503,7 +2503,7 @@ msgstr "argumentet diff måste vara en ndarray" #: extmod/ulab/code/numerical/numerical.c msgid "differentiation order out of range" -msgstr "" +msgstr "differentieringsordning utanför intervallet" #: py/modmath.c py/objfloat.c py/objint_longlong.c py/objint_mpz.c py/runtime.c #: shared-bindings/math/__init__.c @@ -2622,7 +2622,7 @@ msgstr "första argumentet måste vara en funktion" #: extmod/ulab/code/ulab_create.c msgid "first argument must be a tuple of ndarrays" -msgstr "" +msgstr "första argumentet måste vara en tupel av ndarray" #: extmod/ulab/code/ndarray.c msgid "first argument must be an iterable" @@ -2679,7 +2679,7 @@ msgstr "funktionen har samma teckenvärden vid slutet av intervall" #: extmod/ulab/code/ndarray.c msgid "function is defined for ndarrays only" -msgstr "" +msgstr "funktionen är enbart definierad för ndarray" #: py/argcheck.c #, c-format @@ -2775,7 +2775,7 @@ msgstr "inline assembler måste vara en funktion" #: extmod/ulab/code/ndarray.c msgid "input and output shapes are not compatible" -msgstr "" +msgstr "indata- och utdataformer är inte kompatibla" #: extmod/ulab/code/ulab_create.c msgid "input argument must be an integer or a 2-tuple" @@ -2787,7 +2787,7 @@ msgstr "indataarraylängden måste vara en multipel av 2" #: extmod/ulab/code/ulab_create.c msgid "input arrays are not compatible" -msgstr "" +msgstr "indatamatriser är inte kompatibla" #: extmod/ulab/code/poly/poly.c msgid "input data must be an iterable" @@ -2803,19 +2803,19 @@ msgstr "indatamatrisen är singulär" #: extmod/ulab/code/user/user.c msgid "input must be a dense ndarray" -msgstr "" +msgstr "indata måste vara en dense ndarray" #: extmod/ulab/code/ulab_create.c msgid "input must be a tensor of rank 2" -msgstr "" +msgstr "indata måste vara en tensor av rank 2" #: extmod/ulab/code/ulab_create.c extmod/ulab/code/user/user.c msgid "input must be an ndarray" -msgstr "" +msgstr "indata måste vara en ndarray" #: extmod/ulab/code/filter/filter.c msgid "input must be one-dimensional" -msgstr "" +msgstr "indata måste vara endimensionell" #: extmod/ulab/code/linalg/linalg.c msgid "input must be square matrix" @@ -2831,7 +2831,7 @@ msgstr "indatavektorer måste ha samma längd" #: extmod/ulab/code/poly/poly.c msgid "inputs are not iterable" -msgstr "" +msgstr "indata är inte iterbara" #: py/parsenum.c msgid "int() arg 2 must be >= 2 and <= 36" @@ -3006,7 +3006,7 @@ msgstr "max_length måste vara > 0" #: extmod/ulab/code/ndarray.c msgid "maximum number of dimensions is 4" -msgstr "" +msgstr "maximalt antal dimensioner är 4" #: py/runtime.c msgid "maximum recursion depth exceeded" @@ -3141,7 +3141,7 @@ msgstr "icke nyckelord arg efter nyckelord arg" #: extmod/ulab/code/linalg/linalg.c msgid "norm is defined for 1D and 2D arrays" -msgstr "" +msgstr "norm är definierad för 1D- och 2D-matriser" #: shared-bindings/_bleio/UUID.c msgid "not a 128-bit UUID" @@ -3209,7 +3209,7 @@ msgstr "sträng har udda längd" #: extmod/ulab/code/ulab_create.c msgid "offset is too large" -msgstr "" +msgstr "offset är för stor" #: py/objstr.c py/objstrunicode.c msgid "offset out of bounds" @@ -3235,11 +3235,11 @@ msgstr "operander kan inte sändas tillsammans" #: extmod/ulab/code/ndarray.c msgid "operation is implemented for 1D Boolean arrays only" -msgstr "" +msgstr "operationen är enbart implementerad för 1D Boolean-matriser" #: extmod/ulab/code/numerical/numerical.c msgid "operation is not implemented for flattened array" -msgstr "" +msgstr "operationen inte implementeras för tillplattad matris" #: extmod/ulab/code/numerical/numerical.c msgid "operation is not implemented on ndarrays" @@ -3378,7 +3378,7 @@ msgstr "begärd längd %d men objektet har längden %d" #: extmod/ulab/code/ndarray_operators.c msgid "results cannot be cast to specified type" -msgstr "" +msgstr "resultaten kan inte castas till angiven typ" #: py/compile.c msgid "return annotation must be an identifier" @@ -3400,7 +3400,7 @@ msgstr "rgb_pins[%d] är inte på samma port som en klocka" #: extmod/ulab/code/numerical/numerical.c msgid "roll argument must be an ndarray" -msgstr "" +msgstr "argumentet roll måste vara en ndarray" #: py/objstr.c msgid "rsplit(None,n)" @@ -3428,7 +3428,7 @@ msgstr "skriptkompilering stöds inte" #: extmod/ulab/code/ndarray.c msgid "shape must be a tuple" -msgstr "" +msgstr "shape måste vara en tuple" #: py/objstr.c msgid "sign not allowed in string format specifier" @@ -3577,7 +3577,7 @@ msgstr "timestamp utom räckvidd för plattformens \"time_t\"" #: extmod/ulab/code/ndarray.c msgid "tobytes can be invoked for dense arrays only" -msgstr "" +msgstr "tobyte kan enbart anropas för täta matriser" #: shared-module/struct/__init__.c msgid "too many arguments provided with the given format" @@ -3756,11 +3756,11 @@ msgstr "window måste vara <= interval" #: extmod/ulab/code/numerical/numerical.c msgid "wrong axis index" -msgstr "" +msgstr "fel axelindex" #: extmod/ulab/code/ulab_create.c msgid "wrong axis specified" -msgstr "" +msgstr "fel axel angiven" #: extmod/ulab/code/vector/vectorise.c msgid "wrong input type" From 205d135e1a6cebed18ff809a5676f5d667ad677d Mon Sep 17 00:00:00 2001 From: vkuthan Date: Sun, 29 Nov 2020 20:13:26 +0000 Subject: [PATCH 176/207] Translated using Weblate (Czech) Currently translated at 1.8% (16 of 864 strings) Translation: CircuitPython/main Translate-URL: https://hosted.weblate.org/projects/circuitpython/main/cs/ --- locale/cs.po | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/locale/cs.po b/locale/cs.po index a77a655a62..05b5942fc5 100644 --- a/locale/cs.po +++ b/locale/cs.po @@ -6,15 +6,15 @@ msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2020-11-24 15:40-0500\n" -"PO-Revision-Date: 2020-05-24 03:22+0000\n" -"Last-Translator: dronecz \n" +"PO-Revision-Date: 2020-11-30 18:06+0000\n" +"Last-Translator: vkuthan \n" "Language-Team: LANGUAGE \n" "Language: cs\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=3; plural=(n==1) ? 0 : (n>=2 && n<=4) ? 1 : 2;\n" -"X-Generator: Weblate 4.1-dev\n" +"X-Generator: Weblate 4.4-dev\n" #: main.c msgid "" @@ -74,7 +74,7 @@ msgstr "%q index je mimo rozsah" #: py/obj.c msgid "%q indices must be integers, not %q" -msgstr "" +msgstr "%q indexy musí být celá čísla, ne %q" #: shared-bindings/vectorio/Polygon.c msgid "%q list must be a list" @@ -82,7 +82,7 @@ msgstr "Seznam %q musí být seznam" #: shared-bindings/memorymonitor/AllocationAlarm.c msgid "%q must be >= 0" -msgstr "" +msgstr "%q musí být >= 0" #: shared-bindings/_bleio/CharacteristicBuffer.c #: shared-bindings/_bleio/PacketBuffer.c shared-bindings/displayio/Group.c @@ -98,7 +98,7 @@ msgstr " %q musí být n-tice délky 2" #: shared-bindings/canio/Match.c msgid "%q out of range" -msgstr "" +msgstr "%q je mimo rozsah" #: ports/atmel-samd/common-hal/microcontroller/Pin.c msgid "%q pin invalid" From d6f8a43f6cc755b90376a66b75818744fbe63320 Mon Sep 17 00:00:00 2001 From: Christian Walther Date: Mon, 30 Nov 2020 23:33:07 +0100 Subject: [PATCH 177/207] Eliminate goto. --- supervisor/shared/memory.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/supervisor/shared/memory.c b/supervisor/shared/memory.c index bc82804b70..480c322b01 100755 --- a/supervisor/shared/memory.c +++ b/supervisor/shared/memory.c @@ -105,23 +105,23 @@ void free_memory(supervisor_allocation* allocation) { else { // Check if it's in the list of embedded allocations. supervisor_allocation_node** emb = &MP_STATE_VM(first_embedded_allocation); - while (*emb != NULL) { - if (*emb == node) { - // Found, remove it from the list. - *emb = node->next; - m_free(node -#if MICROPY_MALLOC_USES_ALLOCATED_SIZE - , sizeof(supervisor_allocation_node) + (node->length & ~FLAGS) -#endif - ); - goto done; - } + while (*emb != NULL && *emb != node) { emb = &((*emb)->next); } - // Else it must be within the low or high ranges and becomes a hole. - node->length = ((node->length & ~FLAGS) | HOLE); + if (*emb != NULL) { + // Found, remove it from the list. + *emb = node->next; + m_free(node +#if MICROPY_MALLOC_USES_ALLOCATED_SIZE + , sizeof(supervisor_allocation_node) + (node->length & ~FLAGS) +#endif + ); + } + else { + // Else it must be within the low or high ranges and becomes a hole. + node->length = ((node->length & ~FLAGS) | HOLE); + } } -done: allocation->ptr = NULL; } From 4ac4faaaf684bfb3713f54de5fca452e64847700 Mon Sep 17 00:00:00 2001 From: Scott Shawcroft Date: Mon, 30 Nov 2020 17:02:26 -0800 Subject: [PATCH 178/207] Use nina-fw root certs That way we have one set we use for all of Adafruit's connected devices. --- .gitmodules | 3 +++ ports/esp32s2/certificates/README.md | 3 +++ ports/esp32s2/certificates/nina-fw | 1 + ports/esp32s2/esp-idf-config/sdkconfig.defaults | 7 ++++--- 4 files changed, 11 insertions(+), 3 deletions(-) create mode 100644 ports/esp32s2/certificates/README.md create mode 160000 ports/esp32s2/certificates/nina-fw diff --git a/.gitmodules b/.gitmodules index aaa66caf71..d36613d604 100644 --- a/.gitmodules +++ b/.gitmodules @@ -153,3 +153,6 @@ [submodule "ports/esp32s2/esp-idf"] path = ports/esp32s2/esp-idf url = https://github.com/jepler/esp-idf.git +[submodule "ports/esp32s2/certificates/nina-fw"] + path = ports/esp32s2/certificates/nina-fw + url = https://github.com/adafruit/nina-fw.git diff --git a/ports/esp32s2/certificates/README.md b/ports/esp32s2/certificates/README.md new file mode 100644 index 0000000000..dd5cf25b00 --- /dev/null +++ b/ports/esp32s2/certificates/README.md @@ -0,0 +1,3 @@ +We share root certificates with the nina-fw to ensure they both use the same roots. + +https://github.com/adafruit/nina-fw diff --git a/ports/esp32s2/certificates/nina-fw b/ports/esp32s2/certificates/nina-fw new file mode 160000 index 0000000000..f2a0e601b2 --- /dev/null +++ b/ports/esp32s2/certificates/nina-fw @@ -0,0 +1 @@ +Subproject commit f2a0e601b23212dda4fe305eab30af49a7c7fb41 diff --git a/ports/esp32s2/esp-idf-config/sdkconfig.defaults b/ports/esp32s2/esp-idf-config/sdkconfig.defaults index 025b05caa6..53b169e39e 100644 --- a/ports/esp32s2/esp-idf-config/sdkconfig.defaults +++ b/ports/esp32s2/esp-idf-config/sdkconfig.defaults @@ -575,10 +575,11 @@ CONFIG_MBEDTLS_DYNAMIC_FREE_CONFIG_DATA=y # Certificate Bundle # CONFIG_MBEDTLS_CERTIFICATE_BUNDLE=y -CONFIG_MBEDTLS_CERTIFICATE_BUNDLE_DEFAULT_FULL=y +# CONFIG_MBEDTLS_CERTIFICATE_BUNDLE_DEFAULT_FULL is not set # CONFIG_MBEDTLS_CERTIFICATE_BUNDLE_DEFAULT_CMN is not set -# CONFIG_MBEDTLS_CERTIFICATE_BUNDLE_DEFAULT_NONE is not set -# CONFIG_MBEDTLS_CUSTOM_CERTIFICATE_BUNDLE is not set +CONFIG_MBEDTLS_CERTIFICATE_BUNDLE_DEFAULT_NONE=y +CONFIG_MBEDTLS_CUSTOM_CERTIFICATE_BUNDLE=y +CONFIG_MBEDTLS_CUSTOM_CERTIFICATE_BUNDLE_PATH="certificates/nina-fw/data/roots.pem" # end of Certificate Bundle # CONFIG_MBEDTLS_ECP_RESTARTABLE is not set From 927624468d3f2351826b79ca5789c81980ba0cf7 Mon Sep 17 00:00:00 2001 From: Scott Shawcroft Date: Mon, 30 Nov 2020 18:39:50 -0800 Subject: [PATCH 179/207] Two minor socket changes * Remove BrokenPipeError and prefer to return the number of bytes received. (May be zero.) * Add two minute backup timeout to reduce the chance we hang on recv accidentally. --- ports/esp32s2/common-hal/socketpool/Socket.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/ports/esp32s2/common-hal/socketpool/Socket.c b/ports/esp32s2/common-hal/socketpool/Socket.c index 92247420f9..32c5fc72f2 100644 --- a/ports/esp32s2/common-hal/socketpool/Socket.c +++ b/ports/esp32s2/common-hal/socketpool/Socket.c @@ -64,6 +64,18 @@ bool common_hal_socketpool_socket_connect(socketpool_socket_obj_t* self, const c } else { mp_raise_OSError_msg_varg(translate("Unhandled ESP TLS error %d %d %x %d"), esp_tls_code, flags, err, result); } + } else { + // Connection successful, set the timeout on the underlying socket. We can't rely on the IDF + // to do it because the config structure is only used for TLS connections. Generally, we + // shouldn't hit this timeout because we try to only read available data. However, there is + // always a chance that we try to read something that is used internally. + int fd; + esp_tls_get_conn_sockfd(self->tcp, &fd); + struct timeval tv; + tv.tv_sec = 2 * 60; // Two minutes + tv.tv_usec = 0; + setsockopt(fd, SOL_SOCKET, SO_RCVTIMEO, &tv, sizeof(tv)); + setsockopt(fd, SOL_SOCKET, SO_SNDTIMEO, &tv, sizeof(tv)); } return self->connected; @@ -123,9 +135,6 @@ mp_uint_t common_hal_socketpool_socket_recv_into(socketpool_socket_obj_t* self, // socket closed common_hal_socketpool_socket_close(self); } - if (status < 0) { - mp_raise_BrokenPipeError(); - } return received; } From 9a9e972242e985b5528f0255217b641b065ecf74 Mon Sep 17 00:00:00 2001 From: Scott Shawcroft Date: Tue, 1 Dec 2020 11:01:26 -0800 Subject: [PATCH 180/207] Ignore certificates readme in doc build --- conf.py | 1 + 1 file changed, 1 insertion(+) diff --git a/conf.py b/conf.py index 1d4c420481..1a90b617b8 100644 --- a/conf.py +++ b/conf.py @@ -172,6 +172,7 @@ exclude_patterns = ["**/build*", "ports/atmel-samd/tools", "ports/cxd56/mkspk", "ports/cxd56/spresense-exported-sdk", + "ports/esp32s2/certificates", "ports/esp32s2/esp-idf", "ports/esp32s2/peripherals", "ports/litex/hw", From a95285ad362e00dc560f6500ed9df7c86fbaddd0 Mon Sep 17 00:00:00 2001 From: Szymon Jakubiak Date: Tue, 1 Dec 2020 19:52:29 +0000 Subject: [PATCH 181/207] Translated using Weblate (Polish) Currently translated at 70.7% (611 of 864 strings) Translation: CircuitPython/main Translate-URL: https://hosted.weblate.org/projects/circuitpython/main/pl/ --- locale/pl.po | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/locale/pl.po b/locale/pl.po index 5fbe727efa..5381a96c4e 100644 --- a/locale/pl.po +++ b/locale/pl.po @@ -7,8 +7,8 @@ msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2020-11-24 15:40-0500\n" -"PO-Revision-Date: 2020-11-11 19:13+0000\n" -"Last-Translator: Maciej Stankiewicz \n" +"PO-Revision-Date: 2020-12-01 19:53+0000\n" +"Last-Translator: Szymon Jakubiak \n" "Language-Team: pl\n" "Language: pl\n" "MIME-Version: 1.0\n" @@ -132,7 +132,7 @@ msgstr "" #: py/obj.c msgid "'%q' object does not support item deletion" -msgstr "" +msgstr "'%q' obiekt nie umożliwia kasowania elementów" #: py/runtime.c msgid "'%q' object has no attribute '%q'" From f6cba4c9743cb2a9e5b23c61453d5d3aed789e37 Mon Sep 17 00:00:00 2001 From: Maciej Stankiewicz Date: Tue, 1 Dec 2020 19:51:26 +0000 Subject: [PATCH 182/207] Translated using Weblate (Polish) Currently translated at 70.7% (611 of 864 strings) Translation: CircuitPython/main Translate-URL: https://hosted.weblate.org/projects/circuitpython/main/pl/ --- locale/pl.po | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/locale/pl.po b/locale/pl.po index 5381a96c4e..66048c2477 100644 --- a/locale/pl.po +++ b/locale/pl.po @@ -8,7 +8,7 @@ msgstr "" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2020-11-24 15:40-0500\n" "PO-Revision-Date: 2020-12-01 19:53+0000\n" -"Last-Translator: Szymon Jakubiak \n" +"Last-Translator: Maciej Stankiewicz \n" "Language-Team: pl\n" "Language: pl\n" "MIME-Version: 1.0\n" @@ -3197,7 +3197,7 @@ msgstr "tylko fragmenty ze step=1 (lub None) są wspierane" #: extmod/ulab/code/compare/compare.c extmod/ulab/code/ndarray.c #: extmod/ulab/code/vector/vectorise.c msgid "operands could not be broadcast together" -msgstr "" +msgstr "operandy nie mogły być rozgłaszane razem" #: extmod/ulab/code/ndarray.c msgid "operation is implemented for 1D Boolean arrays only" @@ -3433,7 +3433,7 @@ msgstr "programowy reset\n" #: extmod/ulab/code/numerical/numerical.c msgid "sort argument must be an ndarray" -msgstr "" +msgstr "argument sort musi być ndarray" #: extmod/ulab/code/filter/filter.c msgid "sos array must be of shape (n_section, 6)" @@ -3741,7 +3741,7 @@ msgstr "zła liczba wartości do rozpakowania" #: extmod/ulab/code/ndarray.c msgid "wrong operand type" -msgstr "" +msgstr "zły typ operandu" #: extmod/ulab/code/vector/vectorise.c msgid "wrong output type" From 44e0d98c62097d5e2c53616e380ccc104c4ccfcd Mon Sep 17 00:00:00 2001 From: Szymon Jakubiak Date: Tue, 1 Dec 2020 19:55:54 +0000 Subject: [PATCH 183/207] Translated using Weblate (Polish) Currently translated at 70.9% (613 of 864 strings) Translation: CircuitPython/main Translate-URL: https://hosted.weblate.org/projects/circuitpython/main/pl/ --- locale/pl.po | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/locale/pl.po b/locale/pl.po index 66048c2477..9f8de945ee 100644 --- a/locale/pl.po +++ b/locale/pl.po @@ -7,8 +7,8 @@ msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2020-11-24 15:40-0500\n" -"PO-Revision-Date: 2020-12-01 19:53+0000\n" -"Last-Translator: Maciej Stankiewicz \n" +"PO-Revision-Date: 2020-12-01 19:56+0000\n" +"Last-Translator: Szymon Jakubiak \n" "Language-Team: pl\n" "Language: pl\n" "MIME-Version: 1.0\n" @@ -128,7 +128,7 @@ msgstr "Obiekt '%q' nie wspiera '%q'" #: py/obj.c msgid "'%q' object does not support item assignment" -msgstr "" +msgstr "'%q' obiekt nie wspiera dopisywania elementów" #: py/obj.c msgid "'%q' object does not support item deletion" @@ -152,7 +152,7 @@ msgstr "Obiekt '%q' nie jest iterowalny" #: py/obj.c msgid "'%q' object is not subscriptable" -msgstr "" +msgstr "'%q' obiekt nie jest indeksowany" #: py/emitinlinethumb.c py/emitinlinextensa.c #, c-format From 2b9ca4d48aa6756a5ff4cc794abc3299782bc01b Mon Sep 17 00:00:00 2001 From: Maciej Stankiewicz Date: Tue, 1 Dec 2020 19:53:22 +0000 Subject: [PATCH 184/207] Translated using Weblate (Polish) Currently translated at 70.9% (613 of 864 strings) Translation: CircuitPython/main Translate-URL: https://hosted.weblate.org/projects/circuitpython/main/pl/ --- locale/pl.po | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/locale/pl.po b/locale/pl.po index 9f8de945ee..2c028527dc 100644 --- a/locale/pl.po +++ b/locale/pl.po @@ -8,7 +8,7 @@ msgstr "" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2020-11-24 15:40-0500\n" "PO-Revision-Date: 2020-12-01 19:56+0000\n" -"Last-Translator: Szymon Jakubiak \n" +"Last-Translator: Maciej Stankiewicz \n" "Language-Team: pl\n" "Language: pl\n" "MIME-Version: 1.0\n" @@ -132,7 +132,7 @@ msgstr "'%q' obiekt nie wspiera dopisywania elementów" #: py/obj.c msgid "'%q' object does not support item deletion" -msgstr "'%q' obiekt nie umożliwia kasowania elementów" +msgstr "obiekt '%q' nie wspiera usuwania elementów" #: py/runtime.c msgid "'%q' object has no attribute '%q'" From d3bbb99e071a97d7295f6d46dbed766c2aa51fb5 Mon Sep 17 00:00:00 2001 From: gamblor21 Date: Tue, 1 Dec 2020 17:49:15 -0600 Subject: [PATCH 185/207] Fixing stubs --- .../adafruit_bus_device/I2CDevice.c | 35 +++++++++---------- 1 file changed, 16 insertions(+), 19 deletions(-) diff --git a/shared-bindings/adafruit_bus_device/I2CDevice.c b/shared-bindings/adafruit_bus_device/I2CDevice.c index 3ec4dae12e..4c9086162d 100644 --- a/shared-bindings/adafruit_bus_device/I2CDevice.c +++ b/shared-bindings/adafruit_bus_device/I2CDevice.c @@ -86,7 +86,7 @@ STATIC mp_obj_t adafruit_bus_device_i2cdevice_make_new(const mp_obj_type_t *type return (mp_obj_t)self; } -//| def __enter__(self) -> I2C: +//| def __enter__(self) -> I2CDevice: //| """Context manager entry to lock bus.""" //| ... //| @@ -107,14 +107,13 @@ STATIC mp_obj_t adafruit_bus_device_i2cdevice_obj___exit__(size_t n_args, const } STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(adafruit_bus_device_i2cdevice___exit___obj, 4, 4, adafruit_bus_device_i2cdevice_obj___exit__); -//| def readinto(self, buf, *, start=0, end=None) -> None: -//| """ -//| Read into ``buf`` from the device. The number of bytes read will be the +//| def readinto(self, buf: WriteableBuffer, *, start: int = 0, end: int = 0) -> None: +//| """Read into ``buf`` from the device. The number of bytes read will be the //| length of ``buf``. //| If ``start`` or ``end`` is provided, then the buffer will be sliced //| as if ``buf[start:end]``. This will not cause an allocation like //| ``buf[start:end]`` will so it saves memory. -//| :param bytearray buffer: buffer to write into +//| :param bytearray buf: buffer to write into //| :param int start: Index to start writing at //| :param int end: Index to write up to but not include; if None, use ``len(buf)``""" //| ... @@ -153,17 +152,16 @@ STATIC mp_obj_t adafruit_bus_device_i2cdevice_readinto(size_t n_args, const mp_o } STATIC MP_DEFINE_CONST_FUN_OBJ_KW(adafruit_bus_device_i2cdevice_readinto_obj, 2, adafruit_bus_device_i2cdevice_readinto); -//| def write(self, buf, *, start=0, end=None) -> None: -//| """ -//| Write the bytes from ``buffer`` to the device, then transmit a stop bit. -//| If ``start`` or ``end`` is provided, then the buffer will be sliced -//| as if ``buffer[start:end]``. This will not cause an allocation like -//| ``buffer[start:end]`` will so it saves memory. -//| :param bytearray buffer: buffer containing the bytes to write -//| :param int start: Index to start writing from -//| :param int end: Index to read up to but not include; if None, use ``len(buf)`` -//| """ -//| ... +//| def write(self, buf: ReadableBuffer, *, start: int = 0, end: int = 0) -> None: +//| """Write the bytes from ``buffer`` to the device, then transmit a stop bit. +//| If ``start`` or ``end`` is provided, then the buffer will be sliced +//| as if ``buffer[start:end]``. This will not cause an allocation like +//| ``buffer[start:end]`` will so it saves memory. +//| :param bytearray buf: buffer containing the bytes to write +//| :param int start: Index to start writing from +//| :param int end: Index to read up to but not include; if None, use ``len(buf)`` +//| """ +//| ... //| STATIC void write(adafruit_bus_device_i2cdevice_obj_t *self, mp_obj_t buffer, int32_t start, mp_int_t end) { mp_buffer_info_t bufinfo; @@ -199,9 +197,8 @@ STATIC mp_obj_t adafruit_bus_device_i2cdevice_write(size_t n_args, const mp_obj_ MP_DEFINE_CONST_FUN_OBJ_KW(adafruit_bus_device_i2cdevice_write_obj, 2, adafruit_bus_device_i2cdevice_write); -//| def write_then_readinto(self, out_buffer, in_buffer, *, out_start=0, out_end=None, in_start=0, in_end=None) -> None: -//| """ -//| Write the bytes from ``out_buffer`` to the device, then immediately +//| def write_then_readinto(self, out_buffer: WriteableBuffer, in_buffer: ReadableBuffer, *, out_start: int = 0, out_end: int = 0, in_start: int = 0, in_end: int = 0) -> None: +//| """Write the bytes from ``out_buffer`` to the device, then immediately //| reads into ``in_buffer`` from the device. The number of bytes read //| will be the length of ``in_buffer``. //| If ``out_start`` or ``out_end`` is provided, then the output buffer From 8b7c23c1ee5d3fbfbda9116d6689e99f44e3b95a Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Tue, 1 Dec 2020 20:01:14 -0500 Subject: [PATCH 186/207] address review comments --- lib/utils/pyexec.c | 6 +- lib/utils/pyexec.h | 1 + main.c | 10 +++ .../common-hal/microcontroller/Processor.c | 2 +- .../common-hal/microcontroller/Processor.c | 2 +- ports/esp32s2/common-hal/alarm/__init__.c | 43 +++++++--- ports/esp32s2/common-hal/alarm/pin/PinAlarm.c | 13 +-- ports/esp32s2/common-hal/alarm/pin/PinAlarm.h | 2 +- .../common-hal/microcontroller/Processor.c | 2 +- .../common-hal/microcontroller/Processor.c | 2 +- .../common-hal/microcontroller/Processor.c | 2 +- .../common-hal/microcontroller/Processor.c | 2 +- py/obj.h | 4 + py/objexcept.c | 3 + py/reload.c | 22 ++++- py/reload.h | 22 ++++- shared-bindings/alarm/__init__.c | 80 +++++++++---------- shared-bindings/alarm/__init__.h | 4 +- shared-bindings/alarm/pin/PinAlarm.c | 37 ++++----- shared-bindings/alarm/pin/PinAlarm.h | 4 +- 20 files changed, 160 insertions(+), 103 deletions(-) diff --git a/lib/utils/pyexec.c b/lib/utils/pyexec.c index 378fb6267d..68a3710ce6 100755 --- a/lib/utils/pyexec.c +++ b/lib/utils/pyexec.c @@ -101,7 +101,7 @@ STATIC int parse_compile_execute(const void *source, mp_parse_input_kind_t input #endif } - // If the code was loaded from a file its likely to be running for a while so we'll long + // If the code was loaded from a file it's likely to be running for a while so we'll long // live it and collect any garbage before running. if (input_kind == MP_PARSE_FILE_INPUT) { module_fun = make_obj_long_lived(module_fun, 6); @@ -132,6 +132,10 @@ STATIC int parse_compile_execute(const void *source, mp_parse_input_kind_t input if (mp_obj_is_subclass_fast(mp_obj_get_type((mp_obj_t)nlr.ret_val), &mp_type_SystemExit)) { // at the moment, the value of SystemExit is unused ret = pyexec_system_exit; +#if CIRCUITPY_ALARM + } else if (mp_obj_is_subclass_fast(mp_obj_get_type((mp_obj_t)nlr.ret_val), &mp_type_DeepSleepRequest)) { + ret = PYEXEC_DEEP_SLEEP; +#endif } else { if ((mp_obj_t) nlr.ret_val != MP_OBJ_FROM_PTR(&MP_STATE_VM(mp_reload_exception))) { mp_obj_print_exception(&mp_plat_print, (mp_obj_t)nlr.ret_val); diff --git a/lib/utils/pyexec.h b/lib/utils/pyexec.h index cef72a76c7..4c773cd640 100644 --- a/lib/utils/pyexec.h +++ b/lib/utils/pyexec.h @@ -49,6 +49,7 @@ extern int pyexec_system_exit; #define PYEXEC_FORCED_EXIT (0x100) #define PYEXEC_SWITCH_MODE (0x200) #define PYEXEC_EXCEPTION (0x400) +#define PYEXEC_DEEP_SLEEP (0x800) int pyexec_raw_repl(void); int pyexec_friendly_repl(void); diff --git a/main.c b/main.c index dda439d6de..270c0eacf7 100755 --- a/main.c +++ b/main.c @@ -291,11 +291,21 @@ STATIC bool run_code_py(safe_mode_t safe_mode) { } } #endif + + // TODO: on deep sleep, make sure display is refreshed before sleeping (for e-ink). + cleanup_after_vm(heap); if (result.return_code & PYEXEC_FORCED_EXIT) { return reload_requested; } + + #if CIRCUITPY_ALARM + if (result.return_code & PYEXEC_DEEP_SLEEP) { + common_hal_alarm_enter_deep_sleep(); + // Does not return. + } + #endif } // Program has finished running. diff --git a/ports/atmel-samd/common-hal/microcontroller/Processor.c b/ports/atmel-samd/common-hal/microcontroller/Processor.c index 9955212657..8c288a352e 100644 --- a/ports/atmel-samd/common-hal/microcontroller/Processor.c +++ b/ports/atmel-samd/common-hal/microcontroller/Processor.c @@ -352,5 +352,5 @@ void common_hal_mcu_processor_get_uid(uint8_t raw_id[]) { } mcu_reset_reason_t common_hal_mcu_processor_get_reset_reason(void) { - return RESET_REASON_POWER_ON; + return RESET_REASON_UNKNOWN; } diff --git a/ports/cxd56/common-hal/microcontroller/Processor.c b/ports/cxd56/common-hal/microcontroller/Processor.c index bd778e80dd..3cb187de61 100644 --- a/ports/cxd56/common-hal/microcontroller/Processor.c +++ b/ports/cxd56/common-hal/microcontroller/Processor.c @@ -50,5 +50,5 @@ void common_hal_mcu_processor_get_uid(uint8_t raw_id[]) { } mcu_reset_reason_t common_hal_mcu_processor_get_reset_reason(void) { - return RESET_REASON_POWER_ON; + return RESET_REASON_UNKNOWN; } diff --git a/ports/esp32s2/common-hal/alarm/__init__.c b/ports/esp32s2/common-hal/alarm/__init__.c index e044103bce..11e173fe2e 100644 --- a/ports/esp32s2/common-hal/alarm/__init__.c +++ b/ports/esp32s2/common-hal/alarm/__init__.c @@ -29,15 +29,16 @@ #include "py/objtuple.h" #include "py/runtime.h" -#include "shared-bindings/alarm/__init__.h" #include "shared-bindings/alarm/pin/PinAlarm.h" #include "shared-bindings/alarm/time/TimeAlarm.h" #include "shared-bindings/microcontroller/__init__.h" #include "shared-bindings/time/__init__.h" +#include "shared-bindings/wifi/__init__.h" + +#include "common-hal/alarm/__init__.h" #include "esp_log.h" #include "esp_sleep.h" -#include "esp_wifi.h" STATIC mp_obj_tuple_t *_deep_sleep_alarms; @@ -101,7 +102,7 @@ STATIC void setup_sleep_alarms(size_t n_alarms, const mp_obj_t *alarms) { mp_float_t now_secs = uint64_to_float(common_hal_time_monotonic_ms()) / 1000.0f; mp_float_t wakeup_in_secs = MAX(0.0f, time_alarm->monotonic_time - now_secs); const uint64_t sleep_for_us = (uint64_t) (wakeup_in_secs * 1000000); - ESP_LOGI("ALARM", "Sleep for us: %lld", sleep_for_us); + ESP_LOGI("ALARM", "will sleep for us: %lld", sleep_for_us); esp_sleep_enable_timer_wakeup(sleep_for_us); } } @@ -157,25 +158,41 @@ mp_obj_t common_hal_alarm_wait_until_alarms(size_t n_alarms, const mp_obj_t *ala return mp_const_none; } -mp_obj_t common_hal_alarm_sleep_until_alarms(size_t n_alarms, const mp_obj_t *alarms) { +// Is it safe to do a light sleep? Check whether WiFi is on or there are +// other ongoing tasks that should not be shut down. +static bool light_sleep_ok(void) { + return !common_hal_wifi_radio_get_enabled(&common_hal_wifi_radio_obj); +} + +mp_obj_t common_hal_alarm_light_sleep_until_alarms(size_t n_alarms, const mp_obj_t *alarms) { if (n_alarms == 0) { return mp_const_none; } - setup_sleep_alarms(n_alarms, alarms); - - // Shut down wifi cleanly. - esp_wifi_stop(); - ESP_LOGI("ALARM", "start light sleep"); - esp_light_sleep_start(); - return common_hal_alarm_get_wake_alarm(); + if (light_sleep_ok()) { + ESP_LOGI("ALARM", "start light sleep"); + setup_sleep_alarms(n_alarms, alarms); + esp_light_sleep_start(); + return common_hal_alarm_get_wake_alarm(); + } else { + // Don't do an ESP32 light sleep. + return common_hal_alarm_wait_until_alarms(n_alarms, alarms); + } } void common_hal_alarm_exit_and_deep_sleep_until_alarms(size_t n_alarms, const mp_obj_t *alarms) { setup_sleep_alarms(n_alarms, alarms); - // Shut down wifi cleanly. - esp_wifi_stop(); + // Raise an exception, which will be processed in main.c. + mp_raise_arg1(&mp_type_DeepSleepRequest, NULL); +} + +void common_hal_alarm_prepare_for_deep_sleep(void) { + // Turn off WiFi and anything else that should be shut down cleanly. + common_hal_wifi_radio_set_enabled(&common_hal_wifi_radio_obj, false); +} + +void NORETURN common_hal_alarm_enter_deep_sleep(void) { ESP_LOGI("ALARM", "start deep sleep"); esp_deep_sleep_start(); } diff --git a/ports/esp32s2/common-hal/alarm/pin/PinAlarm.c b/ports/esp32s2/common-hal/alarm/pin/PinAlarm.c index 438d6885dc..582a665729 100644 --- a/ports/esp32s2/common-hal/alarm/pin/PinAlarm.c +++ b/ports/esp32s2/common-hal/alarm/pin/PinAlarm.c @@ -29,26 +29,21 @@ #include "shared-bindings/alarm/pin/PinAlarm.h" #include "shared-bindings/microcontroller/Pin.h" -void common_hal_alarm_pin_pin_alarm_construct(alarm_pin_pin_alarm_obj_t *self, const mp_obj_t pins[], size_t num_pins, bool value, bool all_same_value, bool edge, bool pull) { - self->pins = mp_obj_new_tuple(num_pins, pins); +void common_hal_alarm_pin_pin_alarm_construct(alarm_pin_pin_alarm_obj_t *self, mcu_pin_obj_t *pin, bool value, bool edge, bool pull) { + self->pin = pin; self->value = value; - self->all_same_value = all_same_value; self->edge = edge; self->pull = pull; } -mp_obj_tuple_t *common_hal_alarm_pin_pin_alarm_get_pins(alarm_pin_pin_alarm_obj_t *self) { - return self->pins; +mcu_pin_obj_t *common_hal_alarm_pin_pin_alarm_get_pin(alarm_pin_pin_alarm_obj_t *self) { + return self->pin; } bool common_hal_alarm_pin_pin_alarm_get_value(alarm_pin_pin_alarm_obj_t *self) { return self->value; } -bool common_hal_alarm_pin_pin_alarm_get_all_same_value(alarm_pin_pin_alarm_obj_t *self) { - return self->all_same_value; -} - bool common_hal_alarm_pin_pin_alarm_get_edge(alarm_pin_pin_alarm_obj_t *self) { return self->edge; } diff --git a/ports/esp32s2/common-hal/alarm/pin/PinAlarm.h b/ports/esp32s2/common-hal/alarm/pin/PinAlarm.h index d7e7e2552a..0eaa7777f5 100644 --- a/ports/esp32s2/common-hal/alarm/pin/PinAlarm.h +++ b/ports/esp32s2/common-hal/alarm/pin/PinAlarm.h @@ -29,7 +29,7 @@ typedef struct { mp_obj_base_t base; - mp_obj_tuple_t *pins; + mcu_pin_obj_t *pin; bool value; bool all_same_value; bool edge; diff --git a/ports/litex/common-hal/microcontroller/Processor.c b/ports/litex/common-hal/microcontroller/Processor.c index 013a7ca035..4d4f88288e 100644 --- a/ports/litex/common-hal/microcontroller/Processor.c +++ b/ports/litex/common-hal/microcontroller/Processor.c @@ -66,5 +66,5 @@ void common_hal_mcu_processor_get_uid(uint8_t raw_id[]) { } mcu_reset_reason_t common_hal_mcu_processor_get_reset_reason(void) { - return RESET_REASON_POWER_ON; + return RESET_REASON_UNKNOWN; } diff --git a/ports/mimxrt10xx/common-hal/microcontroller/Processor.c b/ports/mimxrt10xx/common-hal/microcontroller/Processor.c index 28fe67db7c..efbde35d28 100644 --- a/ports/mimxrt10xx/common-hal/microcontroller/Processor.c +++ b/ports/mimxrt10xx/common-hal/microcontroller/Processor.c @@ -73,5 +73,5 @@ void common_hal_mcu_processor_get_uid(uint8_t raw_id[]) { } mcu_reset_reason_t common_hal_mcu_processor_get_reset_reason(void) { - return RESET_REASON_POWER_ON; + return RESET_REASON_UNKNOWN; } diff --git a/ports/nrf/common-hal/microcontroller/Processor.c b/ports/nrf/common-hal/microcontroller/Processor.c index e2695139c5..ab5f29b5db 100644 --- a/ports/nrf/common-hal/microcontroller/Processor.c +++ b/ports/nrf/common-hal/microcontroller/Processor.c @@ -123,5 +123,5 @@ void common_hal_mcu_processor_get_uid(uint8_t raw_id[]) { } mcu_reset_reason_t common_hal_mcu_processor_get_reset_reason(void) { - return RESET_REASON_POWER_ON; + return RESET_REASON_UNKNOWN; } diff --git a/ports/stm/common-hal/microcontroller/Processor.c b/ports/stm/common-hal/microcontroller/Processor.c index d77d287a9e..dd04c56dce 100644 --- a/ports/stm/common-hal/microcontroller/Processor.c +++ b/ports/stm/common-hal/microcontroller/Processor.c @@ -143,5 +143,5 @@ void common_hal_mcu_processor_get_uid(uint8_t raw_id[]) { } mcu_reset_reason_t common_hal_mcu_processor_get_reset_reason(void) { - return RESET_REASON_POWER_ON; + return RESET_REASON_UNKNOWN; } diff --git a/py/obj.h b/py/obj.h index e055c97506..066562cc43 100644 --- a/py/obj.h +++ b/py/obj.h @@ -640,6 +640,10 @@ extern const mp_obj_type_t mp_type_UnicodeError; extern const mp_obj_type_t mp_type_ValueError; extern const mp_obj_type_t mp_type_ViperTypeError; extern const mp_obj_type_t mp_type_ZeroDivisionError; +#if CIRCUITPY_ALARM +extern const mp_obj_type_t mp_type_DeepSleepRequest; +#endif + // Constant objects, globally accessible // The macros are for convenience only diff --git a/py/objexcept.c b/py/objexcept.c index 01ba6da9c4..afefee2caf 100644 --- a/py/objexcept.c +++ b/py/objexcept.c @@ -318,6 +318,9 @@ MP_DEFINE_EXCEPTION(Exception, BaseException) #if MICROPY_PY_BUILTINS_STR_UNICODE MP_DEFINE_EXCEPTION(UnicodeError, ValueError) //TODO: Implement more UnicodeError subclasses which take arguments +#endif +#if CIRCUITPY_ALARM + MP_DEFINE_EXCEPTION(DeepSleepRequest, BaseException) #endif MP_DEFINE_EXCEPTION(MpyError, ValueError) /* diff --git a/py/reload.c b/py/reload.c index 95305f2c9c..f9f8a590a6 100644 --- a/py/reload.c +++ b/py/reload.c @@ -1,6 +1,22 @@ -// -// Created by Roy Hooper on 2018-05-14. -// + /* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2018 by Roy Hooper + * 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 "reload.h" #include "py/mpstate.h" diff --git a/py/reload.h b/py/reload.h index 72e84e5ca6..3e8928a32c 100644 --- a/py/reload.h +++ b/py/reload.h @@ -1,6 +1,22 @@ -// -// Created by Roy Hooper on 2018-05-14. -// + /* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2018 by Roy Hooper + * 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_RELOAD_H #define CIRCUITPYTHON_RELOAD_H diff --git a/shared-bindings/alarm/__init__.c b/shared-bindings/alarm/__init__.c index 195ec63745..c983130a19 100644 --- a/shared-bindings/alarm/__init__.c +++ b/shared-bindings/alarm/__init__.c @@ -43,19 +43,21 @@ //| //| Provides alarms that trigger based on time intervals or on external events, such as pin //| changes. -//| The program can simply wait for these alarms, or go into a sleep state and -//| and be awoken when they trigger. +//| The program can simply wait for these alarms, or go to sleep and be awoken when they trigger. //| //| There are two supported levels of sleep: light sleep and deep sleep. //| -//| Light sleep leaves the CPU and RAM powered so the program can resume after sleeping. -//| -//| *However, note that on some platforms, light sleep will shut down some communications, including -//| WiFi and/or Bluetooth.* +//| Light sleep keeps sufficient state so the program can resume after sleeping. +//| It does not shut down WiFi, BLE, or other communications, or ongoing activities such +//| as audio playback. It reduces power consumption to the extent possible that leaves +//| these continuing activities running. In some cases there may be no decrease in power consumption. //| //| Deep sleep shuts down power to nearly all of the microcontroller including the CPU and RAM. This can save //| a more significant amount of power, but CircuitPython must restart ``code.py`` from the beginning when //| awakened. +//| +//| For both light sleep and deep sleep, if CircuitPython is connected to a host computer, +//| maintaining the connection takes priority and power consumption may not be reduced. //| """ //| @@ -75,45 +77,39 @@ void validate_objs_are_alarms(size_t n_args, const mp_obj_t *objs) { } } -//| def wait_until_alarms(*alarms: Alarm) -> Alarm: -//| """Wait for one of the alarms to trigger. The triggering alarm is returned. -//| is returned, and is also available as `alarm.wake_alarm`. Nothing is shut down -//| or interrupted. Power consumption will be reduced if possible. -//| -//| If no alarms are specified, return immediately. -//| """ -//| ... -//| -STATIC mp_obj_t alarm_wait_until_alarms(size_t n_args, const mp_obj_t *args) { - validate_objs_are_alarms(n_args, args); - common_hal_alarm_wait_until_alarms(n_args, args); - return mp_const_none; -} -MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(alarm_wait_until_alarms_obj, 1, MP_OBJ_FUN_ARGS_MAX, alarm_wait_until_alarms); - -//| def sleep_until_alarms(*alarms: Alarm) -> Alarm: +//| def light_sleep_until_alarms(*alarms: Alarm) -> Alarm: //| """Go into a light sleep until awakened one of the alarms. The alarm causing the wake-up //| is returned, and is also available as `alarm.wake_alarm`. //| -//| Some functionality may be shut down during sleep. On ESP32-S2, WiFi is turned off, -//| and existing connections are broken. -//| //| If no alarms are specified, return immediately. //| -//| **If CircuitPython is connected to a host computer,** `alarm.sleep_until_alarms()` -//| **does not go into light sleep.** -//| Instead, light sleep is simulated by doing `alarm.wait_until_alarms()`, +//| **If CircuitPython is connected to a host computer, the connection will be maintained, +//| and the microcontroller may not actually go into a light sleep.** //| This allows the user to interrupt an existing program with ctrl-C, -//| and to edit the files in CIRCUITPY, which would not be possible in true light sleep +//| and to edit the files in CIRCUITPY, which would not be possible in true light sleep. +//| Thus, to use light sleep and save significant power, +// it may be necessary to disconnect from the host. //| """ //| ... //| -STATIC mp_obj_t alarm_sleep_until_alarms(size_t n_args, const mp_obj_t *args) { +STATIC mp_obj_t alarm_light_sleep_until_alarms(size_t n_args, const mp_obj_t *args) { validate_objs_are_alarms(n_args, args); - common_hal_alarm_sleep_until_alarms(n_args, args); + + // See if we are connected to a host. + // Make sure we have been awake long enough for USB to connect (enumeration delay). + int64_t connecting_delay_msec = CIRCUITPY_USB_CONNECTED_SLEEP_DELAY * 1024 - supervisor_ticks_ms64(); + if (connecting_delay_msec > 0) { + common_hal_time_delay_ms(connecting_delay_msec * 1000 / 1024); + } + + if (supervisor_workflow_active()) { + common_hal_alarm_wait_until_alarms(n_args, args); + } else { + common_hal_alarm_light_sleep_until_alarms(n_args, args); + } return mp_const_none; } -MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(alarm_sleep_until_alarms_obj, 1, MP_OBJ_FUN_ARGS_MAX, alarm_sleep_until_alarms); +MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(alarm_light_sleep_until_alarms_obj, 1, MP_OBJ_FUN_ARGS_MAX, alarm_light_sleep_until_alarms); //| def exit_and_deep_sleep_until_alarms(*alarms: Alarm) -> None: //| """Exit the program and go into a deep sleep, until awakened by one of the alarms. @@ -130,11 +126,10 @@ MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(alarm_sleep_until_alarms_obj, 1, MP_OBJ_FUN_ //| If no alarms are specified, the microcontroller will deep sleep until reset. //| //| **If CircuitPython is connected to a host computer, `alarm.exit_and_deep_sleep_until_alarms()` -//| does not go into deep sleep.** -//| Instead, deep sleep is simulated by first doing `alarm.wait_until_alarms()`, -//| and then, when an alarm triggers, by restarting CircuitPython. +//| then the connection will be maintained, and the system will not go into deep sleep.** //| This allows the user to interrupt an existing program with ctrl-C, //| and to edit the files in CIRCUITPY, which would not be possible in true deep sleep. +//| Thus, to use deep sleep and save significant power, you will need to disconnect from the host. //| //| Here is skeletal example that deep-sleeps and restarts every 60 seconds: //| @@ -156,6 +151,10 @@ MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(alarm_sleep_until_alarms_obj, 1, MP_OBJ_FUN_ STATIC mp_obj_t alarm_exit_and_deep_sleep_until_alarms(size_t n_args, const mp_obj_t *args) { validate_objs_are_alarms(n_args, args); + // Shut down WiFi, etc. + common_hal_alarm_prepare_for_deep_sleep(); + + // See if we are connected to a host. // Make sure we have been awake long enough for USB to connect (enumeration delay). int64_t connecting_delay_msec = CIRCUITPY_USB_CONNECTED_SLEEP_DELAY * 1024 - supervisor_ticks_ms64(); if (connecting_delay_msec > 0) { @@ -163,6 +162,7 @@ STATIC mp_obj_t alarm_exit_and_deep_sleep_until_alarms(size_t n_args, const mp_o } if (supervisor_workflow_active()) { + // Simulate deep sleep by waiting for an alarm and then restarting when done. common_hal_alarm_wait_until_alarms(n_args, args); reload_requested = true; supervisor_set_run_reason(RUN_REASON_STARTUP); @@ -175,9 +175,6 @@ STATIC mp_obj_t alarm_exit_and_deep_sleep_until_alarms(size_t n_args, const mp_o } MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(alarm_exit_and_deep_sleep_until_alarms_obj, 1, MP_OBJ_FUN_ARGS_MAX, alarm_exit_and_deep_sleep_until_alarms); -//| """The `alarm.pin` module contains alarm attributes and classes related to pins. -//| """ -//| STATIC const mp_map_elem_t alarm_pin_globals_table[] = { { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_pin) }, @@ -191,9 +188,6 @@ STATIC const mp_obj_module_t alarm_pin_module = { .globals = (mp_obj_dict_t*)&alarm_pin_globals, }; -//| """The `alarm.time` module contains alarm attributes and classes related to time-keeping. -//| """ -//| STATIC const mp_map_elem_t alarm_time_globals_table[] = { { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_time) }, @@ -213,7 +207,7 @@ STATIC mp_map_elem_t alarm_module_globals_table[] = { // wake_alarm is a mutable attribute. { MP_ROM_QSTR(MP_QSTR_wake_alarm), mp_const_none }, - { MP_ROM_QSTR(MP_QSTR_sleep_until_alarms), MP_OBJ_FROM_PTR(&alarm_sleep_until_alarms_obj) }, + { MP_ROM_QSTR(MP_QSTR_light_sleep_until_alarms), MP_OBJ_FROM_PTR(&alarm_light_sleep_until_alarms_obj) }, { MP_ROM_QSTR(MP_QSTR_exit_and_deep_sleep_until_alarms), MP_OBJ_FROM_PTR(&alarm_exit_and_deep_sleep_until_alarms_obj) }, diff --git a/shared-bindings/alarm/__init__.h b/shared-bindings/alarm/__init__.h index 26dbb2897c..380c65ea8c 100644 --- a/shared-bindings/alarm/__init__.h +++ b/shared-bindings/alarm/__init__.h @@ -32,8 +32,10 @@ #include "common-hal/alarm/__init__.h" extern mp_obj_t common_hal_alarm_wait_until_alarms(size_t n_alarms, const mp_obj_t *alarms); -extern mp_obj_t common_hal_alarm_sleep_until_alarms(size_t n_alarms, const mp_obj_t *alarms); +extern mp_obj_t common_hal_alarm_light_sleep_until_alarms(size_t n_alarms, const mp_obj_t *alarms); extern void common_hal_alarm_exit_and_deep_sleep_until_alarms(size_t n_alarms, const mp_obj_t *alarms); +extern void common_hal_alarm_prepare_for_deep_sleep(void); +extern NORETURN void common_hal_alarm_enter_deep_sleep(void); // Used by wake-up code. extern void common_hal_alarm_set_wake_alarm(mp_obj_t alarm); diff --git a/shared-bindings/alarm/pin/PinAlarm.c b/shared-bindings/alarm/pin/PinAlarm.c index a6497d4cde..a435407acc 100644 --- a/shared-bindings/alarm/pin/PinAlarm.c +++ b/shared-bindings/alarm/pin/PinAlarm.c @@ -38,18 +38,16 @@ //| class PinAlarm: //| """Trigger an alarm when a pin changes state.""" //| -//| def __init__(self, *pins: microcontroller.Pin, value: bool, all_same_value: bool = False, edge: bool = False, pull: bool = False) -> None: +//| def __init__(self, pin: microcontroller.Pin, value: bool, edge: bool = False, pull: bool = False) -> None: //| """Create an alarm triggered by a `microcontroller.Pin` level. The alarm is not active //| until it is passed to an `alarm`-enabling function, such as `alarm.sleep_until_alarms()` or //| `alarm.exit_and_deep_sleep_until_alarms()`. //| -//| :param microcontroller.Pin \*pins: The pins to monitor. On some ports, the choice of pins +//| :param microcontroller.Pin pin: The pin to monitor. On some ports, the choice of pin //| may be limited due to hardware restrictions, particularly for deep-sleep alarms. //| :param bool value: When active, trigger when the pin value is high (``True``) or low (``False``). //| On some ports, multiple `PinAlarm` objects may need to have coordinated values //| for deep-sleep alarms. -//| :param bool all_same_value: If ``True``, all pins listed must be at ``value`` to trigger the alarm. -//| If ``False``, any one of the pins going to ``value`` will trigger the alarm. //| :param bool edge: If ``True``, trigger only when there is a transition to the specified //| value of ``value``. If ``True``, if the alarm becomes active when the pin value already //| matches ``value``, the alarm is not triggered: the pin must transition from ``not value`` @@ -65,47 +63,44 @@ STATIC mp_obj_t alarm_pin_pin_alarm_make_new(const mp_obj_type_t *type, mp_uint_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { alarm_pin_pin_alarm_obj_t *self = m_new_obj(alarm_pin_pin_alarm_obj_t); self->base.type = &alarm_pin_pin_alarm_type; - enum { ARG_value, ARG_all_same_value, ARG_edge, ARG_pull }; + enum { ARG_pin, ARG_value, ARG_edge, ARG_pull }; static const mp_arg_t allowed_args[] = { + { MP_QSTR_pin, MP_ARG_REQUIRED | MP_ARG_OBJ }, { MP_QSTR_value, MP_ARG_KW_ONLY | MP_ARG_REQUIRED | MP_ARG_BOOL }, - { MP_QSTR_all_same_value, MP_ARG_KW_ONLY | MP_ARG_BOOL, {.u_bool = false} }, { MP_QSTR_edge, MP_ARG_KW_ONLY | MP_ARG_BOOL, {.u_bool = false} }, { MP_QSTR_pull, MP_ARG_KW_ONLY | MP_ARG_BOOL, {.u_bool = false} }, }; mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; mp_arg_parse_all(0, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); - for (size_t i = 0; i < n_args; i ++) { - validate_obj_is_free_pin(pos_args[i]); - } + mcu_pin_obj_t *pin = validate_obj_is_free_pin(args[ARG_pin].u_obj); - common_hal_alarm_pin_pin_alarm_construct( - self, pos_args, n_args, + common_hal_alarm_pin_pin_alarm_construct(self, + pin, args[ARG_value].u_bool, - args[ARG_all_same_value].u_bool, args[ARG_edge].u_bool, args[ARG_pull].u_bool); return MP_OBJ_FROM_PTR(self); } -//| pins: Tuple[microcontroller.Pin] -//| """The trigger pins.""" +//| pin: microcontroller.Pin +//| """The trigger pin.""" //| -STATIC mp_obj_t alarm_pin_pin_alarm_obj_get_pins(mp_obj_t self_in) { +STATIC mp_obj_t alarm_pin_pin_alarm_obj_get_pin(mp_obj_t self_in) { alarm_pin_pin_alarm_obj_t *self = MP_OBJ_TO_PTR(self_in); - return common_hal_alarm_pin_pin_alarm_get_pins(self); + return common_hal_alarm_pin_pin_alarm_get_pin(self); } -MP_DEFINE_CONST_FUN_OBJ_1(alarm_pin_pin_alarm_get_pins_obj, alarm_pin_pin_alarm_obj_get_pins); +MP_DEFINE_CONST_FUN_OBJ_1(alarm_pin_pin_alarm_get_pin_obj, alarm_pin_pin_alarm_obj_get_pin); -const mp_obj_property_t alarm_pin_pin_alarm_pins_obj = { +const mp_obj_property_t alarm_pin_pin_alarm_pin_obj = { .base.type = &mp_type_property, - .proxy = {(mp_obj_t)&alarm_pin_pin_alarm_get_pins_obj, + .proxy = {(mp_obj_t)&alarm_pin_pin_alarm_get_pin_obj, (mp_obj_t)&mp_const_none_obj, (mp_obj_t)&mp_const_none_obj}, }; -//| value: Tuple[microcontroller.Pin] +//| value: bool //| """The value on which to trigger.""" //| STATIC mp_obj_t alarm_pin_pin_alarm_obj_get_value(mp_obj_t self_in) { @@ -122,7 +117,7 @@ const mp_obj_property_t alarm_pin_pin_alarm_value_obj = { }; STATIC const mp_rom_map_elem_t alarm_pin_pin_alarm_locals_dict_table[] = { - { MP_ROM_QSTR(MP_QSTR_pins), MP_ROM_PTR(&alarm_pin_pin_alarm_pins_obj) }, + { MP_ROM_QSTR(MP_QSTR_pin), MP_ROM_PTR(&alarm_pin_pin_alarm_pin_obj) }, { MP_ROM_QSTR(MP_QSTR_value), MP_ROM_PTR(&alarm_pin_pin_alarm_value_obj) }, }; diff --git a/shared-bindings/alarm/pin/PinAlarm.h b/shared-bindings/alarm/pin/PinAlarm.h index cb69468124..49ba710899 100644 --- a/shared-bindings/alarm/pin/PinAlarm.h +++ b/shared-bindings/alarm/pin/PinAlarm.h @@ -34,8 +34,8 @@ extern const mp_obj_type_t alarm_pin_pin_alarm_type; -void common_hal_alarm_pin_pin_alarm_construct(alarm_pin_pin_alarm_obj_t *self, const mp_obj_t pins[], size_t num_pins, bool value, bool all_same_value, bool edge, bool pull); -extern mp_obj_tuple_t *common_hal_alarm_pin_pin_alarm_get_pins(alarm_pin_pin_alarm_obj_t *self); +void common_hal_alarm_pin_pin_alarm_construct(alarm_pin_pin_alarm_obj_t *self, mcu_pin_obj_t *pin, bool value, bool edge, bool pull); +extern mcu_pin_obj_t *common_hal_alarm_pin_pin_alarm_get_pin(alarm_pin_pin_alarm_obj_t *self); extern bool common_hal_alarm_pin_pin_alarm_get_value(alarm_pin_pin_alarm_obj_t *self); extern bool common_hal_alarm_pin_pin_alarm_get_edge(alarm_pin_pin_alarm_obj_t *self); extern bool common_hal_alarm_pin_pin_alarm_get_pull(alarm_pin_pin_alarm_obj_t *self); From fe1c2fa6f0571d9f5f70ff1e5572dbb0ce629dfb Mon Sep 17 00:00:00 2001 From: gamblor21 Date: Tue, 1 Dec 2020 19:11:17 -0600 Subject: [PATCH 187/207] Removed bus device from simmel build --- ports/nrf/boards/simmel/mpconfigboard.mk | 1 + 1 file changed, 1 insertion(+) diff --git a/ports/nrf/boards/simmel/mpconfigboard.mk b/ports/nrf/boards/simmel/mpconfigboard.mk index e34739c0f3..704881b3c4 100644 --- a/ports/nrf/boards/simmel/mpconfigboard.mk +++ b/ports/nrf/boards/simmel/mpconfigboard.mk @@ -25,6 +25,7 @@ CIRCUITPY_RTC = 1 CIRCUITPY_TOUCHIO = 0 CIRCUITPY_ULAB = 0 CIRCUITPY_WATCHDOG = 1 +CIRCUITPY_BUSDEVICE = 0 # Enable micropython.native #CIRCUITPY_ENABLE_MPY_NATIVE = 1 From 72fa7d88b881d2ed9978c0bd65ce5f8d6eb51703 Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Tue, 1 Dec 2020 20:13:46 -0500 Subject: [PATCH 188/207] fix doc errors --- shared-bindings/alarm/pin/PinAlarm.c | 2 +- shared-bindings/alarm/time/TimeAlarm.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/shared-bindings/alarm/pin/PinAlarm.c b/shared-bindings/alarm/pin/PinAlarm.c index a435407acc..7a5617142b 100644 --- a/shared-bindings/alarm/pin/PinAlarm.c +++ b/shared-bindings/alarm/pin/PinAlarm.c @@ -40,7 +40,7 @@ //| //| def __init__(self, pin: microcontroller.Pin, value: bool, edge: bool = False, pull: bool = False) -> None: //| """Create an alarm triggered by a `microcontroller.Pin` level. The alarm is not active -//| until it is passed to an `alarm`-enabling function, such as `alarm.sleep_until_alarms()` or +//| until it is passed to an `alarm`-enabling function, such as `alarm.light_sleep_until_alarms()` or //| `alarm.exit_and_deep_sleep_until_alarms()`. //| //| :param microcontroller.Pin pin: The pin to monitor. On some ports, the choice of pin diff --git a/shared-bindings/alarm/time/TimeAlarm.c b/shared-bindings/alarm/time/TimeAlarm.c index 17a4faac25..1c4d976ada 100644 --- a/shared-bindings/alarm/time/TimeAlarm.c +++ b/shared-bindings/alarm/time/TimeAlarm.c @@ -48,7 +48,7 @@ mp_obj_t MP_WEAK rtc_get_time_source_time(void) { //| ``monotonic_time``, or when `time.time()` would equal ``epoch_time``. //| Only one of the two arguments can be given. //| The alarm is not active until it is passed to an -//| `alarm`-enabling function, such as `alarm.sleep_until_alarms()` or +//| `alarm`-enabling function, such as `alarm.light_sleep_until_alarms()` or //| `alarm.exit_and_deep_sleep_until_alarms()`. //| //| If the given time is in the past when sleep occurs, the alarm will be triggered From 73e22f9eeb2b02fcf4c39b62ddbabffe6db21199 Mon Sep 17 00:00:00 2001 From: Scott Shawcroft Date: Tue, 1 Dec 2020 18:15:06 -0800 Subject: [PATCH 189/207] Block all tasks (not interrupts) during flash erase Otherwise we risk running code from flash while an erase is in progress, crashing and corrupting the file system. Related to #3744 --- ports/esp32s2/esp-idf-config/sdkconfig.defaults | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/ports/esp32s2/esp-idf-config/sdkconfig.defaults b/ports/esp32s2/esp-idf-config/sdkconfig.defaults index 025b05caa6..2c53da108e 100644 --- a/ports/esp32s2/esp-idf-config/sdkconfig.defaults +++ b/ports/esp32s2/esp-idf-config/sdkconfig.defaults @@ -717,10 +717,8 @@ CONFIG_SPI_FLASH_DANGEROUS_WRITE_ABORTS=y # CONFIG_SPI_FLASH_DANGEROUS_WRITE_ALLOWED is not set # CONFIG_SPI_FLASH_USE_LEGACY_IMPL is not set # CONFIG_SPI_FLASH_BYPASS_BLOCK_ERASE is not set -CONFIG_SPI_FLASH_YIELD_DURING_ERASE=y -CONFIG_SPI_FLASH_ERASE_YIELD_DURATION_MS=20 -CONFIG_SPI_FLASH_ERASE_YIELD_TICKS=1 -CONFIG_SPI_FLASH_WRITE_CHUNK_SIZE=8192 +# CONFIG_SPI_FLASH_YIELD_DURING_ERASE is not set +CONFIG_SPI_FLASH_WRITE_CHUNK_SIZE=4096 # CONFIG_SPI_FLASH_SIZE_OVERRIDE is not set # From cb863e4c5c9ed0c7628ccd737da03085d1bc1a5b Mon Sep 17 00:00:00 2001 From: gamblor21 Date: Tue, 1 Dec 2020 22:19:48 -0600 Subject: [PATCH 190/207] Added to partial builds where frozen removed --- ports/atmel-samd/boards/8086_commander/mpconfigboard.mk | 1 + ports/atmel-samd/boards/feather_m0_rfm69/mpconfigboard.mk | 1 + ports/atmel-samd/boards/feather_m0_rfm9x/mpconfigboard.mk | 1 + ports/atmel-samd/boards/xinabox_cc03/mpconfigboard.mk | 1 + ports/atmel-samd/boards/xinabox_cs11/mpconfigboard.mk | 1 + 5 files changed, 5 insertions(+) diff --git a/ports/atmel-samd/boards/8086_commander/mpconfigboard.mk b/ports/atmel-samd/boards/8086_commander/mpconfigboard.mk index 66e1a12256..f976dfe787 100644 --- a/ports/atmel-samd/boards/8086_commander/mpconfigboard.mk +++ b/ports/atmel-samd/boards/8086_commander/mpconfigboard.mk @@ -19,6 +19,7 @@ SUPEROPT_GC = 0 CFLAGS_INLINE_LIMIT = 60 CIRCUITPY_GAMEPAD = 1 +CIRCUITPY_BUSDEVICE = 1 # Include these Python libraries in firmware. FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_HID diff --git a/ports/atmel-samd/boards/feather_m0_rfm69/mpconfigboard.mk b/ports/atmel-samd/boards/feather_m0_rfm69/mpconfigboard.mk index 3ae94b231f..6ea21ed82e 100644 --- a/ports/atmel-samd/boards/feather_m0_rfm69/mpconfigboard.mk +++ b/ports/atmel-samd/boards/feather_m0_rfm69/mpconfigboard.mk @@ -21,6 +21,7 @@ CIRCUITPY_SAMD = 0 CIRCUITPY_USB_MIDI = 0 CIRCUITPY_USB_HID = 0 CIRCUITPY_TOUCHIO = 0 +CIRCUITPY_BUSDEVICE = 1 CFLAGS_INLINE_LIMIT = 35 # Make more room. diff --git a/ports/atmel-samd/boards/feather_m0_rfm9x/mpconfigboard.mk b/ports/atmel-samd/boards/feather_m0_rfm9x/mpconfigboard.mk index 3ee2396729..76a6be2e34 100644 --- a/ports/atmel-samd/boards/feather_m0_rfm9x/mpconfigboard.mk +++ b/ports/atmel-samd/boards/feather_m0_rfm9x/mpconfigboard.mk @@ -22,6 +22,7 @@ CIRCUITPY_SAMD = 0 CIRCUITPY_USB_MIDI = 0 CIRCUITPY_USB_HID = 0 CIRCUITPY_TOUCHIO = 0 +CIRCUITPY_BUSDEVICE = 1 CFLAGS_INLINE_LIMIT = 35 # Make more room. diff --git a/ports/atmel-samd/boards/xinabox_cc03/mpconfigboard.mk b/ports/atmel-samd/boards/xinabox_cc03/mpconfigboard.mk index 7243c54db7..d6f333b5be 100644 --- a/ports/atmel-samd/boards/xinabox_cc03/mpconfigboard.mk +++ b/ports/atmel-samd/boards/xinabox_cc03/mpconfigboard.mk @@ -21,5 +21,6 @@ CIRCUITPY_PULSEIO=0 CIRCUITPY_ROTARYIO=0 CIRCUITPY_TOUCHIO_USE_NATIVE=0 CIRCUITPY_TOUCHIO=0 +CIRCUITPY_BUSDEVICE=1 # Include these Python libraries in firmware. diff --git a/ports/atmel-samd/boards/xinabox_cs11/mpconfigboard.mk b/ports/atmel-samd/boards/xinabox_cs11/mpconfigboard.mk index 50b2100aba..fd2fa044a8 100644 --- a/ports/atmel-samd/boards/xinabox_cs11/mpconfigboard.mk +++ b/ports/atmel-samd/boards/xinabox_cs11/mpconfigboard.mk @@ -24,6 +24,7 @@ CIRCUITPY_TOUCHIO=0 CIRCUITPY_USB_MIDI=0 CIRCUITPY_RTC=0 CIRCUITPY_COUNTIO=0 +CIRCUITPY_BUSDEVICE=1 # Include these Python libraries in firmware. FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_SD From 1c00deb8be31856cd276ca56303c33ab63053a4a Mon Sep 17 00:00:00 2001 From: Maciej Stankiewicz Date: Tue, 1 Dec 2020 20:02:10 +0000 Subject: [PATCH 191/207] Translated using Weblate (Polish) Currently translated at 71.8% (621 of 864 strings) Translation: CircuitPython/main Translate-URL: https://hosted.weblate.org/projects/circuitpython/main/pl/ --- locale/pl.po | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/locale/pl.po b/locale/pl.po index 2c028527dc..e2a064703e 100644 --- a/locale/pl.po +++ b/locale/pl.po @@ -7,7 +7,7 @@ msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2020-11-24 15:40-0500\n" -"PO-Revision-Date: 2020-12-01 19:56+0000\n" +"PO-Revision-Date: 2020-12-02 20:29+0000\n" "Last-Translator: Maciej Stankiewicz \n" "Language-Team: pl\n" "Language: pl\n" @@ -152,7 +152,7 @@ msgstr "Obiekt '%q' nie jest iterowalny" #: py/obj.c msgid "'%q' object is not subscriptable" -msgstr "'%q' obiekt nie jest indeksowany" +msgstr "obiekt '%q' nie jest indeksowany" #: py/emitinlinethumb.c py/emitinlinextensa.c #, c-format @@ -292,7 +292,7 @@ msgstr "Adres musi mieć %d bajtów" #: shared-bindings/_bleio/Address.c msgid "Address type out of range" -msgstr "" +msgstr "Typ adresu poza zakresem" #: ports/esp32s2/common-hal/canio/CAN.c msgid "All CAN peripherals are in use" @@ -409,7 +409,7 @@ msgstr "Próba przydzielenia %d bloków" #: supervisor/shared/safe_mode.c msgid "Attempted heap allocation when MicroPython VM not running." -msgstr "" +msgstr "Próba przydziału sterty, gdy MicroPython VM nie działa." #: shared-bindings/wifi/Radio.c msgid "Authentication failure" @@ -1191,7 +1191,7 @@ msgstr "Zły tryb uruchomienia." #: shared-module/_bleio/Attribute.c msgid "Invalid security_mode" -msgstr "" +msgstr "Nieprawidłowy security_mode" #: shared-bindings/audiomixer/Mixer.c msgid "Invalid voice" @@ -1393,7 +1393,7 @@ msgstr "Brak pliku/katalogu" #: shared-module/rgbmatrix/RGBMatrix.c msgid "No timer available" -msgstr "" +msgstr "Brak dostępnego timera" #: supervisor/shared/safe_mode.c msgid "Nordic Soft Device failure assertion." @@ -1584,7 +1584,7 @@ msgstr "" #: ports/stm/common-hal/os/__init__.c msgid "Random number generation error" -msgstr "" +msgstr "Błąd generowania liczb losowych" #: shared-bindings/memorymonitor/AllocationSize.c #: shared-bindings/pulseio/PulseIn.c @@ -1665,11 +1665,11 @@ msgstr "Skanuj już w toku. Zatrzymaj za pomocą stop_scan." #: ports/mimxrt10xx/common-hal/busio/UART.c msgid "Selected CTS pin not valid" -msgstr "" +msgstr "Wybrany pin CTS jest nieprawidłowy" #: ports/mimxrt10xx/common-hal/busio/UART.c msgid "Selected RTS pin not valid" -msgstr "" +msgstr "Wybrany pin RTS jest nieprawidłowy" #: ports/atmel-samd/common-hal/audiobusio/I2SOut.c #: ports/atmel-samd/common-hal/audiobusio/PDMIn.c @@ -1717,7 +1717,7 @@ msgstr "Strumień nie ma metod readinto() lub write()." #: ports/mimxrt10xx/common-hal/busio/UART.c ports/stm/common-hal/busio/UART.c msgid "Supply at least one UART pin" -msgstr "" +msgstr "Podaj co najmniej jeden pin UART" #: shared-bindings/gnss/GNSS.c msgid "System entry must be gnss.SatelliteSystem" From 9e6b2b1da8b97a4663a5feb0954b759ab816c9b7 Mon Sep 17 00:00:00 2001 From: vkuthan Date: Tue, 1 Dec 2020 12:08:42 +0000 Subject: [PATCH 192/207] Translated using Weblate (Czech) Currently translated at 3.2% (28 of 864 strings) Translation: CircuitPython/main Translate-URL: https://hosted.weblate.org/projects/circuitpython/main/cs/ --- locale/cs.po | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/locale/cs.po b/locale/cs.po index 05b5942fc5..c69ae2820b 100644 --- a/locale/cs.po +++ b/locale/cs.po @@ -6,7 +6,7 @@ msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2020-11-24 15:40-0500\n" -"PO-Revision-Date: 2020-11-30 18:06+0000\n" +"PO-Revision-Date: 2020-12-02 20:29+0000\n" "Last-Translator: vkuthan \n" "Language-Team: LANGUAGE \n" "Language: cs\n" @@ -122,35 +122,35 @@ msgstr "" #: py/proto.c msgid "'%q' object does not support '%q'" -msgstr "" +msgstr "Objekt '%q' nepodporuje '%q'" #: py/obj.c msgid "'%q' object does not support item assignment" -msgstr "" +msgstr "Objekt '%q' nepodporuje přiřazení položek" #: py/obj.c msgid "'%q' object does not support item deletion" -msgstr "" +msgstr "Objekt '%q' nepodporuje mazání položek" #: py/runtime.c msgid "'%q' object has no attribute '%q'" -msgstr "" +msgstr "Objekt '%q' nemá žádný atribut" #: py/runtime.c msgid "'%q' object is not an iterator" -msgstr "" +msgstr "Objekt '%q' není iterátor" #: py/objtype.c py/runtime.c msgid "'%q' object is not callable" -msgstr "" +msgstr "Objekt '%q' nelze volat" #: py/runtime.c msgid "'%q' object is not iterable" -msgstr "" +msgstr "Objekt '%q' není iterovatelný" #: py/obj.c msgid "'%q' object is not subscriptable" -msgstr "" +msgstr "Objekt '%q' nelze zapsat" #: py/emitinlinethumb.c py/emitinlinextensa.c #, c-format @@ -170,17 +170,17 @@ msgstr "" #: py/emitinlinethumb.c #, c-format msgid "'%s' expects an FPU register" -msgstr "" +msgstr "'%s' očekává register FPU" #: py/emitinlinethumb.c #, c-format msgid "'%s' expects an address of the form [a, b]" -msgstr "" +msgstr "'%s' očekává adresu ve formátu [a, b]" #: py/emitinlinethumb.c py/emitinlinextensa.c #, c-format msgid "'%s' expects an integer" -msgstr "" +msgstr "'%s' očekává integer (celé číslo)" #: py/emitinlinethumb.c #, c-format @@ -190,7 +190,7 @@ msgstr "" #: py/emitinlinethumb.c #, c-format msgid "'%s' expects {r0, r1, ...}" -msgstr "" +msgstr "'%s' očekává {r0, r1, ...}" #: py/emitinlinextensa.c #, c-format From 7655102ef25bc372000c8e9757694af6f979a78e Mon Sep 17 00:00:00 2001 From: Hosted Weblate Date: Wed, 2 Dec 2020 21:51:54 +0100 Subject: [PATCH 193/207] Update translation files Updated by "Update PO files to match POT (msgmerge)" hook in Weblate. Translation: CircuitPython/main Translate-URL: https://hosted.weblate.org/projects/circuitpython/main/ --- locale/ID.po | 44 ++++++++++++++++++++++++++++++++++++++-- locale/cs.po | 44 ++++++++++++++++++++++++++++++++++++++-- locale/de_DE.po | 44 ++++++++++++++++++++++++++++++++++++++-- locale/el.po | 44 ++++++++++++++++++++++++++++++++++++++-- locale/es.po | 44 ++++++++++++++++++++++++++++++++++++++-- locale/fil.po | 44 ++++++++++++++++++++++++++++++++++++++-- locale/fr.po | 44 ++++++++++++++++++++++++++++++++++++++-- locale/hi.po | 44 ++++++++++++++++++++++++++++++++++++++-- locale/it_IT.po | 44 ++++++++++++++++++++++++++++++++++++++-- locale/ja.po | 44 ++++++++++++++++++++++++++++++++++++++-- locale/ko.po | 44 ++++++++++++++++++++++++++++++++++++++-- locale/nl.po | 44 ++++++++++++++++++++++++++++++++++++++-- locale/pl.po | 44 ++++++++++++++++++++++++++++++++++++++-- locale/pt_BR.po | 44 ++++++++++++++++++++++++++++++++++++++-- locale/sv.po | 44 ++++++++++++++++++++++++++++++++++++++-- locale/zh_Latn_pinyin.po | 44 ++++++++++++++++++++++++++++++++++++++-- 16 files changed, 672 insertions(+), 32 deletions(-) diff --git a/locale/ID.po b/locale/ID.po index 6073b6a462..43dcc72889 100644 --- a/locale/ID.po +++ b/locale/ID.po @@ -5,7 +5,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-11-24 15:40-0500\n" +"POT-Creation-Date: 2020-11-27 23:57-0500\n" "PO-Revision-Date: 2020-10-10 23:51+0000\n" "Last-Translator: oon arfiandwi \n" "Language-Team: LANGUAGE \n" @@ -862,6 +862,10 @@ msgstr "Diharapkan sebuah UUID" msgid "Expected an Address" msgstr "Diharapkan sebuah Alamat" +#: shared-bindings/alarm/__init__.c +msgid "Expected an alarm" +msgstr "" + #: shared-module/_pixelbuf/PixelBuf.c #, c-format msgid "Expected tuple of length %d, got %d" @@ -1008,6 +1012,10 @@ msgstr "Gagal Inisialisasi I2C" msgid "I2SOut not available" msgstr "" +#: ports/esp32s2/common-hal/alarm/pin/__init__.c +msgid "IOs 0, 2 & 4 do not support internal pullup in sleep" +msgstr "" + #: shared-bindings/aesio/aes.c #, c-format msgid "IV must be %d bytes long" @@ -1467,6 +1475,10 @@ msgstr "" "Hanya monokrom, 4bpp atau 8bpp yang diindeks, dan 16bpp atau lebih yang " "didukung: %d bpp diberikan" +#: ports/esp32s2/common-hal/alarm/__init__.c +msgid "Only one alarm.time alarm can be set." +msgstr "" + #: shared-module/displayio/ColorConverter.c msgid "Only one color can be transparent at a time" msgstr "" @@ -1526,6 +1538,10 @@ msgstr "Pin harus mendukung interupsi perangkat keras" msgid "Pin number already reserved by EXTI" msgstr "Nomor pin sudah dipesan oleh EXTI" +#: ports/esp32s2/common-hal/alarm/__init__.c +msgid "PinAlarm not yet implemented" +msgstr "" + #: shared-bindings/rgbmatrix/RGBMatrix.c #, c-format msgid "" @@ -1592,7 +1608,7 @@ msgstr "Pembalikan RS485 ditentukan saat tidak dalam mode RS485" msgid "RTC calibration is not supported on this board" msgstr "Kalibrasi RTC tidak didukung pada board ini" -#: shared-bindings/time/__init__.c +#: shared-bindings/alarm/time/TimeAlarm.c shared-bindings/time/__init__.c msgid "RTC is not supported on this board" msgstr "RTC tidak didukung di board ini" @@ -1739,6 +1755,10 @@ msgstr "Aliran tidak menemukan metode readinto() atau write()." msgid "Supply at least one UART pin" msgstr "Berikan setidaknya satu pin UART" +#: shared-bindings/alarm/time/TimeAlarm.c +msgid "Supply one of monotonic_time or epoch_time" +msgstr "" + #: shared-bindings/gnss/GNSS.c msgid "System entry must be gnss.SatelliteSystem" msgstr "" @@ -1806,6 +1826,10 @@ msgstr "" msgid "Tile width must exactly divide bitmap width" msgstr "" +#: shared-bindings/alarm/time/TimeAlarm.c +msgid "Time is in the past." +msgstr "" + #: ports/nrf/common-hal/_bleio/Adapter.c #, c-format msgid "Timeout is too long: Maximum timeout length is %d seconds" @@ -2528,6 +2552,10 @@ msgstr "" msgid "end_x should be an int" msgstr "" +#: shared-bindings/alarm/time/TimeAlarm.c +msgid "epoch_time not supported on this board" +msgstr "" + #: ports/nrf/common-hal/busio/UART.c #, c-format msgid "error = 0x%08lX" @@ -2897,6 +2925,10 @@ msgstr "" msgid "invalid syntax for number" msgstr "" +#: ports/esp32s2/common-hal/alarm/pin/__init__.c +msgid "io must be rtc io" +msgstr "" + #: py/objtype.c msgid "issubclass() arg 1 must be a class" msgstr "" @@ -3586,6 +3618,10 @@ msgstr "" msgid "trapz is defined for 1D arrays of equal length" msgstr "" +#: ports/esp32s2/common-hal/alarm/pin/__init__.c +msgid "trigger level must be 0 or 1" +msgstr "" + #: extmod/ulab/code/linalg/linalg.c msgid "tuple index out of range" msgstr "" @@ -3728,6 +3764,10 @@ msgstr "" msgid "vectors must have same lengths" msgstr "" +#: ports/esp32s2/common-hal/alarm/pin/__init__.c +msgid "wakeup conflict" +msgstr "" + #: ports/esp32s2/common-hal/watchdog/WatchDogTimer.c msgid "watchdog not initialized" msgstr "" diff --git a/locale/cs.po b/locale/cs.po index c69ae2820b..72b2162678 100644 --- a/locale/cs.po +++ b/locale/cs.po @@ -5,7 +5,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-11-24 15:40-0500\n" +"POT-Creation-Date: 2020-11-27 23:57-0500\n" "PO-Revision-Date: 2020-12-02 20:29+0000\n" "Last-Translator: vkuthan \n" "Language-Team: LANGUAGE \n" @@ -848,6 +848,10 @@ msgstr "" msgid "Expected an Address" msgstr "" +#: shared-bindings/alarm/__init__.c +msgid "Expected an alarm" +msgstr "" + #: shared-module/_pixelbuf/PixelBuf.c #, c-format msgid "Expected tuple of length %d, got %d" @@ -993,6 +997,10 @@ msgstr "" msgid "I2SOut not available" msgstr "" +#: ports/esp32s2/common-hal/alarm/pin/__init__.c +msgid "IOs 0, 2 & 4 do not support internal pullup in sleep" +msgstr "" + #: shared-bindings/aesio/aes.c #, c-format msgid "IV must be %d bytes long" @@ -1444,6 +1452,10 @@ msgid "" "%d bpp given" msgstr "" +#: ports/esp32s2/common-hal/alarm/__init__.c +msgid "Only one alarm.time alarm can be set." +msgstr "" + #: shared-module/displayio/ColorConverter.c msgid "Only one color can be transparent at a time" msgstr "" @@ -1501,6 +1513,10 @@ msgstr "" msgid "Pin number already reserved by EXTI" msgstr "" +#: ports/esp32s2/common-hal/alarm/__init__.c +msgid "PinAlarm not yet implemented" +msgstr "" + #: shared-bindings/rgbmatrix/RGBMatrix.c #, c-format msgid "" @@ -1562,7 +1578,7 @@ msgstr "" msgid "RTC calibration is not supported on this board" msgstr "" -#: shared-bindings/time/__init__.c +#: shared-bindings/alarm/time/TimeAlarm.c shared-bindings/time/__init__.c msgid "RTC is not supported on this board" msgstr "" @@ -1708,6 +1724,10 @@ msgstr "" msgid "Supply at least one UART pin" msgstr "" +#: shared-bindings/alarm/time/TimeAlarm.c +msgid "Supply one of monotonic_time or epoch_time" +msgstr "" + #: shared-bindings/gnss/GNSS.c msgid "System entry must be gnss.SatelliteSystem" msgstr "" @@ -1771,6 +1791,10 @@ msgstr "" msgid "Tile width must exactly divide bitmap width" msgstr "" +#: shared-bindings/alarm/time/TimeAlarm.c +msgid "Time is in the past." +msgstr "" + #: ports/nrf/common-hal/_bleio/Adapter.c #, c-format msgid "Timeout is too long: Maximum timeout length is %d seconds" @@ -2485,6 +2509,10 @@ msgstr "" msgid "end_x should be an int" msgstr "" +#: shared-bindings/alarm/time/TimeAlarm.c +msgid "epoch_time not supported on this board" +msgstr "" + #: ports/nrf/common-hal/busio/UART.c #, c-format msgid "error = 0x%08lX" @@ -2854,6 +2882,10 @@ msgstr "" msgid "invalid syntax for number" msgstr "" +#: ports/esp32s2/common-hal/alarm/pin/__init__.c +msgid "io must be rtc io" +msgstr "" + #: py/objtype.c msgid "issubclass() arg 1 must be a class" msgstr "" @@ -3541,6 +3573,10 @@ msgstr "" msgid "trapz is defined for 1D arrays of equal length" msgstr "" +#: ports/esp32s2/common-hal/alarm/pin/__init__.c +msgid "trigger level must be 0 or 1" +msgstr "" + #: extmod/ulab/code/linalg/linalg.c msgid "tuple index out of range" msgstr "" @@ -3683,6 +3719,10 @@ msgstr "" msgid "vectors must have same lengths" msgstr "" +#: ports/esp32s2/common-hal/alarm/pin/__init__.c +msgid "wakeup conflict" +msgstr "" + #: ports/esp32s2/common-hal/watchdog/WatchDogTimer.c msgid "watchdog not initialized" msgstr "" diff --git a/locale/de_DE.po b/locale/de_DE.po index 7dd79d9151..a3b4cd2cc2 100644 --- a/locale/de_DE.po +++ b/locale/de_DE.po @@ -5,7 +5,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-11-24 15:40-0500\n" +"POT-Creation-Date: 2020-11-27 23:57-0500\n" "PO-Revision-Date: 2020-11-26 03:11+0000\n" "Last-Translator: Daniel Bravo Darriba \n" "Language: de_DE\n" @@ -858,6 +858,10 @@ msgstr "Eine UUID wird erwartet" msgid "Expected an Address" msgstr "Erwartet eine Adresse" +#: shared-bindings/alarm/__init__.c +msgid "Expected an alarm" +msgstr "" + #: shared-module/_pixelbuf/PixelBuf.c #, c-format msgid "Expected tuple of length %d, got %d" @@ -1008,6 +1012,10 @@ msgstr "I2C-Init-Fehler" msgid "I2SOut not available" msgstr "I2SOut nicht verfügbar" +#: ports/esp32s2/common-hal/alarm/pin/__init__.c +msgid "IOs 0, 2 & 4 do not support internal pullup in sleep" +msgstr "" + #: shared-bindings/aesio/aes.c #, c-format msgid "IV must be %d bytes long" @@ -1469,6 +1477,10 @@ msgstr "" "Nur monochrome, indizierte 4bpp oder 8bpp, und 16bpp oder größere BMPs " "unterstützt: %d bpp wurden gegeben" +#: ports/esp32s2/common-hal/alarm/__init__.c +msgid "Only one alarm.time alarm can be set." +msgstr "" + #: shared-module/displayio/ColorConverter.c msgid "Only one color can be transparent at a time" msgstr "" @@ -1526,6 +1538,10 @@ msgstr "Pin muss Hardware-Interrupts unterstützen" msgid "Pin number already reserved by EXTI" msgstr "PIN-Nummer bereits von EXTI reserviert" +#: ports/esp32s2/common-hal/alarm/__init__.c +msgid "PinAlarm not yet implemented" +msgstr "" + #: shared-bindings/rgbmatrix/RGBMatrix.c #, c-format msgid "" @@ -1592,7 +1608,7 @@ msgstr "RS485-Inversion angegeben, wenn nicht im RS485-Modus" msgid "RTC calibration is not supported on this board" msgstr "Die RTC-Kalibrierung wird auf diesem Board nicht unterstützt" -#: shared-bindings/time/__init__.c +#: shared-bindings/alarm/time/TimeAlarm.c shared-bindings/time/__init__.c msgid "RTC is not supported on this board" msgstr "Eine RTC wird auf diesem Board nicht unterstützt" @@ -1738,6 +1754,10 @@ msgstr "Stream fehlt readinto() oder write() Methode." msgid "Supply at least one UART pin" msgstr "Geben Sie mindestens einen UART-Pin an" +#: shared-bindings/alarm/time/TimeAlarm.c +msgid "Supply one of monotonic_time or epoch_time" +msgstr "" + #: shared-bindings/gnss/GNSS.c msgid "System entry must be gnss.SatelliteSystem" msgstr "" @@ -1812,6 +1832,10 @@ msgstr "Kachelwert außerhalb der Grenzen" msgid "Tile width must exactly divide bitmap width" msgstr "Die Kachelbreite muss die Bitmap-Breite genau teilen" +#: shared-bindings/alarm/time/TimeAlarm.c +msgid "Time is in the past." +msgstr "" + #: ports/nrf/common-hal/_bleio/Adapter.c #, c-format msgid "Timeout is too long: Maximum timeout length is %d seconds" @@ -2556,6 +2580,10 @@ msgstr "Ende des Formats wärend der Suche nach einem conversion specifier" msgid "end_x should be an int" msgstr "end_x sollte ein int sein" +#: shared-bindings/alarm/time/TimeAlarm.c +msgid "epoch_time not supported on this board" +msgstr "" + #: ports/nrf/common-hal/busio/UART.c #, c-format msgid "error = 0x%08lX" @@ -2926,6 +2954,10 @@ msgstr "ungültige Syntax für integer mit Basis %d" msgid "invalid syntax for number" msgstr "ungültige Syntax für number" +#: ports/esp32s2/common-hal/alarm/pin/__init__.c +msgid "io must be rtc io" +msgstr "" + #: py/objtype.c msgid "issubclass() arg 1 must be a class" msgstr "issubclass() arg 1 muss eine Klasse sein" @@ -3626,6 +3658,10 @@ msgstr "zu viele Werte zum Auspacken (erwartet %d)" msgid "trapz is defined for 1D arrays of equal length" msgstr "" +#: ports/esp32s2/common-hal/alarm/pin/__init__.c +msgid "trigger level must be 0 or 1" +msgstr "" + #: extmod/ulab/code/linalg/linalg.c msgid "tuple index out of range" msgstr "Tupelindex außerhalb des Bereichs" @@ -3772,6 +3808,10 @@ msgstr "value_count muss größer als 0 sein" msgid "vectors must have same lengths" msgstr "Vektoren müssen die selbe Länge haben" +#: ports/esp32s2/common-hal/alarm/pin/__init__.c +msgid "wakeup conflict" +msgstr "" + #: ports/esp32s2/common-hal/watchdog/WatchDogTimer.c msgid "watchdog not initialized" msgstr "" diff --git a/locale/el.po b/locale/el.po index 8d6dad828e..01e4260403 100644 --- a/locale/el.po +++ b/locale/el.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-11-24 15:40-0500\n" +"POT-Creation-Date: 2020-11-27 23:57-0500\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: Automatically generated\n" "Language-Team: none\n" @@ -843,6 +843,10 @@ msgstr "" msgid "Expected an Address" msgstr "" +#: shared-bindings/alarm/__init__.c +msgid "Expected an alarm" +msgstr "" + #: shared-module/_pixelbuf/PixelBuf.c #, c-format msgid "Expected tuple of length %d, got %d" @@ -988,6 +992,10 @@ msgstr "" msgid "I2SOut not available" msgstr "" +#: ports/esp32s2/common-hal/alarm/pin/__init__.c +msgid "IOs 0, 2 & 4 do not support internal pullup in sleep" +msgstr "" + #: shared-bindings/aesio/aes.c #, c-format msgid "IV must be %d bytes long" @@ -1439,6 +1447,10 @@ msgid "" "%d bpp given" msgstr "" +#: ports/esp32s2/common-hal/alarm/__init__.c +msgid "Only one alarm.time alarm can be set." +msgstr "" + #: shared-module/displayio/ColorConverter.c msgid "Only one color can be transparent at a time" msgstr "" @@ -1496,6 +1508,10 @@ msgstr "" msgid "Pin number already reserved by EXTI" msgstr "" +#: ports/esp32s2/common-hal/alarm/__init__.c +msgid "PinAlarm not yet implemented" +msgstr "" + #: shared-bindings/rgbmatrix/RGBMatrix.c #, c-format msgid "" @@ -1557,7 +1573,7 @@ msgstr "" msgid "RTC calibration is not supported on this board" msgstr "" -#: shared-bindings/time/__init__.c +#: shared-bindings/alarm/time/TimeAlarm.c shared-bindings/time/__init__.c msgid "RTC is not supported on this board" msgstr "" @@ -1703,6 +1719,10 @@ msgstr "" msgid "Supply at least one UART pin" msgstr "" +#: shared-bindings/alarm/time/TimeAlarm.c +msgid "Supply one of monotonic_time or epoch_time" +msgstr "" + #: shared-bindings/gnss/GNSS.c msgid "System entry must be gnss.SatelliteSystem" msgstr "" @@ -1766,6 +1786,10 @@ msgstr "" msgid "Tile width must exactly divide bitmap width" msgstr "" +#: shared-bindings/alarm/time/TimeAlarm.c +msgid "Time is in the past." +msgstr "" + #: ports/nrf/common-hal/_bleio/Adapter.c #, c-format msgid "Timeout is too long: Maximum timeout length is %d seconds" @@ -2480,6 +2504,10 @@ msgstr "" msgid "end_x should be an int" msgstr "" +#: shared-bindings/alarm/time/TimeAlarm.c +msgid "epoch_time not supported on this board" +msgstr "" + #: ports/nrf/common-hal/busio/UART.c #, c-format msgid "error = 0x%08lX" @@ -2849,6 +2877,10 @@ msgstr "" msgid "invalid syntax for number" msgstr "" +#: ports/esp32s2/common-hal/alarm/pin/__init__.c +msgid "io must be rtc io" +msgstr "" + #: py/objtype.c msgid "issubclass() arg 1 must be a class" msgstr "" @@ -3536,6 +3568,10 @@ msgstr "" msgid "trapz is defined for 1D arrays of equal length" msgstr "" +#: ports/esp32s2/common-hal/alarm/pin/__init__.c +msgid "trigger level must be 0 or 1" +msgstr "" + #: extmod/ulab/code/linalg/linalg.c msgid "tuple index out of range" msgstr "" @@ -3678,6 +3714,10 @@ msgstr "" msgid "vectors must have same lengths" msgstr "" +#: ports/esp32s2/common-hal/alarm/pin/__init__.c +msgid "wakeup conflict" +msgstr "" + #: ports/esp32s2/common-hal/watchdog/WatchDogTimer.c msgid "watchdog not initialized" msgstr "" diff --git a/locale/es.po b/locale/es.po index 6b0fde563c..293a0c19e7 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-11-24 15:40-0500\n" +"POT-Creation-Date: 2020-11-27 23:57-0500\n" "PO-Revision-Date: 2020-11-27 18:34+0000\n" "Last-Translator: Iván Montiel Cardona \n" "Language-Team: \n" @@ -863,6 +863,10 @@ msgstr "Se esperaba un UUID" msgid "Expected an Address" msgstr "Se esperaba una dirección" +#: shared-bindings/alarm/__init__.c +msgid "Expected an alarm" +msgstr "" + #: shared-module/_pixelbuf/PixelBuf.c #, c-format msgid "Expected tuple of length %d, got %d" @@ -1009,6 +1013,10 @@ msgstr "I2C Error de inicio" msgid "I2SOut not available" msgstr "I2SOut no disponible" +#: ports/esp32s2/common-hal/alarm/pin/__init__.c +msgid "IOs 0, 2 & 4 do not support internal pullup in sleep" +msgstr "" + #: shared-bindings/aesio/aes.c #, c-format msgid "IV must be %d bytes long" @@ -1468,6 +1476,10 @@ msgstr "" "Solo se admiten BMP monocromáticos, indexados de 4 bpp u 8 bpp y 16 bpp o " "más: %d bpp proporcionados" +#: ports/esp32s2/common-hal/alarm/__init__.c +msgid "Only one alarm.time alarm can be set." +msgstr "" + #: shared-module/displayio/ColorConverter.c msgid "Only one color can be transparent at a time" msgstr "Solo un color puede ser transparente a la vez" @@ -1527,6 +1539,10 @@ msgstr "El pin debe admitir interrupciones de hardware" msgid "Pin number already reserved by EXTI" msgstr "Número de pin ya reservado por EXTI" +#: ports/esp32s2/common-hal/alarm/__init__.c +msgid "PinAlarm not yet implemented" +msgstr "" + #: shared-bindings/rgbmatrix/RGBMatrix.c #, c-format msgid "" @@ -1596,7 +1612,7 @@ msgstr "Se especifica inversión de RS485 si no está en modo RS485" msgid "RTC calibration is not supported on this board" msgstr "Calibración de RTC no es soportada en esta placa" -#: shared-bindings/time/__init__.c +#: shared-bindings/alarm/time/TimeAlarm.c shared-bindings/time/__init__.c msgid "RTC is not supported on this board" msgstr "RTC no soportado en esta placa" @@ -1742,6 +1758,10 @@ msgstr "A Stream le falta el método readinto() o write()." msgid "Supply at least one UART pin" msgstr "Suministre al menos un pin UART" +#: shared-bindings/alarm/time/TimeAlarm.c +msgid "Supply one of monotonic_time or epoch_time" +msgstr "" + #: shared-bindings/gnss/GNSS.c msgid "System entry must be gnss.SatelliteSystem" msgstr "La entrada del sistema debe ser gnss.SatelliteSystem" @@ -1814,6 +1834,10 @@ msgstr "Valor de mosaico fuera de límites" msgid "Tile width must exactly divide bitmap width" msgstr "Ancho del Tile debe dividir exactamente el ancho de mapa de bits" +#: shared-bindings/alarm/time/TimeAlarm.c +msgid "Time is in the past." +msgstr "" + #: ports/nrf/common-hal/_bleio/Adapter.c #, c-format msgid "Timeout is too long: Maximum timeout length is %d seconds" @@ -2551,6 +2575,10 @@ msgstr "el final del formato mientras se busca el especificador de conversión" msgid "end_x should be an int" msgstr "end_x debe ser un int" +#: shared-bindings/alarm/time/TimeAlarm.c +msgid "epoch_time not supported on this board" +msgstr "" + #: ports/nrf/common-hal/busio/UART.c #, c-format msgid "error = 0x%08lX" @@ -2920,6 +2948,10 @@ msgstr "sintaxis inválida para entero con base %d" msgid "invalid syntax for number" msgstr "sintaxis inválida para número" +#: ports/esp32s2/common-hal/alarm/pin/__init__.c +msgid "io must be rtc io" +msgstr "" + #: py/objtype.c msgid "issubclass() arg 1 must be a class" msgstr "issubclass() arg 1 debe ser una clase" @@ -3616,6 +3648,10 @@ msgstr "demasiados valores para descomprimir (%d esperado)" msgid "trapz is defined for 1D arrays of equal length" msgstr "trapz está definido para arreglos 1D de igual tamaño" +#: ports/esp32s2/common-hal/alarm/pin/__init__.c +msgid "trigger level must be 0 or 1" +msgstr "" + #: extmod/ulab/code/linalg/linalg.c msgid "tuple index out of range" msgstr "tuple index fuera de rango" @@ -3758,6 +3794,10 @@ msgstr "value_count debe ser > 0" msgid "vectors must have same lengths" msgstr "los vectores deben tener el mismo tamaño" +#: ports/esp32s2/common-hal/alarm/pin/__init__.c +msgid "wakeup conflict" +msgstr "" + #: ports/esp32s2/common-hal/watchdog/WatchDogTimer.c msgid "watchdog not initialized" msgstr "watchdog no inicializado" diff --git a/locale/fil.po b/locale/fil.po index 9178623a29..c492f36c08 100644 --- a/locale/fil.po +++ b/locale/fil.po @@ -5,7 +5,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-11-24 15:40-0500\n" +"POT-Creation-Date: 2020-11-27 23:57-0500\n" "PO-Revision-Date: 2018-12-20 22:15-0800\n" "Last-Translator: Timothy \n" "Language-Team: fil\n" @@ -856,6 +856,10 @@ msgstr "Umasa ng %q" msgid "Expected an Address" msgstr "" +#: shared-bindings/alarm/__init__.c +msgid "Expected an alarm" +msgstr "" + #: shared-module/_pixelbuf/PixelBuf.c #, c-format msgid "Expected tuple of length %d, got %d" @@ -1001,6 +1005,10 @@ msgstr "" msgid "I2SOut not available" msgstr "" +#: ports/esp32s2/common-hal/alarm/pin/__init__.c +msgid "IOs 0, 2 & 4 do not support internal pullup in sleep" +msgstr "" + #: shared-bindings/aesio/aes.c #, c-format msgid "IV must be %d bytes long" @@ -1457,6 +1465,10 @@ msgid "" "%d bpp given" msgstr "" +#: ports/esp32s2/common-hal/alarm/__init__.c +msgid "Only one alarm.time alarm can be set." +msgstr "" + #: shared-module/displayio/ColorConverter.c msgid "Only one color can be transparent at a time" msgstr "" @@ -1515,6 +1527,10 @@ msgstr "" msgid "Pin number already reserved by EXTI" msgstr "" +#: ports/esp32s2/common-hal/alarm/__init__.c +msgid "PinAlarm not yet implemented" +msgstr "" + #: shared-bindings/rgbmatrix/RGBMatrix.c #, c-format msgid "" @@ -1578,7 +1594,7 @@ msgstr "" msgid "RTC calibration is not supported on this board" msgstr "RTC calibration ay hindi supportado ng board na ito" -#: shared-bindings/time/__init__.c +#: shared-bindings/alarm/time/TimeAlarm.c shared-bindings/time/__init__.c msgid "RTC is not supported on this board" msgstr "Hindi supportado ang RTC sa board na ito" @@ -1725,6 +1741,10 @@ msgstr "Stream kulang ng readinto() o write() method." msgid "Supply at least one UART pin" msgstr "" +#: shared-bindings/alarm/time/TimeAlarm.c +msgid "Supply one of monotonic_time or epoch_time" +msgstr "" + #: shared-bindings/gnss/GNSS.c msgid "System entry must be gnss.SatelliteSystem" msgstr "" @@ -1788,6 +1808,10 @@ msgstr "" msgid "Tile width must exactly divide bitmap width" msgstr "" +#: shared-bindings/alarm/time/TimeAlarm.c +msgid "Time is in the past." +msgstr "" + #: ports/nrf/common-hal/_bleio/Adapter.c #, c-format msgid "Timeout is too long: Maximum timeout length is %d seconds" @@ -2524,6 +2548,10 @@ msgstr "sa huli ng format habang naghahanap sa conversion specifier" msgid "end_x should be an int" msgstr "y ay dapat int" +#: shared-bindings/alarm/time/TimeAlarm.c +msgid "epoch_time not supported on this board" +msgstr "" + #: ports/nrf/common-hal/busio/UART.c #, c-format msgid "error = 0x%08lX" @@ -2894,6 +2922,10 @@ msgstr "maling sintaks sa integer na may base %d" msgid "invalid syntax for number" msgstr "maling sintaks sa number" +#: ports/esp32s2/common-hal/alarm/pin/__init__.c +msgid "io must be rtc io" +msgstr "" + #: py/objtype.c msgid "issubclass() arg 1 must be a class" msgstr "issubclass() arg 1 ay dapat na class" @@ -3591,6 +3623,10 @@ msgstr "masyadong maraming values para i-unpact (umaasa ng %d)" msgid "trapz is defined for 1D arrays of equal length" msgstr "" +#: ports/esp32s2/common-hal/alarm/pin/__init__.c +msgid "trigger level must be 0 or 1" +msgstr "" + #: extmod/ulab/code/linalg/linalg.c msgid "tuple index out of range" msgstr "indeks ng tuple wala sa sakop" @@ -3733,6 +3769,10 @@ msgstr "" msgid "vectors must have same lengths" msgstr "" +#: ports/esp32s2/common-hal/alarm/pin/__init__.c +msgid "wakeup conflict" +msgstr "" + #: ports/esp32s2/common-hal/watchdog/WatchDogTimer.c msgid "watchdog not initialized" msgstr "" diff --git a/locale/fr.po b/locale/fr.po index bb9b6ea98d..5dc91096c5 100644 --- a/locale/fr.po +++ b/locale/fr.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: 0.1\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-11-24 15:40-0500\n" +"POT-Creation-Date: 2020-11-27 23:57-0500\n" "PO-Revision-Date: 2020-11-24 22:45+0000\n" "Last-Translator: Antonin ENFRUN \n" "Language: fr\n" @@ -867,6 +867,10 @@ msgstr "Un UUID est attendu" msgid "Expected an Address" msgstr "Attendu une adresse" +#: shared-bindings/alarm/__init__.c +msgid "Expected an alarm" +msgstr "" + #: shared-module/_pixelbuf/PixelBuf.c #, c-format msgid "Expected tuple of length %d, got %d" @@ -1014,6 +1018,10 @@ msgstr "Erreur d'initialisation I2C" msgid "I2SOut not available" msgstr "I2SOut n'est pas disponible" +#: ports/esp32s2/common-hal/alarm/pin/__init__.c +msgid "IOs 0, 2 & 4 do not support internal pullup in sleep" +msgstr "" + #: shared-bindings/aesio/aes.c #, c-format msgid "IV must be %d bytes long" @@ -1473,6 +1481,10 @@ msgstr "" "Prise en charge uniquement des monochromes, 4 bpp ou 8 bpp indexés et 16 bpp " "ou plus : %d bpp fournis" +#: ports/esp32s2/common-hal/alarm/__init__.c +msgid "Only one alarm.time alarm can be set." +msgstr "" + #: shared-module/displayio/ColorConverter.c msgid "Only one color can be transparent at a time" msgstr "Une seule couleur peut être transparente à la fois" @@ -1534,6 +1546,10 @@ msgstr "La broche doit prendre en charge les interruptions matérielles" msgid "Pin number already reserved by EXTI" msgstr "Numéro de broche déjà réservé par EXTI" +#: ports/esp32s2/common-hal/alarm/__init__.c +msgid "PinAlarm not yet implemented" +msgstr "" + #: shared-bindings/rgbmatrix/RGBMatrix.c #, c-format msgid "" @@ -1602,7 +1618,7 @@ msgstr "Inversion RS485 spécifiée lorsqu'elle n'est pas en mode RS485" msgid "RTC calibration is not supported on this board" msgstr "étalonnage de la RTC non supportée sur cette carte" -#: shared-bindings/time/__init__.c +#: shared-bindings/alarm/time/TimeAlarm.c shared-bindings/time/__init__.c msgid "RTC is not supported on this board" msgstr "RTC non supportée sur cette carte" @@ -1748,6 +1764,10 @@ msgstr "Il manque une méthode readinto() ou write() au flux." msgid "Supply at least one UART pin" msgstr "Fournissez au moins une broche UART" +#: shared-bindings/alarm/time/TimeAlarm.c +msgid "Supply one of monotonic_time or epoch_time" +msgstr "" + #: shared-bindings/gnss/GNSS.c msgid "System entry must be gnss.SatelliteSystem" msgstr "L'entrée du système doit être gnss.SatelliteSystem" @@ -1820,6 +1840,10 @@ msgstr "Valeur de tuile hors limites" msgid "Tile width must exactly divide bitmap width" msgstr "La largeur de la tuile doit diviser exactement la largeur de l'image" +#: shared-bindings/alarm/time/TimeAlarm.c +msgid "Time is in the past." +msgstr "" + #: ports/nrf/common-hal/_bleio/Adapter.c #, c-format msgid "Timeout is too long: Maximum timeout length is %d seconds" @@ -2566,6 +2590,10 @@ msgstr "fin de format en cherchant une spécification de conversion" msgid "end_x should be an int" msgstr "end_x doit être un entier 'int'" +#: shared-bindings/alarm/time/TimeAlarm.c +msgid "epoch_time not supported on this board" +msgstr "" + #: ports/nrf/common-hal/busio/UART.c #, c-format msgid "error = 0x%08lX" @@ -2938,6 +2966,10 @@ msgstr "syntaxe invalide pour un entier de base %d" msgid "invalid syntax for number" msgstr "syntaxe invalide pour un nombre" +#: ports/esp32s2/common-hal/alarm/pin/__init__.c +msgid "io must be rtc io" +msgstr "" + #: py/objtype.c msgid "issubclass() arg 1 must be a class" msgstr "l'argument 1 de issubclass() doit être une classe" @@ -3637,6 +3669,10 @@ msgstr "trop de valeur à dégrouper (%d attendues)" msgid "trapz is defined for 1D arrays of equal length" msgstr "trapz n'est défini que pour des tableaux 1D de longueur égale" +#: ports/esp32s2/common-hal/alarm/pin/__init__.c +msgid "trigger level must be 0 or 1" +msgstr "" + #: extmod/ulab/code/linalg/linalg.c msgid "tuple index out of range" msgstr "index du tuple hors gamme" @@ -3779,6 +3815,10 @@ msgstr "'value_count' doit être > 0" msgid "vectors must have same lengths" msgstr "les vecteurs doivent avoir la même longueur" +#: ports/esp32s2/common-hal/alarm/pin/__init__.c +msgid "wakeup conflict" +msgstr "" + #: ports/esp32s2/common-hal/watchdog/WatchDogTimer.c msgid "watchdog not initialized" msgstr "chien de garde non initialisé" diff --git a/locale/hi.po b/locale/hi.po index 025664069d..b70a052019 100644 --- a/locale/hi.po +++ b/locale/hi.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-11-24 15:40-0500\n" +"POT-Creation-Date: 2020-11-27 23:57-0500\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: Automatically generated\n" "Language-Team: none\n" @@ -843,6 +843,10 @@ msgstr "" msgid "Expected an Address" msgstr "" +#: shared-bindings/alarm/__init__.c +msgid "Expected an alarm" +msgstr "" + #: shared-module/_pixelbuf/PixelBuf.c #, c-format msgid "Expected tuple of length %d, got %d" @@ -988,6 +992,10 @@ msgstr "" msgid "I2SOut not available" msgstr "" +#: ports/esp32s2/common-hal/alarm/pin/__init__.c +msgid "IOs 0, 2 & 4 do not support internal pullup in sleep" +msgstr "" + #: shared-bindings/aesio/aes.c #, c-format msgid "IV must be %d bytes long" @@ -1439,6 +1447,10 @@ msgid "" "%d bpp given" msgstr "" +#: ports/esp32s2/common-hal/alarm/__init__.c +msgid "Only one alarm.time alarm can be set." +msgstr "" + #: shared-module/displayio/ColorConverter.c msgid "Only one color can be transparent at a time" msgstr "" @@ -1496,6 +1508,10 @@ msgstr "" msgid "Pin number already reserved by EXTI" msgstr "" +#: ports/esp32s2/common-hal/alarm/__init__.c +msgid "PinAlarm not yet implemented" +msgstr "" + #: shared-bindings/rgbmatrix/RGBMatrix.c #, c-format msgid "" @@ -1557,7 +1573,7 @@ msgstr "" msgid "RTC calibration is not supported on this board" msgstr "" -#: shared-bindings/time/__init__.c +#: shared-bindings/alarm/time/TimeAlarm.c shared-bindings/time/__init__.c msgid "RTC is not supported on this board" msgstr "" @@ -1703,6 +1719,10 @@ msgstr "" msgid "Supply at least one UART pin" msgstr "" +#: shared-bindings/alarm/time/TimeAlarm.c +msgid "Supply one of monotonic_time or epoch_time" +msgstr "" + #: shared-bindings/gnss/GNSS.c msgid "System entry must be gnss.SatelliteSystem" msgstr "" @@ -1766,6 +1786,10 @@ msgstr "" msgid "Tile width must exactly divide bitmap width" msgstr "" +#: shared-bindings/alarm/time/TimeAlarm.c +msgid "Time is in the past." +msgstr "" + #: ports/nrf/common-hal/_bleio/Adapter.c #, c-format msgid "Timeout is too long: Maximum timeout length is %d seconds" @@ -2480,6 +2504,10 @@ msgstr "" msgid "end_x should be an int" msgstr "" +#: shared-bindings/alarm/time/TimeAlarm.c +msgid "epoch_time not supported on this board" +msgstr "" + #: ports/nrf/common-hal/busio/UART.c #, c-format msgid "error = 0x%08lX" @@ -2849,6 +2877,10 @@ msgstr "" msgid "invalid syntax for number" msgstr "" +#: ports/esp32s2/common-hal/alarm/pin/__init__.c +msgid "io must be rtc io" +msgstr "" + #: py/objtype.c msgid "issubclass() arg 1 must be a class" msgstr "" @@ -3536,6 +3568,10 @@ msgstr "" msgid "trapz is defined for 1D arrays of equal length" msgstr "" +#: ports/esp32s2/common-hal/alarm/pin/__init__.c +msgid "trigger level must be 0 or 1" +msgstr "" + #: extmod/ulab/code/linalg/linalg.c msgid "tuple index out of range" msgstr "" @@ -3678,6 +3714,10 @@ msgstr "" msgid "vectors must have same lengths" msgstr "" +#: ports/esp32s2/common-hal/alarm/pin/__init__.c +msgid "wakeup conflict" +msgstr "" + #: ports/esp32s2/common-hal/watchdog/WatchDogTimer.c msgid "watchdog not initialized" msgstr "" diff --git a/locale/it_IT.po b/locale/it_IT.po index bb77d71cc3..836d805852 100644 --- a/locale/it_IT.po +++ b/locale/it_IT.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-11-24 15:40-0500\n" +"POT-Creation-Date: 2020-11-27 23:57-0500\n" "PO-Revision-Date: 2018-10-02 16:27+0200\n" "Last-Translator: Enrico Paganin \n" "Language-Team: \n" @@ -856,6 +856,10 @@ msgstr "Atteso un %q" msgid "Expected an Address" msgstr "" +#: shared-bindings/alarm/__init__.c +msgid "Expected an alarm" +msgstr "" + #: shared-module/_pixelbuf/PixelBuf.c #, c-format msgid "Expected tuple of length %d, got %d" @@ -1001,6 +1005,10 @@ msgstr "" msgid "I2SOut not available" msgstr "" +#: ports/esp32s2/common-hal/alarm/pin/__init__.c +msgid "IOs 0, 2 & 4 do not support internal pullup in sleep" +msgstr "" + #: shared-bindings/aesio/aes.c #, c-format msgid "IV must be %d bytes long" @@ -1462,6 +1470,10 @@ msgid "" "%d bpp given" msgstr "" +#: ports/esp32s2/common-hal/alarm/__init__.c +msgid "Only one alarm.time alarm can be set." +msgstr "" + #: shared-module/displayio/ColorConverter.c msgid "Only one color can be transparent at a time" msgstr "" @@ -1524,6 +1536,10 @@ msgstr "" msgid "Pin number already reserved by EXTI" msgstr "" +#: ports/esp32s2/common-hal/alarm/__init__.c +msgid "PinAlarm not yet implemented" +msgstr "" + #: shared-bindings/rgbmatrix/RGBMatrix.c #, c-format msgid "" @@ -1587,7 +1603,7 @@ msgstr "" msgid "RTC calibration is not supported on this board" msgstr "calibrazione RTC non supportata su questa scheda" -#: shared-bindings/time/__init__.c +#: shared-bindings/alarm/time/TimeAlarm.c shared-bindings/time/__init__.c msgid "RTC is not supported on this board" msgstr "RTC non supportato su questa scheda" @@ -1736,6 +1752,10 @@ msgstr "Metodi mancanti readinto() o write() allo stream." msgid "Supply at least one UART pin" msgstr "" +#: shared-bindings/alarm/time/TimeAlarm.c +msgid "Supply one of monotonic_time or epoch_time" +msgstr "" + #: shared-bindings/gnss/GNSS.c msgid "System entry must be gnss.SatelliteSystem" msgstr "" @@ -1799,6 +1819,10 @@ msgstr "" msgid "Tile width must exactly divide bitmap width" msgstr "" +#: shared-bindings/alarm/time/TimeAlarm.c +msgid "Time is in the past." +msgstr "" + #: ports/nrf/common-hal/_bleio/Adapter.c #, c-format msgid "Timeout is too long: Maximum timeout length is %d seconds" @@ -2525,6 +2549,10 @@ msgstr "" msgid "end_x should be an int" msgstr "y dovrebbe essere un int" +#: shared-bindings/alarm/time/TimeAlarm.c +msgid "epoch_time not supported on this board" +msgstr "" + #: ports/nrf/common-hal/busio/UART.c #, c-format msgid "error = 0x%08lX" @@ -2895,6 +2923,10 @@ msgstr "sintassi invalida per l'intero con base %d" msgid "invalid syntax for number" msgstr "sintassi invalida per il numero" +#: ports/esp32s2/common-hal/alarm/pin/__init__.c +msgid "io must be rtc io" +msgstr "" + #: py/objtype.c msgid "issubclass() arg 1 must be a class" msgstr "il primo argomento di issubclass() deve essere una classe" @@ -3598,6 +3630,10 @@ msgstr "troppi valori da scompattare (%d attesi)" msgid "trapz is defined for 1D arrays of equal length" msgstr "" +#: ports/esp32s2/common-hal/alarm/pin/__init__.c +msgid "trigger level must be 0 or 1" +msgstr "" + #: extmod/ulab/code/linalg/linalg.c msgid "tuple index out of range" msgstr "indice della tupla fuori intervallo" @@ -3740,6 +3776,10 @@ msgstr "" msgid "vectors must have same lengths" msgstr "" +#: ports/esp32s2/common-hal/alarm/pin/__init__.c +msgid "wakeup conflict" +msgstr "" + #: ports/esp32s2/common-hal/watchdog/WatchDogTimer.c msgid "watchdog not initialized" msgstr "" diff --git a/locale/ja.po b/locale/ja.po index bacf0df812..2496db520c 100644 --- a/locale/ja.po +++ b/locale/ja.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-11-24 15:40-0500\n" +"POT-Creation-Date: 2020-11-27 23:57-0500\n" "PO-Revision-Date: 2020-11-27 18:34+0000\n" "Last-Translator: sporeball \n" "Language-Team: none\n" @@ -856,6 +856,10 @@ msgstr "UUIDが必要" msgid "Expected an Address" msgstr "Addressが必要" +#: shared-bindings/alarm/__init__.c +msgid "Expected an alarm" +msgstr "" + #: shared-module/_pixelbuf/PixelBuf.c #, c-format msgid "Expected tuple of length %d, got %d" @@ -1001,6 +1005,10 @@ msgstr "I2C初期化エラー" msgid "I2SOut not available" msgstr "I2SOutが利用できません" +#: ports/esp32s2/common-hal/alarm/pin/__init__.c +msgid "IOs 0, 2 & 4 do not support internal pullup in sleep" +msgstr "" + #: shared-bindings/aesio/aes.c #, c-format msgid "IV must be %d bytes long" @@ -1456,6 +1464,10 @@ msgid "" "%d bpp given" msgstr "" +#: ports/esp32s2/common-hal/alarm/__init__.c +msgid "Only one alarm.time alarm can be set." +msgstr "" + #: shared-module/displayio/ColorConverter.c msgid "Only one color can be transparent at a time" msgstr "" @@ -1514,6 +1526,10 @@ msgstr "ピンはハードウェア割り込みに対応していなければな msgid "Pin number already reserved by EXTI" msgstr "ピン番号はすでにEXTIによって予約されています" +#: ports/esp32s2/common-hal/alarm/__init__.c +msgid "PinAlarm not yet implemented" +msgstr "" + #: shared-bindings/rgbmatrix/RGBMatrix.c #, c-format msgid "" @@ -1575,7 +1591,7 @@ msgstr "" msgid "RTC calibration is not supported on this board" msgstr "このボードはRTCのキャリブレーションに非対応" -#: shared-bindings/time/__init__.c +#: shared-bindings/alarm/time/TimeAlarm.c shared-bindings/time/__init__.c msgid "RTC is not supported on this board" msgstr "このボードはRTCに対応していません" @@ -1721,6 +1737,10 @@ msgstr "ストリームにreadinto()またはwrite()メソッドがありませ msgid "Supply at least one UART pin" msgstr "少なくとも1つのUARTピンが必要" +#: shared-bindings/alarm/time/TimeAlarm.c +msgid "Supply one of monotonic_time or epoch_time" +msgstr "" + #: shared-bindings/gnss/GNSS.c msgid "System entry must be gnss.SatelliteSystem" msgstr "system引数はgnss.SatelliteSystemでなければなりません" @@ -1790,6 +1810,10 @@ msgstr "タイル値が範囲外" msgid "Tile width must exactly divide bitmap width" msgstr "タイルの幅はビットマップの幅を割り切れる値でなければなりません" +#: shared-bindings/alarm/time/TimeAlarm.c +msgid "Time is in the past." +msgstr "" + #: ports/nrf/common-hal/_bleio/Adapter.c #, c-format msgid "Timeout is too long: Maximum timeout length is %d seconds" @@ -2509,6 +2533,10 @@ msgstr "" msgid "end_x should be an int" msgstr "end_xは整数でなければなりません" +#: shared-bindings/alarm/time/TimeAlarm.c +msgid "epoch_time not supported on this board" +msgstr "" + #: ports/nrf/common-hal/busio/UART.c #, c-format msgid "error = 0x%08lX" @@ -2879,6 +2907,10 @@ msgstr "" msgid "invalid syntax for number" msgstr "数字として不正な構文" +#: ports/esp32s2/common-hal/alarm/pin/__init__.c +msgid "io must be rtc io" +msgstr "" + #: py/objtype.c msgid "issubclass() arg 1 must be a class" msgstr "issubclass()の第1引数はクラスでなければなりません" @@ -3569,6 +3601,10 @@ msgstr "アンパックする値が多すぎます (%d個を期待)" msgid "trapz is defined for 1D arrays of equal length" msgstr "trapzは同じ長さの1次元arrayに対して定義されています" +#: ports/esp32s2/common-hal/alarm/pin/__init__.c +msgid "trigger level must be 0 or 1" +msgstr "" + #: extmod/ulab/code/linalg/linalg.c msgid "tuple index out of range" msgstr "" @@ -3711,6 +3747,10 @@ msgstr "value_countは0より大きくなければなりません" msgid "vectors must have same lengths" msgstr "" +#: ports/esp32s2/common-hal/alarm/pin/__init__.c +msgid "wakeup conflict" +msgstr "" + #: ports/esp32s2/common-hal/watchdog/WatchDogTimer.c msgid "watchdog not initialized" msgstr "" diff --git a/locale/ko.po b/locale/ko.po index 9e6cbb0c2a..dcbbfb81d3 100644 --- a/locale/ko.po +++ b/locale/ko.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-11-24 15:40-0500\n" +"POT-Creation-Date: 2020-11-27 23:57-0500\n" "PO-Revision-Date: 2020-10-05 12:12+0000\n" "Last-Translator: Michal Čihař \n" "Language-Team: LANGUAGE \n" @@ -848,6 +848,10 @@ msgstr "UUID이 예상되었습니다." msgid "Expected an Address" msgstr "" +#: shared-bindings/alarm/__init__.c +msgid "Expected an alarm" +msgstr "" + #: shared-module/_pixelbuf/PixelBuf.c #, c-format msgid "Expected tuple of length %d, got %d" @@ -993,6 +997,10 @@ msgstr "" msgid "I2SOut not available" msgstr "" +#: ports/esp32s2/common-hal/alarm/pin/__init__.c +msgid "IOs 0, 2 & 4 do not support internal pullup in sleep" +msgstr "" + #: shared-bindings/aesio/aes.c #, c-format msgid "IV must be %d bytes long" @@ -1444,6 +1452,10 @@ msgid "" "%d bpp given" msgstr "" +#: ports/esp32s2/common-hal/alarm/__init__.c +msgid "Only one alarm.time alarm can be set." +msgstr "" + #: shared-module/displayio/ColorConverter.c msgid "Only one color can be transparent at a time" msgstr "" @@ -1501,6 +1513,10 @@ msgstr "" msgid "Pin number already reserved by EXTI" msgstr "" +#: ports/esp32s2/common-hal/alarm/__init__.c +msgid "PinAlarm not yet implemented" +msgstr "" + #: shared-bindings/rgbmatrix/RGBMatrix.c #, c-format msgid "" @@ -1562,7 +1578,7 @@ msgstr "" msgid "RTC calibration is not supported on this board" msgstr "" -#: shared-bindings/time/__init__.c +#: shared-bindings/alarm/time/TimeAlarm.c shared-bindings/time/__init__.c msgid "RTC is not supported on this board" msgstr "" @@ -1708,6 +1724,10 @@ msgstr "" msgid "Supply at least one UART pin" msgstr "" +#: shared-bindings/alarm/time/TimeAlarm.c +msgid "Supply one of monotonic_time or epoch_time" +msgstr "" + #: shared-bindings/gnss/GNSS.c msgid "System entry must be gnss.SatelliteSystem" msgstr "" @@ -1771,6 +1791,10 @@ msgstr "" msgid "Tile width must exactly divide bitmap width" msgstr "" +#: shared-bindings/alarm/time/TimeAlarm.c +msgid "Time is in the past." +msgstr "" + #: ports/nrf/common-hal/_bleio/Adapter.c #, c-format msgid "Timeout is too long: Maximum timeout length is %d seconds" @@ -2486,6 +2510,10 @@ msgstr "" msgid "end_x should be an int" msgstr "" +#: shared-bindings/alarm/time/TimeAlarm.c +msgid "epoch_time not supported on this board" +msgstr "" + #: ports/nrf/common-hal/busio/UART.c #, c-format msgid "error = 0x%08lX" @@ -2855,6 +2883,10 @@ msgstr "구문(syntax)가 정수가 유효하지 않습니다" msgid "invalid syntax for number" msgstr "숫자에 대한 구문(syntax)가 유효하지 않습니다" +#: ports/esp32s2/common-hal/alarm/pin/__init__.c +msgid "io must be rtc io" +msgstr "" + #: py/objtype.c msgid "issubclass() arg 1 must be a class" msgstr "" @@ -3542,6 +3574,10 @@ msgstr "" msgid "trapz is defined for 1D arrays of equal length" msgstr "" +#: ports/esp32s2/common-hal/alarm/pin/__init__.c +msgid "trigger level must be 0 or 1" +msgstr "" + #: extmod/ulab/code/linalg/linalg.c msgid "tuple index out of range" msgstr "" @@ -3684,6 +3720,10 @@ msgstr "" msgid "vectors must have same lengths" msgstr "" +#: ports/esp32s2/common-hal/alarm/pin/__init__.c +msgid "wakeup conflict" +msgstr "" + #: ports/esp32s2/common-hal/watchdog/WatchDogTimer.c msgid "watchdog not initialized" msgstr "" diff --git a/locale/nl.po b/locale/nl.po index 41a3ace76b..c5d9601c27 100644 --- a/locale/nl.po +++ b/locale/nl.po @@ -5,7 +5,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-11-24 15:40-0500\n" +"POT-Creation-Date: 2020-11-27 23:57-0500\n" "PO-Revision-Date: 2020-10-27 16:47+0000\n" "Last-Translator: Jelle Jager \n" "Language-Team: none\n" @@ -856,6 +856,10 @@ msgstr "Verwachtte een UUID" msgid "Expected an Address" msgstr "Verwachtte een adres" +#: shared-bindings/alarm/__init__.c +msgid "Expected an alarm" +msgstr "" + #: shared-module/_pixelbuf/PixelBuf.c #, c-format msgid "Expected tuple of length %d, got %d" @@ -1003,6 +1007,10 @@ msgstr "I2C Init Fout" msgid "I2SOut not available" msgstr "I2SOut is niet beschikbaar" +#: ports/esp32s2/common-hal/alarm/pin/__init__.c +msgid "IOs 0, 2 & 4 do not support internal pullup in sleep" +msgstr "" + #: shared-bindings/aesio/aes.c #, c-format msgid "IV must be %d bytes long" @@ -1462,6 +1470,10 @@ msgstr "" "Alleen monochrome en 4bpp of 8bpp, en 16bpp of grotere geïndiceerde BMP's " "zijn ondersteund: %d bpp is gegeven" +#: ports/esp32s2/common-hal/alarm/__init__.c +msgid "Only one alarm.time alarm can be set." +msgstr "" + #: shared-module/displayio/ColorConverter.c msgid "Only one color can be transparent at a time" msgstr "Er kan maar één kleur per keer transparant zijn" @@ -1522,6 +1534,10 @@ msgstr "Pin moet hardware interrupts ondersteunen" msgid "Pin number already reserved by EXTI" msgstr "Pin nummer al gereserveerd door EXTI" +#: ports/esp32s2/common-hal/alarm/__init__.c +msgid "PinAlarm not yet implemented" +msgstr "" + #: shared-bindings/rgbmatrix/RGBMatrix.c #, c-format msgid "" @@ -1592,7 +1608,7 @@ msgstr "RS485 inversie gespecificeerd terwijl niet in RS485 modus" msgid "RTC calibration is not supported on this board" msgstr "RTC calibratie niet ondersteund door dit board" -#: shared-bindings/time/__init__.c +#: shared-bindings/alarm/time/TimeAlarm.c shared-bindings/time/__init__.c msgid "RTC is not supported on this board" msgstr "RTC is niet ondersteund door dit board" @@ -1738,6 +1754,10 @@ msgstr "Stream mist readinto() of write() methode." msgid "Supply at least one UART pin" msgstr "Geef op zijn minst 1 UART pin op" +#: shared-bindings/alarm/time/TimeAlarm.c +msgid "Supply one of monotonic_time or epoch_time" +msgstr "" + #: shared-bindings/gnss/GNSS.c msgid "System entry must be gnss.SatelliteSystem" msgstr "Systeem invoer moet gnss.SatelliteSystem zijn" @@ -1809,6 +1829,10 @@ msgstr "Tile waarde buiten bereik" msgid "Tile width must exactly divide bitmap width" msgstr "Tile breedte moet exact de bitmap breedte verdelen" +#: shared-bindings/alarm/time/TimeAlarm.c +msgid "Time is in the past." +msgstr "" + #: ports/nrf/common-hal/_bleio/Adapter.c #, c-format msgid "Timeout is too long: Maximum timeout length is %d seconds" @@ -2540,6 +2564,10 @@ msgstr "einde van format terwijl zoekend naar conversie-specifier" msgid "end_x should be an int" msgstr "end_x moet een int zijn" +#: shared-bindings/alarm/time/TimeAlarm.c +msgid "epoch_time not supported on this board" +msgstr "" + #: ports/nrf/common-hal/busio/UART.c #, c-format msgid "error = 0x%08lX" @@ -2910,6 +2938,10 @@ msgstr "ongeldige syntax voor integer met grondtal %d" msgid "invalid syntax for number" msgstr "ongeldige syntax voor nummer" +#: ports/esp32s2/common-hal/alarm/pin/__init__.c +msgid "io must be rtc io" +msgstr "" + #: py/objtype.c msgid "issubclass() arg 1 must be a class" msgstr "issubclass() argument 1 moet een klasse zijn" @@ -3603,6 +3635,10 @@ msgstr "te veel waarden om uit te pakken (%d verwacht)" msgid "trapz is defined for 1D arrays of equal length" msgstr "trapz is gedefinieerd voor eendimensionale arrays van gelijke lengte" +#: ports/esp32s2/common-hal/alarm/pin/__init__.c +msgid "trigger level must be 0 or 1" +msgstr "" + #: extmod/ulab/code/linalg/linalg.c msgid "tuple index out of range" msgstr "tuple index buiten bereik" @@ -3745,6 +3781,10 @@ msgstr "value_count moet groter dan 0 zijn" msgid "vectors must have same lengths" msgstr "vectoren moeten van gelijke lengte zijn" +#: ports/esp32s2/common-hal/alarm/pin/__init__.c +msgid "wakeup conflict" +msgstr "" + #: ports/esp32s2/common-hal/watchdog/WatchDogTimer.c msgid "watchdog not initialized" msgstr "" diff --git a/locale/pl.po b/locale/pl.po index e2a064703e..12c612cc7f 100644 --- a/locale/pl.po +++ b/locale/pl.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-11-24 15:40-0500\n" +"POT-Creation-Date: 2020-11-27 23:57-0500\n" "PO-Revision-Date: 2020-12-02 20:29+0000\n" "Last-Translator: Maciej Stankiewicz \n" "Language-Team: pl\n" @@ -856,6 +856,10 @@ msgstr "Oczekiwano UUID" msgid "Expected an Address" msgstr "Oczekiwano adresu" +#: shared-bindings/alarm/__init__.c +msgid "Expected an alarm" +msgstr "" + #: shared-module/_pixelbuf/PixelBuf.c #, c-format msgid "Expected tuple of length %d, got %d" @@ -1001,6 +1005,10 @@ msgstr "Błąd inicjalizacji I2C" msgid "I2SOut not available" msgstr "I2SOut niedostępne" +#: ports/esp32s2/common-hal/alarm/pin/__init__.c +msgid "IOs 0, 2 & 4 do not support internal pullup in sleep" +msgstr "" + #: shared-bindings/aesio/aes.c #, c-format msgid "IV must be %d bytes long" @@ -1455,6 +1463,10 @@ msgid "" "%d bpp given" msgstr "" +#: ports/esp32s2/common-hal/alarm/__init__.c +msgid "Only one alarm.time alarm can be set." +msgstr "" + #: shared-module/displayio/ColorConverter.c msgid "Only one color can be transparent at a time" msgstr "W danym momencie przezroczysty może być tylko jeden kolor" @@ -1512,6 +1524,10 @@ msgstr "Pin musi obsługiwać przerwania sprzętowe" msgid "Pin number already reserved by EXTI" msgstr "" +#: ports/esp32s2/common-hal/alarm/__init__.c +msgid "PinAlarm not yet implemented" +msgstr "" + #: shared-bindings/rgbmatrix/RGBMatrix.c #, c-format msgid "" @@ -1573,7 +1589,7 @@ msgstr "" msgid "RTC calibration is not supported on this board" msgstr "Brak obsługi kalibracji RTC" -#: shared-bindings/time/__init__.c +#: shared-bindings/alarm/time/TimeAlarm.c shared-bindings/time/__init__.c msgid "RTC is not supported on this board" msgstr "Brak obsługi RTC" @@ -1719,6 +1735,10 @@ msgstr "Strumień nie ma metod readinto() lub write()." msgid "Supply at least one UART pin" msgstr "Podaj co najmniej jeden pin UART" +#: shared-bindings/alarm/time/TimeAlarm.c +msgid "Supply one of monotonic_time or epoch_time" +msgstr "" + #: shared-bindings/gnss/GNSS.c msgid "System entry must be gnss.SatelliteSystem" msgstr "" @@ -1782,6 +1802,10 @@ msgstr "" msgid "Tile width must exactly divide bitmap width" msgstr "Szerokość bitmapy musi być wielokrotnością szerokości kafelka" +#: shared-bindings/alarm/time/TimeAlarm.c +msgid "Time is in the past." +msgstr "" + #: ports/nrf/common-hal/_bleio/Adapter.c #, c-format msgid "Timeout is too long: Maximum timeout length is %d seconds" @@ -2503,6 +2527,10 @@ msgstr "koniec formatu przy szukaniu specyfikacji konwersji" msgid "end_x should be an int" msgstr "end_x powinien być całkowity" +#: shared-bindings/alarm/time/TimeAlarm.c +msgid "epoch_time not supported on this board" +msgstr "" + #: ports/nrf/common-hal/busio/UART.c #, c-format msgid "error = 0x%08lX" @@ -2872,6 +2900,10 @@ msgstr "zła składnia dla liczby całkowitej w bazie %d" msgid "invalid syntax for number" msgstr "zła składnia dla liczby" +#: ports/esp32s2/common-hal/alarm/pin/__init__.c +msgid "io must be rtc io" +msgstr "" + #: py/objtype.c msgid "issubclass() arg 1 must be a class" msgstr "argument 1 dla issubclass() musi być klasą" @@ -3561,6 +3593,10 @@ msgstr "zbyt wiele wartości do rozpakowania (oczekiwano %d)" msgid "trapz is defined for 1D arrays of equal length" msgstr "" +#: ports/esp32s2/common-hal/alarm/pin/__init__.c +msgid "trigger level must be 0 or 1" +msgstr "" + #: extmod/ulab/code/linalg/linalg.c msgid "tuple index out of range" msgstr "indeks krotki poza zakresem" @@ -3703,6 +3739,10 @@ msgstr "value_count musi być > 0" msgid "vectors must have same lengths" msgstr "wektory muszą mieć identyczną długość" +#: ports/esp32s2/common-hal/alarm/pin/__init__.c +msgid "wakeup conflict" +msgstr "" + #: ports/esp32s2/common-hal/watchdog/WatchDogTimer.c msgid "watchdog not initialized" msgstr "" diff --git a/locale/pt_BR.po b/locale/pt_BR.po index 36b1317d7a..39975643f1 100644 --- a/locale/pt_BR.po +++ b/locale/pt_BR.po @@ -5,7 +5,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-11-24 15:40-0500\n" +"POT-Creation-Date: 2020-11-27 23:57-0500\n" "PO-Revision-Date: 2020-11-30 18:06+0000\n" "Last-Translator: Wellington Terumi Uemura \n" "Language-Team: \n" @@ -865,6 +865,10 @@ msgstr "Um UUID é necessário" msgid "Expected an Address" msgstr "Um endereço esperado" +#: shared-bindings/alarm/__init__.c +msgid "Expected an alarm" +msgstr "" + #: shared-module/_pixelbuf/PixelBuf.c #, c-format msgid "Expected tuple of length %d, got %d" @@ -1012,6 +1016,10 @@ msgstr "Erro de inicialização do I2C" msgid "I2SOut not available" msgstr "O I2SOut não está disponível" +#: ports/esp32s2/common-hal/alarm/pin/__init__.c +msgid "IOs 0, 2 & 4 do not support internal pullup in sleep" +msgstr "" + #: shared-bindings/aesio/aes.c #, c-format msgid "IV must be %d bytes long" @@ -1470,6 +1478,10 @@ msgstr "" "São compatíveis apenas os BMPs monocromáticos, indexados em 4bpp ou 8bpp e " "16bpp ou superior: determinado %d bpp" +#: ports/esp32s2/common-hal/alarm/__init__.c +msgid "Only one alarm.time alarm can be set." +msgstr "" + #: shared-module/displayio/ColorConverter.c msgid "Only one color can be transparent at a time" msgstr "Apenas uma cor pode ser transparente de cada vez" @@ -1531,6 +1543,10 @@ msgstr "O pino deve ser compatível com as interrupções do hardware" msgid "Pin number already reserved by EXTI" msgstr "Número do PIN já está reservado através da EXTI" +#: ports/esp32s2/common-hal/alarm/__init__.c +msgid "PinAlarm not yet implemented" +msgstr "" + #: shared-bindings/rgbmatrix/RGBMatrix.c #, c-format msgid "" @@ -1602,7 +1618,7 @@ msgstr "A definição da inversão do RS485 quando não está no modo RS485" msgid "RTC calibration is not supported on this board" msgstr "A calibração RTC não é suportada nesta placa" -#: shared-bindings/time/__init__.c +#: shared-bindings/alarm/time/TimeAlarm.c shared-bindings/time/__init__.c msgid "RTC is not supported on this board" msgstr "O RTC não é suportado nesta placa" @@ -1748,6 +1764,10 @@ msgstr "Transmita o método ausente readinto() ou write()." msgid "Supply at least one UART pin" msgstr "Forneça pelo menos um pino UART" +#: shared-bindings/alarm/time/TimeAlarm.c +msgid "Supply one of monotonic_time or epoch_time" +msgstr "" + #: shared-bindings/gnss/GNSS.c msgid "System entry must be gnss.SatelliteSystem" msgstr "A entrada no sistema deve ser gnss.SatelliteSystem" @@ -1820,6 +1840,10 @@ msgstr "O valor do bloco está fora dos limites" msgid "Tile width must exactly divide bitmap width" msgstr "A largura do bloco deve dividir exatamente com a largura do bitmap" +#: shared-bindings/alarm/time/TimeAlarm.c +msgid "Time is in the past." +msgstr "" + #: ports/nrf/common-hal/_bleio/Adapter.c #, c-format msgid "Timeout is too long: Maximum timeout length is %d seconds" @@ -2560,6 +2584,10 @@ msgstr "final de formato enquanto procura pelo especificador de conversão" msgid "end_x should be an int" msgstr "end_x deve ser um int" +#: shared-bindings/alarm/time/TimeAlarm.c +msgid "epoch_time not supported on this board" +msgstr "" + #: ports/nrf/common-hal/busio/UART.c #, c-format msgid "error = 0x%08lX" @@ -2929,6 +2957,10 @@ msgstr "sintaxe inválida para o número inteiro com base %d" msgid "invalid syntax for number" msgstr "sintaxe inválida para o número" +#: ports/esp32s2/common-hal/alarm/pin/__init__.c +msgid "io must be rtc io" +msgstr "" + #: py/objtype.c msgid "issubclass() arg 1 must be a class" msgstr "issubclass() arg 1 deve ser uma classe" @@ -3628,6 +3660,10 @@ msgstr "valores demais para descompactar (esperado %d)" msgid "trapz is defined for 1D arrays of equal length" msgstr "o trapz está definido para 1D arrays de igual tamanho" +#: ports/esp32s2/common-hal/alarm/pin/__init__.c +msgid "trigger level must be 0 or 1" +msgstr "" + #: extmod/ulab/code/linalg/linalg.c msgid "tuple index out of range" msgstr "o índice da tupla está fora do intervalo" @@ -3770,6 +3806,10 @@ msgstr "o value_count deve ser > 0" msgid "vectors must have same lengths" msgstr "os vetores devem ter os mesmos comprimentos" +#: ports/esp32s2/common-hal/alarm/pin/__init__.c +msgid "wakeup conflict" +msgstr "" + #: ports/esp32s2/common-hal/watchdog/WatchDogTimer.c msgid "watchdog not initialized" msgstr "o watchdog não foi inicializado" diff --git a/locale/sv.po b/locale/sv.po index 47739e4aa1..72aa0852df 100644 --- a/locale/sv.po +++ b/locale/sv.po @@ -5,7 +5,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-11-24 15:40-0500\n" +"POT-Creation-Date: 2020-11-27 23:57-0500\n" "PO-Revision-Date: 2020-11-30 18:06+0000\n" "Last-Translator: Jonny Bergdahl \n" "Language-Team: LANGUAGE \n" @@ -856,6 +856,10 @@ msgstr "Förväntade en UUID" msgid "Expected an Address" msgstr "Förväntade en adress" +#: shared-bindings/alarm/__init__.c +msgid "Expected an alarm" +msgstr "" + #: shared-module/_pixelbuf/PixelBuf.c #, c-format msgid "Expected tuple of length %d, got %d" @@ -1001,6 +1005,10 @@ msgstr "I2C init-fel" msgid "I2SOut not available" msgstr "I2SOut är inte tillgängligt" +#: ports/esp32s2/common-hal/alarm/pin/__init__.c +msgid "IOs 0, 2 & 4 do not support internal pullup in sleep" +msgstr "" + #: shared-bindings/aesio/aes.c #, c-format msgid "IV must be %d bytes long" @@ -1460,6 +1468,10 @@ msgstr "" "Endast monokrom, indexerad 4 bpp eller 8 bpp och 16 bpp eller högre BMP: er " "stöds: %d bpp angiven" +#: ports/esp32s2/common-hal/alarm/__init__.c +msgid "Only one alarm.time alarm can be set." +msgstr "" + #: shared-module/displayio/ColorConverter.c msgid "Only one color can be transparent at a time" msgstr "Bara en färg kan vara genomskinlig i taget" @@ -1519,6 +1531,10 @@ msgstr "Pinnen måste stödja hårdvaruavbrott" msgid "Pin number already reserved by EXTI" msgstr "PInn-nummer redan reserverat av EXTI" +#: ports/esp32s2/common-hal/alarm/__init__.c +msgid "PinAlarm not yet implemented" +msgstr "" + #: shared-bindings/rgbmatrix/RGBMatrix.c #, c-format msgid "" @@ -1588,7 +1604,7 @@ msgstr "RS485-inversion specificerad när den inte är i RS485-läge" msgid "RTC calibration is not supported on this board" msgstr "RTC-kalibrering stöds inte av detta kort" -#: shared-bindings/time/__init__.c +#: shared-bindings/alarm/time/TimeAlarm.c shared-bindings/time/__init__.c msgid "RTC is not supported on this board" msgstr "RTC stöds inte av detta kort" @@ -1734,6 +1750,10 @@ msgstr "Stream saknar readinto() eller write() metod." msgid "Supply at least one UART pin" msgstr "Ange minst en UART-pinne" +#: shared-bindings/alarm/time/TimeAlarm.c +msgid "Supply one of monotonic_time or epoch_time" +msgstr "" + #: shared-bindings/gnss/GNSS.c msgid "System entry must be gnss.SatelliteSystem" msgstr "Systeminträdet måste vara gnss. SatellitSystem" @@ -1805,6 +1825,10 @@ msgstr "Tile-värde utanför intervall" msgid "Tile width must exactly divide bitmap width" msgstr "Tile-bredd måste vara jämnt delbar med bredd på bitmap" +#: shared-bindings/alarm/time/TimeAlarm.c +msgid "Time is in the past." +msgstr "" + #: ports/nrf/common-hal/_bleio/Adapter.c #, c-format msgid "Timeout is too long: Maximum timeout length is %d seconds" @@ -2534,6 +2558,10 @@ msgstr "slut på format vid sökning efter konverteringsspecificerare" msgid "end_x should be an int" msgstr "color ska vara en int" +#: shared-bindings/alarm/time/TimeAlarm.c +msgid "epoch_time not supported on this board" +msgstr "" + #: ports/nrf/common-hal/busio/UART.c #, c-format msgid "error = 0x%08lX" @@ -2903,6 +2931,10 @@ msgstr "ogiltig syntax för heltal med bas %d" msgid "invalid syntax for number" msgstr "ogiltig syntax för tal" +#: ports/esp32s2/common-hal/alarm/pin/__init__.c +msgid "io must be rtc io" +msgstr "" + #: py/objtype.c msgid "issubclass() arg 1 must be a class" msgstr "issubclass() arg 1 måste vara en klass" @@ -3596,6 +3628,10 @@ msgstr "för många värden att packa upp (förväntat %d)" msgid "trapz is defined for 1D arrays of equal length" msgstr "trapz är definierad för 1D-matriser med samma längd" +#: ports/esp32s2/common-hal/alarm/pin/__init__.c +msgid "trigger level must be 0 or 1" +msgstr "" + #: extmod/ulab/code/linalg/linalg.c msgid "tuple index out of range" msgstr "tupelindex utanför intervallet" @@ -3738,6 +3774,10 @@ msgstr "value_count måste vara > 0" msgid "vectors must have same lengths" msgstr "vektorer måste ha samma längd" +#: ports/esp32s2/common-hal/alarm/pin/__init__.c +msgid "wakeup conflict" +msgstr "" + #: ports/esp32s2/common-hal/watchdog/WatchDogTimer.c msgid "watchdog not initialized" msgstr "watchdog är inte initierad" diff --git a/locale/zh_Latn_pinyin.po b/locale/zh_Latn_pinyin.po index 7a08bc6e8c..eb24ad4210 100644 --- a/locale/zh_Latn_pinyin.po +++ b/locale/zh_Latn_pinyin.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: circuitpython-cn\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-11-24 15:40-0500\n" +"POT-Creation-Date: 2020-11-27 23:57-0500\n" "PO-Revision-Date: 2020-11-19 01:28+0000\n" "Last-Translator: hexthat \n" "Language-Team: Chinese Hanyu Pinyin\n" @@ -854,6 +854,10 @@ msgstr "Yùqí UUID" msgid "Expected an Address" msgstr "Qídài yīgè dìzhǐ" +#: shared-bindings/alarm/__init__.c +msgid "Expected an alarm" +msgstr "" + #: shared-module/_pixelbuf/PixelBuf.c #, c-format msgid "Expected tuple of length %d, got %d" @@ -999,6 +1003,10 @@ msgstr "I2C chūshǐhuà cuòwù" msgid "I2SOut not available" msgstr "I2SOut bù kě yòng" +#: ports/esp32s2/common-hal/alarm/pin/__init__.c +msgid "IOs 0, 2 & 4 do not support internal pullup in sleep" +msgstr "" + #: shared-bindings/aesio/aes.c #, c-format msgid "IV must be %d bytes long" @@ -1457,6 +1465,10 @@ 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" +#: ports/esp32s2/common-hal/alarm/__init__.c +msgid "Only one alarm.time alarm can be set." +msgstr "" + #: shared-module/displayio/ColorConverter.c msgid "Only one color can be transparent at a time" msgstr "Yīcì zhǐ néng yǒuyī zhǒng yánsè shì tòumíng de" @@ -1515,6 +1527,10 @@ msgstr "Yǐn jiǎo bìxū zhīchí yìngjiàn zhōngduàn" msgid "Pin number already reserved by EXTI" msgstr "Zhēn hào yǐ bèi EXTI bǎoliú" +#: ports/esp32s2/common-hal/alarm/__init__.c +msgid "PinAlarm not yet implemented" +msgstr "" + #: shared-bindings/rgbmatrix/RGBMatrix.c #, c-format msgid "" @@ -1580,7 +1596,7 @@ msgstr "Wèi chǔyú RS485 móshì shí zhǐdìngle RS485 fǎn zhuǎn" msgid "RTC calibration is not supported on this board" msgstr "Cǐ bǎn bù zhīchí RTC jiàozhǔn" -#: shared-bindings/time/__init__.c +#: shared-bindings/alarm/time/TimeAlarm.c shared-bindings/time/__init__.c msgid "RTC is not supported on this board" msgstr "Cǐ bǎn bù zhīchí RTC" @@ -1726,6 +1742,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" +#: shared-bindings/alarm/time/TimeAlarm.c +msgid "Supply one of monotonic_time or epoch_time" +msgstr "" + #: shared-bindings/gnss/GNSS.c msgid "System entry must be gnss.SatelliteSystem" msgstr "Xìtǒng tiáomù bìxū shì gnss.SatelliteSystem" @@ -1796,6 +1816,10 @@ 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ù" +#: shared-bindings/alarm/time/TimeAlarm.c +msgid "Time is in the past." +msgstr "" + #: ports/nrf/common-hal/_bleio/Adapter.c #, c-format msgid "Timeout is too long: Maximum timeout length is %d seconds" @@ -2526,6 +2550,10 @@ msgstr "xúnzhǎo zhuǎnhuàn biāozhù géshì de jiéshù" msgid "end_x should be an int" msgstr "jiéwěi_x yīnggāi shì yīgè zhěngshù" +#: shared-bindings/alarm/time/TimeAlarm.c +msgid "epoch_time not supported on this board" +msgstr "" + #: ports/nrf/common-hal/busio/UART.c #, c-format msgid "error = 0x%08lX" @@ -2895,6 +2923,10 @@ msgstr "jīshù wèi %d de zhěng shǔ de yǔfǎ wúxiào" msgid "invalid syntax for number" msgstr "wúxiào de hàomǎ yǔfǎ" +#: ports/esp32s2/common-hal/alarm/pin/__init__.c +msgid "io must be rtc io" +msgstr "" + #: py/objtype.c msgid "issubclass() arg 1 must be a class" msgstr "issubclass() cānshù 1 bìxū shì yīgè lèi" @@ -3585,6 +3617,10 @@ msgstr "dǎkāi tài duō zhí (yùqí %d)" msgid "trapz is defined for 1D arrays of equal length" msgstr "Trapz shì wèi děng zhǎng de 1D shùzǔ dìngyì de" +#: ports/esp32s2/common-hal/alarm/pin/__init__.c +msgid "trigger level must be 0 or 1" +msgstr "" + #: extmod/ulab/code/linalg/linalg.c msgid "tuple index out of range" msgstr "yuán zǔ suǒyǐn chāochū fànwéi" @@ -3727,6 +3763,10 @@ msgstr "zhí jìshù bìxū wèi > 0" msgid "vectors must have same lengths" msgstr "xiàngliàng bìxū jùyǒu xiāngtóng de chángdù" +#: ports/esp32s2/common-hal/alarm/pin/__init__.c +msgid "wakeup conflict" +msgstr "" + #: ports/esp32s2/common-hal/watchdog/WatchDogTimer.c msgid "watchdog not initialized" msgstr "wèi chū shǐ huà jiān shì qì" From 03d0ec85a19eb1dd0751385c764a043bf9b33ca3 Mon Sep 17 00:00:00 2001 From: Hosted Weblate Date: Wed, 2 Dec 2020 22:23:14 +0100 Subject: [PATCH 194/207] Update translation files Updated by "Update PO files to match POT (msgmerge)" hook in Weblate. Translation: CircuitPython/main Translate-URL: https://hosted.weblate.org/projects/circuitpython/main/ --- locale/ID.po | 8 +++++++- locale/cs.po | 8 +++++++- locale/de_DE.po | 8 +++++++- locale/el.po | 8 +++++++- locale/es.po | 8 +++++++- locale/fil.po | 8 +++++++- locale/fr.po | 8 +++++++- locale/hi.po | 8 +++++++- locale/it_IT.po | 8 +++++++- locale/ja.po | 8 +++++++- locale/ko.po | 8 +++++++- locale/nl.po | 8 +++++++- locale/pl.po | 8 +++++++- locale/pt_BR.po | 8 +++++++- locale/sv.po | 8 +++++++- locale/zh_Latn_pinyin.po | 8 +++++++- 16 files changed, 112 insertions(+), 16 deletions(-) diff --git a/locale/ID.po b/locale/ID.po index 43dcc72889..9645dc7024 100644 --- a/locale/ID.po +++ b/locale/ID.po @@ -504,7 +504,8 @@ msgstr "Panjang buffer harus kelipatan 512" msgid "Buffer must be a multiple of 512 bytes" msgstr "" -#: shared-bindings/bitbangio/I2C.c shared-bindings/busio/I2C.c +#: shared-bindings/bitbangio/I2C.c shared-bindings/busdevice/I2CDevice.c +#: shared-bindings/busio/I2C.c msgid "Buffer must be at least length 1" msgstr "Penyangga harus memiliki panjang setidaknya 1" @@ -1316,6 +1317,11 @@ msgstr "Tidak ada DAC (Digital Analog Converter) di dalam chip" msgid "No DMA channel found" msgstr "tidak ada channel DMA ditemukan" +#: shared-module/busdevice/I2CDevice.c +#, c-format +msgid "No I2C device at address: %x" +msgstr "" + #: ports/esp32s2/common-hal/busio/SPI.c ports/mimxrt10xx/common-hal/busio/SPI.c #: ports/stm/common-hal/busio/SPI.c msgid "No MISO Pin" diff --git a/locale/cs.po b/locale/cs.po index 72b2162678..e8287d266f 100644 --- a/locale/cs.po +++ b/locale/cs.po @@ -502,7 +502,8 @@ msgstr "" msgid "Buffer must be a multiple of 512 bytes" msgstr "" -#: shared-bindings/bitbangio/I2C.c shared-bindings/busio/I2C.c +#: shared-bindings/bitbangio/I2C.c shared-bindings/busdevice/I2CDevice.c +#: shared-bindings/busio/I2C.c msgid "Buffer must be at least length 1" msgstr "" @@ -1299,6 +1300,11 @@ msgstr "" msgid "No DMA channel found" msgstr "" +#: shared-module/busdevice/I2CDevice.c +#, c-format +msgid "No I2C device at address: %x" +msgstr "" + #: ports/esp32s2/common-hal/busio/SPI.c ports/mimxrt10xx/common-hal/busio/SPI.c #: ports/stm/common-hal/busio/SPI.c msgid "No MISO Pin" diff --git a/locale/de_DE.po b/locale/de_DE.po index a3b4cd2cc2..1aedb6ce1f 100644 --- a/locale/de_DE.po +++ b/locale/de_DE.po @@ -505,7 +505,8 @@ msgstr "Die Pufferlänge muss ein vielfaches von 512 sein" msgid "Buffer must be a multiple of 512 bytes" msgstr "Der Puffer muss ein vielfaches von 512 bytes sein" -#: shared-bindings/bitbangio/I2C.c shared-bindings/busio/I2C.c +#: shared-bindings/bitbangio/I2C.c shared-bindings/busdevice/I2CDevice.c +#: shared-bindings/busio/I2C.c msgid "Buffer must be at least length 1" msgstr "Der Puffer muss eine Mindestenslänge von 1 haben" @@ -1318,6 +1319,11 @@ msgstr "Kein DAC im Chip vorhanden" msgid "No DMA channel found" msgstr "Kein DMA Kanal gefunden" +#: shared-module/busdevice/I2CDevice.c +#, c-format +msgid "No I2C device at address: %x" +msgstr "" + #: ports/esp32s2/common-hal/busio/SPI.c ports/mimxrt10xx/common-hal/busio/SPI.c #: ports/stm/common-hal/busio/SPI.c msgid "No MISO Pin" diff --git a/locale/el.po b/locale/el.po index 01e4260403..6a4f7cdbb3 100644 --- a/locale/el.po +++ b/locale/el.po @@ -497,7 +497,8 @@ msgstr "" msgid "Buffer must be a multiple of 512 bytes" msgstr "" -#: shared-bindings/bitbangio/I2C.c shared-bindings/busio/I2C.c +#: shared-bindings/bitbangio/I2C.c shared-bindings/busdevice/I2CDevice.c +#: shared-bindings/busio/I2C.c msgid "Buffer must be at least length 1" msgstr "" @@ -1294,6 +1295,11 @@ msgstr "" msgid "No DMA channel found" msgstr "" +#: shared-module/busdevice/I2CDevice.c +#, c-format +msgid "No I2C device at address: %x" +msgstr "" + #: ports/esp32s2/common-hal/busio/SPI.c ports/mimxrt10xx/common-hal/busio/SPI.c #: ports/stm/common-hal/busio/SPI.c msgid "No MISO Pin" diff --git a/locale/es.po b/locale/es.po index 293a0c19e7..57b317e008 100644 --- a/locale/es.po +++ b/locale/es.po @@ -511,7 +511,8 @@ msgstr "El tamaño del búfer debe ser múltiplo de 512" msgid "Buffer must be a multiple of 512 bytes" msgstr "Búfer deber ser un múltiplo de 512 bytes" -#: shared-bindings/bitbangio/I2C.c shared-bindings/busio/I2C.c +#: shared-bindings/bitbangio/I2C.c shared-bindings/busdevice/I2CDevice.c +#: shared-bindings/busio/I2C.c msgid "Buffer must be at least length 1" msgstr "Buffer debe ser de longitud 1 como minimo" @@ -1317,6 +1318,11 @@ msgstr "El chip no tiene DAC" msgid "No DMA channel found" msgstr "No se encontró el canal DMA" +#: shared-module/busdevice/I2CDevice.c +#, c-format +msgid "No I2C device at address: %x" +msgstr "" + #: ports/esp32s2/common-hal/busio/SPI.c ports/mimxrt10xx/common-hal/busio/SPI.c #: ports/stm/common-hal/busio/SPI.c msgid "No MISO Pin" diff --git a/locale/fil.po b/locale/fil.po index c492f36c08..4a9e9591ed 100644 --- a/locale/fil.po +++ b/locale/fil.po @@ -502,7 +502,8 @@ msgstr "" msgid "Buffer must be a multiple of 512 bytes" msgstr "" -#: shared-bindings/bitbangio/I2C.c shared-bindings/busio/I2C.c +#: shared-bindings/bitbangio/I2C.c shared-bindings/busdevice/I2CDevice.c +#: shared-bindings/busio/I2C.c msgid "Buffer must be at least length 1" msgstr "Buffer dapat ay hindi baba sa 1 na haba" @@ -1309,6 +1310,11 @@ msgstr "Walang DAC sa chip" msgid "No DMA channel found" msgstr "Walang DMA channel na mahanap" +#: shared-module/busdevice/I2CDevice.c +#, c-format +msgid "No I2C device at address: %x" +msgstr "" + #: ports/esp32s2/common-hal/busio/SPI.c ports/mimxrt10xx/common-hal/busio/SPI.c #: ports/stm/common-hal/busio/SPI.c msgid "No MISO Pin" diff --git a/locale/fr.po b/locale/fr.po index 5dc91096c5..12d3feca02 100644 --- a/locale/fr.po +++ b/locale/fr.po @@ -511,7 +511,8 @@ msgstr "La longueur de la mémoire tampon doit être un multiple de 512" msgid "Buffer must be a multiple of 512 bytes" msgstr "La mémoire tampon doit être un multiple de 512" -#: shared-bindings/bitbangio/I2C.c shared-bindings/busio/I2C.c +#: shared-bindings/bitbangio/I2C.c shared-bindings/busdevice/I2CDevice.c +#: shared-bindings/busio/I2C.c msgid "Buffer must be at least length 1" msgstr "Le tampon doit être de longueur au moins 1" @@ -1322,6 +1323,11 @@ msgstr "Pas de DAC sur la puce" msgid "No DMA channel found" msgstr "Aucun canal DMA trouvé" +#: shared-module/busdevice/I2CDevice.c +#, c-format +msgid "No I2C device at address: %x" +msgstr "" + #: ports/esp32s2/common-hal/busio/SPI.c ports/mimxrt10xx/common-hal/busio/SPI.c #: ports/stm/common-hal/busio/SPI.c msgid "No MISO Pin" diff --git a/locale/hi.po b/locale/hi.po index b70a052019..7361e41e65 100644 --- a/locale/hi.po +++ b/locale/hi.po @@ -497,7 +497,8 @@ msgstr "" msgid "Buffer must be a multiple of 512 bytes" msgstr "" -#: shared-bindings/bitbangio/I2C.c shared-bindings/busio/I2C.c +#: shared-bindings/bitbangio/I2C.c shared-bindings/busdevice/I2CDevice.c +#: shared-bindings/busio/I2C.c msgid "Buffer must be at least length 1" msgstr "" @@ -1294,6 +1295,11 @@ msgstr "" msgid "No DMA channel found" msgstr "" +#: shared-module/busdevice/I2CDevice.c +#, c-format +msgid "No I2C device at address: %x" +msgstr "" + #: ports/esp32s2/common-hal/busio/SPI.c ports/mimxrt10xx/common-hal/busio/SPI.c #: ports/stm/common-hal/busio/SPI.c msgid "No MISO Pin" diff --git a/locale/it_IT.po b/locale/it_IT.po index 836d805852..4966002d26 100644 --- a/locale/it_IT.po +++ b/locale/it_IT.po @@ -502,7 +502,8 @@ msgstr "" msgid "Buffer must be a multiple of 512 bytes" msgstr "" -#: shared-bindings/bitbangio/I2C.c shared-bindings/busio/I2C.c +#: shared-bindings/bitbangio/I2C.c shared-bindings/busdevice/I2CDevice.c +#: shared-bindings/busio/I2C.c msgid "Buffer must be at least length 1" msgstr "Il buffer deve essere lungo almeno 1" @@ -1313,6 +1314,11 @@ msgstr "Nessun DAC sul chip" msgid "No DMA channel found" msgstr "Nessun canale DMA trovato" +#: shared-module/busdevice/I2CDevice.c +#, c-format +msgid "No I2C device at address: %x" +msgstr "" + #: ports/esp32s2/common-hal/busio/SPI.c ports/mimxrt10xx/common-hal/busio/SPI.c #: ports/stm/common-hal/busio/SPI.c msgid "No MISO Pin" diff --git a/locale/ja.po b/locale/ja.po index 2496db520c..27e094a0ab 100644 --- a/locale/ja.po +++ b/locale/ja.po @@ -506,7 +506,8 @@ msgstr "バッファ長は512の倍数でなければなりません" msgid "Buffer must be a multiple of 512 bytes" msgstr "バッファは512の倍数でなければなりません" -#: shared-bindings/bitbangio/I2C.c shared-bindings/busio/I2C.c +#: shared-bindings/bitbangio/I2C.c shared-bindings/busdevice/I2CDevice.c +#: shared-bindings/busio/I2C.c msgid "Buffer must be at least length 1" msgstr "バッファ長は少なくとも1以上でなければなりません" @@ -1309,6 +1310,11 @@ msgstr "チップにDACがありません" msgid "No DMA channel found" msgstr "DMAチャネルが見つかりません" +#: shared-module/busdevice/I2CDevice.c +#, c-format +msgid "No I2C device at address: %x" +msgstr "" + #: ports/esp32s2/common-hal/busio/SPI.c ports/mimxrt10xx/common-hal/busio/SPI.c #: ports/stm/common-hal/busio/SPI.c msgid "No MISO Pin" diff --git a/locale/ko.po b/locale/ko.po index dcbbfb81d3..407b495b88 100644 --- a/locale/ko.po +++ b/locale/ko.po @@ -502,7 +502,8 @@ msgstr "" msgid "Buffer must be a multiple of 512 bytes" msgstr "" -#: shared-bindings/bitbangio/I2C.c shared-bindings/busio/I2C.c +#: shared-bindings/bitbangio/I2C.c shared-bindings/busdevice/I2CDevice.c +#: shared-bindings/busio/I2C.c msgid "Buffer must be at least length 1" msgstr "잘못된 크기의 버퍼. >1 여야합니다" @@ -1299,6 +1300,11 @@ msgstr "" msgid "No DMA channel found" msgstr "" +#: shared-module/busdevice/I2CDevice.c +#, c-format +msgid "No I2C device at address: %x" +msgstr "" + #: ports/esp32s2/common-hal/busio/SPI.c ports/mimxrt10xx/common-hal/busio/SPI.c #: ports/stm/common-hal/busio/SPI.c msgid "No MISO Pin" diff --git a/locale/nl.po b/locale/nl.po index c5d9601c27..e45f9338d4 100644 --- a/locale/nl.po +++ b/locale/nl.po @@ -504,7 +504,8 @@ msgstr "Buffer lengte moet een veelvoud van 512 zijn" msgid "Buffer must be a multiple of 512 bytes" msgstr "Buffer moet een veelvoud van 512 bytes zijn" -#: shared-bindings/bitbangio/I2C.c shared-bindings/busio/I2C.c +#: shared-bindings/bitbangio/I2C.c shared-bindings/busdevice/I2CDevice.c +#: shared-bindings/busio/I2C.c msgid "Buffer must be at least length 1" msgstr "Buffer moet op zijn minst lengte 1 zijn" @@ -1311,6 +1312,11 @@ msgstr "Geen DAC op de chip" msgid "No DMA channel found" msgstr "Geen DMA kanaal gevonden" +#: shared-module/busdevice/I2CDevice.c +#, c-format +msgid "No I2C device at address: %x" +msgstr "" + #: ports/esp32s2/common-hal/busio/SPI.c ports/mimxrt10xx/common-hal/busio/SPI.c #: ports/stm/common-hal/busio/SPI.c msgid "No MISO Pin" diff --git a/locale/pl.po b/locale/pl.po index 12c612cc7f..31d446b3ba 100644 --- a/locale/pl.po +++ b/locale/pl.po @@ -506,7 +506,8 @@ msgstr "Długość bufora musi być wielokrotnością 512" msgid "Buffer must be a multiple of 512 bytes" msgstr "Bufor musi być wielokrotnością 512 bajtów" -#: shared-bindings/bitbangio/I2C.c shared-bindings/busio/I2C.c +#: shared-bindings/bitbangio/I2C.c shared-bindings/busdevice/I2CDevice.c +#: shared-bindings/busio/I2C.c msgid "Buffer must be at least length 1" msgstr "Bufor musi mieć długość 1 lub więcej" @@ -1310,6 +1311,11 @@ msgstr "Brak DAC" msgid "No DMA channel found" msgstr "Nie znaleziono kanału DMA" +#: shared-module/busdevice/I2CDevice.c +#, c-format +msgid "No I2C device at address: %x" +msgstr "" + #: ports/esp32s2/common-hal/busio/SPI.c ports/mimxrt10xx/common-hal/busio/SPI.c #: ports/stm/common-hal/busio/SPI.c msgid "No MISO Pin" diff --git a/locale/pt_BR.po b/locale/pt_BR.po index 39975643f1..239a83037d 100644 --- a/locale/pt_BR.po +++ b/locale/pt_BR.po @@ -512,7 +512,8 @@ msgstr "O comprimento do Buffer deve ser um múltiplo de 512" msgid "Buffer must be a multiple of 512 bytes" msgstr "O buffer deve ser um múltiplo de 512 bytes" -#: shared-bindings/bitbangio/I2C.c shared-bindings/busio/I2C.c +#: shared-bindings/bitbangio/I2C.c shared-bindings/busdevice/I2CDevice.c +#: shared-bindings/busio/I2C.c msgid "Buffer must be at least length 1" msgstr "O comprimento do buffer deve ter pelo menos 1" @@ -1320,6 +1321,11 @@ msgstr "Nenhum DAC no chip" msgid "No DMA channel found" msgstr "Nenhum canal DMA encontrado" +#: shared-module/busdevice/I2CDevice.c +#, c-format +msgid "No I2C device at address: %x" +msgstr "" + #: ports/esp32s2/common-hal/busio/SPI.c ports/mimxrt10xx/common-hal/busio/SPI.c #: ports/stm/common-hal/busio/SPI.c msgid "No MISO Pin" diff --git a/locale/sv.po b/locale/sv.po index 72aa0852df..db8d6a2d9d 100644 --- a/locale/sv.po +++ b/locale/sv.po @@ -504,7 +504,8 @@ msgstr "Buffertlängd måste vara en multipel av 512" msgid "Buffer must be a multiple of 512 bytes" msgstr "Bufferten måste vara en multipel av 512 byte" -#: shared-bindings/bitbangio/I2C.c shared-bindings/busio/I2C.c +#: shared-bindings/bitbangio/I2C.c shared-bindings/busdevice/I2CDevice.c +#: shared-bindings/busio/I2C.c msgid "Buffer must be at least length 1" msgstr "Bufferten måste ha minst längd 1" @@ -1310,6 +1311,11 @@ msgstr "Ingen DAC på chipet" msgid "No DMA channel found" msgstr "Ingen DMA-kanal hittades" +#: shared-module/busdevice/I2CDevice.c +#, c-format +msgid "No I2C device at address: %x" +msgstr "" + #: ports/esp32s2/common-hal/busio/SPI.c ports/mimxrt10xx/common-hal/busio/SPI.c #: ports/stm/common-hal/busio/SPI.c msgid "No MISO Pin" diff --git a/locale/zh_Latn_pinyin.po b/locale/zh_Latn_pinyin.po index eb24ad4210..5ef4b0e2ae 100644 --- a/locale/zh_Latn_pinyin.po +++ b/locale/zh_Latn_pinyin.po @@ -506,7 +506,8 @@ msgstr "Huǎn chōng qū cháng dù bì xū wéi 512 de bèi shù" msgid "Buffer must be a multiple of 512 bytes" msgstr "Huǎn chōng qū bì xū shì 512 zì jié de bèi shù" -#: shared-bindings/bitbangio/I2C.c shared-bindings/busio/I2C.c +#: shared-bindings/bitbangio/I2C.c shared-bindings/busdevice/I2CDevice.c +#: shared-bindings/busio/I2C.c msgid "Buffer must be at least length 1" msgstr "Huǎnchōng qū bìxū zhìshǎo chángdù 1" @@ -1307,6 +1308,11 @@ 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" +#: shared-module/busdevice/I2CDevice.c +#, c-format +msgid "No I2C device at address: %x" +msgstr "" + #: ports/esp32s2/common-hal/busio/SPI.c ports/mimxrt10xx/common-hal/busio/SPI.c #: ports/stm/common-hal/busio/SPI.c msgid "No MISO Pin" From 57fa6bece8fb841de10aaa6e96ced59749e6c566 Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Thu, 3 Dec 2020 21:27:35 -0500 Subject: [PATCH 195/207] allow radio.enabled to be settable --- shared-bindings/wifi/Radio.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/shared-bindings/wifi/Radio.c b/shared-bindings/wifi/Radio.c index 991abd4f12..d9d7dd5b53 100644 --- a/shared-bindings/wifi/Radio.c +++ b/shared-bindings/wifi/Radio.c @@ -55,10 +55,19 @@ STATIC mp_obj_t wifi_radio_get_enabled(mp_obj_t self) { } MP_DEFINE_CONST_FUN_OBJ_1(wifi_radio_get_enabled_obj, wifi_radio_get_enabled); +static mp_obj_t wifi_radio_set_enabled(mp_obj_t self, mp_obj_t value) { + const bool enabled = mp_obj_is_true(value); + + common_hal_wifi_radio_set_enabled(self, enabled); + + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_2(wifi_radio_set_enabled_obj, wifi_radio_set_enabled); + const mp_obj_property_t wifi_radio_enabled_obj = { .base.type = &mp_type_property, .proxy = { (mp_obj_t)&wifi_radio_get_enabled_obj, - (mp_obj_t)&mp_const_none_obj, + (mp_obj_t)&wifi_radio_set_enabled_obj, (mp_obj_t)&mp_const_none_obj }, }; From 2f0e676fcba318bbfcd39e6c50e75d6aeb739ac6 Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Thu, 3 Dec 2020 22:05:02 -0500 Subject: [PATCH 196/207] update doc per review --- shared-bindings/wifi/Radio.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/shared-bindings/wifi/Radio.c b/shared-bindings/wifi/Radio.c index d9d7dd5b53..edbd9fd2ff 100644 --- a/shared-bindings/wifi/Radio.c +++ b/shared-bindings/wifi/Radio.c @@ -48,7 +48,9 @@ //| //| enabled: bool -//| """True when the wifi radio is enabled.""" +//| """``True`` when the wifi radio is enabled. +//| If you set the value to ``False``, any open sockets will be closed. +//| """ //| STATIC mp_obj_t wifi_radio_get_enabled(mp_obj_t self) { return mp_obj_new_bool(common_hal_wifi_radio_get_enabled(self)); From 9391c8f9ddadbf8b46662f9baa9f10b8826d8b02 Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Sun, 6 Dec 2020 12:00:00 -0500 Subject: [PATCH 197/207] Make ResetReason and RunReason available --- shared-bindings/alarm/__init__.c | 4 ++-- shared-bindings/microcontroller/ResetReason.c | 4 ++-- shared-bindings/microcontroller/__init__.c | 1 + shared-bindings/microcontroller/__init__.h | 1 - shared-bindings/supervisor/__init__.c | 1 + 5 files changed, 6 insertions(+), 5 deletions(-) diff --git a/shared-bindings/alarm/__init__.c b/shared-bindings/alarm/__init__.c index c983130a19..a1f1a2f8c2 100644 --- a/shared-bindings/alarm/__init__.c +++ b/shared-bindings/alarm/__init__.c @@ -125,8 +125,8 @@ MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(alarm_light_sleep_until_alarms_obj, 1, MP_OB //| //| If no alarms are specified, the microcontroller will deep sleep until reset. //| -//| **If CircuitPython is connected to a host computer, `alarm.exit_and_deep_sleep_until_alarms()` -//| then the connection will be maintained, and the system will not go into deep sleep.** +//| **If CircuitPython is connected to a host computer, the connection will be maintained, +//| and the system will not go into deep sleep.** //| This allows the user to interrupt an existing program with ctrl-C, //| and to edit the files in CIRCUITPY, which would not be possible in true deep sleep. //| Thus, to use deep sleep and save significant power, you will need to disconnect from the host. diff --git a/shared-bindings/microcontroller/ResetReason.c b/shared-bindings/microcontroller/ResetReason.c index 61891934ae..1750e55204 100644 --- a/shared-bindings/microcontroller/ResetReason.c +++ b/shared-bindings/microcontroller/ResetReason.c @@ -72,6 +72,6 @@ MAKE_ENUM_MAP(mcu_reset_reason) { }; STATIC MP_DEFINE_CONST_DICT(mcu_reset_reason_locals_dict, mcu_reset_reason_locals_table); -MAKE_PRINTER(alarm, mcu_reset_reason); +MAKE_PRINTER(microcontroller, mcu_reset_reason); -MAKE_ENUM_TYPE(alarm, ResetReason, mcu_reset_reason); +MAKE_ENUM_TYPE(microcontroller, ResetReason, mcu_reset_reason); diff --git a/shared-bindings/microcontroller/__init__.c b/shared-bindings/microcontroller/__init__.c index 8a77d1df5b..035587c30f 100644 --- a/shared-bindings/microcontroller/__init__.c +++ b/shared-bindings/microcontroller/__init__.c @@ -170,6 +170,7 @@ STATIC const mp_rom_map_elem_t mcu_module_globals_table[] = { #else { MP_ROM_QSTR(MP_QSTR_watchdog), MP_ROM_PTR(&mp_const_none_obj) }, #endif + { MP_ROM_QSTR(MP_QSTR_ResetReason), MP_ROM_PTR(&mcu_reset_reason_type) }, { MP_ROM_QSTR(MP_QSTR_RunMode), MP_ROM_PTR(&mcu_runmode_type) }, { MP_ROM_QSTR(MP_QSTR_Pin), MP_ROM_PTR(&mcu_pin_type) }, { MP_ROM_QSTR(MP_QSTR_pin), MP_ROM_PTR(&mcu_pin_module) }, diff --git a/shared-bindings/microcontroller/__init__.h b/shared-bindings/microcontroller/__init__.h index ac71de4247..0dafc74c72 100644 --- a/shared-bindings/microcontroller/__init__.h +++ b/shared-bindings/microcontroller/__init__.h @@ -1,4 +1,3 @@ - /* * This file is part of the MicroPython project, http://micropython.org/ * diff --git a/shared-bindings/supervisor/__init__.c b/shared-bindings/supervisor/__init__.c index aaecdcbeb1..ad86030478 100644 --- a/shared-bindings/supervisor/__init__.c +++ b/shared-bindings/supervisor/__init__.c @@ -119,6 +119,7 @@ STATIC const mp_rom_map_elem_t supervisor_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR_set_rgb_status_brightness), MP_ROM_PTR(&supervisor_set_rgb_status_brightness_obj) }, { MP_ROM_QSTR(MP_QSTR_runtime), MP_ROM_PTR(&common_hal_supervisor_runtime_obj) }, { MP_ROM_QSTR(MP_QSTR_reload), MP_ROM_PTR(&supervisor_reload_obj) }, + { MP_ROM_QSTR(MP_QSTR_RunReason), MP_ROM_PTR(&supervisor_run_reason_type) }, { MP_ROM_QSTR(MP_QSTR_set_next_stack_limit), MP_ROM_PTR(&supervisor_set_next_stack_limit_obj) }, }; From 70827ac3da1138f3dbd4107ecb139cfbefd1846f Mon Sep 17 00:00:00 2001 From: BennyE Date: Sun, 6 Dec 2020 23:38:04 +0100 Subject: [PATCH 198/207] debug log for wifi scan, start stop --- ports/esp32s2/common-hal/wifi/__init__.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/ports/esp32s2/common-hal/wifi/__init__.c b/ports/esp32s2/common-hal/wifi/__init__.c index e06038c228..48fee4500f 100644 --- a/ports/esp32s2/common-hal/wifi/__init__.c +++ b/ports/esp32s2/common-hal/wifi/__init__.c @@ -47,8 +47,15 @@ static void event_handler(void* arg, esp_event_base_t event_base, if (event_base == WIFI_EVENT) { switch (event_id) { case WIFI_EVENT_SCAN_DONE: + ESP_EARLY_LOGW(TAG, "scan"); xEventGroupSetBits(radio->event_group_handle, WIFI_SCAN_DONE_BIT); break; + case WIFI_EVENT_STA_START: + ESP_EARLY_LOGW(TAG, "start"); + break; + case WIFI_EVENT_STA_STOP: + ESP_EARLY_LOGW(TAG, "stop"); + break; case WIFI_EVENT_STA_CONNECTED: ESP_EARLY_LOGW(TAG, "connected"); break; @@ -74,8 +81,6 @@ static void event_handler(void* arg, esp_event_base_t event_base, } // Cases to handle later. - // case WIFI_EVENT_STA_START: - // case WIFI_EVENT_STA_STOP: // case WIFI_EVENT_STA_AUTHMODE_CHANGE: default: break; From 169b4875099869d5d2549e9b717516e4045428d0 Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Mon, 7 Dec 2020 11:06:33 -0500 Subject: [PATCH 199/207] Include wifi.radio singleton in gc --- main.c | 8 ++++++++ ports/esp32s2/common-hal/wifi/Radio.c | 6 ++++++ ports/esp32s2/common-hal/wifi/Radio.h | 2 ++ ports/esp32s2/common-hal/wifi/__init__.c | 4 ++++ shared-bindings/wifi/__init__.h | 1 + 5 files changed, 21 insertions(+) diff --git a/main.c b/main.c index 95aeeeb81c..48c89d8adc 100755 --- a/main.c +++ b/main.c @@ -95,6 +95,10 @@ #include "common-hal/canio/CAN.h" #endif +#if CIRCUITPY_WIFI +#include "shared-bindings/wifi/__init__.h" +#endif + #if MICROPY_ENABLE_PYSTACK static size_t PLACE_IN_DTCM_BSS(_pystack[CIRCUITPY_PYSTACK_SIZE / sizeof(size_t)]); #endif @@ -560,6 +564,10 @@ void gc_collect(void) { common_hal_bleio_gc_collect(); #endif + #if CIRCUITPY_WIFI + common_hal_wifi_gc_collect(); + #endif + // This naively collects all object references from an approximate stack // range. gc_collect_root((void**)sp, ((uint32_t)port_stack_get_top() - sp) / sizeof(uint32_t)); diff --git a/ports/esp32s2/common-hal/wifi/Radio.c b/ports/esp32s2/common-hal/wifi/Radio.c index bc987bc1c9..49cb8ec30f 100644 --- a/ports/esp32s2/common-hal/wifi/Radio.c +++ b/ports/esp32s2/common-hal/wifi/Radio.c @@ -31,6 +31,7 @@ #include "common-hal/wifi/__init__.h" #include "lib/utils/interrupt_char.h" +#include "py/gc.h" #include "py/runtime.h" #include "shared-bindings/ipaddress/IPv4Address.h" #include "shared-bindings/wifi/ScannedNetworks.h" @@ -262,3 +263,8 @@ mp_int_t common_hal_wifi_radio_ping(wifi_radio_obj_t *self, mp_obj_t ip_address, return elapsed_time; } + +void common_hal_wifi_radio_gc_collect(wifi_radio_obj_t *self) { + // Only bother to scan the actual object references. + gc_collect_ptr(self->current_scan); +} diff --git a/ports/esp32s2/common-hal/wifi/Radio.h b/ports/esp32s2/common-hal/wifi/Radio.h index c7f484eafd..1dac47016b 100644 --- a/ports/esp32s2/common-hal/wifi/Radio.h +++ b/ports/esp32s2/common-hal/wifi/Radio.h @@ -59,4 +59,6 @@ typedef struct { uint8_t last_disconnect_reason; } wifi_radio_obj_t; +extern void common_hal_wifi_radio_gc_collect(wifi_radio_obj_t *self); + #endif // MICROPY_INCLUDED_ESP32S2_COMMON_HAL_WIFI_RADIO_H diff --git a/ports/esp32s2/common-hal/wifi/__init__.c b/ports/esp32s2/common-hal/wifi/__init__.c index e06038c228..5945f222e1 100644 --- a/ports/esp32s2/common-hal/wifi/__init__.c +++ b/ports/esp32s2/common-hal/wifi/__init__.c @@ -160,3 +160,7 @@ void ipaddress_ipaddress_to_esp_idf(mp_obj_t ip_address, ip_addr_t* esp_ip_addre IP_ADDR4(esp_ip_address, bytes[0], bytes[1], bytes[2], bytes[3]); } + +void common_hal_wifi_gc_collect(void) { + common_hal_wifi_radio_gc_collect(&common_hal_wifi_radio_obj); +} diff --git a/shared-bindings/wifi/__init__.h b/shared-bindings/wifi/__init__.h index c06ee16be7..124c0bc491 100644 --- a/shared-bindings/wifi/__init__.h +++ b/shared-bindings/wifi/__init__.h @@ -34,5 +34,6 @@ extern wifi_radio_obj_t common_hal_wifi_radio_obj; void common_hal_wifi_init(void); +void common_hal_wifi_gc_collect(void); #endif // MICROPY_INCLUDED_SHARED_BINDINGS_WIFI___INIT___H From 44b56f76c4a65617e8b477eb44cb35dab8624cb9 Mon Sep 17 00:00:00 2001 From: Scott Shawcroft Date: Mon, 7 Dec 2020 16:39:54 -0800 Subject: [PATCH 200/207] Store safe mode state in the RTC. Also print backtrace before reset when DEBUG. This will help debug safe mode issues which calls reset. --- ports/esp32s2/supervisor/port.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/ports/esp32s2/supervisor/port.c b/ports/esp32s2/supervisor/port.c index 0841081de8..6222cd2904 100644 --- a/ports/esp32s2/supervisor/port.c +++ b/ports/esp32s2/supervisor/port.c @@ -54,8 +54,11 @@ #include "peripherals/rmt.h" #include "peripherals/pcnt.h" #include "peripherals/timer.h" +#include "components/esp_rom/include/esp_rom_uart.h" #include "components/heap/include/esp_heap_caps.h" +#include "components/xtensa/include/esp_debug_helpers.h" #include "components/soc/soc/esp32s2/include/soc/cache_memory.h" +#include "components/soc/soc/esp32s2/include/soc/rtc_cntl_reg.h" #define HEAP_SIZE (48 * 1024) @@ -78,6 +81,11 @@ safe_mode_t port_init(void) { args.name = "CircuitPython Tick"; esp_timer_create(&args, &_tick_timer); + #ifdef DEBUG + // Send the ROM output out of the UART. This includes early logs. + esp_rom_install_channel_putc(1, esp_rom_uart_putc); + #endif + heap = NULL; never_reset_module_internal_pins(); @@ -165,6 +173,7 @@ void reset_to_bootloader(void) { } void reset_cpu(void) { + esp_backtrace_print(100); esp_restart(); } @@ -204,10 +213,11 @@ bool port_has_fixed_stack(void) { // Place the word to save just after our BSS section that gets blanked. void port_set_saved_word(uint32_t value) { + REG_WRITE(RTC_CNTL_STORE0_REG, value); } uint32_t port_get_saved_word(void) { - return 0; + return REG_READ(RTC_CNTL_STORE0_REG); } uint64_t port_get_raw_ticks(uint8_t* subticks) { From 571c063c2a9059a6957d5dae1d90702d0b5bd879 Mon Sep 17 00:00:00 2001 From: Bruce Segal Date: Mon, 7 Dec 2020 17:57:54 -0800 Subject: [PATCH 201/207] Working, tested with two i2c busses --- ports/esp32s2/common-hal/busio/I2C.c | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/ports/esp32s2/common-hal/busio/I2C.c b/ports/esp32s2/common-hal/busio/I2C.c index 6f19531288..772262d0a5 100644 --- a/ports/esp32s2/common-hal/busio/I2C.c +++ b/ports/esp32s2/common-hal/busio/I2C.c @@ -49,11 +49,11 @@ void never_reset_i2c(i2c_port_t num) { void i2c_reset(void) { for (i2c_port_t num = 0; num < I2C_NUM_MAX; num++) { if (i2c_status[num] == STATUS_IN_USE) { - i2c_driver_delete(num); i2c_status[num] = STATUS_FREE; } } } +static bool i2c_inited[I2C_NUM_MAX]; 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) { @@ -121,13 +121,19 @@ void common_hal_busio_i2c_construct(busio_i2c_obj_t *self, if (result != ESP_OK) { mp_raise_ValueError(translate("Invalid pins")); } - result = i2c_driver_install(self->i2c_num, - I2C_MODE_MASTER, - 0, - 0, - 0); - if (result != ESP_OK) { - mp_raise_OSError(MP_EIO); + + + if (!i2c_inited[self->i2c_num]) { + result = i2c_driver_install(self->i2c_num, + I2C_MODE_MASTER, + 0, + 0, + 0); + if (result != ESP_OK) { + mp_raise_OSError(MP_EIO); + } + i2c_inited[self->i2c_num] = true; + } claim_pin(sda); @@ -143,7 +149,6 @@ void common_hal_busio_i2c_deinit(busio_i2c_obj_t *self) { return; } - i2c_driver_delete(self->i2c_num); i2c_status[self->i2c_num] = STATUS_FREE; common_hal_reset_pin(self->sda_pin); From 2f95c94ad838f25ad96162435b8abab098484bde Mon Sep 17 00:00:00 2001 From: microDev <70126934+microDev1@users.noreply.github.com> Date: Tue, 8 Dec 2020 18:00:58 +0530 Subject: [PATCH 202/207] esp32s2 - update common_hal_mcu_reset --- ports/esp32s2/common-hal/microcontroller/__init__.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/ports/esp32s2/common-hal/microcontroller/__init__.c b/ports/esp32s2/common-hal/microcontroller/__init__.c index b7bea4e6b8..e425cbf543 100644 --- a/ports/esp32s2/common-hal/microcontroller/__init__.c +++ b/ports/esp32s2/common-hal/microcontroller/__init__.c @@ -74,8 +74,7 @@ void common_hal_mcu_on_next_reset(mcu_runmode_t runmode) { void common_hal_mcu_reset(void) { filesystem_flush(); //TODO: implement as part of flash improvements - // NVIC_SystemReset(); - while(1); + esp_restart(); } // The singleton microcontroller.Processor object, bound to microcontroller.cpu From 2c546ab768e82accbf6c3ed9a7fe3ce8ddcb9456 Mon Sep 17 00:00:00 2001 From: Radomir Dopieralski Date: Tue, 8 Dec 2020 15:54:34 +0100 Subject: [PATCH 203/207] Remove warning about lack of support on M0 from rotaryio It seems that this warning no longer applies. --- shared-bindings/rotaryio/__init__.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/shared-bindings/rotaryio/__init__.c b/shared-bindings/rotaryio/__init__.c index fd8578753d..cd967baa42 100644 --- a/shared-bindings/rotaryio/__init__.c +++ b/shared-bindings/rotaryio/__init__.c @@ -39,8 +39,6 @@ //| `Wikipedia's Rotary Encoder page `_ for more //| background. //| -//| .. warning:: This module is not available in some SAMD21 (aka M0) builds. See the :ref:`module-support-matrix` for more info. -//| //| All classes change hardware state and should be deinitialized when they //| are no longer needed if the program continues after use. To do so, either //| call :py:meth:`!deinit` or use a context manager. See From 40118bcf57f026fd6a58733501c759a9ba87e835 Mon Sep 17 00:00:00 2001 From: Scott Shawcroft Date: Wed, 2 Dec 2020 18:05:29 -0800 Subject: [PATCH 204/207] Add `board_deinit` for use with sleep This changes lots of files to unify `board.h` across ports. It adds `board_deinit` when CIRCUITPY_ALARM is set. `main.c` uses it to deinit the board before deep sleeping (even when pretending.) Deep sleep is now a two step process for the port. First, the port should prepare to deep sleep based on the given alarms. It should set alarms for both deep and pretend sleep. In particular, the pretend versions should be set immediately so that we don't miss an alarm as we shutdown. These alarms should also wake from `port_idle_until_interrupt` which is used when pretending to deep sleep. Second, when real deep sleeping, `alarm_enter_deep_sleep` is called. The port should set any alarms it didn't during prepare based on data it saved internally during prepare. ESP32-S2 sleep is a bit reorganized to locate more logic with TimeAlarm. This will help it scale to more alarm types. Fixes #3786 --- Makefile | 2 +- locale/circuitpython.pot | 19 ++- main.c | 76 +++++++-- .../atmel-samd/boards/8086_commander/board.c | 2 +- .../boards/aloriumtech_evo_m51/board.c | 2 +- .../atmel-samd/boards/arduino_mkr1300/board.c | 2 +- .../atmel-samd/boards/arduino_mkrzero/board.c | 2 +- .../boards/arduino_nano_33_iot/board.c | 2 +- ports/atmel-samd/boards/arduino_zero/board.c | 2 +- .../boards/bast_pro_mini_m0/board.c | 2 +- .../boards/bdmicro_vina_d21/board.c | 2 +- .../boards/bdmicro_vina_d51/board.c | 2 +- ports/atmel-samd/boards/blm_badge/board.c | 4 +- ports/atmel-samd/boards/board.h | 47 ------ .../boards/capablerobot_usbhub/board.c | 2 +- .../atmel-samd/boards/catwan_usbstick/board.c | 2 +- .../boards/circuitbrains_basic_m0/board.c | 2 +- .../boards/circuitbrains_deluxe_m4/board.c | 2 +- .../boards/circuitplayground_express/board.c | 4 +- .../circuitplayground_express_crickit/board.c | 4 +- .../board.c | 4 +- ports/atmel-samd/boards/cp32-m4/board.c | 2 +- ports/atmel-samd/boards/cp_sapling_m0/board.c | 2 +- .../boards/cp_sapling_m0_spiflash/board.c | 2 +- .../atmel-samd/boards/datalore_ip_m4/board.c | 2 +- .../atmel-samd/boards/datum_distance/board.c | 2 +- ports/atmel-samd/boards/datum_imu/board.c | 2 +- ports/atmel-samd/boards/datum_light/board.c | 2 +- ports/atmel-samd/boards/datum_weather/board.c | 2 +- .../boards/dynossat_edu_eps/board.c | 2 +- .../boards/dynossat_edu_obc/board.c | 2 +- .../boards/escornabot_makech/board.c | 2 +- .../boards/feather_m0_adalogger/board.c | 2 +- .../boards/feather_m0_basic/board.c | 2 +- .../boards/feather_m0_express/board.c | 2 +- .../boards/feather_m0_express_crickit/board.c | 2 +- .../boards/feather_m0_rfm69/board.c | 2 +- .../boards/feather_m0_rfm9x/board.c | 2 +- .../boards/feather_m0_supersized/board.c | 2 +- .../atmel-samd/boards/feather_m4_can/board.c | 2 +- .../boards/feather_m4_express/board.c | 2 +- .../boards/feather_radiofruit_zigbee/board.c | 2 +- ports/atmel-samd/boards/fluff_m0/board.c | 2 +- ports/atmel-samd/boards/gemma_m0/board.c | 2 +- .../boards/grandcentral_m4_express/board.c | 2 +- .../boards/hallowing_m0_express/board.c | 2 +- .../boards/hallowing_m0_express/pins.c | 2 +- .../boards/hallowing_m4_express/board.c | 2 +- .../boards/itsybitsy_m0_express/board.c | 2 +- .../boards/itsybitsy_m4_express/board.c | 2 +- .../atmel-samd/boards/kicksat-sprite/board.c | 2 +- ports/atmel-samd/boards/kicksat-sprite/pins.c | 2 +- .../boards/loc_ber_m4_base_board/board.c | 2 +- .../atmel-samd/boards/matrixportal_m4/board.c | 2 +- ports/atmel-samd/boards/meowmeow/board.c | 2 +- .../boards/metro_m0_express/board.c | 2 +- .../boards/metro_m4_airlift_lite/board.c | 2 +- .../boards/metro_m4_express/board.c | 2 +- ports/atmel-samd/boards/mini_sam_m4/board.c | 2 +- ports/atmel-samd/boards/monster_m4sk/board.c | 2 +- ports/atmel-samd/boards/monster_m4sk/pins.c | 2 +- .../atmel-samd/boards/ndgarage_ndbit6/board.c | 2 +- .../boards/ndgarage_ndbit6_v2/board.c | 2 +- ports/atmel-samd/boards/nfc_copy_cat/board.c | 2 +- ports/atmel-samd/boards/openbook_m4/board.c | 2 +- ports/atmel-samd/boards/openbook_m4/pins.c | 2 +- ports/atmel-samd/boards/pewpew10/board.c | 2 +- ports/atmel-samd/boards/pewpew_m4/board.c | 2 +- ports/atmel-samd/boards/picoplanet/board.c | 2 +- ports/atmel-samd/boards/pirkey_m0/board.c | 2 +- ports/atmel-samd/boards/pybadge/board.c | 4 +- ports/atmel-samd/boards/pybadge/pins.c | 2 +- .../atmel-samd/boards/pybadge_airlift/board.c | 4 +- .../atmel-samd/boards/pybadge_airlift/pins.c | 2 +- ports/atmel-samd/boards/pycubed/board.c | 2 +- ports/atmel-samd/boards/pycubed/pins.c | 2 +- ports/atmel-samd/boards/pycubed_mram/board.c | 2 +- ports/atmel-samd/boards/pycubed_mram/pins.c | 2 +- ports/atmel-samd/boards/pygamer/board.c | 4 +- ports/atmel-samd/boards/pygamer/pins.c | 2 +- .../atmel-samd/boards/pygamer_advance/board.c | 4 +- .../atmel-samd/boards/pygamer_advance/pins.c | 2 +- ports/atmel-samd/boards/pyportal/board.c | 2 +- ports/atmel-samd/boards/pyportal/pins.c | 2 +- .../atmel-samd/boards/pyportal_titano/board.c | 2 +- .../atmel-samd/boards/pyportal_titano/pins.c | 2 +- ports/atmel-samd/boards/pyruler/board.c | 2 +- ports/atmel-samd/boards/qtpy_m0/board.c | 2 +- .../boards/qtpy_m0_haxpress/board.c | 2 +- ports/atmel-samd/boards/robohatmm1_m4/board.c | 2 +- ports/atmel-samd/boards/sam32/board.c | 2 +- .../atmel-samd/boards/same54_xplained/board.c | 2 +- .../boards/seeeduino_wio_terminal/board.c | 2 +- .../atmel-samd/boards/seeeduino_xiao/board.c | 2 +- ports/atmel-samd/boards/serpente/board.c | 2 +- ports/atmel-samd/boards/shirtty/board.c | 2 +- ports/atmel-samd/boards/snekboard/board.c | 2 +- .../boards/sparkfun_lumidrive/board.c | 2 +- .../sparkfun_qwiic_micro_no_flash/board.c | 2 +- .../sparkfun_qwiic_micro_with_flash/board.c | 2 +- .../boards/sparkfun_redboard_turbo/board.c | 2 +- .../boards/sparkfun_samd21_dev/board.c | 2 +- .../boards/sparkfun_samd21_mini/board.c | 2 +- .../boards/sparkfun_samd51_thing_plus/board.c | 2 +- .../boards/stringcar_m0_express/board.c | 2 +- .../boards/trellis_m4_express/board.c | 2 +- ports/atmel-samd/boards/trinket_m0/board.c | 2 +- .../boards/trinket_m0_haxpress/board.c | 2 +- ports/atmel-samd/boards/uartlogger2/board.c | 2 +- ports/atmel-samd/boards/uchip/board.c | 2 +- ports/atmel-samd/boards/ugame10/board.c | 2 +- .../winterbloom_big_honking_button/board.c | 2 +- .../atmel-samd/boards/winterbloom_sol/board.c | 2 +- ports/atmel-samd/boards/xinabox_cc03/board.c | 2 +- ports/atmel-samd/boards/xinabox_cs11/board.c | 2 +- ports/atmel-samd/common-hal/busio/SPI.c | 2 +- ports/atmel-samd/common-hal/sdioio/SDCard.c | 1 - ports/atmel-samd/supervisor/port.c | 4 +- ports/cxd56/boards/board.h | 45 ------ ports/cxd56/boards/spresense/board.c | 2 +- ports/cxd56/supervisor/port.c | 4 +- .../adafruit_magtag_2.9_grayscale/board.c | 22 ++- .../boards/adafruit_metro_esp32s2/board.c | 5 +- .../boards/electroniccats_bastwifi/board.c | 5 +- .../esp32s2/boards/espressif_kaluga_1/board.c | 5 +- .../boards/espressif_saola_1_wroom/board.c | 5 +- .../boards/espressif_saola_1_wrover/board.c | 5 +- .../esp32s2/boards/microdev_micro_s2/board.c | 5 +- .../boards/muselab_nanoesp32_s2/board.c | 5 +- .../boards/targett_module_clip_wroom/board.c | 5 +- .../boards/targett_module_clip_wrover/board.c | 5 +- .../boards/unexpectedmaker_feathers2/board.c | 5 +- .../board.c | 5 +- ports/esp32s2/common-hal/alarm/__init__.c | 150 ++++++------------ .../esp32s2/common-hal/alarm/time/TimeAlarm.c | 64 ++++++++ .../esp32s2/common-hal/alarm/time/TimeAlarm.h | 7 + ports/esp32s2/common-hal/busio/SPI.c | 1 - ports/esp32s2/supervisor/port.c | 24 +-- ports/litex/boards/board.h | 45 ------ ports/litex/boards/fomu/board.c | 3 +- ports/litex/supervisor/port.c | 4 +- ports/mimxrt10xx/board.h | 1 + .../mimxrt10xx/boards/feather_m7_1011/board.c | 3 +- .../boards/feather_m7_1011/flash_config.c | 4 +- .../mimxrt10xx/boards/feather_m7_1011/pins.c | 2 +- .../boards/feather_mimxrt1011/board.c | 3 +- .../boards/feather_mimxrt1011/flash_config.c | 4 +- .../boards/feather_mimxrt1011/pins.c | 2 +- .../boards/feather_mimxrt1062/board.c | 3 +- .../boards/feather_mimxrt1062/flash_config.c | 3 +- .../boards/feather_mimxrt1062/pins.c | 2 +- .../boards/{board.h => flash_config.h} | 20 +-- ports/mimxrt10xx/boards/imxrt1010_evk/board.c | 3 +- .../boards/imxrt1010_evk/flash_config.c | 3 +- ports/mimxrt10xx/boards/imxrt1010_evk/pins.c | 2 +- ports/mimxrt10xx/boards/imxrt1020_evk/board.c | 3 +- .../boards/imxrt1020_evk/flash_config.c | 3 +- ports/mimxrt10xx/boards/imxrt1020_evk/pins.c | 2 +- ports/mimxrt10xx/boards/imxrt1060_evk/board.c | 3 +- .../boards/imxrt1060_evk/flash_config.c | 3 +- ports/mimxrt10xx/boards/imxrt1060_evk/pins.c | 2 +- ports/mimxrt10xx/boards/metro_m7_1011/board.c | 3 +- .../boards/metro_m7_1011/flash_config.c | 3 +- ports/mimxrt10xx/boards/metro_m7_1011/pins.c | 2 +- ports/mimxrt10xx/boards/teensy40/board.c | 3 +- .../mimxrt10xx/boards/teensy40/flash_config.c | 3 +- ports/mimxrt10xx/boards/teensy40/pins.c | 2 +- ports/mimxrt10xx/boards/teensy41/board.c | 3 +- .../mimxrt10xx/boards/teensy41/flash_config.c | 3 +- ports/mimxrt10xx/boards/teensy41/pins.c | 2 +- .../supervisor/flexspi_nor_flash_ops.c | 2 +- ports/mimxrt10xx/supervisor/internal_flash.c | 2 +- ports/mimxrt10xx/supervisor/port.c | 4 +- ports/nrf/boards/ADM_B_NRF52840_1/board.c | 2 +- ports/nrf/boards/TG-Watch02A/board.c | 2 +- ports/nrf/boards/aramcon_badge_2019/board.c | 2 +- ports/nrf/boards/arduino_nano_33_ble/board.c | 2 +- .../bless_dev_board_multi_sensor/board.c | 2 +- ports/nrf/boards/board.h | 45 ------ .../circuitplayground_bluefruit/board.c | 4 +- .../nrf/boards/clue_nrf52840_express/board.c | 2 +- ports/nrf/boards/clue_nrf52840_express/pins.c | 2 +- ports/nrf/boards/electronut_labs_blip/board.c | 2 +- .../nrf/boards/electronut_labs_papyr/board.c | 2 +- .../boards/feather_bluefruit_sense/board.c | 2 +- .../boards/feather_nrf52840_express/board.c | 2 +- ports/nrf/boards/hiibot_bluefi/board.c | 2 +- ports/nrf/boards/hiibot_bluefi/pins.c | 2 +- ports/nrf/boards/ikigaisense_vita/board.c | 2 +- .../boards/itsybitsy_nrf52840_express/board.c | 2 +- .../boards/makerdiary_m60_keyboard/board.c | 2 +- .../nrf/boards/makerdiary_m60_keyboard/pins.c | 2 +- .../makerdiary_nrf52840_m2_devkit/board.c | 2 +- .../makerdiary_nrf52840_m2_devkit/pins.c | 2 +- .../boards/makerdiary_nrf52840_mdk/board.c | 2 +- .../board.c | 2 +- .../nrf/boards/metro_nrf52840_express/board.c | 2 +- ports/nrf/boards/nice_nano/board.c | 2 +- ports/nrf/boards/ohs2020_badge/board.c | 2 +- ports/nrf/boards/particle_argon/board.c | 2 +- ports/nrf/boards/particle_boron/board.c | 2 +- ports/nrf/boards/particle_xenon/board.c | 2 +- ports/nrf/boards/pca10056/board.c | 2 +- ports/nrf/boards/pca10059/board.c | 2 +- ports/nrf/boards/pca10100/board.c | 2 +- ports/nrf/boards/pitaya_go/board.c | 2 +- ports/nrf/boards/raytac_mdbt50q-db-40/board.c | 2 +- ports/nrf/boards/simmel/board.c | 2 +- .../nrf/boards/sparkfun_nrf52840_mini/board.c | 2 +- ports/nrf/boards/teknikio_bluebird/board.c | 2 +- .../tinkeringtech_scoutmakes_azul/board.c | 2 +- ports/nrf/supervisor/port.c | 4 +- ports/stm/boards/board.h | 45 ------ ports/stm/boards/espruino_pico/board.c | 2 +- ports/stm/boards/espruino_wifi/board.c | 2 +- .../boards/feather_stm32f405_express/board.c | 2 +- ports/stm/boards/meowbit_v121/board.c | 2 +- ports/stm/boards/nucleo_f746zg/board.c | 2 +- ports/stm/boards/nucleo_f767zi/board.c | 2 +- ports/stm/boards/nucleo_h743zi_2/board.c | 2 +- ports/stm/boards/openmv_h7/board.c | 2 +- ports/stm/boards/pyb_nano_v2/board.c | 2 +- ports/stm/boards/pyboard_v11/board.c | 2 +- .../stm/boards/stm32f411ce_blackpill/board.c | 2 +- .../stm/boards/stm32f411ve_discovery/board.c | 2 +- .../stm/boards/stm32f412zg_discovery/board.c | 2 +- ports/stm/boards/stm32f4_discovery/board.c | 2 +- ports/stm/boards/stm32f746g_discovery/board.c | 2 +- ports/stm/boards/thunderpack_v11/board.c | 2 +- ports/stm/boards/thunderpack_v12/board.c | 2 +- ports/stm/common-hal/busio/SPI.c | 2 +- ports/stm/common-hal/sdioio/SDCard.c | 2 +- ports/stm/supervisor/port.c | 4 +- py/circuitpy_mpconfig.h | 6 + shared-bindings/alarm/__init__.c | 44 ++--- shared-bindings/alarm/__init__.h | 17 +- {ports/esp32s2/boards => supervisor}/board.h | 22 ++- supervisor/port.h | 9 +- supervisor/shared/board.c | 19 ++- supervisor/shared/board.h | 14 +- supervisor/shared/tick.c | 4 +- 241 files changed, 590 insertions(+), 675 deletions(-) delete mode 100644 ports/atmel-samd/boards/board.h delete mode 100644 ports/cxd56/boards/board.h delete mode 100644 ports/litex/boards/board.h create mode 100644 ports/mimxrt10xx/board.h rename ports/mimxrt10xx/boards/{board.h => flash_config.h} (75%) delete mode 100644 ports/nrf/boards/board.h delete mode 100644 ports/stm/boards/board.h rename {ports/esp32s2/boards => supervisor}/board.h (77%) diff --git a/Makefile b/Makefile index e553b85e8b..a1807c308f 100644 --- a/Makefile +++ b/Makefile @@ -265,7 +265,7 @@ update-frozen-libraries: @echo "Updating all frozen libraries to latest tagged version." cd frozen; for library in *; do cd $$library; ../../tools/git-checkout-latest-tag.sh; cd ..; done -one-of-each: samd21 samd51 esp32s2 litex mimxrt10xx nrf stm +one-of-each: samd21 litex mimxrt10xx nrf stm samd21: $(MAKE) -C ports/atmel-samd BOARD=trinket_m0 diff --git a/locale/circuitpython.pot b/locale/circuitpython.pot index b136e9dd26..11ca8c8140 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-11-27 23:57-0500\n" +"POT-Creation-Date: 2020-12-08 09:56-0800\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -498,8 +498,8 @@ msgstr "" msgid "Buffer must be a multiple of 512 bytes" msgstr "" -#: shared-bindings/bitbangio/I2C.c shared-bindings/busdevice/I2CDevice.c -#: shared-bindings/busio/I2C.c +#: shared-bindings/adafruit_bus_device/I2CDevice.c +#: shared-bindings/bitbangio/I2C.c shared-bindings/busio/I2C.c msgid "Buffer must be at least length 1" msgstr "" @@ -1296,7 +1296,7 @@ msgstr "" msgid "No DMA channel found" msgstr "" -#: shared-module/busdevice/I2CDevice.c +#: shared-module/adafruit_bus_device/I2CDevice.c #, c-format msgid "No I2C device at address: %x" msgstr "" @@ -1503,6 +1503,7 @@ msgstr "" msgid "Pin does not have ADC capabilities" msgstr "" +#: shared-bindings/adafruit_bus_device/SPIDevice.c #: shared-bindings/digitalio/DigitalInOut.c msgid "Pin is input only" msgstr "" @@ -1555,7 +1556,11 @@ msgid "Prefix buffer must be on the heap" msgstr "" #: main.c -msgid "Press any key to enter the REPL. Use CTRL-D to reload." +msgid "Press any key to enter the REPL. Use CTRL-D to reload.\n" +msgstr "" + +#: main.c +msgid "Pretending to deep sleep until alarm, any key or file write.\n" msgstr "" #: shared-bindings/digitalio/DigitalInOut.c @@ -2026,6 +2031,10 @@ msgstr "" msgid "WiFi password must be between 8 and 63 characters" msgstr "" +#: main.c +msgid "Woken up by alarm.\n" +msgstr "" + #: ports/nrf/common-hal/_bleio/PacketBuffer.c msgid "Writes not supported on Characteristic" msgstr "" diff --git a/main.c b/main.c index 48c89d8adc..9eb4787299 100755 --- a/main.c +++ b/main.c @@ -46,6 +46,7 @@ #include "background.h" #include "mpconfigboard.h" #include "supervisor/background_callback.h" +#include "supervisor/board.h" #include "supervisor/cpu.h" #include "supervisor/filesystem.h" #include "supervisor/memory.h" @@ -64,8 +65,6 @@ #include "shared-bindings/microcontroller/Processor.h" #include "shared-bindings/supervisor/Runtime.h" -#include "boards/board.h" - #if CIRCUITPY_ALARM #include "shared-bindings/alarm/__init__.h" #endif @@ -303,13 +302,6 @@ STATIC bool run_code_py(safe_mode_t safe_mode) { if (result.return_code & PYEXEC_FORCED_EXIT) { return reload_requested; } - - #if CIRCUITPY_ALARM - if (result.return_code & PYEXEC_DEEP_SLEEP) { - common_hal_alarm_enter_deep_sleep(); - // Does not return. - } - #endif } // Program has finished running. @@ -326,24 +318,47 @@ STATIC bool run_code_py(safe_mode_t safe_mode) { rgb_status_animation_t animation; prep_rgb_status_animation(&result, found_main, safe_mode, &animation); + bool asleep = false; while (true) { - RUN_BACKGROUND_TASKS; if (reload_requested) { + #if CIRCUITPY_ALARM + if (asleep) { + board_init(); + } + #endif supervisor_set_run_reason(RUN_REASON_AUTO_RELOAD); reload_requested = false; return true; } if (serial_connected() && serial_bytes_available()) { + #if CIRCUITPY_ALARM + if (asleep) { + board_init(); + } + #endif // Skip REPL if reload was requested. bool ctrl_d = serial_read() == CHAR_CTRL_D; if (ctrl_d) { supervisor_set_run_reason(RUN_REASON_REPL_RELOAD); } - return (ctrl_d); + return ctrl_d; } + // Check for a deep sleep alarm and restart the VM. This can happen if + // an alarm alerts faster than our USB delay or if we pretended to deep + // sleep. + #if CIRCUITPY_ALARM + if (asleep && alarm_woken_from_sleep()) { + serial_write_compressed(translate("Woken up by alarm.\n")); + board_init(); + supervisor_set_run_reason(RUN_REASON_STARTUP); + // TODO: Reset any volatile memory the user may have access to. + return true; + } + #endif + if (!serial_connected_before_animation && serial_connected()) { if (!serial_connected_at_start) { print_code_py_status_message(safe_mode); @@ -351,7 +366,7 @@ STATIC bool run_code_py(safe_mode_t safe_mode) { print_safe_mode_message(safe_mode); serial_write("\n"); - serial_write_compressed(translate("Press any key to enter the REPL. Use CTRL-D to reload.")); + serial_write_compressed(translate("Press any key to enter the REPL. Use CTRL-D to reload.\n")); } if (serial_connected_before_animation && !serial_connected()) { serial_connected_at_start = false; @@ -360,12 +375,47 @@ STATIC bool run_code_py(safe_mode_t safe_mode) { // Refresh the ePaper display if we have one. That way it'll show an error message. #if CIRCUITPY_DISPLAYIO + // Don't refresh the display if we're about to deep sleep. + #if CIRCUITPY_ALARM + refreshed_epaper_display = refreshed_epaper_display || result.return_code & PYEXEC_DEEP_SLEEP; + #endif if (!refreshed_epaper_display) { refreshed_epaper_display = maybe_refresh_epaperdisplay(); } #endif - tick_rgb_status_animation(&animation); + // Sleep until our next interrupt. + #if CIRCUITPY_ALARM + if (result.return_code & PYEXEC_DEEP_SLEEP) { + // Make sure we have been awake long enough for USB to connect (enumeration delay). + int64_t connecting_delay_ticks = CIRCUITPY_USB_CONNECTED_SLEEP_DELAY * 1024 - port_get_raw_ticks(NULL); + if (connecting_delay_ticks > 0) { + // Set when we've waited long enough so that we wake up from the + // sleep_until_interrupt below and loop around to the real deep + // sleep in the else clause. + port_interrupt_after_ticks(connecting_delay_ticks); + // Deep sleep if we're not connected to a host. + } else if (!asleep) { + asleep = true; + new_status_color(BLACK); + board_deinit(); + if (!supervisor_workflow_active()) { + // Enter true deep sleep. When we wake up we'll be back at the + // top of main(), not in this loop. + alarm_enter_deep_sleep(); + // Does not return. + } else { + serial_write_compressed(translate("Pretending to deep sleep until alarm, any key or file write.\n")); + } + } + } + #endif + + if (!asleep) { + tick_rgb_status_animation(&animation); + } else { + port_idle_until_interrupt(); + } } } diff --git a/ports/atmel-samd/boards/8086_commander/board.c b/ports/atmel-samd/boards/8086_commander/board.c index d7e856d611..84960e73cf 100644 --- a/ports/atmel-samd/boards/8086_commander/board.c +++ b/ports/atmel-samd/boards/8086_commander/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" void board_init(void) { } diff --git a/ports/atmel-samd/boards/aloriumtech_evo_m51/board.c b/ports/atmel-samd/boards/aloriumtech_evo_m51/board.c index 1e9ab029e2..5973eeec1b 100644 --- a/ports/atmel-samd/boards/aloriumtech_evo_m51/board.c +++ b/ports/atmel-samd/boards/aloriumtech_evo_m51/board.c @@ -28,7 +28,7 @@ // Author: Bryan Craker // Date: 2020-05-20 -#include "boards/board.h" +#include "supervisor/board.h" #include "mpconfigboard.h" void board_init(void) { diff --git a/ports/atmel-samd/boards/arduino_mkr1300/board.c b/ports/atmel-samd/boards/arduino_mkr1300/board.c index 770bc82593..112b173ecc 100644 --- a/ports/atmel-samd/boards/arduino_mkr1300/board.c +++ b/ports/atmel-samd/boards/arduino_mkr1300/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" #include "mpconfigboard.h" #include "hal/include/hal_gpio.h" diff --git a/ports/atmel-samd/boards/arduino_mkrzero/board.c b/ports/atmel-samd/boards/arduino_mkrzero/board.c index 0f60736a24..7af05ba45a 100644 --- a/ports/atmel-samd/boards/arduino_mkrzero/board.c +++ b/ports/atmel-samd/boards/arduino_mkrzero/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" #include "mpconfigboard.h" #include "hal/include/hal_gpio.h" diff --git a/ports/atmel-samd/boards/arduino_nano_33_iot/board.c b/ports/atmel-samd/boards/arduino_nano_33_iot/board.c index 770bc82593..112b173ecc 100644 --- a/ports/atmel-samd/boards/arduino_nano_33_iot/board.c +++ b/ports/atmel-samd/boards/arduino_nano_33_iot/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" #include "mpconfigboard.h" #include "hal/include/hal_gpio.h" diff --git a/ports/atmel-samd/boards/arduino_zero/board.c b/ports/atmel-samd/boards/arduino_zero/board.c index 770bc82593..112b173ecc 100644 --- a/ports/atmel-samd/boards/arduino_zero/board.c +++ b/ports/atmel-samd/boards/arduino_zero/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" #include "mpconfigboard.h" #include "hal/include/hal_gpio.h" diff --git a/ports/atmel-samd/boards/bast_pro_mini_m0/board.c b/ports/atmel-samd/boards/bast_pro_mini_m0/board.c index c8e20206a1..6baa43ffaa 100644 --- a/ports/atmel-samd/boards/bast_pro_mini_m0/board.c +++ b/ports/atmel-samd/boards/bast_pro_mini_m0/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" void board_init(void) { diff --git a/ports/atmel-samd/boards/bdmicro_vina_d21/board.c b/ports/atmel-samd/boards/bdmicro_vina_d21/board.c index bd63baa6fd..bb1c5335c1 100644 --- a/ports/atmel-samd/boards/bdmicro_vina_d21/board.c +++ b/ports/atmel-samd/boards/bdmicro_vina_d21/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" #include "mpconfigboard.h" void board_init(void) diff --git a/ports/atmel-samd/boards/bdmicro_vina_d51/board.c b/ports/atmel-samd/boards/bdmicro_vina_d51/board.c index bd63baa6fd..bb1c5335c1 100644 --- a/ports/atmel-samd/boards/bdmicro_vina_d51/board.c +++ b/ports/atmel-samd/boards/bdmicro_vina_d51/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" #include "mpconfigboard.h" void board_init(void) diff --git a/ports/atmel-samd/boards/blm_badge/board.c b/ports/atmel-samd/boards/blm_badge/board.c index ee353c8108..e374899a66 100644 --- a/ports/atmel-samd/boards/blm_badge/board.c +++ b/ports/atmel-samd/boards/blm_badge/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" #include "supervisor/shared/board.h" void board_init(void) { @@ -35,5 +35,5 @@ bool board_requests_safe_mode(void) { } void reset_board(void) { - board_reset_user_neopixels(); + board_reset_user_neopixels(&pin_PA05, 10); } diff --git a/ports/atmel-samd/boards/board.h b/ports/atmel-samd/boards/board.h deleted file mode 100644 index 4f0ae9d728..0000000000 --- a/ports/atmel-samd/boards/board.h +++ /dev/null @@ -1,47 +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. - */ - -// This file defines board specific functions. - -#ifndef MICROPY_INCLUDED_ATMEL_SAMD_BOARDS_BOARD_H -#define MICROPY_INCLUDED_ATMEL_SAMD_BOARDS_BOARD_H - -#include - -#include "py/mpconfig.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_ATMEL_SAMD_BOARDS_BOARD_H diff --git a/ports/atmel-samd/boards/capablerobot_usbhub/board.c b/ports/atmel-samd/boards/capablerobot_usbhub/board.c index 46385f094f..d65582379e 100644 --- a/ports/atmel-samd/boards/capablerobot_usbhub/board.c +++ b/ports/atmel-samd/boards/capablerobot_usbhub/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" #include "mpconfigboard.h" #include "hal/include/hal_gpio.h" #include "common-hal/microcontroller/Pin.h" diff --git a/ports/atmel-samd/boards/catwan_usbstick/board.c b/ports/atmel-samd/boards/catwan_usbstick/board.c index c8e20206a1..6baa43ffaa 100644 --- a/ports/atmel-samd/boards/catwan_usbstick/board.c +++ b/ports/atmel-samd/boards/catwan_usbstick/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" void board_init(void) { diff --git a/ports/atmel-samd/boards/circuitbrains_basic_m0/board.c b/ports/atmel-samd/boards/circuitbrains_basic_m0/board.c index efafd152db..59d573ce9f 100755 --- a/ports/atmel-samd/boards/circuitbrains_basic_m0/board.c +++ b/ports/atmel-samd/boards/circuitbrains_basic_m0/board.c @@ -25,7 +25,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" #include "mpconfigboard.h" #include "hal/include/hal_gpio.h" diff --git a/ports/atmel-samd/boards/circuitbrains_deluxe_m4/board.c b/ports/atmel-samd/boards/circuitbrains_deluxe_m4/board.c index efafd152db..59d573ce9f 100755 --- a/ports/atmel-samd/boards/circuitbrains_deluxe_m4/board.c +++ b/ports/atmel-samd/boards/circuitbrains_deluxe_m4/board.c @@ -25,7 +25,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" #include "mpconfigboard.h" #include "hal/include/hal_gpio.h" diff --git a/ports/atmel-samd/boards/circuitplayground_express/board.c b/ports/atmel-samd/boards/circuitplayground_express/board.c index 85c37ee622..f771c214b3 100644 --- a/ports/atmel-samd/boards/circuitplayground_express/board.c +++ b/ports/atmel-samd/boards/circuitplayground_express/board.c @@ -26,7 +26,7 @@ #include -#include "boards/board.h" +#include "supervisor/board.h" #include "common-hal/microcontroller/Pin.h" #include "supervisor/shared/board.h" #include "hal/include/hal_gpio.h" @@ -53,5 +53,5 @@ bool board_requests_safe_mode(void) { } void reset_board(void) { - board_reset_user_neopixels(); + board_reset_user_neopixels(&pin_PB23, 10); } diff --git a/ports/atmel-samd/boards/circuitplayground_express_crickit/board.c b/ports/atmel-samd/boards/circuitplayground_express_crickit/board.c index 21217caac9..13fed598eb 100644 --- a/ports/atmel-samd/boards/circuitplayground_express_crickit/board.c +++ b/ports/atmel-samd/boards/circuitplayground_express_crickit/board.c @@ -26,7 +26,7 @@ #include -#include "boards/board.h" +#include "supervisor/board.h" #include "common-hal/microcontroller/Pin.h" #include "hal/include/hal_gpio.h" #include "supervisor/shared/board.h" @@ -53,5 +53,5 @@ bool board_requests_safe_mode(void) { } void reset_board(void) { - board_reset_user_neopixels(); + board_reset_user_neopixels(&pin_PB23, 10); } diff --git a/ports/atmel-samd/boards/circuitplayground_express_displayio/board.c b/ports/atmel-samd/boards/circuitplayground_express_displayio/board.c index 21217caac9..13fed598eb 100644 --- a/ports/atmel-samd/boards/circuitplayground_express_displayio/board.c +++ b/ports/atmel-samd/boards/circuitplayground_express_displayio/board.c @@ -26,7 +26,7 @@ #include -#include "boards/board.h" +#include "supervisor/board.h" #include "common-hal/microcontroller/Pin.h" #include "hal/include/hal_gpio.h" #include "supervisor/shared/board.h" @@ -53,5 +53,5 @@ bool board_requests_safe_mode(void) { } void reset_board(void) { - board_reset_user_neopixels(); + board_reset_user_neopixels(&pin_PB23, 10); } diff --git a/ports/atmel-samd/boards/cp32-m4/board.c b/ports/atmel-samd/boards/cp32-m4/board.c index 0f60736a24..7af05ba45a 100644 --- a/ports/atmel-samd/boards/cp32-m4/board.c +++ b/ports/atmel-samd/boards/cp32-m4/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" #include "mpconfigboard.h" #include "hal/include/hal_gpio.h" diff --git a/ports/atmel-samd/boards/cp_sapling_m0/board.c b/ports/atmel-samd/boards/cp_sapling_m0/board.c index ce56366762..cde441b3d9 100644 --- a/ports/atmel-samd/boards/cp_sapling_m0/board.c +++ b/ports/atmel-samd/boards/cp_sapling_m0/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" #include "common-hal/microcontroller/Pin.h" #include "supervisor/shared/board.h" #include "hal/include/hal_gpio.h" diff --git a/ports/atmel-samd/boards/cp_sapling_m0_spiflash/board.c b/ports/atmel-samd/boards/cp_sapling_m0_spiflash/board.c index ce56366762..cde441b3d9 100644 --- a/ports/atmel-samd/boards/cp_sapling_m0_spiflash/board.c +++ b/ports/atmel-samd/boards/cp_sapling_m0_spiflash/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" #include "common-hal/microcontroller/Pin.h" #include "supervisor/shared/board.h" #include "hal/include/hal_gpio.h" diff --git a/ports/atmel-samd/boards/datalore_ip_m4/board.c b/ports/atmel-samd/boards/datalore_ip_m4/board.c index 0f60736a24..7af05ba45a 100644 --- a/ports/atmel-samd/boards/datalore_ip_m4/board.c +++ b/ports/atmel-samd/boards/datalore_ip_m4/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" #include "mpconfigboard.h" #include "hal/include/hal_gpio.h" diff --git a/ports/atmel-samd/boards/datum_distance/board.c b/ports/atmel-samd/boards/datum_distance/board.c index c8e20206a1..6baa43ffaa 100644 --- a/ports/atmel-samd/boards/datum_distance/board.c +++ b/ports/atmel-samd/boards/datum_distance/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" void board_init(void) { diff --git a/ports/atmel-samd/boards/datum_imu/board.c b/ports/atmel-samd/boards/datum_imu/board.c index c8e20206a1..6baa43ffaa 100644 --- a/ports/atmel-samd/boards/datum_imu/board.c +++ b/ports/atmel-samd/boards/datum_imu/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" void board_init(void) { diff --git a/ports/atmel-samd/boards/datum_light/board.c b/ports/atmel-samd/boards/datum_light/board.c index c8e20206a1..6baa43ffaa 100644 --- a/ports/atmel-samd/boards/datum_light/board.c +++ b/ports/atmel-samd/boards/datum_light/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" void board_init(void) { diff --git a/ports/atmel-samd/boards/datum_weather/board.c b/ports/atmel-samd/boards/datum_weather/board.c index c8e20206a1..6baa43ffaa 100644 --- a/ports/atmel-samd/boards/datum_weather/board.c +++ b/ports/atmel-samd/boards/datum_weather/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" void board_init(void) { diff --git a/ports/atmel-samd/boards/dynossat_edu_eps/board.c b/ports/atmel-samd/boards/dynossat_edu_eps/board.c index c8e20206a1..6baa43ffaa 100644 --- a/ports/atmel-samd/boards/dynossat_edu_eps/board.c +++ b/ports/atmel-samd/boards/dynossat_edu_eps/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" void board_init(void) { diff --git a/ports/atmel-samd/boards/dynossat_edu_obc/board.c b/ports/atmel-samd/boards/dynossat_edu_obc/board.c index c8e20206a1..6baa43ffaa 100644 --- a/ports/atmel-samd/boards/dynossat_edu_obc/board.c +++ b/ports/atmel-samd/boards/dynossat_edu_obc/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" void board_init(void) { diff --git a/ports/atmel-samd/boards/escornabot_makech/board.c b/ports/atmel-samd/boards/escornabot_makech/board.c index 881e15e0c5..5afe2fb655 100644 --- a/ports/atmel-samd/boards/escornabot_makech/board.c +++ b/ports/atmel-samd/boards/escornabot_makech/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" void board_init(void) { diff --git a/ports/atmel-samd/boards/feather_m0_adalogger/board.c b/ports/atmel-samd/boards/feather_m0_adalogger/board.c index c8e20206a1..6baa43ffaa 100644 --- a/ports/atmel-samd/boards/feather_m0_adalogger/board.c +++ b/ports/atmel-samd/boards/feather_m0_adalogger/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" void board_init(void) { diff --git a/ports/atmel-samd/boards/feather_m0_basic/board.c b/ports/atmel-samd/boards/feather_m0_basic/board.c index c8e20206a1..6baa43ffaa 100644 --- a/ports/atmel-samd/boards/feather_m0_basic/board.c +++ b/ports/atmel-samd/boards/feather_m0_basic/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" void board_init(void) { diff --git a/ports/atmel-samd/boards/feather_m0_express/board.c b/ports/atmel-samd/boards/feather_m0_express/board.c index c8e20206a1..6baa43ffaa 100644 --- a/ports/atmel-samd/boards/feather_m0_express/board.c +++ b/ports/atmel-samd/boards/feather_m0_express/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" void board_init(void) { diff --git a/ports/atmel-samd/boards/feather_m0_express_crickit/board.c b/ports/atmel-samd/boards/feather_m0_express_crickit/board.c index c8e20206a1..6baa43ffaa 100644 --- a/ports/atmel-samd/boards/feather_m0_express_crickit/board.c +++ b/ports/atmel-samd/boards/feather_m0_express_crickit/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" void board_init(void) { diff --git a/ports/atmel-samd/boards/feather_m0_rfm69/board.c b/ports/atmel-samd/boards/feather_m0_rfm69/board.c index c8e20206a1..6baa43ffaa 100644 --- a/ports/atmel-samd/boards/feather_m0_rfm69/board.c +++ b/ports/atmel-samd/boards/feather_m0_rfm69/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" void board_init(void) { diff --git a/ports/atmel-samd/boards/feather_m0_rfm9x/board.c b/ports/atmel-samd/boards/feather_m0_rfm9x/board.c index c8e20206a1..6baa43ffaa 100644 --- a/ports/atmel-samd/boards/feather_m0_rfm9x/board.c +++ b/ports/atmel-samd/boards/feather_m0_rfm9x/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" void board_init(void) { diff --git a/ports/atmel-samd/boards/feather_m0_supersized/board.c b/ports/atmel-samd/boards/feather_m0_supersized/board.c index c8e20206a1..6baa43ffaa 100644 --- a/ports/atmel-samd/boards/feather_m0_supersized/board.c +++ b/ports/atmel-samd/boards/feather_m0_supersized/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" void board_init(void) { diff --git a/ports/atmel-samd/boards/feather_m4_can/board.c b/ports/atmel-samd/boards/feather_m4_can/board.c index 8096b9b8ea..5fca974e9e 100644 --- a/ports/atmel-samd/boards/feather_m4_can/board.c +++ b/ports/atmel-samd/boards/feather_m4_can/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" #include "mpconfigboard.h" void board_init(void) { diff --git a/ports/atmel-samd/boards/feather_m4_express/board.c b/ports/atmel-samd/boards/feather_m4_express/board.c index 8096b9b8ea..5fca974e9e 100644 --- a/ports/atmel-samd/boards/feather_m4_express/board.c +++ b/ports/atmel-samd/boards/feather_m4_express/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" #include "mpconfigboard.h" void board_init(void) { diff --git a/ports/atmel-samd/boards/feather_radiofruit_zigbee/board.c b/ports/atmel-samd/boards/feather_radiofruit_zigbee/board.c index c8e20206a1..6baa43ffaa 100755 --- a/ports/atmel-samd/boards/feather_radiofruit_zigbee/board.c +++ b/ports/atmel-samd/boards/feather_radiofruit_zigbee/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" void board_init(void) { diff --git a/ports/atmel-samd/boards/fluff_m0/board.c b/ports/atmel-samd/boards/fluff_m0/board.c index c8e20206a1..6baa43ffaa 100644 --- a/ports/atmel-samd/boards/fluff_m0/board.c +++ b/ports/atmel-samd/boards/fluff_m0/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" void board_init(void) { diff --git a/ports/atmel-samd/boards/gemma_m0/board.c b/ports/atmel-samd/boards/gemma_m0/board.c index c8e20206a1..6baa43ffaa 100644 --- a/ports/atmel-samd/boards/gemma_m0/board.c +++ b/ports/atmel-samd/boards/gemma_m0/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" void board_init(void) { diff --git a/ports/atmel-samd/boards/grandcentral_m4_express/board.c b/ports/atmel-samd/boards/grandcentral_m4_express/board.c index 7599f02b8e..5ed8c84049 100644 --- a/ports/atmel-samd/boards/grandcentral_m4_express/board.c +++ b/ports/atmel-samd/boards/grandcentral_m4_express/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" #include "mpconfigboard.h" #include "hal/include/hal_gpio.h" diff --git a/ports/atmel-samd/boards/hallowing_m0_express/board.c b/ports/atmel-samd/boards/hallowing_m0_express/board.c index 14a2bdb816..8b922d6bef 100644 --- a/ports/atmel-samd/boards/hallowing_m0_express/board.c +++ b/ports/atmel-samd/boards/hallowing_m0_express/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" #include "shared-bindings/board/__init__.h" #include "shared-bindings/displayio/FourWire.h" diff --git a/ports/atmel-samd/boards/hallowing_m0_express/pins.c b/ports/atmel-samd/boards/hallowing_m0_express/pins.c index 3e670a676f..5d1dda51ac 100644 --- a/ports/atmel-samd/boards/hallowing_m0_express/pins.c +++ b/ports/atmel-samd/boards/hallowing_m0_express/pins.c @@ -1,6 +1,6 @@ #include "shared-bindings/board/__init__.h" -#include "boards/board.h" +#include "supervisor/board.h" #include "shared-module/displayio/__init__.h" STATIC const mp_rom_map_elem_t board_global_dict_table[] = { diff --git a/ports/atmel-samd/boards/hallowing_m4_express/board.c b/ports/atmel-samd/boards/hallowing_m4_express/board.c index 61e797d652..f51d4282d3 100644 --- a/ports/atmel-samd/boards/hallowing_m4_express/board.c +++ b/ports/atmel-samd/boards/hallowing_m4_express/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" #include "mpconfigboard.h" #include "hal/include/hal_gpio.h" #include "shared-bindings/busio/SPI.h" diff --git a/ports/atmel-samd/boards/itsybitsy_m0_express/board.c b/ports/atmel-samd/boards/itsybitsy_m0_express/board.c index d7e856d611..84960e73cf 100644 --- a/ports/atmel-samd/boards/itsybitsy_m0_express/board.c +++ b/ports/atmel-samd/boards/itsybitsy_m0_express/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" void board_init(void) { } diff --git a/ports/atmel-samd/boards/itsybitsy_m4_express/board.c b/ports/atmel-samd/boards/itsybitsy_m4_express/board.c index 0f60736a24..7af05ba45a 100644 --- a/ports/atmel-samd/boards/itsybitsy_m4_express/board.c +++ b/ports/atmel-samd/boards/itsybitsy_m4_express/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" #include "mpconfigboard.h" #include "hal/include/hal_gpio.h" diff --git a/ports/atmel-samd/boards/kicksat-sprite/board.c b/ports/atmel-samd/boards/kicksat-sprite/board.c index 75cdfbc824..d7f78e764a 100644 --- a/ports/atmel-samd/boards/kicksat-sprite/board.c +++ b/ports/atmel-samd/boards/kicksat-sprite/board.c @@ -27,7 +27,7 @@ #include -#include "boards/board.h" +#include "supervisor/board.h" #include "py/mpconfig.h" void board_init(void) { diff --git a/ports/atmel-samd/boards/kicksat-sprite/pins.c b/ports/atmel-samd/boards/kicksat-sprite/pins.c index 87d894c589..27ee903231 100644 --- a/ports/atmel-samd/boards/kicksat-sprite/pins.c +++ b/ports/atmel-samd/boards/kicksat-sprite/pins.c @@ -1,5 +1,5 @@ #include "shared-bindings/board/__init__.h" -#include "boards/board.h" +#include "supervisor/board.h" STATIC const mp_rom_map_elem_t board_global_dict_table[] = { { MP_ROM_QSTR(MP_QSTR_SCK), MP_ROM_PTR(&pin_PA05) }, diff --git a/ports/atmel-samd/boards/loc_ber_m4_base_board/board.c b/ports/atmel-samd/boards/loc_ber_m4_base_board/board.c index 0f60736a24..7af05ba45a 100644 --- a/ports/atmel-samd/boards/loc_ber_m4_base_board/board.c +++ b/ports/atmel-samd/boards/loc_ber_m4_base_board/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" #include "mpconfigboard.h" #include "hal/include/hal_gpio.h" diff --git a/ports/atmel-samd/boards/matrixportal_m4/board.c b/ports/atmel-samd/boards/matrixportal_m4/board.c index 2d4f302391..52ecd83025 100644 --- a/ports/atmel-samd/boards/matrixportal_m4/board.c +++ b/ports/atmel-samd/boards/matrixportal_m4/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" #include "mpconfigboard.h" #include "hal/include/hal_gpio.h" diff --git a/ports/atmel-samd/boards/meowmeow/board.c b/ports/atmel-samd/boards/meowmeow/board.c index 881e15e0c5..5afe2fb655 100644 --- a/ports/atmel-samd/boards/meowmeow/board.c +++ b/ports/atmel-samd/boards/meowmeow/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" void board_init(void) { diff --git a/ports/atmel-samd/boards/metro_m0_express/board.c b/ports/atmel-samd/boards/metro_m0_express/board.c index bd63baa6fd..bb1c5335c1 100644 --- a/ports/atmel-samd/boards/metro_m0_express/board.c +++ b/ports/atmel-samd/boards/metro_m0_express/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" #include "mpconfigboard.h" void board_init(void) diff --git a/ports/atmel-samd/boards/metro_m4_airlift_lite/board.c b/ports/atmel-samd/boards/metro_m4_airlift_lite/board.c index 0f60736a24..7af05ba45a 100644 --- a/ports/atmel-samd/boards/metro_m4_airlift_lite/board.c +++ b/ports/atmel-samd/boards/metro_m4_airlift_lite/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" #include "mpconfigboard.h" #include "hal/include/hal_gpio.h" diff --git a/ports/atmel-samd/boards/metro_m4_express/board.c b/ports/atmel-samd/boards/metro_m4_express/board.c index 0f60736a24..7af05ba45a 100644 --- a/ports/atmel-samd/boards/metro_m4_express/board.c +++ b/ports/atmel-samd/boards/metro_m4_express/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" #include "mpconfigboard.h" #include "hal/include/hal_gpio.h" diff --git a/ports/atmel-samd/boards/mini_sam_m4/board.c b/ports/atmel-samd/boards/mini_sam_m4/board.c index 0f60736a24..7af05ba45a 100644 --- a/ports/atmel-samd/boards/mini_sam_m4/board.c +++ b/ports/atmel-samd/boards/mini_sam_m4/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" #include "mpconfigboard.h" #include "hal/include/hal_gpio.h" diff --git a/ports/atmel-samd/boards/monster_m4sk/board.c b/ports/atmel-samd/boards/monster_m4sk/board.c index 45fea9d529..2b757d0914 100644 --- a/ports/atmel-samd/boards/monster_m4sk/board.c +++ b/ports/atmel-samd/boards/monster_m4sk/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" #include "mpconfigboard.h" #include "hal/include/hal_gpio.h" #include "shared-bindings/busio/SPI.h" diff --git a/ports/atmel-samd/boards/monster_m4sk/pins.c b/ports/atmel-samd/boards/monster_m4sk/pins.c index 7272b9ed86..c3eff7cc30 100644 --- a/ports/atmel-samd/boards/monster_m4sk/pins.c +++ b/ports/atmel-samd/boards/monster_m4sk/pins.c @@ -1,6 +1,6 @@ #include "shared-bindings/board/__init__.h" -#include "boards/board.h" +#include "supervisor/board.h" #include "shared-module/displayio/__init__.h" STATIC const mp_rom_map_elem_t board_global_dict_table[] = { diff --git a/ports/atmel-samd/boards/ndgarage_ndbit6/board.c b/ports/atmel-samd/boards/ndgarage_ndbit6/board.c index 0f60736a24..7af05ba45a 100644 --- a/ports/atmel-samd/boards/ndgarage_ndbit6/board.c +++ b/ports/atmel-samd/boards/ndgarage_ndbit6/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" #include "mpconfigboard.h" #include "hal/include/hal_gpio.h" diff --git a/ports/atmel-samd/boards/ndgarage_ndbit6_v2/board.c b/ports/atmel-samd/boards/ndgarage_ndbit6_v2/board.c index 0f60736a24..7af05ba45a 100644 --- a/ports/atmel-samd/boards/ndgarage_ndbit6_v2/board.c +++ b/ports/atmel-samd/boards/ndgarage_ndbit6_v2/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" #include "mpconfigboard.h" #include "hal/include/hal_gpio.h" diff --git a/ports/atmel-samd/boards/nfc_copy_cat/board.c b/ports/atmel-samd/boards/nfc_copy_cat/board.c index c8e20206a1..6baa43ffaa 100644 --- a/ports/atmel-samd/boards/nfc_copy_cat/board.c +++ b/ports/atmel-samd/boards/nfc_copy_cat/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" void board_init(void) { diff --git a/ports/atmel-samd/boards/openbook_m4/board.c b/ports/atmel-samd/boards/openbook_m4/board.c index 07dd1741ac..a110779a6a 100644 --- a/ports/atmel-samd/boards/openbook_m4/board.c +++ b/ports/atmel-samd/boards/openbook_m4/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" #include "mpconfigboard.h" #include "hal/include/hal_gpio.h" #include "shared-bindings/busio/SPI.h" diff --git a/ports/atmel-samd/boards/openbook_m4/pins.c b/ports/atmel-samd/boards/openbook_m4/pins.c index 47de3043d9..45a7bc1dd0 100644 --- a/ports/atmel-samd/boards/openbook_m4/pins.c +++ b/ports/atmel-samd/boards/openbook_m4/pins.c @@ -1,6 +1,6 @@ #include "shared-bindings/board/__init__.h" -#include "boards/board.h" +#include "supervisor/board.h" #include "shared-module/displayio/__init__.h" STATIC const mp_rom_map_elem_t board_global_dict_table[] = { diff --git a/ports/atmel-samd/boards/pewpew10/board.c b/ports/atmel-samd/boards/pewpew10/board.c index d7e856d611..84960e73cf 100644 --- a/ports/atmel-samd/boards/pewpew10/board.c +++ b/ports/atmel-samd/boards/pewpew10/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" void board_init(void) { } diff --git a/ports/atmel-samd/boards/pewpew_m4/board.c b/ports/atmel-samd/boards/pewpew_m4/board.c index d02e0dc01d..26bd53cad1 100644 --- a/ports/atmel-samd/boards/pewpew_m4/board.c +++ b/ports/atmel-samd/boards/pewpew_m4/board.c @@ -25,7 +25,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" #include "mpconfigboard.h" #include "hal/include/hal_gpio.h" #include "shared-bindings/busio/SPI.h" diff --git a/ports/atmel-samd/boards/picoplanet/board.c b/ports/atmel-samd/boards/picoplanet/board.c index d7e856d611..84960e73cf 100644 --- a/ports/atmel-samd/boards/picoplanet/board.c +++ b/ports/atmel-samd/boards/picoplanet/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" void board_init(void) { } diff --git a/ports/atmel-samd/boards/pirkey_m0/board.c b/ports/atmel-samd/boards/pirkey_m0/board.c index c8e20206a1..6baa43ffaa 100644 --- a/ports/atmel-samd/boards/pirkey_m0/board.c +++ b/ports/atmel-samd/boards/pirkey_m0/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" void board_init(void) { diff --git a/ports/atmel-samd/boards/pybadge/board.c b/ports/atmel-samd/boards/pybadge/board.c index 35f228c75a..188bf7bf6c 100644 --- a/ports/atmel-samd/boards/pybadge/board.c +++ b/ports/atmel-samd/boards/pybadge/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" #include "mpconfigboard.h" #include "hal/include/hal_gpio.h" #include "shared-bindings/busio/SPI.h" @@ -123,5 +123,5 @@ bool board_requests_safe_mode(void) { } void reset_board(void) { - board_reset_user_neopixels(); + board_reset_user_neopixels(&pin_PA15, 5); } diff --git a/ports/atmel-samd/boards/pybadge/pins.c b/ports/atmel-samd/boards/pybadge/pins.c index ca65d9df46..a1802bb071 100644 --- a/ports/atmel-samd/boards/pybadge/pins.c +++ b/ports/atmel-samd/boards/pybadge/pins.c @@ -1,6 +1,6 @@ #include "shared-bindings/board/__init__.h" -#include "boards/board.h" +#include "supervisor/board.h" #include "shared-module/displayio/__init__.h" STATIC const mp_rom_map_elem_t board_global_dict_table[] = { diff --git a/ports/atmel-samd/boards/pybadge_airlift/board.c b/ports/atmel-samd/boards/pybadge_airlift/board.c index fe3e4a0171..de7eeda096 100644 --- a/ports/atmel-samd/boards/pybadge_airlift/board.c +++ b/ports/atmel-samd/boards/pybadge_airlift/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" #include "mpconfigboard.h" #include "hal/include/hal_gpio.h" #include "shared-bindings/busio/SPI.h" @@ -101,5 +101,5 @@ bool board_requests_safe_mode(void) { } void reset_board(void) { - board_reset_user_neopixels(); + board_reset_user_neopixels(&pin_PA15, 5); } diff --git a/ports/atmel-samd/boards/pybadge_airlift/pins.c b/ports/atmel-samd/boards/pybadge_airlift/pins.c index 9ee579be14..cdf8071da8 100644 --- a/ports/atmel-samd/boards/pybadge_airlift/pins.c +++ b/ports/atmel-samd/boards/pybadge_airlift/pins.c @@ -1,6 +1,6 @@ #include "shared-bindings/board/__init__.h" -#include "boards/board.h" +#include "supervisor/board.h" #include "shared-module/displayio/__init__.h" STATIC const mp_rom_map_elem_t board_global_dict_table[] = { diff --git a/ports/atmel-samd/boards/pycubed/board.c b/ports/atmel-samd/boards/pycubed/board.c index 0bf586ad8e..f092a8d20e 100644 --- a/ports/atmel-samd/boards/pycubed/board.c +++ b/ports/atmel-samd/boards/pycubed/board.c @@ -27,7 +27,7 @@ #include -#include "boards/board.h" +#include "supervisor/board.h" #include "py/mpconfig.h" #include "shared-bindings/nvm/ByteArray.h" #include "common-hal/microcontroller/Pin.h" diff --git a/ports/atmel-samd/boards/pycubed/pins.c b/ports/atmel-samd/boards/pycubed/pins.c index e494fb54bf..93f349ffa4 100644 --- a/ports/atmel-samd/boards/pycubed/pins.c +++ b/ports/atmel-samd/boards/pycubed/pins.c @@ -1,5 +1,5 @@ #include "shared-bindings/board/__init__.h" -#include "boards/board.h" +#include "supervisor/board.h" STATIC const mp_rom_map_elem_t board_global_dict_table[] = { { MP_ROM_QSTR(MP_QSTR_SCK), MP_ROM_PTR(&pin_PA13) }, diff --git a/ports/atmel-samd/boards/pycubed_mram/board.c b/ports/atmel-samd/boards/pycubed_mram/board.c index 0bf586ad8e..f092a8d20e 100644 --- a/ports/atmel-samd/boards/pycubed_mram/board.c +++ b/ports/atmel-samd/boards/pycubed_mram/board.c @@ -27,7 +27,7 @@ #include -#include "boards/board.h" +#include "supervisor/board.h" #include "py/mpconfig.h" #include "shared-bindings/nvm/ByteArray.h" #include "common-hal/microcontroller/Pin.h" diff --git a/ports/atmel-samd/boards/pycubed_mram/pins.c b/ports/atmel-samd/boards/pycubed_mram/pins.c index e494fb54bf..93f349ffa4 100644 --- a/ports/atmel-samd/boards/pycubed_mram/pins.c +++ b/ports/atmel-samd/boards/pycubed_mram/pins.c @@ -1,5 +1,5 @@ #include "shared-bindings/board/__init__.h" -#include "boards/board.h" +#include "supervisor/board.h" STATIC const mp_rom_map_elem_t board_global_dict_table[] = { { MP_ROM_QSTR(MP_QSTR_SCK), MP_ROM_PTR(&pin_PA13) }, diff --git a/ports/atmel-samd/boards/pygamer/board.c b/ports/atmel-samd/boards/pygamer/board.c index b478b5947c..4614e347cd 100644 --- a/ports/atmel-samd/boards/pygamer/board.c +++ b/ports/atmel-samd/boards/pygamer/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" #include "mpconfigboard.h" #include "hal/include/hal_gpio.h" #include "shared-bindings/busio/SPI.h" @@ -123,5 +123,5 @@ bool board_requests_safe_mode(void) { } void reset_board(void) { - board_reset_user_neopixels(); + board_reset_user_neopixels(&pin_PA15, 5); } diff --git a/ports/atmel-samd/boards/pygamer/pins.c b/ports/atmel-samd/boards/pygamer/pins.c index 107d780a8a..8bfaa64792 100644 --- a/ports/atmel-samd/boards/pygamer/pins.c +++ b/ports/atmel-samd/boards/pygamer/pins.c @@ -1,6 +1,6 @@ #include "shared-bindings/board/__init__.h" -#include "boards/board.h" +#include "supervisor/board.h" #include "shared-module/displayio/__init__.h" STATIC const mp_rom_map_elem_t board_global_dict_table[] = { diff --git a/ports/atmel-samd/boards/pygamer_advance/board.c b/ports/atmel-samd/boards/pygamer_advance/board.c index 7dfe07c00d..39bf65602e 100644 --- a/ports/atmel-samd/boards/pygamer_advance/board.c +++ b/ports/atmel-samd/boards/pygamer_advance/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" #include "mpconfigboard.h" #include "hal/include/hal_gpio.h" #include "shared-bindings/busio/SPI.h" @@ -101,5 +101,5 @@ bool board_requests_safe_mode(void) { } void reset_board(void) { - board_reset_user_neopixels(); + board_reset_user_neopixels(&pin_PA15, 5); } diff --git a/ports/atmel-samd/boards/pygamer_advance/pins.c b/ports/atmel-samd/boards/pygamer_advance/pins.c index 653a1bb2ef..8db63f2f0c 100644 --- a/ports/atmel-samd/boards/pygamer_advance/pins.c +++ b/ports/atmel-samd/boards/pygamer_advance/pins.c @@ -1,6 +1,6 @@ #include "shared-bindings/board/__init__.h" -#include "boards/board.h" +#include "supervisor/board.h" #include "shared-module/displayio/__init__.h" STATIC const mp_rom_map_elem_t board_global_dict_table[] = { diff --git a/ports/atmel-samd/boards/pyportal/board.c b/ports/atmel-samd/boards/pyportal/board.c index cd94f68875..db474a8209 100644 --- a/ports/atmel-samd/boards/pyportal/board.c +++ b/ports/atmel-samd/boards/pyportal/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" #include "mpconfigboard.h" #include "hal/include/hal_gpio.h" diff --git a/ports/atmel-samd/boards/pyportal/pins.c b/ports/atmel-samd/boards/pyportal/pins.c index 461ee98da5..1a18464922 100644 --- a/ports/atmel-samd/boards/pyportal/pins.c +++ b/ports/atmel-samd/boards/pyportal/pins.c @@ -1,6 +1,6 @@ #include "shared-bindings/board/__init__.h" -#include "boards/board.h" +#include "supervisor/board.h" #include "shared-module/displayio/__init__.h" // This mapping only includes functional names because pins broken diff --git a/ports/atmel-samd/boards/pyportal_titano/board.c b/ports/atmel-samd/boards/pyportal_titano/board.c index dc417f5d14..59a25c4acf 100644 --- a/ports/atmel-samd/boards/pyportal_titano/board.c +++ b/ports/atmel-samd/boards/pyportal_titano/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" #include "mpconfigboard.h" #include "hal/include/hal_gpio.h" diff --git a/ports/atmel-samd/boards/pyportal_titano/pins.c b/ports/atmel-samd/boards/pyportal_titano/pins.c index 461ee98da5..1a18464922 100644 --- a/ports/atmel-samd/boards/pyportal_titano/pins.c +++ b/ports/atmel-samd/boards/pyportal_titano/pins.c @@ -1,6 +1,6 @@ #include "shared-bindings/board/__init__.h" -#include "boards/board.h" +#include "supervisor/board.h" #include "shared-module/displayio/__init__.h" // This mapping only includes functional names because pins broken diff --git a/ports/atmel-samd/boards/pyruler/board.c b/ports/atmel-samd/boards/pyruler/board.c index d7e856d611..84960e73cf 100644 --- a/ports/atmel-samd/boards/pyruler/board.c +++ b/ports/atmel-samd/boards/pyruler/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" void board_init(void) { } diff --git a/ports/atmel-samd/boards/qtpy_m0/board.c b/ports/atmel-samd/boards/qtpy_m0/board.c index 1a65a561f7..6b948a9a7a 100644 --- a/ports/atmel-samd/boards/qtpy_m0/board.c +++ b/ports/atmel-samd/boards/qtpy_m0/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" #include "common-hal/microcontroller/Pin.h" #include "supervisor/shared/board.h" #include "hal/include/hal_gpio.h" diff --git a/ports/atmel-samd/boards/qtpy_m0_haxpress/board.c b/ports/atmel-samd/boards/qtpy_m0_haxpress/board.c index 1a65a561f7..6b948a9a7a 100644 --- a/ports/atmel-samd/boards/qtpy_m0_haxpress/board.c +++ b/ports/atmel-samd/boards/qtpy_m0_haxpress/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" #include "common-hal/microcontroller/Pin.h" #include "supervisor/shared/board.h" #include "hal/include/hal_gpio.h" diff --git a/ports/atmel-samd/boards/robohatmm1_m4/board.c b/ports/atmel-samd/boards/robohatmm1_m4/board.c index 0f60736a24..7af05ba45a 100644 --- a/ports/atmel-samd/boards/robohatmm1_m4/board.c +++ b/ports/atmel-samd/boards/robohatmm1_m4/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" #include "mpconfigboard.h" #include "hal/include/hal_gpio.h" diff --git a/ports/atmel-samd/boards/sam32/board.c b/ports/atmel-samd/boards/sam32/board.c index e032601440..560edd9c2c 100644 --- a/ports/atmel-samd/boards/sam32/board.c +++ b/ports/atmel-samd/boards/sam32/board.c @@ -27,7 +27,7 @@ #include -#include "boards/board.h" +#include "supervisor/board.h" #include "py/mpconfig.h" #include "common-hal/digitalio/DigitalInOut.h" diff --git a/ports/atmel-samd/boards/same54_xplained/board.c b/ports/atmel-samd/boards/same54_xplained/board.c index 7599f02b8e..5ed8c84049 100644 --- a/ports/atmel-samd/boards/same54_xplained/board.c +++ b/ports/atmel-samd/boards/same54_xplained/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" #include "mpconfigboard.h" #include "hal/include/hal_gpio.h" diff --git a/ports/atmel-samd/boards/seeeduino_wio_terminal/board.c b/ports/atmel-samd/boards/seeeduino_wio_terminal/board.c index 49db498608..53c43cd441 100644 --- a/ports/atmel-samd/boards/seeeduino_wio_terminal/board.c +++ b/ports/atmel-samd/boards/seeeduino_wio_terminal/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" #include "mpconfigboard.h" #include "hal/include/hal_gpio.h" #include "shared-bindings/busio/SPI.h" diff --git a/ports/atmel-samd/boards/seeeduino_xiao/board.c b/ports/atmel-samd/boards/seeeduino_xiao/board.c index 0f60736a24..7af05ba45a 100644 --- a/ports/atmel-samd/boards/seeeduino_xiao/board.c +++ b/ports/atmel-samd/boards/seeeduino_xiao/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" #include "mpconfigboard.h" #include "hal/include/hal_gpio.h" diff --git a/ports/atmel-samd/boards/serpente/board.c b/ports/atmel-samd/boards/serpente/board.c index d7e856d611..84960e73cf 100644 --- a/ports/atmel-samd/boards/serpente/board.c +++ b/ports/atmel-samd/boards/serpente/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" void board_init(void) { } diff --git a/ports/atmel-samd/boards/shirtty/board.c b/ports/atmel-samd/boards/shirtty/board.c index d7e856d611..84960e73cf 100644 --- a/ports/atmel-samd/boards/shirtty/board.c +++ b/ports/atmel-samd/boards/shirtty/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" void board_init(void) { } diff --git a/ports/atmel-samd/boards/snekboard/board.c b/ports/atmel-samd/boards/snekboard/board.c index c8e20206a1..6baa43ffaa 100644 --- a/ports/atmel-samd/boards/snekboard/board.c +++ b/ports/atmel-samd/boards/snekboard/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" void board_init(void) { diff --git a/ports/atmel-samd/boards/sparkfun_lumidrive/board.c b/ports/atmel-samd/boards/sparkfun_lumidrive/board.c index c8e20206a1..6baa43ffaa 100755 --- a/ports/atmel-samd/boards/sparkfun_lumidrive/board.c +++ b/ports/atmel-samd/boards/sparkfun_lumidrive/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" void board_init(void) { diff --git a/ports/atmel-samd/boards/sparkfun_qwiic_micro_no_flash/board.c b/ports/atmel-samd/boards/sparkfun_qwiic_micro_no_flash/board.c index c8e20206a1..6baa43ffaa 100644 --- a/ports/atmel-samd/boards/sparkfun_qwiic_micro_no_flash/board.c +++ b/ports/atmel-samd/boards/sparkfun_qwiic_micro_no_flash/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" void board_init(void) { diff --git a/ports/atmel-samd/boards/sparkfun_qwiic_micro_with_flash/board.c b/ports/atmel-samd/boards/sparkfun_qwiic_micro_with_flash/board.c index c8e20206a1..6baa43ffaa 100644 --- a/ports/atmel-samd/boards/sparkfun_qwiic_micro_with_flash/board.c +++ b/ports/atmel-samd/boards/sparkfun_qwiic_micro_with_flash/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" void board_init(void) { diff --git a/ports/atmel-samd/boards/sparkfun_redboard_turbo/board.c b/ports/atmel-samd/boards/sparkfun_redboard_turbo/board.c index c8e20206a1..6baa43ffaa 100755 --- a/ports/atmel-samd/boards/sparkfun_redboard_turbo/board.c +++ b/ports/atmel-samd/boards/sparkfun_redboard_turbo/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" void board_init(void) { diff --git a/ports/atmel-samd/boards/sparkfun_samd21_dev/board.c b/ports/atmel-samd/boards/sparkfun_samd21_dev/board.c index 0f60736a24..7af05ba45a 100644 --- a/ports/atmel-samd/boards/sparkfun_samd21_dev/board.c +++ b/ports/atmel-samd/boards/sparkfun_samd21_dev/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" #include "mpconfigboard.h" #include "hal/include/hal_gpio.h" diff --git a/ports/atmel-samd/boards/sparkfun_samd21_mini/board.c b/ports/atmel-samd/boards/sparkfun_samd21_mini/board.c index 0f60736a24..7af05ba45a 100644 --- a/ports/atmel-samd/boards/sparkfun_samd21_mini/board.c +++ b/ports/atmel-samd/boards/sparkfun_samd21_mini/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" #include "mpconfigboard.h" #include "hal/include/hal_gpio.h" diff --git a/ports/atmel-samd/boards/sparkfun_samd51_thing_plus/board.c b/ports/atmel-samd/boards/sparkfun_samd51_thing_plus/board.c index 8096b9b8ea..5fca974e9e 100644 --- a/ports/atmel-samd/boards/sparkfun_samd51_thing_plus/board.c +++ b/ports/atmel-samd/boards/sparkfun_samd51_thing_plus/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" #include "mpconfigboard.h" void board_init(void) { diff --git a/ports/atmel-samd/boards/stringcar_m0_express/board.c b/ports/atmel-samd/boards/stringcar_m0_express/board.c index d7e856d611..84960e73cf 100644 --- a/ports/atmel-samd/boards/stringcar_m0_express/board.c +++ b/ports/atmel-samd/boards/stringcar_m0_express/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" void board_init(void) { } diff --git a/ports/atmel-samd/boards/trellis_m4_express/board.c b/ports/atmel-samd/boards/trellis_m4_express/board.c index a9b5f81631..e6f8b59179 100644 --- a/ports/atmel-samd/boards/trellis_m4_express/board.c +++ b/ports/atmel-samd/boards/trellis_m4_express/board.c @@ -26,7 +26,7 @@ #include -#include "boards/board.h" +#include "supervisor/board.h" #include "py/mpconfig.h" #include "common-hal/digitalio/DigitalInOut.h" diff --git a/ports/atmel-samd/boards/trinket_m0/board.c b/ports/atmel-samd/boards/trinket_m0/board.c index d7e856d611..84960e73cf 100644 --- a/ports/atmel-samd/boards/trinket_m0/board.c +++ b/ports/atmel-samd/boards/trinket_m0/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" void board_init(void) { } diff --git a/ports/atmel-samd/boards/trinket_m0_haxpress/board.c b/ports/atmel-samd/boards/trinket_m0_haxpress/board.c index d7e856d611..84960e73cf 100644 --- a/ports/atmel-samd/boards/trinket_m0_haxpress/board.c +++ b/ports/atmel-samd/boards/trinket_m0_haxpress/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" void board_init(void) { } diff --git a/ports/atmel-samd/boards/uartlogger2/board.c b/ports/atmel-samd/boards/uartlogger2/board.c index 0f60736a24..7af05ba45a 100644 --- a/ports/atmel-samd/boards/uartlogger2/board.c +++ b/ports/atmel-samd/boards/uartlogger2/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" #include "mpconfigboard.h" #include "hal/include/hal_gpio.h" diff --git a/ports/atmel-samd/boards/uchip/board.c b/ports/atmel-samd/boards/uchip/board.c index 0f60736a24..7af05ba45a 100644 --- a/ports/atmel-samd/boards/uchip/board.c +++ b/ports/atmel-samd/boards/uchip/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" #include "mpconfigboard.h" #include "hal/include/hal_gpio.h" diff --git a/ports/atmel-samd/boards/ugame10/board.c b/ports/atmel-samd/boards/ugame10/board.c index 9f2b8d039d..918fe2d59d 100644 --- a/ports/atmel-samd/boards/ugame10/board.c +++ b/ports/atmel-samd/boards/ugame10/board.c @@ -25,7 +25,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" #include "shared-bindings/board/__init__.h" #include "shared-bindings/displayio/FourWire.h" diff --git a/ports/atmel-samd/boards/winterbloom_big_honking_button/board.c b/ports/atmel-samd/boards/winterbloom_big_honking_button/board.c index c8e20206a1..6baa43ffaa 100644 --- a/ports/atmel-samd/boards/winterbloom_big_honking_button/board.c +++ b/ports/atmel-samd/boards/winterbloom_big_honking_button/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" void board_init(void) { diff --git a/ports/atmel-samd/boards/winterbloom_sol/board.c b/ports/atmel-samd/boards/winterbloom_sol/board.c index 8096b9b8ea..5fca974e9e 100644 --- a/ports/atmel-samd/boards/winterbloom_sol/board.c +++ b/ports/atmel-samd/boards/winterbloom_sol/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" #include "mpconfigboard.h" void board_init(void) { diff --git a/ports/atmel-samd/boards/xinabox_cc03/board.c b/ports/atmel-samd/boards/xinabox_cc03/board.c index 770bc82593..112b173ecc 100644 --- a/ports/atmel-samd/boards/xinabox_cc03/board.c +++ b/ports/atmel-samd/boards/xinabox_cc03/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" #include "mpconfigboard.h" #include "hal/include/hal_gpio.h" diff --git a/ports/atmel-samd/boards/xinabox_cs11/board.c b/ports/atmel-samd/boards/xinabox_cs11/board.c index 770bc82593..112b173ecc 100644 --- a/ports/atmel-samd/boards/xinabox_cs11/board.c +++ b/ports/atmel-samd/boards/xinabox_cs11/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" #include "mpconfigboard.h" #include "hal/include/hal_gpio.h" diff --git a/ports/atmel-samd/common-hal/busio/SPI.c b/ports/atmel-samd/common-hal/busio/SPI.c index 189fd93b54..9646f9cf1e 100644 --- a/ports/atmel-samd/common-hal/busio/SPI.c +++ b/ports/atmel-samd/common-hal/busio/SPI.c @@ -31,7 +31,7 @@ #include "hpl_sercom_config.h" #include "peripheral_clk_config.h" -#include "boards/board.h" +#include "supervisor/board.h" #include "common-hal/microcontroller/Pin.h" #include "hal/include/hal_gpio.h" #include "hal/include/hal_spi_m_sync.h" diff --git a/ports/atmel-samd/common-hal/sdioio/SDCard.c b/ports/atmel-samd/common-hal/sdioio/SDCard.c index 4d2539aa5a..14c6f29de1 100644 --- a/ports/atmel-samd/common-hal/sdioio/SDCard.c +++ b/ports/atmel-samd/common-hal/sdioio/SDCard.c @@ -28,7 +28,6 @@ #include "py/mperrno.h" #include "py/runtime.h" -#include "boards/board.h" #include "common-hal/microcontroller/Pin.h" #include "shared-bindings/sdioio/SDCard.h" #include "shared-bindings/microcontroller/Pin.h" diff --git a/ports/atmel-samd/supervisor/port.c b/ports/atmel-samd/supervisor/port.c index fc1d1198e2..7d02789e82 100644 --- a/ports/atmel-samd/supervisor/port.c +++ b/ports/atmel-samd/supervisor/port.c @@ -27,7 +27,7 @@ #include #include -#include "boards/board.h" +#include "supervisor/board.h" #include "supervisor/port.h" // ASF 4 @@ -543,7 +543,7 @@ void port_interrupt_after_ticks(uint32_t ticks) { _port_interrupt_after_ticks(ticks); } -void port_sleep_until_interrupt(void) { +void port_idle_until_interrupt(void) { #ifdef SAM_D5X_E5X // Clear the FPU interrupt because it can prevent us from sleeping. if (__get_FPSCR() & ~(0x9f)) { diff --git a/ports/cxd56/boards/board.h b/ports/cxd56/boards/board.h deleted file mode 100644 index 597ae72e6a..0000000000 --- a/ports/cxd56/boards/board.h +++ /dev/null @@ -1,45 +0,0 @@ -/* - * This file is part of the MicroPython project, http://micropython.org/ - * - * The MIT License (MIT) - * - * Copyright 2019 Sony Semiconductor Solutions Corporation - * - * 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_CXD56_BOARDS_BOARD_H -#define MICROPY_INCLUDED_CXD56_BOARDS_BOARD_H - -#include - -// 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_CXD56_BOARDS_BOARD_H diff --git a/ports/cxd56/boards/spresense/board.c b/ports/cxd56/boards/spresense/board.c index 2af7cfdcf2..fd27d3493a 100644 --- a/ports/cxd56/boards/spresense/board.c +++ b/ports/cxd56/boards/spresense/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" void board_init(void) { diff --git a/ports/cxd56/supervisor/port.c b/ports/cxd56/supervisor/port.c index d69f357799..523d6a496b 100644 --- a/ports/cxd56/supervisor/port.c +++ b/ports/cxd56/supervisor/port.c @@ -33,7 +33,7 @@ #include "sched/sched.h" -#include "boards/board.h" +#include "supervisor/board.h" #include "supervisor/port.h" #include "supervisor/background_callback.h" @@ -169,6 +169,6 @@ void port_disable_tick(void) { void port_interrupt_after_ticks(uint32_t ticks) { } -void port_sleep_until_interrupt(void) { +void port_idle_until_interrupt(void) { // TODO: Implement sleep. } diff --git a/ports/esp32s2/boards/adafruit_magtag_2.9_grayscale/board.c b/ports/esp32s2/boards/adafruit_magtag_2.9_grayscale/board.c index ecd44e423c..a9d1074f72 100644 --- a/ports/esp32s2/boards/adafruit_magtag_2.9_grayscale/board.c +++ b/ports/esp32s2/boards/adafruit_magtag_2.9_grayscale/board.c @@ -24,7 +24,8 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" + #include "mpconfigboard.h" #include "shared-bindings/busio/SPI.h" #include "shared-bindings/displayio/FourWire.h" @@ -32,6 +33,10 @@ #include "shared-module/displayio/__init__.h" #include "supervisor/shared/board.h" +#include "components/log/include/esp_log.h" + +static const char* TAG = "board"; + #define DELAY 0x80 // This is an ILO373 control chip. The display is a 2.9" grayscale EInk. @@ -167,3 +172,18 @@ bool board_requests_safe_mode(void) { void reset_board(void) { } + +void board_deinit(void) { + displayio_epaperdisplay_obj_t* display = &displays[0].epaper_display; + if (display->base.type == &displayio_epaperdisplay_type) { + size_t i = 0; + while (common_hal_displayio_epaperdisplay_get_busy(display)) { + RUN_BACKGROUND_TASKS; + i++; + } + ESP_LOGI(TAG, "waited %d iterations for display", i); + } else { + ESP_LOGI(TAG, "didn't wait for display"); + } + common_hal_displayio_release_displays(); +} diff --git a/ports/esp32s2/boards/adafruit_metro_esp32s2/board.c b/ports/esp32s2/boards/adafruit_metro_esp32s2/board.c index 7380be6da6..5abd1ce1b3 100644 --- a/ports/esp32s2/boards/adafruit_metro_esp32s2/board.c +++ b/ports/esp32s2/boards/adafruit_metro_esp32s2/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" #include "mpconfigboard.h" #include "shared-bindings/microcontroller/Pin.h" @@ -41,3 +41,6 @@ bool board_requests_safe_mode(void) { void reset_board(void) { } + +void board_deinit(void) { +} diff --git a/ports/esp32s2/boards/electroniccats_bastwifi/board.c b/ports/esp32s2/boards/electroniccats_bastwifi/board.c index 9f708874bf..ff5d9cfb6c 100644 --- a/ports/esp32s2/boards/electroniccats_bastwifi/board.c +++ b/ports/esp32s2/boards/electroniccats_bastwifi/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" #include "mpconfigboard.h" #include "shared-bindings/microcontroller/Pin.h" @@ -45,3 +45,6 @@ bool board_requests_safe_mode(void) { void reset_board(void) { } + +void board_deinit(void) { +} diff --git a/ports/esp32s2/boards/espressif_kaluga_1/board.c b/ports/esp32s2/boards/espressif_kaluga_1/board.c index 9f708874bf..ff5d9cfb6c 100644 --- a/ports/esp32s2/boards/espressif_kaluga_1/board.c +++ b/ports/esp32s2/boards/espressif_kaluga_1/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" #include "mpconfigboard.h" #include "shared-bindings/microcontroller/Pin.h" @@ -45,3 +45,6 @@ bool board_requests_safe_mode(void) { void reset_board(void) { } + +void board_deinit(void) { +} diff --git a/ports/esp32s2/boards/espressif_saola_1_wroom/board.c b/ports/esp32s2/boards/espressif_saola_1_wroom/board.c index 9f708874bf..ff5d9cfb6c 100644 --- a/ports/esp32s2/boards/espressif_saola_1_wroom/board.c +++ b/ports/esp32s2/boards/espressif_saola_1_wroom/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" #include "mpconfigboard.h" #include "shared-bindings/microcontroller/Pin.h" @@ -45,3 +45,6 @@ bool board_requests_safe_mode(void) { void reset_board(void) { } + +void board_deinit(void) { +} diff --git a/ports/esp32s2/boards/espressif_saola_1_wrover/board.c b/ports/esp32s2/boards/espressif_saola_1_wrover/board.c index 9f708874bf..ff5d9cfb6c 100644 --- a/ports/esp32s2/boards/espressif_saola_1_wrover/board.c +++ b/ports/esp32s2/boards/espressif_saola_1_wrover/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" #include "mpconfigboard.h" #include "shared-bindings/microcontroller/Pin.h" @@ -45,3 +45,6 @@ bool board_requests_safe_mode(void) { void reset_board(void) { } + +void board_deinit(void) { +} diff --git a/ports/esp32s2/boards/microdev_micro_s2/board.c b/ports/esp32s2/boards/microdev_micro_s2/board.c index 1dc30b5af8..abd22091ee 100644 --- a/ports/esp32s2/boards/microdev_micro_s2/board.c +++ b/ports/esp32s2/boards/microdev_micro_s2/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" #include "mpconfigboard.h" #include "shared-bindings/microcontroller/Pin.h" @@ -54,3 +54,6 @@ bool board_requests_safe_mode(void) { void reset_board(void) { } + +void board_deinit(void) { +} diff --git a/ports/esp32s2/boards/muselab_nanoesp32_s2/board.c b/ports/esp32s2/boards/muselab_nanoesp32_s2/board.c index 9f708874bf..ff5d9cfb6c 100644 --- a/ports/esp32s2/boards/muselab_nanoesp32_s2/board.c +++ b/ports/esp32s2/boards/muselab_nanoesp32_s2/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" #include "mpconfigboard.h" #include "shared-bindings/microcontroller/Pin.h" @@ -45,3 +45,6 @@ bool board_requests_safe_mode(void) { void reset_board(void) { } + +void board_deinit(void) { +} diff --git a/ports/esp32s2/boards/targett_module_clip_wroom/board.c b/ports/esp32s2/boards/targett_module_clip_wroom/board.c index 7f5de0e0dd..c2022d292e 100644 --- a/ports/esp32s2/boards/targett_module_clip_wroom/board.c +++ b/ports/esp32s2/boards/targett_module_clip_wroom/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" #include "mpconfigboard.h" #include "shared-bindings/microcontroller/Pin.h" @@ -49,3 +49,6 @@ bool board_requests_safe_mode(void) { void reset_board(void) { } + +void board_deinit(void) { +} diff --git a/ports/esp32s2/boards/targett_module_clip_wrover/board.c b/ports/esp32s2/boards/targett_module_clip_wrover/board.c index 83dcb920a8..5a9fbcbee7 100644 --- a/ports/esp32s2/boards/targett_module_clip_wrover/board.c +++ b/ports/esp32s2/boards/targett_module_clip_wrover/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" #include "mpconfigboard.h" #include "shared-bindings/microcontroller/Pin.h" @@ -49,3 +49,6 @@ bool board_requests_safe_mode(void) { void reset_board(void) { } + +void board_deinit(void) { +} diff --git a/ports/esp32s2/boards/unexpectedmaker_feathers2/board.c b/ports/esp32s2/boards/unexpectedmaker_feathers2/board.c index 1dc30b5af8..abd22091ee 100644 --- a/ports/esp32s2/boards/unexpectedmaker_feathers2/board.c +++ b/ports/esp32s2/boards/unexpectedmaker_feathers2/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" #include "mpconfigboard.h" #include "shared-bindings/microcontroller/Pin.h" @@ -54,3 +54,6 @@ bool board_requests_safe_mode(void) { void reset_board(void) { } + +void board_deinit(void) { +} diff --git a/ports/esp32s2/boards/unexpectedmaker_feathers2_prerelease/board.c b/ports/esp32s2/boards/unexpectedmaker_feathers2_prerelease/board.c index 1dc30b5af8..abd22091ee 100644 --- a/ports/esp32s2/boards/unexpectedmaker_feathers2_prerelease/board.c +++ b/ports/esp32s2/boards/unexpectedmaker_feathers2_prerelease/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" #include "mpconfigboard.h" #include "shared-bindings/microcontroller/Pin.h" @@ -54,3 +54,6 @@ bool board_requests_safe_mode(void) { void reset_board(void) { } + +void board_deinit(void) { +} diff --git a/ports/esp32s2/common-hal/alarm/__init__.c b/ports/esp32s2/common-hal/alarm/__init__.c index 11e173fe2e..529179200d 100644 --- a/ports/esp32s2/common-hal/alarm/__init__.c +++ b/ports/esp32s2/common-hal/alarm/__init__.c @@ -32,38 +32,41 @@ #include "shared-bindings/alarm/pin/PinAlarm.h" #include "shared-bindings/alarm/time/TimeAlarm.h" #include "shared-bindings/microcontroller/__init__.h" -#include "shared-bindings/time/__init__.h" #include "shared-bindings/wifi/__init__.h" +#include "supervisor/port.h" +#include "supervisor/shared/workflow.h" + #include "common-hal/alarm/__init__.h" -#include "esp_log.h" #include "esp_sleep.h" -STATIC mp_obj_tuple_t *_deep_sleep_alarms; - void alarm_reset(void) { - _deep_sleep_alarms = mp_const_empty_tuple; -} - -void common_hal_alarm_disable_all(void) { + alarm_time_timealarm_reset(); esp_sleep_disable_wakeup_source(ESP_SLEEP_WAKEUP_ALL); } -mp_obj_t common_hal_alarm_get_wake_alarm(void) { - switch (esp_sleep_get_wakeup_cause()) { +STATIC esp_sleep_wakeup_cause_t _get_wakeup_cause(void) { + if (alarm_time_timealarm_woke_us_up()) { + return ESP_SLEEP_WAKEUP_TIMER; + } + + return esp_sleep_get_wakeup_cause(); +} + +bool alarm_woken_from_sleep(void) { + return _get_wakeup_cause() != ESP_SLEEP_WAKEUP_UNDEFINED; +} + +STATIC mp_obj_t _get_wake_alarm(size_t n_alarms, const mp_obj_t *alarms) { + switch (_get_wakeup_cause()) { case ESP_SLEEP_WAKEUP_TIMER: { - // Wake up from timer. - alarm_time_time_alarm_obj_t *timer = m_new_obj(alarm_time_time_alarm_obj_t); - timer->base.type = &alarm_time_time_alarm_type; - return timer; + return alarm_time_timealarm_get_wakeup_alarm(n_alarms, alarms); } case ESP_SLEEP_WAKEUP_EXT0: { - // Wake up from GPIO - alarm_pin_pin_alarm_obj_t *ext0 = m_new_obj(alarm_pin_pin_alarm_obj_t); - ext0->base.type = &alarm_pin_pin_alarm_type; - return ext0; + // TODO: implement pin alarm wake. + break; } case ESP_SLEEP_WAKEUP_TOUCHPAD: @@ -79,16 +82,19 @@ mp_obj_t common_hal_alarm_get_wake_alarm(void) { return mp_const_none; } +mp_obj_t common_hal_alarm_get_wake_alarm(void) { + return _get_wake_alarm(0, NULL); +} + // Set up light sleep or deep sleep alarms. -STATIC void setup_sleep_alarms(size_t n_alarms, const mp_obj_t *alarms) { +STATIC void _setup_sleep_alarms(bool deep_sleep, size_t n_alarms, const mp_obj_t *alarms) { bool time_alarm_set = false; alarm_time_time_alarm_obj_t *time_alarm = MP_OBJ_NULL; for (size_t i = 0; i < n_alarms; i++) { if (MP_OBJ_IS_TYPE(alarms[i], &alarm_pin_pin_alarm_type)) { mp_raise_NotImplementedError(translate("PinAlarm not yet implemented")); - } - else if (MP_OBJ_IS_TYPE(alarms[i], &alarm_time_time_alarm_type)) { + } else if (MP_OBJ_IS_TYPE(alarms[i], &alarm_time_time_alarm_type)) { if (time_alarm_set) { mp_raise_ValueError(translate("Only one alarm.time alarm can be set.")); } @@ -97,102 +103,50 @@ STATIC void setup_sleep_alarms(size_t n_alarms, const mp_obj_t *alarms) { } } - if (time_alarm != MP_OBJ_NULL) { - // Compute how long to actually sleep, considering the time now. - mp_float_t now_secs = uint64_to_float(common_hal_time_monotonic_ms()) / 1000.0f; - mp_float_t wakeup_in_secs = MAX(0.0f, time_alarm->monotonic_time - now_secs); - const uint64_t sleep_for_us = (uint64_t) (wakeup_in_secs * 1000000); - ESP_LOGI("ALARM", "will sleep for us: %lld", sleep_for_us); - esp_sleep_enable_timer_wakeup(sleep_for_us); + if (time_alarm_set) { + alarm_time_timealarm_set_alarm(time_alarm); } } -mp_obj_t common_hal_alarm_wait_until_alarms(size_t n_alarms, const mp_obj_t *alarms) { - if (n_alarms == 0) { - return mp_const_none; - } - - bool time_alarm_set = false; - alarm_time_time_alarm_obj_t *time_alarm = MP_OBJ_NULL; - - for (size_t i = 0; i < n_alarms; i++) { - if (MP_OBJ_IS_TYPE(alarms[i], &alarm_pin_pin_alarm_type)) { - mp_raise_NotImplementedError(translate("PinAlarm not yet implemented")); - } - else if (MP_OBJ_IS_TYPE(alarms[i], &alarm_time_time_alarm_type)) { - if (time_alarm_set) { - mp_raise_ValueError(translate("Only one alarm.time alarm can be set.")); - } - time_alarm = MP_OBJ_TO_PTR(alarms[i]); - time_alarm_set = true; +STATIC void _idle_until_alarm(void) { + // Poll for alarms. + while (!mp_hal_is_interrupted()) { + RUN_BACKGROUND_TASKS; + // Allow ctrl-C interrupt. + if (alarm_woken_from_sleep()) { + return; } + + port_idle_until_interrupt(); } - - ESP_LOGI("ALARM", "waiting for alarms"); - - if (time_alarm_set && n_alarms == 1) { - // If we're only checking time, avoid a polling loop, so maybe we can save some power. - const mp_float_t now_secs = uint64_to_float(common_hal_time_monotonic_ms()) / 1000.0f; - const mp_float_t wakeup_in_secs = MAX(0.0f, time_alarm->monotonic_time - now_secs); - const uint32_t delay_ms = (uint32_t) (wakeup_in_secs * 1000.0f); - ESP_LOGI("ALARM", "Delay for ms: %d", delay_ms); - common_hal_time_delay_ms((uint32_t) delay_ms); - } else { - // Poll for alarms. - while (true) { - RUN_BACKGROUND_TASKS; - // Allow ctrl-C interrupt. - if (mp_hal_is_interrupted()) { - return mp_const_none; - } - - // TODO: Check PinAlarms. - - if (time_alarm != MP_OBJ_NULL && - common_hal_time_monotonic_ms() * 1000.f >= time_alarm->monotonic_time) { - return time_alarm; - } - } - } - - return mp_const_none; } // Is it safe to do a light sleep? Check whether WiFi is on or there are // other ongoing tasks that should not be shut down. -static bool light_sleep_ok(void) { - return !common_hal_wifi_radio_get_enabled(&common_hal_wifi_radio_obj); +STATIC bool _light_sleep_ok(void) { + return !common_hal_wifi_radio_get_enabled(&common_hal_wifi_radio_obj) && !supervisor_workflow_active(); } mp_obj_t common_hal_alarm_light_sleep_until_alarms(size_t n_alarms, const mp_obj_t *alarms) { - if (n_alarms == 0) { - return mp_const_none; - } + _setup_sleep_alarms(false, n_alarms, alarms); - if (light_sleep_ok()) { - ESP_LOGI("ALARM", "start light sleep"); - setup_sleep_alarms(n_alarms, alarms); + // Light sleep can break some functionality so only do it when possible. Otherwise we idle. + if (_light_sleep_ok()) { esp_light_sleep_start(); - return common_hal_alarm_get_wake_alarm(); } else { - // Don't do an ESP32 light sleep. - return common_hal_alarm_wait_until_alarms(n_alarms, alarms); + _idle_until_alarm(); } + mp_obj_t wake_alarm = _get_wake_alarm(n_alarms, alarms); + alarm_reset(); + return wake_alarm; } -void common_hal_alarm_exit_and_deep_sleep_until_alarms(size_t n_alarms, const mp_obj_t *alarms) { - setup_sleep_alarms(n_alarms, alarms); - - // Raise an exception, which will be processed in main.c. - mp_raise_arg1(&mp_type_DeepSleepRequest, NULL); +void common_hal_alarm_set_deep_sleep_alarms(size_t n_alarms, const mp_obj_t *alarms) { + _setup_sleep_alarms(true, n_alarms, alarms); } -void common_hal_alarm_prepare_for_deep_sleep(void) { - // Turn off WiFi and anything else that should be shut down cleanly. - common_hal_wifi_radio_set_enabled(&common_hal_wifi_radio_obj, false); -} - -void NORETURN common_hal_alarm_enter_deep_sleep(void) { - ESP_LOGI("ALARM", "start deep sleep"); +void NORETURN alarm_enter_deep_sleep(void) { + // The ESP-IDF caches the deep sleep settings and applies them before sleep. + // We don't need to worry about resetting them in the interim. esp_deep_sleep_start(); } diff --git a/ports/esp32s2/common-hal/alarm/time/TimeAlarm.c b/ports/esp32s2/common-hal/alarm/time/TimeAlarm.c index 7af3694630..34c8b00523 100644 --- a/ports/esp32s2/common-hal/alarm/time/TimeAlarm.c +++ b/ports/esp32s2/common-hal/alarm/time/TimeAlarm.c @@ -27,8 +27,12 @@ #include "esp_sleep.h" #include "py/runtime.h" +#include "supervisor/esp_port.h" + +#include "components/esp_timer/include/esp_timer.h" #include "shared-bindings/alarm/time/TimeAlarm.h" +#include "shared-bindings/time/__init__.h" void common_hal_alarm_time_time_alarm_construct(alarm_time_time_alarm_obj_t *self, mp_float_t monotonic_time) { self->monotonic_time = monotonic_time; @@ -37,3 +41,63 @@ void common_hal_alarm_time_time_alarm_construct(alarm_time_time_alarm_obj_t *sel mp_float_t common_hal_alarm_time_time_alarm_get_monotonic_time(alarm_time_time_alarm_obj_t *self) { return self->monotonic_time; } + +mp_obj_t alarm_time_timealarm_get_wakeup_alarm(size_t n_alarms, const mp_obj_t *alarms) { + // First, check to see if we match + for (size_t i = 0; i < n_alarms; i++) { + if (MP_OBJ_IS_TYPE(alarms[i], &alarm_time_time_alarm_type)) { + return alarms[i]; + } + } + alarm_time_time_alarm_obj_t *timer = m_new_obj(alarm_time_time_alarm_obj_t); + timer->base.type = &alarm_time_time_alarm_type; + return timer; +} + +esp_timer_handle_t pretend_sleep_timer; +STATIC bool woke_up = false; + +// This is run in the timer task. We use it to wake the main CircuitPython task. +void timer_callback(void *arg) { + (void) arg; + woke_up = true; + if (sleeping_circuitpython_task) { + xTaskNotifyGive(sleeping_circuitpython_task); + } +} + +bool alarm_time_timealarm_woke_us_up(void) { + return woke_up; +} + +void alarm_time_timealarm_reset(void) { + esp_timer_stop(pretend_sleep_timer); + esp_timer_delete(pretend_sleep_timer); + pretend_sleep_timer = NULL; + woke_up = false; +} + +void alarm_time_timealarm_set_alarm(alarm_time_time_alarm_obj_t *self) { + if (pretend_sleep_timer != NULL) { + esp_timer_stop(pretend_sleep_timer); + } else { + // Configure the timer to use during pretend sleep. + esp_timer_create_args_t args; + args.callback = timer_callback; + args.arg = NULL; + args.dispatch_method = ESP_TIMER_TASK; + args.name = "Pretend deep sleep"; + esp_timer_create(&args, &pretend_sleep_timer); + } + + // Compute how long to actually sleep, considering the time now. + mp_float_t now_secs = uint64_to_float(common_hal_time_monotonic_ms()) / 1000.0f; + mp_float_t wakeup_in_secs = MAX(0.0f, self->monotonic_time - now_secs); + const uint64_t sleep_for_us = (uint64_t) (wakeup_in_secs * 1000000); + esp_sleep_enable_timer_wakeup(sleep_for_us); + + // Also set the RTC interrupt so it can wake our task. This will be wiped out + // if we actually deep sleep. + woke_up = false; + esp_timer_start_once(pretend_sleep_timer, sleep_for_us); +} diff --git a/ports/esp32s2/common-hal/alarm/time/TimeAlarm.h b/ports/esp32s2/common-hal/alarm/time/TimeAlarm.h index b540541f4d..04c553009e 100644 --- a/ports/esp32s2/common-hal/alarm/time/TimeAlarm.h +++ b/ports/esp32s2/common-hal/alarm/time/TimeAlarm.h @@ -31,3 +31,10 @@ typedef struct { mp_obj_base_t base; mp_float_t monotonic_time; // values compatible with time.monotonic_time() } alarm_time_time_alarm_obj_t; + +// Find the alarm object that caused us to wake up or create an equivalent one. +mp_obj_t alarm_time_timealarm_get_wakeup_alarm(size_t n_alarms, const mp_obj_t *alarms); +// Check for the wake up alarm from pretend deep sleep. +bool alarm_time_timealarm_woke_us_up(void); +void alarm_time_timealarm_set_alarm(alarm_time_time_alarm_obj_t *self); +void alarm_time_timealarm_reset(void); diff --git a/ports/esp32s2/common-hal/busio/SPI.c b/ports/esp32s2/common-hal/busio/SPI.c index da738bbfdd..562881585d 100644 --- a/ports/esp32s2/common-hal/busio/SPI.c +++ b/ports/esp32s2/common-hal/busio/SPI.c @@ -28,7 +28,6 @@ #include "py/mperrno.h" #include "py/runtime.h" -#include "boards/board.h" #include "shared-bindings/microcontroller/Pin.h" #include "supervisor/shared/rgb_led_status.h" diff --git a/ports/esp32s2/supervisor/port.c b/ports/esp32s2/supervisor/port.c index 6222cd2904..954fb93309 100644 --- a/ports/esp32s2/supervisor/port.c +++ b/ports/esp32s2/supervisor/port.c @@ -27,8 +27,8 @@ #include #include +#include "supervisor/board.h" #include "supervisor/port.h" -#include "boards/board.h" #include "modules/module.h" #include "py/runtime.h" #include "supervisor/esp_port.h" @@ -239,27 +239,31 @@ void port_enable_tick(void) { // Disable 1/1024 second tick. void port_disable_tick(void) { esp_timer_stop(_tick_timer); + + // CircuitPython's VM is run in a separate FreeRTOS task from TinyUSB. + // Tick disable can happen via auto-reload so poke the main task here. + if (sleeping_circuitpython_task != NULL) { + xTaskNotifyGive(sleeping_circuitpython_task); + } } TickType_t sleep_time_duration; void port_interrupt_after_ticks(uint32_t ticks) { sleep_time_duration = (ticks * 100)/1024; - sleeping_circuitpython_task = xTaskGetCurrentTaskHandle(); } -void port_sleep_until_interrupt(void) { - - uint32_t NotifyValue = 0; +void port_idle_until_interrupt(void) { + uint32_t notify_value = 0; if (sleep_time_duration == 0) { return; } - xTaskNotifyWait(0x01,0x01,&NotifyValue, - sleep_time_duration ); - if (NotifyValue == 1) { - sleeping_circuitpython_task = NULL; - mp_handle_pending(); + sleeping_circuitpython_task = xTaskGetCurrentTaskHandle(); + xTaskNotifyWait(0x01, 0x01, ¬ify_value, sleep_time_duration ); + sleeping_circuitpython_task = NULL; + if (notify_value == 1) { + mp_handle_pending(); } } diff --git a/ports/litex/boards/board.h b/ports/litex/boards/board.h deleted file mode 100644 index 837b371904..0000000000 --- a/ports/litex/boards/board.h +++ /dev/null @@ -1,45 +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. - */ - -// This file defines board specific functions. - -#ifndef MICROPY_INCLUDED_LITEX_BOARDS_BOARD_H -#define MICROPY_INCLUDED_LITEX_BOARDS_BOARD_H - -#include - -// 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_LITEX_BOARDS_BOARD_H diff --git a/ports/litex/boards/fomu/board.c b/ports/litex/boards/fomu/board.c index 97e1ecadd6..a90f22f81e 100644 --- a/ports/litex/boards/fomu/board.c +++ b/ports/litex/boards/fomu/board.c @@ -24,7 +24,8 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" + #include "mpconfigboard.h" #include "csr.h" diff --git a/ports/litex/supervisor/port.c b/ports/litex/supervisor/port.c index f5c362ea6e..4dea020652 100644 --- a/ports/litex/supervisor/port.c +++ b/ports/litex/supervisor/port.c @@ -26,9 +26,9 @@ */ #include +#include "supervisor/board.h" #include "supervisor/port.h" #include "supervisor/shared/tick.h" -#include "boards/board.h" #include "irq.h" #include "csr.h" @@ -147,5 +147,5 @@ void port_interrupt_after_ticks(uint32_t ticks) { } // TODO: Add sleep support if the SoC supports sleep. -void port_sleep_until_interrupt(void) { +void port_idle_until_interrupt(void) { } diff --git a/ports/mimxrt10xx/board.h b/ports/mimxrt10xx/board.h new file mode 100644 index 0000000000..1c9596e7d2 --- /dev/null +++ b/ports/mimxrt10xx/board.h @@ -0,0 +1 @@ +// Empty but needed for the SDK diff --git a/ports/mimxrt10xx/boards/feather_m7_1011/board.c b/ports/mimxrt10xx/boards/feather_m7_1011/board.c index ed543e1b06..1db1dd6861 100644 --- a/ports/mimxrt10xx/boards/feather_m7_1011/board.c +++ b/ports/mimxrt10xx/boards/feather_m7_1011/board.c @@ -25,7 +25,8 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" +#include "boards/flash_config.h" #include "mpconfigboard.h" #include "shared-bindings/microcontroller/Pin.h" diff --git a/ports/mimxrt10xx/boards/feather_m7_1011/flash_config.c b/ports/mimxrt10xx/boards/feather_m7_1011/flash_config.c index 282464c75d..9ba3e168f5 100644 --- a/ports/mimxrt10xx/boards/feather_m7_1011/flash_config.c +++ b/ports/mimxrt10xx/boards/feather_m7_1011/flash_config.c @@ -5,9 +5,9 @@ * SPDX-License-Identifier: BSD-3-Clause */ -#include "fsl_flexspi_nor_boot.h" -#include "boards/board.h" +#include "boards/flash_config.h" +#include "fsl_flexspi_nor_boot.h" __attribute__((section(".boot_hdr.ivt"))) /************************************* diff --git a/ports/mimxrt10xx/boards/feather_m7_1011/pins.c b/ports/mimxrt10xx/boards/feather_m7_1011/pins.c index 09e3217614..04fbeea59b 100644 --- a/ports/mimxrt10xx/boards/feather_m7_1011/pins.c +++ b/ports/mimxrt10xx/boards/feather_m7_1011/pins.c @@ -1,6 +1,6 @@ #include "shared-bindings/board/__init__.h" -#include "boards/board.h" +#include "supervisor/board.h" STATIC const mp_rom_map_elem_t board_global_dict_table[] = { // Analog diff --git a/ports/mimxrt10xx/boards/feather_mimxrt1011/board.c b/ports/mimxrt10xx/boards/feather_mimxrt1011/board.c index ed543e1b06..1db1dd6861 100644 --- a/ports/mimxrt10xx/boards/feather_mimxrt1011/board.c +++ b/ports/mimxrt10xx/boards/feather_mimxrt1011/board.c @@ -25,7 +25,8 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" +#include "boards/flash_config.h" #include "mpconfigboard.h" #include "shared-bindings/microcontroller/Pin.h" diff --git a/ports/mimxrt10xx/boards/feather_mimxrt1011/flash_config.c b/ports/mimxrt10xx/boards/feather_mimxrt1011/flash_config.c index 51cc0f164b..eafc9ac3af 100644 --- a/ports/mimxrt10xx/boards/feather_mimxrt1011/flash_config.c +++ b/ports/mimxrt10xx/boards/feather_mimxrt1011/flash_config.c @@ -5,9 +5,9 @@ * SPDX-License-Identifier: BSD-3-Clause */ -#include "fsl_flexspi_nor_boot.h" -#include "boards/board.h" +#include "boards/flash_config.h" +#include "fsl_flexspi_nor_boot.h" __attribute__((section(".boot_hdr.ivt"))) /************************************* diff --git a/ports/mimxrt10xx/boards/feather_mimxrt1011/pins.c b/ports/mimxrt10xx/boards/feather_mimxrt1011/pins.c index 2c6c1ce93e..4e5de8de27 100644 --- a/ports/mimxrt10xx/boards/feather_mimxrt1011/pins.c +++ b/ports/mimxrt10xx/boards/feather_mimxrt1011/pins.c @@ -1,6 +1,6 @@ #include "shared-bindings/board/__init__.h" -#include "boards/board.h" +#include "supervisor/board.h" STATIC const mp_rom_map_elem_t board_global_dict_table[] = { // Analog diff --git a/ports/mimxrt10xx/boards/feather_mimxrt1062/board.c b/ports/mimxrt10xx/boards/feather_mimxrt1062/board.c index 9878a62a29..26f55f96e1 100644 --- a/ports/mimxrt10xx/boards/feather_mimxrt1062/board.c +++ b/ports/mimxrt10xx/boards/feather_mimxrt1062/board.c @@ -25,7 +25,8 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" +#include "boards/flash_config.h" #include "mpconfigboard.h" #include "shared-bindings/microcontroller/Pin.h" diff --git a/ports/mimxrt10xx/boards/feather_mimxrt1062/flash_config.c b/ports/mimxrt10xx/boards/feather_mimxrt1062/flash_config.c index 51cc0f164b..fef1c11e3e 100644 --- a/ports/mimxrt10xx/boards/feather_mimxrt1062/flash_config.c +++ b/ports/mimxrt10xx/boards/feather_mimxrt1062/flash_config.c @@ -5,8 +5,9 @@ * SPDX-License-Identifier: BSD-3-Clause */ +#include "boards/flash_config.h" + #include "fsl_flexspi_nor_boot.h" -#include "boards/board.h" __attribute__((section(".boot_hdr.ivt"))) diff --git a/ports/mimxrt10xx/boards/feather_mimxrt1062/pins.c b/ports/mimxrt10xx/boards/feather_mimxrt1062/pins.c index eb287b87aa..d372b951f6 100644 --- a/ports/mimxrt10xx/boards/feather_mimxrt1062/pins.c +++ b/ports/mimxrt10xx/boards/feather_mimxrt1062/pins.c @@ -1,6 +1,6 @@ #include "shared-bindings/board/__init__.h" -#include "boards/board.h" +#include "supervisor/board.h" STATIC const mp_rom_map_elem_t board_global_dict_table[] = { // Analog diff --git a/ports/mimxrt10xx/boards/board.h b/ports/mimxrt10xx/boards/flash_config.h similarity index 75% rename from ports/mimxrt10xx/boards/board.h rename to ports/mimxrt10xx/boards/flash_config.h index 678c223ae0..25f1550ae8 100644 --- a/ports/mimxrt10xx/boards/board.h +++ b/ports/mimxrt10xx/boards/flash_config.h @@ -26,26 +26,16 @@ // This file defines board specific functions. -#ifndef MICROPY_INCLUDED_MIMXRT10XX_BOARDS_BOARD_H -#define MICROPY_INCLUDED_MIMXRT10XX_BOARDS_BOARD_H +#ifndef MICROPY_INCLUDED_MIMXRT10XX_BOARDS_FLASH_CONFIG_H +#define MICROPY_INCLUDED_MIMXRT10XX_BOARDS_FLASH_CONFIG_H #include -#include "py/mpconfig.h" +#include "mpconfigboard.h" // For flash size settings + #include "fsl_common.h" #include "fsl_flexspi_nor_config.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); - #define SEQUENCE(first, second, third, fourth) first, second, third, fourth #define TWO_EMPTY_STEPS 0x00000000 #define EMPTY_SEQUENCE SEQUENCE(TWO_EMPTY_STEPS, TWO_EMPTY_STEPS, TWO_EMPTY_STEPS, TWO_EMPTY_STEPS) @@ -53,4 +43,4 @@ void reset_board(void); // FlexSPI configuration that stores command info. extern const flexspi_nor_config_t qspiflash_config; -#endif // MICROPY_INCLUDED_MIMXRT10XX_BOARDS_BOARD_H +#endif // MICROPY_INCLUDED_MIMXRT10XX_BOARDS_FLASH_CONFIG_H diff --git a/ports/mimxrt10xx/boards/imxrt1010_evk/board.c b/ports/mimxrt10xx/boards/imxrt1010_evk/board.c index ba3498581c..8519893a5f 100644 --- a/ports/mimxrt10xx/boards/imxrt1010_evk/board.c +++ b/ports/mimxrt10xx/boards/imxrt1010_evk/board.c @@ -25,7 +25,8 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" +#include "boards/flash_config.h" #include "mpconfigboard.h" #include "shared-bindings/microcontroller/Pin.h" diff --git a/ports/mimxrt10xx/boards/imxrt1010_evk/flash_config.c b/ports/mimxrt10xx/boards/imxrt1010_evk/flash_config.c index 19573bd993..00ee47c985 100644 --- a/ports/mimxrt10xx/boards/imxrt1010_evk/flash_config.c +++ b/ports/mimxrt10xx/boards/imxrt1010_evk/flash_config.c @@ -5,8 +5,9 @@ * SPDX-License-Identifier: BSD-3-Clause */ +#include "boards/flash_config.h" + #include "fsl_flexspi_nor_boot.h" -#include "boards/board.h" __attribute__((section(".boot_hdr.ivt"))) diff --git a/ports/mimxrt10xx/boards/imxrt1010_evk/pins.c b/ports/mimxrt10xx/boards/imxrt1010_evk/pins.c index a0221a2ad2..4aad9aaeb3 100644 --- a/ports/mimxrt10xx/boards/imxrt1010_evk/pins.c +++ b/ports/mimxrt10xx/boards/imxrt1010_evk/pins.c @@ -1,6 +1,6 @@ #include "shared-bindings/board/__init__.h" -#include "boards/board.h" +#include "supervisor/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) }, diff --git a/ports/mimxrt10xx/boards/imxrt1020_evk/board.c b/ports/mimxrt10xx/boards/imxrt1020_evk/board.c index d5166b3560..531c0c6f62 100644 --- a/ports/mimxrt10xx/boards/imxrt1020_evk/board.c +++ b/ports/mimxrt10xx/boards/imxrt1020_evk/board.c @@ -25,7 +25,8 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" +#include "boards/flash_config.h" #include "mpconfigboard.h" #include "shared-bindings/microcontroller/Pin.h" diff --git a/ports/mimxrt10xx/boards/imxrt1020_evk/flash_config.c b/ports/mimxrt10xx/boards/imxrt1020_evk/flash_config.c index 40b566618e..4c3ba47179 100644 --- a/ports/mimxrt10xx/boards/imxrt1020_evk/flash_config.c +++ b/ports/mimxrt10xx/boards/imxrt1020_evk/flash_config.c @@ -5,8 +5,9 @@ * SPDX-License-Identifier: BSD-3-Clause */ +#include "boards/flash_config.h" + #include "fsl_flexspi_nor_boot.h" -#include "boards/board.h" __attribute__((section(".boot_hdr.ivt"))) diff --git a/ports/mimxrt10xx/boards/imxrt1020_evk/pins.c b/ports/mimxrt10xx/boards/imxrt1020_evk/pins.c index ef8115a64f..2052a12429 100644 --- a/ports/mimxrt10xx/boards/imxrt1020_evk/pins.c +++ b/ports/mimxrt10xx/boards/imxrt1020_evk/pins.c @@ -1,6 +1,6 @@ #include "shared-bindings/board/__init__.h" -#include "boards/board.h" +#include "supervisor/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) }, diff --git a/ports/mimxrt10xx/boards/imxrt1060_evk/board.c b/ports/mimxrt10xx/boards/imxrt1060_evk/board.c index 25bc4e8c9d..e7d74ab49f 100644 --- a/ports/mimxrt10xx/boards/imxrt1060_evk/board.c +++ b/ports/mimxrt10xx/boards/imxrt1060_evk/board.c @@ -25,7 +25,8 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" +#include "boards/flash_config.h" #include "mpconfigboard.h" #include "shared-bindings/microcontroller/Pin.h" diff --git a/ports/mimxrt10xx/boards/imxrt1060_evk/flash_config.c b/ports/mimxrt10xx/boards/imxrt1060_evk/flash_config.c index d79a8d0f91..502e21a3b0 100644 --- a/ports/mimxrt10xx/boards/imxrt1060_evk/flash_config.c +++ b/ports/mimxrt10xx/boards/imxrt1060_evk/flash_config.c @@ -5,8 +5,9 @@ * SPDX-License-Identifier: BSD-3-Clause */ +#include "boards/flash_config.h" + #include "fsl_flexspi_nor_boot.h" -#include "boards/board.h" __attribute__((section(".boot_hdr.ivt"))) diff --git a/ports/mimxrt10xx/boards/imxrt1060_evk/pins.c b/ports/mimxrt10xx/boards/imxrt1060_evk/pins.c index 2d268952d1..b24e4dc86d 100644 --- a/ports/mimxrt10xx/boards/imxrt1060_evk/pins.c +++ b/ports/mimxrt10xx/boards/imxrt1060_evk/pins.c @@ -1,6 +1,6 @@ #include "shared-bindings/board/__init__.h" -#include "boards/board.h" +#include "supervisor/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) }, diff --git a/ports/mimxrt10xx/boards/metro_m7_1011/board.c b/ports/mimxrt10xx/boards/metro_m7_1011/board.c index ed543e1b06..1db1dd6861 100644 --- a/ports/mimxrt10xx/boards/metro_m7_1011/board.c +++ b/ports/mimxrt10xx/boards/metro_m7_1011/board.c @@ -25,7 +25,8 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" +#include "boards/flash_config.h" #include "mpconfigboard.h" #include "shared-bindings/microcontroller/Pin.h" diff --git a/ports/mimxrt10xx/boards/metro_m7_1011/flash_config.c b/ports/mimxrt10xx/boards/metro_m7_1011/flash_config.c index 30ce67523e..991bc43e45 100644 --- a/ports/mimxrt10xx/boards/metro_m7_1011/flash_config.c +++ b/ports/mimxrt10xx/boards/metro_m7_1011/flash_config.c @@ -5,8 +5,9 @@ * SPDX-License-Identifier: BSD-3-Clause */ +#include "boards/flash_config.h" + #include "fsl_flexspi_nor_boot.h" -#include "boards/board.h" __attribute__((section(".boot_hdr.ivt"))) diff --git a/ports/mimxrt10xx/boards/metro_m7_1011/pins.c b/ports/mimxrt10xx/boards/metro_m7_1011/pins.c index e884934134..ea9ae55290 100644 --- a/ports/mimxrt10xx/boards/metro_m7_1011/pins.c +++ b/ports/mimxrt10xx/boards/metro_m7_1011/pins.c @@ -1,6 +1,6 @@ #include "shared-bindings/board/__init__.h" -#include "boards/board.h" +#include "supervisor/board.h" STATIC const mp_rom_map_elem_t board_global_dict_table[] = { // Analog diff --git a/ports/mimxrt10xx/boards/teensy40/board.c b/ports/mimxrt10xx/boards/teensy40/board.c index 09f0bf3f2a..33ad5ff04a 100644 --- a/ports/mimxrt10xx/boards/teensy40/board.c +++ b/ports/mimxrt10xx/boards/teensy40/board.c @@ -25,7 +25,8 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" +#include "boards/flash_config.h" #include "mpconfigboard.h" #include "shared-bindings/microcontroller/Pin.h" diff --git a/ports/mimxrt10xx/boards/teensy40/flash_config.c b/ports/mimxrt10xx/boards/teensy40/flash_config.c index 30ce67523e..991bc43e45 100644 --- a/ports/mimxrt10xx/boards/teensy40/flash_config.c +++ b/ports/mimxrt10xx/boards/teensy40/flash_config.c @@ -5,8 +5,9 @@ * SPDX-License-Identifier: BSD-3-Clause */ +#include "boards/flash_config.h" + #include "fsl_flexspi_nor_boot.h" -#include "boards/board.h" __attribute__((section(".boot_hdr.ivt"))) diff --git a/ports/mimxrt10xx/boards/teensy40/pins.c b/ports/mimxrt10xx/boards/teensy40/pins.c index 9066ce0d20..64b4aa7f69 100644 --- a/ports/mimxrt10xx/boards/teensy40/pins.c +++ b/ports/mimxrt10xx/boards/teensy40/pins.c @@ -1,6 +1,6 @@ #include "shared-bindings/board/__init__.h" -#include "boards/board.h" +#include "supervisor/board.h" STATIC const mp_rom_map_elem_t board_global_dict_table[] = { // With USB on left. Bottom edge. diff --git a/ports/mimxrt10xx/boards/teensy41/board.c b/ports/mimxrt10xx/boards/teensy41/board.c index 09f0bf3f2a..33ad5ff04a 100644 --- a/ports/mimxrt10xx/boards/teensy41/board.c +++ b/ports/mimxrt10xx/boards/teensy41/board.c @@ -25,7 +25,8 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" +#include "boards/flash_config.h" #include "mpconfigboard.h" #include "shared-bindings/microcontroller/Pin.h" diff --git a/ports/mimxrt10xx/boards/teensy41/flash_config.c b/ports/mimxrt10xx/boards/teensy41/flash_config.c index 7b2bfb768d..c0e0c86f98 100644 --- a/ports/mimxrt10xx/boards/teensy41/flash_config.c +++ b/ports/mimxrt10xx/boards/teensy41/flash_config.c @@ -5,8 +5,9 @@ * SPDX-License-Identifier: BSD-3-Clause */ +#include "boards/flash_config.h" + #include "fsl_flexspi_nor_boot.h" -#include "boards/board.h" __attribute__((section(".boot_hdr.ivt"))) diff --git a/ports/mimxrt10xx/boards/teensy41/pins.c b/ports/mimxrt10xx/boards/teensy41/pins.c index 5eb5ab0f55..cf24513019 100644 --- a/ports/mimxrt10xx/boards/teensy41/pins.c +++ b/ports/mimxrt10xx/boards/teensy41/pins.c @@ -1,6 +1,6 @@ #include "shared-bindings/board/__init__.h" -#include "boards/board.h" +#include "supervisor/board.h" STATIC const mp_rom_map_elem_t board_global_dict_table[] = { // With USB on left. Bottom edge. diff --git a/ports/mimxrt10xx/supervisor/flexspi_nor_flash_ops.c b/ports/mimxrt10xx/supervisor/flexspi_nor_flash_ops.c index 353ba3176d..bd471f9305 100644 --- a/ports/mimxrt10xx/supervisor/flexspi_nor_flash_ops.c +++ b/ports/mimxrt10xx/supervisor/flexspi_nor_flash_ops.c @@ -9,7 +9,7 @@ #include "fsl_flexspi.h" #include "internal_flash.h" -#include "boards/board.h" +#include "boards/flash_config.h" #include "supervisor/linker.h" status_t PLACE_IN_ITCM(flexspi_nor_write_enable)(FLEXSPI_Type *base, uint32_t baseAddr) diff --git a/ports/mimxrt10xx/supervisor/internal_flash.c b/ports/mimxrt10xx/supervisor/internal_flash.c index e194cbed96..9c0d9f8956 100644 --- a/ports/mimxrt10xx/supervisor/internal_flash.c +++ b/ports/mimxrt10xx/supervisor/internal_flash.c @@ -30,7 +30,7 @@ #include #include -#include "boards/board.h" +#include "boards/flash_config.h" #include "extmod/vfs.h" #include "extmod/vfs_fat.h" #include "py/mphal.h" diff --git a/ports/mimxrt10xx/supervisor/port.c b/ports/mimxrt10xx/supervisor/port.c index 1be2b10396..33a85d2b72 100644 --- a/ports/mimxrt10xx/supervisor/port.c +++ b/ports/mimxrt10xx/supervisor/port.c @@ -31,7 +31,7 @@ * SPDX-License-Identifier: BSD-3-Clause */ -#include "boards/board.h" +#include "supervisor/board.h" #include "supervisor/port.h" #include "fsl_device_registers.h" @@ -403,7 +403,7 @@ void port_interrupt_after_ticks(uint32_t ticks) { SNVS->HPCR |= SNVS_HPCR_HPTA_EN_MASK; } -void port_sleep_until_interrupt(void) { +void port_idle_until_interrupt(void) { // App note here: https://www.nxp.com/docs/en/application-note/AN12085.pdf // Clear the FPU interrupt because it can prevent us from sleeping. diff --git a/ports/nrf/boards/ADM_B_NRF52840_1/board.c b/ports/nrf/boards/ADM_B_NRF52840_1/board.c index 4421970eef..7817933281 100644 --- a/ports/nrf/boards/ADM_B_NRF52840_1/board.c +++ b/ports/nrf/boards/ADM_B_NRF52840_1/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" void board_init(void) { } diff --git a/ports/nrf/boards/TG-Watch02A/board.c b/ports/nrf/boards/TG-Watch02A/board.c index 4421970eef..7817933281 100644 --- a/ports/nrf/boards/TG-Watch02A/board.c +++ b/ports/nrf/boards/TG-Watch02A/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" void board_init(void) { } diff --git a/ports/nrf/boards/aramcon_badge_2019/board.c b/ports/nrf/boards/aramcon_badge_2019/board.c index efb449285b..8f3830b000 100644 --- a/ports/nrf/boards/aramcon_badge_2019/board.c +++ b/ports/nrf/boards/aramcon_badge_2019/board.c @@ -25,7 +25,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" #include "common-hal/microcontroller/Pin.h" void board_init(void) { diff --git a/ports/nrf/boards/arduino_nano_33_ble/board.c b/ports/nrf/boards/arduino_nano_33_ble/board.c index ddfcde2848..d1689e9ddc 100644 --- a/ports/nrf/boards/arduino_nano_33_ble/board.c +++ b/ports/nrf/boards/arduino_nano_33_ble/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" #include "nrf.h" #include "nrf_rtc.h" diff --git a/ports/nrf/boards/bless_dev_board_multi_sensor/board.c b/ports/nrf/boards/bless_dev_board_multi_sensor/board.c index 71b9a06577..6970294ecc 100644 --- a/ports/nrf/boards/bless_dev_board_multi_sensor/board.c +++ b/ports/nrf/boards/bless_dev_board_multi_sensor/board.c @@ -1,4 +1,4 @@ -#include "boards/board.h" +#include "supervisor/board.h" void board_init(void) { } diff --git a/ports/nrf/boards/board.h b/ports/nrf/boards/board.h deleted file mode 100644 index ec98f04fbe..0000000000 --- a/ports/nrf/boards/board.h +++ /dev/null @@ -1,45 +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. - */ - -// This file defines board specific functions. - -#ifndef MICROPY_INCLUDED_NRF_BOARDS_BOARD_H -#define MICROPY_INCLUDED_NRF_BOARDS_BOARD_H - -#include - -// 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_NRF_BOARDS_BOARD_H diff --git a/ports/nrf/boards/circuitplayground_bluefruit/board.c b/ports/nrf/boards/circuitplayground_bluefruit/board.c index 3aa6857da2..ff731d8f98 100644 --- a/ports/nrf/boards/circuitplayground_bluefruit/board.c +++ b/ports/nrf/boards/circuitplayground_bluefruit/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" #include "mpconfigboard.h" #include "py/obj.h" #include "peripherals/nrf/pins.h" @@ -49,5 +49,5 @@ void reset_board(void) { NRF_GPIO_PIN_NOSENSE); nrf_gpio_pin_write(POWER_SWITCH_PIN->number, false); - board_reset_user_neopixels(); + board_reset_user_neopixels(&pin_P0_13, 10); } diff --git a/ports/nrf/boards/clue_nrf52840_express/board.c b/ports/nrf/boards/clue_nrf52840_express/board.c index 523bd7677b..cd46ce75d3 100644 --- a/ports/nrf/boards/clue_nrf52840_express/board.c +++ b/ports/nrf/boards/clue_nrf52840_express/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" #include "mpconfigboard.h" #include "shared-bindings/busio/SPI.h" diff --git a/ports/nrf/boards/clue_nrf52840_express/pins.c b/ports/nrf/boards/clue_nrf52840_express/pins.c index ab0738893c..61d77cedc9 100644 --- a/ports/nrf/boards/clue_nrf52840_express/pins.c +++ b/ports/nrf/boards/clue_nrf52840_express/pins.c @@ -1,6 +1,6 @@ #include "shared-bindings/board/__init__.h" -#include "boards/board.h" +#include "supervisor/board.h" #include "shared-module/displayio/__init__.h" STATIC const mp_rom_map_elem_t board_module_globals_table[] = { diff --git a/ports/nrf/boards/electronut_labs_blip/board.c b/ports/nrf/boards/electronut_labs_blip/board.c index 4421970eef..7817933281 100644 --- a/ports/nrf/boards/electronut_labs_blip/board.c +++ b/ports/nrf/boards/electronut_labs_blip/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" void board_init(void) { } diff --git a/ports/nrf/boards/electronut_labs_papyr/board.c b/ports/nrf/boards/electronut_labs_papyr/board.c index 4421970eef..7817933281 100644 --- a/ports/nrf/boards/electronut_labs_papyr/board.c +++ b/ports/nrf/boards/electronut_labs_papyr/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" void board_init(void) { } diff --git a/ports/nrf/boards/feather_bluefruit_sense/board.c b/ports/nrf/boards/feather_bluefruit_sense/board.c index 4421970eef..7817933281 100644 --- a/ports/nrf/boards/feather_bluefruit_sense/board.c +++ b/ports/nrf/boards/feather_bluefruit_sense/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" void board_init(void) { } diff --git a/ports/nrf/boards/feather_nrf52840_express/board.c b/ports/nrf/boards/feather_nrf52840_express/board.c index 4421970eef..7817933281 100644 --- a/ports/nrf/boards/feather_nrf52840_express/board.c +++ b/ports/nrf/boards/feather_nrf52840_express/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" void board_init(void) { } diff --git a/ports/nrf/boards/hiibot_bluefi/board.c b/ports/nrf/boards/hiibot_bluefi/board.c index 93e31aef0c..a3fd5cf129 100644 --- a/ports/nrf/boards/hiibot_bluefi/board.c +++ b/ports/nrf/boards/hiibot_bluefi/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" #include "mpconfigboard.h" #include "shared-bindings/busio/SPI.h" diff --git a/ports/nrf/boards/hiibot_bluefi/pins.c b/ports/nrf/boards/hiibot_bluefi/pins.c index bce4ee52dd..c7879c4c21 100644 --- a/ports/nrf/boards/hiibot_bluefi/pins.c +++ b/ports/nrf/boards/hiibot_bluefi/pins.c @@ -1,6 +1,6 @@ #include "shared-bindings/board/__init__.h" -#include "boards/board.h" +#include "supervisor/board.h" #include "shared-module/displayio/__init__.h" STATIC const mp_rom_map_elem_t board_module_globals_table[] = { diff --git a/ports/nrf/boards/ikigaisense_vita/board.c b/ports/nrf/boards/ikigaisense_vita/board.c index 4421970eef..7817933281 100644 --- a/ports/nrf/boards/ikigaisense_vita/board.c +++ b/ports/nrf/boards/ikigaisense_vita/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" void board_init(void) { } diff --git a/ports/nrf/boards/itsybitsy_nrf52840_express/board.c b/ports/nrf/boards/itsybitsy_nrf52840_express/board.c index 4421970eef..7817933281 100644 --- a/ports/nrf/boards/itsybitsy_nrf52840_express/board.c +++ b/ports/nrf/boards/itsybitsy_nrf52840_express/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" void board_init(void) { } diff --git a/ports/nrf/boards/makerdiary_m60_keyboard/board.c b/ports/nrf/boards/makerdiary_m60_keyboard/board.c index 4421970eef..7817933281 100644 --- a/ports/nrf/boards/makerdiary_m60_keyboard/board.c +++ b/ports/nrf/boards/makerdiary_m60_keyboard/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" void board_init(void) { } diff --git a/ports/nrf/boards/makerdiary_m60_keyboard/pins.c b/ports/nrf/boards/makerdiary_m60_keyboard/pins.c index 63c3ad1711..fc85fa24b0 100644 --- a/ports/nrf/boards/makerdiary_m60_keyboard/pins.c +++ b/ports/nrf/boards/makerdiary_m60_keyboard/pins.c @@ -1,6 +1,6 @@ #include "shared-bindings/board/__init__.h" -#include "boards/board.h" +#include "supervisor/board.h" #include "shared-module/displayio/__init__.h" STATIC const mp_rom_map_elem_t board_module_globals_table[] = { diff --git a/ports/nrf/boards/makerdiary_nrf52840_m2_devkit/board.c b/ports/nrf/boards/makerdiary_nrf52840_m2_devkit/board.c index e08d00daca..569106ec2a 100644 --- a/ports/nrf/boards/makerdiary_nrf52840_m2_devkit/board.c +++ b/ports/nrf/boards/makerdiary_nrf52840_m2_devkit/board.c @@ -25,7 +25,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" #include "mpconfigboard.h" #include "shared-bindings/busio/SPI.h" diff --git a/ports/nrf/boards/makerdiary_nrf52840_m2_devkit/pins.c b/ports/nrf/boards/makerdiary_nrf52840_m2_devkit/pins.c index 7dc6db18fa..1892868330 100644 --- a/ports/nrf/boards/makerdiary_nrf52840_m2_devkit/pins.c +++ b/ports/nrf/boards/makerdiary_nrf52840_m2_devkit/pins.c @@ -1,6 +1,6 @@ #include "shared-bindings/board/__init__.h" -#include "boards/board.h" +#include "supervisor/board.h" #include "shared-module/displayio/__init__.h" STATIC const mp_rom_map_elem_t board_module_globals_table[] = { diff --git a/ports/nrf/boards/makerdiary_nrf52840_mdk/board.c b/ports/nrf/boards/makerdiary_nrf52840_mdk/board.c index 4421970eef..7817933281 100644 --- a/ports/nrf/boards/makerdiary_nrf52840_mdk/board.c +++ b/ports/nrf/boards/makerdiary_nrf52840_mdk/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" void board_init(void) { } diff --git a/ports/nrf/boards/makerdiary_nrf52840_mdk_usb_dongle/board.c b/ports/nrf/boards/makerdiary_nrf52840_mdk_usb_dongle/board.c index 4421970eef..7817933281 100644 --- a/ports/nrf/boards/makerdiary_nrf52840_mdk_usb_dongle/board.c +++ b/ports/nrf/boards/makerdiary_nrf52840_mdk_usb_dongle/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" void board_init(void) { } diff --git a/ports/nrf/boards/metro_nrf52840_express/board.c b/ports/nrf/boards/metro_nrf52840_express/board.c index 4421970eef..7817933281 100644 --- a/ports/nrf/boards/metro_nrf52840_express/board.c +++ b/ports/nrf/boards/metro_nrf52840_express/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" void board_init(void) { } diff --git a/ports/nrf/boards/nice_nano/board.c b/ports/nrf/boards/nice_nano/board.c index 4421970eef..7817933281 100644 --- a/ports/nrf/boards/nice_nano/board.c +++ b/ports/nrf/boards/nice_nano/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" void board_init(void) { } diff --git a/ports/nrf/boards/ohs2020_badge/board.c b/ports/nrf/boards/ohs2020_badge/board.c index ec52690ced..20abf4e2a9 100644 --- a/ports/nrf/boards/ohs2020_badge/board.c +++ b/ports/nrf/boards/ohs2020_badge/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" #include "mpconfigboard.h" #include "shared-bindings/busio/SPI.h" diff --git a/ports/nrf/boards/particle_argon/board.c b/ports/nrf/boards/particle_argon/board.c index f891f54a13..a41f0ae06e 100644 --- a/ports/nrf/boards/particle_argon/board.c +++ b/ports/nrf/boards/particle_argon/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" void board_init(void) { } diff --git a/ports/nrf/boards/particle_boron/board.c b/ports/nrf/boards/particle_boron/board.c index f891f54a13..a41f0ae06e 100644 --- a/ports/nrf/boards/particle_boron/board.c +++ b/ports/nrf/boards/particle_boron/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" void board_init(void) { } diff --git a/ports/nrf/boards/particle_xenon/board.c b/ports/nrf/boards/particle_xenon/board.c index f891f54a13..a41f0ae06e 100644 --- a/ports/nrf/boards/particle_xenon/board.c +++ b/ports/nrf/boards/particle_xenon/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" void board_init(void) { } diff --git a/ports/nrf/boards/pca10056/board.c b/ports/nrf/boards/pca10056/board.c index 4421970eef..7817933281 100644 --- a/ports/nrf/boards/pca10056/board.c +++ b/ports/nrf/boards/pca10056/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" void board_init(void) { } diff --git a/ports/nrf/boards/pca10059/board.c b/ports/nrf/boards/pca10059/board.c index 4421970eef..7817933281 100644 --- a/ports/nrf/boards/pca10059/board.c +++ b/ports/nrf/boards/pca10059/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" void board_init(void) { } diff --git a/ports/nrf/boards/pca10100/board.c b/ports/nrf/boards/pca10100/board.c index f891f54a13..a41f0ae06e 100644 --- a/ports/nrf/boards/pca10100/board.c +++ b/ports/nrf/boards/pca10100/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" void board_init(void) { } diff --git a/ports/nrf/boards/pitaya_go/board.c b/ports/nrf/boards/pitaya_go/board.c index 4421970eef..7817933281 100644 --- a/ports/nrf/boards/pitaya_go/board.c +++ b/ports/nrf/boards/pitaya_go/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" void board_init(void) { } diff --git a/ports/nrf/boards/raytac_mdbt50q-db-40/board.c b/ports/nrf/boards/raytac_mdbt50q-db-40/board.c index 4421970eef..7817933281 100644 --- a/ports/nrf/boards/raytac_mdbt50q-db-40/board.c +++ b/ports/nrf/boards/raytac_mdbt50q-db-40/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" void board_init(void) { } diff --git a/ports/nrf/boards/simmel/board.c b/ports/nrf/boards/simmel/board.c index f891f54a13..a41f0ae06e 100644 --- a/ports/nrf/boards/simmel/board.c +++ b/ports/nrf/boards/simmel/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" void board_init(void) { } diff --git a/ports/nrf/boards/sparkfun_nrf52840_mini/board.c b/ports/nrf/boards/sparkfun_nrf52840_mini/board.c index 4421970eef..7817933281 100644 --- a/ports/nrf/boards/sparkfun_nrf52840_mini/board.c +++ b/ports/nrf/boards/sparkfun_nrf52840_mini/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" void board_init(void) { } diff --git a/ports/nrf/boards/teknikio_bluebird/board.c b/ports/nrf/boards/teknikio_bluebird/board.c index 4421970eef..7817933281 100644 --- a/ports/nrf/boards/teknikio_bluebird/board.c +++ b/ports/nrf/boards/teknikio_bluebird/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" void board_init(void) { } diff --git a/ports/nrf/boards/tinkeringtech_scoutmakes_azul/board.c b/ports/nrf/boards/tinkeringtech_scoutmakes_azul/board.c index 4421970eef..7817933281 100644 --- a/ports/nrf/boards/tinkeringtech_scoutmakes_azul/board.c +++ b/ports/nrf/boards/tinkeringtech_scoutmakes_azul/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" void board_init(void) { } diff --git a/ports/nrf/supervisor/port.c b/ports/nrf/supervisor/port.c index 5f1c9f1ba9..00485d8588 100644 --- a/ports/nrf/supervisor/port.c +++ b/ports/nrf/supervisor/port.c @@ -26,7 +26,7 @@ #include #include "supervisor/port.h" -#include "boards/board.h" +#include "supervisor/board.h" #include "nrfx/hal/nrf_clock.h" #include "nrfx/hal/nrf_power.h" @@ -307,7 +307,7 @@ void port_interrupt_after_ticks(uint32_t ticks) { nrfx_rtc_cc_set(&rtc_instance, 0, current_ticks + diff, true); } -void port_sleep_until_interrupt(void) { +void port_idle_until_interrupt(void) { #if defined(MICROPY_QSPI_CS) qspi_disable(); #endif diff --git a/ports/stm/boards/board.h b/ports/stm/boards/board.h deleted file mode 100644 index 22d9e99be0..0000000000 --- a/ports/stm/boards/board.h +++ /dev/null @@ -1,45 +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. - */ - -// This file defines board specific functions. - -#ifndef MICROPY_INCLUDED_STM32F4_BOARDS_BOARD_H -#define MICROPY_INCLUDED_STM32F4_BOARDS_BOARD_H - -#include - -// 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_STM32F4_BOARDS_BOARD_H diff --git a/ports/stm/boards/espruino_pico/board.c b/ports/stm/boards/espruino_pico/board.c index 82b0c506ed..f8e462f938 100644 --- a/ports/stm/boards/espruino_pico/board.c +++ b/ports/stm/boards/espruino_pico/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" #include "mpconfigboard.h" void board_init(void) { diff --git a/ports/stm/boards/espruino_wifi/board.c b/ports/stm/boards/espruino_wifi/board.c index 4421970eef..7817933281 100644 --- a/ports/stm/boards/espruino_wifi/board.c +++ b/ports/stm/boards/espruino_wifi/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" void board_init(void) { } diff --git a/ports/stm/boards/feather_stm32f405_express/board.c b/ports/stm/boards/feather_stm32f405_express/board.c index 82b0c506ed..f8e462f938 100644 --- a/ports/stm/boards/feather_stm32f405_express/board.c +++ b/ports/stm/boards/feather_stm32f405_express/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" #include "mpconfigboard.h" void board_init(void) { diff --git a/ports/stm/boards/meowbit_v121/board.c b/ports/stm/boards/meowbit_v121/board.c index f67b4a49db..4a8014a3a1 100644 --- a/ports/stm/boards/meowbit_v121/board.c +++ b/ports/stm/boards/meowbit_v121/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" #include "mpconfigboard.h" #include "shared-bindings/board/__init__.h" diff --git a/ports/stm/boards/nucleo_f746zg/board.c b/ports/stm/boards/nucleo_f746zg/board.c index 4421970eef..7817933281 100644 --- a/ports/stm/boards/nucleo_f746zg/board.c +++ b/ports/stm/boards/nucleo_f746zg/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" void board_init(void) { } diff --git a/ports/stm/boards/nucleo_f767zi/board.c b/ports/stm/boards/nucleo_f767zi/board.c index 4421970eef..7817933281 100644 --- a/ports/stm/boards/nucleo_f767zi/board.c +++ b/ports/stm/boards/nucleo_f767zi/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" void board_init(void) { } diff --git a/ports/stm/boards/nucleo_h743zi_2/board.c b/ports/stm/boards/nucleo_h743zi_2/board.c index 4421970eef..7817933281 100644 --- a/ports/stm/boards/nucleo_h743zi_2/board.c +++ b/ports/stm/boards/nucleo_h743zi_2/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" void board_init(void) { } diff --git a/ports/stm/boards/openmv_h7/board.c b/ports/stm/boards/openmv_h7/board.c index 4421970eef..7817933281 100644 --- a/ports/stm/boards/openmv_h7/board.c +++ b/ports/stm/boards/openmv_h7/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" void board_init(void) { } diff --git a/ports/stm/boards/pyb_nano_v2/board.c b/ports/stm/boards/pyb_nano_v2/board.c index 82b0c506ed..f8e462f938 100644 --- a/ports/stm/boards/pyb_nano_v2/board.c +++ b/ports/stm/boards/pyb_nano_v2/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" #include "mpconfigboard.h" void board_init(void) { diff --git a/ports/stm/boards/pyboard_v11/board.c b/ports/stm/boards/pyboard_v11/board.c index 4421970eef..7817933281 100644 --- a/ports/stm/boards/pyboard_v11/board.c +++ b/ports/stm/boards/pyboard_v11/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" void board_init(void) { } diff --git a/ports/stm/boards/stm32f411ce_blackpill/board.c b/ports/stm/boards/stm32f411ce_blackpill/board.c index 82b0c506ed..f8e462f938 100644 --- a/ports/stm/boards/stm32f411ce_blackpill/board.c +++ b/ports/stm/boards/stm32f411ce_blackpill/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" #include "mpconfigboard.h" void board_init(void) { diff --git a/ports/stm/boards/stm32f411ve_discovery/board.c b/ports/stm/boards/stm32f411ve_discovery/board.c index 4421970eef..7817933281 100644 --- a/ports/stm/boards/stm32f411ve_discovery/board.c +++ b/ports/stm/boards/stm32f411ve_discovery/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" void board_init(void) { } diff --git a/ports/stm/boards/stm32f412zg_discovery/board.c b/ports/stm/boards/stm32f412zg_discovery/board.c index 4421970eef..7817933281 100644 --- a/ports/stm/boards/stm32f412zg_discovery/board.c +++ b/ports/stm/boards/stm32f412zg_discovery/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" void board_init(void) { } diff --git a/ports/stm/boards/stm32f4_discovery/board.c b/ports/stm/boards/stm32f4_discovery/board.c index 4421970eef..7817933281 100644 --- a/ports/stm/boards/stm32f4_discovery/board.c +++ b/ports/stm/boards/stm32f4_discovery/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" void board_init(void) { } diff --git a/ports/stm/boards/stm32f746g_discovery/board.c b/ports/stm/boards/stm32f746g_discovery/board.c index aafc69cf02..db2c727271 100644 --- a/ports/stm/boards/stm32f746g_discovery/board.c +++ b/ports/stm/boards/stm32f746g_discovery/board.c @@ -25,7 +25,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" #include "stm32f7xx_hal.h" #include "common-hal/microcontroller/Pin.h" diff --git a/ports/stm/boards/thunderpack_v11/board.c b/ports/stm/boards/thunderpack_v11/board.c index 4421970eef..7817933281 100644 --- a/ports/stm/boards/thunderpack_v11/board.c +++ b/ports/stm/boards/thunderpack_v11/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" void board_init(void) { } diff --git a/ports/stm/boards/thunderpack_v12/board.c b/ports/stm/boards/thunderpack_v12/board.c index 4421970eef..7817933281 100644 --- a/ports/stm/boards/thunderpack_v12/board.c +++ b/ports/stm/boards/thunderpack_v12/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" void board_init(void) { } diff --git a/ports/stm/common-hal/busio/SPI.c b/ports/stm/common-hal/busio/SPI.c index 29fbdee569..20ee0f6e15 100644 --- a/ports/stm/common-hal/busio/SPI.c +++ b/ports/stm/common-hal/busio/SPI.c @@ -32,7 +32,7 @@ #include "py/runtime.h" #include "shared-bindings/microcontroller/__init__.h" -#include "boards/board.h" +#include "supervisor/board.h" #include "supervisor/shared/translate.h" #include "shared-bindings/microcontroller/Pin.h" diff --git a/ports/stm/common-hal/sdioio/SDCard.c b/ports/stm/common-hal/sdioio/SDCard.c index 5f6010f01a..de0e8d1119 100644 --- a/ports/stm/common-hal/sdioio/SDCard.c +++ b/ports/stm/common-hal/sdioio/SDCard.c @@ -31,7 +31,7 @@ #include "shared-bindings/microcontroller/__init__.h" #include "shared-bindings/util.h" -#include "boards/board.h" +#include "supervisor/board.h" #include "supervisor/shared/translate.h" #include "common-hal/microcontroller/Pin.h" #include "shared-bindings/microcontroller/Pin.h" diff --git a/ports/stm/supervisor/port.c b/ports/stm/supervisor/port.c index dba1cf21ee..3103a07160 100644 --- a/ports/stm/supervisor/port.c +++ b/ports/stm/supervisor/port.c @@ -27,7 +27,7 @@ #include #include "supervisor/port.h" -#include "boards/board.h" +#include "supervisor/board.h" #include "lib/timeutils/timeutils.h" #include "common-hal/microcontroller/Pin.h" @@ -436,7 +436,7 @@ void port_interrupt_after_ticks(uint32_t ticks) { alarmed_already = false; } -void port_sleep_until_interrupt(void) { +void port_idle_until_interrupt(void) { // Clear the FPU interrupt because it can prevent us from sleeping. if (__get_FPSCR() & ~(0x9f)) { __set_FPSCR(__get_FPSCR() & ~(0x9f)); diff --git a/py/circuitpy_mpconfig.h b/py/circuitpy_mpconfig.h index f04112bfcd..0bd889ccdf 100644 --- a/py/circuitpy_mpconfig.h +++ b/py/circuitpy_mpconfig.h @@ -912,6 +912,12 @@ void supervisor_run_background_tasks_if_tick(void); #define CIRCUITPY_PYSTACK_SIZE 1536 #endif + +// Wait this long imediately after startup to see if we are connected to USB. +#ifndef CIRCUITPY_USB_CONNECTED_SLEEP_DELAY +#define CIRCUITPY_USB_CONNECTED_SLEEP_DELAY 5 +#endif + #define CIRCUITPY_BOOT_OUTPUT_FILE "/boot_out.txt" #define CIRCUITPY_VERBOSE_BLE 0 diff --git a/shared-bindings/alarm/__init__.c b/shared-bindings/alarm/__init__.c index a1f1a2f8c2..5420b8404b 100644 --- a/shared-bindings/alarm/__init__.c +++ b/shared-bindings/alarm/__init__.c @@ -36,9 +36,6 @@ #include "supervisor/shared/autoreload.h" #include "supervisor/shared/workflow.h" -// Wait this long imediately after startup to see if we are connected to USB. -#define CIRCUITPY_USB_CONNECTED_SLEEP_DELAY 5 - //| """Alarms and sleep //| //| Provides alarms that trigger based on time intervals or on external events, such as pin @@ -93,21 +90,13 @@ void validate_objs_are_alarms(size_t n_args, const mp_obj_t *objs) { //| ... //| STATIC mp_obj_t alarm_light_sleep_until_alarms(size_t n_args, const mp_obj_t *args) { + if (n_args == 0) { + return mp_const_none; + } + validate_objs_are_alarms(n_args, args); - // See if we are connected to a host. - // Make sure we have been awake long enough for USB to connect (enumeration delay). - int64_t connecting_delay_msec = CIRCUITPY_USB_CONNECTED_SLEEP_DELAY * 1024 - supervisor_ticks_ms64(); - if (connecting_delay_msec > 0) { - common_hal_time_delay_ms(connecting_delay_msec * 1000 / 1024); - } - - if (supervisor_workflow_active()) { - common_hal_alarm_wait_until_alarms(n_args, args); - } else { - common_hal_alarm_light_sleep_until_alarms(n_args, args); - } - return mp_const_none; + return common_hal_alarm_light_sleep_until_alarms(n_args, args); } MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(alarm_light_sleep_until_alarms_obj, 1, MP_OBJ_FUN_ARGS_MAX, alarm_light_sleep_until_alarms); @@ -151,26 +140,13 @@ MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(alarm_light_sleep_until_alarms_obj, 1, MP_OB STATIC mp_obj_t alarm_exit_and_deep_sleep_until_alarms(size_t n_args, const mp_obj_t *args) { validate_objs_are_alarms(n_args, args); - // Shut down WiFi, etc. - common_hal_alarm_prepare_for_deep_sleep(); + // Validate the alarms and set them. + common_hal_alarm_set_deep_sleep_alarms(n_args, args); - // See if we are connected to a host. - // Make sure we have been awake long enough for USB to connect (enumeration delay). - int64_t connecting_delay_msec = CIRCUITPY_USB_CONNECTED_SLEEP_DELAY * 1024 - supervisor_ticks_ms64(); - if (connecting_delay_msec > 0) { - common_hal_time_delay_ms(connecting_delay_msec * 1000 / 1024); - } + // Raise an exception, which will be processed in main.c. + mp_raise_arg1(&mp_type_DeepSleepRequest, NULL); - if (supervisor_workflow_active()) { - // Simulate deep sleep by waiting for an alarm and then restarting when done. - common_hal_alarm_wait_until_alarms(n_args, args); - reload_requested = true; - supervisor_set_run_reason(RUN_REASON_STARTUP); - mp_raise_reload_exception(); - } else { - common_hal_alarm_exit_and_deep_sleep_until_alarms(n_args, args); - // Does not return. - } + // Doesn't get here. return mp_const_none; } MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(alarm_exit_and_deep_sleep_until_alarms_obj, 1, MP_OBJ_FUN_ARGS_MAX, alarm_exit_and_deep_sleep_until_alarms); diff --git a/shared-bindings/alarm/__init__.h b/shared-bindings/alarm/__init__.h index 380c65ea8c..5a8c613d9d 100644 --- a/shared-bindings/alarm/__init__.h +++ b/shared-bindings/alarm/__init__.h @@ -31,13 +31,22 @@ #include "common-hal/alarm/__init__.h" -extern mp_obj_t common_hal_alarm_wait_until_alarms(size_t n_alarms, const mp_obj_t *alarms); extern mp_obj_t common_hal_alarm_light_sleep_until_alarms(size_t n_alarms, const mp_obj_t *alarms); -extern void common_hal_alarm_exit_and_deep_sleep_until_alarms(size_t n_alarms, const mp_obj_t *alarms); -extern void common_hal_alarm_prepare_for_deep_sleep(void); -extern NORETURN void common_hal_alarm_enter_deep_sleep(void); + +// Deep sleep is a two step process. Alarms are set when the VM is valid but +// everything is reset before entering deep sleep. Furthermore, deep sleep may +// not actually happen if the user is connected to the device. In this case, the +// supervisor will idle using `port_wait_for_interrupt`. After each call, it will +// call alarm_woken_from_sleep to see if we've been woken by an alarm and if so, +// it will exit idle as if deep sleep was exited. +extern void common_hal_alarm_set_deep_sleep_alarms(size_t n_alarms, const mp_obj_t *alarms); +// Deep sleep is entered outside of the VM so we omit the `common_hal_` prefix. +extern NORETURN void alarm_enter_deep_sleep(void); // Used by wake-up code. extern void common_hal_alarm_set_wake_alarm(mp_obj_t alarm); +// True if an alarm is alerting. This is most useful for pretend deep sleep. +extern bool alarm_woken_from_sleep(void); + #endif // MICROPY_INCLUDED_SHARED_BINDINGS_ALARM___INIT___H diff --git a/ports/esp32s2/boards/board.h b/supervisor/board.h similarity index 77% rename from ports/esp32s2/boards/board.h rename to supervisor/board.h index 2f0db81356..939ee1c194 100644 --- a/ports/esp32s2/boards/board.h +++ b/supervisor/board.h @@ -24,22 +24,30 @@ * THE SOFTWARE. */ -// This file defines board specific functions. - -#ifndef MICROPY_INCLUDED_ESP32S2_BOARDS_BOARD_H -#define MICROPY_INCLUDED_ESP32S2_BOARDS_BOARD_H +#ifndef MICROPY_INCLUDED_SUPERVISOR_BOARD_H +#define MICROPY_INCLUDED_SUPERVISOR_BOARD_H #include -// Initializes board related state once on start up. -void board_init(void); +#include "supervisor/shared/safe_mode.h" // 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); +// Initializes board related state once on start up. +void board_init(void); + // Reset the state of off MCU components such as neopixels. void reset_board(void); -#endif // MICROPY_INCLUDED_ESP32S2_BOARDS_BOARD_H +#if CIRCUITPY_ALARM +// Deinit the board. This should put the board in deep sleep durable, low power +// state. It should not prevent the user access method from working (such as +// disabling USB, BLE or flash) because CircuitPython may continue to run. +void board_deinit(void); +#endif + + +#endif // MICROPY_INCLUDED_SUPERVISOR_BOARD_H diff --git a/supervisor/port.h b/supervisor/port.h index 5bc06bc4e1..862400986b 100644 --- a/supervisor/port.h +++ b/supervisor/port.h @@ -49,9 +49,6 @@ void reset_cpu(void) NORETURN; // Reset the microcontroller state. void reset_port(void); -// Reset the rest of the board. -void reset_board(void); - // Reset to the bootloader void reset_to_bootloader(void) NORETURN; @@ -89,8 +86,9 @@ void port_disable_tick(void); // Only the common sleep routine should use it. void port_interrupt_after_ticks(uint32_t ticks); -// Sleep the CPU until an interrupt is received. -void port_sleep_until_interrupt(void); +// Sleep the CPU until an interrupt is received. We call this idle because it +// may not be a system level sleep. +void port_idle_until_interrupt(void); // Execute port specific actions during background tasks. void port_background_task(void); @@ -100,4 +98,5 @@ void port_background_task(void); // work" should be done in port_background_task() instead. void port_start_background_task(void); void port_finish_background_task(void); + #endif // MICROPY_INCLUDED_SUPERVISOR_PORT_H diff --git a/supervisor/shared/board.c b/supervisor/shared/board.c index e3eb8fd0d7..111aa0e3c9 100644 --- a/supervisor/shared/board.c +++ b/supervisor/shared/board.c @@ -26,23 +26,22 @@ #include "supervisor/shared/board.h" +#if CIRCUITPY_DIGITALIO && CIRCUITPY_NEOPIXEL_WRITE + +#include + #include "shared-bindings/digitalio/DigitalInOut.h" #include "shared-bindings/neopixel_write/__init__.h" -#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) { +void board_reset_user_neopixels(mcu_pin_obj_t* pin, size_t count) { // Turn off on-board NeoPixel string - uint8_t empty[USER_NEOPIXELS_MAX_COUNT * 3] = { 0 }; + uint8_t empty[count * 3]; + memset(empty, 0, count); digitalio_digitalinout_obj_t neopixel_pin; - common_hal_digitalio_digitalinout_construct(&neopixel_pin, USER_NEOPIXELS_PIN); + common_hal_digitalio_digitalinout_construct(&neopixel_pin, pin); common_hal_digitalio_digitalinout_switch_to_output(&neopixel_pin, false, DRIVE_MODE_PUSH_PULL); - common_hal_neopixel_write(&neopixel_pin, empty, USER_NEOPIXELS_MAX_COUNT * 3); + common_hal_neopixel_write(&neopixel_pin, empty, count * 3); common_hal_digitalio_digitalinout_deinit(&neopixel_pin); } diff --git a/supervisor/shared/board.h b/supervisor/shared/board.h index 0e4d73455d..cdeefbf222 100644 --- a/supervisor/shared/board.h +++ b/supervisor/shared/board.h @@ -24,15 +24,13 @@ * THE SOFTWARE. */ -#ifndef MICROPY_INCLUDED_SUPERVISOR_BOARD_H -#define MICROPY_INCLUDED_SUPERVISOR_BOARD_H +#ifndef MICROPY_INCLUDED_SUPERVISOR_SHARED_BOARD_H +#define MICROPY_INCLUDED_SUPERVISOR_SHARED_BOARD_H -#include "py/mpconfig.h" +#include -#ifdef USER_NEOPIXELS_PIN +#include "shared-bindings/microcontroller/Pin.h" -void board_reset_user_neopixels(void); +void board_reset_user_neopixels(mcu_pin_obj_t* pin, size_t count); -#endif - -#endif // MICROPY_INCLUDED_SUPERVISOR_BOARD_H +#endif // MICROPY_INCLUDED_SUPERVISOR_SHARED_BOARD_H diff --git a/supervisor/shared/tick.c b/supervisor/shared/tick.c index a2855a5706..d37a585eb2 100644 --- a/supervisor/shared/tick.c +++ b/supervisor/shared/tick.c @@ -156,8 +156,8 @@ void mp_hal_delay_ms(mp_uint_t delay) { break; } port_interrupt_after_ticks(remaining); - // Sleep until an interrupt happens. - port_sleep_until_interrupt(); + // Idle until an interrupt happens. + port_idle_until_interrupt(); remaining = end_tick - port_get_raw_ticks(NULL); } } From d0a806d7975ecc2c653d23ee48e463f38b4f1194 Mon Sep 17 00:00:00 2001 From: Scott Shawcroft Date: Tue, 8 Dec 2020 11:03:24 -0800 Subject: [PATCH 205/207] Enter safe mode after panic or brownout Uses the IDF's reset reason. Does nothing before reset. Fixes #3389 --- ports/esp32s2/supervisor/port.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/ports/esp32s2/supervisor/port.c b/ports/esp32s2/supervisor/port.c index 6222cd2904..5a50bda698 100644 --- a/ports/esp32s2/supervisor/port.c +++ b/ports/esp32s2/supervisor/port.c @@ -102,6 +102,14 @@ safe_mode_t port_init(void) { return NO_HEAP; } + esp_reset_reason_t reason = esp_reset_reason(); + if (reason == ESP_RST_BROWNOUT) { + return BROWNOUT; + } + if (reason == ESP_RST_PANIC) { + return HARD_CRASH; + } + return NO_SAFE_MODE; } From 0b4bcd9599cc07ff85d6a70297ae86ff3b02cdec Mon Sep 17 00:00:00 2001 From: Scott Shawcroft Date: Tue, 8 Dec 2020 13:05:21 -0800 Subject: [PATCH 206/207] Fix build and more comments --- main.c | 7 ++++++- ports/atmel-samd/boards/blm_badge/mpconfigboard.h | 2 -- .../boards/circuitplayground_express/mpconfigboard.h | 2 -- .../circuitplayground_express_crickit/mpconfigboard.h | 2 -- .../circuitplayground_express_displayio/mpconfigboard.h | 2 -- ports/atmel-samd/boards/pybadge/mpconfigboard.h | 2 -- ports/atmel-samd/boards/pybadge_airlift/mpconfigboard.h | 2 -- ports/atmel-samd/boards/pygamer/mpconfigboard.h | 2 -- ports/atmel-samd/boards/pygamer_advance/mpconfigboard.h | 2 -- ports/esp32s2/common-hal/alarm/time/TimeAlarm.c | 1 + .../nrf/boards/circuitplayground_bluefruit/mpconfigboard.h | 2 -- supervisor/shared/board.c | 2 +- supervisor/shared/board.h | 2 +- 13 files changed, 9 insertions(+), 21 deletions(-) diff --git a/main.c b/main.c index 9eb4787299..5aa9131a0d 100755 --- a/main.c +++ b/main.c @@ -391,7 +391,7 @@ STATIC bool run_code_py(safe_mode_t safe_mode) { int64_t connecting_delay_ticks = CIRCUITPY_USB_CONNECTED_SLEEP_DELAY * 1024 - port_get_raw_ticks(NULL); if (connecting_delay_ticks > 0) { // Set when we've waited long enough so that we wake up from the - // sleep_until_interrupt below and loop around to the real deep + // port_idle_until_interrupt below and loop around to the real deep // sleep in the else clause. port_interrupt_after_ticks(connecting_delay_ticks); // Deep sleep if we're not connected to a host. @@ -414,6 +414,11 @@ STATIC bool run_code_py(safe_mode_t safe_mode) { if (!asleep) { tick_rgb_status_animation(&animation); } else { + // This waits until a pretend deep sleep alarm occurs. They are set + // during common_hal_alarm_set_deep_sleep_alarms. On some platforms + // it may also return due to another interrupt, that's why we check + // for deep sleep alarms above. If it wasn't a deep sleep alarm, + // then we'll idle here again. port_idle_until_interrupt(); } } diff --git a/ports/atmel-samd/boards/blm_badge/mpconfigboard.h b/ports/atmel-samd/boards/blm_badge/mpconfigboard.h index 4f56d23b0a..7343455b80 100644 --- a/ports/atmel-samd/boards/blm_badge/mpconfigboard.h +++ b/ports/atmel-samd/boards/blm_badge/mpconfigboard.h @@ -13,8 +13,6 @@ #define DEFAULT_UART_BUS_RX (&pin_PA01) #define DEFAULT_UART_BUS_TX (&pin_PA00) -#define USER_NEOPIXELS_PIN (&pin_PA05) - #define IGNORE_PIN_PA09 1 #define IGNORE_PIN_PA12 1 #define IGNORE_PIN_PA13 1 diff --git a/ports/atmel-samd/boards/circuitplayground_express/mpconfigboard.h b/ports/atmel-samd/boards/circuitplayground_express/mpconfigboard.h index 4321335e59..e46e477e4e 100644 --- a/ports/atmel-samd/boards/circuitplayground_express/mpconfigboard.h +++ b/ports/atmel-samd/boards/circuitplayground_express/mpconfigboard.h @@ -30,8 +30,6 @@ // Increase stack size slightly due to CPX library import nesting #define CIRCUITPY_DEFAULT_STACK_SIZE (4248) //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/mpconfigboard.h b/ports/atmel-samd/boards/circuitplayground_express_crickit/mpconfigboard.h index 5673be2909..bc40554217 100644 --- a/ports/atmel-samd/boards/circuitplayground_express_crickit/mpconfigboard.h +++ b/ports/atmel-samd/boards/circuitplayground_express_crickit/mpconfigboard.h @@ -24,8 +24,6 @@ #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 translate("pressing both buttons at start up.\n") diff --git a/ports/atmel-samd/boards/circuitplayground_express_displayio/mpconfigboard.h b/ports/atmel-samd/boards/circuitplayground_express_displayio/mpconfigboard.h index fab235149d..4b0c324faa 100644 --- a/ports/atmel-samd/boards/circuitplayground_express_displayio/mpconfigboard.h +++ b/ports/atmel-samd/boards/circuitplayground_express_displayio/mpconfigboard.h @@ -30,8 +30,6 @@ // Increase stack size slightly due to CPX library import nesting. #define CIRCUITPY_DEFAULT_STACK_SIZE (4248) // 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/pybadge/mpconfigboard.h b/ports/atmel-samd/boards/pybadge/mpconfigboard.h index 74a13eb1c2..435185322a 100644 --- a/ports/atmel-samd/boards/pybadge/mpconfigboard.h +++ b/ports/atmel-samd/boards/pybadge/mpconfigboard.h @@ -14,8 +14,6 @@ #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/mpconfigboard.h b/ports/atmel-samd/boards/pybadge_airlift/mpconfigboard.h index a37d7ceec4..921669d8cb 100644 --- a/ports/atmel-samd/boards/pybadge_airlift/mpconfigboard.h +++ b/ports/atmel-samd/boards/pybadge_airlift/mpconfigboard.h @@ -14,8 +14,6 @@ #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/mpconfigboard.h b/ports/atmel-samd/boards/pygamer/mpconfigboard.h index 21f75d2728..102c259567 100644 --- a/ports/atmel-samd/boards/pygamer/mpconfigboard.h +++ b/ports/atmel-samd/boards/pygamer/mpconfigboard.h @@ -13,8 +13,6 @@ #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/mpconfigboard.h b/ports/atmel-samd/boards/pygamer_advance/mpconfigboard.h index 7c631d1c37..fbe946b72f 100644 --- a/ports/atmel-samd/boards/pygamer_advance/mpconfigboard.h +++ b/ports/atmel-samd/boards/pygamer_advance/mpconfigboard.h @@ -13,8 +13,6 @@ #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/esp32s2/common-hal/alarm/time/TimeAlarm.c b/ports/esp32s2/common-hal/alarm/time/TimeAlarm.c index 34c8b00523..d5e896c015 100644 --- a/ports/esp32s2/common-hal/alarm/time/TimeAlarm.c +++ b/ports/esp32s2/common-hal/alarm/time/TimeAlarm.c @@ -51,6 +51,7 @@ mp_obj_t alarm_time_timealarm_get_wakeup_alarm(size_t n_alarms, const mp_obj_t * } alarm_time_time_alarm_obj_t *timer = m_new_obj(alarm_time_time_alarm_obj_t); timer->base.type = &alarm_time_time_alarm_type; + // TODO: Set monotonic_time based on the RTC state. return timer; } diff --git a/ports/nrf/boards/circuitplayground_bluefruit/mpconfigboard.h b/ports/nrf/boards/circuitplayground_bluefruit/mpconfigboard.h index ef34465dcd..da32230a6f 100644 --- a/ports/nrf/boards/circuitplayground_bluefruit/mpconfigboard.h +++ b/ports/nrf/boards/circuitplayground_bluefruit/mpconfigboard.h @@ -54,8 +54,6 @@ // 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/supervisor/shared/board.c b/supervisor/shared/board.c index 111aa0e3c9..30603aa66c 100644 --- a/supervisor/shared/board.c +++ b/supervisor/shared/board.c @@ -33,7 +33,7 @@ #include "shared-bindings/digitalio/DigitalInOut.h" #include "shared-bindings/neopixel_write/__init__.h" -void board_reset_user_neopixels(mcu_pin_obj_t* pin, size_t count) { +void board_reset_user_neopixels(const mcu_pin_obj_t* pin, size_t count) { // Turn off on-board NeoPixel string uint8_t empty[count * 3]; memset(empty, 0, count); diff --git a/supervisor/shared/board.h b/supervisor/shared/board.h index cdeefbf222..fe887a9335 100644 --- a/supervisor/shared/board.h +++ b/supervisor/shared/board.h @@ -31,6 +31,6 @@ #include "shared-bindings/microcontroller/Pin.h" -void board_reset_user_neopixels(mcu_pin_obj_t* pin, size_t count); +void board_reset_user_neopixels(const mcu_pin_obj_t* pin, size_t count); #endif // MICROPY_INCLUDED_SUPERVISOR_SHARED_BOARD_H From eedcc98cc5379f93704fd344289e2f5c8a60eddd Mon Sep 17 00:00:00 2001 From: Mike Causer Date: Thu, 10 Dec 2020 02:52:18 +1100 Subject: [PATCH 207/207] Fix some spelling mistakes --- docs/design_guide.rst | 8 ++++---- docs/drivers.rst | 2 +- docs/library/hashlib.rst | 4 ++-- docs/library/index.rst | 4 ++-- docs/library/network.rst | 2 +- docs/porting.rst | 2 +- docs/troubleshooting.rst | 4 ++-- main.c | 2 +- shared-bindings/os/__init__.c | 6 +++--- 9 files changed, 17 insertions(+), 17 deletions(-) diff --git a/docs/design_guide.rst b/docs/design_guide.rst index cc2a3b296d..75825893a9 100644 --- a/docs/design_guide.rst +++ b/docs/design_guide.rst @@ -421,7 +421,7 @@ SPI Example """Widget's one register.""" with self.spi_device as spi: spi.write(b'0x00') - i2c.readinto(self.buf) + spi.readinto(self.buf) return self.buf[0] Use composition @@ -462,7 +462,7 @@ like properties for state even if it sacrifices a bit of speed. Avoid allocations in drivers -------------------------------------------------------------------------------- -Although Python doesn't require managing memory, its still a good practice for +Although Python doesn't require managing memory, it's still a good practice for library writers to think about memory allocations. Avoid them in drivers if you can because you never know how much something will be called. Fewer allocations means less time spent cleaning up. So, where you can, prefer @@ -471,7 +471,7 @@ object with methods that read or write into the buffer instead of creating new objects. Unified hardware API classes such as `busio.SPI` are design to read and write to subsections of buffers. -Its ok to allocate an object to return to the user. Just beware of causing more +It's ok to allocate an object to return to the user. Just beware of causing more than one allocation per call due to internal logic. **However**, this is a memory tradeoff so do not do it for large or rarely used @@ -580,4 +580,4 @@ MicroPython compatibility -------------------------------------------------------------------------------- Keeping compatibility with MicroPython isn't a high priority. It should be done -when its not in conflict with any of the above goals. +when it's not in conflict with any of the above goals. diff --git a/docs/drivers.rst b/docs/drivers.rst index 241415cc1c..8855abbd2d 100644 --- a/docs/drivers.rst +++ b/docs/drivers.rst @@ -12,7 +12,7 @@ Adafruit CircuitPython Library Bundle We provide a bundle of all our libraries to ease installation of drivers and their dependencies. The bundle is primarily geared to the Adafruit Express line of boards which feature a relatively large external flash. With Express boards, -its easy to copy them all onto the filesystem. However, if you don't have +it's easy to copy them all onto the filesystem. However, if you don't have enough space simply copy things over as they are needed. - The Adafruit bundles are available on GitHub: . diff --git a/docs/library/hashlib.rst b/docs/library/hashlib.rst index 0205d5e6a8..8e5ebc2d1a 100644 --- a/docs/library/hashlib.rst +++ b/docs/library/hashlib.rst @@ -20,10 +20,10 @@ be implemented: * SHA1 - A previous generation algorithm. Not recommended for new usages, but SHA1 is a part of number of Internet standards and existing applications, so boards targeting network connectivity and - interoperatiability will try to provide this. + interoperability will try to provide this. * MD5 - A legacy algorithm, not considered cryptographically secure. Only - selected boards, targeting interoperatibility with legacy applications, + selected boards, targeting interoperability with legacy applications, will offer this. Constructors diff --git a/docs/library/index.rst b/docs/library/index.rst index f847ead0af..e913872421 100644 --- a/docs/library/index.rst +++ b/docs/library/index.rst @@ -21,7 +21,7 @@ standard Python library. You may need to change your code later if you rely on any non-standard functionality they currently provide. -CircuitPython's goal long-term goalis that code written in CircuitPython +CircuitPython's long-term goal is that code written in CircuitPython using Python standard libraries will be runnable on CPython without changes. Some libraries below are not enabled on CircuitPython builds with @@ -69,7 +69,7 @@ CircuitPython/MicroPython-specific libraries -------------------------------------------- Functionality specific to the CircuitPython/MicroPython implementation is available in -the following libraries. These libraries may change signficantly or be removed in future +the following libraries. These libraries may change significantly or be removed in future versions of CircuitPython. .. toctree:: diff --git a/docs/library/network.rst b/docs/library/network.rst index bd32267fe9..3bd41150d5 100644 --- a/docs/library/network.rst +++ b/docs/library/network.rst @@ -71,7 +71,7 @@ parameter should be `id`. (password) required to access said service. There can be further arbitrary keyword-only parameters, depending on the networking medium type and/or particular device. Parameters can be used to: a) - specify alternative service identifer types; b) provide additional + specify alternative service identifier types; b) provide additional connection parameters. For various medium types, there are different sets of predefined/recommended parameters, among them: diff --git a/docs/porting.rst b/docs/porting.rst index 6cd59fefb1..8d0262455b 100644 --- a/docs/porting.rst +++ b/docs/porting.rst @@ -106,7 +106,7 @@ request a safe mode state which prevents the supervisor from running user code while still allowing access to the REPL and other resources. The core port initialization and reset methods are defined in -``supervisor/port.c`` and should be the first to be implemented. Its required +``supervisor/port.c`` and should be the first to be implemented. It's required that they be implemented in the ``supervisor`` directory within the port directory. That way, they are always in the expected place. diff --git a/docs/troubleshooting.rst b/docs/troubleshooting.rst index 66bcc2764c..45c637f349 100644 --- a/docs/troubleshooting.rst +++ b/docs/troubleshooting.rst @@ -13,7 +13,7 @@ When CircuitPython restarts it will create a fresh empty ``CIRCUITPY`` filesyste This often happens on Windows when the ``CIRCUITPY`` disk is not safely ejected before being reset by the button or being disconnected from USB. This can also -happen on Linux and Mac OSX but its less likely. +happen on Linux and Mac OSX but it's less likely. .. caution:: To erase and re-create ``CIRCUITPY`` (for example, to correct a corrupted filesystem), follow one of the procedures below. It's important to note that **any files stored on the** @@ -43,7 +43,7 @@ ValueError: Incompatible ``.mpy`` file. This error occurs when importing a module that is stored as a ``mpy`` binary file (rather than a ``py`` text file) that was generated by a different version of -CircuitPython than the one its being loaded into. Most versions are compatible +CircuitPython than the one it's being loaded into. Most versions are compatible but, rarely they aren't. In particular, the ``mpy`` binary format changed between CircuitPython versions 1.x and 2.x, and will change again between 2.x and 3.x. diff --git a/main.c b/main.c index 5aa9131a0d..da04ada466 100755 --- a/main.c +++ b/main.c @@ -215,7 +215,7 @@ STATIC bool maybe_run_list(const char * const * filenames, pyexec_result_t* exec STATIC void cleanup_after_vm(supervisor_allocation* heap) { // Reset port-independent devices, like CIRCUITPY_BLEIO_HCI. reset_devices(); - // Turn off the display and flush the fileystem before the heap disappears. + // Turn off the display and flush the filesystem before the heap disappears. #if CIRCUITPY_DISPLAYIO reset_displays(); #endif diff --git a/shared-bindings/os/__init__.c b/shared-bindings/os/__init__.c index c499df9724..8b9b389111 100644 --- a/shared-bindings/os/__init__.c +++ b/shared-bindings/os/__init__.c @@ -160,7 +160,7 @@ mp_obj_t os_stat(mp_obj_t path_in) { MP_DEFINE_CONST_FUN_OBJ_1(os_stat_obj, os_stat); //| def statvfs(path: str) -> Tuple[int, int, int, int, int, int, int, int, int, int]: -//| """Get the status of a fileystem. +//| """Get the status of a filesystem. //| //| Returns a tuple with the filesystem information in the following order: //| @@ -168,10 +168,10 @@ MP_DEFINE_CONST_FUN_OBJ_1(os_stat_obj, os_stat); //| * ``f_frsize`` -- fragment size //| * ``f_blocks`` -- size of fs in f_frsize units //| * ``f_bfree`` -- number of free blocks -//| * ``f_bavail`` -- number of free blocks for unpriviliged users +//| * ``f_bavail`` -- number of free blocks for unprivileged users //| * ``f_files`` -- number of inodes //| * ``f_ffree`` -- number of free inodes -//| * ``f_favail`` -- number of free inodes for unpriviliged users +//| * ``f_favail`` -- number of free inodes for unprivileged users //| * ``f_flag`` -- mount flags //| * ``f_namemax`` -- maximum filename length //|