From e6350ff8341510ccaaf0ae74502bea1040dca27b Mon Sep 17 00:00:00 2001 From: jun2sak Date: Wed, 17 Feb 2021 20:53:18 +0900 Subject: [PATCH 01/67] Initial commit. --- main.c | 3 + ports/nrf/Makefile | 8 + ports/nrf/common-hal/alarm/SleepMemory.c | 48 ++++ ports/nrf/common-hal/alarm/SleepMemory.h | 41 +++ ports/nrf/common-hal/alarm/__init__.c | 204 ++++++++++++++ ports/nrf/common-hal/alarm/__init__.h | 45 +++ ports/nrf/common-hal/alarm/pin/PinAlarm.c | 260 ++++++++++++++++++ ports/nrf/common-hal/alarm/pin/PinAlarm.h | 41 +++ ports/nrf/common-hal/alarm/pin/__init__.c | 38 +++ ports/nrf/common-hal/alarm/time/TimeAlarm.c | 101 +++++++ ports/nrf/common-hal/alarm/time/TimeAlarm.h | 40 +++ ports/nrf/common-hal/alarm/touch/TouchAlarm.c | 185 +++++++++++++ ports/nrf/common-hal/alarm/touch/TouchAlarm.h | 46 ++++ ports/nrf/mpconfigport.mk | 3 + ports/nrf/nrfx_config.h | 2 +- ports/nrf/supervisor/port.c | 43 ++- supervisor/serial.h | 3 + supervisor/shared/serial.c | 110 ++++++++ 18 files changed, 1218 insertions(+), 3 deletions(-) create mode 100644 ports/nrf/common-hal/alarm/SleepMemory.c create mode 100644 ports/nrf/common-hal/alarm/SleepMemory.h create mode 100644 ports/nrf/common-hal/alarm/__init__.c create mode 100644 ports/nrf/common-hal/alarm/__init__.h create mode 100644 ports/nrf/common-hal/alarm/pin/PinAlarm.c create mode 100644 ports/nrf/common-hal/alarm/pin/PinAlarm.h create mode 100644 ports/nrf/common-hal/alarm/pin/__init__.c create mode 100644 ports/nrf/common-hal/alarm/time/TimeAlarm.c create mode 100644 ports/nrf/common-hal/alarm/time/TimeAlarm.h create mode 100644 ports/nrf/common-hal/alarm/touch/TouchAlarm.c create mode 100644 ports/nrf/common-hal/alarm/touch/TouchAlarm.h diff --git a/main.c b/main.c index 7bfa565df4..054c6b4f53 100755 --- a/main.c +++ b/main.c @@ -214,6 +214,7 @@ STATIC bool maybe_run_list(const char * const * filenames, pyexec_result_t* exec decompress(compressed, decompressed); mp_hal_stdout_tx_str(decompressed); pyexec_file(filename, exec_result); + dbg_printf("pyexec_file end result=(code=%d, line=%d)\r\n", exec_result->return_code, exec_result->exception_line); return true; } @@ -259,6 +260,7 @@ STATIC void print_code_py_status_message(safe_mode_t safe_mode) { } STATIC bool run_code_py(safe_mode_t safe_mode) { + dbg_printf("run_code_py (%d)\r\n", (int)safe_mode); bool serial_connected_at_start = serial_connected(); #if CIRCUITPY_AUTORELOAD_DELAY_MS > 0 serial_write("\n"); @@ -434,6 +436,7 @@ STATIC bool run_code_py(safe_mode_t safe_mode) { FIL* boot_output_file; STATIC void __attribute__ ((noinline)) run_boot_py(safe_mode_t safe_mode) { + dbg_printf("run_boot_py (%d)\r\n", (int)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) { diff --git a/ports/nrf/Makefile b/ports/nrf/Makefile index 278625e92d..c78a5dc503 100755 --- a/ports/nrf/Makefile +++ b/ports/nrf/Makefile @@ -87,6 +87,7 @@ INC += -I../../supervisor/shared/usb #Debugging/Optimization ifeq ($(DEBUG), 1) CFLAGS += -ggdb3 + CFLAGS += -DNDEBUG OPTIMIZATION_FLAGS = -Og else OPTIMIZATION_FLAGS ?= -O2 -fno-inline-functions @@ -94,6 +95,13 @@ else CFLAGS += -flto -flto-partition=none endif +ifeq ($(MY_DBG), 1) + CFLAGS += -DMY_DBG +endif +ifeq ($(MY_DEBUGUART), 1) + CFLAGS += -DMY_DEBUGUART=1 +endif + # option to override compiler optimization level, set in boards/$(BOARD)/mpconfigboard.mk CFLAGS += $(OPTIMIZATION_FLAGS) diff --git a/ports/nrf/common-hal/alarm/SleepMemory.c b/ports/nrf/common-hal/alarm/SleepMemory.c new file mode 100644 index 0000000000..dd87b31b17 --- /dev/null +++ b/ports/nrf/common-hal/alarm/SleepMemory.c @@ -0,0 +1,48 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2020 microDev + * 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 + +#include "py/runtime.h" +#include "common-hal/alarm/SleepMemory.h" + +//static RTC_DATA_ATTR uint8_t _sleep_mem[SLEEP_MEMORY_LENGTH]; + +void alarm_sleep_memory_reset(void) { +} + +uint32_t common_hal_alarm_sleep_memory_get_length(alarm_sleep_memory_obj_t *self) { + return 0; +} + +bool common_hal_alarm_sleep_memory_set_bytes(alarm_sleep_memory_obj_t *self, uint32_t start_index, const uint8_t* values, uint32_t len) { + return false; +} + +void common_hal_alarm_sleep_memory_get_bytes(alarm_sleep_memory_obj_t *self, uint32_t start_index, uint8_t* values, uint32_t len) { + return; +} diff --git a/ports/nrf/common-hal/alarm/SleepMemory.h b/ports/nrf/common-hal/alarm/SleepMemory.h new file mode 100644 index 0000000000..ea3d40c35a --- /dev/null +++ b/ports/nrf/common-hal/alarm/SleepMemory.h @@ -0,0 +1,41 @@ +/* + * 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_NRF_COMMON_HAL_ALARM_SLEEPMEMORY_H +#define MICROPY_INCLUDED_NRF_COMMON_HAL_ALARM_SLEEPMEMORY_H + +#include "py/obj.h" + +// not implemented yet +#define SLEEP_MEMORY_LENGTH (4) + +typedef struct { + mp_obj_base_t base; +} alarm_sleep_memory_obj_t; + +extern void alarm_sleep_memory_reset(void); + +#endif // MICROPY_INCLUDED_NRF_COMMON_HAL_ALARM_SLEEPMEMORY_H diff --git a/ports/nrf/common-hal/alarm/__init__.c b/ports/nrf/common-hal/alarm/__init__.c new file mode 100644 index 0000000000..d5a4aec3c8 --- /dev/null +++ b/ports/nrf/common-hal/alarm/__init__.c @@ -0,0 +1,204 @@ +/* + * 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 + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION 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/gc.h" +#include "py/obj.h" +#include "py/objtuple.h" +#include "py/runtime.h" +#include +#include + +#include "shared-bindings/alarm/__init__.h" +#include "shared-bindings/alarm/SleepMemory.h" +#include "shared-bindings/alarm/pin/PinAlarm.h" +#include "shared-bindings/alarm/time/TimeAlarm.h" +#include "shared-bindings/alarm/touch/TouchAlarm.h" + +//#include "shared-bindings/wifi/__init__.h" +//#include "shared-bindings/microcontroller/__init__.h" + +#include "supervisor/port.h" + +#include "nrf.h" +#include "nrf_power.h" +#include "nrfx.h" +#include "nrfx_gpiote.h" + +extern void _debug_print(const char* s); +extern void _xxx_dumpRTC(void);//XXXX + +#define DEBUG_LED_PIN (NRF_GPIO_PIN_MAP(1, 11)) // P1_11 = LED +void _debug_led_init(void) { + nrf_gpio_cfg_output(DEBUG_LED_PIN); +} +void _debug_led_set(int v) { + nrf_gpio_pin_write(DEBUG_LED_PIN, v); +} + + +// Singleton instance of SleepMemory. +const alarm_sleep_memory_obj_t alarm_sleep_memory_obj = { + .base = { + .type = &alarm_sleep_memory_type, + }, +}; + +void alarm_reset(void) { + //alarm_sleep_memory_reset(); + alarm_pin_pinalarm_reset(); + alarm_time_timealarm_reset(); + //alarm_touch_touchalarm_reset(); +} + +extern uint32_t reset_reason_saved; +STATIC uint32_t _get_wakeup_cause(void) { + if (alarm_pin_pinalarm_woke_us_up()) { + return NRF_SLEEP_WAKEUP_GPIO; + } + if (alarm_time_timealarm_woke_us_up()) { + return NRF_SLEEP_WAKEUP_TIMER; + } +#if 0 + if (alarm_touch_touchalarm_woke_us_up()) { + return ESP_SLEEP_WAKEUP_TOUCHPAD; + } + return esp_sleep_get_wakeup_cause(); +#endif + if (reset_reason_saved & NRF_POWER_RESETREAS_RESETPIN_MASK) { + return NRF_SLEEP_WAKEUP_RESETPIN; + } + else if (reset_reason_saved & NRF_POWER_RESETREAS_OFF_MASK) { + return NRF_SLEEP_WAKEUP_GPIO; + } + else if (reset_reason_saved & NRF_POWER_RESETREAS_VBUS_MASK) { + return NRF_SLEEP_WAKEUP_VBUS; + } + return NRF_SLEEP_WAKEUP_UNDEFINED; +} + +bool alarm_woken_from_sleep(void) { + uint32_t cause = _get_wakeup_cause(); + return (cause == NRF_SLEEP_WAKEUP_GPIO || cause == NRF_SLEEP_WAKEUP_TIMER + || cause == NRF_SLEEP_WAKEUP_TOUCHPAD + || cause == NRF_SLEEP_WAKEUP_RESETPIN); +} + +STATIC mp_obj_t _get_wake_alarm(size_t n_alarms, const mp_obj_t *alarms) { + uint32_t cause = _get_wakeup_cause(); + if (cause & 0x80000000) { + printf("wakeup cause = 0x%08X\r\n", (int)cause); + } + switch (cause) { + case NRF_SLEEP_WAKEUP_TIMER: { + return alarm_time_timealarm_get_wakeup_alarm(n_alarms, alarms); + } + case NRF_SLEEP_WAKEUP_TOUCHPAD: { + return mp_const_none; + } + case NRF_SLEEP_WAKEUP_GPIO: { + return alarm_pin_pinalarm_get_wakeup_alarm(n_alarms, alarms); + } + } + return mp_const_none; +} + +mp_obj_t common_hal_alarm_get_wake_alarm(void) { + mp_obj_t obj = _get_wake_alarm(0, NULL); + //_xxx_dumpRTC();//XXX + return obj; +} + +// Set up light sleep or deep sleep alarms. +STATIC void _setup_sleep_alarms(bool deep_sleep, size_t n_alarms, const mp_obj_t *alarms) { + alarm_pin_pinalarm_set_alarms(deep_sleep, n_alarms, alarms); + alarm_time_timealarm_set_alarms(deep_sleep, n_alarms, alarms); +#if 0 + alarm_touch_touchalarm_set_alarm(deep_sleep, n_alarms, alarms); +#endif + //_xxx_dumpRTC(); +} + +STATIC void _idle_until_alarm(void) { + int ct = 40; + // Poll for alarms. + while (!mp_hal_is_interrupted()) { + RUN_BACKGROUND_TASKS; + // Allow ctrl-C interrupt. + if (alarm_woken_from_sleep()) { + alarm_save_wake_alarm(); + int cause = _get_wakeup_cause(); + printf("wakeup(%d)\r\n", cause); //XXX + return; + } + port_idle_until_interrupt(); + if (ct > 0) { + printf("_"); --ct; + } + } +} + +mp_obj_t common_hal_alarm_light_sleep_until_alarms(size_t n_alarms, const mp_obj_t *alarms) { + mp_obj_t r_obj = mp_const_none; + _setup_sleep_alarms(false, n_alarms, alarms); + _debug_print("\r\nsleep..."); + + _idle_until_alarm(); + + if (mp_hal_is_interrupted()) { + _debug_print("mp_hal_is_interrupted\r\n"); + r_obj = mp_const_none; + } + else { + r_obj = _get_wake_alarm(n_alarms, alarms); + alarm_reset(); + } + return r_obj; +} + +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 nrf_deep_sleep_start(void) { + _debug_print("go system off..\r\n"); + sd_power_system_off(); +} + +void NORETURN alarm_enter_deep_sleep(void) { + alarm_pin_pinalarm_prepare_for_deep_sleep(); + //alarm_touch_touchalarm_prepare_for_deep_sleep(); + + nrf_deep_sleep_start(); + + // should not reach here.. + while(1) ; +} + +void common_hal_alarm_gc_collect(void) { + void* p = alarm_get_wake_alarm(); + gc_collect_ptr(p); +} diff --git a/ports/nrf/common-hal/alarm/__init__.h b/ports/nrf/common-hal/alarm/__init__.h new file mode 100644 index 0000000000..11652ec828 --- /dev/null +++ b/ports/nrf/common-hal/alarm/__init__.h @@ -0,0 +1,45 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2020 Dan Halbert for Adafruit Industries. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#ifndef MICROPY_INCLUDED_NRF_COMMON_HAL_ALARM__INIT__H +#define MICROPY_INCLUDED_NRF_COMMON_HAL_ALARM__INIT__H + +#include "common-hal/alarm/SleepMemory.h" + +typedef enum { + NRF_SLEEP_WAKEUP_UNDEFINED, + NRF_SLEEP_WAKEUP_GPIO, + NRF_SLEEP_WAKEUP_TIMER, + NRF_SLEEP_WAKEUP_TOUCHPAD, + NRF_SLEEP_WAKEUP_VBUS, + NRF_SLEEP_WAKEUP_RESETPIN, +} nrf_sleep_source_t; + +extern const alarm_sleep_memory_obj_t alarm_sleep_memory_obj; + +extern void alarm_reset(void); + +#endif // MICROPY_INCLUDED_NRF_COMMON_HAL_ALARM__INIT__H diff --git a/ports/nrf/common-hal/alarm/pin/PinAlarm.c b/ports/nrf/common-hal/alarm/pin/PinAlarm.c new file mode 100644 index 0000000000..0e0f6c4832 --- /dev/null +++ b/ports/nrf/common-hal/alarm/pin/PinAlarm.c @@ -0,0 +1,260 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2020 Dan Halbert for Adafruit Industries + * 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/runtime.h" +#include + +#include "shared-bindings/alarm/pin/PinAlarm.h" +#include "shared-bindings/microcontroller/__init__.h" +#include "shared-bindings/microcontroller/Pin.h" + +#include "nrfx.h" +#include "nrf_gpio.h" +#include "nrfx_gpiote.h" +#include "nrf_soc.h" +#include + +#include "supervisor/serial.h" // dbg_print + +#define WPIN_UNUSED 0xFF +volatile char _pinhandler_gpiote_count; +volatile nrfx_gpiote_pin_t _pinhandler_ev_pin; +#define MYGPIOTE_EV_PIN_UNDEF 0xFF + +void common_hal_alarm_pin_pinalarm_construct(alarm_pin_pinalarm_obj_t *self, mcu_pin_obj_t *pin, bool value, bool edge, bool pull) { +#if 0 + if (edge) { + mp_raise_ValueError(translate("Cannot wake on pin edge. Only level.")); + } + + if (pull && !GPIO_IS_VALID_OUTPUT_GPIO(pin->number)) { + mp_raise_ValueError(translate("Cannot pull on input-only pin.")); + } +#endif + self->pin = pin; + self->value = value; + self->pull = pull; +} + +mcu_pin_obj_t *common_hal_alarm_pin_pinalarm_get_pin(alarm_pin_pinalarm_obj_t *self) { + return self->pin; +} + +bool common_hal_alarm_pin_pinalarm_get_value(alarm_pin_pinalarm_obj_t *self) { + return self->value; +} + +bool common_hal_alarm_pin_pinalarm_get_edge(alarm_pin_pinalarm_obj_t *self) { + return false; +} + +bool common_hal_alarm_pin_pinalarm_get_pull(alarm_pin_pinalarm_obj_t *self) { + return self->pull; +} + + +static void pinalarm_gpiote_handler(nrfx_gpiote_pin_t pin, nrf_gpiote_polarity_t action) { + ++_pinhandler_gpiote_count; + _pinhandler_ev_pin = pin; +} + +bool alarm_pin_pinalarm_woke_us_up(void) { + return (_pinhandler_gpiote_count > 0 && _pinhandler_ev_pin != MYGPIOTE_EV_PIN_UNDEF); +} + +mp_obj_t alarm_pin_pinalarm_get_wakeup_alarm(size_t n_alarms, const mp_obj_t *alarms) { + // First, check to see if we match any given alarms. + for (size_t i = 0; i < n_alarms; i++) { + if (!MP_OBJ_IS_TYPE(alarms[i], &alarm_pin_pinalarm_type)) { + continue; + } + alarm_pin_pinalarm_obj_t *alarm = MP_OBJ_TO_PTR(alarms[i]); + if (alarm->pin->number == _pinhandler_ev_pin) { + return alarms[i]; + } + } + + alarm_pin_pinalarm_obj_t *alarm = m_new_obj(alarm_pin_pinalarm_obj_t); + alarm->base.type = &alarm_pin_pinalarm_type; + alarm->pin = NULL; + // Map the pin number back to a pin object. + for (size_t i = 0; i < mcu_pin_globals.map.used; i++) { + const mcu_pin_obj_t* pin_obj = MP_OBJ_TO_PTR(mcu_pin_globals.map.table[i].value); + if ((size_t) pin_obj->number == _pinhandler_ev_pin) { + alarm->pin = mcu_pin_globals.map.table[i].value; + break; + } + } + return alarm; +} + +// These must be static because we need to configure pulls later, right before +// deep sleep. +static uint64_t high_alarms = 0; +static uint64_t low_alarms = 0; +static uint64_t pull_pins = 0; + +void alarm_pin_pinalarm_reset(void) { + for (size_t i = 0; i < 64; i++) { + uint64_t mask = 1ull << i; + bool high = (high_alarms & mask) != 0; + bool low = (low_alarms & mask) != 0; + if (!(high || low)) { + continue; + } + reset_pin_number(i); + nrfx_gpiote_in_event_disable((nrfx_gpiote_pin_t)i); + nrfx_gpiote_in_uninit((nrfx_gpiote_pin_t)i); + } + + high_alarms = 0; + low_alarms = 0; + pull_pins = 0; +} + +void _setup2(void) { + nrfx_gpiote_in_config_t cfg = { + .sense = NRF_GPIOTE_POLARITY_TOGGLE, + .pull = NRF_GPIO_PIN_PULLUP, + .is_watcher = false, + .hi_accuracy = true, + .skip_gpio_setup = false + }; + for(size_t i = 0; i < 64; ++i) { + uint64_t mask = 1ull << i; + int pull = 0; + int sense = 0; + if (((high_alarms & mask) == 0) && ((low_alarms & mask) == 0)) { + continue; + } + if (((high_alarms & mask) != 0) && ((low_alarms & mask) == 0)) { + cfg.sense = NRF_GPIOTE_POLARITY_LOTOHI; + cfg.pull = ((pull_pins & mask) != 0) ? NRF_GPIO_PIN_PULLDOWN : NRF_GPIO_PIN_NOPULL; + pull = -1; sense = 1; + } + else + if (((high_alarms & mask) == 0) && ((low_alarms & mask) != 0)) { + cfg.sense = NRF_GPIOTE_POLARITY_HITOLO; + cfg.pull = ((pull_pins & mask) != 0) ? NRF_GPIO_PIN_PULLUP : NRF_GPIO_PIN_NOPULL; + pull = 1; sense = -1; + } + else { + cfg.sense = NRF_GPIOTE_POLARITY_TOGGLE; + cfg.pull = NRF_GPIO_PIN_NOPULL; + sense = 9; + } + nrfx_gpiote_in_init((nrfx_gpiote_pin_t)i, &cfg, pinalarm_gpiote_handler); + nrfx_gpiote_in_event_enable((nrfx_gpiote_pin_t)i, true); + printf("pin=%d, sense=%d, pull=%d\r\n", i, sense, pull); + } +} + +void _setup_pin1_for_lightsleep(void) { + if ( nrfx_gpiote_is_init() ) { + nrfx_gpiote_uninit(); + } + nrfx_gpiote_init(NRFX_GPIOTE_CONFIG_IRQ_PRIORITY); + + _pinhandler_gpiote_count = 0; + _pinhandler_ev_pin = MYGPIOTE_EV_PIN_UNDEF; + _setup2(); +} + +void _setup_pin1_for_deepsleep(void) { + for(size_t i = 0; i < 64; ++i) { + uint64_t mask = 1ull << i; + int pull = 0; + int sense = 0; + if (((high_alarms & mask) == 0) && ((low_alarms & mask) == 0)) { + continue; + } + if (((high_alarms & mask) != 0) && ((low_alarms & mask) == 0)) { + pull = ((pull_pins & mask) != 0) ? NRF_GPIO_PIN_PULLDOWN : NRF_GPIO_PIN_NOPULL; + nrf_gpio_cfg_input((uint32_t)i, (nrf_gpio_pin_pull_t)pull); + nrf_gpio_cfg_sense_set((uint32_t)i, NRF_GPIO_PIN_SENSE_HIGH); + sense = NRF_GPIO_PIN_SENSE_HIGH; + } + else + if (((high_alarms & mask) == 0) && ((low_alarms & mask) != 0)) { + pull = ((pull_pins & mask) != 0) ? NRF_GPIO_PIN_PULLUP : NRF_GPIO_PIN_NOPULL; + nrf_gpio_cfg_input((uint32_t)i, (nrf_gpio_pin_pull_t)pull); + nrf_gpio_cfg_sense_set((uint32_t)i, NRF_GPIO_PIN_SENSE_LOW); + sense = NRF_GPIO_PIN_SENSE_LOW; + } + printf("pin=%d, sense=%d, pull=%d\r\n", i, sense, pull); + } +#if 0 + uint32_t pin_number = 2; + NRF_GPIO_Type * reg = nrf_gpio_pin_port_decode(&pin_number); + dbg_printf(" 2 PIN_CNF=0x%08X\r\n", (unsigned int)(reg->PIN_CNF[pin_number])); + pin_number = 28; + reg = nrf_gpio_pin_port_decode(&pin_number); + dbg_printf("28 PIN_CNF=0x%08X\r\n", (unsigned int)(reg->PIN_CNF[pin_number])); +#endif +} + +void alarm_pin_pinalarm_set_alarms(bool deep_sleep, size_t n_alarms, const mp_obj_t *alarms) { + // Bitmask of wake up settings. + size_t high_count = 0; + size_t low_count = 0; + int pin_number = -1; + + for (size_t i = 0; i < n_alarms; i++) { + if (!MP_OBJ_IS_TYPE(alarms[i], &alarm_pin_pinalarm_type)) { + continue; + } + alarm_pin_pinalarm_obj_t *alarm = MP_OBJ_TO_PTR(alarms[i]); + + pin_number = alarm->pin->number; + dbg_printf("alarm_pin_pinalarm_set_alarms(pin#=%d, val=%d, pull=%d)\r\n", pin_number, alarm->value, alarm->pull); + if (alarm->value) { + high_alarms |= 1ull << pin_number; + high_count++; + } else { + low_alarms |= 1ull << pin_number; + low_count++; + } + if (alarm->pull) { + pull_pins |= 1ull << pin_number; + } + } + if (pin_number != -1) { + if (!deep_sleep) { + _setup_pin1_for_lightsleep(); + } + else { + //_setup_pin1_for_deepsleep(pin_number); + } + } + else { + dbg_printf("alarm_pin_pinalarm_set_alarms() no valid pins\r\n"); + } +} + +void alarm_pin_pinalarm_prepare_for_deep_sleep(void) { + _setup_pin1_for_deepsleep(); +} diff --git a/ports/nrf/common-hal/alarm/pin/PinAlarm.h b/ports/nrf/common-hal/alarm/pin/PinAlarm.h new file mode 100644 index 0000000000..93672c1f2d --- /dev/null +++ b/ports/nrf/common-hal/alarm/pin/PinAlarm.h @@ -0,0 +1,41 @@ +/* + * 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/objtuple.h" + +typedef struct { + mp_obj_base_t base; + mcu_pin_obj_t *pin; + bool value; + bool pull; +} alarm_pin_pinalarm_obj_t; + +void alarm_pin_pinalarm_reset(void); +void alarm_pin_pinalarm_set_alarms(bool deep_sleep, size_t n_alarms, const mp_obj_t *alarms); +void alarm_pin_pinalarm_prepare_for_deep_sleep(void); +mp_obj_t alarm_pin_pinalarm_get_wakeup_alarm(size_t n_alarms, const mp_obj_t *alarms); +bool alarm_pin_pinalarm_woke_us_up(void); diff --git a/ports/nrf/common-hal/alarm/pin/__init__.c b/ports/nrf/common-hal/alarm/pin/__init__.c new file mode 100644 index 0000000000..d2ce00a3e3 --- /dev/null +++ b/ports/nrf/common-hal/alarm/pin/__init__.c @@ -0,0 +1,38 @@ +//#include "shared-bindings/alarm_io/__init__.h" + +//#include "esp_sleep.h" +//#include "driver/rtc_io.h" + +mp_obj_t common_hal_alarm_io_pin_state (alarm_io_obj_t *self_in) { +#if 0 + if (!rtc_gpio_is_valid_gpio(self_in->gpio)) { + 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")); + case ESP_ERR_INVALID_STATE: + mp_raise_RuntimeError(translate("wakeup conflict")); + default: + break; + } + + if (self_in->pull) { (self_in->level) ? rtc_gpio_pulldown_en(self_in->gpio) : rtc_gpio_pullup_en(self_in->gpio); } +#endif + return self_in; +} + +void common_hal_alarm_io_disable (void) { +#if 0 + esp_sleep_disable_wakeup_source(ESP_SLEEP_WAKEUP_EXT0 | ESP_SLEEP_WAKEUP_EXT1); +#endif +} diff --git a/ports/nrf/common-hal/alarm/time/TimeAlarm.c b/ports/nrf/common-hal/alarm/time/TimeAlarm.c new file mode 100644 index 0000000000..220ed2f4df --- /dev/null +++ b/ports/nrf/common-hal/alarm/time/TimeAlarm.c @@ -0,0 +1,101 @@ +/* + * 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 "esp_sleep.h" + +#include "py/runtime.h" +//#include "supervisor/esp_port.h" +#include + +#include "shared-bindings/alarm/time/TimeAlarm.h" +#include "shared-bindings/time/__init__.h" + +void common_hal_alarm_time_timealarm_construct(alarm_time_timealarm_obj_t *self, mp_float_t monotonic_time) { + self->monotonic_time = monotonic_time; +} + +mp_float_t common_hal_alarm_time_timealarm_get_monotonic_time(alarm_time_timealarm_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_timealarm_type)) { + return alarms[i]; + } + } + alarm_time_timealarm_obj_t *timer = m_new_obj(alarm_time_timealarm_obj_t); + timer->base.type = &alarm_time_timealarm_type; + // TODO: Set monotonic_time based on the RTC state. + timer->monotonic_time = 0.0f; + return timer; +} + +extern volatile int rtc_woke_up_counter; +bool alarm_time_timealarm_woke_us_up(void) { + return rtc_woke_up_counter; +} + +extern void port_disable_interrupt_after_ticks_ch(uint32_t channel); +void alarm_time_timealarm_reset(void) { + port_disable_interrupt_after_ticks_ch(1); + rtc_woke_up_counter = 0; +} + +extern void port_interrupt_after_ticks_ch(uint32_t channel, uint32_t ticks);//XXX in port.c + +void alarm_time_timealarm_set_alarms(bool deep_sleep, size_t n_alarms, const mp_obj_t *alarms) { + bool timealarm_set = false; + alarm_time_timealarm_obj_t *timealarm = MP_OBJ_NULL; + + for (size_t i = 0; i < n_alarms; i++) { + if (!MP_OBJ_IS_TYPE(alarms[i], &alarm_time_timealarm_type)) { + continue; + } + if (timealarm_set) { + mp_raise_ValueError(translate("Only one alarm.time alarm can be set.")); + } + timealarm = MP_OBJ_TO_PTR(alarms[i]); + timealarm_set = true; + } + if (!timealarm_set) { + return; + } + + // 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, timealarm->monotonic_time - now_secs); + int wsecs = (int)(wakeup_in_secs); + if (wsecs > 510) { //XXX + mp_raise_ValueError(translate("Alarm time is too far.")); + } + + uint32_t wakeup_in_ticks = (uint32_t)(wakeup_in_secs * 1024.0f); + //printf("alarm_time_timealarm_set_alarms() %d secs 0x%08X ticks\r\n", wsecs, (int)wakeup_in_ticks); + port_interrupt_after_ticks_ch(1, wakeup_in_ticks); + rtc_woke_up_counter = 0; +} diff --git a/ports/nrf/common-hal/alarm/time/TimeAlarm.h b/ports/nrf/common-hal/alarm/time/TimeAlarm.h new file mode 100644 index 0000000000..dfd75524fd --- /dev/null +++ b/ports/nrf/common-hal/alarm/time/TimeAlarm.h @@ -0,0 +1,40 @@ +/* + * 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; + mp_float_t monotonic_time; // values compatible with time.monotonic_time() +} alarm_time_timealarm_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_alarms(bool deep_sleep, size_t n_alarms, const mp_obj_t *alarms); +void alarm_time_timealarm_reset(void); diff --git a/ports/nrf/common-hal/alarm/touch/TouchAlarm.c b/ports/nrf/common-hal/alarm/touch/TouchAlarm.c new file mode 100644 index 0000000000..4db178c56e --- /dev/null +++ b/ports/nrf/common-hal/alarm/touch/TouchAlarm.c @@ -0,0 +1,185 @@ +/* + * 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/alarm/touch/TouchAlarm.h" +#include "shared-bindings/microcontroller/__init__.h" + +//#include "esp_sleep.h" +//#include "peripherals/touch.h" +//#include "supervisor/esp_port.h" + +static uint16_t touch_channel_mask; +static volatile bool woke_up = false; + +void common_hal_alarm_touch_touchalarm_construct(alarm_touch_touchalarm_obj_t *self, const mcu_pin_obj_t *pin) { +#if 0 + if (pin->touch_channel == TOUCH_PAD_MAX) { + mp_raise_ValueError(translate("Invalid pin")); + } + claim_pin(pin); +#endif + self->pin = pin; +} + +mp_obj_t alarm_touch_touchalarm_get_wakeup_alarm(const size_t n_alarms, const mp_obj_t *alarms) { + // First, check to see if we match any given alarms. + for (size_t i = 0; i < n_alarms; i++) { + if (MP_OBJ_IS_TYPE(alarms[i], &alarm_touch_touchalarm_type)) { + return alarms[i]; + } + } + + // Create TouchAlarm object. + alarm_touch_touchalarm_obj_t *alarm = m_new_obj(alarm_touch_touchalarm_obj_t); + alarm->base.type = &alarm_touch_touchalarm_type; + alarm->pin = NULL; +#if 0 + touch_pad_t wake_channel = touch_pad_get_current_meas_channel(); + if (wake_channel == TOUCH_PAD_MAX) { + return alarm; + } + + // Map the pin number back to a pin object. + for (size_t i = 0; i < mcu_pin_globals.map.used; i++) { + const mcu_pin_obj_t* pin_obj = MP_OBJ_TO_PTR(mcu_pin_globals.map.table[i].value); + if (pin_obj->touch_channel == wake_channel) { + alarm->pin = mcu_pin_globals.map.table[i].value; + break; + } + } +#endif + return alarm; +} + +// This is used to wake the main CircuitPython task. +void touch_interrupt(void *arg) { + (void) arg; +#if 0 + woke_up = true; + BaseType_t task_wakeup; + vTaskNotifyGiveFromISR(circuitpython_task, &task_wakeup); + if (task_wakeup) { + portYIELD_FROM_ISR(); + } +#endif +} + +void alarm_touch_touchalarm_set_alarm(const bool deep_sleep, const size_t n_alarms, const mp_obj_t *alarms) { +#if 0 + bool touch_alarm_set = false; + alarm_touch_touchalarm_obj_t *touch_alarm = MP_OBJ_NULL; + + for (size_t i = 0; i < n_alarms; i++) { + if (MP_OBJ_IS_TYPE(alarms[i], &alarm_touch_touchalarm_type)) { + if (deep_sleep && touch_alarm_set) { + mp_raise_ValueError(translate("Only one TouchAlarm can be set in deep sleep.")); + } + touch_alarm = MP_OBJ_TO_PTR(alarms[i]); + touch_channel_mask |= 1 << touch_alarm->pin->number; + touch_alarm_set = true; + } + } + + if (!touch_alarm_set) { + return; + } + + // configure interrupt for pretend to deep sleep + // this will be disabled if we actually deep sleep + + // reset touch peripheral + peripherals_touch_reset(); + peripherals_touch_never_reset(true); + + for (uint8_t i = 1; i <= 14; i++) { + if ((touch_channel_mask & 1 << i) != 0) { + touch_pad_t touch_channel = (touch_pad_t)i; + // intialize touchpad + peripherals_touch_init(touch_channel); + + // wait for touch data to reset + mp_hal_delay_ms(10); + + // configure trigger threshold + uint32_t touch_value; + touch_pad_read_benchmark(touch_channel, &touch_value); + touch_pad_set_thresh(touch_channel, touch_value * 0.1); //10% + } + } + + // configure touch interrupt + touch_pad_timeout_set(true, SOC_TOUCH_PAD_THRESHOLD_MAX); + touch_pad_isr_register(touch_interrupt, NULL, TOUCH_PAD_INTR_MASK_ALL); + touch_pad_intr_enable(TOUCH_PAD_INTR_MASK_ACTIVE | TOUCH_PAD_INTR_MASK_INACTIVE); +} + +void alarm_touch_touchalarm_prepare_for_deep_sleep(void) { + if (!touch_channel_mask) { + return; + } + + touch_pad_t touch_channel = TOUCH_PAD_MAX; + for (uint8_t i = 1; i <= 14; i++) { + if ((touch_channel_mask & 1 << i) != 0) { + touch_channel = (touch_pad_t)i; + break; + } + } + + // reset touch peripheral + peripherals_touch_never_reset(false); + peripherals_touch_reset(); + + // intialize touchpad + peripherals_touch_init(touch_channel); + + // configure touchpad for sleep + touch_pad_sleep_channel_enable(touch_channel, true); + touch_pad_sleep_channel_enable_proximity(touch_channel, false); + + // wait for touch data to reset + mp_hal_delay_ms(10); + + // configure trigger threshold + uint32_t touch_value; + touch_pad_sleep_channel_read_smooth(touch_channel, &touch_value); + touch_pad_sleep_set_threshold(touch_channel, touch_value * 0.1); //10% + + // enable touchpad wakeup + esp_sleep_enable_touchpad_wakeup(); + esp_sleep_pd_config(ESP_PD_DOMAIN_RTC_PERIPH, ESP_PD_OPTION_ON); +#endif +} + +bool alarm_touch_touchalarm_woke_us_up(void) { + return woke_up; +} + +void alarm_touch_touchalarm_reset(void) { + woke_up = false; + touch_channel_mask = 0; +// peripherals_touch_never_reset(false); +} diff --git a/ports/nrf/common-hal/alarm/touch/TouchAlarm.h b/ports/nrf/common-hal/alarm/touch/TouchAlarm.h new file mode 100644 index 0000000000..755a3977ad --- /dev/null +++ b/ports/nrf/common-hal/alarm/touch/TouchAlarm.h @@ -0,0 +1,46 @@ +/* + * 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_COMMON_HAL_ALARM_TOUCH_TOUCHALARM_H +#define MICROPY_INCLUDED_COMMON_HAL_ALARM_TOUCH_TOUCHALARM_H + +#include "py/obj.h" +#include "common-hal/microcontroller/Pin.h" + +typedef struct { + mp_obj_base_t base; + const mcu_pin_obj_t *pin; +} alarm_touch_touchalarm_obj_t; + +// Find the alarm object that caused us to wake up or create an equivalent one. +mp_obj_t alarm_touch_touchalarm_get_wakeup_alarm(const size_t n_alarms, const mp_obj_t *alarms); +// Check for the wake up alarm from pretend deep sleep. +void alarm_touch_touchalarm_set_alarm(const bool deep_sleep, const size_t n_alarms, const mp_obj_t *alarms); +void alarm_touch_touchalarm_prepare_for_deep_sleep(void); +bool alarm_touch_touchalarm_woke_us_up(void); +void alarm_touch_touchalarm_reset(void); + +#endif // MICROPY_INCLUDED_COMMON_HAL_ALARM_TOUCH_TOUCHALARM_H diff --git a/ports/nrf/mpconfigport.mk b/ports/nrf/mpconfigport.mk index 9560064fbc..3e3f30d350 100644 --- a/ports/nrf/mpconfigport.mk +++ b/ports/nrf/mpconfigport.mk @@ -42,6 +42,9 @@ CIRCUITPY_FRAMEBUFFERIO ?= 1 CIRCUITPY_COUNTIO = 0 CIRCUITPY_WATCHDOG ?= 1 +# Sleep and Wakeup +CIRCUITPY_ALARM = 1 + # nRF52840-specific ifeq ($(MCU_CHIP),nrf52840) diff --git a/ports/nrf/nrfx_config.h b/ports/nrf/nrfx_config.h index 94812d5913..1becad813d 100644 --- a/ports/nrf/nrfx_config.h +++ b/ports/nrf/nrfx_config.h @@ -116,7 +116,7 @@ // GPIO interrupt #define NRFX_GPIOTE_ENABLED 1 -#define NRFX_GPIOTE_CONFIG_NUM_OF_LOW_POWER_EVENTS 1 +#define NRFX_GPIOTE_CONFIG_NUM_OF_LOW_POWER_EVENTS 2 #define NRFX_GPIOTE_CONFIG_IRQ_PRIORITY 7 // NVM controller diff --git a/ports/nrf/supervisor/port.c b/ports/nrf/supervisor/port.c index 78bb20ce6c..3ed822ed76 100644 --- a/ports/nrf/supervisor/port.c +++ b/ports/nrf/supervisor/port.c @@ -27,6 +27,10 @@ #include #include "supervisor/port.h" #include "supervisor/board.h" +#ifdef MY_DEBUGUART +#include "supervisor/serial.h" // dbg_printf() +extern void _debug_uart_init(void); +#endif #include "nrfx/hal/nrf_clock.h" #include "nrfx/hal/nrf_power.h" @@ -90,6 +94,9 @@ static volatile struct { uint32_t suffix; } overflow_tracker __attribute__((section(".uninitialized"))); +uint32_t reset_reason_saved = 0; +volatile int rtc_woke_up_counter = 0; + void rtc_handler(nrfx_rtc_int_type_t int_type) { if (int_type == NRFX_RTC_INT_OVERFLOW) { // Our RTC is 24 bits and we're clocking it at 32.768khz which is 32 (2 ** 5) subticks per @@ -100,9 +107,25 @@ void rtc_handler(nrfx_rtc_int_type_t int_type) { supervisor_tick(); } else if (int_type == NRFX_RTC_INT_COMPARE0) { nrfx_rtc_cc_set(&rtc_instance, 0, 0, false); + } else if (int_type == NRFX_RTC_INT_COMPARE1) { + // used in light sleep + ++rtc_woke_up_counter; + nrfx_rtc_cc_set(&rtc_instance, 1, 0, false); } } +void _xxx_dumpRTC(void) { + dbg_printf("\r\nRTC2\r\n"); + NRF_RTC_Type *r = rtc_instance.p_reg; + dbg_printf("PRESCALER=%08X, ", (int)r->PRESCALER); + dbg_printf("COUNTER=%08X ", (int)r->COUNTER); + dbg_printf("INTENSET=%08X ", (int)r->INTENSET); + dbg_printf("EVTENSET=%08X\r\n", (int)r->EVTENSET); + dbg_printf("EVENTS_COMPARE[0..3]=%X,%X,%X,%X ", (int)r->EVENTS_COMPARE[0], (int)r->EVENTS_COMPARE[1], (int)r->EVENTS_COMPARE[2], (int)r->EVENTS_COMPARE[3]); + dbg_printf("CC[0..3]=%08X,%08X,%08X,%08X\r\n", (int)r->CC[0], (int)r->CC[1], (int)r->CC[2], (int)r->CC[3]); + dbg_printf("woke_up=%d\r\n", rtc_woke_up_counter); +} + void tick_init(void) { if (!nrf_clock_lf_is_running(NRF_CLOCK)) { nrf_clock_task_trigger(NRF_CLOCK, NRF_CLOCK_TASK_LFCLKSTART); @@ -124,6 +147,7 @@ void tick_init(void) { } } + safe_mode_t port_init(void) { nrf_peripherals_clocks_init(); @@ -153,6 +177,8 @@ safe_mode_t port_init(void) { analogin_init(); #endif + reset_reason_saved = NRF_POWER->RESETREAS; + // If the board was reset by the WatchDogTimer, we may // need to boot into safe mode. Reset the RESETREAS bit // for the WatchDogTimer so we don't encounter this the @@ -171,6 +197,7 @@ safe_mode_t port_init(void) { return NO_SAFE_MODE; } + void reset_port(void) { #ifdef CIRCUITPY_GAMEPAD_TICKS gamepad_reset(); @@ -219,6 +246,10 @@ void reset_port(void) { #endif reset_all_pins(); + +#ifdef MY_DEBUGUART + _debug_uart_init(); +#endif } void reset_to_bootloader(void) { @@ -295,7 +326,7 @@ void port_disable_tick(void) { nrfx_rtc_tick_disable(&rtc_instance); } -void port_interrupt_after_ticks(uint32_t ticks) { +void port_interrupt_after_ticks_ch(uint32_t channel, uint32_t ticks) { uint32_t current_ticks = nrfx_rtc_counter_get(&rtc_instance); uint32_t diff = 3; if (ticks > diff) { @@ -304,7 +335,15 @@ void port_interrupt_after_ticks(uint32_t ticks) { if (diff > 0xffffff) { diff = 0xffffff; } - nrfx_rtc_cc_set(&rtc_instance, 0, current_ticks + diff, true); + nrfx_rtc_cc_set(&rtc_instance, channel, current_ticks + diff, true); +} + +void port_disable_interrupt_after_ticks_ch(uint32_t channel) { + nrfx_rtc_cc_disable(&rtc_instance, channel); +} + +void port_interrupt_after_ticks(uint32_t ticks) { + port_interrupt_after_ticks_ch(0, ticks); } void port_idle_until_interrupt(void) { diff --git a/supervisor/serial.h b/supervisor/serial.h index 066886303e..6cd8530b36 100644 --- a/supervisor/serial.h +++ b/supervisor/serial.h @@ -29,6 +29,7 @@ #include #include +#include #include "py/mpconfig.h" @@ -47,4 +48,6 @@ char serial_read(void); bool serial_bytes_available(void); bool serial_connected(void); +int dbg_printf(const char *fmt, ...)__attribute__((format (printf, 1, 2))); + #endif // MICROPY_INCLUDED_SUPERVISOR_SERIAL_H diff --git a/supervisor/shared/serial.c b/supervisor/shared/serial.c index b9feb04f25..2db4c6b2ec 100644 --- a/supervisor/shared/serial.c +++ b/supervisor/shared/serial.c @@ -36,6 +36,103 @@ #include "tusb.h" +#ifdef MY_DEBUGUART +#include +#include +#include "nrfx.h" +#include "nrf_uart.h" +#include "nrfx_uart.h" +const nrfx_uarte_t _dbg_uart_inst = NRFX_UARTE_INSTANCE(1); +static int _dbg_uart_initialized = 0; +#define DBG_PBUF_LEN 80 +static char _dbg_pbuf[DBG_PBUF_LEN+1]; + +void _debug_uart_init(void) { + //if (_dbg_uart_initialized) return; + nrfx_uarte_config_t config = { + .pseltxd = 26, + .pselrxd = 15, + .pselcts = NRF_UARTE_PSEL_DISCONNECTED, + .pselrts = NRF_UARTE_PSEL_DISCONNECTED, + .p_context = NULL, + .baudrate = NRF_UART_BAUDRATE_115200, + .interrupt_priority = 7, + .hal_cfg = { + .hwfc = NRF_UARTE_HWFC_DISABLED, + .parity = NRF_UARTE_PARITY_EXCLUDED + } + }; + nrfx_uarte_init(&_dbg_uart_inst, &config, NULL); + // drive config + nrf_gpio_cfg(config.pseltxd, + NRF_GPIO_PIN_DIR_OUTPUT, + NRF_GPIO_PIN_INPUT_DISCONNECT, + NRF_GPIO_PIN_PULLUP, // orig=NOPULL + NRF_GPIO_PIN_H0H1, // orig=S0S1 + NRF_GPIO_PIN_NOSENSE); + _dbg_uart_initialized = 1; + return; +} + +void _debug_printbuf(char* data) { + int siz, l; + while((l = strlen(data)) != 0) { + if (l <= DBG_PBUF_LEN) { + siz = l; + } + else { + siz = DBG_PBUF_LEN; + } + memcpy(_dbg_pbuf, data, siz); + _dbg_pbuf[siz] = 0; + nrfx_uarte_tx(&_dbg_uart_inst, (uint8_t const*)_dbg_pbuf, siz); + data += siz; + } +} + +void _debug_print_substr(const char* text, uint32_t length) { + char* data = (char*)text; + int siz; + while(length != 0) { + if (length <= DBG_PBUF_LEN) { + siz = length; + } + else { + siz = DBG_PBUF_LEN; + } + memcpy(_dbg_pbuf, data, siz); + _dbg_pbuf[siz] = 0; + nrfx_uarte_tx(&_dbg_uart_inst, (uint8_t const*)_dbg_pbuf, siz); + data += siz; + length -= siz; + } +} + +void _debug_print(const char* s) { + _debug_printbuf((char*)s); +} + +void _debug_uart_deinit(void) { + nrfx_uarte_uninit(&_dbg_uart_inst); +} + +int dbg_printf(const char *fmt, ...) { + va_list ap; + va_start(ap, fmt); + int ret = vprintf(fmt, ap); + va_end(ap); + return ret; +} + +extern void _debug_led_init(void); +extern void _debug_led_set(int v); +#else /*!MY_DEBUGUART*/ +int dbg_printf(const char *fmt, ...) { + return 0; +} +#endif + + /* * Note: DEBUG_UART currently only works on STM32, * enabling on another platform will cause a crash. @@ -63,10 +160,19 @@ void serial_early_init(void) { buf_array, true); common_hal_busio_uart_never_reset(&debug_uart); #endif + +#ifdef MY_DEBUGUART + _debug_uart_init(); + _debug_led_init(); + _debug_print("\r\ndebug_uart start\r\n"); +#endif } void serial_init(void) { usb_init(); +#ifdef MY_DEBUGUART + _debug_uart_init(); +#endif } bool serial_connected(void) { @@ -144,6 +250,10 @@ void serial_write_substring(const char* text, uint32_t length) { int uart_errcode; common_hal_busio_uart_write(&debug_uart, (const uint8_t*) text, length, &uart_errcode); #endif + +#ifdef MY_DEBUGUART + _debug_print_substr(text, length); +#endif } void serial_write(const char* text) { From cf2427c5618339fa248c41064796f5c39a4e5bf2 Mon Sep 17 00:00:00 2001 From: jun2sak Date: Wed, 17 Feb 2021 21:51:28 +0900 Subject: [PATCH 02/67] light sleep reason fix. --- ports/nrf/common-hal/alarm/__init__.c | 1 + 1 file changed, 1 insertion(+) diff --git a/ports/nrf/common-hal/alarm/__init__.c b/ports/nrf/common-hal/alarm/__init__.c index d5a4aec3c8..c91593861a 100644 --- a/ports/nrf/common-hal/alarm/__init__.c +++ b/ports/nrf/common-hal/alarm/__init__.c @@ -144,6 +144,7 @@ STATIC void _setup_sleep_alarms(bool deep_sleep, size_t n_alarms, const mp_obj_t STATIC void _idle_until_alarm(void) { int ct = 40; + reset_reason_saved = 0; // Poll for alarms. while (!mp_hal_is_interrupted()) { RUN_BACKGROUND_TASKS; From 26f8f532f126bb0b66e3a812d46e78fabf73f5f6 Mon Sep 17 00:00:00 2001 From: jun2sak Date: Sun, 21 Feb 2021 00:47:07 +0900 Subject: [PATCH 03/67] safe mode fix. --- .gitignore | 6 ++ main.c | 15 +++- ports/nrf/common-hal/alarm/SleepMemory.c | 69 +++++++++++++++++-- ports/nrf/common-hal/alarm/__init__.c | 57 +++++++++++---- ports/nrf/common-hal/alarm/__init__.h | 1 + ports/nrf/common-hal/alarm/pin/PinAlarm.c | 26 +++++-- .../common-hal/microcontroller/Processor.c | 22 +++++- ports/nrf/supervisor/port.c | 8 ++- supervisor/shared/serial.c | 21 ------ 9 files changed, 175 insertions(+), 50 deletions(-) diff --git a/.gitignore b/.gitignore index a8814be45e..6f27970f89 100644 --- a/.gitignore +++ b/.gitignore @@ -86,3 +86,9 @@ TAGS #################### .venv .env + +1FILES +2FILES +TAG +ports/nrf/LOG*.txt +ports/nrf/boards/pg8c diff --git a/main.c b/main.c index 054c6b4f53..b3c783bf79 100755 --- a/main.c +++ b/main.c @@ -214,7 +214,7 @@ STATIC bool maybe_run_list(const char * const * filenames, pyexec_result_t* exec decompress(compressed, decompressed); mp_hal_stdout_tx_str(decompressed); pyexec_file(filename, exec_result); - dbg_printf("pyexec_file end result=(code=%d, line=%d)\r\n", exec_result->return_code, exec_result->exception_line); + //dbg_printf("pyexec_file end result=(code=%d, line=%d)\r\n", exec_result->return_code, exec_result->exception_line); return true; } @@ -260,7 +260,7 @@ STATIC void print_code_py_status_message(safe_mode_t safe_mode) { } STATIC bool run_code_py(safe_mode_t safe_mode) { - dbg_printf("run_code_py (%d)\r\n", (int)safe_mode); + //dbg_printf("run_code_py (%d)\r\n", (int)safe_mode); bool serial_connected_at_start = serial_connected(); #if CIRCUITPY_AUTORELOAD_DELAY_MS > 0 serial_write("\n"); @@ -436,7 +436,7 @@ STATIC bool run_code_py(safe_mode_t safe_mode) { FIL* boot_output_file; STATIC void __attribute__ ((noinline)) run_boot_py(safe_mode_t safe_mode) { - dbg_printf("run_boot_py (%d)\r\n", (int)safe_mode); + //dbg_printf("run_boot_py (%d)\r\n", (int)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) { @@ -583,6 +583,15 @@ int __attribute__((used)) main(void) { // Start serial and HID after giving boot.py a chance to tweak behavior. serial_init(); +#if 0 //XXX + int rr = (int)common_hal_mcu_processor_get_reset_reason(); + const char* rrstr[] = { + "POWER_ON", "BROWNOUT", "SOFTWARE", "DEEPSLEEPALARM", + "RESET_PIN", "WATCHDOG", "UNKNOWN" + }; + dbg_printf("reset_reason=%s\r\n", rrstr[rr]); +#endif + #if CIRCUITPY_BLEIO supervisor_start_bluetooth(); #endif diff --git a/ports/nrf/common-hal/alarm/SleepMemory.c b/ports/nrf/common-hal/alarm/SleepMemory.c index dd87b31b17..a867b17b13 100644 --- a/ports/nrf/common-hal/alarm/SleepMemory.c +++ b/ports/nrf/common-hal/alarm/SleepMemory.c @@ -26,23 +26,84 @@ */ #include +#ifdef MY_DEBUGUART +#include "supervisor/serial.h" // dbg_printf() +#endif #include "py/runtime.h" #include "common-hal/alarm/SleepMemory.h" -//static RTC_DATA_ATTR uint8_t _sleep_mem[SLEEP_MEMORY_LENGTH]; +#define RTC_DATA_ATTR __attribute__((section(".uninitialized"))) +static RTC_DATA_ATTR uint8_t _sleep_mem[SLEEP_MEMORY_LENGTH]; +static RTC_DATA_ATTR uint32_t _sleep_mem_magicnum; +#define SLEEP_MEMORY_DATA_GUARD 0xad0000af +#define SLEEP_MEMORY_DATA_GUARD_MASK 0xff0000ff + +static int is_sleep_memory_valid(void) { + if ((_sleep_mem_magicnum & SLEEP_MEMORY_DATA_GUARD_MASK) + == SLEEP_MEMORY_DATA_GUARD) { + return 1; + } + return 0; +} + +static void dumpRAMreg(void) { +#ifdef MY_DEBUGUART + int i; + for(i = 0; i <= 8; ++i) { + dbg_printf(" RAM%d:%08X", i, (int)(NRF_POWER->RAM[i].POWER)); + if (i==4) dbg_printf("\r\n"); + } + dbg_printf("\r\n"); +#endif +} + +static void initialize_sleep_memory(void) { + memset((uint8_t *)_sleep_mem, 0, SLEEP_MEMORY_LENGTH); + + // also, set RAM[n].POWER register for RAM retention + // nRF52840 has RAM[0..7].Section[0..1] and RAM[8].Section[0..5] + // nRF52833 has RAM[0..7].Section[0..1] and RAM[8].Section[0,1] + dumpRAMreg(); + for(int ram = 0; ram <= 7; ++ram) { + NRF_POWER->RAM[ram].POWERSET = 0x00030000; // RETENTION for section 0,1 + }; +#ifdef NRF52840 + NRF_POWER->RAM[8].POWERSET = 0x001F0000; // RETENTION for section 0..5 +#endif +#ifdef NRF52833 + NRF_POWER->RAM[8].POWERSET = 0x00030000; // RETENTION for section 0,1 +#endif + dumpRAMreg(); + + _sleep_mem_magicnum = SLEEP_MEMORY_DATA_GUARD; +} void alarm_sleep_memory_reset(void) { + if (!is_sleep_memory_valid()) { + initialize_sleep_memory(); +#ifdef MY_DEBUGUART + dbg_printf("_sleep_mem[] initialized\r\n"); +#endif + } } uint32_t common_hal_alarm_sleep_memory_get_length(alarm_sleep_memory_obj_t *self) { - return 0; + return sizeof(_sleep_mem); } bool common_hal_alarm_sleep_memory_set_bytes(alarm_sleep_memory_obj_t *self, uint32_t start_index, const uint8_t* values, uint32_t len) { - return false; + if (start_index + len > sizeof(_sleep_mem)) { + return false; + } + + memcpy((uint8_t *) (_sleep_mem + start_index), values, len); + return true; } void common_hal_alarm_sleep_memory_get_bytes(alarm_sleep_memory_obj_t *self, uint32_t start_index, uint8_t* values, uint32_t len) { - return; + if (start_index + len > sizeof(_sleep_mem)) { + return; + } + memcpy(values, (uint8_t *) (_sleep_mem + start_index), len); } diff --git a/ports/nrf/common-hal/alarm/__init__.c b/ports/nrf/common-hal/alarm/__init__.c index c91593861a..1823bf4649 100644 --- a/ports/nrf/common-hal/alarm/__init__.c +++ b/ports/nrf/common-hal/alarm/__init__.c @@ -42,14 +42,15 @@ //#include "shared-bindings/microcontroller/__init__.h" #include "supervisor/port.h" +#ifdef MY_DEBUGUART +#include "supervisor/serial.h" // dbg_printf() +#endif #include "nrf.h" #include "nrf_power.h" #include "nrfx.h" #include "nrfx_gpiote.h" -extern void _debug_print(const char* s); -extern void _xxx_dumpRTC(void);//XXXX #define DEBUG_LED_PIN (NRF_GPIO_PIN_MAP(1, 11)) // P1_11 = LED void _debug_led_init(void) { @@ -68,14 +69,14 @@ const alarm_sleep_memory_obj_t alarm_sleep_memory_obj = { }; void alarm_reset(void) { - //alarm_sleep_memory_reset(); + alarm_sleep_memory_reset(); alarm_pin_pinalarm_reset(); alarm_time_timealarm_reset(); //alarm_touch_touchalarm_reset(); } extern uint32_t reset_reason_saved; -STATIC uint32_t _get_wakeup_cause(void) { +STATIC nrf_sleep_source_t _get_wakeup_cause(void) { if (alarm_pin_pinalarm_woke_us_up()) { return NRF_SLEEP_WAKEUP_GPIO; } @@ -101,17 +102,30 @@ STATIC uint32_t _get_wakeup_cause(void) { } bool alarm_woken_from_sleep(void) { - uint32_t cause = _get_wakeup_cause(); + nrf_sleep_source_t cause = _get_wakeup_cause(); return (cause == NRF_SLEEP_WAKEUP_GPIO || cause == NRF_SLEEP_WAKEUP_TIMER || cause == NRF_SLEEP_WAKEUP_TOUCHPAD || cause == NRF_SLEEP_WAKEUP_RESETPIN); } +#ifdef MY_DEBUGUART +static const char* cause_str[] = { + "UNDEFINED", + "GPIO", + "TIMER", + "TOUCHPAD", + "VBUS", + "RESETPIN", +}; +#endif + STATIC mp_obj_t _get_wake_alarm(size_t n_alarms, const mp_obj_t *alarms) { - uint32_t cause = _get_wakeup_cause(); - if (cause & 0x80000000) { - printf("wakeup cause = 0x%08X\r\n", (int)cause); + nrf_sleep_source_t cause = _get_wakeup_cause(); +#if 0 + if (cause >= 0 && cause < NRF_SLEEP_WAKEUP_ZZZ) { + printf("wakeup cause = NRF_SLEEP_WAKEUP_%s\r\n", cause_str[(int)cause]); } +#endif switch (cause) { case NRF_SLEEP_WAKEUP_TIMER: { return alarm_time_timealarm_get_wakeup_alarm(n_alarms, alarms); @@ -122,13 +136,14 @@ STATIC mp_obj_t _get_wake_alarm(size_t n_alarms, const mp_obj_t *alarms) { case NRF_SLEEP_WAKEUP_GPIO: { return alarm_pin_pinalarm_get_wakeup_alarm(n_alarms, alarms); } + default: + break; } return mp_const_none; } mp_obj_t common_hal_alarm_get_wake_alarm(void) { mp_obj_t obj = _get_wake_alarm(0, NULL); - //_xxx_dumpRTC();//XXX return obj; } @@ -139,11 +154,12 @@ STATIC void _setup_sleep_alarms(bool deep_sleep, size_t n_alarms, const mp_obj_t #if 0 alarm_touch_touchalarm_set_alarm(deep_sleep, n_alarms, alarms); #endif - //_xxx_dumpRTC(); } STATIC void _idle_until_alarm(void) { +#ifdef MY_DEBUGUART int ct = 40; +#endif reset_reason_saved = 0; // Poll for alarms. while (!mp_hal_is_interrupted()) { @@ -151,26 +167,35 @@ STATIC void _idle_until_alarm(void) { // Allow ctrl-C interrupt. if (alarm_woken_from_sleep()) { alarm_save_wake_alarm(); +#ifdef MY_DEBUGUART int cause = _get_wakeup_cause(); - printf("wakeup(%d)\r\n", cause); //XXX + printf("wakeup(%d)\r\n", cause); +#endif return; } port_idle_until_interrupt(); +#ifdef MY_DEBUGUART if (ct > 0) { - printf("_"); --ct; + printf("_"); + --ct; } +#endif } } mp_obj_t common_hal_alarm_light_sleep_until_alarms(size_t n_alarms, const mp_obj_t *alarms) { mp_obj_t r_obj = mp_const_none; _setup_sleep_alarms(false, n_alarms, alarms); - _debug_print("\r\nsleep..."); +#ifdef MY_DEBUGUART + dbg_printf("\r\nsleep..."); +#endif _idle_until_alarm(); if (mp_hal_is_interrupted()) { - _debug_print("mp_hal_is_interrupted\r\n"); +#ifdef MY_DEBUGUART + dbg_printf("mp_hal_is_interrupted\r\n"); +#endif r_obj = mp_const_none; } else { @@ -185,7 +210,9 @@ void common_hal_alarm_set_deep_sleep_alarms(size_t n_alarms, const mp_obj_t *ala } void nrf_deep_sleep_start(void) { - _debug_print("go system off..\r\n"); +#ifdef MY_DEBUGUART + dbg_printf("go system off..\r\n"); +#endif sd_power_system_off(); } diff --git a/ports/nrf/common-hal/alarm/__init__.h b/ports/nrf/common-hal/alarm/__init__.h index 11652ec828..6fa07bcd29 100644 --- a/ports/nrf/common-hal/alarm/__init__.h +++ b/ports/nrf/common-hal/alarm/__init__.h @@ -36,6 +36,7 @@ typedef enum { NRF_SLEEP_WAKEUP_TOUCHPAD, NRF_SLEEP_WAKEUP_VBUS, NRF_SLEEP_WAKEUP_RESETPIN, + NRF_SLEEP_WAKEUP_ZZZ } nrf_sleep_source_t; extern const alarm_sleep_memory_obj_t alarm_sleep_memory_obj; diff --git a/ports/nrf/common-hal/alarm/pin/PinAlarm.c b/ports/nrf/common-hal/alarm/pin/PinAlarm.c index 0e0f6c4832..1945beaaf8 100644 --- a/ports/nrf/common-hal/alarm/pin/PinAlarm.c +++ b/ports/nrf/common-hal/alarm/pin/PinAlarm.c @@ -146,30 +146,40 @@ void _setup2(void) { }; for(size_t i = 0; i < 64; ++i) { uint64_t mask = 1ull << i; +#ifdef MY_DEBUGUART int pull = 0; int sense = 0; +#endif if (((high_alarms & mask) == 0) && ((low_alarms & mask) == 0)) { continue; } if (((high_alarms & mask) != 0) && ((low_alarms & mask) == 0)) { cfg.sense = NRF_GPIOTE_POLARITY_LOTOHI; cfg.pull = ((pull_pins & mask) != 0) ? NRF_GPIO_PIN_PULLDOWN : NRF_GPIO_PIN_NOPULL; +#ifdef MY_DEBUGUART pull = -1; sense = 1; +#endif } else if (((high_alarms & mask) == 0) && ((low_alarms & mask) != 0)) { cfg.sense = NRF_GPIOTE_POLARITY_HITOLO; cfg.pull = ((pull_pins & mask) != 0) ? NRF_GPIO_PIN_PULLUP : NRF_GPIO_PIN_NOPULL; +#ifdef MY_DEBUGUART pull = 1; sense = -1; +#endif } else { cfg.sense = NRF_GPIOTE_POLARITY_TOGGLE; cfg.pull = NRF_GPIO_PIN_NOPULL; +#ifdef MY_DEBUGUART sense = 9; +#endif } nrfx_gpiote_in_init((nrfx_gpiote_pin_t)i, &cfg, pinalarm_gpiote_handler); nrfx_gpiote_in_event_enable((nrfx_gpiote_pin_t)i, true); - printf("pin=%d, sense=%d, pull=%d\r\n", i, sense, pull); +#ifdef MY_DEBUGUART + dbg_printf("pin=%d, sense=%d, pull=%d\r\n", i, sense, pull); +#endif } } @@ -188,7 +198,9 @@ void _setup_pin1_for_deepsleep(void) { for(size_t i = 0; i < 64; ++i) { uint64_t mask = 1ull << i; int pull = 0; +#ifdef MY_DEBUGUART int sense = 0; +#endif if (((high_alarms & mask) == 0) && ((low_alarms & mask) == 0)) { continue; } @@ -196,16 +208,22 @@ void _setup_pin1_for_deepsleep(void) { pull = ((pull_pins & mask) != 0) ? NRF_GPIO_PIN_PULLDOWN : NRF_GPIO_PIN_NOPULL; nrf_gpio_cfg_input((uint32_t)i, (nrf_gpio_pin_pull_t)pull); nrf_gpio_cfg_sense_set((uint32_t)i, NRF_GPIO_PIN_SENSE_HIGH); +#ifdef MY_DEBUGUART sense = NRF_GPIO_PIN_SENSE_HIGH; +#endif } else if (((high_alarms & mask) == 0) && ((low_alarms & mask) != 0)) { pull = ((pull_pins & mask) != 0) ? NRF_GPIO_PIN_PULLUP : NRF_GPIO_PIN_NOPULL; nrf_gpio_cfg_input((uint32_t)i, (nrf_gpio_pin_pull_t)pull); nrf_gpio_cfg_sense_set((uint32_t)i, NRF_GPIO_PIN_SENSE_LOW); +#ifdef MY_DEBUGUART sense = NRF_GPIO_PIN_SENSE_LOW; +#endif } - printf("pin=%d, sense=%d, pull=%d\r\n", i, sense, pull); +#ifdef MY_DEBUGUART + dbg_printf("pin=%d, sense=%d, pull=%d\r\n", i, sense, pull); +#endif } #if 0 uint32_t pin_number = 2; @@ -230,7 +248,7 @@ void alarm_pin_pinalarm_set_alarms(bool deep_sleep, size_t n_alarms, const mp_ob alarm_pin_pinalarm_obj_t *alarm = MP_OBJ_TO_PTR(alarms[i]); pin_number = alarm->pin->number; - dbg_printf("alarm_pin_pinalarm_set_alarms(pin#=%d, val=%d, pull=%d)\r\n", pin_number, alarm->value, alarm->pull); + //dbg_printf("alarm_pin_pinalarm_set_alarms(pin#=%d, val=%d, pull=%d)\r\n", pin_number, alarm->value, alarm->pull); if (alarm->value) { high_alarms |= 1ull << pin_number; high_count++; @@ -251,7 +269,7 @@ void alarm_pin_pinalarm_set_alarms(bool deep_sleep, size_t n_alarms, const mp_ob } } else { - dbg_printf("alarm_pin_pinalarm_set_alarms() no valid pins\r\n"); + //dbg_printf("alarm_pin_pinalarm_set_alarms() no valid pins\r\n"); } } diff --git a/ports/nrf/common-hal/microcontroller/Processor.c b/ports/nrf/common-hal/microcontroller/Processor.c index ab5f29b5db..5564c86c54 100644 --- a/ports/nrf/common-hal/microcontroller/Processor.c +++ b/ports/nrf/common-hal/microcontroller/Processor.c @@ -122,6 +122,26 @@ void common_hal_mcu_processor_get_uid(uint8_t raw_id[]) { } } +extern uint32_t reset_reason_saved; mcu_reset_reason_t common_hal_mcu_processor_get_reset_reason(void) { - return RESET_REASON_UNKNOWN; + mcu_reset_reason_t r = RESET_REASON_UNKNOWN; + if (reset_reason_saved == 0) { + r = RESET_REASON_POWER_ON; + } + else if (reset_reason_saved & POWER_RESETREAS_RESETPIN_Msk) { + r = RESET_REASON_RESET_PIN; + } + else if (reset_reason_saved & POWER_RESETREAS_DOG_Msk) { + r = RESET_REASON_WATCHDOG; + } + else if (reset_reason_saved & POWER_RESETREAS_SREQ_Msk) { + r = RESET_REASON_SOFTWARE; + } + else if ((reset_reason_saved & POWER_RESETREAS_OFF_Msk) || + (reset_reason_saved & POWER_RESETREAS_LPCOMP_Msk) || + (reset_reason_saved & POWER_RESETREAS_NFC_Msk) || + (reset_reason_saved & POWER_RESETREAS_VBUS_Msk)) { + r = RESET_REASON_DEEP_SLEEP_ALARM; + } + return r; } diff --git a/ports/nrf/supervisor/port.c b/ports/nrf/supervisor/port.c index 3ed822ed76..6e19e7645e 100644 --- a/ports/nrf/supervisor/port.c +++ b/ports/nrf/supervisor/port.c @@ -114,7 +114,8 @@ void rtc_handler(nrfx_rtc_int_type_t int_type) { } } -void _xxx_dumpRTC(void) { +#ifdef MY_DEBUGUART +void dbg_dumpRTC(void) { dbg_printf("\r\nRTC2\r\n"); NRF_RTC_Type *r = rtc_instance.p_reg; dbg_printf("PRESCALER=%08X, ", (int)r->PRESCALER); @@ -125,6 +126,7 @@ void _xxx_dumpRTC(void) { dbg_printf("CC[0..3]=%08X,%08X,%08X,%08X\r\n", (int)r->CC[0], (int)r->CC[1], (int)r->CC[2], (int)r->CC[3]); dbg_printf("woke_up=%d\r\n", rtc_woke_up_counter); } +#endif void tick_init(void) { if (!nrf_clock_lf_is_running(NRF_CLOCK)) { @@ -178,12 +180,14 @@ safe_mode_t port_init(void) { #endif reset_reason_saved = NRF_POWER->RESETREAS; + // clear all RESET reason bits + NRF_POWER->RESETREAS = reset_reason_saved; // If the board was reset by the WatchDogTimer, we may // need to boot into safe mode. Reset the RESETREAS bit // for the WatchDogTimer so we don't encounter this the // next time we reboot. - if (NRF_POWER->RESETREAS & POWER_RESETREAS_DOG_Msk) { + if (reset_reason_saved & POWER_RESETREAS_DOG_Msk) { NRF_POWER->RESETREAS = POWER_RESETREAS_DOG_Msk; uint32_t usb_reg = NRF_POWER->USBREGSTATUS; diff --git a/supervisor/shared/serial.c b/supervisor/shared/serial.c index 2db4c6b2ec..b5d4ef919c 100644 --- a/supervisor/shared/serial.c +++ b/supervisor/shared/serial.c @@ -74,22 +74,6 @@ void _debug_uart_init(void) { return; } -void _debug_printbuf(char* data) { - int siz, l; - while((l = strlen(data)) != 0) { - if (l <= DBG_PBUF_LEN) { - siz = l; - } - else { - siz = DBG_PBUF_LEN; - } - memcpy(_dbg_pbuf, data, siz); - _dbg_pbuf[siz] = 0; - nrfx_uarte_tx(&_dbg_uart_inst, (uint8_t const*)_dbg_pbuf, siz); - data += siz; - } -} - void _debug_print_substr(const char* text, uint32_t length) { char* data = (char*)text; int siz; @@ -108,10 +92,6 @@ void _debug_print_substr(const char* text, uint32_t length) { } } -void _debug_print(const char* s) { - _debug_printbuf((char*)s); -} - void _debug_uart_deinit(void) { nrfx_uarte_uninit(&_dbg_uart_inst); } @@ -164,7 +144,6 @@ void serial_early_init(void) { #ifdef MY_DEBUGUART _debug_uart_init(); _debug_led_init(); - _debug_print("\r\ndebug_uart start\r\n"); #endif } From 41d9d4e0ab2398d2f851269e9771bd0458de8ec5 Mon Sep 17 00:00:00 2001 From: jun2sak Date: Sun, 21 Feb 2021 08:17:57 +0900 Subject: [PATCH 04/67] call sd API only when sd enabled. --- ports/nrf/common-hal/alarm/__init__.c | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/ports/nrf/common-hal/alarm/__init__.c b/ports/nrf/common-hal/alarm/__init__.c index 1823bf4649..4fe8432a1f 100644 --- a/ports/nrf/common-hal/alarm/__init__.c +++ b/ports/nrf/common-hal/alarm/__init__.c @@ -109,6 +109,7 @@ bool alarm_woken_from_sleep(void) { } #ifdef MY_DEBUGUART +#if 0 static const char* cause_str[] = { "UNDEFINED", "GPIO", @@ -118,6 +119,7 @@ static const char* cause_str[] = { "RESETPIN", }; #endif +#endif STATIC mp_obj_t _get_wake_alarm(size_t n_alarms, const mp_obj_t *alarms) { nrf_sleep_source_t cause = _get_wakeup_cause(); @@ -209,18 +211,21 @@ void common_hal_alarm_set_deep_sleep_alarms(size_t n_alarms, const mp_obj_t *ala _setup_sleep_alarms(true, n_alarms, alarms); } -void nrf_deep_sleep_start(void) { -#ifdef MY_DEBUGUART - dbg_printf("go system off..\r\n"); -#endif - sd_power_system_off(); -} - void NORETURN alarm_enter_deep_sleep(void) { alarm_pin_pinalarm_prepare_for_deep_sleep(); //alarm_touch_touchalarm_prepare_for_deep_sleep(); - nrf_deep_sleep_start(); + uint8_t sd_enabled; + sd_softdevice_is_enabled(&sd_enabled); +#ifdef MY_DEBUGUART + dbg_printf("go system off.. %d\r\n", sd_enabled); +#endif + if (sd_enabled) { + sd_power_system_off(); + } + else { + NRF_POWER->SYSTEMOFF = 1; + } // should not reach here.. while(1) ; From 793198909eff7dee17fd79b2f5d6b6eceb1978c9 Mon Sep 17 00:00:00 2001 From: jun2sak Date: Sun, 21 Feb 2021 08:19:39 +0900 Subject: [PATCH 05/67] set SleepMemory size to 256 bytes. --- ports/nrf/common-hal/alarm/SleepMemory.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/ports/nrf/common-hal/alarm/SleepMemory.h b/ports/nrf/common-hal/alarm/SleepMemory.h index ea3d40c35a..24fe0065d0 100644 --- a/ports/nrf/common-hal/alarm/SleepMemory.h +++ b/ports/nrf/common-hal/alarm/SleepMemory.h @@ -29,8 +29,7 @@ #include "py/obj.h" -// not implemented yet -#define SLEEP_MEMORY_LENGTH (4) +#define SLEEP_MEMORY_LENGTH (256) typedef struct { mp_obj_base_t base; From d659c2ce3401c3a33b73d5e6074dd7c93a9deffc Mon Sep 17 00:00:00 2001 From: jun2sak Date: Sun, 21 Feb 2021 09:55:10 +0900 Subject: [PATCH 06/67] move port-specific debug functions from supervisor/shared/serial.c to ports/nrf/supervisor/port.c --- ports/nrf/supervisor/port.c | 78 ++++++++++++++++++++++++++++++++++++- supervisor/serial.h | 1 + supervisor/shared/serial.c | 78 ++----------------------------------- 3 files changed, 80 insertions(+), 77 deletions(-) diff --git a/ports/nrf/supervisor/port.c b/ports/nrf/supervisor/port.c index 6e19e7645e..d3c31b51a6 100644 --- a/ports/nrf/supervisor/port.c +++ b/ports/nrf/supervisor/port.c @@ -77,6 +77,82 @@ static void power_warning_handler(void) { reset_into_safe_mode(BROWNOUT); } +#ifdef MY_DEBUGUART +#include +#include +#include "nrfx.h" +#include "nrf_uart.h" +#include "nrfx_uart.h" +const nrfx_uarte_t _dbg_uart_inst = NRFX_UARTE_INSTANCE(1); +static int _dbg_uart_initialized = 0; +#define DBG_PBUF_LEN 80 +static char _dbg_pbuf[DBG_PBUF_LEN+1]; + +void _debug_uart_init(void) { + //if (_dbg_uart_initialized) return; + nrfx_uarte_config_t config = { + .pseltxd = 26, + .pselrxd = 15, + .pselcts = NRF_UARTE_PSEL_DISCONNECTED, + .pselrts = NRF_UARTE_PSEL_DISCONNECTED, + .p_context = NULL, + .baudrate = NRF_UART_BAUDRATE_115200, + .interrupt_priority = 7, + .hal_cfg = { + .hwfc = NRF_UARTE_HWFC_DISABLED, + .parity = NRF_UARTE_PARITY_EXCLUDED + } + }; + nrfx_uarte_init(&_dbg_uart_inst, &config, NULL); + // drive config + nrf_gpio_cfg(config.pseltxd, + NRF_GPIO_PIN_DIR_OUTPUT, + NRF_GPIO_PIN_INPUT_DISCONNECT, + NRF_GPIO_PIN_PULLUP, // orig=NOPULL + NRF_GPIO_PIN_H0H1, // orig=S0S1 + NRF_GPIO_PIN_NOSENSE); + _dbg_uart_initialized = 1; + return; +} + +void _debug_print_substr(const char* text, uint32_t length) { + char* data = (char*)text; + int siz; + while(length != 0) { + if (length <= DBG_PBUF_LEN) { + siz = length; + } + else { + siz = DBG_PBUF_LEN; + } + memcpy(_dbg_pbuf, data, siz); + _dbg_pbuf[siz] = 0; + nrfx_uarte_tx(&_dbg_uart_inst, (uint8_t const*)_dbg_pbuf, siz); + data += siz; + length -= siz; + } +} + +void _debug_uart_deinit(void) { + nrfx_uarte_uninit(&_dbg_uart_inst); +} + +int dbg_printf(const char *fmt, ...) { + va_list ap; + va_start(ap, fmt); + int ret = vprintf(fmt, ap); + va_end(ap); + return ret; +} + +extern void _debug_led_init(void); +extern void _debug_led_set(int v); +#else /*!MY_DEBUGUART*/ +int dbg_printf(const char *fmt, ...) { + return 0; +} +#endif + const nrfx_rtc_t rtc_instance = NRFX_RTC_INSTANCE(2); const nrfx_rtc_config_t rtc_config = { @@ -149,7 +225,6 @@ void tick_init(void) { } } - safe_mode_t port_init(void) { nrf_peripherals_clocks_init(); @@ -201,7 +276,6 @@ safe_mode_t port_init(void) { return NO_SAFE_MODE; } - void reset_port(void) { #ifdef CIRCUITPY_GAMEPAD_TICKS gamepad_reset(); diff --git a/supervisor/serial.h b/supervisor/serial.h index 6cd8530b36..457ee5336a 100644 --- a/supervisor/serial.h +++ b/supervisor/serial.h @@ -48,6 +48,7 @@ char serial_read(void); bool serial_bytes_available(void); bool serial_connected(void); +// XXX used in nrf52-sleep debug int dbg_printf(const char *fmt, ...)__attribute__((format (printf, 1, 2))); #endif // MICROPY_INCLUDED_SUPERVISOR_SERIAL_H diff --git a/supervisor/shared/serial.c b/supervisor/shared/serial.c index b5d4ef919c..d2fde39a64 100644 --- a/supervisor/shared/serial.c +++ b/supervisor/shared/serial.c @@ -37,82 +37,11 @@ #include "tusb.h" #ifdef MY_DEBUGUART -#include -#include -#include "nrfx.h" -#include "nrf_uart.h" -#include "nrfx_uart.h" -const nrfx_uarte_t _dbg_uart_inst = NRFX_UARTE_INSTANCE(1); -static int _dbg_uart_initialized = 0; -#define DBG_PBUF_LEN 80 -static char _dbg_pbuf[DBG_PBUF_LEN+1]; - -void _debug_uart_init(void) { - //if (_dbg_uart_initialized) return; - nrfx_uarte_config_t config = { - .pseltxd = 26, - .pselrxd = 15, - .pselcts = NRF_UARTE_PSEL_DISCONNECTED, - .pselrts = NRF_UARTE_PSEL_DISCONNECTED, - .p_context = NULL, - .baudrate = NRF_UART_BAUDRATE_115200, - .interrupt_priority = 7, - .hal_cfg = { - .hwfc = NRF_UARTE_HWFC_DISABLED, - .parity = NRF_UARTE_PARITY_EXCLUDED - } - }; - nrfx_uarte_init(&_dbg_uart_inst, &config, NULL); - // drive config - nrf_gpio_cfg(config.pseltxd, - NRF_GPIO_PIN_DIR_OUTPUT, - NRF_GPIO_PIN_INPUT_DISCONNECT, - NRF_GPIO_PIN_PULLUP, // orig=NOPULL - NRF_GPIO_PIN_H0H1, // orig=S0S1 - NRF_GPIO_PIN_NOSENSE); - _dbg_uart_initialized = 1; - return; -} - -void _debug_print_substr(const char* text, uint32_t length) { - char* data = (char*)text; - int siz; - while(length != 0) { - if (length <= DBG_PBUF_LEN) { - siz = length; - } - else { - siz = DBG_PBUF_LEN; - } - memcpy(_dbg_pbuf, data, siz); - _dbg_pbuf[siz] = 0; - nrfx_uarte_tx(&_dbg_uart_inst, (uint8_t const*)_dbg_pbuf, siz); - data += siz; - length -= siz; - } -} - -void _debug_uart_deinit(void) { - nrfx_uarte_uninit(&_dbg_uart_inst); -} - -int dbg_printf(const char *fmt, ...) { - va_list ap; - va_start(ap, fmt); - int ret = vprintf(fmt, ap); - va_end(ap); - return ret; -} - -extern void _debug_led_init(void); -extern void _debug_led_set(int v); -#else /*!MY_DEBUGUART*/ -int dbg_printf(const char *fmt, ...) { - return 0; -} +// XXX these functions are in nrf/supervisor/port.c +extern void _debug_uart_init(void); +extern void _debug_print_substr(const char* text, uint32_t length); #endif - /* * Note: DEBUG_UART currently only works on STM32, * enabling on another platform will cause a crash. @@ -143,7 +72,6 @@ void serial_early_init(void) { #ifdef MY_DEBUGUART _debug_uart_init(); - _debug_led_init(); #endif } From 36c59250dde158d8b123ba8c20091fb04b3f5160 Mon Sep 17 00:00:00 2001 From: jun2sak Date: Sun, 21 Feb 2021 09:57:14 +0900 Subject: [PATCH 07/67] some cleanups. --- ports/nrf/common-hal/alarm/__init__.c | 34 +++-- ports/nrf/common-hal/alarm/pin/PinAlarm.c | 175 +++++++++++----------- 2 files changed, 107 insertions(+), 102 deletions(-) diff --git a/ports/nrf/common-hal/alarm/__init__.c b/ports/nrf/common-hal/alarm/__init__.c index 4fe8432a1f..d39c38fe44 100644 --- a/ports/nrf/common-hal/alarm/__init__.c +++ b/ports/nrf/common-hal/alarm/__init__.c @@ -51,7 +51,8 @@ #include "nrfx.h" #include "nrfx_gpiote.h" - +#if 0 +// XXX #define DEBUG_LED_PIN (NRF_GPIO_PIN_MAP(1, 11)) // P1_11 = LED void _debug_led_init(void) { nrf_gpio_cfg_output(DEBUG_LED_PIN); @@ -59,7 +60,7 @@ void _debug_led_init(void) { void _debug_led_set(int v) { nrf_gpio_pin_write(DEBUG_LED_PIN, v); } - +#endif // Singleton instance of SleepMemory. const alarm_sleep_memory_obj_t alarm_sleep_memory_obj = { @@ -84,10 +85,10 @@ STATIC nrf_sleep_source_t _get_wakeup_cause(void) { return NRF_SLEEP_WAKEUP_TIMER; } #if 0 + // XXX not implemented yet if (alarm_touch_touchalarm_woke_us_up()) { return ESP_SLEEP_WAKEUP_TOUCHPAD; } - return esp_sleep_get_wakeup_cause(); #endif if (reset_reason_saved & NRF_POWER_RESETREAS_RESETPIN_MASK) { return NRF_SLEEP_WAKEUP_RESETPIN; @@ -130,16 +131,16 @@ STATIC mp_obj_t _get_wake_alarm(size_t n_alarms, const mp_obj_t *alarms) { #endif switch (cause) { case NRF_SLEEP_WAKEUP_TIMER: { - return alarm_time_timealarm_get_wakeup_alarm(n_alarms, alarms); + return alarm_time_timealarm_get_wakeup_alarm(n_alarms, alarms); } case NRF_SLEEP_WAKEUP_TOUCHPAD: { - return mp_const_none; + return mp_const_none; } case NRF_SLEEP_WAKEUP_GPIO: { - return alarm_pin_pinalarm_get_wakeup_alarm(n_alarms, alarms); + return alarm_pin_pinalarm_get_wakeup_alarm(n_alarms, alarms); } default: - break; + break; } return mp_const_none; } @@ -154,6 +155,7 @@ STATIC void _setup_sleep_alarms(bool deep_sleep, size_t n_alarms, const mp_obj_t alarm_pin_pinalarm_set_alarms(deep_sleep, n_alarms, alarms); alarm_time_timealarm_set_alarms(deep_sleep, n_alarms, alarms); #if 0 + // XXX not implemented yet alarm_touch_touchalarm_set_alarm(deep_sleep, n_alarms, alarms); #endif } @@ -170,17 +172,17 @@ STATIC void _idle_until_alarm(void) { if (alarm_woken_from_sleep()) { alarm_save_wake_alarm(); #ifdef MY_DEBUGUART - int cause = _get_wakeup_cause(); - printf("wakeup(%d)\r\n", cause); + int cause = _get_wakeup_cause(); + printf("wakeup(%d)\r\n", cause); #endif return; } port_idle_until_interrupt(); #ifdef MY_DEBUGUART - if (ct > 0) { - printf("_"); - --ct; - } + if (ct > 0) { + printf("_"); + --ct; + } #endif } } @@ -201,8 +203,8 @@ mp_obj_t common_hal_alarm_light_sleep_until_alarms(size_t n_alarms, const mp_obj r_obj = mp_const_none; } else { - r_obj = _get_wake_alarm(n_alarms, alarms); - alarm_reset(); + r_obj = _get_wake_alarm(n_alarms, alarms); + alarm_reset(); } return r_obj; } @@ -213,7 +215,7 @@ void common_hal_alarm_set_deep_sleep_alarms(size_t n_alarms, const mp_obj_t *ala void NORETURN alarm_enter_deep_sleep(void) { alarm_pin_pinalarm_prepare_for_deep_sleep(); - //alarm_touch_touchalarm_prepare_for_deep_sleep(); + //alarm_touch_touchalarm_prepare_for_deep_sleep(); // XXX uint8_t sd_enabled; sd_softdevice_is_enabled(&sd_enabled); diff --git a/ports/nrf/common-hal/alarm/pin/PinAlarm.c b/ports/nrf/common-hal/alarm/pin/PinAlarm.c index 1945beaaf8..9ccc79db92 100644 --- a/ports/nrf/common-hal/alarm/pin/PinAlarm.c +++ b/ports/nrf/common-hal/alarm/pin/PinAlarm.c @@ -78,8 +78,8 @@ bool common_hal_alarm_pin_pinalarm_get_pull(alarm_pin_pinalarm_obj_t *self) { static void pinalarm_gpiote_handler(nrfx_gpiote_pin_t pin, nrf_gpiote_polarity_t action) { - ++_pinhandler_gpiote_count; - _pinhandler_ev_pin = pin; + ++_pinhandler_gpiote_count; + _pinhandler_ev_pin = pin; } bool alarm_pin_pinalarm_woke_us_up(void) { @@ -136,93 +136,95 @@ void alarm_pin_pinalarm_reset(void) { pull_pins = 0; } -void _setup2(void) { - nrfx_gpiote_in_config_t cfg = { - .sense = NRF_GPIOTE_POLARITY_TOGGLE, - .pull = NRF_GPIO_PIN_PULLUP, - .is_watcher = false, - .hi_accuracy = true, - .skip_gpio_setup = false - }; - for(size_t i = 0; i < 64; ++i) { - uint64_t mask = 1ull << i; -#ifdef MY_DEBUGUART - int pull = 0; - int sense = 0; -#endif - if (((high_alarms & mask) == 0) && ((low_alarms & mask) == 0)) { - continue; +static void setup_pin1_for_lightsleep(void) { + if ( nrfx_gpiote_is_init() ) { + nrfx_gpiote_uninit(); } - if (((high_alarms & mask) != 0) && ((low_alarms & mask) == 0)) { - cfg.sense = NRF_GPIOTE_POLARITY_LOTOHI; - cfg.pull = ((pull_pins & mask) != 0) ? NRF_GPIO_PIN_PULLDOWN : NRF_GPIO_PIN_NOPULL; -#ifdef MY_DEBUGUART - pull = -1; sense = 1; -#endif - } - else - if (((high_alarms & mask) == 0) && ((low_alarms & mask) != 0)) { - cfg.sense = NRF_GPIOTE_POLARITY_HITOLO; - cfg.pull = ((pull_pins & mask) != 0) ? NRF_GPIO_PIN_PULLUP : NRF_GPIO_PIN_NOPULL; -#ifdef MY_DEBUGUART - pull = 1; sense = -1; -#endif - } - else { - cfg.sense = NRF_GPIOTE_POLARITY_TOGGLE; - cfg.pull = NRF_GPIO_PIN_NOPULL; -#ifdef MY_DEBUGUART - sense = 9; -#endif - } - nrfx_gpiote_in_init((nrfx_gpiote_pin_t)i, &cfg, pinalarm_gpiote_handler); - nrfx_gpiote_in_event_enable((nrfx_gpiote_pin_t)i, true); -#ifdef MY_DEBUGUART - dbg_printf("pin=%d, sense=%d, pull=%d\r\n", i, sense, pull); -#endif - } -} + nrfx_gpiote_init(NRFX_GPIOTE_CONFIG_IRQ_PRIORITY); -void _setup_pin1_for_lightsleep(void) { - if ( nrfx_gpiote_is_init() ) { - nrfx_gpiote_uninit(); - } - nrfx_gpiote_init(NRFX_GPIOTE_CONFIG_IRQ_PRIORITY); + _pinhandler_gpiote_count = 0; + _pinhandler_ev_pin = MYGPIOTE_EV_PIN_UNDEF; - _pinhandler_gpiote_count = 0; - _pinhandler_ev_pin = MYGPIOTE_EV_PIN_UNDEF; - _setup2(); -} - -void _setup_pin1_for_deepsleep(void) { + nrfx_gpiote_in_config_t cfg = { + .sense = NRF_GPIOTE_POLARITY_TOGGLE, + .pull = NRF_GPIO_PIN_PULLUP, + .is_watcher = false, + .hi_accuracy = true, + .skip_gpio_setup = false + }; for(size_t i = 0; i < 64; ++i) { - uint64_t mask = 1ull << i; - int pull = 0; + uint64_t mask = 1ull << i; #ifdef MY_DEBUGUART - int sense = 0; + int pull = 0; + int sense = 0; #endif - if (((high_alarms & mask) == 0) && ((low_alarms & mask) == 0)) { - continue; - } - if (((high_alarms & mask) != 0) && ((low_alarms & mask) == 0)) { - pull = ((pull_pins & mask) != 0) ? NRF_GPIO_PIN_PULLDOWN : NRF_GPIO_PIN_NOPULL; - nrf_gpio_cfg_input((uint32_t)i, (nrf_gpio_pin_pull_t)pull); - nrf_gpio_cfg_sense_set((uint32_t)i, NRF_GPIO_PIN_SENSE_HIGH); + if (((high_alarms & mask) == 0) && ((low_alarms & mask) == 0)) { + continue; + } + if (((high_alarms & mask) != 0) && ((low_alarms & mask) == 0)) { + cfg.sense = NRF_GPIOTE_POLARITY_LOTOHI; + cfg.pull = ((pull_pins & mask) != 0) ? + NRF_GPIO_PIN_PULLDOWN : NRF_GPIO_PIN_NOPULL; #ifdef MY_DEBUGUART - sense = NRF_GPIO_PIN_SENSE_HIGH; + pull = -1; sense = 1; #endif - } - else - if (((high_alarms & mask) == 0) && ((low_alarms & mask) != 0)) { - pull = ((pull_pins & mask) != 0) ? NRF_GPIO_PIN_PULLUP : NRF_GPIO_PIN_NOPULL; - nrf_gpio_cfg_input((uint32_t)i, (nrf_gpio_pin_pull_t)pull); - nrf_gpio_cfg_sense_set((uint32_t)i, NRF_GPIO_PIN_SENSE_LOW); + } + else + if (((high_alarms & mask) == 0) && ((low_alarms & mask) != 0)) { + cfg.sense = NRF_GPIOTE_POLARITY_HITOLO; + cfg.pull = ((pull_pins & mask) != 0) ? + NRF_GPIO_PIN_PULLUP : NRF_GPIO_PIN_NOPULL; #ifdef MY_DEBUGUART - sense = NRF_GPIO_PIN_SENSE_LOW; + pull = 1; sense = -1; #endif - } + } + else { + cfg.sense = NRF_GPIOTE_POLARITY_TOGGLE; + cfg.pull = NRF_GPIO_PIN_NOPULL; #ifdef MY_DEBUGUART - dbg_printf("pin=%d, sense=%d, pull=%d\r\n", i, sense, pull); + sense = 9; +#endif + } + nrfx_gpiote_in_init((nrfx_gpiote_pin_t)i, &cfg, + pinalarm_gpiote_handler); + nrfx_gpiote_in_event_enable((nrfx_gpiote_pin_t)i, true); +#ifdef MY_DEBUGUART + dbg_printf("pin=%d, sense=%d, pull=%d\r\n", i, sense, pull); +#endif + } +} + +static void setup_pin1_for_deepsleep(void) { + for(size_t i = 0; i < 64; ++i) { + uint64_t mask = 1ull << i; + int pull = 0; +#ifdef MY_DEBUGUART + int sense = 0; +#endif + if (((high_alarms & mask) == 0) && ((low_alarms & mask) == 0)) { + continue; + } + if (((high_alarms & mask) != 0) && ((low_alarms & mask) == 0)) { + pull = ((pull_pins & mask) != 0) ? + NRF_GPIO_PIN_PULLDOWN : NRF_GPIO_PIN_NOPULL; + nrf_gpio_cfg_input((uint32_t)i, (nrf_gpio_pin_pull_t)pull); + nrf_gpio_cfg_sense_set((uint32_t)i, NRF_GPIO_PIN_SENSE_HIGH); +#ifdef MY_DEBUGUART + sense = NRF_GPIO_PIN_SENSE_HIGH; +#endif + } + else + if (((high_alarms & mask) == 0) && ((low_alarms & mask) != 0)) { + pull = ((pull_pins & mask) != 0) ? + NRF_GPIO_PIN_PULLUP : NRF_GPIO_PIN_NOPULL; + nrf_gpio_cfg_input((uint32_t)i, (nrf_gpio_pin_pull_t)pull); + nrf_gpio_cfg_sense_set((uint32_t)i, NRF_GPIO_PIN_SENSE_LOW); +#ifdef MY_DEBUGUART + sense = NRF_GPIO_PIN_SENSE_LOW; +#endif + } +#ifdef MY_DEBUGUART + dbg_printf("pin=%d, sense=%d, pull=%d\r\n", i, sense, pull); #endif } #if 0 @@ -261,18 +263,19 @@ void alarm_pin_pinalarm_set_alarms(bool deep_sleep, size_t n_alarms, const mp_ob } } if (pin_number != -1) { - if (!deep_sleep) { - _setup_pin1_for_lightsleep(); - } - else { - //_setup_pin1_for_deepsleep(pin_number); - } + if (!deep_sleep) { + setup_pin1_for_lightsleep(); + } + else { + // we don't setup gpio HW here but do them in + // alarm_pin_pinalarm_prepare_for_deep_sleep() below + } } else { - //dbg_printf("alarm_pin_pinalarm_set_alarms() no valid pins\r\n"); + //dbg_printf("alarm_pin_pinalarm_set_alarms() no valid pins\r\n"); } } void alarm_pin_pinalarm_prepare_for_deep_sleep(void) { - _setup_pin1_for_deepsleep(); + setup_pin1_for_deepsleep(); } From 62b38e273b2aff3c250d3fb87986fba8a199c16d Mon Sep 17 00:00:00 2001 From: jun2sak Date: Sun, 21 Feb 2021 15:37:51 +0900 Subject: [PATCH 08/67] update translation file. --- locale/circuitpython.pot | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/locale/circuitpython.pot b/locale/circuitpython.pot index 0a79520b88..e90883582c 100644 --- a/locale/circuitpython.pot +++ b/locale/circuitpython.pot @@ -307,6 +307,10 @@ msgstr "" msgid "Address type out of range" msgstr "" +#: ports/nrf/common-hal/alarm/time/TimeAlarm.c +msgid "Alarm time is too far." +msgstr "" + #: ports/esp32s2/common-hal/canio/CAN.c msgid "All CAN peripherals are in use" msgstr "" @@ -609,6 +613,7 @@ msgid "Cannot output both channels on the same pin" msgstr "" #: ports/esp32s2/common-hal/alarm/pin/PinAlarm.c +#: ports/nrf/common-hal/alarm/pin/PinAlarm.c msgid "Cannot pull on input-only pin." msgstr "" @@ -660,6 +665,7 @@ msgid "Cannot vary frequency on a timer that is already in use" msgstr "" #: ports/esp32s2/common-hal/alarm/pin/PinAlarm.c +#: ports/nrf/common-hal/alarm/pin/PinAlarm.c msgid "Cannot wake on pin edge. Only level." msgstr "" @@ -1066,6 +1072,7 @@ msgid "I2SOut not available" msgstr "" #: ports/esp32s2/common-hal/alarm/pin/__init__.c +#: ports/nrf/common-hal/alarm/pin/__init__.c msgid "IOs 0, 2 & 4 do not support internal pullup in sleep" msgstr "" @@ -1251,7 +1258,8 @@ msgstr "" #: ports/atmel-samd/common-hal/audioio/AudioOut.c #: ports/atmel-samd/common-hal/touchio/TouchIn.c #: ports/esp32s2/common-hal/alarm/touch/TouchAlarm.c -#: ports/esp32s2/common-hal/touchio/TouchIn.c shared-bindings/pwmio/PWMOut.c +#: ports/esp32s2/common-hal/touchio/TouchIn.c +#: ports/nrf/common-hal/alarm/touch/TouchAlarm.c shared-bindings/pwmio/PWMOut.c #: shared-module/rgbmatrix/RGBMatrix.c msgid "Invalid pin" msgstr "" @@ -1633,10 +1641,12 @@ msgid "" msgstr "" #: ports/esp32s2/common-hal/alarm/touch/TouchAlarm.c +#: ports/nrf/common-hal/alarm/touch/TouchAlarm.c msgid "Only one TouchAlarm can be set in deep sleep." msgstr "" #: ports/esp32s2/common-hal/alarm/time/TimeAlarm.c +#: ports/nrf/common-hal/alarm/time/TimeAlarm.c msgid "Only one alarm.time alarm can be set." msgstr "" @@ -3207,6 +3217,7 @@ msgid "invalid syntax for number" msgstr "" #: ports/esp32s2/common-hal/alarm/pin/__init__.c +#: ports/nrf/common-hal/alarm/pin/__init__.c msgid "io must be rtc io" msgstr "" @@ -3958,6 +3969,7 @@ msgid "trapz is defined for 1D arrays of equal length" msgstr "" #: ports/esp32s2/common-hal/alarm/pin/__init__.c +#: ports/nrf/common-hal/alarm/pin/__init__.c msgid "trigger level must be 0 or 1" msgstr "" @@ -4100,6 +4112,7 @@ msgid "vectors must have same lengths" msgstr "" #: ports/esp32s2/common-hal/alarm/pin/__init__.c +#: ports/nrf/common-hal/alarm/pin/__init__.c msgid "wakeup conflict" msgstr "" From 5c858a192562bf854beb2cd9c3c59ce5d8f9da54 Mon Sep 17 00:00:00 2001 From: jun2sak Date: Sun, 21 Feb 2021 16:27:21 +0900 Subject: [PATCH 09/67] add weak board_deinit(). --- ports/nrf/supervisor/port.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/ports/nrf/supervisor/port.c b/ports/nrf/supervisor/port.c index d3c31b51a6..264fb81982 100644 --- a/ports/nrf/supervisor/port.c +++ b/ports/nrf/supervisor/port.c @@ -472,3 +472,9 @@ void HardFault_Handler(void) { asm("nop;"); } } + +#if CIRCUITPY_ALARM +// in case boards/xxx/board.c does not provide board_deinit() +MP_WEAK void board_deinit(void) { +} +#endif From 9df0f439f300f81c28d28473097cb9b897513b2b Mon Sep 17 00:00:00 2001 From: jun2sak Date: Tue, 23 Feb 2021 10:31:49 +0900 Subject: [PATCH 10/67] alarm/pin/__init__.c is no longer used. --- ports/nrf/common-hal/alarm/pin/__init__.c | 34 +++-------------------- 1 file changed, 4 insertions(+), 30 deletions(-) diff --git a/ports/nrf/common-hal/alarm/pin/__init__.c b/ports/nrf/common-hal/alarm/pin/__init__.c index d2ce00a3e3..94778f5eb1 100644 --- a/ports/nrf/common-hal/alarm/pin/__init__.c +++ b/ports/nrf/common-hal/alarm/pin/__init__.c @@ -1,38 +1,12 @@ //#include "shared-bindings/alarm_io/__init__.h" -//#include "esp_sleep.h" -//#include "driver/rtc_io.h" +// these are in esp32s2 implementation, +// but not used in nrf -mp_obj_t common_hal_alarm_io_pin_state (alarm_io_obj_t *self_in) { #if 0 - if (!rtc_gpio_is_valid_gpio(self_in->gpio)) { - 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")); - case ESP_ERR_INVALID_STATE: - mp_raise_RuntimeError(translate("wakeup conflict")); - default: - break; - } - - if (self_in->pull) { (self_in->level) ? rtc_gpio_pulldown_en(self_in->gpio) : rtc_gpio_pullup_en(self_in->gpio); } -#endif - return self_in; +mp_obj_t common_hal_alarm_io_pin_state (alarm_io_obj_t *self_in) { } void common_hal_alarm_io_disable (void) { -#if 0 - esp_sleep_disable_wakeup_source(ESP_SLEEP_WAKEUP_EXT0 | ESP_SLEEP_WAKEUP_EXT1); -#endif } +#endif From 372c98626a8e0cc7031d89e803a40ecb4746f7da Mon Sep 17 00:00:00 2001 From: jun2sak Date: Tue, 23 Feb 2021 11:56:40 +0900 Subject: [PATCH 11/67] move all the debug codes from port.c to debug_uart.c. --- ports/nrf/Makefile | 4 +- ports/nrf/supervisor/debug_uart.c | 106 ++++++++++++++++++++++++++++++ ports/nrf/supervisor/port.c | 97 +-------------------------- 3 files changed, 110 insertions(+), 97 deletions(-) create mode 100644 ports/nrf/supervisor/debug_uart.c diff --git a/ports/nrf/Makefile b/ports/nrf/Makefile index c78a5dc503..6a22e62195 100755 --- a/ports/nrf/Makefile +++ b/ports/nrf/Makefile @@ -95,11 +95,9 @@ else CFLAGS += -flto -flto-partition=none endif -ifeq ($(MY_DBG), 1) - CFLAGS += -DMY_DBG -endif ifeq ($(MY_DEBUGUART), 1) CFLAGS += -DMY_DEBUGUART=1 + SRC_SUPERVISOR += supervisor/debug_uart.c endif # option to override compiler optimization level, set in boards/$(BOARD)/mpconfigboard.mk diff --git a/ports/nrf/supervisor/debug_uart.c b/ports/nrf/supervisor/debug_uart.c new file mode 100644 index 0000000000..2bd6be39c6 --- /dev/null +++ b/ports/nrf/supervisor/debug_uart.c @@ -0,0 +1,106 @@ +/* + * debug functions + * (will be removed) + */ + +#include +#include +#include +#include + +#ifdef MY_DEBUGUART + +#define DEBUG_UART_TXPIN 26 +#define DEBUG_UART_RXPIN 15 + +#include "nrfx.h" +#include "nrf_uart.h" +#include "nrf_gpio.h" +#include "nrf_rtc.h" +#include "nrfx_uarte.h" +#include "nrfx_rtc.h" +#include "supervisor/serial.h" // dbg_printf() + +extern const nrfx_rtc_t rtc_instance; // port.c +extern volatile int rtc_woke_up_counter; // port.c + +const nrfx_uarte_t _dbg_uart_inst = NRFX_UARTE_INSTANCE(1); +static int _dbg_uart_initialized = 0; +#define DBG_PBUF_LEN 80 +static char _dbg_pbuf[DBG_PBUF_LEN+1]; + +void _debug_uart_init(void) { + //if (_dbg_uart_initialized) return; + nrfx_uarte_config_t config = { + .pseltxd = DEBUG_UART_TXPIN, + .pselrxd = DEBUG_UART_RXPIN, + .pselcts = NRF_UARTE_PSEL_DISCONNECTED, + .pselrts = NRF_UARTE_PSEL_DISCONNECTED, + .p_context = NULL, + .baudrate = NRF_UART_BAUDRATE_115200, + .interrupt_priority = 7, + .hal_cfg = { + .hwfc = NRF_UARTE_HWFC_DISABLED, + .parity = NRF_UARTE_PARITY_EXCLUDED + } + }; + nrfx_uarte_init(&_dbg_uart_inst, &config, NULL); + // drive config + nrf_gpio_cfg(config.pseltxd, + NRF_GPIO_PIN_DIR_OUTPUT, + NRF_GPIO_PIN_INPUT_DISCONNECT, + NRF_GPIO_PIN_PULLUP, // orig=NOPULL + NRF_GPIO_PIN_H0H1, // orig=S0S1 + NRF_GPIO_PIN_NOSENSE); + _dbg_uart_initialized = 1; + return; +} + +void _debug_print_substr(const char* text, uint32_t length) { + char* data = (char*)text; + int siz; + while(length != 0) { + if (length <= DBG_PBUF_LEN) { + siz = length; + } + else { + siz = DBG_PBUF_LEN; + } + memcpy(_dbg_pbuf, data, siz); + _dbg_pbuf[siz] = 0; + nrfx_uarte_tx(&_dbg_uart_inst, (uint8_t const*)_dbg_pbuf, siz); + data += siz; + length -= siz; + } +} + +void _debug_uart_deinit(void) { + nrfx_uarte_uninit(&_dbg_uart_inst); +} + +int dbg_printf(const char *fmt, ...) { + va_list ap; + va_start(ap, fmt); + int ret = vprintf(fmt, ap); + va_end(ap); + return ret; +} + + +void dbg_dumpRTC(void) { + dbg_printf("\r\nRTC2\r\n"); + NRF_RTC_Type *r = rtc_instance.p_reg; + dbg_printf("PRESCALER=%08X, ", (int)r->PRESCALER); + dbg_printf("COUNTER=%08X ", (int)r->COUNTER); + dbg_printf("INTENSET=%08X ", (int)r->INTENSET); + dbg_printf("EVTENSET=%08X\r\n", (int)r->EVTENSET); + dbg_printf("EVENTS_COMPARE[0..3]=%X,%X,%X,%X ", (int)r->EVENTS_COMPARE[0], (int)r->EVENTS_COMPARE[1], (int)r->EVENTS_COMPARE[2], (int)r->EVENTS_COMPARE[3]); + dbg_printf("CC[0..3]=%08X,%08X,%08X,%08X\r\n", (int)r->CC[0], (int)r->CC[1], (int)r->CC[2], (int)r->CC[3]); + dbg_printf("woke_up=%d\r\n", rtc_woke_up_counter); +} + +#else /*!MY_DEBUGUART*/ +int dbg_printf(const char *fmt, ...) { + return 0; +} +#endif /*!MY_DEBUGUART*/ diff --git a/ports/nrf/supervisor/port.c b/ports/nrf/supervisor/port.c index 264fb81982..d29659bf8d 100644 --- a/ports/nrf/supervisor/port.c +++ b/ports/nrf/supervisor/port.c @@ -27,10 +27,6 @@ #include #include "supervisor/port.h" #include "supervisor/board.h" -#ifdef MY_DEBUGUART -#include "supervisor/serial.h" // dbg_printf() -extern void _debug_uart_init(void); -#endif #include "nrfx/hal/nrf_clock.h" #include "nrfx/hal/nrf_power.h" @@ -78,82 +74,12 @@ static void power_warning_handler(void) { } #ifdef MY_DEBUGUART -#include -#include -#include "nrfx.h" -#include "nrf_uart.h" -#include "nrfx_uart.h" -const nrfx_uarte_t _dbg_uart_inst = NRFX_UARTE_INSTANCE(1); -static int _dbg_uart_initialized = 0; -#define DBG_PBUF_LEN 80 -static char _dbg_pbuf[DBG_PBUF_LEN+1]; - -void _debug_uart_init(void) { - //if (_dbg_uart_initialized) return; - nrfx_uarte_config_t config = { - .pseltxd = 26, - .pselrxd = 15, - .pselcts = NRF_UARTE_PSEL_DISCONNECTED, - .pselrts = NRF_UARTE_PSEL_DISCONNECTED, - .p_context = NULL, - .baudrate = NRF_UART_BAUDRATE_115200, - .interrupt_priority = 7, - .hal_cfg = { - .hwfc = NRF_UARTE_HWFC_DISABLED, - .parity = NRF_UARTE_PARITY_EXCLUDED - } - }; - nrfx_uarte_init(&_dbg_uart_inst, &config, NULL); - // drive config - nrf_gpio_cfg(config.pseltxd, - NRF_GPIO_PIN_DIR_OUTPUT, - NRF_GPIO_PIN_INPUT_DISCONNECT, - NRF_GPIO_PIN_PULLUP, // orig=NOPULL - NRF_GPIO_PIN_H0H1, // orig=S0S1 - NRF_GPIO_PIN_NOSENSE); - _dbg_uart_initialized = 1; - return; -} - -void _debug_print_substr(const char* text, uint32_t length) { - char* data = (char*)text; - int siz; - while(length != 0) { - if (length <= DBG_PBUF_LEN) { - siz = length; - } - else { - siz = DBG_PBUF_LEN; - } - memcpy(_dbg_pbuf, data, siz); - _dbg_pbuf[siz] = 0; - nrfx_uarte_tx(&_dbg_uart_inst, (uint8_t const*)_dbg_pbuf, siz); - data += siz; - length -= siz; - } -} - -void _debug_uart_deinit(void) { - nrfx_uarte_uninit(&_dbg_uart_inst); -} - -int dbg_printf(const char *fmt, ...) { - va_list ap; - va_start(ap, fmt); - int ret = vprintf(fmt, ap); - va_end(ap); - return ret; -} - -extern void _debug_led_init(void); -extern void _debug_led_set(int v); -#else /*!MY_DEBUGUART*/ -int dbg_printf(const char *fmt, ...) { - return 0; -} +extern void _debug_uart_init(void); #endif +uint32_t reset_reason_saved = 0; const nrfx_rtc_t rtc_instance = NRFX_RTC_INSTANCE(2); +volatile int rtc_woke_up_counter = 0; const nrfx_rtc_config_t rtc_config = { .prescaler = RTC_FREQ_TO_PRESCALER(0x8000), @@ -170,9 +96,6 @@ static volatile struct { uint32_t suffix; } overflow_tracker __attribute__((section(".uninitialized"))); -uint32_t reset_reason_saved = 0; -volatile int rtc_woke_up_counter = 0; - void rtc_handler(nrfx_rtc_int_type_t int_type) { if (int_type == NRFX_RTC_INT_OVERFLOW) { // Our RTC is 24 bits and we're clocking it at 32.768khz which is 32 (2 ** 5) subticks per @@ -190,20 +113,6 @@ void rtc_handler(nrfx_rtc_int_type_t int_type) { } } -#ifdef MY_DEBUGUART -void dbg_dumpRTC(void) { - dbg_printf("\r\nRTC2\r\n"); - NRF_RTC_Type *r = rtc_instance.p_reg; - dbg_printf("PRESCALER=%08X, ", (int)r->PRESCALER); - dbg_printf("COUNTER=%08X ", (int)r->COUNTER); - dbg_printf("INTENSET=%08X ", (int)r->INTENSET); - dbg_printf("EVTENSET=%08X\r\n", (int)r->EVTENSET); - dbg_printf("EVENTS_COMPARE[0..3]=%X,%X,%X,%X ", (int)r->EVENTS_COMPARE[0], (int)r->EVENTS_COMPARE[1], (int)r->EVENTS_COMPARE[2], (int)r->EVENTS_COMPARE[3]); - dbg_printf("CC[0..3]=%08X,%08X,%08X,%08X\r\n", (int)r->CC[0], (int)r->CC[1], (int)r->CC[2], (int)r->CC[3]); - dbg_printf("woke_up=%d\r\n", rtc_woke_up_counter); -} -#endif - void tick_init(void) { if (!nrf_clock_lf_is_running(NRF_CLOCK)) { nrf_clock_task_trigger(NRF_CLOCK, NRF_CLOCK_TASK_LFCLKSTART); From ec64fa6a291d2f7449f6ef1fc0313b53a889a6aa Mon Sep 17 00:00:00 2001 From: jun2sak Date: Tue, 23 Feb 2021 12:16:37 +0900 Subject: [PATCH 12/67] move dump_xxx functions to debug_uart.c. --- main.c | 10 ++++------ ports/nrf/common-hal/alarm/SleepMemory.c | 22 +++++----------------- ports/nrf/common-hal/alarm/__init__.c | 11 ----------- ports/nrf/supervisor/debug_uart.c | 22 +++++++++++++++++++++- 4 files changed, 30 insertions(+), 35 deletions(-) diff --git a/main.c b/main.c index 2a256f5b5d..0ca6684356 100755 --- a/main.c +++ b/main.c @@ -588,12 +588,10 @@ int __attribute__((used)) main(void) { serial_init(); #if 0 //XXX - int rr = (int)common_hal_mcu_processor_get_reset_reason(); - const char* rrstr[] = { - "POWER_ON", "BROWNOUT", "SOFTWARE", "DEEPSLEEPALARM", - "RESET_PIN", "WATCHDOG", "UNKNOWN" - }; - dbg_printf("reset_reason=%s\r\n", rrstr[rr]); + { + extern void dbg_dump_reset_reason(void); + dbg_dump_reset_reason(); + } #endif #if CIRCUITPY_BLEIO diff --git a/ports/nrf/common-hal/alarm/SleepMemory.c b/ports/nrf/common-hal/alarm/SleepMemory.c index a867b17b13..62afd37379 100644 --- a/ports/nrf/common-hal/alarm/SleepMemory.c +++ b/ports/nrf/common-hal/alarm/SleepMemory.c @@ -47,26 +47,15 @@ static int is_sleep_memory_valid(void) { return 0; } -static void dumpRAMreg(void) { -#ifdef MY_DEBUGUART - int i; - for(i = 0; i <= 8; ++i) { - dbg_printf(" RAM%d:%08X", i, (int)(NRF_POWER->RAM[i].POWER)); - if (i==4) dbg_printf("\r\n"); - } - dbg_printf("\r\n"); -#endif -} - +extern void dbg_dump_RAMreg(void); static void initialize_sleep_memory(void) { memset((uint8_t *)_sleep_mem, 0, SLEEP_MEMORY_LENGTH); // also, set RAM[n].POWER register for RAM retention // nRF52840 has RAM[0..7].Section[0..1] and RAM[8].Section[0..5] // nRF52833 has RAM[0..7].Section[0..1] and RAM[8].Section[0,1] - dumpRAMreg(); for(int ram = 0; ram <= 7; ++ram) { - NRF_POWER->RAM[ram].POWERSET = 0x00030000; // RETENTION for section 0,1 + NRF_POWER->RAM[ram].POWERSET = 0x00030000; // RETENTION for section 0,1 }; #ifdef NRF52840 NRF_POWER->RAM[8].POWERSET = 0x001F0000; // RETENTION for section 0..5 @@ -74,7 +63,9 @@ static void initialize_sleep_memory(void) { #ifdef NRF52833 NRF_POWER->RAM[8].POWERSET = 0x00030000; // RETENTION for section 0,1 #endif - dumpRAMreg(); +#ifdef MY_DEBUGUART + dbg_dump_RAMreg(); +#endif _sleep_mem_magicnum = SLEEP_MEMORY_DATA_GUARD; } @@ -82,9 +73,6 @@ static void initialize_sleep_memory(void) { void alarm_sleep_memory_reset(void) { if (!is_sleep_memory_valid()) { initialize_sleep_memory(); -#ifdef MY_DEBUGUART - dbg_printf("_sleep_mem[] initialized\r\n"); -#endif } } diff --git a/ports/nrf/common-hal/alarm/__init__.c b/ports/nrf/common-hal/alarm/__init__.c index d39c38fe44..dfdcb76889 100644 --- a/ports/nrf/common-hal/alarm/__init__.c +++ b/ports/nrf/common-hal/alarm/__init__.c @@ -51,17 +51,6 @@ #include "nrfx.h" #include "nrfx_gpiote.h" -#if 0 -// XXX -#define DEBUG_LED_PIN (NRF_GPIO_PIN_MAP(1, 11)) // P1_11 = LED -void _debug_led_init(void) { - nrf_gpio_cfg_output(DEBUG_LED_PIN); -} -void _debug_led_set(int v) { - nrf_gpio_pin_write(DEBUG_LED_PIN, v); -} -#endif - // Singleton instance of SleepMemory. const alarm_sleep_memory_obj_t alarm_sleep_memory_obj = { .base = { diff --git a/ports/nrf/supervisor/debug_uart.c b/ports/nrf/supervisor/debug_uart.c index 2bd6be39c6..53a3baebf9 100644 --- a/ports/nrf/supervisor/debug_uart.c +++ b/ports/nrf/supervisor/debug_uart.c @@ -20,9 +20,11 @@ #include "nrfx_uarte.h" #include "nrfx_rtc.h" #include "supervisor/serial.h" // dbg_printf() +#include "shared-bindings/microcontroller/Processor.h" extern const nrfx_rtc_t rtc_instance; // port.c extern volatile int rtc_woke_up_counter; // port.c +extern uint32_t reset_reason_saved; const nrfx_uarte_t _dbg_uart_inst = NRFX_UARTE_INSTANCE(1); static int _dbg_uart_initialized = 0; @@ -87,7 +89,7 @@ int dbg_printf(const char *fmt, ...) { } -void dbg_dumpRTC(void) { +void dbg_dump_RTCreg(void) { dbg_printf("\r\nRTC2\r\n"); NRF_RTC_Type *r = rtc_instance.p_reg; dbg_printf("PRESCALER=%08X, ", (int)r->PRESCALER); @@ -99,6 +101,24 @@ void dbg_dumpRTC(void) { dbg_printf("woke_up=%d\r\n", rtc_woke_up_counter); } +void dbg_dump_RAMreg(void) { + int i; + for(i = 0; i <= 8; ++i) { + dbg_printf(" RAM%d:%08X", i, (int)(NRF_POWER->RAM[i].POWER)); + if (i==4) dbg_printf("\r\n"); + } + dbg_printf("\r\n"); +} + +void dbg_dump_reset_reason(void) { + int reset_reason = (int)common_hal_mcu_processor_get_reset_reason(); + const char* rr_str[] = { + "POWER_ON", "BROWNOUT", "SOFTWARE", "DEEPSLEEPALARM", + "RESET_PIN", "WATCHDOG", "UNKNOWN" + }; + dbg_printf("reset_reason=%s\r\n", rr_str[reset_reason]); +} + #else /*!MY_DEBUGUART*/ int dbg_printf(const char *fmt, ...) { return 0; From 105042e870529092113ecfee24d8790a21f45f7b Mon Sep 17 00:00:00 2001 From: jun2sak Date: Tue, 23 Feb 2021 12:22:33 +0900 Subject: [PATCH 13/67] move dump_xxx functions to debug_uart.c. --- supervisor/shared/serial.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/supervisor/shared/serial.c b/supervisor/shared/serial.c index 832242214a..262fe706bd 100644 --- a/supervisor/shared/serial.c +++ b/supervisor/shared/serial.c @@ -37,7 +37,7 @@ #include "tusb.h" #ifdef MY_DEBUGUART -// XXX these functions are in nrf/supervisor/port.c +// XXX these functions are in nrf/supervisor/debug_uart.c extern void _debug_uart_init(void); extern void _debug_print_substr(const char* text, uint32_t length); #endif From 0f188befb6c115ad9bee9dee80ae47840cb560ab Mon Sep 17 00:00:00 2001 From: jun2sak Date: Wed, 24 Feb 2021 00:12:25 +0900 Subject: [PATCH 14/67] set RAM retention just before deep sleep --- ports/nrf/common-hal/alarm/SleepMemory.c | 21 ++++++++++++--------- ports/nrf/common-hal/alarm/__init__.c | 5 +++++ 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/ports/nrf/common-hal/alarm/SleepMemory.c b/ports/nrf/common-hal/alarm/SleepMemory.c index 62afd37379..89430f2937 100644 --- a/ports/nrf/common-hal/alarm/SleepMemory.c +++ b/ports/nrf/common-hal/alarm/SleepMemory.c @@ -26,13 +26,13 @@ */ #include -#ifdef MY_DEBUGUART -#include "supervisor/serial.h" // dbg_printf() -#endif - #include "py/runtime.h" #include "common-hal/alarm/SleepMemory.h" +#ifdef MY_DEBUGUART +extern void dbg_dump_RAMreg(void); +#endif + #define RTC_DATA_ATTR __attribute__((section(".uninitialized"))) static RTC_DATA_ATTR uint8_t _sleep_mem[SLEEP_MEMORY_LENGTH]; static RTC_DATA_ATTR uint32_t _sleep_mem_magicnum; @@ -47,11 +47,8 @@ static int is_sleep_memory_valid(void) { return 0; } -extern void dbg_dump_RAMreg(void); -static void initialize_sleep_memory(void) { - memset((uint8_t *)_sleep_mem, 0, SLEEP_MEMORY_LENGTH); - - // also, set RAM[n].POWER register for RAM retention +void set_memory_retention(void) { + // set RAM[n].POWER register for RAM retention // nRF52840 has RAM[0..7].Section[0..1] and RAM[8].Section[0..5] // nRF52833 has RAM[0..7].Section[0..1] and RAM[8].Section[0,1] for(int ram = 0; ram <= 7; ++ram) { @@ -63,6 +60,12 @@ static void initialize_sleep_memory(void) { #ifdef NRF52833 NRF_POWER->RAM[8].POWERSET = 0x00030000; // RETENTION for section 0,1 #endif +} + +static void initialize_sleep_memory(void) { + memset((uint8_t *)_sleep_mem, 0, SLEEP_MEMORY_LENGTH); + + set_memory_retention(); #ifdef MY_DEBUGUART dbg_dump_RAMreg(); #endif diff --git a/ports/nrf/common-hal/alarm/__init__.c b/ports/nrf/common-hal/alarm/__init__.c index dfdcb76889..14f6e041f9 100644 --- a/ports/nrf/common-hal/alarm/__init__.c +++ b/ports/nrf/common-hal/alarm/__init__.c @@ -202,12 +202,17 @@ void common_hal_alarm_set_deep_sleep_alarms(size_t n_alarms, const mp_obj_t *ala _setup_sleep_alarms(true, n_alarms, alarms); } +extern void set_memory_retention(void); + void NORETURN alarm_enter_deep_sleep(void) { alarm_pin_pinalarm_prepare_for_deep_sleep(); //alarm_touch_touchalarm_prepare_for_deep_sleep(); // XXX uint8_t sd_enabled; sd_softdevice_is_enabled(&sd_enabled); + + set_memory_retention(); + #ifdef MY_DEBUGUART dbg_printf("go system off.. %d\r\n", sd_enabled); #endif From 057682f776c52500cfbbdd5f7fbe70d4010d1ad1 Mon Sep 17 00:00:00 2001 From: jun2sak Date: Wed, 24 Feb 2021 00:13:11 +0900 Subject: [PATCH 15/67] cleanup. --- main.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/main.c b/main.c index 0ca6684356..d6ad3ac2c1 100755 --- a/main.c +++ b/main.c @@ -537,6 +537,10 @@ STATIC int run_repl(void) { return exit_code; } +#ifdef MY_DEBUGUART +extern void dbg_dump_reset_reason(void); +#endif + int __attribute__((used)) main(void) { // initialise the cpu and peripherals safe_mode_t safe_mode = port_init(); @@ -589,7 +593,6 @@ int __attribute__((used)) main(void) { #if 0 //XXX { - extern void dbg_dump_reset_reason(void); dbg_dump_reset_reason(); } #endif From 72b5f1a9a62d05330571f0e8e4bf0c5f1ffe0d7a Mon Sep 17 00:00:00 2001 From: jun2sak Date: Thu, 25 Feb 2021 01:38:23 +0900 Subject: [PATCH 16/67] clean up my personal settings. --- .gitignore | 6 ------ ports/nrf/Makefile | 1 - 2 files changed, 7 deletions(-) diff --git a/.gitignore b/.gitignore index 6f27970f89..a8814be45e 100644 --- a/.gitignore +++ b/.gitignore @@ -86,9 +86,3 @@ TAGS #################### .venv .env - -1FILES -2FILES -TAG -ports/nrf/LOG*.txt -ports/nrf/boards/pg8c diff --git a/ports/nrf/Makefile b/ports/nrf/Makefile index 6a22e62195..d48b788cba 100755 --- a/ports/nrf/Makefile +++ b/ports/nrf/Makefile @@ -87,7 +87,6 @@ INC += -I../../supervisor/shared/usb #Debugging/Optimization ifeq ($(DEBUG), 1) CFLAGS += -ggdb3 - CFLAGS += -DNDEBUG OPTIMIZATION_FLAGS = -Og else OPTIMIZATION_FLAGS ?= -O2 -fno-inline-functions From 9661d67cd37964afe66fdfced5620ac8c0c195bc Mon Sep 17 00:00:00 2001 From: jun2sak Date: Thu, 25 Feb 2021 01:49:57 +0900 Subject: [PATCH 17/67] replace MY_DEBUG_UART -> NRF_DEBUG_PRINT. --- main.c | 2 +- ports/nrf/Makefile | 4 ++-- ports/nrf/common-hal/alarm/SleepMemory.c | 4 ++-- ports/nrf/common-hal/alarm/__init__.c | 16 ++++++++-------- ports/nrf/common-hal/alarm/pin/PinAlarm.c | 18 +++++++++--------- ports/nrf/supervisor/debug_uart.c | 6 +++--- ports/nrf/supervisor/port.c | 4 ++-- supervisor/shared/serial.c | 8 ++++---- 8 files changed, 31 insertions(+), 31 deletions(-) diff --git a/main.c b/main.c index d6ad3ac2c1..c15d5810b0 100755 --- a/main.c +++ b/main.c @@ -537,7 +537,7 @@ STATIC int run_repl(void) { return exit_code; } -#ifdef MY_DEBUGUART +#ifdef NRF_DEBUG_PRINT extern void dbg_dump_reset_reason(void); #endif diff --git a/ports/nrf/Makefile b/ports/nrf/Makefile index d48b788cba..8925189f56 100755 --- a/ports/nrf/Makefile +++ b/ports/nrf/Makefile @@ -94,8 +94,8 @@ else CFLAGS += -flto -flto-partition=none endif -ifeq ($(MY_DEBUGUART), 1) - CFLAGS += -DMY_DEBUGUART=1 +ifeq ($(NRF_DEBUG_PRINT), 1) + CFLAGS += -DNRF_DEBUG_PRINT=1 SRC_SUPERVISOR += supervisor/debug_uart.c endif diff --git a/ports/nrf/common-hal/alarm/SleepMemory.c b/ports/nrf/common-hal/alarm/SleepMemory.c index 89430f2937..fc7453beb4 100644 --- a/ports/nrf/common-hal/alarm/SleepMemory.c +++ b/ports/nrf/common-hal/alarm/SleepMemory.c @@ -29,7 +29,7 @@ #include "py/runtime.h" #include "common-hal/alarm/SleepMemory.h" -#ifdef MY_DEBUGUART +#ifdef NRF_DEBUG_PRINT extern void dbg_dump_RAMreg(void); #endif @@ -66,7 +66,7 @@ static void initialize_sleep_memory(void) { memset((uint8_t *)_sleep_mem, 0, SLEEP_MEMORY_LENGTH); set_memory_retention(); -#ifdef MY_DEBUGUART +#ifdef NRF_DEBUG_PRINT dbg_dump_RAMreg(); #endif diff --git a/ports/nrf/common-hal/alarm/__init__.c b/ports/nrf/common-hal/alarm/__init__.c index 14f6e041f9..9c64e8e119 100644 --- a/ports/nrf/common-hal/alarm/__init__.c +++ b/ports/nrf/common-hal/alarm/__init__.c @@ -42,7 +42,7 @@ //#include "shared-bindings/microcontroller/__init__.h" #include "supervisor/port.h" -#ifdef MY_DEBUGUART +#ifdef NRF_DEBUG_PRINT #include "supervisor/serial.h" // dbg_printf() #endif @@ -98,7 +98,7 @@ bool alarm_woken_from_sleep(void) { || cause == NRF_SLEEP_WAKEUP_RESETPIN); } -#ifdef MY_DEBUGUART +#ifdef NRF_DEBUG_PRINT #if 0 static const char* cause_str[] = { "UNDEFINED", @@ -150,7 +150,7 @@ STATIC void _setup_sleep_alarms(bool deep_sleep, size_t n_alarms, const mp_obj_t } STATIC void _idle_until_alarm(void) { -#ifdef MY_DEBUGUART +#ifdef NRF_DEBUG_PRINT int ct = 40; #endif reset_reason_saved = 0; @@ -160,14 +160,14 @@ STATIC void _idle_until_alarm(void) { // Allow ctrl-C interrupt. if (alarm_woken_from_sleep()) { alarm_save_wake_alarm(); -#ifdef MY_DEBUGUART +#ifdef NRF_DEBUG_PRINT int cause = _get_wakeup_cause(); printf("wakeup(%d)\r\n", cause); #endif return; } port_idle_until_interrupt(); -#ifdef MY_DEBUGUART +#ifdef NRF_DEBUG_PRINT if (ct > 0) { printf("_"); --ct; @@ -179,14 +179,14 @@ STATIC void _idle_until_alarm(void) { mp_obj_t common_hal_alarm_light_sleep_until_alarms(size_t n_alarms, const mp_obj_t *alarms) { mp_obj_t r_obj = mp_const_none; _setup_sleep_alarms(false, n_alarms, alarms); -#ifdef MY_DEBUGUART +#ifdef NRF_DEBUG_PRINT dbg_printf("\r\nsleep..."); #endif _idle_until_alarm(); if (mp_hal_is_interrupted()) { -#ifdef MY_DEBUGUART +#ifdef NRF_DEBUG_PRINT dbg_printf("mp_hal_is_interrupted\r\n"); #endif r_obj = mp_const_none; @@ -213,7 +213,7 @@ void NORETURN alarm_enter_deep_sleep(void) { set_memory_retention(); -#ifdef MY_DEBUGUART +#ifdef NRF_DEBUG_PRINT dbg_printf("go system off.. %d\r\n", sd_enabled); #endif if (sd_enabled) { diff --git a/ports/nrf/common-hal/alarm/pin/PinAlarm.c b/ports/nrf/common-hal/alarm/pin/PinAlarm.c index 9ccc79db92..bdc268d512 100644 --- a/ports/nrf/common-hal/alarm/pin/PinAlarm.c +++ b/ports/nrf/common-hal/alarm/pin/PinAlarm.c @@ -154,7 +154,7 @@ static void setup_pin1_for_lightsleep(void) { }; for(size_t i = 0; i < 64; ++i) { uint64_t mask = 1ull << i; -#ifdef MY_DEBUGUART +#ifdef NRF_DEBUG_PRINT int pull = 0; int sense = 0; #endif @@ -165,7 +165,7 @@ static void setup_pin1_for_lightsleep(void) { cfg.sense = NRF_GPIOTE_POLARITY_LOTOHI; cfg.pull = ((pull_pins & mask) != 0) ? NRF_GPIO_PIN_PULLDOWN : NRF_GPIO_PIN_NOPULL; -#ifdef MY_DEBUGUART +#ifdef NRF_DEBUG_PRINT pull = -1; sense = 1; #endif } @@ -174,21 +174,21 @@ static void setup_pin1_for_lightsleep(void) { cfg.sense = NRF_GPIOTE_POLARITY_HITOLO; cfg.pull = ((pull_pins & mask) != 0) ? NRF_GPIO_PIN_PULLUP : NRF_GPIO_PIN_NOPULL; -#ifdef MY_DEBUGUART +#ifdef NRF_DEBUG_PRINT pull = 1; sense = -1; #endif } else { cfg.sense = NRF_GPIOTE_POLARITY_TOGGLE; cfg.pull = NRF_GPIO_PIN_NOPULL; -#ifdef MY_DEBUGUART +#ifdef NRF_DEBUG_PRINT sense = 9; #endif } nrfx_gpiote_in_init((nrfx_gpiote_pin_t)i, &cfg, pinalarm_gpiote_handler); nrfx_gpiote_in_event_enable((nrfx_gpiote_pin_t)i, true); -#ifdef MY_DEBUGUART +#ifdef NRF_DEBUG_PRINT dbg_printf("pin=%d, sense=%d, pull=%d\r\n", i, sense, pull); #endif } @@ -198,7 +198,7 @@ static void setup_pin1_for_deepsleep(void) { for(size_t i = 0; i < 64; ++i) { uint64_t mask = 1ull << i; int pull = 0; -#ifdef MY_DEBUGUART +#ifdef NRF_DEBUG_PRINT int sense = 0; #endif if (((high_alarms & mask) == 0) && ((low_alarms & mask) == 0)) { @@ -209,7 +209,7 @@ static void setup_pin1_for_deepsleep(void) { NRF_GPIO_PIN_PULLDOWN : NRF_GPIO_PIN_NOPULL; nrf_gpio_cfg_input((uint32_t)i, (nrf_gpio_pin_pull_t)pull); nrf_gpio_cfg_sense_set((uint32_t)i, NRF_GPIO_PIN_SENSE_HIGH); -#ifdef MY_DEBUGUART +#ifdef NRF_DEBUG_PRINT sense = NRF_GPIO_PIN_SENSE_HIGH; #endif } @@ -219,11 +219,11 @@ static void setup_pin1_for_deepsleep(void) { NRF_GPIO_PIN_PULLUP : NRF_GPIO_PIN_NOPULL; nrf_gpio_cfg_input((uint32_t)i, (nrf_gpio_pin_pull_t)pull); nrf_gpio_cfg_sense_set((uint32_t)i, NRF_GPIO_PIN_SENSE_LOW); -#ifdef MY_DEBUGUART +#ifdef NRF_DEBUG_PRINT sense = NRF_GPIO_PIN_SENSE_LOW; #endif } -#ifdef MY_DEBUGUART +#ifdef NRF_DEBUG_PRINT dbg_printf("pin=%d, sense=%d, pull=%d\r\n", i, sense, pull); #endif } diff --git a/ports/nrf/supervisor/debug_uart.c b/ports/nrf/supervisor/debug_uart.c index 53a3baebf9..79cc33b198 100644 --- a/ports/nrf/supervisor/debug_uart.c +++ b/ports/nrf/supervisor/debug_uart.c @@ -8,7 +8,7 @@ #include #include -#ifdef MY_DEBUGUART +#ifdef NRF_DEBUG_PRINT #define DEBUG_UART_TXPIN 26 #define DEBUG_UART_RXPIN 15 @@ -119,8 +119,8 @@ void dbg_dump_reset_reason(void) { dbg_printf("reset_reason=%s\r\n", rr_str[reset_reason]); } -#else /*!MY_DEBUGUART*/ +#else /*!NRF_DEBUG_PRINT*/ int dbg_printf(const char *fmt, ...) { return 0; } -#endif /*!MY_DEBUGUART*/ +#endif /*!NRF_DEBUG_PRINT*/ diff --git a/ports/nrf/supervisor/port.c b/ports/nrf/supervisor/port.c index d29659bf8d..5908683008 100644 --- a/ports/nrf/supervisor/port.c +++ b/ports/nrf/supervisor/port.c @@ -73,7 +73,7 @@ static void power_warning_handler(void) { reset_into_safe_mode(BROWNOUT); } -#ifdef MY_DEBUGUART +#ifdef NRF_DEBUG_PRINT extern void _debug_uart_init(void); #endif @@ -234,7 +234,7 @@ void reset_port(void) { reset_all_pins(); -#ifdef MY_DEBUGUART +#ifdef NRF_DEBUG_PRINT _debug_uart_init(); #endif } diff --git a/supervisor/shared/serial.c b/supervisor/shared/serial.c index 262fe706bd..479a996553 100644 --- a/supervisor/shared/serial.c +++ b/supervisor/shared/serial.c @@ -36,7 +36,7 @@ #include "tusb.h" -#ifdef MY_DEBUGUART +#ifdef NRF_DEBUG_PRINT // XXX these functions are in nrf/supervisor/debug_uart.c extern void _debug_uart_init(void); extern void _debug_print_substr(const char* text, uint32_t length); @@ -70,14 +70,14 @@ void serial_early_init(void) { common_hal_busio_uart_never_reset(&debug_uart); #endif -#ifdef MY_DEBUGUART +#ifdef NRF_DEBUG_PRINT _debug_uart_init(); #endif } void serial_init(void) { usb_init(); -#ifdef MY_DEBUGUART +#ifdef NRF_DEBUG_PRINT _debug_uart_init(); #endif } @@ -157,7 +157,7 @@ void serial_write_substring(const char* text, uint32_t length) { common_hal_busio_uart_write(&debug_uart, (const uint8_t*) text, length, &uart_errcode); #endif -#ifdef MY_DEBUGUART +#ifdef NRF_DEBUG_PRINT _debug_print_substr(text, length); #endif } From f66896ce32351e0992d6d3417d1a8af1038c5d4b Mon Sep 17 00:00:00 2001 From: jun2sak Date: Thu, 25 Feb 2021 02:34:43 +0900 Subject: [PATCH 18/67] use nRF SDK function to set up memory retention. --- ports/nrf/common-hal/alarm/SleepMemory.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/ports/nrf/common-hal/alarm/SleepMemory.c b/ports/nrf/common-hal/alarm/SleepMemory.c index fc7453beb4..e78e9fdd76 100644 --- a/ports/nrf/common-hal/alarm/SleepMemory.c +++ b/ports/nrf/common-hal/alarm/SleepMemory.c @@ -28,6 +28,7 @@ #include #include "py/runtime.h" #include "common-hal/alarm/SleepMemory.h" +#include "nrf_power.h" #ifdef NRF_DEBUG_PRINT extern void dbg_dump_RAMreg(void); @@ -51,14 +52,24 @@ void set_memory_retention(void) { // set RAM[n].POWER register for RAM retention // nRF52840 has RAM[0..7].Section[0..1] and RAM[8].Section[0..5] // nRF52833 has RAM[0..7].Section[0..1] and RAM[8].Section[0,1] - for(int ram = 0; ram <= 7; ++ram) { - NRF_POWER->RAM[ram].POWERSET = 0x00030000; // RETENTION for section 0,1 + for(int block = 0; block <= 7; ++block) { + nrf_power_rampower_mask_on(NRF_POWER, block, + NRF_POWER_RAMPOWER_S0RETENTION_MASK | + NRF_POWER_RAMPOWER_S1RETENTION_MASK); }; #ifdef NRF52840 - NRF_POWER->RAM[8].POWERSET = 0x001F0000; // RETENTION for section 0..5 + nrf_power_rampower_mask_on(NRF_POWER, 8, + NRF_POWER_RAMPOWER_S0RETENTION_MASK | + NRF_POWER_RAMPOWER_S1RETENTION_MASK | + NRF_POWER_RAMPOWER_S2RETENTION_MASK | + NRF_POWER_RAMPOWER_S3RETENTION_MASK | + NRF_POWER_RAMPOWER_S4RETENTION_MASK | + NRF_POWER_RAMPOWER_S5RETENTION_MASK); #endif #ifdef NRF52833 - NRF_POWER->RAM[8].POWERSET = 0x00030000; // RETENTION for section 0,1 + nrf_power_rampower_mask_on(NRF_POWER, 8, + NRF_POWER_RAMPOWER_S0RETENTION_MASK | + NRF_POWER_RAMPOWER_S1RETENTION_MASK); #endif } From 61a69daae1fd6460b830b7fd6707c74adbcd3f23 Mon Sep 17 00:00:00 2001 From: jun2sak Date: Thu, 25 Feb 2021 08:19:03 +0900 Subject: [PATCH 19/67] raise NotImplementedError when construct TouchAlarm. --- ports/nrf/common-hal/alarm/touch/TouchAlarm.c | 142 +----------------- 1 file changed, 5 insertions(+), 137 deletions(-) diff --git a/ports/nrf/common-hal/alarm/touch/TouchAlarm.c b/ports/nrf/common-hal/alarm/touch/TouchAlarm.c index 4db178c56e..1878b78b33 100644 --- a/ports/nrf/common-hal/alarm/touch/TouchAlarm.c +++ b/ports/nrf/common-hal/alarm/touch/TouchAlarm.c @@ -24,162 +24,30 @@ * THE SOFTWARE. */ +#include "py/runtime.h" #include "shared-bindings/alarm/touch/TouchAlarm.h" #include "shared-bindings/microcontroller/__init__.h" -//#include "esp_sleep.h" -//#include "peripherals/touch.h" -//#include "supervisor/esp_port.h" - -static uint16_t touch_channel_mask; static volatile bool woke_up = false; void common_hal_alarm_touch_touchalarm_construct(alarm_touch_touchalarm_obj_t *self, const mcu_pin_obj_t *pin) { -#if 0 - if (pin->touch_channel == TOUCH_PAD_MAX) { - mp_raise_ValueError(translate("Invalid pin")); - } - claim_pin(pin); -#endif - self->pin = pin; + mp_raise_NotImplementedError(NULL); + (void)pin; } mp_obj_t alarm_touch_touchalarm_get_wakeup_alarm(const size_t n_alarms, const mp_obj_t *alarms) { - // First, check to see if we match any given alarms. - for (size_t i = 0; i < n_alarms; i++) { - if (MP_OBJ_IS_TYPE(alarms[i], &alarm_touch_touchalarm_type)) { - return alarms[i]; - } - } - - // Create TouchAlarm object. - alarm_touch_touchalarm_obj_t *alarm = m_new_obj(alarm_touch_touchalarm_obj_t); - alarm->base.type = &alarm_touch_touchalarm_type; - alarm->pin = NULL; -#if 0 - touch_pad_t wake_channel = touch_pad_get_current_meas_channel(); - if (wake_channel == TOUCH_PAD_MAX) { - return alarm; - } - - // Map the pin number back to a pin object. - for (size_t i = 0; i < mcu_pin_globals.map.used; i++) { - const mcu_pin_obj_t* pin_obj = MP_OBJ_TO_PTR(mcu_pin_globals.map.table[i].value); - if (pin_obj->touch_channel == wake_channel) { - alarm->pin = mcu_pin_globals.map.table[i].value; - break; - } - } -#endif - return alarm; -} - -// This is used to wake the main CircuitPython task. -void touch_interrupt(void *arg) { - (void) arg; -#if 0 - woke_up = true; - BaseType_t task_wakeup; - vTaskNotifyGiveFromISR(circuitpython_task, &task_wakeup); - if (task_wakeup) { - portYIELD_FROM_ISR(); - } -#endif + return mp_const_none; } void alarm_touch_touchalarm_set_alarm(const bool deep_sleep, const size_t n_alarms, const mp_obj_t *alarms) { -#if 0 - bool touch_alarm_set = false; - alarm_touch_touchalarm_obj_t *touch_alarm = MP_OBJ_NULL; - - for (size_t i = 0; i < n_alarms; i++) { - if (MP_OBJ_IS_TYPE(alarms[i], &alarm_touch_touchalarm_type)) { - if (deep_sleep && touch_alarm_set) { - mp_raise_ValueError(translate("Only one TouchAlarm can be set in deep sleep.")); - } - touch_alarm = MP_OBJ_TO_PTR(alarms[i]); - touch_channel_mask |= 1 << touch_alarm->pin->number; - touch_alarm_set = true; - } - } - - if (!touch_alarm_set) { - return; - } - - // configure interrupt for pretend to deep sleep - // this will be disabled if we actually deep sleep - - // reset touch peripheral - peripherals_touch_reset(); - peripherals_touch_never_reset(true); - - for (uint8_t i = 1; i <= 14; i++) { - if ((touch_channel_mask & 1 << i) != 0) { - touch_pad_t touch_channel = (touch_pad_t)i; - // intialize touchpad - peripherals_touch_init(touch_channel); - - // wait for touch data to reset - mp_hal_delay_ms(10); - - // configure trigger threshold - uint32_t touch_value; - touch_pad_read_benchmark(touch_channel, &touch_value); - touch_pad_set_thresh(touch_channel, touch_value * 0.1); //10% - } - } - - // configure touch interrupt - touch_pad_timeout_set(true, SOC_TOUCH_PAD_THRESHOLD_MAX); - touch_pad_isr_register(touch_interrupt, NULL, TOUCH_PAD_INTR_MASK_ALL); - touch_pad_intr_enable(TOUCH_PAD_INTR_MASK_ACTIVE | TOUCH_PAD_INTR_MASK_INACTIVE); } void alarm_touch_touchalarm_prepare_for_deep_sleep(void) { - if (!touch_channel_mask) { - return; - } - - touch_pad_t touch_channel = TOUCH_PAD_MAX; - for (uint8_t i = 1; i <= 14; i++) { - if ((touch_channel_mask & 1 << i) != 0) { - touch_channel = (touch_pad_t)i; - break; - } - } - - // reset touch peripheral - peripherals_touch_never_reset(false); - peripherals_touch_reset(); - - // intialize touchpad - peripherals_touch_init(touch_channel); - - // configure touchpad for sleep - touch_pad_sleep_channel_enable(touch_channel, true); - touch_pad_sleep_channel_enable_proximity(touch_channel, false); - - // wait for touch data to reset - mp_hal_delay_ms(10); - - // configure trigger threshold - uint32_t touch_value; - touch_pad_sleep_channel_read_smooth(touch_channel, &touch_value); - touch_pad_sleep_set_threshold(touch_channel, touch_value * 0.1); //10% - - // enable touchpad wakeup - esp_sleep_enable_touchpad_wakeup(); - esp_sleep_pd_config(ESP_PD_DOMAIN_RTC_PERIPH, ESP_PD_OPTION_ON); -#endif } bool alarm_touch_touchalarm_woke_us_up(void) { - return woke_up; + return false; } void alarm_touch_touchalarm_reset(void) { - woke_up = false; - touch_channel_mask = 0; -// peripherals_touch_never_reset(false); } From 9328d09a7a7a3cddc1ca0c346c781f3cb55203ee Mon Sep 17 00:00:00 2001 From: jun2sak Date: Fri, 26 Feb 2021 00:50:44 +0900 Subject: [PATCH 20/67] re-enable parameters check. --- ports/nrf/common-hal/alarm/pin/PinAlarm.c | 7 ++----- ports/nrf/common-hal/alarm/pin/__init__.c | 12 ------------ 2 files changed, 2 insertions(+), 17 deletions(-) delete mode 100644 ports/nrf/common-hal/alarm/pin/__init__.c diff --git a/ports/nrf/common-hal/alarm/pin/PinAlarm.c b/ports/nrf/common-hal/alarm/pin/PinAlarm.c index bdc268d512..606a7125fa 100644 --- a/ports/nrf/common-hal/alarm/pin/PinAlarm.c +++ b/ports/nrf/common-hal/alarm/pin/PinAlarm.c @@ -46,15 +46,12 @@ volatile nrfx_gpiote_pin_t _pinhandler_ev_pin; #define MYGPIOTE_EV_PIN_UNDEF 0xFF void common_hal_alarm_pin_pinalarm_construct(alarm_pin_pinalarm_obj_t *self, mcu_pin_obj_t *pin, bool value, bool edge, bool pull) { -#if 0 if (edge) { mp_raise_ValueError(translate("Cannot wake on pin edge. Only level.")); } - - if (pull && !GPIO_IS_VALID_OUTPUT_GPIO(pin->number)) { - mp_raise_ValueError(translate("Cannot pull on input-only pin.")); + if (pin->number >= NUMBER_OF_PINS) { + mp_raise_ValueError(translate("Invalid pin")); } -#endif self->pin = pin; self->value = value; self->pull = pull; diff --git a/ports/nrf/common-hal/alarm/pin/__init__.c b/ports/nrf/common-hal/alarm/pin/__init__.c deleted file mode 100644 index 94778f5eb1..0000000000 --- a/ports/nrf/common-hal/alarm/pin/__init__.c +++ /dev/null @@ -1,12 +0,0 @@ -//#include "shared-bindings/alarm_io/__init__.h" - -// these are in esp32s2 implementation, -// but not used in nrf - -#if 0 -mp_obj_t common_hal_alarm_io_pin_state (alarm_io_obj_t *self_in) { -} - -void common_hal_alarm_io_disable (void) { -} -#endif From c86ca2a4ff7e23feeb77fbbfcee1a9ea61178851 Mon Sep 17 00:00:00 2001 From: jun2sak Date: Fri, 26 Feb 2021 00:51:52 +0900 Subject: [PATCH 21/67] move externs to .h --- ports/nrf/common-hal/alarm/time/TimeAlarm.c | 4 ---- ports/nrf/common-hal/alarm/time/TimeAlarm.h | 4 ++++ 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/ports/nrf/common-hal/alarm/time/TimeAlarm.c b/ports/nrf/common-hal/alarm/time/TimeAlarm.c index 220ed2f4df..2a9a0fcd33 100644 --- a/ports/nrf/common-hal/alarm/time/TimeAlarm.c +++ b/ports/nrf/common-hal/alarm/time/TimeAlarm.c @@ -55,19 +55,15 @@ mp_obj_t alarm_time_timealarm_get_wakeup_alarm(size_t n_alarms, const mp_obj_t * return timer; } -extern volatile int rtc_woke_up_counter; bool alarm_time_timealarm_woke_us_up(void) { return rtc_woke_up_counter; } -extern void port_disable_interrupt_after_ticks_ch(uint32_t channel); void alarm_time_timealarm_reset(void) { port_disable_interrupt_after_ticks_ch(1); rtc_woke_up_counter = 0; } -extern void port_interrupt_after_ticks_ch(uint32_t channel, uint32_t ticks);//XXX in port.c - void alarm_time_timealarm_set_alarms(bool deep_sleep, size_t n_alarms, const mp_obj_t *alarms) { bool timealarm_set = false; alarm_time_timealarm_obj_t *timealarm = MP_OBJ_NULL; diff --git a/ports/nrf/common-hal/alarm/time/TimeAlarm.h b/ports/nrf/common-hal/alarm/time/TimeAlarm.h index dfd75524fd..14a2ff80cf 100644 --- a/ports/nrf/common-hal/alarm/time/TimeAlarm.h +++ b/ports/nrf/common-hal/alarm/time/TimeAlarm.h @@ -32,6 +32,10 @@ typedef struct { mp_float_t monotonic_time; // values compatible with time.monotonic_time() } alarm_time_timealarm_obj_t; +extern volatile int rtc_woke_up_counter; +extern void port_disable_interrupt_after_ticks_ch(uint32_t channel); +extern void port_interrupt_after_ticks_ch(uint32_t channel, uint32_t ticks); + // 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. From c713d31d0d77e461c97efa95229467e311b7e35b Mon Sep 17 00:00:00 2001 From: jun2sak Date: Fri, 26 Feb 2021 01:20:55 +0900 Subject: [PATCH 22/67] move externs to .h --- ports/nrf/common-hal/microcontroller/Processor.c | 1 - ports/nrf/common-hal/microcontroller/Processor.h | 2 ++ 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/ports/nrf/common-hal/microcontroller/Processor.c b/ports/nrf/common-hal/microcontroller/Processor.c index 5564c86c54..edff0fa076 100644 --- a/ports/nrf/common-hal/microcontroller/Processor.c +++ b/ports/nrf/common-hal/microcontroller/Processor.c @@ -122,7 +122,6 @@ void common_hal_mcu_processor_get_uid(uint8_t raw_id[]) { } } -extern uint32_t reset_reason_saved; mcu_reset_reason_t common_hal_mcu_processor_get_reset_reason(void) { mcu_reset_reason_t r = RESET_REASON_UNKNOWN; if (reset_reason_saved == 0) { diff --git a/ports/nrf/common-hal/microcontroller/Processor.h b/ports/nrf/common-hal/microcontroller/Processor.h index 4049c165fb..1abbe1e4eb 100644 --- a/ports/nrf/common-hal/microcontroller/Processor.h +++ b/ports/nrf/common-hal/microcontroller/Processor.h @@ -36,4 +36,6 @@ typedef struct { // Stores no state currently. } mcu_processor_obj_t; +extern uint32_t reset_reason_saved; + #endif // MICROPY_INCLUDED_NRF_COMMON_HAL_MICROCONTROLLER_PROCESSOR_H From 5b3c6ed0c3cb923a597da1221cb4386f033bb741 Mon Sep 17 00:00:00 2001 From: jun2sak Date: Fri, 26 Feb 2021 01:28:13 +0900 Subject: [PATCH 23/67] update translation file. --- locale/circuitpython.pot | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/locale/circuitpython.pot b/locale/circuitpython.pot index e90883582c..dc0ec9fb7e 100644 --- a/locale/circuitpython.pot +++ b/locale/circuitpython.pot @@ -613,7 +613,6 @@ msgid "Cannot output both channels on the same pin" msgstr "" #: ports/esp32s2/common-hal/alarm/pin/PinAlarm.c -#: ports/nrf/common-hal/alarm/pin/PinAlarm.c msgid "Cannot pull on input-only pin." msgstr "" @@ -1072,7 +1071,6 @@ msgid "I2SOut not available" msgstr "" #: ports/esp32s2/common-hal/alarm/pin/__init__.c -#: ports/nrf/common-hal/alarm/pin/__init__.c msgid "IOs 0, 2 & 4 do not support internal pullup in sleep" msgstr "" @@ -1259,7 +1257,7 @@ msgstr "" #: ports/atmel-samd/common-hal/touchio/TouchIn.c #: ports/esp32s2/common-hal/alarm/touch/TouchAlarm.c #: ports/esp32s2/common-hal/touchio/TouchIn.c -#: ports/nrf/common-hal/alarm/touch/TouchAlarm.c shared-bindings/pwmio/PWMOut.c +#: ports/nrf/common-hal/alarm/pin/PinAlarm.c shared-bindings/pwmio/PWMOut.c #: shared-module/rgbmatrix/RGBMatrix.c msgid "Invalid pin" msgstr "" @@ -1641,7 +1639,6 @@ msgid "" msgstr "" #: ports/esp32s2/common-hal/alarm/touch/TouchAlarm.c -#: ports/nrf/common-hal/alarm/touch/TouchAlarm.c msgid "Only one TouchAlarm can be set in deep sleep." msgstr "" @@ -3217,7 +3214,6 @@ msgid "invalid syntax for number" msgstr "" #: ports/esp32s2/common-hal/alarm/pin/__init__.c -#: ports/nrf/common-hal/alarm/pin/__init__.c msgid "io must be rtc io" msgstr "" @@ -3969,7 +3965,6 @@ msgid "trapz is defined for 1D arrays of equal length" msgstr "" #: ports/esp32s2/common-hal/alarm/pin/__init__.c -#: ports/nrf/common-hal/alarm/pin/__init__.c msgid "trigger level must be 0 or 1" msgstr "" @@ -4112,7 +4107,6 @@ msgid "vectors must have same lengths" msgstr "" #: ports/esp32s2/common-hal/alarm/pin/__init__.c -#: ports/nrf/common-hal/alarm/pin/__init__.c msgid "wakeup conflict" msgstr "" From 2aa5aec0d5b9c3b9c11ecf0f1d728cc7891f0ca6 Mon Sep 17 00:00:00 2001 From: jun2sak Date: Fri, 26 Feb 2021 01:45:12 +0900 Subject: [PATCH 24/67] cleanup. --- ports/nrf/common-hal/alarm/__init__.c | 27 ++++++++++----------------- 1 file changed, 10 insertions(+), 17 deletions(-) diff --git a/ports/nrf/common-hal/alarm/__init__.c b/ports/nrf/common-hal/alarm/__init__.c index 9c64e8e119..c719deb876 100644 --- a/ports/nrf/common-hal/alarm/__init__.c +++ b/ports/nrf/common-hal/alarm/__init__.c @@ -38,9 +38,6 @@ #include "shared-bindings/alarm/time/TimeAlarm.h" #include "shared-bindings/alarm/touch/TouchAlarm.h" -//#include "shared-bindings/wifi/__init__.h" -//#include "shared-bindings/microcontroller/__init__.h" - #include "supervisor/port.h" #ifdef NRF_DEBUG_PRINT #include "supervisor/serial.h" // dbg_printf() @@ -73,12 +70,9 @@ STATIC nrf_sleep_source_t _get_wakeup_cause(void) { if (alarm_time_timealarm_woke_us_up()) { return NRF_SLEEP_WAKEUP_TIMER; } -#if 0 - // XXX not implemented yet if (alarm_touch_touchalarm_woke_us_up()) { - return ESP_SLEEP_WAKEUP_TOUCHPAD; + return NRF_SLEEP_WAKEUP_TOUCHPAD; } -#endif if (reset_reason_saved & NRF_POWER_RESETREAS_RESETPIN_MASK) { return NRF_SLEEP_WAKEUP_RESETPIN; } @@ -99,7 +93,6 @@ bool alarm_woken_from_sleep(void) { } #ifdef NRF_DEBUG_PRINT -#if 0 static const char* cause_str[] = { "UNDEFINED", "GPIO", @@ -108,15 +101,18 @@ static const char* cause_str[] = { "VBUS", "RESETPIN", }; -#endif +void print_wakeup_cause(nrf_sleep_source_t cause) { + if (cause >= 0 && cause < NRF_SLEEP_WAKEUP_ZZZ) { + dbg_printf("wakeup cause = NRF_SLEEP_WAKEUP_%s\r\n", + cause_str[(int)cause]); + } +} #endif STATIC mp_obj_t _get_wake_alarm(size_t n_alarms, const mp_obj_t *alarms) { nrf_sleep_source_t cause = _get_wakeup_cause(); -#if 0 - if (cause >= 0 && cause < NRF_SLEEP_WAKEUP_ZZZ) { - printf("wakeup cause = NRF_SLEEP_WAKEUP_%s\r\n", cause_str[(int)cause]); - } +#ifdef NRF_DEBUG_PRINT + //print_wakeup_cause(cause); #endif switch (cause) { case NRF_SLEEP_WAKEUP_TIMER: { @@ -143,10 +139,7 @@ mp_obj_t common_hal_alarm_get_wake_alarm(void) { STATIC void _setup_sleep_alarms(bool deep_sleep, size_t n_alarms, const mp_obj_t *alarms) { alarm_pin_pinalarm_set_alarms(deep_sleep, n_alarms, alarms); alarm_time_timealarm_set_alarms(deep_sleep, n_alarms, alarms); -#if 0 - // XXX not implemented yet alarm_touch_touchalarm_set_alarm(deep_sleep, n_alarms, alarms); -#endif } STATIC void _idle_until_alarm(void) { @@ -206,7 +199,7 @@ extern void set_memory_retention(void); void NORETURN alarm_enter_deep_sleep(void) { alarm_pin_pinalarm_prepare_for_deep_sleep(); - //alarm_touch_touchalarm_prepare_for_deep_sleep(); // XXX + //alarm_touch_touchalarm_prepare_for_deep_sleep(); uint8_t sd_enabled; sd_softdevice_is_enabled(&sd_enabled); From 277a67d8767b6b297bc0ce375c44bf3fdd38c617 Mon Sep 17 00:00:00 2001 From: jun2sak Date: Fri, 26 Feb 2021 08:11:50 +0900 Subject: [PATCH 25/67] call touchalarm funcs as well as pin/timealarm. --- ports/nrf/common-hal/alarm/__init__.c | 6 +++--- ports/nrf/common-hal/alarm/touch/TouchAlarm.c | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/ports/nrf/common-hal/alarm/__init__.c b/ports/nrf/common-hal/alarm/__init__.c index c719deb876..8042855a61 100644 --- a/ports/nrf/common-hal/alarm/__init__.c +++ b/ports/nrf/common-hal/alarm/__init__.c @@ -59,7 +59,7 @@ void alarm_reset(void) { alarm_sleep_memory_reset(); alarm_pin_pinalarm_reset(); alarm_time_timealarm_reset(); - //alarm_touch_touchalarm_reset(); + alarm_touch_touchalarm_reset(); } extern uint32_t reset_reason_saved; @@ -119,7 +119,7 @@ STATIC mp_obj_t _get_wake_alarm(size_t n_alarms, const mp_obj_t *alarms) { return alarm_time_timealarm_get_wakeup_alarm(n_alarms, alarms); } case NRF_SLEEP_WAKEUP_TOUCHPAD: { - return mp_const_none; + return alarm_touch_touchalarm_get_wakeup_alarm(n_alarms, alarms); } case NRF_SLEEP_WAKEUP_GPIO: { return alarm_pin_pinalarm_get_wakeup_alarm(n_alarms, alarms); @@ -199,7 +199,7 @@ extern void set_memory_retention(void); void NORETURN alarm_enter_deep_sleep(void) { alarm_pin_pinalarm_prepare_for_deep_sleep(); - //alarm_touch_touchalarm_prepare_for_deep_sleep(); + alarm_touch_touchalarm_prepare_for_deep_sleep(); uint8_t sd_enabled; sd_softdevice_is_enabled(&sd_enabled); diff --git a/ports/nrf/common-hal/alarm/touch/TouchAlarm.c b/ports/nrf/common-hal/alarm/touch/TouchAlarm.c index 1878b78b33..e85797e692 100644 --- a/ports/nrf/common-hal/alarm/touch/TouchAlarm.c +++ b/ports/nrf/common-hal/alarm/touch/TouchAlarm.c @@ -28,7 +28,7 @@ #include "shared-bindings/alarm/touch/TouchAlarm.h" #include "shared-bindings/microcontroller/__init__.h" -static volatile bool woke_up = false; +//static volatile bool woke_up = false; void common_hal_alarm_touch_touchalarm_construct(alarm_touch_touchalarm_obj_t *self, const mcu_pin_obj_t *pin) { mp_raise_NotImplementedError(NULL); From 7fd4648cd5ce467520920d58dd7518e7beace08d Mon Sep 17 00:00:00 2001 From: jun2sak Date: Fri, 26 Feb 2021 09:06:11 +0900 Subject: [PATCH 26/67] rase error if Alarm time >= 512 sec. --- locale/circuitpython.pot | 2 +- ports/nrf/common-hal/alarm/time/TimeAlarm.c | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/locale/circuitpython.pot b/locale/circuitpython.pot index dc0ec9fb7e..39bc4d74e1 100644 --- a/locale/circuitpython.pot +++ b/locale/circuitpython.pot @@ -308,7 +308,7 @@ msgid "Address type out of range" msgstr "" #: ports/nrf/common-hal/alarm/time/TimeAlarm.c -msgid "Alarm time is too far." +msgid "Alarm time must be < 512 seconds." msgstr "" #: ports/esp32s2/common-hal/canio/CAN.c diff --git a/ports/nrf/common-hal/alarm/time/TimeAlarm.c b/ports/nrf/common-hal/alarm/time/TimeAlarm.c index 2a9a0fcd33..e9c536414b 100644 --- a/ports/nrf/common-hal/alarm/time/TimeAlarm.c +++ b/ports/nrf/common-hal/alarm/time/TimeAlarm.c @@ -86,12 +86,13 @@ void alarm_time_timealarm_set_alarms(bool deep_sleep, size_t n_alarms, const mp_ mp_float_t now_secs = uint64_to_float(common_hal_time_monotonic_ms()) / 1000.0f; mp_float_t wakeup_in_secs = MAX(0.0f, timealarm->monotonic_time - now_secs); int wsecs = (int)(wakeup_in_secs); - if (wsecs > 510) { //XXX - mp_raise_ValueError(translate("Alarm time is too far.")); + // timealarm is implemented by RTC, which is a 24bit counter + // running at 32768Hz. So, 2^24 / 32768 = 512sec is an upper limit. + if (wsecs >= 512) { + mp_raise_ValueError(translate("Alarm time must be < 512 seconds.")); } uint32_t wakeup_in_ticks = (uint32_t)(wakeup_in_secs * 1024.0f); - //printf("alarm_time_timealarm_set_alarms() %d secs 0x%08X ticks\r\n", wsecs, (int)wakeup_in_ticks); port_interrupt_after_ticks_ch(1, wakeup_in_ticks); rtc_woke_up_counter = 0; } From 0f8c96f424c08d5bdfcec565d5718c5151955ab6 Mon Sep 17 00:00:00 2001 From: jun2sak Date: Fri, 26 Feb 2021 09:11:35 +0900 Subject: [PATCH 27/67] remove trailing whitespaces. --- ports/nrf/common-hal/alarm/SleepMemory.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ports/nrf/common-hal/alarm/SleepMemory.c b/ports/nrf/common-hal/alarm/SleepMemory.c index e78e9fdd76..f29ac07f67 100644 --- a/ports/nrf/common-hal/alarm/SleepMemory.c +++ b/ports/nrf/common-hal/alarm/SleepMemory.c @@ -53,12 +53,12 @@ void set_memory_retention(void) { // nRF52840 has RAM[0..7].Section[0..1] and RAM[8].Section[0..5] // nRF52833 has RAM[0..7].Section[0..1] and RAM[8].Section[0,1] for(int block = 0; block <= 7; ++block) { - nrf_power_rampower_mask_on(NRF_POWER, block, + nrf_power_rampower_mask_on(NRF_POWER, block, NRF_POWER_RAMPOWER_S0RETENTION_MASK | NRF_POWER_RAMPOWER_S1RETENTION_MASK); }; #ifdef NRF52840 - nrf_power_rampower_mask_on(NRF_POWER, 8, + nrf_power_rampower_mask_on(NRF_POWER, 8, NRF_POWER_RAMPOWER_S0RETENTION_MASK | NRF_POWER_RAMPOWER_S1RETENTION_MASK | NRF_POWER_RAMPOWER_S2RETENTION_MASK | @@ -67,7 +67,7 @@ void set_memory_retention(void) { NRF_POWER_RAMPOWER_S5RETENTION_MASK); #endif #ifdef NRF52833 - nrf_power_rampower_mask_on(NRF_POWER, 8, + nrf_power_rampower_mask_on(NRF_POWER, 8, NRF_POWER_RAMPOWER_S0RETENTION_MASK | NRF_POWER_RAMPOWER_S1RETENTION_MASK); #endif From fac86c8277bca2002c8ed8983c8a8e4055c1c31a Mon Sep 17 00:00:00 2001 From: jun2sak Date: Sun, 28 Feb 2021 15:34:55 +0900 Subject: [PATCH 28/67] remove unused debug printf's. --- main.c | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/main.c b/main.c index c15d5810b0..7df6e293aa 100755 --- a/main.c +++ b/main.c @@ -218,7 +218,6 @@ STATIC bool maybe_run_list(const char * const * filenames, pyexec_result_t* exec decompress(compressed, decompressed); mp_hal_stdout_tx_str(decompressed); pyexec_file(filename, exec_result); - //dbg_printf("pyexec_file end result=(code=%d, line=%d)\r\n", exec_result->return_code, exec_result->exception_line); return true; } @@ -264,7 +263,6 @@ STATIC void print_code_py_status_message(safe_mode_t safe_mode) { } STATIC bool run_code_py(safe_mode_t safe_mode) { - //dbg_printf("run_code_py (%d)\r\n", (int)safe_mode); bool serial_connected_at_start = serial_connected(); #if CIRCUITPY_AUTORELOAD_DELAY_MS > 0 serial_write("\n"); @@ -440,7 +438,6 @@ STATIC bool run_code_py(safe_mode_t safe_mode) { FIL* boot_output_file; STATIC void __attribute__ ((noinline)) run_boot_py(safe_mode_t safe_mode) { - //dbg_printf("run_boot_py (%d)\r\n", (int)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) { @@ -537,10 +534,6 @@ STATIC int run_repl(void) { return exit_code; } -#ifdef NRF_DEBUG_PRINT -extern void dbg_dump_reset_reason(void); -#endif - int __attribute__((used)) main(void) { // initialise the cpu and peripherals safe_mode_t safe_mode = port_init(); @@ -591,12 +584,6 @@ int __attribute__((used)) main(void) { // Start serial and HID after giving boot.py a chance to tweak behavior. serial_init(); -#if 0 //XXX - { - dbg_dump_reset_reason(); - } -#endif - #if CIRCUITPY_BLEIO supervisor_start_bluetooth(); #endif From 9b34726c0d5b2a5a79deec8132828199ba5ff25a Mon Sep 17 00:00:00 2001 From: jun2sak Date: Sun, 28 Feb 2021 15:36:14 +0900 Subject: [PATCH 29/67] GPIO and GPIOTE reg dump for debug. --- ports/nrf/supervisor/debug_uart.c | 55 ++++++++++++++++++++++++++++++- 1 file changed, 54 insertions(+), 1 deletion(-) diff --git a/ports/nrf/supervisor/debug_uart.c b/ports/nrf/supervisor/debug_uart.c index 79cc33b198..dda03a00af 100644 --- a/ports/nrf/supervisor/debug_uart.c +++ b/ports/nrf/supervisor/debug_uart.c @@ -88,7 +88,6 @@ int dbg_printf(const char *fmt, ...) { return ret; } - void dbg_dump_RTCreg(void) { dbg_printf("\r\nRTC2\r\n"); NRF_RTC_Type *r = rtc_instance.p_reg; @@ -110,6 +109,60 @@ void dbg_dump_RAMreg(void) { dbg_printf("\r\n"); } +void dbg_dump_GPIOregs(void) { + int i, port, col; + + NRF_GPIO_Type *gpio[] = { NRF_P0, NRF_P1 }; + const char cnf_pull_chr[] = "-D*U"; // pull down, pull up + const char cnf_sense_chr[] = "-?HL"; // sense high, sense low + for(port=0, col=0; port<=1; ++port) { + for(i=0; i<32; ++i) { + uint32_t cnf = gpio[port]->PIN_CNF[i]; + if (cnf != 0x0002) { // changed from default value + dbg_printf("[%d_%02d]:%c%c%c%d%c ", port, i, + (cnf & 1) ? 'O' : 'I', // output, input + (cnf & 2) ? 'd' : 'c', // disconnected, connected + cnf_pull_chr[(cnf >> 2) & 3], + (int)((cnf >> 8) & 7), // drive config 0-7 + cnf_sense_chr[(cnf >> 16) & 3]); + if (++col >= 6) { + dbg_printf("\r\n"); + col = 0; + } + } + } + } + if (col > 0) dbg_printf("\r\n"); + + dbg_printf("GPIOTE\r\n"); + NRF_GPIOTE_Type const *reg = NRF_GPIOTE; + const char config_mode_chr[] = "-E-T"; // event, task + const char config_pol_chr[] = "-HLT"; // low-to-Hi, hi-to-Low, Toggle + const char config_outinit_chr[] = "01"; // initial value is 0 or 1 + for(i=0, col=0; i<8; ++i) { + uint32_t conf = reg->CONFIG[i]; + if (conf != 0) { // changed from default value + dbg_printf("CONFIG[%d]:%d_%02d,%c%c%c ", i, + (int)((conf >> 13) & 1), (int)((conf >> 8) & 0x1F), + config_mode_chr[conf & 3], + config_pol_chr[(conf >> 16) & 3], + (conf & 3) == 3 ? + config_outinit_chr[(conf >> 20) & 1] : '-'); + if (++col >= 4) { + dbg_printf("\r\n"); + col = 0; + } + } + } + if (col > 0) dbg_printf("\r\n"); + for(i=0; i<8; ++i) { + dbg_printf("EVENTS_IN[%d]:%X ", i, (int)(reg->EVENTS_IN[i])); + if ((i & 3) == 3) dbg_printf("\r\n"); + } + dbg_printf("EVENTS_PORT:%X INTENSET:%08X\r\n", + (int)(reg->EVENTS_PORT), (int)(reg->INTENSET)); +} + void dbg_dump_reset_reason(void) { int reset_reason = (int)common_hal_mcu_processor_get_reset_reason(); const char* rr_str[] = { From 498debc82621efb12f45f14a15b4282636f78299 Mon Sep 17 00:00:00 2001 From: jun2sak Date: Sun, 28 Feb 2021 15:37:25 +0900 Subject: [PATCH 30/67] remove unused debug printf's. --- ports/nrf/common-hal/alarm/SleepMemory.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/ports/nrf/common-hal/alarm/SleepMemory.c b/ports/nrf/common-hal/alarm/SleepMemory.c index f29ac07f67..49eb0b2594 100644 --- a/ports/nrf/common-hal/alarm/SleepMemory.c +++ b/ports/nrf/common-hal/alarm/SleepMemory.c @@ -32,6 +32,7 @@ #ifdef NRF_DEBUG_PRINT extern void dbg_dump_RAMreg(void); +#include "supervisor/serial.h" // dbg_printf() #endif #define RTC_DATA_ATTR __attribute__((section(".uninitialized"))) @@ -78,7 +79,7 @@ static void initialize_sleep_memory(void) { set_memory_retention(); #ifdef NRF_DEBUG_PRINT - dbg_dump_RAMreg(); + //dbg_dump_RAMreg(); #endif _sleep_mem_magicnum = SLEEP_MEMORY_DATA_GUARD; @@ -87,6 +88,9 @@ static void initialize_sleep_memory(void) { void alarm_sleep_memory_reset(void) { if (!is_sleep_memory_valid()) { initialize_sleep_memory(); +#ifdef NRF_DEBUG_PRINT + dbg_printf("sleep memory initialized\r\n"); +#endif } } From 3e47e00291909e13260482e18a0814da7dbf39ff Mon Sep 17 00:00:00 2001 From: jun2sak Date: Sun, 28 Feb 2021 15:57:37 +0900 Subject: [PATCH 31/67] address the pretending-to-deep-sleep issue. --- main.c | 2 +- ports/nrf/common-hal/alarm/__init__.c | 48 +++++++----- ports/nrf/common-hal/alarm/pin/PinAlarm.c | 89 +++++++---------------- shared-bindings/alarm/__init__.c | 5 ++ shared-bindings/alarm/__init__.h | 1 + 5 files changed, 62 insertions(+), 83 deletions(-) diff --git a/main.c b/main.c index 7df6e293aa..2aebfa062f 100755 --- a/main.c +++ b/main.c @@ -430,7 +430,7 @@ STATIC bool run_code_py(safe_mode_t safe_mode) { // 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(); + alarm_pretending_deep_sleep(); } } } diff --git a/ports/nrf/common-hal/alarm/__init__.c b/ports/nrf/common-hal/alarm/__init__.c index 8042855a61..f54b54a3f9 100644 --- a/ports/nrf/common-hal/alarm/__init__.c +++ b/ports/nrf/common-hal/alarm/__init__.c @@ -85,13 +85,6 @@ STATIC nrf_sleep_source_t _get_wakeup_cause(void) { return NRF_SLEEP_WAKEUP_UNDEFINED; } -bool alarm_woken_from_sleep(void) { - nrf_sleep_source_t cause = _get_wakeup_cause(); - return (cause == NRF_SLEEP_WAKEUP_GPIO || cause == NRF_SLEEP_WAKEUP_TIMER - || cause == NRF_SLEEP_WAKEUP_TOUCHPAD - || cause == NRF_SLEEP_WAKEUP_RESETPIN); -} - #ifdef NRF_DEBUG_PRINT static const char* cause_str[] = { "UNDEFINED", @@ -109,6 +102,17 @@ void print_wakeup_cause(nrf_sleep_source_t cause) { } #endif +bool alarm_woken_from_sleep(void) { + nrf_sleep_source_t cause = _get_wakeup_cause(); +#ifdef NRF_DEBUG_PRINT + if (cause != NRF_SLEEP_WAKEUP_UNDEFINED) { + //print_wakeup_cause(cause); + } +#endif + return (cause == NRF_SLEEP_WAKEUP_GPIO || cause == NRF_SLEEP_WAKEUP_TIMER + || cause == NRF_SLEEP_WAKEUP_TOUCHPAD); +} + STATIC mp_obj_t _get_wake_alarm(size_t n_alarms, const mp_obj_t *alarms) { nrf_sleep_source_t cause = _get_wakeup_cause(); #ifdef NRF_DEBUG_PRINT @@ -152,19 +156,15 @@ STATIC void _idle_until_alarm(void) { RUN_BACKGROUND_TASKS; // Allow ctrl-C interrupt. if (alarm_woken_from_sleep()) { - alarm_save_wake_alarm(); -#ifdef NRF_DEBUG_PRINT - int cause = _get_wakeup_cause(); - printf("wakeup(%d)\r\n", cause); -#endif - return; - } + alarm_save_wake_alarm(); + return; + } port_idle_until_interrupt(); #ifdef NRF_DEBUG_PRINT - if (ct > 0) { - printf("_"); - --ct; - } + if (ct > 0) { + dbg_printf("_"); + --ct; + } #endif } } @@ -186,8 +186,8 @@ mp_obj_t common_hal_alarm_light_sleep_until_alarms(size_t n_alarms, const mp_obj } else { r_obj = _get_wake_alarm(n_alarms, alarms); - alarm_reset(); } + alarm_reset(); return r_obj; } @@ -220,6 +220,16 @@ void NORETURN alarm_enter_deep_sleep(void) { while(1) ; } +void alarm_pretending_deep_sleep(void) { + alarm_pin_pinalarm_prepare_for_deep_sleep(); + alarm_touch_touchalarm_prepare_for_deep_sleep(); + + port_idle_until_interrupt(); + if (alarm_woken_from_sleep()) { + alarm_reset(); + } +} + void common_hal_alarm_gc_collect(void) { void* p = alarm_get_wake_alarm(); gc_collect_ptr(p); diff --git a/ports/nrf/common-hal/alarm/pin/PinAlarm.c b/ports/nrf/common-hal/alarm/pin/PinAlarm.c index 606a7125fa..5ed6fb725c 100644 --- a/ports/nrf/common-hal/alarm/pin/PinAlarm.c +++ b/ports/nrf/common-hal/alarm/pin/PinAlarm.c @@ -27,6 +27,7 @@ #include "py/runtime.h" #include +#include #include "shared-bindings/alarm/pin/PinAlarm.h" #include "shared-bindings/microcontroller/__init__.h" @@ -44,6 +45,10 @@ volatile char _pinhandler_gpiote_count; volatile nrfx_gpiote_pin_t _pinhandler_ev_pin; #define MYGPIOTE_EV_PIN_UNDEF 0xFF +static bool pins_configured = false; + +extern uint32_t reset_reason_saved; +extern void dbg_dump_GPIOregs(void); void common_hal_alarm_pin_pinalarm_construct(alarm_pin_pinalarm_obj_t *self, mcu_pin_obj_t *pin, bool value, bool edge, bool pull) { if (edge) { @@ -94,7 +99,6 @@ mp_obj_t alarm_pin_pinalarm_get_wakeup_alarm(size_t n_alarms, const mp_obj_t *al return alarms[i]; } } - alarm_pin_pinalarm_obj_t *alarm = m_new_obj(alarm_pin_pinalarm_obj_t); alarm->base.type = &alarm_pin_pinalarm_type; alarm->pin = NULL; @@ -133,11 +137,14 @@ void alarm_pin_pinalarm_reset(void) { pull_pins = 0; } -static void setup_pin1_for_lightsleep(void) { +static void configure_pins_for_sleep(void) { + nrfx_err_t err; if ( nrfx_gpiote_is_init() ) { - nrfx_gpiote_uninit(); + nrfx_gpiote_uninit(); } - nrfx_gpiote_init(NRFX_GPIOTE_CONFIG_IRQ_PRIORITY); + err = nrfx_gpiote_init(NRFX_GPIOTE_CONFIG_IRQ_PRIORITY); + assert(err == NRFX_SUCCESS); + (void)err; // to suppress unused warning _pinhandler_gpiote_count = 0; _pinhandler_ev_pin = MYGPIOTE_EV_PIN_UNDEF; @@ -151,10 +158,6 @@ static void setup_pin1_for_lightsleep(void) { }; for(size_t i = 0; i < 64; ++i) { uint64_t mask = 1ull << i; -#ifdef NRF_DEBUG_PRINT - int pull = 0; - int sense = 0; -#endif if (((high_alarms & mask) == 0) && ((low_alarms & mask) == 0)) { continue; } @@ -162,76 +165,28 @@ static void setup_pin1_for_lightsleep(void) { cfg.sense = NRF_GPIOTE_POLARITY_LOTOHI; cfg.pull = ((pull_pins & mask) != 0) ? NRF_GPIO_PIN_PULLDOWN : NRF_GPIO_PIN_NOPULL; -#ifdef NRF_DEBUG_PRINT - pull = -1; sense = 1; -#endif } else if (((high_alarms & mask) == 0) && ((low_alarms & mask) != 0)) { cfg.sense = NRF_GPIOTE_POLARITY_HITOLO; cfg.pull = ((pull_pins & mask) != 0) ? NRF_GPIO_PIN_PULLUP : NRF_GPIO_PIN_NOPULL; -#ifdef NRF_DEBUG_PRINT - pull = 1; sense = -1; -#endif } else { cfg.sense = NRF_GPIOTE_POLARITY_TOGGLE; cfg.pull = NRF_GPIO_PIN_NOPULL; -#ifdef NRF_DEBUG_PRINT - sense = 9; -#endif } - nrfx_gpiote_in_init((nrfx_gpiote_pin_t)i, &cfg, - pinalarm_gpiote_handler); + err = nrfx_gpiote_in_init((nrfx_gpiote_pin_t)i, &cfg, + pinalarm_gpiote_handler); + assert(err == NRFX_SUCCESS); nrfx_gpiote_in_event_enable((nrfx_gpiote_pin_t)i, true); -#ifdef NRF_DEBUG_PRINT - dbg_printf("pin=%d, sense=%d, pull=%d\r\n", i, sense, pull); -#endif - } -} - -static void setup_pin1_for_deepsleep(void) { - for(size_t i = 0; i < 64; ++i) { - uint64_t mask = 1ull << i; - int pull = 0; -#ifdef NRF_DEBUG_PRINT - int sense = 0; -#endif - if (((high_alarms & mask) == 0) && ((low_alarms & mask) == 0)) { - continue; - } if (((high_alarms & mask) != 0) && ((low_alarms & mask) == 0)) { - pull = ((pull_pins & mask) != 0) ? - NRF_GPIO_PIN_PULLDOWN : NRF_GPIO_PIN_NOPULL; - nrf_gpio_cfg_input((uint32_t)i, (nrf_gpio_pin_pull_t)pull); nrf_gpio_cfg_sense_set((uint32_t)i, NRF_GPIO_PIN_SENSE_HIGH); -#ifdef NRF_DEBUG_PRINT - sense = NRF_GPIO_PIN_SENSE_HIGH; -#endif - } - else + } if (((high_alarms & mask) == 0) && ((low_alarms & mask) != 0)) { - pull = ((pull_pins & mask) != 0) ? - NRF_GPIO_PIN_PULLUP : NRF_GPIO_PIN_NOPULL; - nrf_gpio_cfg_input((uint32_t)i, (nrf_gpio_pin_pull_t)pull); nrf_gpio_cfg_sense_set((uint32_t)i, NRF_GPIO_PIN_SENSE_LOW); -#ifdef NRF_DEBUG_PRINT - sense = NRF_GPIO_PIN_SENSE_LOW; -#endif - } -#ifdef NRF_DEBUG_PRINT - dbg_printf("pin=%d, sense=%d, pull=%d\r\n", i, sense, pull); -#endif + } } -#if 0 - uint32_t pin_number = 2; - NRF_GPIO_Type * reg = nrf_gpio_pin_port_decode(&pin_number); - dbg_printf(" 2 PIN_CNF=0x%08X\r\n", (unsigned int)(reg->PIN_CNF[pin_number])); - pin_number = 28; - reg = nrf_gpio_pin_port_decode(&pin_number); - dbg_printf("28 PIN_CNF=0x%08X\r\n", (unsigned int)(reg->PIN_CNF[pin_number])); -#endif } void alarm_pin_pinalarm_set_alarms(bool deep_sleep, size_t n_alarms, const mp_obj_t *alarms) { @@ -261,11 +216,13 @@ void alarm_pin_pinalarm_set_alarms(bool deep_sleep, size_t n_alarms, const mp_ob } if (pin_number != -1) { if (!deep_sleep) { - setup_pin1_for_lightsleep(); + configure_pins_for_sleep(); } else { // we don't setup gpio HW here but do them in // alarm_pin_pinalarm_prepare_for_deep_sleep() below + reset_reason_saved = 0; + pins_configured = false; } } else { @@ -274,5 +231,11 @@ void alarm_pin_pinalarm_set_alarms(bool deep_sleep, size_t n_alarms, const mp_ob } void alarm_pin_pinalarm_prepare_for_deep_sleep(void) { - setup_pin1_for_deepsleep(); + if (!pins_configured) { + configure_pins_for_sleep(); + pins_configured = true; +#ifdef NRF_DEBUG_PRINT + dbg_dump_GPIOregs(); +#endif + } } diff --git a/shared-bindings/alarm/__init__.c b/shared-bindings/alarm/__init__.c index 7023c70e5d..509e0acebd 100644 --- a/shared-bindings/alarm/__init__.c +++ b/shared-bindings/alarm/__init__.c @@ -242,3 +242,8 @@ const mp_obj_module_t alarm_module = { .base = { &mp_type_module }, .globals = (mp_obj_dict_t*)&alarm_module_globals, }; + +extern void port_idle_until_interrupt(void); +MP_WEAK void alarm_pretending_deep_sleep(void) { + port_idle_until_interrupt(); +} diff --git a/shared-bindings/alarm/__init__.h b/shared-bindings/alarm/__init__.h index 154f91e265..37e8b98ecc 100644 --- a/shared-bindings/alarm/__init__.h +++ b/shared-bindings/alarm/__init__.h @@ -42,6 +42,7 @@ extern mp_obj_t common_hal_alarm_light_sleep_until_alarms(size_t n_alarms, const 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); +extern void alarm_pretending_deep_sleep(void); // Fetches value from module dict. extern mp_obj_t alarm_get_wake_alarm(void); From 7cecd996584d819a99b3a09cc1dc1c86d6514041 Mon Sep 17 00:00:00 2001 From: jun2sak Date: Sun, 28 Feb 2021 16:04:29 +0900 Subject: [PATCH 32/67] remove unused debug printf's. --- ports/nrf/common-hal/alarm/pin/PinAlarm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ports/nrf/common-hal/alarm/pin/PinAlarm.c b/ports/nrf/common-hal/alarm/pin/PinAlarm.c index 5ed6fb725c..47d7ce8360 100644 --- a/ports/nrf/common-hal/alarm/pin/PinAlarm.c +++ b/ports/nrf/common-hal/alarm/pin/PinAlarm.c @@ -235,7 +235,7 @@ void alarm_pin_pinalarm_prepare_for_deep_sleep(void) { configure_pins_for_sleep(); pins_configured = true; #ifdef NRF_DEBUG_PRINT - dbg_dump_GPIOregs(); + //dbg_dump_GPIOregs(); #endif } } From 7bb789625ed8713334c24c1d78460bf5c2f03492 Mon Sep 17 00:00:00 2001 From: jun2sak Date: Sun, 28 Feb 2021 16:27:37 +0900 Subject: [PATCH 33/67] use the original port_idle_until_interrupt() if not CIRCUITPY_ALARM. --- main.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/main.c b/main.c index 2aebfa062f..e6e5a6d2a8 100755 --- a/main.c +++ b/main.c @@ -430,7 +430,11 @@ STATIC bool run_code_py(safe_mode_t safe_mode) { // 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. + #if CIRCUITPY_ALARM alarm_pretending_deep_sleep(); + #else + port_idle_until_interrupt(); + #endif } } } From 3fab9f8b1b8e86d0c9224ea4c79b4ba35da6ade1 Mon Sep 17 00:00:00 2001 From: jun2sak Date: Sun, 7 Mar 2021 01:09:54 +0900 Subject: [PATCH 34/67] new wait-until-alarm design, don't use System OFF. --- main.c | 1 + ports/nrf/common-hal/alarm/SleepMemory.c | 26 +-- ports/nrf/common-hal/alarm/SleepMemory.h | 1 + ports/nrf/common-hal/alarm/__init__.c | 184 +++++++++++++++++--- ports/nrf/common-hal/alarm/__init__.h | 9 + ports/nrf/common-hal/alarm/pin/PinAlarm.c | 14 +- ports/nrf/common-hal/alarm/time/TimeAlarm.c | 36 ++-- ports/nrf/common-hal/alarm/time/TimeAlarm.h | 6 + ports/nrf/supervisor/debug_uart.c | 32 +++- ports/nrf/supervisor/port.c | 32 +++- 10 files changed, 274 insertions(+), 67 deletions(-) diff --git a/main.c b/main.c index e6e5a6d2a8..0f7ca8860e 100755 --- a/main.c +++ b/main.c @@ -435,6 +435,7 @@ STATIC bool run_code_py(safe_mode_t safe_mode) { #else port_idle_until_interrupt(); #endif + return false; // to go REPL } } } diff --git a/ports/nrf/common-hal/alarm/SleepMemory.c b/ports/nrf/common-hal/alarm/SleepMemory.c index 49eb0b2594..367f305972 100644 --- a/ports/nrf/common-hal/alarm/SleepMemory.c +++ b/ports/nrf/common-hal/alarm/SleepMemory.c @@ -27,6 +27,7 @@ #include #include "py/runtime.h" +#include "common-hal/alarm/__init__.h" #include "common-hal/alarm/SleepMemory.h" #include "nrf_power.h" @@ -35,14 +36,15 @@ extern void dbg_dump_RAMreg(void); #include "supervisor/serial.h" // dbg_printf() #endif -#define RTC_DATA_ATTR __attribute__((section(".uninitialized"))) -static RTC_DATA_ATTR uint8_t _sleep_mem[SLEEP_MEMORY_LENGTH]; -static RTC_DATA_ATTR uint32_t _sleep_mem_magicnum; +__attribute__((section(".uninitialized"))) static uint8_t _sleepmem[SLEEP_MEMORY_LENGTH]; +__attribute__((section(".uninitialized"))) uint8_t sleepmem_wakeup_event; +__attribute__((section(".uninitialized"))) uint8_t sleepmem_wakeup_pin; +__attribute__((section(".uninitialized"))) static uint32_t _sleepmem_magicnum; #define SLEEP_MEMORY_DATA_GUARD 0xad0000af #define SLEEP_MEMORY_DATA_GUARD_MASK 0xff0000ff static int is_sleep_memory_valid(void) { - if ((_sleep_mem_magicnum & SLEEP_MEMORY_DATA_GUARD_MASK) + if ((_sleepmem_magicnum & SLEEP_MEMORY_DATA_GUARD_MASK) == SLEEP_MEMORY_DATA_GUARD) { return 1; } @@ -75,14 +77,16 @@ void set_memory_retention(void) { } static void initialize_sleep_memory(void) { - memset((uint8_t *)_sleep_mem, 0, SLEEP_MEMORY_LENGTH); + memset((uint8_t *)_sleepmem, 0, SLEEP_MEMORY_LENGTH); + sleepmem_wakeup_event = 0; + sleepmem_wakeup_pin = 0; set_memory_retention(); #ifdef NRF_DEBUG_PRINT //dbg_dump_RAMreg(); #endif - _sleep_mem_magicnum = SLEEP_MEMORY_DATA_GUARD; + _sleepmem_magicnum = SLEEP_MEMORY_DATA_GUARD; } void alarm_sleep_memory_reset(void) { @@ -95,21 +99,21 @@ void alarm_sleep_memory_reset(void) { } uint32_t common_hal_alarm_sleep_memory_get_length(alarm_sleep_memory_obj_t *self) { - return sizeof(_sleep_mem); + return sizeof(_sleepmem); } bool common_hal_alarm_sleep_memory_set_bytes(alarm_sleep_memory_obj_t *self, uint32_t start_index, const uint8_t* values, uint32_t len) { - if (start_index + len > sizeof(_sleep_mem)) { + if (start_index + len > sizeof(_sleepmem)) { return false; } - memcpy((uint8_t *) (_sleep_mem + start_index), values, len); + memcpy((uint8_t *) (_sleepmem + start_index), values, len); return true; } void common_hal_alarm_sleep_memory_get_bytes(alarm_sleep_memory_obj_t *self, uint32_t start_index, uint8_t* values, uint32_t len) { - if (start_index + len > sizeof(_sleep_mem)) { + if (start_index + len > sizeof(_sleepmem)) { return; } - memcpy(values, (uint8_t *) (_sleep_mem + start_index), len); + memcpy(values, (uint8_t *) (_sleepmem + start_index), len); } diff --git a/ports/nrf/common-hal/alarm/SleepMemory.h b/ports/nrf/common-hal/alarm/SleepMemory.h index 24fe0065d0..11cc4a8fb9 100644 --- a/ports/nrf/common-hal/alarm/SleepMemory.h +++ b/ports/nrf/common-hal/alarm/SleepMemory.h @@ -35,6 +35,7 @@ typedef struct { mp_obj_base_t base; } alarm_sleep_memory_obj_t; +extern void set_memory_retention(void); extern void alarm_sleep_memory_reset(void); #endif // MICROPY_INCLUDED_NRF_COMMON_HAL_ALARM_SLEEPMEMORY_H diff --git a/ports/nrf/common-hal/alarm/__init__.c b/ports/nrf/common-hal/alarm/__init__.c index f54b54a3f9..12bb2a40c4 100644 --- a/ports/nrf/common-hal/alarm/__init__.c +++ b/ports/nrf/common-hal/alarm/__init__.c @@ -37,10 +37,13 @@ #include "shared-bindings/alarm/pin/PinAlarm.h" #include "shared-bindings/alarm/time/TimeAlarm.h" #include "shared-bindings/alarm/touch/TouchAlarm.h" +#include "shared-bindings/time/__init__.h" #include "supervisor/port.h" +#include "supervisor/serial.h" // serial_connected() #ifdef NRF_DEBUG_PRINT #include "supervisor/serial.h" // dbg_printf() +extern int dbg_check_RTCprescaler(void); #endif #include "nrf.h" @@ -113,6 +116,23 @@ bool alarm_woken_from_sleep(void) { || cause == NRF_SLEEP_WAKEUP_TOUCHPAD); } +nrf_sleep_source_t alarm_woken_from_sleep_2(void) { + nrf_sleep_source_t cause = _get_wakeup_cause(); +#ifdef NRF_DEBUG_PRINT + if (cause != NRF_SLEEP_WAKEUP_UNDEFINED) { + //print_wakeup_cause(cause); + } +#endif + if (cause == NRF_SLEEP_WAKEUP_GPIO || + cause == NRF_SLEEP_WAKEUP_TIMER || + cause == NRF_SLEEP_WAKEUP_TOUCHPAD) { + return cause; + } + else { + return NRF_SLEEP_WAKEUP_UNDEFINED; + } +} + STATIC mp_obj_t _get_wake_alarm(size_t n_alarms, const mp_obj_t *alarms) { nrf_sleep_source_t cause = _get_wakeup_cause(); #ifdef NRF_DEBUG_PRINT @@ -146,19 +166,74 @@ STATIC void _setup_sleep_alarms(bool deep_sleep, size_t n_alarms, const mp_obj_t alarm_touch_touchalarm_set_alarm(deep_sleep, n_alarms, alarms); } -STATIC void _idle_until_alarm(void) { +nrf_sleep_source_t system_on_idle_until_alarm(int64_t timediff_ms, uint32_t prescaler) { + bool have_timeout = false; + uint64_t start_tick = 0, end_tick = 0; + + if (timediff_ms != -1) { + have_timeout = true; +#if 0 + int64_t now = common_hal_time_monotonic_ms(); + dbg_printf("now_ms=%ld timediff_ms=%ld\r\n", (long)now, (long)timediff_ms); +#endif + if (timediff_ms < 0) timediff_ms = 0; + int64_t tickdiff; + if (prescaler == 0) { + // 1 tick = 1/1024 sec = 1000/1024 ms + // -> 1 ms = 1024/1000 ticks + tickdiff = (mp_uint_t)(timediff_ms * 1024 / 1000); // ms -> ticks + } + else { + // 1 tick = prescaler/1024 sec = prescaler*1000/1024 ms + // -> 1ms = 1024/(1000*prescaler) ticks + tickdiff = (mp_uint_t)(timediff_ms * 1024 / (1000 * prescaler)); + } + start_tick = port_get_raw_ticks(NULL); + end_tick = start_tick + tickdiff; + } +#if 0 + dbg_printf("start_tick=%ld end_tick=%ld have_timeout=%c\r\n", (long)start_tick, (long)end_tick, have_timeout ? 'T' : 'F'); +#endif + + int64_t remaining; + nrf_sleep_source_t wakeup_cause = NRF_SLEEP_WAKEUP_UNDEFINED; + sleepmem_wakeup_event = SLEEPMEM_WAKEUP_BY_NONE; + sleepmem_wakeup_pin = WAKEUP_PIN_UNDEF; + #ifdef NRF_DEBUG_PRINT int ct = 40; + char reason = '?'; +#define WAKEUP_REASON(x) reason = (x) +#else +#define WAKEUP_REASON(x) #endif - reset_reason_saved = 0; - // Poll for alarms. - while (!mp_hal_is_interrupted()) { - RUN_BACKGROUND_TASKS; - // Allow ctrl-C interrupt. - if (alarm_woken_from_sleep()) { - alarm_save_wake_alarm(); - return; + + while(1) { + if (mp_hal_is_interrupted()) { + WAKEUP_REASON('I'); + break; } + if (serial_connected() && serial_bytes_available()) { + WAKEUP_REASON('S'); + break; + } + RUN_BACKGROUND_TASKS; + wakeup_cause = alarm_woken_from_sleep_2(); + if (wakeup_cause != NRF_SLEEP_WAKEUP_UNDEFINED) { + WAKEUP_REASON('0'+wakeup_cause); + break; + } + if (have_timeout) { + remaining = end_tick - port_get_raw_ticks(NULL); + // We break a bit early so we don't risk setting the alarm before the time when we call + // sleep. + if (remaining < 1) { + WAKEUP_REASON('t'); + break; + } + port_interrupt_after_ticks(remaining); + } + // Idle until an interrupt happens. port_idle_until_interrupt(); #ifdef NRF_DEBUG_PRINT if (ct > 0) { @@ -166,17 +241,39 @@ STATIC void _idle_until_alarm(void) { --ct; } #endif + if (have_timeout) { + remaining = end_tick - port_get_raw_ticks(NULL); + if (remaining <= 0) { + wakeup_cause = NRF_SLEEP_WAKEUP_TIMER; + sleepmem_wakeup_event = SLEEPMEM_WAKEUP_BY_TIMER; + WAKEUP_REASON('T'); + break; + } + } } +#ifdef NRF_DEBUG_PRINT + dbg_printf("%c\r\n", reason); +#endif + return wakeup_cause; } mp_obj_t common_hal_alarm_light_sleep_until_alarms(size_t n_alarms, const mp_obj_t *alarms) { mp_obj_t r_obj = mp_const_none; + alarm_time_timealarm_clear_wakeup_time(); _setup_sleep_alarms(false, n_alarms, alarms); + #ifdef NRF_DEBUG_PRINT - dbg_printf("\r\nsleep..."); + dbg_printf("\r\nlight sleep..."); #endif - _idle_until_alarm(); + int64_t timediff_ms = alarm_time_timealarm_get_wakeup_timediff_ms(); + nrf_sleep_source_t cause = system_on_idle_until_alarm(timediff_ms, 0); + (void)cause; + +#ifdef NRF_DEBUG_PRINT + //dbg_printf("wakeup! "); + print_wakeup_cause(cause); +#endif if (mp_hal_is_interrupted()) { #ifdef NRF_DEBUG_PRINT @@ -192,29 +289,47 @@ mp_obj_t common_hal_alarm_light_sleep_until_alarms(size_t n_alarms, const mp_obj } void common_hal_alarm_set_deep_sleep_alarms(size_t n_alarms, const mp_obj_t *alarms) { + alarm_time_timealarm_clear_wakeup_time(); _setup_sleep_alarms(true, n_alarms, alarms); } -extern void set_memory_retention(void); +#if defined(MICROPY_QSPI_CS) +extern void qspi_disable(void); +#endif + +#define PRESCALER_VALUE_IN_DEEP_SLEEP (1024) +extern void _debug_uart_init(void); +extern void _debug_uart_uninit(void); void NORETURN alarm_enter_deep_sleep(void) { alarm_pin_pinalarm_prepare_for_deep_sleep(); - alarm_touch_touchalarm_prepare_for_deep_sleep(); + alarm_time_timealarm_prepare_for_deep_sleep(); - uint8_t sd_enabled; - sd_softdevice_is_enabled(&sd_enabled); - - set_memory_retention(); +#if defined(MICROPY_QSPI_CS) + qspi_disable(); +#endif #ifdef NRF_DEBUG_PRINT - dbg_printf("go system off.. %d\r\n", sd_enabled); + dbg_printf("\r\ndeep sleep..."); #endif - if (sd_enabled) { - sd_power_system_off(); - } - else { - NRF_POWER->SYSTEMOFF = 1; - } + int64_t timediff_ms = alarm_time_timealarm_get_wakeup_timediff_ms(); + tick_set_prescaler(PRESCALER_VALUE_IN_DEEP_SLEEP -1); +#ifdef NRF_DEBUG_PRINT + dbg_dump_RTCreg(); //XXX + dbg_check_RTCprescaler(); //XXX +#endif + nrf_sleep_source_t cause; + cause = system_on_idle_until_alarm(timediff_ms, + PRESCALER_VALUE_IN_DEEP_SLEEP); + (void)cause; + +#ifdef NRF_DEBUG_PRINT + dbg_printf("wakeup! "); + print_wakeup_cause(cause); + dbg_printf("RESET...\r\n\r\n"); +#endif + + reset_cpu(); // should not reach here.. while(1) ; @@ -222,12 +337,23 @@ void NORETURN alarm_enter_deep_sleep(void) { void alarm_pretending_deep_sleep(void) { alarm_pin_pinalarm_prepare_for_deep_sleep(); - alarm_touch_touchalarm_prepare_for_deep_sleep(); + alarm_time_timealarm_prepare_for_deep_sleep(); - port_idle_until_interrupt(); - if (alarm_woken_from_sleep()) { - alarm_reset(); - } +#ifdef NRF_DEBUG_PRINT + dbg_printf("\r\npretending to deep sleep..."); +#endif + + int64_t timediff_ms = alarm_time_timealarm_get_wakeup_timediff_ms(); + nrf_sleep_source_t cause = system_on_idle_until_alarm(timediff_ms, 0); + (void)cause; + +#ifdef NRF_DEBUG_PRINT + dbg_printf("wakeup! "); + print_wakeup_cause(cause); + dbg_printf("continue..\r\n"); +#endif + + alarm_reset(); } void common_hal_alarm_gc_collect(void) { diff --git a/ports/nrf/common-hal/alarm/__init__.h b/ports/nrf/common-hal/alarm/__init__.h index 6fa07bcd29..7df3aaf4c3 100644 --- a/ports/nrf/common-hal/alarm/__init__.h +++ b/ports/nrf/common-hal/alarm/__init__.h @@ -41,6 +41,15 @@ typedef enum { extern const alarm_sleep_memory_obj_t alarm_sleep_memory_obj; +enum { + SLEEPMEM_WAKEUP_BY_NONE = 0, + SLEEPMEM_WAKEUP_BY_PIN = 1, + SLEEPMEM_WAKEUP_BY_TIMER = 2, +}; +#define WAKEUP_PIN_UNDEF 0xFF +extern uint8_t sleepmem_wakeup_event; +extern uint8_t sleepmem_wakeup_pin; + extern void alarm_reset(void); #endif // MICROPY_INCLUDED_NRF_COMMON_HAL_ALARM__INIT__H diff --git a/ports/nrf/common-hal/alarm/pin/PinAlarm.c b/ports/nrf/common-hal/alarm/pin/PinAlarm.c index 47d7ce8360..1f00dc0c33 100644 --- a/ports/nrf/common-hal/alarm/pin/PinAlarm.c +++ b/ports/nrf/common-hal/alarm/pin/PinAlarm.c @@ -32,6 +32,7 @@ #include "shared-bindings/alarm/pin/PinAlarm.h" #include "shared-bindings/microcontroller/__init__.h" #include "shared-bindings/microcontroller/Pin.h" +#include "common-hal/alarm/__init__.h" #include "nrfx.h" #include "nrf_gpio.h" @@ -43,8 +44,6 @@ #define WPIN_UNUSED 0xFF volatile char _pinhandler_gpiote_count; -volatile nrfx_gpiote_pin_t _pinhandler_ev_pin; -#define MYGPIOTE_EV_PIN_UNDEF 0xFF static bool pins_configured = false; extern uint32_t reset_reason_saved; @@ -81,11 +80,13 @@ bool common_hal_alarm_pin_pinalarm_get_pull(alarm_pin_pinalarm_obj_t *self) { static void pinalarm_gpiote_handler(nrfx_gpiote_pin_t pin, nrf_gpiote_polarity_t action) { ++_pinhandler_gpiote_count; - _pinhandler_ev_pin = pin; + sleepmem_wakeup_event = SLEEPMEM_WAKEUP_BY_PIN; + sleepmem_wakeup_pin = pin & 0xFF; } bool alarm_pin_pinalarm_woke_us_up(void) { - return (_pinhandler_gpiote_count > 0 && _pinhandler_ev_pin != MYGPIOTE_EV_PIN_UNDEF); + return (sleepmem_wakeup_event == SLEEPMEM_WAKEUP_BY_PIN && + sleepmem_wakeup_pin != WAKEUP_PIN_UNDEF); } mp_obj_t alarm_pin_pinalarm_get_wakeup_alarm(size_t n_alarms, const mp_obj_t *alarms) { @@ -95,7 +96,7 @@ mp_obj_t alarm_pin_pinalarm_get_wakeup_alarm(size_t n_alarms, const mp_obj_t *al continue; } alarm_pin_pinalarm_obj_t *alarm = MP_OBJ_TO_PTR(alarms[i]); - if (alarm->pin->number == _pinhandler_ev_pin) { + if (alarm->pin->number == sleepmem_wakeup_pin) { return alarms[i]; } } @@ -105,7 +106,7 @@ mp_obj_t alarm_pin_pinalarm_get_wakeup_alarm(size_t n_alarms, const mp_obj_t *al // Map the pin number back to a pin object. for (size_t i = 0; i < mcu_pin_globals.map.used; i++) { const mcu_pin_obj_t* pin_obj = MP_OBJ_TO_PTR(mcu_pin_globals.map.table[i].value); - if ((size_t) pin_obj->number == _pinhandler_ev_pin) { + if ((size_t) pin_obj->number == sleepmem_wakeup_pin) { alarm->pin = mcu_pin_globals.map.table[i].value; break; } @@ -147,7 +148,6 @@ static void configure_pins_for_sleep(void) { (void)err; // to suppress unused warning _pinhandler_gpiote_count = 0; - _pinhandler_ev_pin = MYGPIOTE_EV_PIN_UNDEF; nrfx_gpiote_in_config_t cfg = { .sense = NRF_GPIOTE_POLARITY_TOGGLE, diff --git a/ports/nrf/common-hal/alarm/time/TimeAlarm.c b/ports/nrf/common-hal/alarm/time/TimeAlarm.c index e9c536414b..c4b06982bf 100644 --- a/ports/nrf/common-hal/alarm/time/TimeAlarm.c +++ b/ports/nrf/common-hal/alarm/time/TimeAlarm.c @@ -30,6 +30,7 @@ //#include "supervisor/esp_port.h" #include +#include "common-hal/alarm/__init__.h" #include "shared-bindings/alarm/time/TimeAlarm.h" #include "shared-bindings/time/__init__.h" @@ -56,17 +57,31 @@ mp_obj_t alarm_time_timealarm_get_wakeup_alarm(size_t n_alarms, const mp_obj_t * } bool alarm_time_timealarm_woke_us_up(void) { - return rtc_woke_up_counter; + return sleepmem_wakeup_event == SLEEPMEM_WAKEUP_BY_TIMER; +} + +int64_t wakeup_time_saved =0; + +int64_t alarm_time_timealarm_get_wakeup_timediff_ms(void) { + if (wakeup_time_saved == 0) { + return -1; + } + return wakeup_time_saved - common_hal_time_monotonic_ms(); +} + +void alarm_time_timealarm_clear_wakeup_time(void) { + wakeup_time_saved = 0; } void alarm_time_timealarm_reset(void) { port_disable_interrupt_after_ticks_ch(1); - rtc_woke_up_counter = 0; + wakeup_time_saved = 0; } void alarm_time_timealarm_set_alarms(bool deep_sleep, size_t n_alarms, const mp_obj_t *alarms) { bool timealarm_set = false; alarm_time_timealarm_obj_t *timealarm = MP_OBJ_NULL; + wakeup_time_saved = 0; for (size_t i = 0; i < n_alarms; i++) { if (!MP_OBJ_IS_TYPE(alarms[i], &alarm_time_timealarm_type)) { @@ -82,17 +97,8 @@ void alarm_time_timealarm_set_alarms(bool deep_sleep, size_t n_alarms, const mp_ return; } - // 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, timealarm->monotonic_time - now_secs); - int wsecs = (int)(wakeup_in_secs); - // timealarm is implemented by RTC, which is a 24bit counter - // running at 32768Hz. So, 2^24 / 32768 = 512sec is an upper limit. - if (wsecs >= 512) { - mp_raise_ValueError(translate("Alarm time must be < 512 seconds.")); - } - - uint32_t wakeup_in_ticks = (uint32_t)(wakeup_in_secs * 1024.0f); - port_interrupt_after_ticks_ch(1, wakeup_in_ticks); - rtc_woke_up_counter = 0; + wakeup_time_saved = (int64_t)(timealarm->monotonic_time * 1000.0f); +} + +void alarm_time_timealarm_prepare_for_deep_sleep(void) { } diff --git a/ports/nrf/common-hal/alarm/time/TimeAlarm.h b/ports/nrf/common-hal/alarm/time/TimeAlarm.h index 14a2ff80cf..a824c52535 100644 --- a/ports/nrf/common-hal/alarm/time/TimeAlarm.h +++ b/ports/nrf/common-hal/alarm/time/TimeAlarm.h @@ -42,3 +42,9 @@ mp_obj_t alarm_time_timealarm_get_wakeup_alarm(size_t n_alarms, const mp_obj_t * bool alarm_time_timealarm_woke_us_up(void); void alarm_time_timealarm_set_alarms(bool deep_sleep, size_t n_alarms, const mp_obj_t *alarms); void alarm_time_timealarm_reset(void); + +extern void alarm_time_timealarm_prepare_for_deep_sleep(void); +extern int64_t alarm_time_timealarm_get_wakeup_timediff_ms(void); +extern void alarm_time_timealarm_clear_wakeup_time(void); +extern void dbg_dump_RTCreg(void); +extern void tick_set_prescaler(uint32_t prescaler_val); diff --git a/ports/nrf/supervisor/debug_uart.c b/ports/nrf/supervisor/debug_uart.c index dda03a00af..f920cdae32 100644 --- a/ports/nrf/supervisor/debug_uart.c +++ b/ports/nrf/supervisor/debug_uart.c @@ -21,9 +21,9 @@ #include "nrfx_rtc.h" #include "supervisor/serial.h" // dbg_printf() #include "shared-bindings/microcontroller/Processor.h" +#include "common-hal/alarm/__init__.h" extern const nrfx_rtc_t rtc_instance; // port.c -extern volatile int rtc_woke_up_counter; // port.c extern uint32_t reset_reason_saved; const nrfx_uarte_t _dbg_uart_inst = NRFX_UARTE_INSTANCE(1); @@ -31,6 +31,16 @@ static int _dbg_uart_initialized = 0; #define DBG_PBUF_LEN 80 static char _dbg_pbuf[DBG_PBUF_LEN+1]; +void _debug_uart_uninit(void) { + nrf_gpio_cfg(DEBUG_UART_TXPIN, + NRF_GPIO_PIN_DIR_INPUT, + NRF_GPIO_PIN_INPUT_DISCONNECT, + NRF_GPIO_PIN_NOPULL, + NRF_GPIO_PIN_S0S1, + NRF_GPIO_PIN_NOSENSE); + nrfx_uarte_uninit(&_dbg_uart_inst); +} + void _debug_uart_init(void) { //if (_dbg_uart_initialized) return; nrfx_uarte_config_t config = { @@ -55,6 +65,16 @@ void _debug_uart_init(void) { NRF_GPIO_PIN_H0H1, // orig=S0S1 NRF_GPIO_PIN_NOSENSE); _dbg_uart_initialized = 1; +#if 1 //XXX + #define DBGPIN 6+32 + nrf_gpio_cfg(DBGPIN, + NRF_GPIO_PIN_DIR_OUTPUT, + NRF_GPIO_PIN_INPUT_DISCONNECT, + NRF_GPIO_PIN_NOPULL, + NRF_GPIO_PIN_H0H1, + NRF_GPIO_PIN_NOSENSE); + nrf_gpio_pin_write(DBGPIN, 1); +#endif return; } @@ -97,7 +117,15 @@ void dbg_dump_RTCreg(void) { dbg_printf("EVTENSET=%08X\r\n", (int)r->EVTENSET); dbg_printf("EVENTS_COMPARE[0..3]=%X,%X,%X,%X ", (int)r->EVENTS_COMPARE[0], (int)r->EVENTS_COMPARE[1], (int)r->EVENTS_COMPARE[2], (int)r->EVENTS_COMPARE[3]); dbg_printf("CC[0..3]=%08X,%08X,%08X,%08X\r\n", (int)r->CC[0], (int)r->CC[1], (int)r->CC[2], (int)r->CC[3]); - dbg_printf("woke_up=%d\r\n", rtc_woke_up_counter); +} + +int dbg_check_RTCprescaler(void) { + NRF_RTC_Type *r = rtc_instance.p_reg; + if ((int)r->PRESCALER == 0) { + dbg_printf("****** PRESCALER == 0\r\n"); + return -1; + } + return 0; } void dbg_dump_RAMreg(void) { diff --git a/ports/nrf/supervisor/port.c b/ports/nrf/supervisor/port.c index 5908683008..d5efa92b46 100644 --- a/ports/nrf/supervisor/port.c +++ b/ports/nrf/supervisor/port.c @@ -51,6 +51,7 @@ #include "common-hal/rtc/RTC.h" #include "common-hal/neopixel_write/__init__.h" #include "common-hal/watchdog/WatchDogTimer.h" +#include "common-hal/alarm/__init__.h" #include "shared-bindings/microcontroller/__init__.h" #include "shared-bindings/rtc/__init__.h" @@ -75,13 +76,13 @@ static void power_warning_handler(void) { #ifdef NRF_DEBUG_PRINT extern void _debug_uart_init(void); +#define DBGPIN 6+32 //XXX P1_06 = TP1 #endif uint32_t reset_reason_saved = 0; const nrfx_rtc_t rtc_instance = NRFX_RTC_INSTANCE(2); -volatile int rtc_woke_up_counter = 0; -const nrfx_rtc_config_t rtc_config = { +nrfx_rtc_config_t rtc_config = { .prescaler = RTC_FREQ_TO_PRESCALER(0x8000), .reliable = 0, .tick_latency = 0, @@ -97,6 +98,11 @@ static volatile struct { } overflow_tracker __attribute__((section(".uninitialized"))); void rtc_handler(nrfx_rtc_int_type_t int_type) { +#ifdef NRF_DEBUG_PRINT + if (int_type == NRFX_RTC_INT_TICK) { + nrf_gpio_pin_toggle(DBGPIN); //XXX + } +#endif if (int_type == NRFX_RTC_INT_OVERFLOW) { // Our RTC is 24 bits and we're clocking it at 32.768khz which is 32 (2 ** 5) subticks per // tick. @@ -108,7 +114,7 @@ void rtc_handler(nrfx_rtc_int_type_t int_type) { nrfx_rtc_cc_set(&rtc_instance, 0, 0, false); } else if (int_type == NRFX_RTC_INT_COMPARE1) { // used in light sleep - ++rtc_woke_up_counter; + sleepmem_wakeup_event = SLEEPMEM_WAKEUP_BY_TIMER; nrfx_rtc_cc_set(&rtc_instance, 1, 0, false); } } @@ -134,6 +140,22 @@ void tick_init(void) { } } +void tick_uninit(void) { + nrfx_rtc_counter_clear(&rtc_instance); + nrfx_rtc_disable(&rtc_instance); + nrfx_rtc_uninit(&rtc_instance); +} + +void tick_set_prescaler(uint32_t prescaler_val) { + tick_uninit(); + // update of prescaler value sometimes fails if we skip this delay.. + NRFX_DELAY_US(1000); + uint16_t prescaler_saved = rtc_config.prescaler; + rtc_config.prescaler = prescaler_val; + tick_init(); + rtc_config.prescaler = prescaler_saved; +} + safe_mode_t port_init(void) { nrf_peripherals_clocks_init(); @@ -166,6 +188,10 @@ safe_mode_t port_init(void) { reset_reason_saved = NRF_POWER->RESETREAS; // clear all RESET reason bits NRF_POWER->RESETREAS = reset_reason_saved; + // clear wakeup event/pin when reset by reset-pin + if (reset_reason_saved & NRF_POWER_RESETREAS_RESETPIN_MASK) { + sleepmem_wakeup_event = SLEEPMEM_WAKEUP_BY_NONE; + } // If the board was reset by the WatchDogTimer, we may // need to boot into safe mode. Reset the RESETREAS bit From cd5c0e99f797a5d21156c1f6d421b8c8e7fbf090 Mon Sep 17 00:00:00 2001 From: jun2sak Date: Sun, 7 Mar 2021 19:09:01 +0900 Subject: [PATCH 35/67] Clean up. --- ports/nrf/supervisor/debug_uart.c | 26 ++++++++++++++++---------- ports/nrf/supervisor/port.c | 6 ------ 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/ports/nrf/supervisor/debug_uart.c b/ports/nrf/supervisor/debug_uart.c index f920cdae32..f770b661fc 100644 --- a/ports/nrf/supervisor/debug_uart.c +++ b/ports/nrf/supervisor/debug_uart.c @@ -65,16 +65,6 @@ void _debug_uart_init(void) { NRF_GPIO_PIN_H0H1, // orig=S0S1 NRF_GPIO_PIN_NOSENSE); _dbg_uart_initialized = 1; -#if 1 //XXX - #define DBGPIN 6+32 - nrf_gpio_cfg(DBGPIN, - NRF_GPIO_PIN_DIR_OUTPUT, - NRF_GPIO_PIN_INPUT_DISCONNECT, - NRF_GPIO_PIN_NOPULL, - NRF_GPIO_PIN_H0H1, - NRF_GPIO_PIN_NOSENSE); - nrf_gpio_pin_write(DBGPIN, 1); -#endif return; } @@ -191,6 +181,22 @@ void dbg_dump_GPIOregs(void) { (int)(reg->EVENTS_PORT), (int)(reg->INTENSET)); } +void dbg_dumpQSPIreg(void) { + uint32_t r; + dbg_printf("QSPI\r\n"); + r = NRF_QSPI->IFCONFIG0; + dbg_printf("IFCONFIG0 READ=%ld write=%ld ADDR=%ld DPM=%ld PPSIZE=%ld\r\n", + r & 7, (r >> 3) & 7, (r >> 6) & 1, (r >> 7) & 1, (r >> 12) & 1); + r = NRF_QSPI->IFCONFIG1; + dbg_printf("IFCONFIG1 SCKDELAY=%ld SPIMODE=%ld SCKFREQ=%ld\r\n", + r & 0xFF, (r >> 25) & 1, (r >> 28) & 0xF); + r = NRF_QSPI->STATUS; + dbg_printf("STATUS DPM=%ld READY=%ld SREG=0x%02lX\r\n", + (r >> 2) & 1, (r >> 3) & 1, (r >> 24) & 0xFF); + r = NRF_QSPI->DPMDUR; + dbg_printf("DPMDUR ENTER=%ld EXIT=%ld\r\n", r & 0xFFFF, (r >> 16) & 0xFFFF); +} + void dbg_dump_reset_reason(void) { int reset_reason = (int)common_hal_mcu_processor_get_reset_reason(); const char* rr_str[] = { diff --git a/ports/nrf/supervisor/port.c b/ports/nrf/supervisor/port.c index d5efa92b46..1ae3cb29ab 100644 --- a/ports/nrf/supervisor/port.c +++ b/ports/nrf/supervisor/port.c @@ -76,7 +76,6 @@ static void power_warning_handler(void) { #ifdef NRF_DEBUG_PRINT extern void _debug_uart_init(void); -#define DBGPIN 6+32 //XXX P1_06 = TP1 #endif uint32_t reset_reason_saved = 0; @@ -98,11 +97,6 @@ static volatile struct { } overflow_tracker __attribute__((section(".uninitialized"))); void rtc_handler(nrfx_rtc_int_type_t int_type) { -#ifdef NRF_DEBUG_PRINT - if (int_type == NRFX_RTC_INT_TICK) { - nrf_gpio_pin_toggle(DBGPIN); //XXX - } -#endif if (int_type == NRFX_RTC_INT_OVERFLOW) { // Our RTC is 24 bits and we're clocking it at 32.768khz which is 32 (2 ** 5) subticks per // tick. From 2795c002adbaa4bdac90c87159cd00eed31792bb Mon Sep 17 00:00:00 2001 From: jun2sak Date: Sun, 7 Mar 2021 19:14:04 +0900 Subject: [PATCH 36/67] disable QSPI while system ON idle loop. --- ports/nrf/common-hal/alarm/__init__.c | 21 ++++--- ports/nrf/supervisor/qspi_flash.c | 86 +++++++++++++++++++++++++++ ports/nrf/supervisor/qspi_flash.h | 2 + 3 files changed, 98 insertions(+), 11 deletions(-) create mode 100644 ports/nrf/supervisor/qspi_flash.h diff --git a/ports/nrf/common-hal/alarm/__init__.c b/ports/nrf/common-hal/alarm/__init__.c index 12bb2a40c4..10d3bcc4fb 100644 --- a/ports/nrf/common-hal/alarm/__init__.c +++ b/ports/nrf/common-hal/alarm/__init__.c @@ -45,6 +45,7 @@ #include "supervisor/serial.h" // dbg_printf() extern int dbg_check_RTCprescaler(void); #endif +#include "supervisor/qspi_flash.h" #include "nrf.h" #include "nrf_power.h" @@ -170,6 +171,10 @@ nrf_sleep_source_t system_on_idle_until_alarm(int64_t timediff_ms, uint32_t pres bool have_timeout = false; uint64_t start_tick = 0, end_tick = 0; +#if defined(MICROPY_QSPI_CS) + qspi_flash_enter_sleep(); +#endif + if (timediff_ms != -1) { have_timeout = true; #if 0 @@ -254,6 +259,11 @@ nrf_sleep_source_t system_on_idle_until_alarm(int64_t timediff_ms, uint32_t pres #ifdef NRF_DEBUG_PRINT dbg_printf("%c\r\n", reason); #endif + +#if defined(MICROPY_QSPI_CS) + qspi_flash_exit_sleep(); +#endif + return wakeup_cause; } @@ -293,29 +303,18 @@ void common_hal_alarm_set_deep_sleep_alarms(size_t n_alarms, const mp_obj_t *ala _setup_sleep_alarms(true, n_alarms, alarms); } -#if defined(MICROPY_QSPI_CS) -extern void qspi_disable(void); -#endif - #define PRESCALER_VALUE_IN_DEEP_SLEEP (1024) -extern void _debug_uart_init(void); -extern void _debug_uart_uninit(void); void NORETURN alarm_enter_deep_sleep(void) { alarm_pin_pinalarm_prepare_for_deep_sleep(); alarm_time_timealarm_prepare_for_deep_sleep(); -#if defined(MICROPY_QSPI_CS) - qspi_disable(); -#endif - #ifdef NRF_DEBUG_PRINT dbg_printf("\r\ndeep sleep..."); #endif int64_t timediff_ms = alarm_time_timealarm_get_wakeup_timediff_ms(); tick_set_prescaler(PRESCALER_VALUE_IN_DEEP_SLEEP -1); #ifdef NRF_DEBUG_PRINT - dbg_dump_RTCreg(); //XXX dbg_check_RTCprescaler(); //XXX #endif nrf_sleep_source_t cause; diff --git a/ports/nrf/supervisor/qspi_flash.c b/ports/nrf/supervisor/qspi_flash.c index 7ca27d56c4..00a88d52b9 100644 --- a/ports/nrf/supervisor/qspi_flash.c +++ b/ports/nrf/supervisor/qspi_flash.c @@ -37,6 +37,9 @@ #include "supervisor/shared/external_flash/common_commands.h" #include "supervisor/shared/external_flash/qspi_flash.h" +#ifdef NRF_DEBUG_PRINT +#include "supervisor/serial.h" // dbg_printf() +#endif // When USB is disconnected, disable QSPI in sleep mode to save energy void qspi_disable(void) @@ -190,7 +193,11 @@ void spi_flash_init(void) { .readoc = NRF_QSPI_READOC_FASTREAD, .writeoc = NRF_QSPI_WRITEOC_PP, .addrmode = NRF_QSPI_ADDRMODE_24BIT, +#ifdef QSPI_FLASH_POWERDOWN + .dpmconfig = true +#else .dpmconfig = false +#endif }, .phy_if = { .sck_freq = NRF_QSPI_FREQ_32MDIV16, // Start at a slow 2MHz and speed up once we know what we're talking to. @@ -238,3 +245,82 @@ void spi_flash_init_device(const external_flash_device* device) { NRF_QSPI->IFCONFIG1 &= ~QSPI_IFCONFIG1_SCKFREQ_Msk; NRF_QSPI->IFCONFIG1 |= sckfreq << QSPI_IFCONFIG1_SCKFREQ_Pos; } + +#ifdef QSPI_FLASH_POWERDOWN +// Parameters for external QSPI Flash power-down +// for W25Q128FV, +// tDP (nCS high to Power-down mode) = 3us +// tRES (nCS high to Standby mode) = 3us +// sck_delay = max(tDP, tRES) / 62.5ns = 48 -> 50 (w/ margin) +#define DUR_DPM_ENTER 1 // tDP in (256*62.5ns) units +#define DUR_DPM_EXIT 1 // tRES in (256*62.5ns) units +#define SCK_DELAY 50 // max(tDP, tRES) in (62.5ns) units +// wait necessary just after DPM enter/exit (cut and try) +#define WAIT_AFTER_DPM_ENTER 10 // usec +#define WAIT_AFTER_DPM_EXIT 50 // usec +#endif + +static int sck_delay_saved = 0; +#ifdef NRF_DEBUG_PRINT +extern void dbg_dumpQSPIreg(void); +#else +#define dbg_dumpQSPIreg(...) +#endif + +void qspi_flash_enter_sleep(void) { +#ifdef QSPI_FLASH_POWERDOWN + uint32_t r; + NRF_QSPI->DPMDUR = + ((DUR_DPM_ENTER & 0xFFFF) << 16) | (DUR_DPM_EXIT & 0xFFFF); + // set sck_delay tempolarily + r = NRF_QSPI->IFCONFIG1; + sck_delay_saved = (r & QSPI_IFCONFIG1_SCKDELAY_Msk) + >> QSPI_IFCONFIG1_SCKDELAY_Pos; + NRF_QSPI->IFCONFIG1 + = (NRF_QSPI->IFCONFIG1 & ~QSPI_IFCONFIG1_SCKDELAY_Msk) + | (SCK_DELAY << QSPI_IFCONFIG1_SCKDELAY_Pos); + + // enabling IFCONFIG0.DPMENABLE here won't work. + // -> do it in spi_flash_init() + //NRF_QSPI->IFCONFIG0 |= QSPI_IFCONFIG0_DPMENABLE_Msk; + //dbg_dumpQSPIreg(); + + // enter deep power-down mode (DPM) + NRF_QSPI->IFCONFIG1 |= QSPI_IFCONFIG1_DPMEN_Msk; + NRFX_DELAY_US(WAIT_AFTER_DPM_ENTER); + if (!(NRF_QSPI->STATUS & QSPI_STATUS_DPM_Msk)) { +#ifdef NRF_DEBUG_PRINT + dbg_printf("qspi flash: DPM failed\r\n"); +#endif + } +#endif + + qspi_disable(); + //dbg_dumpQSPIreg(); +} + +void qspi_flash_exit_sleep(void) { + qspi_enable(); + +#ifdef QSPI_FLASH_POWERDOWN + if (NRF_QSPI->STATUS & QSPI_STATUS_DPM_Msk) { + // exit deep power-down mode + NRF_QSPI->IFCONFIG1 &= ~QSPI_IFCONFIG1_DPMEN_Msk; + NRFX_DELAY_US(WAIT_AFTER_DPM_EXIT); + + if (NRF_QSPI->STATUS & QSPI_STATUS_DPM_Msk) { +#ifdef NRF_DEBUG_PRINT + dbg_printf("qspi flash: exiting DPM failed\r\n"); +#endif + } + // restore sck_delay + if (sck_delay_saved == 0) { + sck_delay_saved = 10; // default + } + NRF_QSPI->IFCONFIG1 + = (NRF_QSPI->IFCONFIG1 & ~QSPI_IFCONFIG1_SCKDELAY_Msk) + | (sck_delay_saved << QSPI_IFCONFIG1_SCKDELAY_Pos); + } + //dbg_dumpQSPIreg(); +#endif +} diff --git a/ports/nrf/supervisor/qspi_flash.h b/ports/nrf/supervisor/qspi_flash.h new file mode 100644 index 0000000000..527f3cec39 --- /dev/null +++ b/ports/nrf/supervisor/qspi_flash.h @@ -0,0 +1,2 @@ +extern void qspi_flash_enter_sleep(void); +extern void qspi_flash_exit_sleep(void); From 7430b92d27c912cf2e43337b4c4a45dac73100b0 Mon Sep 17 00:00:00 2001 From: jun2sak Date: Sun, 7 Mar 2021 20:20:29 +0900 Subject: [PATCH 37/67] address hw pin-reset while sleep. --- ports/nrf/supervisor/qspi_flash.c | 49 ++++++++++++++++++------------- 1 file changed, 28 insertions(+), 21 deletions(-) diff --git a/ports/nrf/supervisor/qspi_flash.c b/ports/nrf/supervisor/qspi_flash.c index 00a88d52b9..d2bf9678da 100644 --- a/ports/nrf/supervisor/qspi_flash.c +++ b/ports/nrf/supervisor/qspi_flash.c @@ -41,6 +41,27 @@ #include "supervisor/serial.h" // dbg_printf() #endif +#ifdef QSPI_FLASH_POWERDOWN +// Parameters for external QSPI Flash power-down +// for W25Q128FV, +// tDP (nCS high to Power-down mode) = 3us +// tRES (nCS high to Standby mode) = 3us +// sck_delay = max(tDP, tRES) / 62.5ns = 48 -> 50 (w/ margin) +#define DUR_DPM_ENTER 1 // tDP in (256*62.5ns) units +#define DUR_DPM_EXIT 1 // tRES in (256*62.5ns) units +#define SCK_DELAY 50 // max(tDP, tRES) in (62.5ns) units +// wait necessary just after DPM enter/exit (cut and try) +#define WAIT_AFTER_DPM_ENTER 10 // usec +#define WAIT_AFTER_DPM_EXIT 50 // usec +#endif + +static int sck_delay_saved = 0; +#ifdef NRF_DEBUG_PRINT +extern void dbg_dumpQSPIreg(void); +#else +#define dbg_dumpQSPIreg(...) +#endif + // When USB is disconnected, disable QSPI in sleep mode to save energy void qspi_disable(void) { @@ -222,6 +243,13 @@ void spi_flash_init(void) { // No callback for blocking API nrfx_qspi_init(&qspi_cfg, NULL, NULL); + +#ifdef QSPI_FLASH_POWERDOWN + // If pin-reset while flash is in power-down mode, + // the flash cannot accept any commands. Send CMD_WAKE to release it. + spi_flash_write_command(CMD_WAKE, NULL, 0); + NRFX_DELAY_US(WAIT_AFTER_DPM_EXIT); +#endif } void spi_flash_init_device(const external_flash_device* device) { @@ -246,27 +274,6 @@ void spi_flash_init_device(const external_flash_device* device) { NRF_QSPI->IFCONFIG1 |= sckfreq << QSPI_IFCONFIG1_SCKFREQ_Pos; } -#ifdef QSPI_FLASH_POWERDOWN -// Parameters for external QSPI Flash power-down -// for W25Q128FV, -// tDP (nCS high to Power-down mode) = 3us -// tRES (nCS high to Standby mode) = 3us -// sck_delay = max(tDP, tRES) / 62.5ns = 48 -> 50 (w/ margin) -#define DUR_DPM_ENTER 1 // tDP in (256*62.5ns) units -#define DUR_DPM_EXIT 1 // tRES in (256*62.5ns) units -#define SCK_DELAY 50 // max(tDP, tRES) in (62.5ns) units -// wait necessary just after DPM enter/exit (cut and try) -#define WAIT_AFTER_DPM_ENTER 10 // usec -#define WAIT_AFTER_DPM_EXIT 50 // usec -#endif - -static int sck_delay_saved = 0; -#ifdef NRF_DEBUG_PRINT -extern void dbg_dumpQSPIreg(void); -#else -#define dbg_dumpQSPIreg(...) -#endif - void qspi_flash_enter_sleep(void) { #ifdef QSPI_FLASH_POWERDOWN uint32_t r; From 2eed9a173555e837f2b33178346c42374379fa0e Mon Sep 17 00:00:00 2001 From: jun2sak Date: Sun, 7 Mar 2021 20:21:33 +0900 Subject: [PATCH 38/67] old System OFF sleep code for future reference. --- ports/nrf/common-hal/alarm/__init__.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/ports/nrf/common-hal/alarm/__init__.c b/ports/nrf/common-hal/alarm/__init__.c index 10d3bcc4fb..5544cdeb59 100644 --- a/ports/nrf/common-hal/alarm/__init__.c +++ b/ports/nrf/common-hal/alarm/__init__.c @@ -334,6 +334,25 @@ void NORETURN alarm_enter_deep_sleep(void) { while(1) ; } +// old version deep sleep code that was used in alarm_enter_deep_sleep() +// for anyone who might want true System OFF sleep .. +#if 0 +void OLD_go_system_off(void) { + sleepmem_wakeup_event = SLEEPMEM_WAKEUP_BY_NONE; + sleepmem_wakeup_pin = WAKEUP_PIN_UNDEF; + uint8_t sd_enabled; + sd_softdevice_is_enabled(&sd_enabled); + set_memory_retention(); + dbg_printf("OLD go system off.. %d\r\n", sd_enabled); + if (sd_enabled) { + sd_power_system_off(); + } + else { + NRF_POWER->SYSTEMOFF = 1; + } +} +#endif + void alarm_pretending_deep_sleep(void) { alarm_pin_pinalarm_prepare_for_deep_sleep(); alarm_time_timealarm_prepare_for_deep_sleep(); From 5bd1107feca0eb3e1d0e59f50d3e6d6d88753832 Mon Sep 17 00:00:00 2001 From: jun2sak Date: Sun, 7 Mar 2021 20:38:04 +0900 Subject: [PATCH 39/67] Clean up. --- ports/nrf/supervisor/qspi_flash.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ports/nrf/supervisor/qspi_flash.c b/ports/nrf/supervisor/qspi_flash.c index d2bf9678da..e4449bcba0 100644 --- a/ports/nrf/supervisor/qspi_flash.c +++ b/ports/nrf/supervisor/qspi_flash.c @@ -53,9 +53,10 @@ // wait necessary just after DPM enter/exit (cut and try) #define WAIT_AFTER_DPM_ENTER 10 // usec #define WAIT_AFTER_DPM_EXIT 50 // usec -#endif static int sck_delay_saved = 0; +#endif + #ifdef NRF_DEBUG_PRINT extern void dbg_dumpQSPIreg(void); #else From c8f36e604cc8d9f566e1f68f0fffb1ad828204ce Mon Sep 17 00:00:00 2001 From: jun2sak Date: Tue, 9 Mar 2021 00:42:22 +0900 Subject: [PATCH 40/67] reset myself, not go REPL, after wakeup from deep sleep. --- ports/nrf/common-hal/alarm/__init__.c | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/ports/nrf/common-hal/alarm/__init__.c b/ports/nrf/common-hal/alarm/__init__.c index 5544cdeb59..b9b39b84a4 100644 --- a/ports/nrf/common-hal/alarm/__init__.c +++ b/ports/nrf/common-hal/alarm/__init__.c @@ -170,6 +170,7 @@ STATIC void _setup_sleep_alarms(bool deep_sleep, size_t n_alarms, const mp_obj_t nrf_sleep_source_t system_on_idle_until_alarm(int64_t timediff_ms, uint32_t prescaler) { bool have_timeout = false; uint64_t start_tick = 0, end_tick = 0; + int64_t tickdiff; #if defined(MICROPY_QSPI_CS) qspi_flash_enter_sleep(); @@ -182,7 +183,6 @@ nrf_sleep_source_t system_on_idle_until_alarm(int64_t timediff_ms, uint32_t pres dbg_printf("now_ms=%ld timediff_ms=%ld\r\n", (long)now, (long)timediff_ms); #endif if (timediff_ms < 0) timediff_ms = 0; - int64_t tickdiff; if (prescaler == 0) { // 1 tick = 1/1024 sec = 1000/1024 ms // -> 1 ms = 1024/1000 ticks @@ -264,6 +264,18 @@ nrf_sleep_source_t system_on_idle_until_alarm(int64_t timediff_ms, uint32_t pres qspi_flash_exit_sleep(); #endif + tickdiff = port_get_raw_ticks(NULL) - start_tick; + if (prescaler == 0) { + timediff_ms = tickdiff / 1024; + } + else { + timediff_ms = tickdiff * prescaler / 1024; + } + (void)timediff_ms; +#ifdef NRF_DEBUG_PRINT + dbg_printf("lapse %6.1f sec\r\n", (double)(timediff_ms)); +#endif + return wakeup_cause; } @@ -368,10 +380,17 @@ void alarm_pretending_deep_sleep(void) { #ifdef NRF_DEBUG_PRINT dbg_printf("wakeup! "); print_wakeup_cause(cause); - dbg_printf("continue..\r\n"); #endif alarm_reset(); + + // if one of Alarm event occurred, reset myself + if (cause == NRF_SLEEP_WAKEUP_GPIO || + cause == NRF_SLEEP_WAKEUP_TIMER || + cause == NRF_SLEEP_WAKEUP_TOUCHPAD) { + reset_cpu(); + } + // else, just return and go into REPL } void common_hal_alarm_gc_collect(void) { From 6e9429d779f01c823ca4e0d0b277e20533d6ada3 Mon Sep 17 00:00:00 2001 From: jun2sak Date: Mon, 12 Apr 2021 20:53:14 +0900 Subject: [PATCH 41/67] soft reboot for pretending deep sleep. --- main.c | 19 +++++++++++++++---- ports/nrf/common-hal/alarm/__init__.c | 7 ++++--- 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/main.c b/main.c index b311db39dd..755f8d5362 100755 --- a/main.c +++ b/main.c @@ -404,10 +404,10 @@ STATIC bool run_code_py(safe_mode_t safe_mode) { 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. + // Enter deep sleep. When we wake up we'll return from + // this loop. common_hal_alarm_enter_deep_sleep(); - // Does not return. + // Does not return. } else { serial_write_compressed(translate("Pretending to deep sleep until alarm, CTRL-C or file write.\n")); } @@ -426,10 +426,21 @@ STATIC bool run_code_py(safe_mode_t safe_mode) { #if CIRCUITPY_ALARM common_hal_alarm_pretending_deep_sleep(); + bool serial_in = (serial_connected() && + serial_bytes_available()); + supervisor_set_run_reason(RUN_REASON_STARTUP); + board_init(); + if (serial_in) { + bool ctrl_d = serial_read() == CHAR_CTRL_D; + if (ctrl_d) { + supervisor_set_run_reason(RUN_REASON_REPL_RELOAD); + } + return ctrl_d; + } + return true; #else port_idle_until_interrupt(); #endif - //return false; // to go REPL } } } diff --git a/ports/nrf/common-hal/alarm/__init__.c b/ports/nrf/common-hal/alarm/__init__.c index 2baec6b433..c8180fb2e0 100644 --- a/ports/nrf/common-hal/alarm/__init__.c +++ b/ports/nrf/common-hal/alarm/__init__.c @@ -346,7 +346,7 @@ void NORETURN common_hal_alarm_enter_deep_sleep(void) { while(1) ; } -// old version deep sleep code that was used in alarm_enter_deep_sleep() +// old version deep sleep code that was used in common_hal_alarm_enter_deep_sleep() // for anyone who might want true System OFF sleep .. #if 0 void OLD_go_system_off(void) { @@ -384,6 +384,7 @@ void common_hal_alarm_pretending_deep_sleep(void) { alarm_reset(); +#if 0 // if one of Alarm event occurred, reset myself if (cause == NRF_SLEEP_WAKEUP_GPIO || cause == NRF_SLEEP_WAKEUP_TIMER || @@ -391,9 +392,9 @@ void common_hal_alarm_pretending_deep_sleep(void) { reset_cpu(); } // else, just return and go into REPL +#endif } void common_hal_alarm_gc_collect(void) { - void* p = shared_alarm_get_wake_alarm(); - gc_collect_ptr(p); + gc_collect_ptr(shared_alarm_get_wake_alarm()); } From 436e33e7ecd7af42ac52e94b6604c728d296bffe Mon Sep 17 00:00:00 2001 From: Lucian Copeland Date: Tue, 20 Apr 2021 15:04:52 -0400 Subject: [PATCH 42/67] Fix CI formatting issues --- locale/circuitpython.pot | 5 +---- supervisor/shared/serial.c | 10 +++++----- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/locale/circuitpython.pot b/locale/circuitpython.pot index a5a4da90f8..2a43daf014 100644 --- a/locale/circuitpython.pot +++ b/locale/circuitpython.pot @@ -309,10 +309,6 @@ msgstr "" msgid "Address type out of range" msgstr "" -#: ports/nrf/common-hal/alarm/time/TimeAlarm.c -msgid "Alarm time must be < 512 seconds." -msgstr "" - #: ports/esp32s2/common-hal/canio/CAN.c msgid "All CAN peripherals are in use" msgstr "" @@ -3722,6 +3718,7 @@ msgstr "" #: ports/esp32s2/boards/adafruit_magtag_2.9_grayscale/mpconfigboard.h #: ports/esp32s2/boards/adafruit_metro_esp32s2/mpconfigboard.h #: ports/esp32s2/boards/artisense_rd00/mpconfigboard.h +#: ports/esp32s2/boards/atmegazero_esp32s2/mpconfigboard.h #: ports/esp32s2/boards/electroniccats_bastwifi/mpconfigboard.h #: ports/esp32s2/boards/espressif_kaluga_1/mpconfigboard.h #: ports/esp32s2/boards/espressif_saola_1_wroom/mpconfigboard.h diff --git a/supervisor/shared/serial.c b/supervisor/shared/serial.c index dc3a37e116..beb2541a15 100644 --- a/supervisor/shared/serial.c +++ b/supervisor/shared/serial.c @@ -40,7 +40,7 @@ #ifdef NRF_DEBUG_PRINT // XXX these functions are in nrf/supervisor/debug_uart.c extern void _debug_uart_init(void); -extern void _debug_print_substr(const char* text, uint32_t length); +extern void _debug_print_substr(const char *text, uint32_t length); #endif /* @@ -72,15 +72,15 @@ void serial_early_init(void) { #endif #ifdef NRF_DEBUG_PRINT - _debug_uart_init(); + _debug_uart_init(); #endif } void serial_init(void) { usb_init(); -#ifdef NRF_DEBUG_PRINT + #ifdef NRF_DEBUG_PRINT _debug_uart_init(); -#endif + #endif } bool serial_connected(void) { @@ -160,7 +160,7 @@ void serial_write_substring(const char *text, uint32_t length) { #if defined(DEBUG_UART_TX) && defined(DEBUG_UART_RX) int uart_errcode; - common_hal_busio_uart_write(&debug_uart, (const uint8_t*) text, length, &uart_errcode); + common_hal_busio_uart_write(&debug_uart, (const uint8_t *)text, length, &uart_errcode); #endif #ifdef NRF_DEBUG_PRINT From a1dc423569c94b994aaa7ee21cd4d3bbdb59fbc8 Mon Sep 17 00:00:00 2001 From: Lucian Copeland Date: Tue, 20 Apr 2021 17:20:53 -0400 Subject: [PATCH 43/67] Remove Alarm from small boards --- ports/nrf/boards/pca10100/mpconfigboard.mk | 1 + ports/nrf/boards/simmel/mpconfigboard.mk | 1 + ports/nrf/mpconfigport.mk | 2 +- ports/nrf/supervisor/port.c | 4 ++++ 4 files changed, 7 insertions(+), 1 deletion(-) diff --git a/ports/nrf/boards/pca10100/mpconfigboard.mk b/ports/nrf/boards/pca10100/mpconfigboard.mk index 74080a1ed9..dd59eb96c9 100644 --- a/ports/nrf/boards/pca10100/mpconfigboard.mk +++ b/ports/nrf/boards/pca10100/mpconfigboard.mk @@ -7,6 +7,7 @@ MCU_CHIP = nrf52833 INTERNAL_FLASH_FILESYSTEM = 1 +CIRCUITPY_ALARM = 0 CIRCUITPY_AUDIOMP3 = 0 CIRCUITPY_BITBANGIO = 0 CIRCUITPY_BITMAPTOOLS = 0 diff --git a/ports/nrf/boards/simmel/mpconfigboard.mk b/ports/nrf/boards/simmel/mpconfigboard.mk index 005ec8af2f..e6750877b2 100644 --- a/ports/nrf/boards/simmel/mpconfigboard.mk +++ b/ports/nrf/boards/simmel/mpconfigboard.mk @@ -10,6 +10,7 @@ MCU_CHIP = nrf52833 INTERNAL_FLASH_FILESYSTEM = 1 +CIRCUITPY_ALARM = 0 CIRCUITPY_AESIO = 1 CIRCUITPY_AUDIOMP3 = 0 CIRCUITPY_BITMAPTOOLS = 0 diff --git a/ports/nrf/mpconfigport.mk b/ports/nrf/mpconfigport.mk index a5766cf1fe..132aba208f 100644 --- a/ports/nrf/mpconfigport.mk +++ b/ports/nrf/mpconfigport.mk @@ -47,7 +47,7 @@ CIRCUITPY_COUNTIO = 0 CIRCUITPY_WATCHDOG ?= 1 # Sleep and Wakeup -CIRCUITPY_ALARM = 1 +CIRCUITPY_ALARM ?= 1 # nRF52840-specific diff --git a/ports/nrf/supervisor/port.c b/ports/nrf/supervisor/port.c index 5cad994c0d..8026e51d84 100644 --- a/ports/nrf/supervisor/port.c +++ b/ports/nrf/supervisor/port.c @@ -108,7 +108,9 @@ void rtc_handler(nrfx_rtc_int_type_t int_type) { nrfx_rtc_cc_set(&rtc_instance, 0, 0, false); } else if (int_type == NRFX_RTC_INT_COMPARE1) { // used in light sleep + #if CIRCUITPY_ALARM sleepmem_wakeup_event = SLEEPMEM_WAKEUP_BY_TIMER; + #endif nrfx_rtc_cc_set(&rtc_instance, 1, 0, false); } } @@ -184,7 +186,9 @@ safe_mode_t port_init(void) { NRF_POWER->RESETREAS = reset_reason_saved; // clear wakeup event/pin when reset by reset-pin if (reset_reason_saved & NRF_POWER_RESETREAS_RESETPIN_MASK) { + #if CIRCUITPY_ALARM sleepmem_wakeup_event = SLEEPMEM_WAKEUP_BY_NONE; + #endif } // If the board was reset by the WatchDogTimer, we may From 39b7d9bcf2098d8402392dd5f237787cf8d75d86 Mon Sep 17 00:00:00 2001 From: Lucian Copeland Date: Tue, 20 Apr 2021 18:03:37 -0400 Subject: [PATCH 44/67] Fix indentation --- main.c | 12 +- ports/nrf/common-hal/alarm/SleepMemory.c | 22 ++-- ports/nrf/common-hal/alarm/__init__.c | 106 +++++++++--------- ports/nrf/common-hal/alarm/__init__.h | 14 +-- ports/nrf/common-hal/alarm/pin/PinAlarm.c | 26 ++--- .../common-hal/microcontroller/Processor.c | 6 +- ports/nrf/supervisor/debug_uart.c | 104 ++++++++--------- ports/nrf/supervisor/qspi_flash.c | 24 ++-- 8 files changed, 157 insertions(+), 157 deletions(-) diff --git a/main.c b/main.c index 755f8d5362..d16db235e8 100755 --- a/main.c +++ b/main.c @@ -407,7 +407,7 @@ STATIC bool run_code_py(safe_mode_t safe_mode) { // Enter deep sleep. When we wake up we'll return from // this loop. common_hal_alarm_enter_deep_sleep(); - // Does not return. + // Does not return. } else { serial_write_compressed(translate("Pretending to deep sleep until alarm, CTRL-C or file write.\n")); } @@ -431,11 +431,11 @@ STATIC bool run_code_py(safe_mode_t safe_mode) { supervisor_set_run_reason(RUN_REASON_STARTUP); board_init(); if (serial_in) { - bool ctrl_d = serial_read() == CHAR_CTRL_D; - if (ctrl_d) { - supervisor_set_run_reason(RUN_REASON_REPL_RELOAD); - } - return ctrl_d; + bool ctrl_d = serial_read() == CHAR_CTRL_D; + if (ctrl_d) { + supervisor_set_run_reason(RUN_REASON_REPL_RELOAD); + } + return ctrl_d; } return true; #else diff --git a/ports/nrf/common-hal/alarm/SleepMemory.c b/ports/nrf/common-hal/alarm/SleepMemory.c index 367f305972..e87fcd7991 100644 --- a/ports/nrf/common-hal/alarm/SleepMemory.c +++ b/ports/nrf/common-hal/alarm/SleepMemory.c @@ -57,22 +57,22 @@ void set_memory_retention(void) { // nRF52833 has RAM[0..7].Section[0..1] and RAM[8].Section[0,1] for(int block = 0; block <= 7; ++block) { nrf_power_rampower_mask_on(NRF_POWER, block, - NRF_POWER_RAMPOWER_S0RETENTION_MASK | - NRF_POWER_RAMPOWER_S1RETENTION_MASK); + NRF_POWER_RAMPOWER_S0RETENTION_MASK | + NRF_POWER_RAMPOWER_S1RETENTION_MASK); }; #ifdef NRF52840 nrf_power_rampower_mask_on(NRF_POWER, 8, - NRF_POWER_RAMPOWER_S0RETENTION_MASK | - NRF_POWER_RAMPOWER_S1RETENTION_MASK | - NRF_POWER_RAMPOWER_S2RETENTION_MASK | - NRF_POWER_RAMPOWER_S3RETENTION_MASK | - NRF_POWER_RAMPOWER_S4RETENTION_MASK | - NRF_POWER_RAMPOWER_S5RETENTION_MASK); + NRF_POWER_RAMPOWER_S0RETENTION_MASK | + NRF_POWER_RAMPOWER_S1RETENTION_MASK | + NRF_POWER_RAMPOWER_S2RETENTION_MASK | + NRF_POWER_RAMPOWER_S3RETENTION_MASK | + NRF_POWER_RAMPOWER_S4RETENTION_MASK | + NRF_POWER_RAMPOWER_S5RETENTION_MASK); #endif #ifdef NRF52833 nrf_power_rampower_mask_on(NRF_POWER, 8, - NRF_POWER_RAMPOWER_S0RETENTION_MASK | - NRF_POWER_RAMPOWER_S1RETENTION_MASK); + NRF_POWER_RAMPOWER_S0RETENTION_MASK | + NRF_POWER_RAMPOWER_S1RETENTION_MASK); #endif } @@ -93,7 +93,7 @@ void alarm_sleep_memory_reset(void) { if (!is_sleep_memory_valid()) { initialize_sleep_memory(); #ifdef NRF_DEBUG_PRINT - dbg_printf("sleep memory initialized\r\n"); + dbg_printf("sleep memory initialized\r\n"); #endif } } diff --git a/ports/nrf/common-hal/alarm/__init__.c b/ports/nrf/common-hal/alarm/__init__.c index c8180fb2e0..aabb27ef25 100644 --- a/ports/nrf/common-hal/alarm/__init__.c +++ b/ports/nrf/common-hal/alarm/__init__.c @@ -101,7 +101,7 @@ static const char* cause_str[] = { void print_wakeup_cause(nrf_sleep_source_t cause) { if (cause >= 0 && cause < NRF_SLEEP_WAKEUP_ZZZ) { dbg_printf("wakeup cause = NRF_SLEEP_WAKEUP_%s\r\n", - cause_str[(int)cause]); + cause_str[(int)cause]); } } #endif @@ -114,7 +114,7 @@ bool common_hal_alarm_woken_from_sleep(void) { } #endif return (cause == NRF_SLEEP_WAKEUP_GPIO || cause == NRF_SLEEP_WAKEUP_TIMER - || cause == NRF_SLEEP_WAKEUP_TOUCHPAD); + || cause == NRF_SLEEP_WAKEUP_TOUCHPAD); } nrf_sleep_source_t alarm_woken_from_sleep_2(void) { @@ -125,8 +125,8 @@ nrf_sleep_source_t alarm_woken_from_sleep_2(void) { } #endif if (cause == NRF_SLEEP_WAKEUP_GPIO || - cause == NRF_SLEEP_WAKEUP_TIMER || - cause == NRF_SLEEP_WAKEUP_TOUCHPAD) { + cause == NRF_SLEEP_WAKEUP_TIMER || + cause == NRF_SLEEP_WAKEUP_TOUCHPAD) { return cause; } else { @@ -179,22 +179,22 @@ nrf_sleep_source_t system_on_idle_until_alarm(int64_t timediff_ms, uint32_t pres if (timediff_ms != -1) { have_timeout = true; #if 0 - int64_t now = common_hal_time_monotonic_ms(); - dbg_printf("now_ms=%ld timediff_ms=%ld\r\n", (long)now, (long)timediff_ms); + int64_t now = common_hal_time_monotonic_ms(); + dbg_printf("now_ms=%ld timediff_ms=%ld\r\n", (long)now, (long)timediff_ms); #endif - if (timediff_ms < 0) timediff_ms = 0; - if (prescaler == 0) { - // 1 tick = 1/1024 sec = 1000/1024 ms - // -> 1 ms = 1024/1000 ticks - tickdiff = (mp_uint_t)(timediff_ms * 1024 / 1000); // ms -> ticks - } - else { - // 1 tick = prescaler/1024 sec = prescaler*1000/1024 ms - // -> 1ms = 1024/(1000*prescaler) ticks - tickdiff = (mp_uint_t)(timediff_ms * 1024 / (1000 * prescaler)); - } - start_tick = port_get_raw_ticks(NULL); - end_tick = start_tick + tickdiff; + if (timediff_ms < 0) timediff_ms = 0; + if (prescaler == 0) { + // 1 tick = 1/1024 sec = 1000/1024 ms + // -> 1 ms = 1024/1000 ticks + tickdiff = (mp_uint_t)(timediff_ms * 1024 / 1000); // ms -> ticks + } + else { + // 1 tick = prescaler/1024 sec = prescaler*1000/1024 ms + // -> 1ms = 1024/(1000*prescaler) ticks + tickdiff = (mp_uint_t)(timediff_ms * 1024 / (1000 * prescaler)); + } + start_tick = port_get_raw_ticks(NULL); + end_tick = start_tick + tickdiff; } #if 0 dbg_printf("start_tick=%ld end_tick=%ld have_timeout=%c\r\n", (long)start_tick, (long)end_tick, have_timeout ? 'T' : 'F'); @@ -214,30 +214,30 @@ nrf_sleep_source_t system_on_idle_until_alarm(int64_t timediff_ms, uint32_t pres #endif while(1) { - if (mp_hal_is_interrupted()) { - WAKEUP_REASON('I'); - break; - } + if (mp_hal_is_interrupted()) { + WAKEUP_REASON('I'); + break; + } if (serial_connected() && serial_bytes_available()) { - WAKEUP_REASON('S'); - break; - } + WAKEUP_REASON('S'); + break; + } RUN_BACKGROUND_TASKS; - wakeup_cause = alarm_woken_from_sleep_2(); - if (wakeup_cause != NRF_SLEEP_WAKEUP_UNDEFINED) { - WAKEUP_REASON('0'+wakeup_cause); - break; - } - if (have_timeout) { - remaining = end_tick - port_get_raw_ticks(NULL); - // We break a bit early so we don't risk setting the alarm before the time when we call - // sleep. - if (remaining < 1) { - WAKEUP_REASON('t'); - break; - } - port_interrupt_after_ticks(remaining); - } + wakeup_cause = alarm_woken_from_sleep_2(); + if (wakeup_cause != NRF_SLEEP_WAKEUP_UNDEFINED) { + WAKEUP_REASON('0'+wakeup_cause); + break; + } + if (have_timeout) { + remaining = end_tick - port_get_raw_ticks(NULL); + // We break a bit early so we don't risk setting the alarm before the time when we call + // sleep. + if (remaining < 1) { + WAKEUP_REASON('t'); + break; + } + port_interrupt_after_ticks(remaining); + } // Idle until an interrupt happens. port_idle_until_interrupt(); #ifdef NRF_DEBUG_PRINT @@ -246,15 +246,15 @@ nrf_sleep_source_t system_on_idle_until_alarm(int64_t timediff_ms, uint32_t pres --ct; } #endif - if (have_timeout) { - remaining = end_tick - port_get_raw_ticks(NULL); - if (remaining <= 0) { - wakeup_cause = NRF_SLEEP_WAKEUP_TIMER; - sleepmem_wakeup_event = SLEEPMEM_WAKEUP_BY_TIMER; - WAKEUP_REASON('T'); - break; - } - } + if (have_timeout) { + remaining = end_tick - port_get_raw_ticks(NULL); + if (remaining <= 0) { + wakeup_cause = NRF_SLEEP_WAKEUP_TIMER; + sleepmem_wakeup_event = SLEEPMEM_WAKEUP_BY_TIMER; + WAKEUP_REASON('T'); + break; + } + } } #ifdef NRF_DEBUG_PRINT dbg_printf("%c\r\n", reason); @@ -331,7 +331,7 @@ void NORETURN common_hal_alarm_enter_deep_sleep(void) { #endif nrf_sleep_source_t cause; cause = system_on_idle_until_alarm(timediff_ms, - PRESCALER_VALUE_IN_DEEP_SLEEP); + PRESCALER_VALUE_IN_DEEP_SLEEP); (void)cause; #ifdef NRF_DEBUG_PRINT @@ -387,8 +387,8 @@ void common_hal_alarm_pretending_deep_sleep(void) { #if 0 // if one of Alarm event occurred, reset myself if (cause == NRF_SLEEP_WAKEUP_GPIO || - cause == NRF_SLEEP_WAKEUP_TIMER || - cause == NRF_SLEEP_WAKEUP_TOUCHPAD) { + cause == NRF_SLEEP_WAKEUP_TIMER || + cause == NRF_SLEEP_WAKEUP_TOUCHPAD) { reset_cpu(); } // else, just return and go into REPL diff --git a/ports/nrf/common-hal/alarm/__init__.h b/ports/nrf/common-hal/alarm/__init__.h index 7df3aaf4c3..ce8ca5f327 100644 --- a/ports/nrf/common-hal/alarm/__init__.h +++ b/ports/nrf/common-hal/alarm/__init__.h @@ -30,13 +30,13 @@ #include "common-hal/alarm/SleepMemory.h" typedef enum { - NRF_SLEEP_WAKEUP_UNDEFINED, - NRF_SLEEP_WAKEUP_GPIO, - NRF_SLEEP_WAKEUP_TIMER, - NRF_SLEEP_WAKEUP_TOUCHPAD, - NRF_SLEEP_WAKEUP_VBUS, - NRF_SLEEP_WAKEUP_RESETPIN, - NRF_SLEEP_WAKEUP_ZZZ + NRF_SLEEP_WAKEUP_UNDEFINED, + NRF_SLEEP_WAKEUP_GPIO, + NRF_SLEEP_WAKEUP_TIMER, + NRF_SLEEP_WAKEUP_TOUCHPAD, + NRF_SLEEP_WAKEUP_VBUS, + NRF_SLEEP_WAKEUP_RESETPIN, + NRF_SLEEP_WAKEUP_ZZZ } nrf_sleep_source_t; extern const alarm_sleep_memory_obj_t alarm_sleep_memory_obj; diff --git a/ports/nrf/common-hal/alarm/pin/PinAlarm.c b/ports/nrf/common-hal/alarm/pin/PinAlarm.c index 1f00dc0c33..89ec2ad30f 100644 --- a/ports/nrf/common-hal/alarm/pin/PinAlarm.c +++ b/ports/nrf/common-hal/alarm/pin/PinAlarm.c @@ -86,7 +86,7 @@ static void pinalarm_gpiote_handler(nrfx_gpiote_pin_t pin, nrf_gpiote_polarity_t bool alarm_pin_pinalarm_woke_us_up(void) { return (sleepmem_wakeup_event == SLEEPMEM_WAKEUP_BY_PIN && - sleepmem_wakeup_pin != WAKEUP_PIN_UNDEF); + sleepmem_wakeup_pin != WAKEUP_PIN_UNDEF); } mp_obj_t alarm_pin_pinalarm_get_wakeup_alarm(size_t n_alarms, const mp_obj_t *alarms) { @@ -96,7 +96,7 @@ mp_obj_t alarm_pin_pinalarm_get_wakeup_alarm(size_t n_alarms, const mp_obj_t *al continue; } alarm_pin_pinalarm_obj_t *alarm = MP_OBJ_TO_PTR(alarms[i]); - if (alarm->pin->number == sleepmem_wakeup_pin) { + if (alarm->pin->number == sleepmem_wakeup_pin) { return alarms[i]; } } @@ -129,8 +129,8 @@ void alarm_pin_pinalarm_reset(void) { continue; } reset_pin_number(i); - nrfx_gpiote_in_event_disable((nrfx_gpiote_pin_t)i); - nrfx_gpiote_in_uninit((nrfx_gpiote_pin_t)i); + nrfx_gpiote_in_event_disable((nrfx_gpiote_pin_t)i); + nrfx_gpiote_in_uninit((nrfx_gpiote_pin_t)i); } high_alarms = 0; @@ -177,15 +177,15 @@ static void configure_pins_for_sleep(void) { cfg.pull = NRF_GPIO_PIN_NOPULL; } err = nrfx_gpiote_in_init((nrfx_gpiote_pin_t)i, &cfg, - pinalarm_gpiote_handler); - assert(err == NRFX_SUCCESS); + pinalarm_gpiote_handler); + assert(err == NRFX_SUCCESS); nrfx_gpiote_in_event_enable((nrfx_gpiote_pin_t)i, true); if (((high_alarms & mask) != 0) && ((low_alarms & mask) == 0)) { nrf_gpio_cfg_sense_set((uint32_t)i, NRF_GPIO_PIN_SENSE_HIGH); - } + } if (((high_alarms & mask) == 0) && ((low_alarms & mask) != 0)) { nrf_gpio_cfg_sense_set((uint32_t)i, NRF_GPIO_PIN_SENSE_LOW); - } + } } } @@ -202,7 +202,7 @@ void alarm_pin_pinalarm_set_alarms(bool deep_sleep, size_t n_alarms, const mp_ob alarm_pin_pinalarm_obj_t *alarm = MP_OBJ_TO_PTR(alarms[i]); pin_number = alarm->pin->number; - //dbg_printf("alarm_pin_pinalarm_set_alarms(pin#=%d, val=%d, pull=%d)\r\n", pin_number, alarm->value, alarm->pull); + //dbg_printf("alarm_pin_pinalarm_set_alarms(pin#=%d, val=%d, pull=%d)\r\n", pin_number, alarm->value, alarm->pull); if (alarm->value) { high_alarms |= 1ull << pin_number; high_count++; @@ -221,8 +221,8 @@ void alarm_pin_pinalarm_set_alarms(bool deep_sleep, size_t n_alarms, const mp_ob else { // we don't setup gpio HW here but do them in // alarm_pin_pinalarm_prepare_for_deep_sleep() below - reset_reason_saved = 0; - pins_configured = false; + reset_reason_saved = 0; + pins_configured = false; } } else { @@ -233,9 +233,9 @@ void alarm_pin_pinalarm_set_alarms(bool deep_sleep, size_t n_alarms, const mp_ob void alarm_pin_pinalarm_prepare_for_deep_sleep(void) { if (!pins_configured) { configure_pins_for_sleep(); - pins_configured = true; + pins_configured = true; #ifdef NRF_DEBUG_PRINT - //dbg_dump_GPIOregs(); + //dbg_dump_GPIOregs(); #endif } } diff --git a/ports/nrf/common-hal/microcontroller/Processor.c b/ports/nrf/common-hal/microcontroller/Processor.c index 4baa4eaace..bcad002ffe 100644 --- a/ports/nrf/common-hal/microcontroller/Processor.c +++ b/ports/nrf/common-hal/microcontroller/Processor.c @@ -141,9 +141,9 @@ mcu_reset_reason_t common_hal_mcu_processor_get_reset_reason(void) { r = RESET_REASON_SOFTWARE; } else if ((reset_reason_saved & POWER_RESETREAS_OFF_Msk) || - (reset_reason_saved & POWER_RESETREAS_LPCOMP_Msk) || - (reset_reason_saved & POWER_RESETREAS_NFC_Msk) || - (reset_reason_saved & POWER_RESETREAS_VBUS_Msk)) { + (reset_reason_saved & POWER_RESETREAS_LPCOMP_Msk) || + (reset_reason_saved & POWER_RESETREAS_NFC_Msk) || + (reset_reason_saved & POWER_RESETREAS_VBUS_Msk)) { r = RESET_REASON_DEEP_SLEEP_ALARM; } return r; diff --git a/ports/nrf/supervisor/debug_uart.c b/ports/nrf/supervisor/debug_uart.c index f770b661fc..420ba14b82 100644 --- a/ports/nrf/supervisor/debug_uart.c +++ b/ports/nrf/supervisor/debug_uart.c @@ -33,11 +33,11 @@ static char _dbg_pbuf[DBG_PBUF_LEN+1]; void _debug_uart_uninit(void) { nrf_gpio_cfg(DEBUG_UART_TXPIN, - NRF_GPIO_PIN_DIR_INPUT, - NRF_GPIO_PIN_INPUT_DISCONNECT, - NRF_GPIO_PIN_NOPULL, - NRF_GPIO_PIN_S0S1, - NRF_GPIO_PIN_NOSENSE); + NRF_GPIO_PIN_DIR_INPUT, + NRF_GPIO_PIN_INPUT_DISCONNECT, + NRF_GPIO_PIN_NOPULL, + NRF_GPIO_PIN_S0S1, + NRF_GPIO_PIN_NOSENSE); nrfx_uarte_uninit(&_dbg_uart_inst); } @@ -59,11 +59,11 @@ void _debug_uart_init(void) { nrfx_uarte_init(&_dbg_uart_inst, &config, NULL); // drive config nrf_gpio_cfg(config.pseltxd, - NRF_GPIO_PIN_DIR_OUTPUT, - NRF_GPIO_PIN_INPUT_DISCONNECT, - NRF_GPIO_PIN_PULLUP, // orig=NOPULL - NRF_GPIO_PIN_H0H1, // orig=S0S1 - NRF_GPIO_PIN_NOSENSE); + NRF_GPIO_PIN_DIR_OUTPUT, + NRF_GPIO_PIN_INPUT_DISCONNECT, + NRF_GPIO_PIN_PULLUP, // orig=NOPULL + NRF_GPIO_PIN_H0H1, // orig=S0S1 + NRF_GPIO_PIN_NOSENSE); _dbg_uart_initialized = 1; return; } @@ -73,16 +73,16 @@ void _debug_print_substr(const char* text, uint32_t length) { int siz; while(length != 0) { if (length <= DBG_PBUF_LEN) { - siz = length; - } - else { - siz = DBG_PBUF_LEN; - } - memcpy(_dbg_pbuf, data, siz); - _dbg_pbuf[siz] = 0; - nrfx_uarte_tx(&_dbg_uart_inst, (uint8_t const*)_dbg_pbuf, siz); - data += siz; - length -= siz; + siz = length; + } + else { + siz = DBG_PBUF_LEN; + } + memcpy(_dbg_pbuf, data, siz); + _dbg_pbuf[siz] = 0; + nrfx_uarte_tx(&_dbg_uart_inst, (uint8_t const*)_dbg_pbuf, siz); + data += siz; + length -= siz; } } @@ -113,7 +113,7 @@ int dbg_check_RTCprescaler(void) { NRF_RTC_Type *r = rtc_instance.p_reg; if ((int)r->PRESCALER == 0) { dbg_printf("****** PRESCALER == 0\r\n"); - return -1; + return -1; } return 0; } @@ -135,20 +135,20 @@ void dbg_dump_GPIOregs(void) { const char cnf_sense_chr[] = "-?HL"; // sense high, sense low for(port=0, col=0; port<=1; ++port) { for(i=0; i<32; ++i) { - uint32_t cnf = gpio[port]->PIN_CNF[i]; - if (cnf != 0x0002) { // changed from default value - dbg_printf("[%d_%02d]:%c%c%c%d%c ", port, i, - (cnf & 1) ? 'O' : 'I', // output, input - (cnf & 2) ? 'd' : 'c', // disconnected, connected - cnf_pull_chr[(cnf >> 2) & 3], - (int)((cnf >> 8) & 7), // drive config 0-7 - cnf_sense_chr[(cnf >> 16) & 3]); - if (++col >= 6) { - dbg_printf("\r\n"); - col = 0; - } - } - } + uint32_t cnf = gpio[port]->PIN_CNF[i]; + if (cnf != 0x0002) { // changed from default value + dbg_printf("[%d_%02d]:%c%c%c%d%c ", port, i, + (cnf & 1) ? 'O' : 'I', // output, input + (cnf & 2) ? 'd' : 'c', // disconnected, connected + cnf_pull_chr[(cnf >> 2) & 3], + (int)((cnf >> 8) & 7), // drive config 0-7 + cnf_sense_chr[(cnf >> 16) & 3]); + if (++col >= 6) { + dbg_printf("\r\n"); + col = 0; + } + } + } } if (col > 0) dbg_printf("\r\n"); @@ -159,26 +159,26 @@ void dbg_dump_GPIOregs(void) { const char config_outinit_chr[] = "01"; // initial value is 0 or 1 for(i=0, col=0; i<8; ++i) { uint32_t conf = reg->CONFIG[i]; - if (conf != 0) { // changed from default value - dbg_printf("CONFIG[%d]:%d_%02d,%c%c%c ", i, - (int)((conf >> 13) & 1), (int)((conf >> 8) & 0x1F), - config_mode_chr[conf & 3], - config_pol_chr[(conf >> 16) & 3], - (conf & 3) == 3 ? - config_outinit_chr[(conf >> 20) & 1] : '-'); - if (++col >= 4) { - dbg_printf("\r\n"); - col = 0; - } - } + if (conf != 0) { // changed from default value + dbg_printf("CONFIG[%d]:%d_%02d,%c%c%c ", i, + (int)((conf >> 13) & 1), (int)((conf >> 8) & 0x1F), + config_mode_chr[conf & 3], + config_pol_chr[(conf >> 16) & 3], + (conf & 3) == 3 ? + config_outinit_chr[(conf >> 20) & 1] : '-'); + if (++col >= 4) { + dbg_printf("\r\n"); + col = 0; + } + } } if (col > 0) dbg_printf("\r\n"); for(i=0; i<8; ++i) { dbg_printf("EVENTS_IN[%d]:%X ", i, (int)(reg->EVENTS_IN[i])); - if ((i & 3) == 3) dbg_printf("\r\n"); + if ((i & 3) == 3) dbg_printf("\r\n"); } dbg_printf("EVENTS_PORT:%X INTENSET:%08X\r\n", - (int)(reg->EVENTS_PORT), (int)(reg->INTENSET)); + (int)(reg->EVENTS_PORT), (int)(reg->INTENSET)); } void dbg_dumpQSPIreg(void) { @@ -186,13 +186,13 @@ void dbg_dumpQSPIreg(void) { dbg_printf("QSPI\r\n"); r = NRF_QSPI->IFCONFIG0; dbg_printf("IFCONFIG0 READ=%ld write=%ld ADDR=%ld DPM=%ld PPSIZE=%ld\r\n", - r & 7, (r >> 3) & 7, (r >> 6) & 1, (r >> 7) & 1, (r >> 12) & 1); + r & 7, (r >> 3) & 7, (r >> 6) & 1, (r >> 7) & 1, (r >> 12) & 1); r = NRF_QSPI->IFCONFIG1; dbg_printf("IFCONFIG1 SCKDELAY=%ld SPIMODE=%ld SCKFREQ=%ld\r\n", - r & 0xFF, (r >> 25) & 1, (r >> 28) & 0xF); + r & 0xFF, (r >> 25) & 1, (r >> 28) & 0xF); r = NRF_QSPI->STATUS; dbg_printf("STATUS DPM=%ld READY=%ld SREG=0x%02lX\r\n", - (r >> 2) & 1, (r >> 3) & 1, (r >> 24) & 0xFF); + (r >> 2) & 1, (r >> 3) & 1, (r >> 24) & 0xFF); r = NRF_QSPI->DPMDUR; dbg_printf("DPMDUR ENTER=%ld EXIT=%ld\r\n", r & 0xFFFF, (r >> 16) & 0xFFFF); } diff --git a/ports/nrf/supervisor/qspi_flash.c b/ports/nrf/supervisor/qspi_flash.c index f2beb3e3a9..6d1bec4422 100644 --- a/ports/nrf/supervisor/qspi_flash.c +++ b/ports/nrf/supervisor/qspi_flash.c @@ -281,7 +281,7 @@ void qspi_flash_enter_sleep(void) { // set sck_delay tempolarily r = NRF_QSPI->IFCONFIG1; sck_delay_saved = (r & QSPI_IFCONFIG1_SCKDELAY_Msk) - >> QSPI_IFCONFIG1_SCKDELAY_Pos; + >> QSPI_IFCONFIG1_SCKDELAY_Pos; NRF_QSPI->IFCONFIG1 = (NRF_QSPI->IFCONFIG1 & ~QSPI_IFCONFIG1_SCKDELAY_Msk) | (SCK_DELAY << QSPI_IFCONFIG1_SCKDELAY_Pos); @@ -312,20 +312,20 @@ void qspi_flash_exit_sleep(void) { if (NRF_QSPI->STATUS & QSPI_STATUS_DPM_Msk) { // exit deep power-down mode NRF_QSPI->IFCONFIG1 &= ~QSPI_IFCONFIG1_DPMEN_Msk; - NRFX_DELAY_US(WAIT_AFTER_DPM_EXIT); + NRFX_DELAY_US(WAIT_AFTER_DPM_EXIT); - if (NRF_QSPI->STATUS & QSPI_STATUS_DPM_Msk) { + if (NRF_QSPI->STATUS & QSPI_STATUS_DPM_Msk) { #ifdef NRF_DEBUG_PRINT - dbg_printf("qspi flash: exiting DPM failed\r\n"); + dbg_printf("qspi flash: exiting DPM failed\r\n"); #endif - } - // restore sck_delay - if (sck_delay_saved == 0) { - sck_delay_saved = 10; // default - } - NRF_QSPI->IFCONFIG1 - = (NRF_QSPI->IFCONFIG1 & ~QSPI_IFCONFIG1_SCKDELAY_Msk) - | (sck_delay_saved << QSPI_IFCONFIG1_SCKDELAY_Pos); + } + // restore sck_delay + if (sck_delay_saved == 0) { + sck_delay_saved = 10; // default + } + NRF_QSPI->IFCONFIG1 + = (NRF_QSPI->IFCONFIG1 & ~QSPI_IFCONFIG1_SCKDELAY_Msk) + | (sck_delay_saved << QSPI_IFCONFIG1_SCKDELAY_Pos); } //dbg_dumpQSPIreg(); #endif From 779169da266cc52759596cf8e25ae18e5e8f7e8d Mon Sep 17 00:00:00 2001 From: Lucian Copeland Date: Wed, 21 Apr 2021 13:43:10 -0400 Subject: [PATCH 45/67] Reduce Simmel size --- ports/nrf/boards/simmel/mpconfigboard.mk | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ports/nrf/boards/simmel/mpconfigboard.mk b/ports/nrf/boards/simmel/mpconfigboard.mk index e6750877b2..e235fd1051 100644 --- a/ports/nrf/boards/simmel/mpconfigboard.mk +++ b/ports/nrf/boards/simmel/mpconfigboard.mk @@ -16,6 +16,7 @@ CIRCUITPY_AUDIOMP3 = 0 CIRCUITPY_BITMAPTOOLS = 0 CIRCUITPY_BUSDEVICE = 0 CIRCUITPY_BUSIO = 1 +CIRCUITPY_COUNTIO = 0 CIRCUITPY_DISPLAYIO = 0 CIRCUITPY_ERRNO = 0 CIRCUITPY_FRAMEBUFFERIO = 0 @@ -24,10 +25,13 @@ CIRCUITPY_MSGPACK = 0 CIRCUITPY_NEOPIXEL_WRITE = 0 CIRCUITPY_NVM = 0 CIRCUITPY_PIXELBUF = 0 +CIRCUITPY_PULSEIO = 0 +CIRCUITPY_PWMIO = 1 CIRCUITPY_RGBMATRIX = 0 CIRCUITPY_ROTARYIO = 0 CIRCUITPY_RTC = 1 CIRCUITPY_SDCARDIO = 0 +CIRCUITPY_SYNTHIO = 0 CIRCUITPY_TOUCHIO = 0 CIRCUITPY_ULAB = 0 CIRCUITPY_USB_CDC = 0 From beb7e33db333fdb21653e81f56ae8a676120fa82 Mon Sep 17 00:00:00 2001 From: Lucian Copeland Date: Wed, 21 Apr 2021 16:34:03 -0400 Subject: [PATCH 46/67] Fix attribution and revert changes to main --- main.c | 16 ++----------- ports/nrf/common-hal/alarm/SleepMemory.c | 3 +-- ports/nrf/common-hal/alarm/SleepMemory.h | 2 +- ports/nrf/common-hal/alarm/__init__.c | 8 ++++--- ports/nrf/common-hal/alarm/__init__.h | 2 +- ports/nrf/common-hal/alarm/pin/PinAlarm.c | 3 +-- ports/nrf/common-hal/alarm/pin/PinAlarm.h | 2 +- ports/nrf/common-hal/alarm/time/TimeAlarm.c | 2 +- ports/nrf/common-hal/alarm/time/TimeAlarm.h | 2 +- ports/nrf/supervisor/debug_uart.c | 25 +++++++++++++++++++-- 10 files changed, 37 insertions(+), 28 deletions(-) diff --git a/main.c b/main.c index d16db235e8..7020ab3851 100755 --- a/main.c +++ b/main.c @@ -404,8 +404,8 @@ STATIC bool run_code_py(safe_mode_t safe_mode) { new_status_color(BLACK); board_deinit(); if (!supervisor_workflow_active()) { - // Enter deep sleep. When we wake up we'll return from - // this loop. + // Enter true deep sleep. When we wake up we'll be back at the + // top of main(), not in this loop. common_hal_alarm_enter_deep_sleep(); // Does not return. } else { @@ -426,18 +426,6 @@ STATIC bool run_code_py(safe_mode_t safe_mode) { #if CIRCUITPY_ALARM common_hal_alarm_pretending_deep_sleep(); - bool serial_in = (serial_connected() && - serial_bytes_available()); - supervisor_set_run_reason(RUN_REASON_STARTUP); - board_init(); - if (serial_in) { - bool ctrl_d = serial_read() == CHAR_CTRL_D; - if (ctrl_d) { - supervisor_set_run_reason(RUN_REASON_REPL_RELOAD); - } - return ctrl_d; - } - return true; #else port_idle_until_interrupt(); #endif diff --git a/ports/nrf/common-hal/alarm/SleepMemory.c b/ports/nrf/common-hal/alarm/SleepMemory.c index e87fcd7991..a27fb88e4c 100644 --- a/ports/nrf/common-hal/alarm/SleepMemory.c +++ b/ports/nrf/common-hal/alarm/SleepMemory.c @@ -3,8 +3,7 @@ * * The MIT License (MIT) * - * Copyright (c) 2020 microDev - * Copyright (c) 2020 Dan Halbert for Adafruit Industries + * Copyright (c) 2021 Jun2Sak * * 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/ports/nrf/common-hal/alarm/SleepMemory.h b/ports/nrf/common-hal/alarm/SleepMemory.h index 11cc4a8fb9..816f4f492b 100644 --- a/ports/nrf/common-hal/alarm/SleepMemory.h +++ b/ports/nrf/common-hal/alarm/SleepMemory.h @@ -3,7 +3,7 @@ * * The MIT License (MIT) * - * Copyright (c) 2020 Dan Halbert for Adafruit Industries + * Copyright (c) 2021 Jun2Sak * * 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/ports/nrf/common-hal/alarm/__init__.c b/ports/nrf/common-hal/alarm/__init__.c index aabb27ef25..f60a33ca4c 100644 --- a/ports/nrf/common-hal/alarm/__init__.c +++ b/ports/nrf/common-hal/alarm/__init__.c @@ -3,8 +3,7 @@ * * The MIT License (MIT) * - * Copyright (c) 2020 Scott Shawcroft for Adafruit Industries - * Copyright (c) 2020 Dan Halbert for Adafruit Industries + * Copyright (c) 2021 Jun2Sak * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -167,6 +166,9 @@ STATIC void _setup_sleep_alarms(bool deep_sleep, size_t n_alarms, const mp_obj_t alarm_touch_touchalarm_set_alarm(deep_sleep, n_alarms, alarms); } +// TODO: this handles all possible types of wakeup, which is redundant with main. +// revise to extract all parts essential to enabling sleep wakeup, but leave the +// alarm/non-alarm sorting to the existing main loop. nrf_sleep_source_t system_on_idle_until_alarm(int64_t timediff_ms, uint32_t prescaler) { bool have_timeout = false; uint64_t start_tick = 0, end_tick = 0; @@ -382,7 +384,7 @@ void common_hal_alarm_pretending_deep_sleep(void) { print_wakeup_cause(cause); #endif - alarm_reset(); + // alarm_reset(); #if 0 // if one of Alarm event occurred, reset myself diff --git a/ports/nrf/common-hal/alarm/__init__.h b/ports/nrf/common-hal/alarm/__init__.h index ce8ca5f327..2473ab64a1 100644 --- a/ports/nrf/common-hal/alarm/__init__.h +++ b/ports/nrf/common-hal/alarm/__init__.h @@ -3,7 +3,7 @@ * * The MIT License (MIT) * - * Copyright (c) 2020 Dan Halbert for Adafruit Industries. + * Copyright (c) 2021 Jun2Sak * * 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/ports/nrf/common-hal/alarm/pin/PinAlarm.c b/ports/nrf/common-hal/alarm/pin/PinAlarm.c index 89ec2ad30f..b6293ad1c5 100644 --- a/ports/nrf/common-hal/alarm/pin/PinAlarm.c +++ b/ports/nrf/common-hal/alarm/pin/PinAlarm.c @@ -3,8 +3,7 @@ * * The MIT License (MIT) * - * Copyright (c) 2020 Dan Halbert for Adafruit Industries - * Copyright (c) 2020 Scott Shawcroft for Adafruit Industries + * Copyright (c) 2021 Jun2Sak * * 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/ports/nrf/common-hal/alarm/pin/PinAlarm.h b/ports/nrf/common-hal/alarm/pin/PinAlarm.h index 93672c1f2d..0b7401669f 100644 --- a/ports/nrf/common-hal/alarm/pin/PinAlarm.h +++ b/ports/nrf/common-hal/alarm/pin/PinAlarm.h @@ -3,7 +3,7 @@ * * The MIT License (MIT) * - * Copyright (c) 2020 Dan Halbert for Adafruit Industries + * Copyright (c) 2021 Jun2Sak * * 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/ports/nrf/common-hal/alarm/time/TimeAlarm.c b/ports/nrf/common-hal/alarm/time/TimeAlarm.c index c4b06982bf..c6a79cbbc9 100644 --- a/ports/nrf/common-hal/alarm/time/TimeAlarm.c +++ b/ports/nrf/common-hal/alarm/time/TimeAlarm.c @@ -3,7 +3,7 @@ * * The MIT License (MIT) * - * Copyright (c) 2020 Dan Halbert for Adafruit Industries + * Copyright (c) 2021 Jun2Sak * * 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/ports/nrf/common-hal/alarm/time/TimeAlarm.h b/ports/nrf/common-hal/alarm/time/TimeAlarm.h index a824c52535..61938210a2 100644 --- a/ports/nrf/common-hal/alarm/time/TimeAlarm.h +++ b/ports/nrf/common-hal/alarm/time/TimeAlarm.h @@ -3,7 +3,7 @@ * * The MIT License (MIT) * - * Copyright (c) 2020 Dan Halbert for Adafruit Industries + * Copyright (c) 2021 Jun2Sak * * 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/ports/nrf/supervisor/debug_uart.c b/ports/nrf/supervisor/debug_uart.c index 420ba14b82..9cf33279f7 100644 --- a/ports/nrf/supervisor/debug_uart.c +++ b/ports/nrf/supervisor/debug_uart.c @@ -1,6 +1,27 @@ /* - * debug functions - * (will be removed) + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2021 Jun2Sak + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. */ #include From 07059dd373ccc7d58452bc23c4d4c373132b3436 Mon Sep 17 00:00:00 2001 From: James Carr Date: Fri, 23 Apr 2021 12:56:44 +0100 Subject: [PATCH 47/67] Minor docs fixes in displayio.Bitmap --- shared-bindings/displayio/Bitmap.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/shared-bindings/displayio/Bitmap.c b/shared-bindings/displayio/Bitmap.c index 900428b6e4..db9b430ba7 100644 --- a/shared-bindings/displayio/Bitmap.c +++ b/shared-bindings/displayio/Bitmap.c @@ -45,11 +45,11 @@ //| the bitmap data is packed into the memoryview with unspecified padding. //| //| A Bitmap can be treated as a buffer, allowing its content to be -//| viewed and modified using e.g., with ``ulab.numpy.frombuffer``, +//| viewed and modified using e.g., with `ulab.numpy.frombuffer`, //| but the `displayio.Bitmap.dirty` method must be used to inform //| displayio when a bitmap was modified through the buffer interface. //| -//| `bitmaptools.arrayblit` can also be useful to omve data efficiently +//| `bitmaptools.arrayblit` can also be useful to move data efficiently //| into a Bitmap. //| """ //| @@ -125,7 +125,7 @@ const mp_obj_property_t displayio_bitmap_height_obj = { //| def __getitem__(self, index: Union[Tuple[int, int], int]) -> int: //| """Returns the value at the given index. The index can either be an x,y tuple or an int equal -//| to ``y * width + x``. +//| to `y * width + x`. //| //| This allows you to:: //| @@ -134,7 +134,7 @@ const mp_obj_property_t displayio_bitmap_height_obj = { //| //| def __setitem__(self, index: Union[Tuple[int, int], int], value: int) -> None: //| """Sets the value at the given index. The index can either be an x,y tuple or an int equal -//| to ``y * width + x``. +//| to `y * width + x`. //| //| This allows you to:: //| From 0be610fd2bce8465ad5ab25ce0bf3723673374fa Mon Sep 17 00:00:00 2001 From: James Carr Date: Fri, 23 Apr 2021 14:41:47 +0100 Subject: [PATCH 48/67] Changes as requested for Bitmap docs. --- shared-bindings/displayio/Bitmap.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/shared-bindings/displayio/Bitmap.c b/shared-bindings/displayio/Bitmap.c index db9b430ba7..f85666cae6 100644 --- a/shared-bindings/displayio/Bitmap.c +++ b/shared-bindings/displayio/Bitmap.c @@ -45,7 +45,7 @@ //| the bitmap data is packed into the memoryview with unspecified padding. //| //| A Bitmap can be treated as a buffer, allowing its content to be -//| viewed and modified using e.g., with `ulab.numpy.frombuffer`, +//| viewed and modified using e.g., with ``ulab.numpy.frombuffer``, //| but the `displayio.Bitmap.dirty` method must be used to inform //| displayio when a bitmap was modified through the buffer interface. //| @@ -125,7 +125,7 @@ const mp_obj_property_t displayio_bitmap_height_obj = { //| def __getitem__(self, index: Union[Tuple[int, int], int]) -> int: //| """Returns the value at the given index. The index can either be an x,y tuple or an int equal -//| to `y * width + x`. +//| to ``y * width + x``. //| //| This allows you to:: //| @@ -134,7 +134,7 @@ const mp_obj_property_t displayio_bitmap_height_obj = { //| //| def __setitem__(self, index: Union[Tuple[int, int], int], value: int) -> None: //| """Sets the value at the given index. The index can either be an x,y tuple or an int equal -//| to `y * width + x`. +//| to ``y * width + x``. //| //| This allows you to:: //| From 901e6ab5b031493ce79c6a9f23da9bb8644f9e10 Mon Sep 17 00:00:00 2001 From: jposada202020 Date: Fri, 23 Apr 2021 10:02:24 -0400 Subject: [PATCH 49/67] Referencing_documentation_other_libraries --- docs/design_guide.rst | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/docs/design_guide.rst b/docs/design_guide.rst index 1bac4df61b..5bd6bbd387 100644 --- a/docs/design_guide.rst +++ b/docs/design_guide.rst @@ -383,6 +383,14 @@ Renders as: :param float degrees: Degrees to turn right +Documentation References to other Libraries +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +When you need to make references to documentation in other libraries you should refer the class using single +backticks ``:class:`~adafruit_motor.servo.Servo```. You must add also the reference in the ``conf.py`` file in the +``intersphinx_mapping section`` adding a new entry:: + + "adafruit_motor": ("https://circuitpython.readthedocs.io/projects/motor/en/latest/", None,), + Use BusDevice -------------------------------------------------------------------------------- From a17fcb6d1ab05ff2e6a984e992462130c17812fc Mon Sep 17 00:00:00 2001 From: jun2sak Date: Sun, 25 Apr 2021 19:19:11 +0900 Subject: [PATCH 51/67] add copyright notice. remove obsolete comments. --- ports/nrf/common-hal/alarm/__init__.c | 19 ++++++------------- ports/nrf/common-hal/alarm/__init__.h | 1 + ports/nrf/common-hal/alarm/pin/PinAlarm.c | 1 + ports/nrf/common-hal/alarm/time/TimeAlarm.c | 4 +--- ports/nrf/supervisor/port.c | 1 + supervisor/shared/serial.c | 6 +++--- 6 files changed, 13 insertions(+), 19 deletions(-) diff --git a/ports/nrf/common-hal/alarm/__init__.c b/ports/nrf/common-hal/alarm/__init__.c index c8180fb2e0..f678b5f22b 100644 --- a/ports/nrf/common-hal/alarm/__init__.c +++ b/ports/nrf/common-hal/alarm/__init__.c @@ -5,6 +5,7 @@ * * Copyright (c) 2020 Scott Shawcroft for Adafruit Industries * Copyright (c) 2020 Dan Halbert for Adafruit Industries + * Copyright (c) 2021 Junji Sakai * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -119,11 +120,6 @@ bool common_hal_alarm_woken_from_sleep(void) { nrf_sleep_source_t alarm_woken_from_sleep_2(void) { nrf_sleep_source_t cause = _get_wakeup_cause(); -#ifdef NRF_DEBUG_PRINT - if (cause != NRF_SLEEP_WAKEUP_UNDEFINED) { - //print_wakeup_cause(cause); - } -#endif if (cause == NRF_SLEEP_WAKEUP_GPIO || cause == NRF_SLEEP_WAKEUP_TIMER || cause == NRF_SLEEP_WAKEUP_TOUCHPAD) { @@ -136,9 +132,6 @@ nrf_sleep_source_t alarm_woken_from_sleep_2(void) { STATIC mp_obj_t _get_wake_alarm(size_t n_alarms, const mp_obj_t *alarms) { nrf_sleep_source_t cause = _get_wakeup_cause(); -#ifdef NRF_DEBUG_PRINT - //print_wakeup_cause(cause); -#endif switch (cause) { case NRF_SLEEP_WAKEUP_TIMER: { return alarm_time_timealarm_get_wakeup_alarm(n_alarms, alarms); @@ -264,16 +257,16 @@ nrf_sleep_source_t system_on_idle_until_alarm(int64_t timediff_ms, uint32_t pres qspi_flash_exit_sleep(); #endif +#ifdef NRF_DEBUG_PRINT tickdiff = port_get_raw_ticks(NULL) - start_tick; + double sec; if (prescaler == 0) { - timediff_ms = tickdiff / 1024; + sec = (double)tickdiff / 1024; } else { - timediff_ms = tickdiff * prescaler / 1024; + sec = (double)(tickdiff * prescaler) / 1024; } - (void)timediff_ms; -#ifdef NRF_DEBUG_PRINT - dbg_printf("lapse %6.1f sec\r\n", (double)(timediff_ms)); + dbg_printf("lapse %6.1f sec\r\n", sec); #endif return wakeup_cause; diff --git a/ports/nrf/common-hal/alarm/__init__.h b/ports/nrf/common-hal/alarm/__init__.h index 7df3aaf4c3..642fb7d93a 100644 --- a/ports/nrf/common-hal/alarm/__init__.h +++ b/ports/nrf/common-hal/alarm/__init__.h @@ -4,6 +4,7 @@ * The MIT License (MIT) * * Copyright (c) 2020 Dan Halbert for Adafruit Industries. + * Copyright (c) 2021 Junji Sakai * * 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/ports/nrf/common-hal/alarm/pin/PinAlarm.c b/ports/nrf/common-hal/alarm/pin/PinAlarm.c index 1f00dc0c33..fcfd02f84c 100644 --- a/ports/nrf/common-hal/alarm/pin/PinAlarm.c +++ b/ports/nrf/common-hal/alarm/pin/PinAlarm.c @@ -5,6 +5,7 @@ * * Copyright (c) 2020 Dan Halbert for Adafruit Industries * Copyright (c) 2020 Scott Shawcroft for Adafruit Industries + * Copyright (c) 2021 Junji Sakai * * 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/ports/nrf/common-hal/alarm/time/TimeAlarm.c b/ports/nrf/common-hal/alarm/time/TimeAlarm.c index c4b06982bf..09409e7ce4 100644 --- a/ports/nrf/common-hal/alarm/time/TimeAlarm.c +++ b/ports/nrf/common-hal/alarm/time/TimeAlarm.c @@ -4,6 +4,7 @@ * The MIT License (MIT) * * Copyright (c) 2020 Dan Halbert for Adafruit Industries + * Copyright (c) 2021 Junji Sakai * * 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,10 +25,7 @@ * THE SOFTWARE. */ -//#include "esp_sleep.h" - #include "py/runtime.h" -//#include "supervisor/esp_port.h" #include #include "common-hal/alarm/__init__.h" diff --git a/ports/nrf/supervisor/port.c b/ports/nrf/supervisor/port.c index 5cad994c0d..c984feb77d 100644 --- a/ports/nrf/supervisor/port.c +++ b/ports/nrf/supervisor/port.c @@ -4,6 +4,7 @@ * The MIT License (MIT) * * Copyright (c) 2017 Scott Shawcroft for Adafruit Industries + * Copyright (c) 2021 Junji Sakai * * 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/supervisor/shared/serial.c b/supervisor/shared/serial.c index 41bb200afc..c73d702c9c 100644 --- a/supervisor/shared/serial.c +++ b/supervisor/shared/serial.c @@ -39,7 +39,7 @@ #ifdef NRF_DEBUG_PRINT // XXX these functions are in nrf/supervisor/debug_uart.c extern void _debug_uart_init(void); -extern void _debug_print_substr(const char* text, uint32_t length); +extern void _debug_print_substr(const char *text, uint32_t length); #endif /* @@ -71,7 +71,7 @@ void serial_early_init(void) { #endif #ifdef NRF_DEBUG_PRINT - _debug_uart_init(); + _debug_uart_init(); #endif } @@ -155,7 +155,7 @@ void serial_write_substring(const char *text, uint32_t length) { #if defined(DEBUG_UART_TX) && defined(DEBUG_UART_RX) int uart_errcode; - common_hal_busio_uart_write(&debug_uart, (const uint8_t*) text, length, &uart_errcode); + common_hal_busio_uart_write(&debug_uart, (const uint8_t *) text, length, &uart_errcode); #endif #ifdef NRF_DEBUG_PRINT From 7accb8b173ce97979e466bf3d2dc1e7f56300332 Mon Sep 17 00:00:00 2001 From: jun2sak Date: Sun, 25 Apr 2021 19:57:21 +0900 Subject: [PATCH 52/67] modify copyright notice. --- .github/workflows/build.yml | 19 +- .github/workflows/match-build-fail.json | 14 ++ .gitmodules | 6 + conf.py | 2 + .../common-hal/_bleio/Characteristic.c | 4 + .../ble_hci/common-hal/_bleio/PacketBuffer.c | 16 +- .../ble_hci/common-hal/_bleio/PacketBuffer.h | 1 + docs/static/filter.css | 17 ++ docs/static/filter.js | 86 +++++++ frozen/Adafruit_CircuitPython_MIDI | 1 + frozen/Adafruit_CircuitPython_SimpleMath | 1 + lib/protomatter | 2 +- locale/ID.po | 74 +++--- locale/circuitpython.pot | 66 +++--- locale/cs.po | 59 +++-- locale/de_DE.po | 81 ++++--- locale/el.po | 59 +++-- locale/en_GB.po | 95 +++++--- locale/es.po | 97 +++++--- locale/fil.po | 62 ++--- locale/fr.po | 169 ++++++++------ locale/hi.po | 59 +++-- locale/it_IT.po | 64 +++--- locale/ja.po | 73 +++--- locale/ko.po | 59 +++-- locale/nl.po | 85 ++++--- locale/pl.po | 75 ++++--- locale/pt_BR.po | 92 +++++--- locale/sv.po | 89 +++++--- locale/zh_Latn_pinyin.po | 103 +++++---- main.c | 18 +- .../board.c | 0 .../mpconfigboard.h | 58 +++++ .../mpconfigboard.mk | 34 +++ .../boards/adafruit_neokey_trinkey_m0/pins.c | 8 + .../adafruit_proxlight_trinkey_m0/board.c | 40 ++++ .../mpconfigboard.h | 58 +++++ .../mpconfigboard.mk | 33 +++ .../adafruit_proxlight_trinkey_m0/pins.c | 15 ++ .../boards/adafruit_rotary_trinkey_m0/board.c | 40 ++++ .../mpconfigboard.h | 0 .../mpconfigboard.mk | 2 +- .../pins.c | 0 .../boards/adafruit_slide_trinkey_m0/board.c | 40 ++++ .../adafruit_slide_trinkey_m0/mpconfigboard.h | 58 +++++ .../mpconfigboard.mk | 35 +++ .../boards/adafruit_slide_trinkey_m0/pins.c | 8 + .../feather_m0_adalogger/mpconfigboard.h | 4 +- .../neopixel_trinkey_m0/mpconfigboard.mk | 2 +- ports/atmel-samd/boards/sensebox_mcu/board.c | 39 ++++ .../boards/sensebox_mcu/mpconfigboard.h | 24 ++ .../boards/sensebox_mcu/mpconfigboard.mk | 14 ++ ports/atmel-samd/boards/sensebox_mcu/pins.c | 71 ++++++ ports/atmel-samd/mpconfigport.mk | 20 ++ .../esp32s2/boards/atmegazero_esp32s2/board.c | 61 +++++ .../boards/atmegazero_esp32s2/mpconfigboard.h | 47 ++++ .../atmegazero_esp32s2/mpconfigboard.mk | 15 ++ .../esp32s2/boards/atmegazero_esp32s2/pins.c | 80 +++++++ .../boards/atmegazero_esp32s2/sdkconfig | 39 ++++ ports/nrf/boards/aramcon2_badge/board.c | 40 ++++ .../nrf/boards/aramcon2_badge/mpconfigboard.h | 68 ++++++ .../boards/aramcon2_badge/mpconfigboard.mk | 11 + ports/nrf/boards/aramcon2_badge/pins.c | 42 ++++ ports/nrf/boards/pca10100/mpconfigboard.mk | 1 + ports/nrf/boards/simmel/mpconfigboard.mk | 5 + ports/nrf/common-hal/_bleio/Characteristic.c | 4 + ports/nrf/common-hal/_bleio/PacketBuffer.c | 34 ++- ports/nrf/common-hal/_bleio/PacketBuffer.h | 1 + ports/nrf/common-hal/alarm/SleepMemory.c | 25 +-- ports/nrf/common-hal/alarm/SleepMemory.h | 2 +- ports/nrf/common-hal/alarm/__init__.c | 111 ++++----- ports/nrf/common-hal/alarm/__init__.h | 14 +- ports/nrf/common-hal/alarm/pin/PinAlarm.c | 26 +-- ports/nrf/common-hal/alarm/pin/PinAlarm.h | 2 +- ports/nrf/common-hal/alarm/time/TimeAlarm.h | 2 +- .../common-hal/microcontroller/Processor.c | 6 +- ports/nrf/mpconfigport.mk | 2 +- ports/nrf/supervisor/debug_uart.c | 129 ++++++----- ports/nrf/supervisor/port.c | 4 + ports/nrf/supervisor/qspi_flash.c | 24 +- .../boards/pimoroni_picolipo_16mb/board.c | 37 +++ .../pimoroni_picolipo_16mb/mpconfigboard.h | 10 + .../pimoroni_picolipo_16mb/mpconfigboard.mk | 11 + .../boards/pimoroni_picolipo_16mb/pins.c | 52 +++++ .../boards/pimoroni_picolipo_4mb/board.c | 37 +++ .../pimoroni_picolipo_4mb/mpconfigboard.h | 10 + .../pimoroni_picolipo_4mb/mpconfigboard.mk | 11 + .../boards/pimoroni_picolipo_4mb/pins.c | 52 +++++ .../boards/raspberry_pi_pico/pins.c | 10 + .../boards/sparkfun_micromod_rp2040/board.c | 40 ++++ .../sparkfun_micromod_rp2040/mpconfigboard.h | 12 + .../sparkfun_micromod_rp2040/mpconfigboard.mk | 9 + .../boards/sparkfun_micromod_rp2040/pins.c | 105 +++++++++ ports/raspberrypi/mpconfigport.mk | 3 +- .../mpconfigboard.mk | 2 + py/binary.c | 6 +- py/circuitpy_defns.mk | 5 + py/circuitpy_mpconfig.h | 8 + py/circuitpy_mpconfig.mk | 3 + py/compile.c | 2 +- py/makeqstrdata.py | 50 ++--- py/modstruct.c | 6 +- py/mpstate.h | 2 +- py/qstr.c | 130 ++++++----- py/qstr.h | 20 +- py/repl.c | 13 +- shared-bindings/_bleio/Characteristic.c | 17 ++ shared-bindings/_bleio/Characteristic.h | 1 + shared-bindings/_bleio/PacketBuffer.c | 20 +- shared-bindings/_bleio/PacketBuffer.h | 2 +- shared-bindings/_typing/__init__.pyi | 3 +- shared-bindings/audiocore/RawSample.c | 26 +-- shared-bindings/audiocore/RawSample.h | 1 - shared-bindings/audiocore/WaveFile.c | 2 +- shared-bindings/support_matrix.rst | 5 + shared-bindings/synthio/MidiTrack.c | 169 ++++++++++++++ shared-bindings/synthio/MidiTrack.h | 43 ++++ shared-bindings/synthio/__init__.c | 136 +++++++++++ shared-bindings/synthio/__init__.h | 34 +++ shared-module/audiomixer/Mixer.c | 45 ++++ shared-module/struct/__init__.c | 6 +- shared-module/synthio/MidiTrack.c | 212 ++++++++++++++++++ shared-module/synthio/MidiTrack.h | 65 ++++++ shared-module/synthio/__init__.c | 0 shared-module/synthio/__init__.h | 32 +++ supervisor/shared/cpu.c | 40 ++++ supervisor/shared/cpu.h | 36 +++ supervisor/shared/safe_mode.c | 6 +- supervisor/shared/serial.c | 11 +- supervisor/shared/translate.c | 2 +- supervisor/supervisor.mk | 1 + tests/basics/struct1.py | 2 + .../audiocore/single-track.midi | Bin 0 -> 5123 bytes tools/build_board_info.py | 2 +- tools/mpy-tool.py | 27 ++- 135 files changed, 3646 insertions(+), 992 deletions(-) create mode 100644 .github/workflows/match-build-fail.json create mode 100644 docs/static/filter.css create mode 100644 docs/static/filter.js create mode 160000 frozen/Adafruit_CircuitPython_MIDI create mode 160000 frozen/Adafruit_CircuitPython_SimpleMath rename ports/atmel-samd/boards/{rotary_trinkey_m0 => adafruit_neokey_trinkey_m0}/board.c (100%) create mode 100644 ports/atmel-samd/boards/adafruit_neokey_trinkey_m0/mpconfigboard.h create mode 100644 ports/atmel-samd/boards/adafruit_neokey_trinkey_m0/mpconfigboard.mk create mode 100644 ports/atmel-samd/boards/adafruit_neokey_trinkey_m0/pins.c create mode 100644 ports/atmel-samd/boards/adafruit_proxlight_trinkey_m0/board.c create mode 100644 ports/atmel-samd/boards/adafruit_proxlight_trinkey_m0/mpconfigboard.h create mode 100644 ports/atmel-samd/boards/adafruit_proxlight_trinkey_m0/mpconfigboard.mk create mode 100644 ports/atmel-samd/boards/adafruit_proxlight_trinkey_m0/pins.c create mode 100644 ports/atmel-samd/boards/adafruit_rotary_trinkey_m0/board.c rename ports/atmel-samd/boards/{rotary_trinkey_m0 => adafruit_rotary_trinkey_m0}/mpconfigboard.h (100%) rename ports/atmel-samd/boards/{rotary_trinkey_m0 => adafruit_rotary_trinkey_m0}/mpconfigboard.mk (97%) rename ports/atmel-samd/boards/{rotary_trinkey_m0 => adafruit_rotary_trinkey_m0}/pins.c (100%) create mode 100644 ports/atmel-samd/boards/adafruit_slide_trinkey_m0/board.c create mode 100644 ports/atmel-samd/boards/adafruit_slide_trinkey_m0/mpconfigboard.h create mode 100644 ports/atmel-samd/boards/adafruit_slide_trinkey_m0/mpconfigboard.mk create mode 100644 ports/atmel-samd/boards/adafruit_slide_trinkey_m0/pins.c create mode 100644 ports/atmel-samd/boards/sensebox_mcu/board.c create mode 100644 ports/atmel-samd/boards/sensebox_mcu/mpconfigboard.h create mode 100644 ports/atmel-samd/boards/sensebox_mcu/mpconfigboard.mk create mode 100644 ports/atmel-samd/boards/sensebox_mcu/pins.c create mode 100644 ports/esp32s2/boards/atmegazero_esp32s2/board.c create mode 100644 ports/esp32s2/boards/atmegazero_esp32s2/mpconfigboard.h create mode 100644 ports/esp32s2/boards/atmegazero_esp32s2/mpconfigboard.mk create mode 100644 ports/esp32s2/boards/atmegazero_esp32s2/pins.c create mode 100644 ports/esp32s2/boards/atmegazero_esp32s2/sdkconfig create mode 100644 ports/nrf/boards/aramcon2_badge/board.c create mode 100644 ports/nrf/boards/aramcon2_badge/mpconfigboard.h create mode 100644 ports/nrf/boards/aramcon2_badge/mpconfigboard.mk create mode 100644 ports/nrf/boards/aramcon2_badge/pins.c create mode 100644 ports/raspberrypi/boards/pimoroni_picolipo_16mb/board.c create mode 100644 ports/raspberrypi/boards/pimoroni_picolipo_16mb/mpconfigboard.h create mode 100644 ports/raspberrypi/boards/pimoroni_picolipo_16mb/mpconfigboard.mk create mode 100644 ports/raspberrypi/boards/pimoroni_picolipo_16mb/pins.c create mode 100644 ports/raspberrypi/boards/pimoroni_picolipo_4mb/board.c create mode 100644 ports/raspberrypi/boards/pimoroni_picolipo_4mb/mpconfigboard.h create mode 100644 ports/raspberrypi/boards/pimoroni_picolipo_4mb/mpconfigboard.mk create mode 100644 ports/raspberrypi/boards/pimoroni_picolipo_4mb/pins.c create mode 100644 ports/raspberrypi/boards/sparkfun_micromod_rp2040/board.c create mode 100644 ports/raspberrypi/boards/sparkfun_micromod_rp2040/mpconfigboard.h create mode 100644 ports/raspberrypi/boards/sparkfun_micromod_rp2040/mpconfigboard.mk create mode 100644 ports/raspberrypi/boards/sparkfun_micromod_rp2040/pins.c create mode 100644 shared-bindings/synthio/MidiTrack.c create mode 100644 shared-bindings/synthio/MidiTrack.h create mode 100644 shared-bindings/synthio/__init__.c create mode 100644 shared-bindings/synthio/__init__.h create mode 100644 shared-module/synthio/MidiTrack.c create mode 100644 shared-module/synthio/MidiTrack.h create mode 100644 shared-module/synthio/__init__.c create mode 100644 shared-module/synthio/__init__.h create mode 100644 supervisor/shared/cpu.c create mode 100644 supervisor/shared/cpu.h create mode 100755 tests/circuitpython-manual/audiocore/single-track.midi diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index dce5388211..6d58085929 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -178,8 +178,13 @@ jobs: - "TG-Watch" - "adafruit_feather_rp2040" - "adafruit_itsybitsy_rp2040" + - "adafruit_neokey_trinkey_m0" + - "adafruit_proxlight_trinkey_m0" - "adafruit_qtpy_rp2040" + - "adafruit_rotary_trinkey_m0" + - "adafruit_slide_trinkey_m0" - "aloriumtech_evo_m51" + - "aramcon2_badge" - "aramcon_badge_2019" - "arduino_mkr1300" - "arduino_mkrzero" @@ -285,6 +290,8 @@ jobs: - "pewpew_m4" - "picoplanet" - "pimoroni_keybow2040" + - "pimoroni_picolipo_16mb" + - "pimoroni_picolipo_4mb" - "pimoroni_picosystem" - "pimoroni_tiny2040" - "pirkey_m0" @@ -305,17 +312,18 @@ jobs: - "raspberry_pi_pico" - "raytac_mdbt50q-db-40" - "robohatmm1_m4" - - "rotary_trinkey_m0" - "sam32" - "same54_xplained" - "seeeduino_wio_terminal" - "seeeduino_xiao" + - "sensebox_mcu" - "serpente" - "shirtty" - "silicognition-m4-shim" - "simmel" - "snekboard" - "sparkfun_lumidrive" + - "sparkfun_micromod_rp2040" - "sparkfun_nrf52840_micromod" - "sparkfun_nrf52840_mini" - "sparkfun_pro_micro_rp2040" @@ -375,6 +383,8 @@ jobs: python3 --version - name: mpy-cross run: make -C mpy-cross -j2 + - name: Setup build failure matcher + run: echo "::add-matcher::$GITHUB_WORKSPACE/.github/workflows/match-build-fail.json" - name: build run: python3 -u build_release_files.py working-directory: tools @@ -424,6 +434,8 @@ jobs: python3 --version - name: mpy-cross run: make -C mpy-cross -j2 + - name: Setup build failure matcher + run: echo "::add-matcher::$GITHUB_WORKSPACE/.github/workflows/match-build-fail.json" - name: build run: python3 -u build_release_files.py working-directory: tools @@ -453,6 +465,7 @@ jobs: - "adafruit_magtag_2.9_grayscale" - "adafruit_metro_esp32s2" - "artisense_rd00" + - "atmegazero_esp32s2" - "electroniccats_bastwifi" - "espressif_kaluga_1" - "espressif_saola_1_wroom" @@ -485,7 +498,7 @@ jobs: id: idf-cache with: path: ${{ github.workspace }}/.idf_tools - key: ${{ runner.os }}-idf-tools-${{ hashFiles('.git/modules/ports/esp32s2/esp-idf/HEAD') }}-20210304 + key: ${{ runner.os }}-idf-tools-${{ hashFiles('.git/modules/ports/esp32s2/esp-idf/HEAD') }}-20210415 - name: Clone IDF submodules run: | (cd $IDF_PATH && git submodule update --init) @@ -522,6 +535,8 @@ jobs: IDF_TOOLS_PATH: ${{ github.workspace }}/.idf_tools - name: mpy-cross run: make -C mpy-cross -j2 + - name: Setup build failure matcher + run: echo "::add-matcher::$GITHUB_WORKSPACE/.github/workflows/match-build-fail.json" - name: build run: | source $IDF_PATH/export.sh diff --git a/.github/workflows/match-build-fail.json b/.github/workflows/match-build-fail.json new file mode 100644 index 0000000000..938c484f26 --- /dev/null +++ b/.github/workflows/match-build-fail.json @@ -0,0 +1,14 @@ +{ + "problemMatcher": [ + { + "severity": "error", + "pattern": [ + { + "regexp": "^(Build .+ and \\x1b\\[31mfailed\\x1b\\[0m)$", + "message": 1 + } + ], + "owner": "build-failed" + } + ] +} diff --git a/.gitmodules b/.gitmodules index 52abb02a99..da5b5835a6 100644 --- a/.gitmodules +++ b/.gitmodules @@ -171,6 +171,9 @@ [submodule "frozen/Adafruit_CircuitPython_LC709203F"] path = frozen/Adafruit_CircuitPython_LC709203F url = https://github.com/adafruit/Adafruit_CircuitPython_LC709203F +[submodule "frozen/Adafruit_CircuitPython_SimpleMath"] + path = frozen/Adafruit_CircuitPython_SimpleMath + url = https://github.com/adafruit/Adafruit_CircuitPython_SimpleMath [submodule "ports/raspberrypi/sdk"] path = ports/raspberrypi/sdk url = https://github.com/adafruit/pico-sdk.git @@ -178,3 +181,6 @@ path = data/nvm.toml url = https://github.com/adafruit/nvm.toml.git branch = main +[submodule "frozen/Adafruit_CircuitPython_MIDI"] + path = frozen/Adafruit_CircuitPython_MIDI + url = https://github.com/adafruit/Adafruit_CircuitPython_MIDI diff --git a/conf.py b/conf.py index 44f86f6361..2625ad63c1 100644 --- a/conf.py +++ b/conf.py @@ -489,6 +489,8 @@ class CoreModuleTransform(SphinxTransform): def setup(app): app.add_css_file("customstyle.css") + app.add_css_file("filter.css") + app.add_js_file("filter.js") app.add_config_value('redirects_file', 'redirects', 'env') app.connect('builder-inited', generate_redirects) app.add_transform(CoreModuleTransform) diff --git a/devices/ble_hci/common-hal/_bleio/Characteristic.c b/devices/ble_hci/common-hal/_bleio/Characteristic.c index 7255661576..db1317f4c8 100644 --- a/devices/ble_hci/common-hal/_bleio/Characteristic.c +++ b/devices/ble_hci/common-hal/_bleio/Characteristic.c @@ -78,6 +78,10 @@ bleio_service_obj_t *common_hal_bleio_characteristic_get_service(bleio_character return self->service; } +size_t common_hal_bleio_characteristic_get_max_length(bleio_characteristic_obj_t *self) { + return self->max_length; +} + size_t common_hal_bleio_characteristic_get_value(bleio_characteristic_obj_t *self, uint8_t *buf, size_t len) { // Do GATT operations only if this characteristic has been added to a registered service. if (self->handle != BLE_GATT_HANDLE_INVALID) { diff --git a/devices/ble_hci/common-hal/_bleio/PacketBuffer.c b/devices/ble_hci/common-hal/_bleio/PacketBuffer.c index 9d8a21601d..cb14f4044b 100644 --- a/devices/ble_hci/common-hal/_bleio/PacketBuffer.c +++ b/devices/ble_hci/common-hal/_bleio/PacketBuffer.c @@ -81,7 +81,7 @@ void bleio_packet_buffer_update(bleio_packet_buffer_obj_t *self, mp_buffer_info_ void common_hal_bleio_packet_buffer_construct( bleio_packet_buffer_obj_t *self, bleio_characteristic_obj_t *characteristic, - size_t buffer_size) { + size_t buffer_size, size_t max_packet_size) { self->characteristic = characteristic; self->client = self->characteristic->service->is_remote; @@ -101,7 +101,7 @@ void common_hal_bleio_packet_buffer_construct( } if (incoming) { - if (!ringbuf_alloc(&self->ringbuf, buffer_size * (sizeof(uint16_t) + characteristic->max_length), false)) { + if (!ringbuf_alloc(&self->ringbuf, buffer_size * (sizeof(uint16_t) + max_packet_size), false)) { mp_raise_ValueError(translate("Buffer too large and unable to allocate")); } } @@ -110,12 +110,13 @@ void common_hal_bleio_packet_buffer_construct( self->packet_queued = false; self->pending_index = 0; self->pending_size = 0; - self->outgoing[0] = m_malloc(characteristic->max_length, false); - self->outgoing[1] = m_malloc(characteristic->max_length, false); + self->outgoing[0] = m_malloc(max_packet_size, false); + self->outgoing[1] = m_malloc(max_packet_size, false); } else { self->outgoing[0] = NULL; self->outgoing[1] = NULL; } + self->max_packet_size = max_packet_size; bleio_characteristic_set_observer(self->characteristic, self); } @@ -243,15 +244,16 @@ mp_int_t common_hal_bleio_packet_buffer_get_outgoing_packet_length(bleio_packet_ if (self->conn_handle != BLE_CONN_HANDLE_INVALID) { bleio_connection_internal_t *connection = bleio_conn_handle_to_connection(self->conn_handle); if (connection) { - return MIN(common_hal_bleio_connection_get_max_packet_length(connection), - self->characteristic->max_length); + return MIN(MIN(common_hal_bleio_connection_get_max_packet_length(connection), + self->max_packet_size), + self->characteristic->max_length); } } // There's no current connection, so we don't know the MTU, and // we can't tell what the largest outgoing packet length would be. return -1; } - return self->characteristic->max_length; + return MIN(self->characteristic->max_length, self->max_packet_size); } bool common_hal_bleio_packet_buffer_deinited(bleio_packet_buffer_obj_t *self) { diff --git a/devices/ble_hci/common-hal/_bleio/PacketBuffer.h b/devices/ble_hci/common-hal/_bleio/PacketBuffer.h index 7f351929d5..34471741fe 100644 --- a/devices/ble_hci/common-hal/_bleio/PacketBuffer.h +++ b/devices/ble_hci/common-hal/_bleio/PacketBuffer.h @@ -42,6 +42,7 @@ typedef struct { // We remember the conn_handle so we can do a NOTIFY/INDICATE to a client. // We can find out the conn_handle on a Characteristic write or a CCCD write (but not a read). volatile uint16_t conn_handle; + uint16_t max_packet_size; uint8_t pending_index; uint8_t write_type; bool client; diff --git a/docs/static/filter.css b/docs/static/filter.css new file mode 100644 index 0000000000..12efe14a40 --- /dev/null +++ b/docs/static/filter.css @@ -0,0 +1,17 @@ +#support-matrix-filter-block { position: relative; } +#support-matrix-filter { + width: 100%; +} +#support-matrix-filter-num { + position: absolute; + right: 10px; + top: 4px; +} +.support-matrix-table .this_module code, +.support-matrix-table .this_module span { + background: black; + color: white; +} +.support-matrix-table .board_hidden { + display: none; +} diff --git a/docs/static/filter.js b/docs/static/filter.js new file mode 100644 index 0000000000..9dc46a9eed --- /dev/null +++ b/docs/static/filter.js @@ -0,0 +1,86 @@ +$(() => { + var urlTimeout = null; + function setURL(query, value) { + clearTimeout(urlTimeout); + + urlTimeout = setTimeout(function() { + var url = new URL(window.location.href); + console.log(query,value,value.length,!value.length); + if (!value.length) { + console.log + url.searchParams.delete(query); + } else if (Array.isArray(value)) { + url.searchParams.delete(query); + value.forEach(function(v) { + url.searchParams.append(query, v); + }) + } else { + url.searchParams.set(query, value); + } + + window.history.pushState(null, document.title, url.href); + }, 1000); + } + + function handlePageLoad() { + var url = new URL(window.location.href); + //get values from URL + var filters = url.searchParams.getAll('filter'); + search_terms = filters.join(" "); + $("#support-matrix-filter").val(search_terms); + run_filter(); + } + + function filter_boards(search_string) { + $(".board_hidden").removeClass("board_hidden"); + $(".this_module").removeClass("this_module"); + var nboards = $(".support-matrix-table tbody tr").length; + if(search_string.trim() == "") { + $("#support-matrix-filter-num").html("(all)"); + setURL("filter",[]); + return; + } + var list_search = search_string.split(" ").filter(i => i); + var nvisible = 0; + $(".support-matrix-table tbody tr").each( (index,item) => { + var name = $(item).find("td:first-child p").html(); + var modules = $(item).find("a.reference.internal"); + var matching_all = true; + // + list_search.forEach((sstring) => { + var matching = (sstring[0] == "-"); + for(var modi = 0; modi < modules.length; ++modi) { + module = modules[modi]; + var mod_name = module.firstChild.firstChild.textContent; + if(sstring[0] == "-") { + if(mod_name.match(sstring.substr(1))) { + matching = false; + break; + } + } else { + if(mod_name.match(sstring)) { + $(module).addClass("this_module"); + matching = true; + } + } + } + matching_all = matching_all && matching; + }); + if(!matching_all) { + $(item).addClass("board_hidden"); + } else { + nvisible += 1; + } + }); + $("#support-matrix-filter-num").html(`(${nvisible}/${nboards})`); + setURL("filter",list_search); + } + + function run_filter() { + var search_string = $("#support-matrix-filter").val(); + filter_boards(search_string); + } + $("#support-matrix-filter").on("keyup", run_filter); + // $(document).on("keyup", "#support-matrix-filter", run_filter); + handlePageLoad(); +}); diff --git a/frozen/Adafruit_CircuitPython_MIDI b/frozen/Adafruit_CircuitPython_MIDI new file mode 160000 index 0000000000..669ab7b752 --- /dev/null +++ b/frozen/Adafruit_CircuitPython_MIDI @@ -0,0 +1 @@ +Subproject commit 669ab7b752d6c863577312560faf505656e5e603 diff --git a/frozen/Adafruit_CircuitPython_SimpleMath b/frozen/Adafruit_CircuitPython_SimpleMath new file mode 160000 index 0000000000..cdf9944730 --- /dev/null +++ b/frozen/Adafruit_CircuitPython_SimpleMath @@ -0,0 +1 @@ +Subproject commit cdf99447307473080b2f2e95e7c3667247095ac0 diff --git a/lib/protomatter b/lib/protomatter index c2c81ded11..98017c5734 160000 --- a/lib/protomatter +++ b/lib/protomatter @@ -1 +1 @@ -Subproject commit c2c81ded118484f8925bf81e270b416739cd72d9 +Subproject commit 98017c57349e259fab70c6a7830436b19a55f6f4 diff --git a/locale/ID.po b/locale/ID.po index ad5700cb99..ea16feddb8 100644 --- a/locale/ID.po +++ b/locale/ID.po @@ -445,8 +445,8 @@ msgid "Attempt to allocate %d blocks" msgstr "" #: supervisor/shared/safe_mode.c -msgid "Attempted heap allocation when MicroPython VM not running." -msgstr "Mencoba alokasi heap ketika MicroPython VM tidak berjalan." +msgid "Attempted heap allocation when VM not running." +msgstr "" #: shared-bindings/wifi/Radio.c msgid "Authentication failure" @@ -899,6 +899,11 @@ msgstr "" msgid "EXTINT channel already in use" msgstr "Channel EXTINT sedang digunakan" +#: shared-module/synthio/MidiTrack.c +#, c-format +msgid "Error in MIDI stream at position %d" +msgstr "" + #: extmod/modure.c msgid "Error in regex" msgstr "Error pada regex" @@ -1028,6 +1033,10 @@ msgstr "Gagal melepaskan mutex, err 0x%04x" msgid "Failed to write internal flash." msgstr "Gagal menulis flash internal." +#: supervisor/shared/safe_mode.c +msgid "Fatal error." +msgstr "" + #: py/moduerrno.c msgid "File exists" msgstr "File sudah ada" @@ -1100,10 +1109,6 @@ 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" @@ -1229,6 +1234,10 @@ msgstr "" msgid "Invalid DAC pin supplied" msgstr "Pin DAC yang diberikan tidak valid" +#: shared-bindings/synthio/__init__.c +msgid "Invalid MIDI file" +msgstr "" + #: ports/atmel-samd/common-hal/pwmio/PWMOut.c #: ports/cxd56/common-hal/pwmio/PWMOut.c #: ports/mimxrt10xx/common-hal/pwmio/PWMOut.c @@ -1420,14 +1429,6 @@ msgstr "Nilai x maksimum ketika dicerminkan adalah %d" msgid "Messages limited to 8 bytes" msgstr "" -#: supervisor/shared/safe_mode.c -msgid "MicroPython NLR jump failed. Likely memory corruption." -msgstr "Lompatan NLR MicroPython gagal. Kemungkinan kerusakan memori." - -#: supervisor/shared/safe_mode.c -msgid "MicroPython fatal error." -msgstr "Kesalahan fatal MicroPython." - #: shared-bindings/audiobusio/PDMIn.c msgid "Microphone startup delay must be in range 0.0 to 1.0" msgstr "Penundaan mulai mikrofon harus dalam kisaran 0,0 hingga 1,0" @@ -1479,6 +1480,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" +#: supervisor/shared/safe_mode.c +msgid "NLR jump failed. Likely memory corruption." +msgstr "" + #: ports/esp32s2/common-hal/nvm/ByteArray.c msgid "NVS Error" msgstr "" @@ -1623,6 +1628,7 @@ msgstr "" msgid "Not a valid IP string" msgstr "" +#: ports/nrf/common-hal/_bleio/PacketBuffer.c #: ports/nrf/common-hal/_bleio/__init__.c #: shared-bindings/_bleio/CharacteristicBuffer.c msgid "Not connected" @@ -1847,8 +1853,8 @@ msgstr "Buffer awalan harus ada di heap" #: main.c msgid "Press any key to enter the REPL. Use CTRL-D to reload.\n" msgstr "" -"Tekan sembarang tombol untuk masuk ke REPL. Tekan CTRL-D untuk memuat ulang." -"\n" +"Tekan sembarang tombol untuk masuk ke REPL. Tekan CTRL-D untuk memuat " +"ulang.\n" #: main.c msgid "Pretending to deep sleep until alarm, CTRL-C or file write.\n" @@ -2543,10 +2549,6 @@ msgstr "" msgid "buffer is smaller than requested size" msgstr "" -#: shared-bindings/audiocore/RawSample.c -msgid "buffer must be a bytes-like object" -msgstr "" - #: extmod/ulab/code/ulab_create.c extmod/ulab/code/utils/utils.c msgid "buffer size must be a multiple of element size" msgstr "" @@ -2988,7 +2990,7 @@ msgid "f-string: single '}' is not allowed" msgstr "" #: shared-bindings/audiocore/WaveFile.c shared-bindings/audiomp3/MP3Decoder.c -#: shared-bindings/displayio/OnDiskBitmap.c +#: shared-bindings/displayio/OnDiskBitmap.c shared-bindings/synthio/__init__.c msgid "file must be a file opened in byte mode" msgstr "" @@ -3244,6 +3246,10 @@ msgstr "" msgid "invalid cert" msgstr "cert tidak valid" +#: py/compile.c +msgid "invalid decorator" +msgstr "" + #: extmod/uos_dupterm.c msgid "invalid dupterm index" msgstr "indeks dupterm tidak valid" @@ -3299,10 +3305,6 @@ 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 "" @@ -3763,6 +3765,7 @@ msgstr "" #: ports/esp32s2/boards/adafruit_funhouse/mpconfigboard.h #: ports/esp32s2/boards/adafruit_magtag_2.9_grayscale/mpconfigboard.h #: ports/esp32s2/boards/adafruit_metro_esp32s2/mpconfigboard.h +#: ports/esp32s2/boards/artisense_rd00/mpconfigboard.h #: ports/esp32s2/boards/electroniccats_bastwifi/mpconfigboard.h #: ports/esp32s2/boards/espressif_kaluga_1/mpconfigboard.h #: ports/esp32s2/boards/espressif_saola_1_wroom/mpconfigboard.h @@ -3788,6 +3791,10 @@ msgstr "" msgid "pressing both buttons at start up.\n" msgstr "" +#: ports/nrf/boards/aramcon2_badge/mpconfigboard.h +msgid "pressing the left button at start up\n" +msgstr "" + #: ports/raspberrypi/common-hal/rp2pio/StateMachine.c msgid "pull masks conflict with direction masks" msgstr "" @@ -4061,10 +4068,6 @@ 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 "" - #: py/obj.c msgid "tuple/list has wrong length" msgstr "" @@ -4199,10 +4202,6 @@ msgstr "" msgid "value_count must be > 0" 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 "" @@ -4289,6 +4288,15 @@ msgstr "zi harus berjenis float" msgid "zi must be of shape (n_section, 2)" msgstr "" +#~ msgid "Attempted heap allocation when MicroPython VM not running." +#~ msgstr "Mencoba alokasi heap ketika MicroPython VM tidak berjalan." + +#~ msgid "MicroPython NLR jump failed. Likely memory corruption." +#~ msgstr "Lompatan NLR MicroPython gagal. Kemungkinan kerusakan memori." + +#~ msgid "MicroPython fatal error." +#~ msgstr "Kesalahan fatal MicroPython." + #~ msgid "Nordic Soft Device failure assertion." #~ msgstr "Pernyataan kegagalan Perangkat Lunak Nordic." diff --git a/locale/circuitpython.pot b/locale/circuitpython.pot index 1245f17840..2a43daf014 100644 --- a/locale/circuitpython.pot +++ b/locale/circuitpython.pot @@ -309,10 +309,6 @@ msgstr "" msgid "Address type out of range" msgstr "" -#: ports/nrf/common-hal/alarm/time/TimeAlarm.c -msgid "Alarm time must be < 512 seconds." -msgstr "" - #: ports/esp32s2/common-hal/canio/CAN.c msgid "All CAN peripherals are in use" msgstr "" @@ -442,7 +438,7 @@ msgid "Attempt to allocate %d blocks" msgstr "" #: supervisor/shared/safe_mode.c -msgid "Attempted heap allocation when MicroPython VM not running." +msgid "Attempted heap allocation when VM not running." msgstr "" #: shared-bindings/wifi/Radio.c @@ -884,6 +880,11 @@ msgstr "" msgid "EXTINT channel already in use" msgstr "" +#: shared-module/synthio/MidiTrack.c +#, c-format +msgid "Error in MIDI stream at position %d" +msgstr "" + #: extmod/modure.c msgid "Error in regex" msgstr "" @@ -1013,6 +1014,10 @@ msgstr "" msgid "Failed to write internal flash." msgstr "" +#: supervisor/shared/safe_mode.c +msgid "Fatal error." +msgstr "" + #: py/moduerrno.c msgid "File exists" msgstr "" @@ -1085,10 +1090,6 @@ 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" @@ -1212,6 +1213,10 @@ msgstr "" msgid "Invalid DAC pin supplied" msgstr "" +#: shared-bindings/synthio/__init__.c +msgid "Invalid MIDI file" +msgstr "" + #: ports/atmel-samd/common-hal/pwmio/PWMOut.c #: ports/cxd56/common-hal/pwmio/PWMOut.c #: ports/mimxrt10xx/common-hal/pwmio/PWMOut.c @@ -1404,14 +1409,6 @@ msgstr "" msgid "Messages limited to 8 bytes" msgstr "" -#: supervisor/shared/safe_mode.c -msgid "MicroPython NLR jump failed. Likely memory corruption." -msgstr "" - -#: supervisor/shared/safe_mode.c -msgid "MicroPython fatal error." -msgstr "" - #: shared-bindings/audiobusio/PDMIn.c msgid "Microphone startup delay must be in range 0.0 to 1.0" msgstr "" @@ -1463,6 +1460,10 @@ msgstr "" msgid "Must use a multiple of 6 rgb pins, not %d" msgstr "" +#: supervisor/shared/safe_mode.c +msgid "NLR jump failed. Likely memory corruption." +msgstr "" + #: ports/esp32s2/common-hal/nvm/ByteArray.c msgid "NVS Error" msgstr "" @@ -1607,6 +1608,7 @@ msgstr "" msgid "Not a valid IP string" msgstr "" +#: ports/nrf/common-hal/_bleio/PacketBuffer.c #: ports/nrf/common-hal/_bleio/__init__.c #: shared-bindings/_bleio/CharacteristicBuffer.c msgid "Not connected" @@ -2133,7 +2135,7 @@ msgid "Too many displays" msgstr "" #: ports/nrf/common-hal/_bleio/PacketBuffer.c -msgid "Total data to write is larger than outgoing_packet_length" +msgid "Total data to write is larger than %q" msgstr "" #: py/obj.c @@ -2500,10 +2502,6 @@ msgstr "" msgid "buffer is smaller than requested size" msgstr "" -#: shared-bindings/audiocore/RawSample.c -msgid "buffer must be a bytes-like object" -msgstr "" - #: extmod/ulab/code/ulab_create.c extmod/ulab/code/utils/utils.c msgid "buffer size must be a multiple of element size" msgstr "" @@ -2945,7 +2943,7 @@ msgid "f-string: single '}' is not allowed" msgstr "" #: shared-bindings/audiocore/WaveFile.c shared-bindings/audiomp3/MP3Decoder.c -#: shared-bindings/displayio/OnDiskBitmap.c +#: shared-bindings/displayio/OnDiskBitmap.c shared-bindings/synthio/__init__.c msgid "file must be a file opened in byte mode" msgstr "" @@ -3201,6 +3199,10 @@ msgstr "" msgid "invalid cert" msgstr "" +#: py/compile.c +msgid "invalid decorator" +msgstr "" + #: extmod/uos_dupterm.c msgid "invalid dupterm index" msgstr "" @@ -3256,10 +3258,6 @@ 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 "" @@ -3719,6 +3717,8 @@ msgstr "" #: ports/esp32s2/boards/adafruit_funhouse/mpconfigboard.h #: ports/esp32s2/boards/adafruit_magtag_2.9_grayscale/mpconfigboard.h #: ports/esp32s2/boards/adafruit_metro_esp32s2/mpconfigboard.h +#: ports/esp32s2/boards/artisense_rd00/mpconfigboard.h +#: ports/esp32s2/boards/atmegazero_esp32s2/mpconfigboard.h #: ports/esp32s2/boards/electroniccats_bastwifi/mpconfigboard.h #: ports/esp32s2/boards/espressif_kaluga_1/mpconfigboard.h #: ports/esp32s2/boards/espressif_saola_1_wroom/mpconfigboard.h @@ -3744,6 +3744,10 @@ msgstr "" msgid "pressing both buttons at start up.\n" msgstr "" +#: ports/nrf/boards/aramcon2_badge/mpconfigboard.h +msgid "pressing the left button at start up\n" +msgstr "" + #: ports/raspberrypi/common-hal/rp2pio/StateMachine.c msgid "pull masks conflict with direction masks" msgstr "" @@ -4017,10 +4021,6 @@ 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 "" - #: py/obj.c msgid "tuple/list has wrong length" msgstr "" @@ -4155,10 +4155,6 @@ msgstr "" msgid "value_count must be > 0" 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 654023f1f5..9bed9ec3c6 100644 --- a/locale/cs.po +++ b/locale/cs.po @@ -441,7 +441,7 @@ msgid "Attempt to allocate %d blocks" msgstr "" #: supervisor/shared/safe_mode.c -msgid "Attempted heap allocation when MicroPython VM not running." +msgid "Attempted heap allocation when VM not running." msgstr "" #: shared-bindings/wifi/Radio.c @@ -882,6 +882,11 @@ msgstr "" msgid "EXTINT channel already in use" msgstr "" +#: shared-module/synthio/MidiTrack.c +#, c-format +msgid "Error in MIDI stream at position %d" +msgstr "" + #: extmod/modure.c msgid "Error in regex" msgstr "" @@ -1011,6 +1016,10 @@ msgstr "" msgid "Failed to write internal flash." msgstr "" +#: supervisor/shared/safe_mode.c +msgid "Fatal error." +msgstr "" + #: py/moduerrno.c msgid "File exists" msgstr "" @@ -1083,10 +1092,6 @@ 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" @@ -1210,6 +1215,10 @@ msgstr "" msgid "Invalid DAC pin supplied" msgstr "" +#: shared-bindings/synthio/__init__.c +msgid "Invalid MIDI file" +msgstr "" + #: ports/atmel-samd/common-hal/pwmio/PWMOut.c #: ports/cxd56/common-hal/pwmio/PWMOut.c #: ports/mimxrt10xx/common-hal/pwmio/PWMOut.c @@ -1401,14 +1410,6 @@ msgstr "" msgid "Messages limited to 8 bytes" msgstr "" -#: supervisor/shared/safe_mode.c -msgid "MicroPython NLR jump failed. Likely memory corruption." -msgstr "" - -#: supervisor/shared/safe_mode.c -msgid "MicroPython fatal error." -msgstr "" - #: shared-bindings/audiobusio/PDMIn.c msgid "Microphone startup delay must be in range 0.0 to 1.0" msgstr "" @@ -1460,6 +1461,10 @@ msgstr "" msgid "Must use a multiple of 6 rgb pins, not %d" msgstr "" +#: supervisor/shared/safe_mode.c +msgid "NLR jump failed. Likely memory corruption." +msgstr "" + #: ports/esp32s2/common-hal/nvm/ByteArray.c msgid "NVS Error" msgstr "" @@ -1604,6 +1609,7 @@ msgstr "" msgid "Not a valid IP string" msgstr "" +#: ports/nrf/common-hal/_bleio/PacketBuffer.c #: ports/nrf/common-hal/_bleio/__init__.c #: shared-bindings/_bleio/CharacteristicBuffer.c msgid "Not connected" @@ -2496,10 +2502,6 @@ msgstr "" msgid "buffer is smaller than requested size" msgstr "" -#: shared-bindings/audiocore/RawSample.c -msgid "buffer must be a bytes-like object" -msgstr "" - #: extmod/ulab/code/ulab_create.c extmod/ulab/code/utils/utils.c msgid "buffer size must be a multiple of element size" msgstr "" @@ -2941,7 +2943,7 @@ msgid "f-string: single '}' is not allowed" msgstr "" #: shared-bindings/audiocore/WaveFile.c shared-bindings/audiomp3/MP3Decoder.c -#: shared-bindings/displayio/OnDiskBitmap.c +#: shared-bindings/displayio/OnDiskBitmap.c shared-bindings/synthio/__init__.c msgid "file must be a file opened in byte mode" msgstr "" @@ -3197,6 +3199,10 @@ msgstr "" msgid "invalid cert" msgstr "" +#: py/compile.c +msgid "invalid decorator" +msgstr "" + #: extmod/uos_dupterm.c msgid "invalid dupterm index" msgstr "" @@ -3252,10 +3258,6 @@ 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 "" @@ -3715,6 +3717,7 @@ msgstr "" #: ports/esp32s2/boards/adafruit_funhouse/mpconfigboard.h #: ports/esp32s2/boards/adafruit_magtag_2.9_grayscale/mpconfigboard.h #: ports/esp32s2/boards/adafruit_metro_esp32s2/mpconfigboard.h +#: ports/esp32s2/boards/artisense_rd00/mpconfigboard.h #: ports/esp32s2/boards/electroniccats_bastwifi/mpconfigboard.h #: ports/esp32s2/boards/espressif_kaluga_1/mpconfigboard.h #: ports/esp32s2/boards/espressif_saola_1_wroom/mpconfigboard.h @@ -3740,6 +3743,10 @@ msgstr "" msgid "pressing both buttons at start up.\n" msgstr "" +#: ports/nrf/boards/aramcon2_badge/mpconfigboard.h +msgid "pressing the left button at start up\n" +msgstr "" + #: ports/raspberrypi/common-hal/rp2pio/StateMachine.c msgid "pull masks conflict with direction masks" msgstr "" @@ -4013,10 +4020,6 @@ 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 "" - #: py/obj.c msgid "tuple/list has wrong length" msgstr "" @@ -4151,10 +4154,6 @@ msgstr "" msgid "value_count must be > 0" 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 e3e2ddbd45..3a64342366 100644 --- a/locale/de_DE.po +++ b/locale/de_DE.po @@ -447,10 +447,8 @@ msgid "Attempt to allocate %d blocks" msgstr "Versuche %d Blöcke zu allokieren" #: supervisor/shared/safe_mode.c -msgid "Attempted heap allocation when MicroPython VM not running." +msgid "Attempted heap allocation when VM not running." msgstr "" -"Versuch einer Heap Reservierung, wenn die MicroPython-VM nicht ausgeführt " -"wird." #: shared-bindings/wifi/Radio.c msgid "Authentication failure" @@ -899,6 +897,11 @@ msgstr "ESP-IDF Speicherallozierung fehlgeschlagen" msgid "EXTINT channel already in use" msgstr "EXTINT Kanal ist schon in Benutzung" +#: shared-module/synthio/MidiTrack.c +#, c-format +msgid "Error in MIDI stream at position %d" +msgstr "" + #: extmod/modure.c msgid "Error in regex" msgstr "Fehler in regex" @@ -1029,6 +1032,10 @@ msgstr "Mutex konnte nicht freigegeben werden. Status: 0x%04x" msgid "Failed to write internal flash." msgstr "Interner Flash konnte nicht geschrieben werden." +#: supervisor/shared/safe_mode.c +msgid "Fatal error." +msgstr "" + #: py/moduerrno.c msgid "File exists" msgstr "Datei existiert" @@ -1103,10 +1110,6 @@ msgstr "I2C Peripherie in Verwendung" 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 "IOs 0, 2 & 4 unterstützen keinen internen Pull up im sleep-Modus" - #: shared-bindings/aesio/aes.c #, c-format msgid "IV must be %d bytes long" @@ -1232,6 +1235,10 @@ msgstr "Ungültige BSSID" msgid "Invalid DAC pin supplied" msgstr "Ungültiger DAC-Pin angegeben" +#: shared-bindings/synthio/__init__.c +msgid "Invalid MIDI file" +msgstr "" + #: ports/atmel-samd/common-hal/pwmio/PWMOut.c #: ports/cxd56/common-hal/pwmio/PWMOut.c #: ports/mimxrt10xx/common-hal/pwmio/PWMOut.c @@ -1423,15 +1430,6 @@ msgstr "Maximaler x-Wert beim Spiegeln ist %d" msgid "Messages limited to 8 bytes" msgstr "" -#: supervisor/shared/safe_mode.c -msgid "MicroPython NLR jump failed. Likely memory corruption." -msgstr "" -"MicroPython NLR-Sprung fehlgeschlagen. Wahrscheinlich Speicherbeschädigung." - -#: supervisor/shared/safe_mode.c -msgid "MicroPython fatal error." -msgstr "Schwerwiegender MicroPython-Fehler." - #: shared-bindings/audiobusio/PDMIn.c msgid "Microphone startup delay must be in range 0.0 to 1.0" msgstr "" @@ -1484,6 +1482,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" +#: supervisor/shared/safe_mode.c +msgid "NLR jump failed. Likely memory corruption." +msgstr "" + #: ports/esp32s2/common-hal/nvm/ByteArray.c msgid "NVS Error" msgstr "" @@ -1628,6 +1630,7 @@ msgstr "" msgid "Not a valid IP string" msgstr "" +#: ports/nrf/common-hal/_bleio/PacketBuffer.c #: ports/nrf/common-hal/_bleio/__init__.c #: shared-bindings/_bleio/CharacteristicBuffer.c msgid "Not connected" @@ -2560,10 +2563,6 @@ msgstr "Zweig ist außerhalb der Reichweite" msgid "buffer is smaller than requested size" msgstr "" -#: shared-bindings/audiocore/RawSample.c -msgid "buffer must be a bytes-like object" -msgstr "Puffer muss ein bytes-artiges Objekt sein" - #: extmod/ulab/code/ulab_create.c extmod/ulab/code/utils/utils.c msgid "buffer size must be a multiple of element size" msgstr "" @@ -3017,7 +3016,7 @@ msgid "f-string: single '}' is not allowed" msgstr "f-string: einzelne '}' nicht erlaubt" #: shared-bindings/audiocore/WaveFile.c shared-bindings/audiomp3/MP3Decoder.c -#: shared-bindings/displayio/OnDiskBitmap.c +#: shared-bindings/displayio/OnDiskBitmap.c shared-bindings/synthio/__init__.c msgid "file must be a file opened in byte mode" msgstr "Die Datei muss eine im Byte-Modus geöffnete Datei sein" @@ -3275,6 +3274,10 @@ msgstr "" msgid "invalid cert" msgstr "ungültiges cert" +#: py/compile.c +msgid "invalid decorator" +msgstr "" + #: extmod/uos_dupterm.c msgid "invalid dupterm index" msgstr "ungültiger dupterm index" @@ -3330,10 +3333,6 @@ 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" @@ -3803,6 +3802,7 @@ msgstr "pow () mit 3 Argumenten erfordert Integer" #: ports/esp32s2/boards/adafruit_funhouse/mpconfigboard.h #: ports/esp32s2/boards/adafruit_magtag_2.9_grayscale/mpconfigboard.h #: ports/esp32s2/boards/adafruit_metro_esp32s2/mpconfigboard.h +#: ports/esp32s2/boards/artisense_rd00/mpconfigboard.h #: ports/esp32s2/boards/electroniccats_bastwifi/mpconfigboard.h #: ports/esp32s2/boards/espressif_kaluga_1/mpconfigboard.h #: ports/esp32s2/boards/espressif_saola_1_wroom/mpconfigboard.h @@ -3828,6 +3828,10 @@ msgstr "" msgid "pressing both buttons at start up.\n" msgstr "" +#: ports/nrf/boards/aramcon2_badge/mpconfigboard.h +msgid "pressing the left button at start up\n" +msgstr "" + #: ports/raspberrypi/common-hal/rp2pio/StateMachine.c msgid "pull masks conflict with direction masks" msgstr "" @@ -4104,10 +4108,6 @@ 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 "" - #: py/obj.c msgid "tuple/list has wrong length" msgstr "tupel/list hat falsche Länge" @@ -4246,10 +4246,6 @@ msgstr "Wert muss in %d Byte(s) passen" msgid "value_count must be > 0" msgstr "value_count muss größer als 0 sein" -#: ports/esp32s2/common-hal/alarm/pin/__init__.c -msgid "wakeup conflict" -msgstr "" - #: ports/esp32s2/common-hal/watchdog/WatchDogTimer.c msgid "watchdog not initialized" msgstr "" @@ -4336,6 +4332,25 @@ msgstr "" msgid "zi must be of shape (n_section, 2)" msgstr "" +#~ msgid "IOs 0, 2 & 4 do not support internal pullup in sleep" +#~ msgstr "IOs 0, 2 & 4 unterstützen keinen internen Pull up im sleep-Modus" + +#~ msgid "buffer must be a bytes-like object" +#~ msgstr "Puffer muss ein bytes-artiges Objekt sein" + +#~ msgid "Attempted heap allocation when MicroPython VM not running." +#~ msgstr "" +#~ "Versuch einer Heap Reservierung, wenn die MicroPython-VM nicht ausgeführt " +#~ "wird." + +#~ msgid "MicroPython NLR jump failed. Likely memory corruption." +#~ msgstr "" +#~ "MicroPython NLR-Sprung fehlgeschlagen. Wahrscheinlich " +#~ "Speicherbeschädigung." + +#~ msgid "MicroPython fatal error." +#~ msgstr "Schwerwiegender MicroPython-Fehler." + #~ msgid "argument must be ndarray" #~ msgstr "Argument muss ein ndarray sein" diff --git a/locale/el.po b/locale/el.po index 1f7fabf381..c150ef8258 100644 --- a/locale/el.po +++ b/locale/el.po @@ -438,7 +438,7 @@ msgid "Attempt to allocate %d blocks" msgstr "" #: supervisor/shared/safe_mode.c -msgid "Attempted heap allocation when MicroPython VM not running." +msgid "Attempted heap allocation when VM not running." msgstr "" #: shared-bindings/wifi/Radio.c @@ -879,6 +879,11 @@ msgstr "" msgid "EXTINT channel already in use" msgstr "" +#: shared-module/synthio/MidiTrack.c +#, c-format +msgid "Error in MIDI stream at position %d" +msgstr "" + #: extmod/modure.c msgid "Error in regex" msgstr "" @@ -1008,6 +1013,10 @@ msgstr "" msgid "Failed to write internal flash." msgstr "" +#: supervisor/shared/safe_mode.c +msgid "Fatal error." +msgstr "" + #: py/moduerrno.c msgid "File exists" msgstr "" @@ -1080,10 +1089,6 @@ 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" @@ -1207,6 +1212,10 @@ msgstr "" msgid "Invalid DAC pin supplied" msgstr "" +#: shared-bindings/synthio/__init__.c +msgid "Invalid MIDI file" +msgstr "" + #: ports/atmel-samd/common-hal/pwmio/PWMOut.c #: ports/cxd56/common-hal/pwmio/PWMOut.c #: ports/mimxrt10xx/common-hal/pwmio/PWMOut.c @@ -1398,14 +1407,6 @@ msgstr "" msgid "Messages limited to 8 bytes" msgstr "" -#: supervisor/shared/safe_mode.c -msgid "MicroPython NLR jump failed. Likely memory corruption." -msgstr "" - -#: supervisor/shared/safe_mode.c -msgid "MicroPython fatal error." -msgstr "" - #: shared-bindings/audiobusio/PDMIn.c msgid "Microphone startup delay must be in range 0.0 to 1.0" msgstr "" @@ -1457,6 +1458,10 @@ msgstr "" msgid "Must use a multiple of 6 rgb pins, not %d" msgstr "" +#: supervisor/shared/safe_mode.c +msgid "NLR jump failed. Likely memory corruption." +msgstr "" + #: ports/esp32s2/common-hal/nvm/ByteArray.c msgid "NVS Error" msgstr "" @@ -1601,6 +1606,7 @@ msgstr "" msgid "Not a valid IP string" msgstr "" +#: ports/nrf/common-hal/_bleio/PacketBuffer.c #: ports/nrf/common-hal/_bleio/__init__.c #: shared-bindings/_bleio/CharacteristicBuffer.c msgid "Not connected" @@ -2493,10 +2499,6 @@ msgstr "" msgid "buffer is smaller than requested size" msgstr "" -#: shared-bindings/audiocore/RawSample.c -msgid "buffer must be a bytes-like object" -msgstr "" - #: extmod/ulab/code/ulab_create.c extmod/ulab/code/utils/utils.c msgid "buffer size must be a multiple of element size" msgstr "" @@ -2938,7 +2940,7 @@ msgid "f-string: single '}' is not allowed" msgstr "" #: shared-bindings/audiocore/WaveFile.c shared-bindings/audiomp3/MP3Decoder.c -#: shared-bindings/displayio/OnDiskBitmap.c +#: shared-bindings/displayio/OnDiskBitmap.c shared-bindings/synthio/__init__.c msgid "file must be a file opened in byte mode" msgstr "" @@ -3194,6 +3196,10 @@ msgstr "" msgid "invalid cert" msgstr "" +#: py/compile.c +msgid "invalid decorator" +msgstr "" + #: extmod/uos_dupterm.c msgid "invalid dupterm index" msgstr "" @@ -3249,10 +3255,6 @@ 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 "" @@ -3712,6 +3714,7 @@ msgstr "" #: ports/esp32s2/boards/adafruit_funhouse/mpconfigboard.h #: ports/esp32s2/boards/adafruit_magtag_2.9_grayscale/mpconfigboard.h #: ports/esp32s2/boards/adafruit_metro_esp32s2/mpconfigboard.h +#: ports/esp32s2/boards/artisense_rd00/mpconfigboard.h #: ports/esp32s2/boards/electroniccats_bastwifi/mpconfigboard.h #: ports/esp32s2/boards/espressif_kaluga_1/mpconfigboard.h #: ports/esp32s2/boards/espressif_saola_1_wroom/mpconfigboard.h @@ -3737,6 +3740,10 @@ msgstr "" msgid "pressing both buttons at start up.\n" msgstr "" +#: ports/nrf/boards/aramcon2_badge/mpconfigboard.h +msgid "pressing the left button at start up\n" +msgstr "" + #: ports/raspberrypi/common-hal/rp2pio/StateMachine.c msgid "pull masks conflict with direction masks" msgstr "" @@ -4010,10 +4017,6 @@ 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 "" - #: py/obj.c msgid "tuple/list has wrong length" msgstr "" @@ -4148,10 +4151,6 @@ msgstr "" msgid "value_count must be > 0" 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/en_GB.po b/locale/en_GB.po index 135f738872..d3859c7c9e 100644 --- a/locale/en_GB.po +++ b/locale/en_GB.po @@ -7,15 +7,15 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"PO-Revision-Date: 2021-03-25 23:30+0000\n" -"Last-Translator: Gareth Coleman \n" +"PO-Revision-Date: 2021-04-11 01:30+0000\n" +"Last-Translator: Hugo Dahl \n" "Language-Team: none\n" "Language: en_GB\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.5.2-dev\n" +"X-Generator: Weblate 4.6-dev\n" #: main.c msgid "" @@ -447,9 +447,8 @@ msgid "Attempt to allocate %d blocks" msgstr "Attempt to allocate %d blocks" #: supervisor/shared/safe_mode.c -#, fuzzy -msgid "Attempted heap allocation when MicroPython VM not running." -msgstr "Attempted heap allocation when CircuitPython VM not running." +msgid "Attempted heap allocation when VM not running." +msgstr "" #: shared-bindings/wifi/Radio.c msgid "Authentication failure" @@ -895,6 +894,11 @@ msgstr "ESP-IDF memory allocation failed" msgid "EXTINT channel already in use" msgstr "EXTINT channel already in use" +#: shared-module/synthio/MidiTrack.c +#, c-format +msgid "Error in MIDI stream at position %d" +msgstr "" + #: extmod/modure.c msgid "Error in regex" msgstr "Error in regex" @@ -1024,6 +1028,10 @@ msgstr "Failed to release mutex, err 0x%04x" msgid "Failed to write internal flash." msgstr "Failed to write internal flash." +#: supervisor/shared/safe_mode.c +msgid "Fatal error." +msgstr "" + #: py/moduerrno.c msgid "File exists" msgstr "File exists" @@ -1096,10 +1104,6 @@ msgstr "I2C peripheral in use" msgid "I2SOut not available" msgstr "I2SOut not available" -#: ports/esp32s2/common-hal/alarm/pin/__init__.c -msgid "IOs 0, 2 & 4 do not support internal pullup in sleep" -msgstr "IOs 0, 2 & 4 do not support internal pullup in sleep" - #: shared-bindings/aesio/aes.c #, c-format msgid "IV must be %d bytes long" @@ -1225,6 +1229,10 @@ msgstr "Invalid BSSID" msgid "Invalid DAC pin supplied" msgstr "Invalid DAC pin supplied" +#: shared-bindings/synthio/__init__.c +msgid "Invalid MIDI file" +msgstr "" + #: ports/atmel-samd/common-hal/pwmio/PWMOut.c #: ports/cxd56/common-hal/pwmio/PWMOut.c #: ports/mimxrt10xx/common-hal/pwmio/PWMOut.c @@ -1416,16 +1424,6 @@ msgstr "Maximum x value when mirrored is %d" msgid "Messages limited to 8 bytes" msgstr "Messages limited to 8 bytes" -#: supervisor/shared/safe_mode.c -#, fuzzy -msgid "MicroPython NLR jump failed. Likely memory corruption." -msgstr "CircuitPython NLR jump failed. Likely memory corruption." - -#: supervisor/shared/safe_mode.c -#, fuzzy -msgid "MicroPython fatal error." -msgstr "CircuitPython fatal error." - #: shared-bindings/audiobusio/PDMIn.c msgid "Microphone startup delay must be in range 0.0 to 1.0" msgstr "Microphone startup delay must be in range 0.0 to 1.0" @@ -1477,6 +1475,10 @@ msgstr "Must provide MISO or MOSI pin" msgid "Must use a multiple of 6 rgb pins, not %d" msgstr "Must use a multiple of 6 rgb pins, not %d" +#: supervisor/shared/safe_mode.c +msgid "NLR jump failed. Likely memory corruption." +msgstr "" + #: ports/esp32s2/common-hal/nvm/ByteArray.c msgid "NVS Error" msgstr "NVS Error" @@ -1621,6 +1623,7 @@ msgstr "" msgid "Not a valid IP string" msgstr "Not a valid IP string" +#: ports/nrf/common-hal/_bleio/PacketBuffer.c #: ports/nrf/common-hal/_bleio/__init__.c #: shared-bindings/_bleio/CharacteristicBuffer.c msgid "Not connected" @@ -2540,10 +2543,6 @@ msgstr "Branch not in range" msgid "buffer is smaller than requested size" msgstr "Buffer is smaller than requested size" -#: shared-bindings/audiocore/RawSample.c -msgid "buffer must be a bytes-like object" -msgstr "Buffer must be a bytes-like object" - #: extmod/ulab/code/ulab_create.c extmod/ulab/code/utils/utils.c msgid "buffer size must be a multiple of element size" msgstr "Buffer size must be a multiple of element size" @@ -2988,7 +2987,7 @@ msgid "f-string: single '}' is not allowed" msgstr "f-string: single '}' is not allowed" #: shared-bindings/audiocore/WaveFile.c shared-bindings/audiomp3/MP3Decoder.c -#: shared-bindings/displayio/OnDiskBitmap.c +#: shared-bindings/displayio/OnDiskBitmap.c shared-bindings/synthio/__init__.c msgid "file must be a file opened in byte mode" msgstr "file must be a file opened in byte mode" @@ -3244,6 +3243,10 @@ msgstr "invalid bits_per_pixel %d, must be, 1, 4, 8, 16, 24, or 32" msgid "invalid cert" msgstr "invalid cert" +#: py/compile.c +msgid "invalid decorator" +msgstr "" + #: extmod/uos_dupterm.c msgid "invalid dupterm index" msgstr "invalid dupterm index" @@ -3300,10 +3303,6 @@ msgstr "invalid syntax for integer with base %d" msgid "invalid syntax for number" msgstr "invalid syntax for number" -#: ports/esp32s2/common-hal/alarm/pin/__init__.c -msgid "io must be rtc io" -msgstr "io must be rtc io" - #: py/objtype.c msgid "issubclass() arg 1 must be a class" msgstr "issubclass() arg 1 must be a class" @@ -3763,6 +3762,7 @@ msgstr "pow() with 3 arguments requires integers" #: ports/esp32s2/boards/adafruit_funhouse/mpconfigboard.h #: ports/esp32s2/boards/adafruit_magtag_2.9_grayscale/mpconfigboard.h #: ports/esp32s2/boards/adafruit_metro_esp32s2/mpconfigboard.h +#: ports/esp32s2/boards/artisense_rd00/mpconfigboard.h #: ports/esp32s2/boards/electroniccats_bastwifi/mpconfigboard.h #: ports/esp32s2/boards/espressif_kaluga_1/mpconfigboard.h #: ports/esp32s2/boards/espressif_saola_1_wroom/mpconfigboard.h @@ -3788,6 +3788,10 @@ msgstr "pressing boot button at start up.\n" msgid "pressing both buttons at start up.\n" msgstr "pressing both buttons at start up.\n" +#: ports/nrf/boards/aramcon2_badge/mpconfigboard.h +msgid "pressing the left button at start up\n" +msgstr "" + #: ports/raspberrypi/common-hal/rp2pio/StateMachine.c msgid "pull masks conflict with direction masks" msgstr "pull masks conflict with direction masks" @@ -4063,10 +4067,6 @@ msgstr "trapz is defined for 1D arrays" msgid "trapz is defined for 1D arrays of equal length" msgstr "trapz is defined for 1D arrays of equal length" -#: ports/esp32s2/common-hal/alarm/pin/__init__.c -msgid "trigger level must be 0 or 1" -msgstr "trigger level must be 0 or 1" - #: py/obj.c msgid "tuple/list has wrong length" msgstr "tuple/list has wrong length" @@ -4201,10 +4201,6 @@ msgstr "value must fit in %d byte(s)" msgid "value_count must be > 0" msgstr "value_count must be > 0" -#: ports/esp32s2/common-hal/alarm/pin/__init__.c -msgid "wakeup conflict" -msgstr "wakeup conflict" - #: ports/esp32s2/common-hal/watchdog/WatchDogTimer.c msgid "watchdog not initialized" msgstr "WatchDog not initialised" @@ -4291,6 +4287,31 @@ msgstr "zi must be of float type" msgid "zi must be of shape (n_section, 2)" msgstr "zi must be of shape (n_section, 2)" +#~ msgid "IOs 0, 2 & 4 do not support internal pullup in sleep" +#~ msgstr "IOs 0, 2 & 4 do not support internal pullup in sleep" + +#~ msgid "buffer must be a bytes-like object" +#~ msgstr "Buffer must be a bytes-like object" + +#~ msgid "io must be rtc io" +#~ msgstr "io must be rtc io" + +#~ msgid "trigger level must be 0 or 1" +#~ msgstr "trigger level must be 0 or 1" + +#~ msgid "wakeup conflict" +#~ msgstr "wakeup conflict" + +#~ msgid "Attempted heap allocation when MicroPython VM not running." +#~ msgstr "Attempted heap allocation when MicroPython VM not running." + +#~ msgid "MicroPython NLR jump failed. Likely memory corruption." +#~ msgstr "MicroPython NLR jump failed. Likely memory corruption." + +#, fuzzy +#~ msgid "MicroPython fatal error." +#~ msgstr "CircuitPython fatal error." + #~ msgid "argument must be ndarray" #~ msgstr "argument must be ndarray" diff --git a/locale/es.po b/locale/es.po index 2f7a7a7b9c..6339727b8c 100644 --- a/locale/es.po +++ b/locale/es.po @@ -8,8 +8,8 @@ msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2021-01-04 12:55-0600\n" -"PO-Revision-Date: 2021-04-05 22:35+0000\n" -"Last-Translator: Jose David M \n" +"PO-Revision-Date: 2021-04-15 14:26+0000\n" +"Last-Translator: Alvaro Figueroa \n" "Language-Team: \n" "Language: es\n" "MIME-Version: 1.0\n" @@ -426,7 +426,7 @@ msgstr "El pin proporcionado no soporta AnalogOut" #: ports/stm/common-hal/audiopwmio/PWMAudioOut.c msgid "Another PWMAudioOut is already active" -msgstr "" +msgstr "Otra salida PWMAudioOut esta ya activada" #: ports/atmel-samd/common-hal/pulseio/PulseOut.c #: ports/cxd56/common-hal/pulseio/PulseOut.c @@ -451,10 +451,8 @@ msgid "Attempt to allocate %d blocks" msgstr "Tratando de localizar %d bloques" #: supervisor/shared/safe_mode.c -msgid "Attempted heap allocation when MicroPython VM not running." -msgstr "" -"Se intentó asignación del montículo, sin que la VM de MicroPython esté " -"ejecutando." +msgid "Attempted heap allocation when VM not running." +msgstr "Asignación del montículo mientras la VM no esta ejecutándose." #: shared-bindings/wifi/Radio.c msgid "Authentication failure" @@ -905,6 +903,11 @@ msgstr "Fallo ESP-IDF al tomar la memoria" msgid "EXTINT channel already in use" msgstr "El canal EXTINT ya está siendo utilizado" +#: shared-module/synthio/MidiTrack.c +#, c-format +msgid "Error in MIDI stream at position %d" +msgstr "Error en el flujo MIDI en la posición %d" + #: extmod/modure.c msgid "Error in regex" msgstr "Error en regex" @@ -1007,7 +1010,7 @@ msgstr "Fallo al tomar memoria para búsqueda wifi" #: ports/stm/common-hal/audiopwmio/PWMAudioOut.c msgid "Failed to buffer the sample" -msgstr "" +msgstr "Fallo al hacer el búfer de la muestra" #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Failed to connect: internal error" @@ -1034,6 +1037,10 @@ msgstr "No se puede liberar el mutex, err 0x%04x" msgid "Failed to write internal flash." msgstr "Error al escribir el flash interno." +#: supervisor/shared/safe_mode.c +msgid "Fatal error." +msgstr "Error grave." + #: py/moduerrno.c msgid "File exists" msgstr "El archivo ya existe" @@ -1107,10 +1114,6 @@ msgstr "Dispositivo I2C en uso" 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 "IOs 0, 2 y 4 no soportan pullup interno durante sleep" - #: shared-bindings/aesio/aes.c #, c-format msgid "IV must be %d bytes long" @@ -1243,6 +1246,10 @@ msgstr "BSSID inválido" msgid "Invalid DAC pin supplied" msgstr "Pin suministrado inválido para DAC" +#: shared-bindings/synthio/__init__.c +msgid "Invalid MIDI file" +msgstr "Archivo MIDI inválido" + #: ports/atmel-samd/common-hal/pwmio/PWMOut.c #: ports/cxd56/common-hal/pwmio/PWMOut.c #: ports/mimxrt10xx/common-hal/pwmio/PWMOut.c @@ -1434,14 +1441,6 @@ msgstr "Valor máximo de x cuando se refleja es %d" msgid "Messages limited to 8 bytes" msgstr "Mensajes limitados a 8 bytes" -#: supervisor/shared/safe_mode.c -msgid "MicroPython NLR jump failed. Likely memory corruption." -msgstr "MicroPython NLR jump falló. Probable corrupción de la memoria." - -#: supervisor/shared/safe_mode.c -msgid "MicroPython fatal error." -msgstr "Error fatal de MicroPython." - #: shared-bindings/audiobusio/PDMIn.c msgid "Microphone startup delay must be in range 0.0 to 1.0" msgstr "Micrófono demora de inicio debe estar en el rango 0.0 a 1.0" @@ -1497,6 +1496,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" +#: supervisor/shared/safe_mode.c +msgid "NLR jump failed. Likely memory corruption." +msgstr "Salto NLR falló. Probablemente corrupción de memoria." + #: ports/esp32s2/common-hal/nvm/ByteArray.c msgid "NVS Error" msgstr "Error NVS" @@ -1641,6 +1644,7 @@ msgstr "El firmware del sistema Nordic no tiene memoria" msgid "Not a valid IP string" msgstr "No es una cadena de IP válida" +#: ports/nrf/common-hal/_bleio/PacketBuffer.c #: ports/nrf/common-hal/_bleio/__init__.c #: shared-bindings/_bleio/CharacteristicBuffer.c msgid "Not connected" @@ -2573,10 +2577,6 @@ msgstr "la rama no está dentro del rango" msgid "buffer is smaller than requested size" msgstr "El buffer es mas pequeño que el requerido" -#: shared-bindings/audiocore/RawSample.c -msgid "buffer must be a bytes-like object" -msgstr "buffer debe de ser un objeto bytes-like" - #: extmod/ulab/code/ulab_create.c extmod/ulab/code/utils/utils.c msgid "buffer size must be a multiple of element size" msgstr "El tamaño del buffer debe ser un múltiplo del tamaño del elemento" @@ -3025,7 +3025,7 @@ msgid "f-string: single '}' is not allowed" msgstr "cadena-f: solo '}' no está permitido" #: shared-bindings/audiocore/WaveFile.c shared-bindings/audiomp3/MP3Decoder.c -#: shared-bindings/displayio/OnDiskBitmap.c +#: shared-bindings/displayio/OnDiskBitmap.c shared-bindings/synthio/__init__.c msgid "file must be a file opened in byte mode" msgstr "el archivo deberia ser una archivo abierto en modo byte" @@ -3281,6 +3281,10 @@ msgstr "los bits_per_pixel %d no son validos, deben ser 1, 4, 8, 16, 24 o 32" msgid "invalid cert" msgstr "certificado inválido" +#: py/compile.c +msgid "invalid decorator" +msgstr "decorador invalido" + #: extmod/uos_dupterm.c msgid "invalid dupterm index" msgstr "index dupterm inválido" @@ -3336,10 +3340,6 @@ 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 "io debe ser rtc io" - #: py/objtype.c msgid "issubclass() arg 1 must be a class" msgstr "issubclass() arg 1 debe ser una clase" @@ -3806,6 +3806,7 @@ msgstr "pow() con 3 argumentos requiere enteros" #: ports/esp32s2/boards/adafruit_funhouse/mpconfigboard.h #: ports/esp32s2/boards/adafruit_magtag_2.9_grayscale/mpconfigboard.h #: ports/esp32s2/boards/adafruit_metro_esp32s2/mpconfigboard.h +#: ports/esp32s2/boards/artisense_rd00/mpconfigboard.h #: ports/esp32s2/boards/electroniccats_bastwifi/mpconfigboard.h #: ports/esp32s2/boards/espressif_kaluga_1/mpconfigboard.h #: ports/esp32s2/boards/espressif_saola_1_wroom/mpconfigboard.h @@ -3831,6 +3832,10 @@ msgstr "presionando botón de arranque al inicio.\n" msgid "pressing both buttons at start up.\n" msgstr "presionando ambos botones al inicio.\n" +#: ports/nrf/boards/aramcon2_badge/mpconfigboard.h +msgid "pressing the left button at start up\n" +msgstr "" + #: ports/raspberrypi/common-hal/rp2pio/StateMachine.c msgid "pull masks conflict with direction masks" msgstr "máscara de pull en conflicto con máscara de dirección" @@ -4107,10 +4112,6 @@ msgstr "trapz esta definido para matrices 1D" 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 "nivel de accionamiento debe ser 0 o 1" - #: py/obj.c msgid "tuple/list has wrong length" msgstr "tupla/lista tiene una longitud incorrecta" @@ -4245,10 +4246,6 @@ msgstr "el valor debe caber en %d byte(s)" msgid "value_count must be > 0" msgstr "value_count debe ser > 0" -#: ports/esp32s2/common-hal/alarm/pin/__init__.c -msgid "wakeup conflict" -msgstr "conflicto de wakeup" - #: ports/esp32s2/common-hal/watchdog/WatchDogTimer.c msgid "watchdog not initialized" msgstr "watchdog no inicializado" @@ -4335,6 +4332,32 @@ 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 "IOs 0, 2 & 4 do not support internal pullup in sleep" +#~ msgstr "IOs 0, 2 y 4 no soportan pullup interno durante sleep" + +#~ msgid "buffer must be a bytes-like object" +#~ msgstr "buffer debe de ser un objeto bytes-like" + +#~ msgid "io must be rtc io" +#~ msgstr "io debe ser rtc io" + +#~ msgid "trigger level must be 0 or 1" +#~ msgstr "nivel de accionamiento debe ser 0 o 1" + +#~ msgid "wakeup conflict" +#~ msgstr "conflicto de wakeup" + +#~ msgid "Attempted heap allocation when MicroPython VM not running." +#~ msgstr "" +#~ "Se intentó asignación del montículo, sin que la VM de MicroPython esté " +#~ "ejecutando." + +#~ msgid "MicroPython NLR jump failed. Likely memory corruption." +#~ msgstr "MicroPython NLR jump falló. Probable corrupción de la memoria." + +#~ msgid "MicroPython fatal error." +#~ msgstr "Error fatal de MicroPython." + #~ msgid "argument must be ndarray" #~ msgstr "argumento debe ser ndarray" diff --git a/locale/fil.po b/locale/fil.po index 23d1be9718..3248eb0ce2 100644 --- a/locale/fil.po +++ b/locale/fil.po @@ -441,7 +441,7 @@ msgid "Attempt to allocate %d blocks" msgstr "" #: supervisor/shared/safe_mode.c -msgid "Attempted heap allocation when MicroPython VM not running." +msgid "Attempted heap allocation when VM not running." msgstr "" #: shared-bindings/wifi/Radio.c @@ -890,6 +890,11 @@ msgstr "" msgid "EXTINT channel already in use" msgstr "Ginagamit na ang EXTINT channel" +#: shared-module/synthio/MidiTrack.c +#, c-format +msgid "Error in MIDI stream at position %d" +msgstr "" + #: extmod/modure.c msgid "Error in regex" msgstr "May pagkakamali sa REGEX" @@ -1021,6 +1026,10 @@ msgstr "Nabigo sa pagrelease ng mutex, status: 0x%08lX" msgid "Failed to write internal flash." msgstr "" +#: supervisor/shared/safe_mode.c +msgid "Fatal error." +msgstr "" + #: py/moduerrno.c msgid "File exists" msgstr "Mayroong file" @@ -1093,10 +1102,6 @@ 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" @@ -1222,6 +1227,10 @@ msgstr "" msgid "Invalid DAC pin supplied" msgstr "" +#: shared-bindings/synthio/__init__.c +msgid "Invalid MIDI file" +msgstr "" + #: ports/atmel-samd/common-hal/pwmio/PWMOut.c #: ports/cxd56/common-hal/pwmio/PWMOut.c #: ports/mimxrt10xx/common-hal/pwmio/PWMOut.c @@ -1413,14 +1422,6 @@ msgstr "" msgid "Messages limited to 8 bytes" msgstr "" -#: supervisor/shared/safe_mode.c -msgid "MicroPython NLR jump failed. Likely memory corruption." -msgstr "" - -#: supervisor/shared/safe_mode.c -msgid "MicroPython fatal error." -msgstr "" - #: shared-bindings/audiobusio/PDMIn.c msgid "Microphone startup delay must be in range 0.0 to 1.0" msgstr "Ang delay ng startup ng mikropono ay dapat na nasa 0.0 hanggang 1.0" @@ -1472,6 +1473,10 @@ msgstr "" msgid "Must use a multiple of 6 rgb pins, not %d" msgstr "" +#: supervisor/shared/safe_mode.c +msgid "NLR jump failed. Likely memory corruption." +msgstr "" + #: ports/esp32s2/common-hal/nvm/ByteArray.c msgid "NVS Error" msgstr "" @@ -1616,6 +1621,7 @@ msgstr "" msgid "Not a valid IP string" msgstr "" +#: ports/nrf/common-hal/_bleio/PacketBuffer.c #: ports/nrf/common-hal/_bleio/__init__.c #: shared-bindings/_bleio/CharacteristicBuffer.c #, fuzzy @@ -2523,10 +2529,6 @@ msgstr "branch wala sa range" msgid "buffer is smaller than requested size" msgstr "" -#: shared-bindings/audiocore/RawSample.c -msgid "buffer must be a bytes-like object" -msgstr "buffer ay dapat bytes-like object" - #: extmod/ulab/code/ulab_create.c extmod/ulab/code/utils/utils.c msgid "buffer size must be a multiple of element size" msgstr "" @@ -2980,7 +2982,7 @@ msgid "f-string: single '}' is not allowed" msgstr "" #: shared-bindings/audiocore/WaveFile.c shared-bindings/audiomp3/MP3Decoder.c -#: shared-bindings/displayio/OnDiskBitmap.c +#: shared-bindings/displayio/OnDiskBitmap.c shared-bindings/synthio/__init__.c msgid "file must be a file opened in byte mode" msgstr "file ay dapat buksan sa byte mode" @@ -3237,6 +3239,10 @@ msgstr "" msgid "invalid cert" msgstr "mali ang cert" +#: py/compile.c +msgid "invalid decorator" +msgstr "" + #: extmod/uos_dupterm.c msgid "invalid dupterm index" msgstr "mali ang dupterm index" @@ -3292,10 +3298,6 @@ 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" @@ -3761,6 +3763,7 @@ msgstr "pow() na may 3 argumento kailangan ng integers" #: ports/esp32s2/boards/adafruit_funhouse/mpconfigboard.h #: ports/esp32s2/boards/adafruit_magtag_2.9_grayscale/mpconfigboard.h #: ports/esp32s2/boards/adafruit_metro_esp32s2/mpconfigboard.h +#: ports/esp32s2/boards/artisense_rd00/mpconfigboard.h #: ports/esp32s2/boards/electroniccats_bastwifi/mpconfigboard.h #: ports/esp32s2/boards/espressif_kaluga_1/mpconfigboard.h #: ports/esp32s2/boards/espressif_saola_1_wroom/mpconfigboard.h @@ -3786,6 +3789,10 @@ msgstr "" msgid "pressing both buttons at start up.\n" msgstr "" +#: ports/nrf/boards/aramcon2_badge/mpconfigboard.h +msgid "pressing the left button at start up\n" +msgstr "" + #: ports/raspberrypi/common-hal/rp2pio/StateMachine.c msgid "pull masks conflict with direction masks" msgstr "" @@ -4063,10 +4070,6 @@ 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 "" - #: py/obj.c msgid "tuple/list has wrong length" msgstr "mali ang haba ng tuple/list" @@ -4201,10 +4204,6 @@ msgstr "" msgid "value_count must be > 0" 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 "" @@ -4293,6 +4292,9 @@ msgstr "" msgid "zi must be of shape (n_section, 2)" msgstr "" +#~ msgid "buffer must be a bytes-like object" +#~ msgstr "buffer ay dapat bytes-like object" + #~ msgid "Group full" #~ msgstr "Puno ang group" diff --git a/locale/fr.po b/locale/fr.po index 19d98f770a..eb56894ff2 100644 --- a/locale/fr.po +++ b/locale/fr.po @@ -8,7 +8,7 @@ msgstr "" "Project-Id-Version: 0.1\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2021-01-04 12:55-0600\n" -"PO-Revision-Date: 2021-04-03 21:57+0000\n" +"PO-Revision-Date: 2021-04-17 03:26+0000\n" "Last-Translator: Hugo Dahl \n" "Language: fr\n" "MIME-Version: 1.0\n" @@ -426,7 +426,7 @@ msgstr "'AnalogOut' n'est pas supporté sur la broche indiquée" #: ports/stm/common-hal/audiopwmio/PWMAudioOut.c msgid "Another PWMAudioOut is already active" -msgstr "" +msgstr "Un autre PWMAudioOut est déjà actif" #: ports/atmel-samd/common-hal/pulseio/PulseOut.c #: ports/cxd56/common-hal/pulseio/PulseOut.c @@ -435,11 +435,11 @@ msgstr "Un autre envoi est déjà actif" #: shared-bindings/pulseio/PulseOut.c msgid "Array must contain halfwords (type 'H')" -msgstr "Le tableau doit contenir des demi-mots (type 'H')" +msgstr "La matrice doit contenir des demi-mots (type 'H')" #: shared-bindings/alarm/SleepMemory.c shared-bindings/nvm/ByteArray.c msgid "Array values should be single bytes." -msgstr "Les valeurs du tableau doivent être des octets singuliers." +msgstr "Les valeurs de la matrice doivent être des octets singuliers." #: shared-bindings/microcontroller/Pin.c msgid "At most %d %q may be specified (not %d)" @@ -451,10 +451,10 @@ msgid "Attempt to allocate %d blocks" msgstr "Tentative d'allocation de %d blocs" #: supervisor/shared/safe_mode.c -msgid "Attempted heap allocation when MicroPython VM not running." +msgid "Attempted heap allocation when VM not running." msgstr "" -"Tentative d'allocation de segments lorsque la machine virtuelle MicroPython " -"n'est pas en cours d'exécution." +"Tentative d'allocation à la pile quand la Machine Virtuelle n'est pas en " +"exécution." #: shared-bindings/wifi/Radio.c msgid "Authentication failure" @@ -911,6 +911,11 @@ msgstr "ESP-IDF échec d'allocation de la mémoire" msgid "EXTINT channel already in use" msgstr "Canal EXTINT déjà utilisé" +#: shared-module/synthio/MidiTrack.c +#, c-format +msgid "Error in MIDI stream at position %d" +msgstr "Erreur dans le flot MIDI à la position %d" + #: extmod/modure.c msgid "Error in regex" msgstr "Erreur dans l'expression régulière" @@ -973,7 +978,7 @@ msgstr "La FFT est définie uniquement pour les ndarrays" #: extmod/ulab/code/numpy/fft/fft_tools.c msgid "FFT is implemented for linear arrays only" -msgstr "FFT n'est implémenté que pour les tableaux linéaires" +msgstr "FFT n'est implémenté que pour les matrices linéaires" #: ports/esp32s2/common-hal/ssl/SSLSocket.c msgid "Failed SSL handshake" @@ -1014,7 +1019,7 @@ msgstr "Impossible d'allouer la mémoire pour le scan wifi" #: ports/stm/common-hal/audiopwmio/PWMAudioOut.c msgid "Failed to buffer the sample" -msgstr "" +msgstr "Échec du tamponage de l'échantillon" #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Failed to connect: internal error" @@ -1041,6 +1046,10 @@ msgstr "Impossible de libérer mutex, err 0x%04x" msgid "Failed to write internal flash." msgstr "Échec de l'écriture vers flash interne." +#: supervisor/shared/safe_mode.c +msgid "Fatal error." +msgstr "Erreurre fatale." + #: py/moduerrno.c msgid "File exists" msgstr "Le fichier existe" @@ -1115,10 +1124,6 @@ msgstr "périphérique I2C utilisé" 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 "IOs 0, 2 & 4 ne supportent pas l'éleveuse interne en mode someil" - #: shared-bindings/aesio/aes.c #, c-format msgid "IV must be %d bytes long" @@ -1253,6 +1258,10 @@ msgstr "BSSID invalide" msgid "Invalid DAC pin supplied" msgstr "Broche DAC non valide fournie" +#: shared-bindings/synthio/__init__.c +msgid "Invalid MIDI file" +msgstr "Fichier MIDI invalide" + #: ports/atmel-samd/common-hal/pwmio/PWMOut.c #: ports/cxd56/common-hal/pwmio/PWMOut.c #: ports/mimxrt10xx/common-hal/pwmio/PWMOut.c @@ -1444,14 +1453,6 @@ msgstr "La valeur maximale de x est %d lors d'une opération miroir" msgid "Messages limited to 8 bytes" msgstr "Messages limités à 8 octets" -#: supervisor/shared/safe_mode.c -msgid "MicroPython NLR jump failed. Likely memory corruption." -msgstr "Échec du saut MicroPython NLR. Corruption de la mémoire probable." - -#: supervisor/shared/safe_mode.c -msgid "MicroPython fatal error." -msgstr "Erreur fatale MicroPython." - #: shared-bindings/audiobusio/PDMIn.c msgid "Microphone startup delay must be in range 0.0 to 1.0" msgstr "Le délais au démarrage du micro doit être entre 0.0 et 1.0" @@ -1505,6 +1506,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" +#: supervisor/shared/safe_mode.c +msgid "NLR jump failed. Likely memory corruption." +msgstr "Saut NLR échoué. Corruption de mémoire probable." + #: ports/esp32s2/common-hal/nvm/ByteArray.c msgid "NVS Error" msgstr "Erreur NVS" @@ -1649,6 +1654,7 @@ msgstr "Logiciel systême Nordic hors de mémoire" msgid "Not a valid IP string" msgstr "Chaîne IP non valide" +#: ports/nrf/common-hal/_bleio/PacketBuffer.c #: ports/nrf/common-hal/_bleio/__init__.c #: shared-bindings/_bleio/CharacteristicBuffer.c msgid "Not connected" @@ -2494,11 +2500,11 @@ msgstr "l'argument est une séquence vide" #: extmod/ulab/code/numpy/numerical/numerical.c msgid "argsort argument must be an ndarray" -msgstr "L'argument argsort doit être un ndarray" +msgstr "Le paramêtre argsort doit être un ndarray" #: extmod/ulab/code/numpy/numerical/numerical.c msgid "argsort is not implemented for flattened arrays" -msgstr "argsort n'est pas mis en œuvre pour les tableaux aplatis" +msgstr "argsort n'est pas mis en œuvre pour les matrices aplatis" #: py/runtime.c msgid "argument has wrong type" @@ -2520,12 +2526,12 @@ msgstr "les paramètres doivent être des ndarrays" #: extmod/ulab/code/ndarray.c msgid "array and index length must be equal" -msgstr "la longueur du tableau et de l'index doivent être égaux" +msgstr "la taille de la matrice et de l'index doivent être égaux" #: py/objarray.c shared-bindings/alarm/SleepMemory.c #: shared-bindings/nvm/ByteArray.c msgid "array/bytes required on right side" -msgstr "tableau/octets requis à droite" +msgstr "matrice/octets requis à la droite" #: extmod/ulab/code/numpy/numerical/numerical.c msgid "attempt to get (arg)min/(arg)max of empty sequence" @@ -2587,10 +2593,6 @@ msgstr "branche hors-bornes" msgid "buffer is smaller than requested size" msgstr "tampon est plus petit que la taille demandée" -#: shared-bindings/audiocore/RawSample.c -msgid "buffer must be a bytes-like object" -msgstr "le tampon doit être un objet bytes-like" - #: extmod/ulab/code/ulab_create.c extmod/ulab/code/utils/utils.c msgid "buffer size must be a multiple of element size" msgstr "taille du tampon doit être un multiple de la taille de l'élement" @@ -2828,8 +2830,7 @@ msgstr "" #: shared-bindings/displayio/Palette.c msgid "color buffer must be a bytearray or array of type 'b' or 'B'" -msgstr "" -"le tampon de couleur doit être un bytearray ou un tableau de type 'b' ou 'B'" +msgstr "tampon color doit être un bytearray ou une matrice de type 'b' ou 'B'" #: shared-bindings/displayio/Palette.c msgid "color must be between 0x000000 and 0xffffff" @@ -2861,11 +2862,11 @@ msgstr "conversion en objet" #: extmod/ulab/code/numpy/filter/filter.c msgid "convolve arguments must be linear arrays" -msgstr "les arguments convolve doivent être des tableaux linéaires" +msgstr "les paramêtres pour convolve doivent être des matrices linéaires" #: extmod/ulab/code/numpy/filter/filter.c msgid "convolve arguments must be ndarrays" -msgstr "les arguments convolve doivent être des ndarrays" +msgstr "les paramêtres pour convolve doivent être des ndarrays" #: extmod/ulab/code/numpy/filter/filter.c msgid "convolve arguments must not be empty" @@ -2881,7 +2882,7 @@ msgstr "impossible de déterminer la version de la carte SD" #: extmod/ulab/code/numpy/numerical/numerical.c msgid "cross is defined for 1D arrays of length 3" -msgstr "cross est défini pour les tableaux 1D de longueur 3" +msgstr "cross est défini pour les matrices 1D de longueur 3" #: extmod/ulab/code/scipy/optimize/optimize.c msgid "data must be iterable" @@ -2911,12 +2912,13 @@ msgstr "default n'est pas une fonction" msgid "" "destination buffer must be a bytearray or array of type 'B' for bit_depth = 8" msgstr "" -"le tampon de destination doit être un tableau de type 'B' pour bit_depth = 8" +"le tampon de destination doit être une matrice de type 'B' pour bit_depth = 8" #: shared-bindings/audiobusio/PDMIn.c msgid "destination buffer must be an array of type 'H' for bit_depth = 16" msgstr "" -"le tampon de destination doit être un tableau de type 'H' pour bit_depth = 16" +"le tampon de destination doit être une matrice de type 'H' pour bit_depth = " +"16" #: shared-bindings/audiobusio/PDMIn.c msgid "destination_length must be an int >= 0" @@ -2928,7 +2930,7 @@ msgstr "la séquence de mise à jour de dict a une mauvaise longueur" #: extmod/ulab/code/numpy/numerical/numerical.c msgid "diff argument must be an ndarray" -msgstr "l'argument diff doit être un ndarray" +msgstr "le paramêtre diff doit être un ndarray" #: extmod/ulab/code/numpy/numerical/numerical.c msgid "differentiation order out of range" @@ -3047,7 +3049,7 @@ msgid "f-string: single '}' is not allowed" msgstr "f-string : single '}' n'est pas autorisé" #: shared-bindings/audiocore/WaveFile.c shared-bindings/audiomp3/MP3Decoder.c -#: shared-bindings/displayio/OnDiskBitmap.c +#: shared-bindings/displayio/OnDiskBitmap.c shared-bindings/synthio/__init__.c msgid "file must be a file opened in byte mode" msgstr "le fichier doit être un fichier ouvert en mode 'byte'" @@ -3065,11 +3067,11 @@ msgstr "le premier argument doit être une fonction" #: extmod/ulab/code/ulab_create.c msgid "first argument must be a tuple of ndarrays" -msgstr "le premier argument doit être un tuple de ndarrays" +msgstr "le premier paramêtre doit être un tuple de ndarrays" #: extmod/ulab/code/numpy/vector/vector.c msgid "first argument must be an ndarray" -msgstr "le premier argument doit être un ndarray" +msgstr "le premier paramêtre doit être un ndarray" #: py/objtype.c msgid "first argument to super() must be type" @@ -3081,7 +3083,7 @@ msgstr "l'ordre d'aplatissement doit être «C» ou «F»" #: extmod/ulab/code/numpy/numerical/numerical.c msgid "flip argument must be an ndarray" -msgstr "l'argument flip doit être un ndarray" +msgstr "le paramêtre flip doit être un ndarray" #: py/objint.c msgid "float too big" @@ -3118,7 +3120,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 "La fonction n'est définie que pour les ndarrays" +msgstr "fonction définie que pour les ndarrays" #: py/argcheck.c #, c-format @@ -3224,11 +3226,11 @@ msgstr "Paramètre entrant doit être un chiffre entier, un tuple, ou une liste" #: extmod/ulab/code/numpy/fft/fft_tools.c msgid "input array length must be power of 2" -msgstr "la longueur du tableau d'entrée doit être une puissance de 2" +msgstr "longueur de la matrice d'entrée doit être une puissance de 2" #: extmod/ulab/code/ulab_create.c msgid "input arrays are not compatible" -msgstr "les tableaux d'entrée ne sont pas compatibles" +msgstr "les matrices d'entrée ne sont pas compatibles" #: extmod/ulab/code/numpy/poly/poly.c msgid "input data must be an iterable" @@ -3244,7 +3246,7 @@ msgstr "la matrice d'entrée est singulière" #: extmod/ulab/code/user/user.c msgid "input must be a dense ndarray" -msgstr "l'entrée doit être un tableau dense" +msgstr "l'entrée doit être un ndarray dense" #: extmod/ulab/code/ulab_create.c msgid "input must be a tensor of rank 2" @@ -3284,7 +3286,7 @@ msgstr "entier requis" #: extmod/ulab/code/numpy/approx/approx.c msgid "interp is defined for 1D arrays of equal length" -msgstr "interp est défini pour les tableaux 1D de longueur égale" +msgstr "interp est défini pour les matrices 1D de longueur égale" #: shared-bindings/_bleio/Adapter.c #, c-format @@ -3304,6 +3306,10 @@ msgstr "bits_per_pixel %d est invalid, doit être 1, 4, 8, 16, 24 ou 32" msgid "invalid cert" msgstr "certificat invalide" +#: py/compile.c +msgid "invalid decorator" +msgstr "décorateur invalide" + #: extmod/uos_dupterm.c msgid "invalid dupterm index" msgstr "index invalide pour dupterm" @@ -3359,10 +3365,6 @@ 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 "io doit être rtc io" - #: py/objtype.c msgid "issubclass() arg 1 must be a class" msgstr "l'argument 1 de issubclass() doit être une classe" @@ -3718,11 +3720,11 @@ 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 "opération implémentée que pour des tableaux 1D booléennes" +msgstr "opération implémentée que pour les matrices 1D booléennes" #: extmod/ulab/code/numpy/numerical/numerical.c msgid "operation is not implemented on ndarrays" -msgstr "l'opération n'est pas implémentée sur les ndarrays" +msgstr "l'opération n'est pas implémentée pour les ndarrays" #: extmod/ulab/code/ndarray.c msgid "operation is not supported for given type" @@ -3741,11 +3743,11 @@ msgstr "" #: extmod/ulab/code/utils/utils.c msgid "out array is too small" -msgstr "" +msgstr "matrice de sortie est trop petite" #: extmod/ulab/code/utils/utils.c msgid "out must be a float dense array" -msgstr "" +msgstr "la matrice sortante doit être de type float" #: shared-bindings/displayio/Bitmap.c msgid "out of range of source" @@ -3831,6 +3833,7 @@ msgstr "pow() avec 3 arguments nécessite des entiers" #: ports/esp32s2/boards/adafruit_funhouse/mpconfigboard.h #: ports/esp32s2/boards/adafruit_magtag_2.9_grayscale/mpconfigboard.h #: ports/esp32s2/boards/adafruit_metro_esp32s2/mpconfigboard.h +#: ports/esp32s2/boards/artisense_rd00/mpconfigboard.h #: ports/esp32s2/boards/electroniccats_bastwifi/mpconfigboard.h #: ports/esp32s2/boards/espressif_kaluga_1/mpconfigboard.h #: ports/esp32s2/boards/espressif_saola_1_wroom/mpconfigboard.h @@ -3856,6 +3859,10 @@ msgstr "bouton boot appuyé lors du démarrage.\n" msgid "pressing both buttons at start up.\n" msgstr "les deux boutons appuyés lors du démarrage.\n" +#: ports/nrf/boards/aramcon2_badge/mpconfigboard.h +msgid "pressing the left button at start up\n" +msgstr "" + #: ports/raspberrypi/common-hal/rp2pio/StateMachine.c msgid "pull masks conflict with direction masks" msgstr "masque pull est en conflit avec les masques de direction" @@ -3924,8 +3931,8 @@ msgid "" "sample_source buffer must be a bytearray or array of type 'h', 'H', 'b' or " "'B'" msgstr "" -"le tampon de sample_source doit être un bytearray ou un tableau de type " -"'h','H', 'b' ou 'B'" +"tampon sample_source doit être un bytearray ou une matrice de type 'h', 'H', " +"'b' ou 'B'" #: ports/atmel-samd/common-hal/audiobusio/PDMIn.c #: ports/raspberrypi/common-hal/audiobusio/PDMIn.c @@ -3962,7 +3969,7 @@ msgstr "'}' seule rencontrée dans une chaîne de format" #: extmod/ulab/code/ulab_tools.c msgid "size is defined for ndarrays only" -msgstr "la taille est définie pour les ndarrays uniquement" +msgstr "la taille n'est définie que pour les ndarrays" #: shared-bindings/time/__init__.c msgid "sleep length must be non-negative" @@ -3986,11 +3993,11 @@ msgstr "redémarrage logiciel\n" #: extmod/ulab/code/numpy/numerical/numerical.c msgid "sort argument must be an ndarray" -msgstr "l'argument de «sort» doit être un ndarray" +msgstr "le paramètre de «sort» doit être un ndarray" #: extmod/ulab/code/scipy/signal/signal.c msgid "sos array must be of shape (n_section, 6)" -msgstr "le tableau sos doit être de forme (n_section, 6)" +msgstr "la matrice sos doit être de forme (n_section, 6)" #: extmod/ulab/code/scipy/signal/signal.c msgid "sos[:, 3] should be all ones" @@ -4035,7 +4042,7 @@ msgstr "les indices d'une chaîne doivent être des entiers, pas %q" #: py/stream.c msgid "string not supported; use bytes or bytearray" msgstr "" -"chaîne de carac. non supportée ; utilisez des bytes ou un tableau de bytes" +"chaîne de carac. non supportée; utilisez des bytes ou une matrice de bytes" #: extmod/moductypes.c msgid "struct: cannot index" @@ -4105,7 +4112,7 @@ 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 "tobytes ne peut être appelé que pour des tableaux dense" +msgstr "tobytes ne peut être appelée que pour des matrices dense" #: shared-module/struct/__init__.c msgid "too many arguments provided with the given format" @@ -4126,15 +4133,11 @@ msgstr "trop de valeur à dégrouper (%d attendues)" #: extmod/ulab/code/numpy/approx/approx.c msgid "trapz is defined for 1D arrays" -msgstr "trapz est défini pour tableaux à une dimension" +msgstr "trapz est définie pour matrices à une dimension" #: extmod/ulab/code/numpy/approx/approx.c 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 "niveau du déclencheur doit être 0 ou 1" +msgstr "trapz n'est défini que pour des matrices 1D de longueur égales" #: py/obj.c msgid "tuple/list has wrong length" @@ -4270,10 +4273,6 @@ msgstr "la valeur doit tenir dans %d octet(s)" msgid "value_count must be > 0" msgstr "'value_count' doit être > 0" -#: ports/esp32s2/common-hal/alarm/pin/__init__.c -msgid "wakeup conflict" -msgstr "conflit au réveil" - #: ports/esp32s2/common-hal/watchdog/WatchDogTimer.c msgid "watchdog not initialized" msgstr "chien de garde (watchdog) non initialisé" @@ -4350,7 +4349,7 @@ msgstr "'step' nul" #: extmod/ulab/code/scipy/signal/signal.c msgid "zi must be an ndarray" -msgstr "zi doit être ndarray" +msgstr "zi doit être un ndarray" #: extmod/ulab/code/scipy/signal/signal.c msgid "zi must be of float type" @@ -4360,6 +4359,32 @@ 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 "IOs 0, 2 & 4 do not support internal pullup in sleep" +#~ msgstr "IOs 0, 2 & 4 ne supportent pas l'éleveuse interne en mode someil" + +#~ msgid "buffer must be a bytes-like object" +#~ msgstr "le tampon doit être un objet bytes-like" + +#~ msgid "io must be rtc io" +#~ msgstr "io doit être rtc io" + +#~ msgid "trigger level must be 0 or 1" +#~ msgstr "niveau du déclencheur doit être 0 ou 1" + +#~ msgid "wakeup conflict" +#~ msgstr "conflit au réveil" + +#~ msgid "Attempted heap allocation when MicroPython VM not running." +#~ msgstr "" +#~ "Tentative d'allocation de segments lorsque la machine virtuelle " +#~ "MicroPython n'est pas en cours d'exécution." + +#~ msgid "MicroPython NLR jump failed. Likely memory corruption." +#~ msgstr "Échec du saut MicroPython NLR. Corruption de la mémoire probable." + +#~ msgid "MicroPython fatal error." +#~ msgstr "Erreur fatale MicroPython." + #~ msgid "argument must be ndarray" #~ msgstr "l'argument doit être un ndarray" diff --git a/locale/hi.po b/locale/hi.po index 388a85472b..b1a5c0d5dd 100644 --- a/locale/hi.po +++ b/locale/hi.po @@ -438,7 +438,7 @@ msgid "Attempt to allocate %d blocks" msgstr "" #: supervisor/shared/safe_mode.c -msgid "Attempted heap allocation when MicroPython VM not running." +msgid "Attempted heap allocation when VM not running." msgstr "" #: shared-bindings/wifi/Radio.c @@ -879,6 +879,11 @@ msgstr "" msgid "EXTINT channel already in use" msgstr "" +#: shared-module/synthio/MidiTrack.c +#, c-format +msgid "Error in MIDI stream at position %d" +msgstr "" + #: extmod/modure.c msgid "Error in regex" msgstr "" @@ -1008,6 +1013,10 @@ msgstr "" msgid "Failed to write internal flash." msgstr "" +#: supervisor/shared/safe_mode.c +msgid "Fatal error." +msgstr "" + #: py/moduerrno.c msgid "File exists" msgstr "" @@ -1080,10 +1089,6 @@ 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" @@ -1207,6 +1212,10 @@ msgstr "" msgid "Invalid DAC pin supplied" msgstr "" +#: shared-bindings/synthio/__init__.c +msgid "Invalid MIDI file" +msgstr "" + #: ports/atmel-samd/common-hal/pwmio/PWMOut.c #: ports/cxd56/common-hal/pwmio/PWMOut.c #: ports/mimxrt10xx/common-hal/pwmio/PWMOut.c @@ -1398,14 +1407,6 @@ msgstr "" msgid "Messages limited to 8 bytes" msgstr "" -#: supervisor/shared/safe_mode.c -msgid "MicroPython NLR jump failed. Likely memory corruption." -msgstr "" - -#: supervisor/shared/safe_mode.c -msgid "MicroPython fatal error." -msgstr "" - #: shared-bindings/audiobusio/PDMIn.c msgid "Microphone startup delay must be in range 0.0 to 1.0" msgstr "" @@ -1457,6 +1458,10 @@ msgstr "" msgid "Must use a multiple of 6 rgb pins, not %d" msgstr "" +#: supervisor/shared/safe_mode.c +msgid "NLR jump failed. Likely memory corruption." +msgstr "" + #: ports/esp32s2/common-hal/nvm/ByteArray.c msgid "NVS Error" msgstr "" @@ -1601,6 +1606,7 @@ msgstr "" msgid "Not a valid IP string" msgstr "" +#: ports/nrf/common-hal/_bleio/PacketBuffer.c #: ports/nrf/common-hal/_bleio/__init__.c #: shared-bindings/_bleio/CharacteristicBuffer.c msgid "Not connected" @@ -2493,10 +2499,6 @@ msgstr "" msgid "buffer is smaller than requested size" msgstr "" -#: shared-bindings/audiocore/RawSample.c -msgid "buffer must be a bytes-like object" -msgstr "" - #: extmod/ulab/code/ulab_create.c extmod/ulab/code/utils/utils.c msgid "buffer size must be a multiple of element size" msgstr "" @@ -2938,7 +2940,7 @@ msgid "f-string: single '}' is not allowed" msgstr "" #: shared-bindings/audiocore/WaveFile.c shared-bindings/audiomp3/MP3Decoder.c -#: shared-bindings/displayio/OnDiskBitmap.c +#: shared-bindings/displayio/OnDiskBitmap.c shared-bindings/synthio/__init__.c msgid "file must be a file opened in byte mode" msgstr "" @@ -3194,6 +3196,10 @@ msgstr "" msgid "invalid cert" msgstr "" +#: py/compile.c +msgid "invalid decorator" +msgstr "" + #: extmod/uos_dupterm.c msgid "invalid dupterm index" msgstr "" @@ -3249,10 +3255,6 @@ 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 "" @@ -3712,6 +3714,7 @@ msgstr "" #: ports/esp32s2/boards/adafruit_funhouse/mpconfigboard.h #: ports/esp32s2/boards/adafruit_magtag_2.9_grayscale/mpconfigboard.h #: ports/esp32s2/boards/adafruit_metro_esp32s2/mpconfigboard.h +#: ports/esp32s2/boards/artisense_rd00/mpconfigboard.h #: ports/esp32s2/boards/electroniccats_bastwifi/mpconfigboard.h #: ports/esp32s2/boards/espressif_kaluga_1/mpconfigboard.h #: ports/esp32s2/boards/espressif_saola_1_wroom/mpconfigboard.h @@ -3737,6 +3740,10 @@ msgstr "" msgid "pressing both buttons at start up.\n" msgstr "" +#: ports/nrf/boards/aramcon2_badge/mpconfigboard.h +msgid "pressing the left button at start up\n" +msgstr "" + #: ports/raspberrypi/common-hal/rp2pio/StateMachine.c msgid "pull masks conflict with direction masks" msgstr "" @@ -4010,10 +4017,6 @@ 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 "" - #: py/obj.c msgid "tuple/list has wrong length" msgstr "" @@ -4148,10 +4151,6 @@ msgstr "" msgid "value_count must be > 0" 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 241b07d7ec..a9865b99bf 100644 --- a/locale/it_IT.po +++ b/locale/it_IT.po @@ -450,8 +450,8 @@ msgid "Attempt to allocate %d blocks" msgstr "Provo ad allocare %d blocchi" #: supervisor/shared/safe_mode.c -msgid "Attempted heap allocation when MicroPython VM not running." -msgstr "Provo l'allocazione quando MicroPython VM non è attivo." +msgid "Attempted heap allocation when VM not running." +msgstr "" #: shared-bindings/wifi/Radio.c msgid "Authentication failure" @@ -899,6 +899,11 @@ msgstr "" msgid "EXTINT channel already in use" msgstr "Canale EXTINT già in uso" +#: shared-module/synthio/MidiTrack.c +#, c-format +msgid "Error in MIDI stream at position %d" +msgstr "" + #: extmod/modure.c msgid "Error in regex" msgstr "Errore nella regex" @@ -1030,6 +1035,10 @@ msgstr "Impossibile rilasciare il mutex, err 0x%04x" msgid "Failed to write internal flash." msgstr "" +#: supervisor/shared/safe_mode.c +msgid "Fatal error." +msgstr "" + #: py/moduerrno.c msgid "File exists" msgstr "File esistente" @@ -1102,10 +1111,6 @@ 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" @@ -1231,6 +1236,10 @@ msgstr "" msgid "Invalid DAC pin supplied" msgstr "" +#: shared-bindings/synthio/__init__.c +msgid "Invalid MIDI file" +msgstr "" + #: ports/atmel-samd/common-hal/pwmio/PWMOut.c #: ports/cxd56/common-hal/pwmio/PWMOut.c #: ports/mimxrt10xx/common-hal/pwmio/PWMOut.c @@ -1425,14 +1434,6 @@ msgstr "Valore massimo di x quando rispachiato è %d" msgid "Messages limited to 8 bytes" msgstr "" -#: supervisor/shared/safe_mode.c -msgid "MicroPython NLR jump failed. Likely memory corruption." -msgstr "" - -#: supervisor/shared/safe_mode.c -msgid "MicroPython fatal error." -msgstr "" - #: shared-bindings/audiobusio/PDMIn.c msgid "Microphone startup delay must be in range 0.0 to 1.0" msgstr "" @@ -1485,6 +1486,10 @@ msgstr "" msgid "Must use a multiple of 6 rgb pins, not %d" msgstr "" +#: supervisor/shared/safe_mode.c +msgid "NLR jump failed. Likely memory corruption." +msgstr "" + #: ports/esp32s2/common-hal/nvm/ByteArray.c msgid "NVS Error" msgstr "" @@ -1629,6 +1634,7 @@ msgstr "" msgid "Not a valid IP string" msgstr "" +#: ports/nrf/common-hal/_bleio/PacketBuffer.c #: ports/nrf/common-hal/_bleio/__init__.c #: shared-bindings/_bleio/CharacteristicBuffer.c #, fuzzy @@ -2538,10 +2544,6 @@ msgstr "argomento di chr() non è in range(256)" msgid "buffer is smaller than requested size" msgstr "" -#: shared-bindings/audiocore/RawSample.c -msgid "buffer must be a bytes-like object" -msgstr "" - #: extmod/ulab/code/ulab_create.c extmod/ulab/code/utils/utils.c msgid "buffer size must be a multiple of element size" msgstr "" @@ -2991,7 +2993,7 @@ msgid "f-string: single '}' is not allowed" msgstr "" #: shared-bindings/audiocore/WaveFile.c shared-bindings/audiomp3/MP3Decoder.c -#: shared-bindings/displayio/OnDiskBitmap.c +#: shared-bindings/displayio/OnDiskBitmap.c shared-bindings/synthio/__init__.c msgid "file must be a file opened in byte mode" msgstr "" @@ -3248,6 +3250,10 @@ msgstr "" msgid "invalid cert" msgstr "certificato non valido" +#: py/compile.c +msgid "invalid decorator" +msgstr "" + #: extmod/uos_dupterm.c msgid "invalid dupterm index" msgstr "indice dupterm non valido" @@ -3303,10 +3309,6 @@ 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" @@ -3778,6 +3780,7 @@ msgstr "pow() con 3 argomenti richiede interi" #: ports/esp32s2/boards/adafruit_funhouse/mpconfigboard.h #: ports/esp32s2/boards/adafruit_magtag_2.9_grayscale/mpconfigboard.h #: ports/esp32s2/boards/adafruit_metro_esp32s2/mpconfigboard.h +#: ports/esp32s2/boards/artisense_rd00/mpconfigboard.h #: ports/esp32s2/boards/electroniccats_bastwifi/mpconfigboard.h #: ports/esp32s2/boards/espressif_kaluga_1/mpconfigboard.h #: ports/esp32s2/boards/espressif_saola_1_wroom/mpconfigboard.h @@ -3803,6 +3806,10 @@ msgstr "" msgid "pressing both buttons at start up.\n" msgstr "" +#: ports/nrf/boards/aramcon2_badge/mpconfigboard.h +msgid "pressing the left button at start up\n" +msgstr "" + #: ports/raspberrypi/common-hal/rp2pio/StateMachine.c msgid "pull masks conflict with direction masks" msgstr "" @@ -4080,10 +4087,6 @@ 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 "" - #: py/obj.c msgid "tuple/list has wrong length" msgstr "tupla/lista ha la lunghezza sbagliata" @@ -4218,10 +4221,6 @@ msgstr "" msgid "value_count must be > 0" 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 "" @@ -4310,6 +4309,9 @@ msgstr "" msgid "zi must be of shape (n_section, 2)" msgstr "" +#~ msgid "Attempted heap allocation when MicroPython VM not running." +#~ msgstr "Provo l'allocazione quando MicroPython VM non è attivo." + #~ msgid "Group full" #~ msgstr "Gruppo pieno" diff --git a/locale/ja.po b/locale/ja.po index e2b5d926af..36b19d14c5 100644 --- a/locale/ja.po +++ b/locale/ja.po @@ -443,8 +443,8 @@ msgid "Attempt to allocate %d blocks" msgstr "%d個のブロックの確保を試みました" #: supervisor/shared/safe_mode.c -msgid "Attempted heap allocation when MicroPython VM not running." -msgstr "MicroPython VMの非実行時にヒープ確保を試みました" +msgid "Attempted heap allocation when VM not running." +msgstr "" #: shared-bindings/wifi/Radio.c msgid "Authentication failure" @@ -890,6 +890,11 @@ msgstr "" msgid "EXTINT channel already in use" msgstr "EXTINTチャネルはすでに使用されています" +#: shared-module/synthio/MidiTrack.c +#, c-format +msgid "Error in MIDI stream at position %d" +msgstr "" + #: extmod/modure.c msgid "Error in regex" msgstr "正規表現にエラーがあります" @@ -1019,6 +1024,10 @@ msgstr "ミューテックスの開放に失敗。エラー 0x%04x" msgid "Failed to write internal flash." msgstr "内部フラッシュ書き込みに失敗" +#: supervisor/shared/safe_mode.c +msgid "Fatal error." +msgstr "" + #: py/moduerrno.c msgid "File exists" msgstr "ファイルが存在します" @@ -1091,10 +1100,6 @@ msgstr "" 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" @@ -1220,6 +1225,10 @@ msgstr "不正なBSSID" msgid "Invalid DAC pin supplied" msgstr "不正なDACピンが与えられました" +#: shared-bindings/synthio/__init__.c +msgid "Invalid MIDI file" +msgstr "" + #: ports/atmel-samd/common-hal/pwmio/PWMOut.c #: ports/cxd56/common-hal/pwmio/PWMOut.c #: ports/mimxrt10xx/common-hal/pwmio/PWMOut.c @@ -1411,14 +1420,6 @@ msgstr "" msgid "Messages limited to 8 bytes" msgstr "" -#: supervisor/shared/safe_mode.c -msgid "MicroPython NLR jump failed. Likely memory corruption." -msgstr "MicroPython NLRジャンプ失敗。メモリ破壊の可能性あり" - -#: supervisor/shared/safe_mode.c -msgid "MicroPython fatal error." -msgstr "MicroPython致命的エラー" - #: shared-bindings/audiobusio/PDMIn.c msgid "Microphone startup delay must be in range 0.0 to 1.0" msgstr "マイクのスタートアップディレイは 0.0 から 1.0 の間でなければなりません" @@ -1470,6 +1471,10 @@ msgstr "MISOピンまたはMOSIピンが必要" msgid "Must use a multiple of 6 rgb pins, not %d" msgstr "%d個でなく6の倍数個のrgbピンを使ってください" +#: supervisor/shared/safe_mode.c +msgid "NLR jump failed. Likely memory corruption." +msgstr "" + #: ports/esp32s2/common-hal/nvm/ByteArray.c msgid "NVS Error" msgstr "" @@ -1614,6 +1619,7 @@ msgstr "" msgid "Not a valid IP string" msgstr "不正なIP文字列です" +#: ports/nrf/common-hal/_bleio/PacketBuffer.c #: ports/nrf/common-hal/_bleio/__init__.c #: shared-bindings/_bleio/CharacteristicBuffer.c msgid "Not connected" @@ -2516,10 +2522,6 @@ msgstr "" msgid "buffer is smaller than requested size" msgstr "" -#: shared-bindings/audiocore/RawSample.c -msgid "buffer must be a bytes-like object" -msgstr "バッファはbytes-likeオブジェクトでなければなりません" - #: extmod/ulab/code/ulab_create.c extmod/ulab/code/utils/utils.c msgid "buffer size must be a multiple of element size" msgstr "" @@ -2965,7 +2967,7 @@ msgid "f-string: single '}' is not allowed" msgstr "f-string: 1つだけの'}'は許されません" #: shared-bindings/audiocore/WaveFile.c shared-bindings/audiomp3/MP3Decoder.c -#: shared-bindings/displayio/OnDiskBitmap.c +#: shared-bindings/displayio/OnDiskBitmap.c shared-bindings/synthio/__init__.c msgid "file must be a file opened in byte mode" msgstr "fileはバイトモードで開かれたファイルでなければなりません" @@ -3222,6 +3224,10 @@ msgstr "" msgid "invalid cert" msgstr "不正な証明書" +#: py/compile.c +msgid "invalid decorator" +msgstr "" + #: extmod/uos_dupterm.c msgid "invalid dupterm index" msgstr "不正なduptermインデクス" @@ -3277,10 +3283,6 @@ 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引数はクラスでなければなりません" @@ -3742,6 +3744,7 @@ msgstr "pow()の第3引数には整数が必要" #: ports/esp32s2/boards/adafruit_funhouse/mpconfigboard.h #: ports/esp32s2/boards/adafruit_magtag_2.9_grayscale/mpconfigboard.h #: ports/esp32s2/boards/adafruit_metro_esp32s2/mpconfigboard.h +#: ports/esp32s2/boards/artisense_rd00/mpconfigboard.h #: ports/esp32s2/boards/electroniccats_bastwifi/mpconfigboard.h #: ports/esp32s2/boards/espressif_kaluga_1/mpconfigboard.h #: ports/esp32s2/boards/espressif_saola_1_wroom/mpconfigboard.h @@ -3767,6 +3770,10 @@ msgstr "" msgid "pressing both buttons at start up.\n" msgstr "" +#: ports/nrf/boards/aramcon2_badge/mpconfigboard.h +msgid "pressing the left button at start up\n" +msgstr "" + #: ports/raspberrypi/common-hal/rp2pio/StateMachine.c msgid "pull masks conflict with direction masks" msgstr "" @@ -4041,10 +4048,6 @@ msgstr "" 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 "" - #: py/obj.c msgid "tuple/list has wrong length" msgstr "タプル/リストの長さが正しくありません" @@ -4179,10 +4182,6 @@ msgstr "値は%dバイトに収まらなければなりません" msgid "value_count must be > 0" msgstr "value_countは0より大きくなければなりません" -#: ports/esp32s2/common-hal/alarm/pin/__init__.c -msgid "wakeup conflict" -msgstr "" - #: ports/esp32s2/common-hal/watchdog/WatchDogTimer.c msgid "watchdog not initialized" msgstr "" @@ -4269,6 +4268,18 @@ msgstr "ziはfloat値でなければなりません" msgid "zi must be of shape (n_section, 2)" msgstr "" +#~ msgid "buffer must be a bytes-like object" +#~ msgstr "バッファはbytes-likeオブジェクトでなければなりません" + +#~ msgid "Attempted heap allocation when MicroPython VM not running." +#~ msgstr "MicroPython VMの非実行時にヒープ確保を試みました" + +#~ msgid "MicroPython NLR jump failed. Likely memory corruption." +#~ msgstr "MicroPython NLRジャンプ失敗。メモリ破壊の可能性あり" + +#~ msgid "MicroPython fatal error." +#~ msgstr "MicroPython致命的エラー" + #~ msgid "argument must be ndarray" #~ msgstr "引数はndarrayでなければなりません" diff --git a/locale/ko.po b/locale/ko.po index 3b8eeebe6d..fe5ce58d9a 100644 --- a/locale/ko.po +++ b/locale/ko.po @@ -439,7 +439,7 @@ msgid "Attempt to allocate %d blocks" msgstr "" #: supervisor/shared/safe_mode.c -msgid "Attempted heap allocation when MicroPython VM not running." +msgid "Attempted heap allocation when VM not running." msgstr "" #: shared-bindings/wifi/Radio.c @@ -882,6 +882,11 @@ msgstr "" msgid "EXTINT channel already in use" msgstr "" +#: shared-module/synthio/MidiTrack.c +#, c-format +msgid "Error in MIDI stream at position %d" +msgstr "" + #: extmod/modure.c msgid "Error in regex" msgstr "Regex에 오류가 있습니다." @@ -1011,6 +1016,10 @@ msgstr "" msgid "Failed to write internal flash." msgstr "" +#: supervisor/shared/safe_mode.c +msgid "Fatal error." +msgstr "" + #: py/moduerrno.c msgid "File exists" msgstr "" @@ -1083,10 +1092,6 @@ 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" @@ -1210,6 +1215,10 @@ msgstr "" msgid "Invalid DAC pin supplied" msgstr "" +#: shared-bindings/synthio/__init__.c +msgid "Invalid MIDI file" +msgstr "" + #: ports/atmel-samd/common-hal/pwmio/PWMOut.c #: ports/cxd56/common-hal/pwmio/PWMOut.c #: ports/mimxrt10xx/common-hal/pwmio/PWMOut.c @@ -1401,14 +1410,6 @@ msgstr "" msgid "Messages limited to 8 bytes" msgstr "" -#: supervisor/shared/safe_mode.c -msgid "MicroPython NLR jump failed. Likely memory corruption." -msgstr "" - -#: supervisor/shared/safe_mode.c -msgid "MicroPython fatal error." -msgstr "" - #: shared-bindings/audiobusio/PDMIn.c msgid "Microphone startup delay must be in range 0.0 to 1.0" msgstr "" @@ -1460,6 +1461,10 @@ msgstr "" msgid "Must use a multiple of 6 rgb pins, not %d" msgstr "" +#: supervisor/shared/safe_mode.c +msgid "NLR jump failed. Likely memory corruption." +msgstr "" + #: ports/esp32s2/common-hal/nvm/ByteArray.c msgid "NVS Error" msgstr "" @@ -1604,6 +1609,7 @@ msgstr "" msgid "Not a valid IP string" msgstr "" +#: ports/nrf/common-hal/_bleio/PacketBuffer.c #: ports/nrf/common-hal/_bleio/__init__.c #: shared-bindings/_bleio/CharacteristicBuffer.c msgid "Not connected" @@ -2497,10 +2503,6 @@ msgstr "" msgid "buffer is smaller than requested size" msgstr "" -#: shared-bindings/audiocore/RawSample.c -msgid "buffer must be a bytes-like object" -msgstr "" - #: extmod/ulab/code/ulab_create.c extmod/ulab/code/utils/utils.c msgid "buffer size must be a multiple of element size" msgstr "" @@ -2942,7 +2944,7 @@ msgid "f-string: single '}' is not allowed" msgstr "" #: shared-bindings/audiocore/WaveFile.c shared-bindings/audiomp3/MP3Decoder.c -#: shared-bindings/displayio/OnDiskBitmap.c +#: shared-bindings/displayio/OnDiskBitmap.c shared-bindings/synthio/__init__.c msgid "file must be a file opened in byte mode" msgstr "" @@ -3198,6 +3200,10 @@ msgstr "" msgid "invalid cert" msgstr "cert가 유효하지 않습니다" +#: py/compile.c +msgid "invalid decorator" +msgstr "" + #: extmod/uos_dupterm.c msgid "invalid dupterm index" msgstr "Dupterm index가 유효하지 않습니다" @@ -3253,10 +3259,6 @@ 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 "" @@ -3716,6 +3718,7 @@ msgstr "" #: ports/esp32s2/boards/adafruit_funhouse/mpconfigboard.h #: ports/esp32s2/boards/adafruit_magtag_2.9_grayscale/mpconfigboard.h #: ports/esp32s2/boards/adafruit_metro_esp32s2/mpconfigboard.h +#: ports/esp32s2/boards/artisense_rd00/mpconfigboard.h #: ports/esp32s2/boards/electroniccats_bastwifi/mpconfigboard.h #: ports/esp32s2/boards/espressif_kaluga_1/mpconfigboard.h #: ports/esp32s2/boards/espressif_saola_1_wroom/mpconfigboard.h @@ -3741,6 +3744,10 @@ msgstr "" msgid "pressing both buttons at start up.\n" msgstr "" +#: ports/nrf/boards/aramcon2_badge/mpconfigboard.h +msgid "pressing the left button at start up\n" +msgstr "" + #: ports/raspberrypi/common-hal/rp2pio/StateMachine.c msgid "pull masks conflict with direction masks" msgstr "" @@ -4014,10 +4021,6 @@ 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 "" - #: py/obj.c msgid "tuple/list has wrong length" msgstr "" @@ -4152,10 +4155,6 @@ msgstr "" msgid "value_count must be > 0" 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 3285f52150..27f12fba3a 100644 --- a/locale/nl.po +++ b/locale/nl.po @@ -441,8 +441,8 @@ msgid "Attempt to allocate %d blocks" msgstr "Poging om %d blokken toe te wijzen" #: supervisor/shared/safe_mode.c -msgid "Attempted heap allocation when MicroPython VM not running." -msgstr "heap allocatie geprobeerd terwijl MicroPython VM niet draait." +msgid "Attempted heap allocation when VM not running." +msgstr "" #: shared-bindings/wifi/Radio.c msgid "Authentication failure" @@ -890,6 +890,11 @@ msgstr "ESP-IDF geheugen toewijzing mislukt" msgid "EXTINT channel already in use" msgstr "EXTINT kanaal al in gebruik" +#: shared-module/synthio/MidiTrack.c +#, c-format +msgid "Error in MIDI stream at position %d" +msgstr "" + #: extmod/modure.c msgid "Error in regex" msgstr "Fout in regex" @@ -1019,6 +1024,10 @@ msgstr "Mislukt mutex los te laten, err 0x%04x" msgid "Failed to write internal flash." msgstr "Schrijven naar interne flash mislukt." +#: supervisor/shared/safe_mode.c +msgid "Fatal error." +msgstr "" + #: py/moduerrno.c msgid "File exists" msgstr "Bestand bestaat" @@ -1092,10 +1101,6 @@ msgstr "" 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 "IO's 0, 2 en 4 ondersteunen geen interne pullup in slaapstand" - #: shared-bindings/aesio/aes.c #, c-format msgid "IV must be %d bytes long" @@ -1221,6 +1226,10 @@ msgstr "Ongeldig BSSID" msgid "Invalid DAC pin supplied" msgstr "Ongeldige DAC pin opgegeven" +#: shared-bindings/synthio/__init__.c +msgid "Invalid MIDI file" +msgstr "" + #: ports/atmel-samd/common-hal/pwmio/PWMOut.c #: ports/cxd56/common-hal/pwmio/PWMOut.c #: ports/mimxrt10xx/common-hal/pwmio/PWMOut.c @@ -1412,14 +1421,6 @@ msgstr "Maximale x waarde indien gespiegeld is %d" msgid "Messages limited to 8 bytes" msgstr "Berichten zijn beperkt tot 8 bytes" -#: supervisor/shared/safe_mode.c -msgid "MicroPython NLR jump failed. Likely memory corruption." -msgstr "MicroPython NLR sprong mislukt. Waarschijnlijk geheugen corruptie." - -#: supervisor/shared/safe_mode.c -msgid "MicroPython fatal error." -msgstr "MicroPython fatale fout." - #: shared-bindings/audiobusio/PDMIn.c msgid "Microphone startup delay must be in range 0.0 to 1.0" msgstr "Microfoon opstart vertraging moet in bereik van 0.0 tot 1.0 zijn" @@ -1471,6 +1472,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" +#: supervisor/shared/safe_mode.c +msgid "NLR jump failed. Likely memory corruption." +msgstr "" + #: ports/esp32s2/common-hal/nvm/ByteArray.c msgid "NVS Error" msgstr "NVS-fout" @@ -1615,6 +1620,7 @@ msgstr "" msgid "Not a valid IP string" msgstr "Geen geldige IP string" +#: ports/nrf/common-hal/_bleio/PacketBuffer.c #: ports/nrf/common-hal/_bleio/__init__.c #: shared-bindings/_bleio/CharacteristicBuffer.c msgid "Not connected" @@ -2544,10 +2550,6 @@ msgstr "pad (branch) niet binnen bereik" msgid "buffer is smaller than requested size" msgstr "" -#: shared-bindings/audiocore/RawSample.c -msgid "buffer must be a bytes-like object" -msgstr "buffer moet een byte-achtig object zijn" - #: extmod/ulab/code/ulab_create.c extmod/ulab/code/utils/utils.c msgid "buffer size must be a multiple of element size" msgstr "" @@ -2993,7 +2995,7 @@ msgid "f-string: single '}' is not allowed" msgstr "f-string: enkele '}' is niet toegestaan" #: shared-bindings/audiocore/WaveFile.c shared-bindings/audiomp3/MP3Decoder.c -#: shared-bindings/displayio/OnDiskBitmap.c +#: shared-bindings/displayio/OnDiskBitmap.c shared-bindings/synthio/__init__.c msgid "file must be a file opened in byte mode" msgstr "bestand moet een bestand zijn geopend in byte modus" @@ -3250,6 +3252,10 @@ msgstr "" msgid "invalid cert" msgstr "ongeldig certificaat" +#: py/compile.c +msgid "invalid decorator" +msgstr "" + #: extmod/uos_dupterm.c msgid "invalid dupterm index" msgstr "ongeldige dupterm index" @@ -3305,10 +3311,6 @@ 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 "io moet rtc io zijn" - #: py/objtype.c msgid "issubclass() arg 1 must be a class" msgstr "issubclass() argument 1 moet een klasse zijn" @@ -3772,6 +3774,7 @@ msgstr "pow() met 3 argumenten vereist integers" #: ports/esp32s2/boards/adafruit_funhouse/mpconfigboard.h #: ports/esp32s2/boards/adafruit_magtag_2.9_grayscale/mpconfigboard.h #: ports/esp32s2/boards/adafruit_metro_esp32s2/mpconfigboard.h +#: ports/esp32s2/boards/artisense_rd00/mpconfigboard.h #: ports/esp32s2/boards/electroniccats_bastwifi/mpconfigboard.h #: ports/esp32s2/boards/espressif_kaluga_1/mpconfigboard.h #: ports/esp32s2/boards/espressif_saola_1_wroom/mpconfigboard.h @@ -3797,6 +3800,10 @@ msgstr "druk bootknop in bij opstarten.\n" msgid "pressing both buttons at start up.\n" msgstr "druk beide knoppen in bij opstarten.\n" +#: ports/nrf/boards/aramcon2_badge/mpconfigboard.h +msgid "pressing the left button at start up\n" +msgstr "" + #: ports/raspberrypi/common-hal/rp2pio/StateMachine.c msgid "pull masks conflict with direction masks" msgstr "" @@ -4072,10 +4079,6 @@ msgstr "" 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 "triggerniveau moet 0 of 1 zijn" - #: py/obj.c msgid "tuple/list has wrong length" msgstr "tuple of lijst heeft onjuiste lengte" @@ -4210,10 +4213,6 @@ msgstr "waarde moet in %d byte(s) passen" msgid "value_count must be > 0" msgstr "value_count moet groter dan 0 zijn" -#: ports/esp32s2/common-hal/alarm/pin/__init__.c -msgid "wakeup conflict" -msgstr "conflict bij ontwaken" - #: ports/esp32s2/common-hal/watchdog/WatchDogTimer.c msgid "watchdog not initialized" msgstr "watchdog niet geïnitialiseerd" @@ -4300,6 +4299,30 @@ 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 "IOs 0, 2 & 4 do not support internal pullup in sleep" +#~ msgstr "IO's 0, 2 en 4 ondersteunen geen interne pullup in slaapstand" + +#~ msgid "buffer must be a bytes-like object" +#~ msgstr "buffer moet een byte-achtig object zijn" + +#~ msgid "io must be rtc io" +#~ msgstr "io moet rtc io zijn" + +#~ msgid "trigger level must be 0 or 1" +#~ msgstr "triggerniveau moet 0 of 1 zijn" + +#~ msgid "wakeup conflict" +#~ msgstr "conflict bij ontwaken" + +#~ msgid "Attempted heap allocation when MicroPython VM not running." +#~ msgstr "heap allocatie geprobeerd terwijl MicroPython VM niet draait." + +#~ msgid "MicroPython NLR jump failed. Likely memory corruption." +#~ msgstr "MicroPython NLR sprong mislukt. Waarschijnlijk geheugen corruptie." + +#~ msgid "MicroPython fatal error." +#~ msgstr "MicroPython fatale fout." + #~ msgid "argument must be ndarray" #~ msgstr "argument moet ndarray zijn" diff --git a/locale/pl.po b/locale/pl.po index 295901c994..234c2ba998 100644 --- a/locale/pl.po +++ b/locale/pl.po @@ -443,8 +443,8 @@ msgid "Attempt to allocate %d blocks" msgstr "Próba przydzielenia %d bloków" #: supervisor/shared/safe_mode.c -msgid "Attempted heap allocation when MicroPython VM not running." -msgstr "Próba przydziału sterty, gdy MicroPython VM nie działa." +msgid "Attempted heap allocation when VM not running." +msgstr "" #: shared-bindings/wifi/Radio.c msgid "Authentication failure" @@ -890,6 +890,11 @@ msgstr "" msgid "EXTINT channel already in use" msgstr "Kanał EXTINT w użyciu" +#: shared-module/synthio/MidiTrack.c +#, c-format +msgid "Error in MIDI stream at position %d" +msgstr "" + #: extmod/modure.c msgid "Error in regex" msgstr "Błąd w regex" @@ -1019,6 +1024,10 @@ msgstr "Nie udało się zwolnić blokady, błąd 0x%04x" msgid "Failed to write internal flash." msgstr "Nie udało się zapisać wewnętrznej pamięci flash." +#: supervisor/shared/safe_mode.c +msgid "Fatal error." +msgstr "" + #: py/moduerrno.c msgid "File exists" msgstr "Plik istnieje" @@ -1091,10 +1100,6 @@ msgstr "" 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" @@ -1220,6 +1225,10 @@ msgstr "" msgid "Invalid DAC pin supplied" msgstr "" +#: shared-bindings/synthio/__init__.c +msgid "Invalid MIDI file" +msgstr "" + #: ports/atmel-samd/common-hal/pwmio/PWMOut.c #: ports/cxd56/common-hal/pwmio/PWMOut.c #: ports/mimxrt10xx/common-hal/pwmio/PWMOut.c @@ -1411,15 +1420,6 @@ msgstr "Największa wartość x przy odwróceniu to %d" msgid "Messages limited to 8 bytes" msgstr "Wiadomości ograniczone do 8 bajtów" -#: supervisor/shared/safe_mode.c -msgid "MicroPython NLR jump failed. Likely memory corruption." -msgstr "" -"Skok MicroRython NLR nie powiódł się. Prawdopodobne uszkodzenie pamięci." - -#: supervisor/shared/safe_mode.c -msgid "MicroPython fatal error." -msgstr "Błąd krytyczny MicroPython." - #: shared-bindings/audiobusio/PDMIn.c msgid "Microphone startup delay must be in range 0.0 to 1.0" msgstr "Opóźnienie włączenia mikrofonu musi być w zakresie od 0.0 do 1.0" @@ -1471,6 +1471,10 @@ msgstr "Należy podać pin MISO lub MOSI" msgid "Must use a multiple of 6 rgb pins, not %d" msgstr "" +#: supervisor/shared/safe_mode.c +msgid "NLR jump failed. Likely memory corruption." +msgstr "" + #: ports/esp32s2/common-hal/nvm/ByteArray.c msgid "NVS Error" msgstr "" @@ -1615,6 +1619,7 @@ msgstr "" msgid "Not a valid IP string" msgstr "" +#: ports/nrf/common-hal/_bleio/PacketBuffer.c #: ports/nrf/common-hal/_bleio/__init__.c #: shared-bindings/_bleio/CharacteristicBuffer.c msgid "Not connected" @@ -2513,10 +2518,6 @@ msgstr "skok poza zakres" msgid "buffer is smaller than requested size" msgstr "" -#: shared-bindings/audiocore/RawSample.c -msgid "buffer must be a bytes-like object" -msgstr "bufor mysi być typu bytes" - #: extmod/ulab/code/ulab_create.c extmod/ulab/code/utils/utils.c msgid "buffer size must be a multiple of element size" msgstr "" @@ -2959,7 +2960,7 @@ msgid "f-string: single '}' is not allowed" msgstr "" #: shared-bindings/audiocore/WaveFile.c shared-bindings/audiomp3/MP3Decoder.c -#: shared-bindings/displayio/OnDiskBitmap.c +#: shared-bindings/displayio/OnDiskBitmap.c shared-bindings/synthio/__init__.c msgid "file must be a file opened in byte mode" msgstr "file musi być otwarte w trybie bajtowym" @@ -3215,6 +3216,10 @@ msgstr "" msgid "invalid cert" msgstr "zły ceryfikat" +#: py/compile.c +msgid "invalid decorator" +msgstr "" + #: extmod/uos_dupterm.c msgid "invalid dupterm index" msgstr "zły indeks dupterm" @@ -3270,10 +3275,6 @@ 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ą" @@ -3734,6 +3735,7 @@ msgstr "trzyargumentowe pow() wymaga liczb całkowitych" #: ports/esp32s2/boards/adafruit_funhouse/mpconfigboard.h #: ports/esp32s2/boards/adafruit_magtag_2.9_grayscale/mpconfigboard.h #: ports/esp32s2/boards/adafruit_metro_esp32s2/mpconfigboard.h +#: ports/esp32s2/boards/artisense_rd00/mpconfigboard.h #: ports/esp32s2/boards/electroniccats_bastwifi/mpconfigboard.h #: ports/esp32s2/boards/espressif_kaluga_1/mpconfigboard.h #: ports/esp32s2/boards/espressif_saola_1_wroom/mpconfigboard.h @@ -3759,6 +3761,10 @@ msgstr "" msgid "pressing both buttons at start up.\n" msgstr "" +#: ports/nrf/boards/aramcon2_badge/mpconfigboard.h +msgid "pressing the left button at start up\n" +msgstr "" + #: ports/raspberrypi/common-hal/rp2pio/StateMachine.c msgid "pull masks conflict with direction masks" msgstr "" @@ -4033,10 +4039,6 @@ 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 "" - #: py/obj.c msgid "tuple/list has wrong length" msgstr "krotka/lista ma złą długość" @@ -4171,10 +4173,6 @@ msgstr "wartość musi mieścić się w %d bajtach" msgid "value_count must be > 0" msgstr "value_count musi być > 0" -#: ports/esp32s2/common-hal/alarm/pin/__init__.c -msgid "wakeup conflict" -msgstr "" - #: ports/esp32s2/common-hal/watchdog/WatchDogTimer.c msgid "watchdog not initialized" msgstr "" @@ -4261,6 +4259,19 @@ msgstr "" msgid "zi must be of shape (n_section, 2)" msgstr "" +#~ msgid "buffer must be a bytes-like object" +#~ msgstr "bufor mysi być typu bytes" + +#~ msgid "Attempted heap allocation when MicroPython VM not running." +#~ msgstr "Próba przydziału sterty, gdy MicroPython VM nie działa." + +#~ msgid "MicroPython NLR jump failed. Likely memory corruption." +#~ msgstr "" +#~ "Skok MicroRython NLR nie powiódł się. Prawdopodobne uszkodzenie pamięci." + +#~ msgid "MicroPython fatal error." +#~ msgstr "Błąd krytyczny MicroPython." + #~ msgid "vectors must have same lengths" #~ msgstr "wektory muszą mieć identyczną długość" diff --git a/locale/pt_BR.po b/locale/pt_BR.po index 7643bcfb0d..adb54556be 100644 --- a/locale/pt_BR.po +++ b/locale/pt_BR.po @@ -6,7 +6,7 @@ msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2021-01-04 12:55-0600\n" -"PO-Revision-Date: 2021-04-07 12:23+0000\n" +"PO-Revision-Date: 2021-04-19 21:50+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.6-dev\n" +"X-Generator: Weblate 4.7-dev\n" #: main.c msgid "" @@ -451,10 +451,9 @@ msgid "Attempt to allocate %d blocks" msgstr "Tentativa de alocar %d blocos" #: supervisor/shared/safe_mode.c -msgid "Attempted heap allocation when MicroPython VM not running." +msgid "Attempted heap allocation when VM not running." msgstr "" -"A tentativa da área de alocação dinâmica de variáveis (heap) quando o " -"MicroPython VM não está em execução." +"Tentativa de alocação das pilhas quando o VM não estiver em funcionamento." #: shared-bindings/wifi/Radio.c msgid "Authentication failure" @@ -908,6 +907,11 @@ msgstr "Houve uma falha na alocação da memória ESP-IDF" msgid "EXTINT channel already in use" msgstr "Canal EXTINT em uso" +#: shared-module/synthio/MidiTrack.c +#, c-format +msgid "Error in MIDI stream at position %d" +msgstr "Houve um erro no fluxo MIDI na posição %d" + #: extmod/modure.c msgid "Error in regex" msgstr "Erro no regex" @@ -1037,6 +1041,10 @@ msgstr "Houve uma falha ao liberar o mutex, err 0x%04x" msgid "Failed to write internal flash." msgstr "Falha ao gravar o flash interno." +#: supervisor/shared/safe_mode.c +msgid "Fatal error." +msgstr "Erro fatal." + #: py/moduerrno.c msgid "File exists" msgstr "Arquivo já existe" @@ -1110,10 +1118,6 @@ msgstr "Periférico I2C em uso" 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 "IOs 0, 2 e 4 não suportam pullup interno em repouso (sleep)" - #: shared-bindings/aesio/aes.c #, c-format msgid "IV must be %d bytes long" @@ -1245,6 +1249,10 @@ msgstr "BSSID Inválido" msgid "Invalid DAC pin supplied" msgstr "O pino DAC informado é inválido" +#: shared-bindings/synthio/__init__.c +msgid "Invalid MIDI file" +msgstr "O arquivo MIDI é inválido" + #: ports/atmel-samd/common-hal/pwmio/PWMOut.c #: ports/cxd56/common-hal/pwmio/PWMOut.c #: ports/mimxrt10xx/common-hal/pwmio/PWMOut.c @@ -1436,14 +1444,6 @@ msgstr "O valor máximo de x quando espelhado é %d" msgid "Messages limited to 8 bytes" msgstr "As mensagens estão limitadas a 8 bytes" -#: supervisor/shared/safe_mode.c -msgid "MicroPython NLR jump failed. Likely memory corruption." -msgstr "O salto do MicroPython NLR falhou. Possível corrupção de memória." - -#: supervisor/shared/safe_mode.c -msgid "MicroPython fatal error." -msgstr "Houve um erro fatal do MicroPython." - #: shared-bindings/audiobusio/PDMIn.c msgid "Microphone startup delay must be in range 0.0 to 1.0" msgstr "O atraso na inicialização do microfone deve estar entre 0,0 e 1,0" @@ -1495,6 +1495,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" +#: supervisor/shared/safe_mode.c +msgid "NLR jump failed. Likely memory corruption." +msgstr "O salto NLR falhou. Possível corrupção da memória." + #: ports/esp32s2/common-hal/nvm/ByteArray.c msgid "NVS Error" msgstr "Erro NVS" @@ -1641,6 +1645,7 @@ msgstr "O firmware do sistema nórdico está sem memória" msgid "Not a valid IP string" msgstr "Não é uma sequência válida de IP" +#: ports/nrf/common-hal/_bleio/PacketBuffer.c #: ports/nrf/common-hal/_bleio/__init__.c #: shared-bindings/_bleio/CharacteristicBuffer.c msgid "Not connected" @@ -2579,10 +2584,6 @@ msgstr "ramo fora do alcance" msgid "buffer is smaller than requested size" msgstr "o tamanho do buffer é menor do que o tamanho que foi solicitado" -#: shared-bindings/audiocore/RawSample.c -msgid "buffer must be a bytes-like object" -msgstr "o buffer deve ser um objeto como bytes" - #: extmod/ulab/code/ulab_create.c extmod/ulab/code/utils/utils.c msgid "buffer size must be a multiple of element size" msgstr "o tamanho do buffer deve ser um múltiplo do tamanho do elemento" @@ -3033,7 +3034,7 @@ msgid "f-string: single '}' is not allowed" msgstr "f-string: um único '}' não é permitido" #: shared-bindings/audiocore/WaveFile.c shared-bindings/audiomp3/MP3Decoder.c -#: shared-bindings/displayio/OnDiskBitmap.c +#: shared-bindings/displayio/OnDiskBitmap.c shared-bindings/synthio/__init__.c msgid "file must be a file opened in byte mode" msgstr "o arquivo deve ser um arquivo aberto no modo byte" @@ -3290,6 +3291,10 @@ msgstr "bits_per_pixel %d é inválido, deve ser, 1, 4, 8, 16, 24, ou 32" msgid "invalid cert" msgstr "certificado inválido" +#: py/compile.c +msgid "invalid decorator" +msgstr "decorador inválido" + #: extmod/uos_dupterm.c msgid "invalid dupterm index" msgstr "Índice de dupterm inválido" @@ -3345,10 +3350,6 @@ 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 "O io deve ser rtc io" - #: py/objtype.c msgid "issubclass() arg 1 must be a class" msgstr "issubclass() arg 1 deve ser uma classe" @@ -3818,6 +3819,7 @@ msgstr "o pow() com 3 argumentos requer números inteiros" #: ports/esp32s2/boards/adafruit_funhouse/mpconfigboard.h #: ports/esp32s2/boards/adafruit_magtag_2.9_grayscale/mpconfigboard.h #: ports/esp32s2/boards/adafruit_metro_esp32s2/mpconfigboard.h +#: ports/esp32s2/boards/artisense_rd00/mpconfigboard.h #: ports/esp32s2/boards/electroniccats_bastwifi/mpconfigboard.h #: ports/esp32s2/boards/espressif_kaluga_1/mpconfigboard.h #: ports/esp32s2/boards/espressif_saola_1_wroom/mpconfigboard.h @@ -3843,6 +3845,10 @@ msgstr "pressionando o botão de boot na inicialização.\n" msgid "pressing both buttons at start up.\n" msgstr "pressionando ambos os botões durante a inicialização.\n" +#: ports/nrf/boards/aramcon2_badge/mpconfigboard.h +msgid "pressing the left button at start up\n" +msgstr "pressionando o botão esquerdo durante a inicialização\n" + #: ports/raspberrypi/common-hal/rp2pio/StateMachine.c msgid "pull masks conflict with direction masks" msgstr "puxe as máscaras em conflito com as máscaras de direção" @@ -4118,10 +4124,6 @@ msgstr "Trapz está definido para arrays 1D" 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 "nível do gatilho deve ser 0 ou 1" - #: py/obj.c msgid "tuple/list has wrong length" msgstr "a tupla/lista está com tamanho incorreto" @@ -4256,10 +4258,6 @@ msgstr "o valor deve caber em %d byte(s)" msgid "value_count must be > 0" msgstr "o value_count deve ser > 0" -#: ports/esp32s2/common-hal/alarm/pin/__init__.c -msgid "wakeup conflict" -msgstr "conflito de wakeup" - #: ports/esp32s2/common-hal/watchdog/WatchDogTimer.c msgid "watchdog not initialized" msgstr "o watchdog não foi inicializado" @@ -4346,6 +4344,32 @@ 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 "IOs 0, 2 & 4 do not support internal pullup in sleep" +#~ msgstr "IOs 0, 2 e 4 não suportam pullup interno em repouso (sleep)" + +#~ msgid "buffer must be a bytes-like object" +#~ msgstr "o buffer deve ser um objeto como bytes" + +#~ msgid "io must be rtc io" +#~ msgstr "O io deve ser rtc io" + +#~ msgid "trigger level must be 0 or 1" +#~ msgstr "nível do gatilho deve ser 0 ou 1" + +#~ msgid "wakeup conflict" +#~ msgstr "conflito de wakeup" + +#~ msgid "Attempted heap allocation when MicroPython VM not running." +#~ msgstr "" +#~ "A tentativa da área de alocação dinâmica de variáveis (heap) quando o " +#~ "MicroPython VM não está em execução." + +#~ msgid "MicroPython NLR jump failed. Likely memory corruption." +#~ msgstr "O salto do MicroPython NLR falhou. Possível corrupção de memória." + +#~ msgid "MicroPython fatal error." +#~ msgstr "Houve um erro fatal do MicroPython." + #~ msgid "argument must be ndarray" #~ msgstr "o argumento deve ser ndarray" diff --git a/locale/sv.po b/locale/sv.po index 5feb28845d..69fe35736d 100644 --- a/locale/sv.po +++ b/locale/sv.po @@ -6,7 +6,7 @@ msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2021-01-04 12:55-0600\n" -"PO-Revision-Date: 2021-04-06 14:41+0000\n" +"PO-Revision-Date: 2021-04-19 21:50+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.6-dev\n" +"X-Generator: Weblate 4.7-dev\n" #: main.c msgid "" @@ -446,8 +446,8 @@ msgid "Attempt to allocate %d blocks" msgstr "Försök att tilldela %d block" #: supervisor/shared/safe_mode.c -msgid "Attempted heap allocation when MicroPython VM not running." -msgstr "Försökte tilldela heap när MicroPython VM inte körs." +msgid "Attempted heap allocation when VM not running." +msgstr "Försök till heap-allokering när den virtuella maskinen inte är igång." #: shared-bindings/wifi/Radio.c msgid "Authentication failure" @@ -896,6 +896,11 @@ msgstr "ESP-IDF-minnetilldelning misslyckades" msgid "EXTINT channel already in use" msgstr "EXTINT-kanalen används redan" +#: shared-module/synthio/MidiTrack.c +#, c-format +msgid "Error in MIDI stream at position %d" +msgstr "Fel i MIDI-ström vid position %d" + #: extmod/modure.c msgid "Error in regex" msgstr "Fel i regex" @@ -1025,6 +1030,10 @@ msgstr "Det gick inte att frigöra mutex, fel 0x%04x" msgid "Failed to write internal flash." msgstr "Det gick inte att skriva till intern flash." +#: supervisor/shared/safe_mode.c +msgid "Fatal error." +msgstr "Fatalt fel." + #: py/moduerrno.c msgid "File exists" msgstr "Filen finns redan" @@ -1097,10 +1106,6 @@ msgstr "I2C-enhet används redan" 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 "IO 0, 2 & 4 stöder inte intern pullup för sovläge" - #: shared-bindings/aesio/aes.c #, c-format msgid "IV must be %d bytes long" @@ -1228,6 +1233,10 @@ msgstr "Ogiltig BSSID" msgid "Invalid DAC pin supplied" msgstr "Ogiltig DAC-pinne angiven" +#: shared-bindings/synthio/__init__.c +msgid "Invalid MIDI file" +msgstr "Ogiltig MIDI-fil" + #: ports/atmel-samd/common-hal/pwmio/PWMOut.c #: ports/cxd56/common-hal/pwmio/PWMOut.c #: ports/mimxrt10xx/common-hal/pwmio/PWMOut.c @@ -1419,14 +1428,6 @@ msgstr "Maximum x-värde vid spegling är %d" msgid "Messages limited to 8 bytes" msgstr "Meddelanden begränsad till 8 byte" -#: supervisor/shared/safe_mode.c -msgid "MicroPython NLR jump failed. Likely memory corruption." -msgstr "MicroPython NLR jump misslyckades. Troligen korrupt minne." - -#: supervisor/shared/safe_mode.c -msgid "MicroPython fatal error." -msgstr "MicroPython fatalt fel." - #: shared-bindings/audiobusio/PDMIn.c msgid "Microphone startup delay must be in range 0.0 to 1.0" msgstr "" @@ -1479,6 +1480,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" +#: supervisor/shared/safe_mode.c +msgid "NLR jump failed. Likely memory corruption." +msgstr "NLR jump misslyckades. Troligen korrupt minne." + #: ports/esp32s2/common-hal/nvm/ByteArray.c msgid "NVS Error" msgstr "NVS-fel" @@ -1623,6 +1628,7 @@ msgstr "Nordic systemfirmware fick slut på minne" msgid "Not a valid IP string" msgstr "Inte en giltig IP-sträng" +#: ports/nrf/common-hal/_bleio/PacketBuffer.c #: ports/nrf/common-hal/_bleio/__init__.c #: shared-bindings/_bleio/CharacteristicBuffer.c msgid "Not connected" @@ -2547,10 +2553,6 @@ msgstr "branch utanför räckvidd" msgid "buffer is smaller than requested size" msgstr "bufferten är mindre än begärd storlek" -#: shared-bindings/audiocore/RawSample.c -msgid "buffer must be a bytes-like object" -msgstr "buffer måste vara en byte-liknande objekt" - #: extmod/ulab/code/ulab_create.c extmod/ulab/code/utils/utils.c msgid "buffer size must be a multiple of element size" msgstr "buffertstorlek måste vara en multipel av elementstorlek" @@ -2997,7 +2999,7 @@ msgid "f-string: single '}' is not allowed" msgstr "f-string: singel '}' är inte tillåten" #: shared-bindings/audiocore/WaveFile.c shared-bindings/audiomp3/MP3Decoder.c -#: shared-bindings/displayio/OnDiskBitmap.c +#: shared-bindings/displayio/OnDiskBitmap.c shared-bindings/synthio/__init__.c msgid "file must be a file opened in byte mode" msgstr "filen måste vara en fil som öppnats i byte-läge" @@ -3253,6 +3255,10 @@ msgstr "ogiltig bits_per_pixel %d, måste vara 1, 4, 8, 16, 24 eller 32" msgid "invalid cert" msgstr "ogiltigt certifikat" +#: py/compile.c +msgid "invalid decorator" +msgstr "ogiltig dekorator" + #: extmod/uos_dupterm.c msgid "invalid dupterm index" msgstr "ogiltigt dupterm index" @@ -3308,10 +3314,6 @@ 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 "io måste vara rtc io" - #: py/objtype.c msgid "issubclass() arg 1 must be a class" msgstr "issubclass() arg 1 måste vara en klass" @@ -3775,6 +3777,7 @@ msgstr "pow() med 3 argument kräver heltal" #: ports/esp32s2/boards/adafruit_funhouse/mpconfigboard.h #: ports/esp32s2/boards/adafruit_magtag_2.9_grayscale/mpconfigboard.h #: ports/esp32s2/boards/adafruit_metro_esp32s2/mpconfigboard.h +#: ports/esp32s2/boards/artisense_rd00/mpconfigboard.h #: ports/esp32s2/boards/electroniccats_bastwifi/mpconfigboard.h #: ports/esp32s2/boards/espressif_kaluga_1/mpconfigboard.h #: ports/esp32s2/boards/espressif_saola_1_wroom/mpconfigboard.h @@ -3800,6 +3803,10 @@ msgstr "trycka på startknappen vid start.\n" msgid "pressing both buttons at start up.\n" msgstr "trycka båda knapparna vid uppstart.\n" +#: ports/nrf/boards/aramcon2_badge/mpconfigboard.h +msgid "pressing the left button at start up\n" +msgstr "håll ner vänster knapp vid start\n" + #: ports/raspberrypi/common-hal/rp2pio/StateMachine.c msgid "pull masks conflict with direction masks" msgstr "pull-mask är i konflikt med riktnings-mask" @@ -4075,10 +4082,6 @@ msgstr "trapz är definierat för 1D-matriser" 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 "triggernivå måste vara 0 eller 1" - #: py/obj.c msgid "tuple/list has wrong length" msgstr "tupel/lista har fel längd" @@ -4213,10 +4216,6 @@ msgstr "värdet måste passa i %d byte(s)" msgid "value_count must be > 0" msgstr "value_count måste vara > 0" -#: ports/esp32s2/common-hal/alarm/pin/__init__.c -msgid "wakeup conflict" -msgstr "wakeup-konflikt" - #: ports/esp32s2/common-hal/watchdog/WatchDogTimer.c msgid "watchdog not initialized" msgstr "watchdog är inte initierad" @@ -4303,6 +4302,30 @@ 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 "IOs 0, 2 & 4 do not support internal pullup in sleep" +#~ msgstr "IO 0, 2 & 4 stöder inte intern pullup för sovläge" + +#~ msgid "buffer must be a bytes-like object" +#~ msgstr "buffer måste vara en byte-liknande objekt" + +#~ msgid "io must be rtc io" +#~ msgstr "io måste vara rtc io" + +#~ msgid "trigger level must be 0 or 1" +#~ msgstr "triggernivå måste vara 0 eller 1" + +#~ msgid "wakeup conflict" +#~ msgstr "wakeup-konflikt" + +#~ msgid "Attempted heap allocation when MicroPython VM not running." +#~ msgstr "Försökte tilldela heap när MicroPython VM inte körs." + +#~ msgid "MicroPython NLR jump failed. Likely memory corruption." +#~ msgstr "MicroPython NLR jump misslyckades. Troligen korrupt minne." + +#~ msgid "MicroPython fatal error." +#~ msgstr "MicroPython fatalt fel." + #~ msgid "argument must be ndarray" #~ msgstr "argument måste vara ndarray" diff --git a/locale/zh_Latn_pinyin.po b/locale/zh_Latn_pinyin.po index 14c0a9eca0..c8a2d8cf83 100644 --- a/locale/zh_Latn_pinyin.po +++ b/locale/zh_Latn_pinyin.po @@ -7,7 +7,7 @@ msgstr "" "Project-Id-Version: circuitpython-cn\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2021-01-04 12:55-0600\n" -"PO-Revision-Date: 2021-03-29 08:26+0000\n" +"PO-Revision-Date: 2021-04-19 19:15+0000\n" "Last-Translator: hexthat \n" "Language-Team: Chinese Hanyu Pinyin\n" "Language: zh_Latn_pinyin\n" @@ -15,7 +15,7 @@ msgstr "" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=1; plural=0;\n" -"X-Generator: Weblate 4.6-dev\n" +"X-Generator: Weblate 4.7-dev\n" #: main.c msgid "" @@ -423,7 +423,7 @@ msgstr "Wèi zhīchí zhǐdìng de yǐn jiǎo AnalogOut" #: ports/stm/common-hal/audiopwmio/PWMAudioOut.c msgid "Another PWMAudioOut is already active" -msgstr "" +msgstr "lìng yí gè PWMAudioOut yǐ jīng chǔ yú huó dòng zhuàng tài" #: ports/atmel-samd/common-hal/pulseio/PulseOut.c #: ports/cxd56/common-hal/pulseio/PulseOut.c @@ -448,8 +448,8 @@ msgid "Attempt to allocate %d blocks" msgstr "cháng shì fēn pèi %d kuài" #: supervisor/shared/safe_mode.c -msgid "Attempted heap allocation when MicroPython VM not running." -msgstr "MicroPython VM zài wèi yùnxíng shí chángshì fēnpèi duī." +msgid "Attempted heap allocation when VM not running." +msgstr "dāng VM bú yùn xíng shí, cháng shì duī fēn pèi." #: shared-bindings/wifi/Radio.c msgid "Authentication failure" @@ -895,6 +895,11 @@ msgstr "ESP-IDF nèicún fēnpèi shībài" msgid "EXTINT channel already in use" msgstr "EXTINT píndào yǐjīng shǐyòng" +#: shared-module/synthio/MidiTrack.c +#, c-format +msgid "Error in MIDI stream at position %d" +msgstr "wèi yú %d wèi zhì de MIDI liú zhōng de cuò wù" + #: extmod/modure.c msgid "Error in regex" msgstr "Zhèngzé biǎodá shì cuòwù" @@ -997,7 +1002,7 @@ msgstr "Wúfǎ fēnpèi wifi sǎomiáo nèicún" #: ports/stm/common-hal/audiopwmio/PWMAudioOut.c msgid "Failed to buffer the sample" -msgstr "" +msgstr "wèi néng huǎn chōng yàng běn" #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Failed to connect: internal error" @@ -1024,6 +1029,10 @@ msgstr "Wúfǎ shìfàng mutex, err 0x%04x" msgid "Failed to write internal flash." msgstr "Wúfǎ xiě rù nèibù shǎncún." +#: supervisor/shared/safe_mode.c +msgid "Fatal error." +msgstr "zhì mìng cuò wù." + #: py/moduerrno.c msgid "File exists" msgstr "Wénjiàn cúnzài" @@ -1096,10 +1105,6 @@ msgstr "I2C wài shè zhèng zài shǐ yòng zhōng" 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 "IOS 0, 2 + 4 bù zhī chí shuì mián zhōng de nèi bù shàng lā" - #: shared-bindings/aesio/aes.c #, c-format msgid "IV must be %d bytes long" @@ -1230,6 +1235,10 @@ msgstr "Wúxiào de BSSID" msgid "Invalid DAC pin supplied" msgstr "Tí gōng liǎo wúxiào de DAC yǐn jiǎo" +#: shared-bindings/synthio/__init__.c +msgid "Invalid MIDI file" +msgstr "wú xiào de MIDI wén jiàn" + #: ports/atmel-samd/common-hal/pwmio/PWMOut.c #: ports/cxd56/common-hal/pwmio/PWMOut.c #: ports/mimxrt10xx/common-hal/pwmio/PWMOut.c @@ -1421,14 +1430,6 @@ msgstr "Jìngxiàng shí de zuìdà X zhí wèi%d" msgid "Messages limited to 8 bytes" msgstr "Yóujiàn xiànzhì wèi 8 gè zì jié" -#: supervisor/shared/safe_mode.c -msgid "MicroPython NLR jump failed. Likely memory corruption." -msgstr "MicroPython NLR tiào zhuǎn shībài. Kěnéng shì nèicún sǔnhuài." - -#: supervisor/shared/safe_mode.c -msgid "MicroPython fatal error." -msgstr "MicroPython zhìmìng cuòwù." - #: shared-bindings/audiobusio/PDMIn.c msgid "Microphone startup delay must be in range 0.0 to 1.0" msgstr "Màikèfēng qǐdòng yánchí bìxū zài 0.0 Dào 1.0 De fànwéi nèi" @@ -1481,6 +1482,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" +#: supervisor/shared/safe_mode.c +msgid "NLR jump failed. Likely memory corruption." +msgstr "NLR tiào zhuǎn shī bài. kě néng shì nèi cún sǔn huài." + #: ports/esp32s2/common-hal/nvm/ByteArray.c msgid "NVS Error" msgstr "NVS cuò wù" @@ -1615,16 +1620,17 @@ msgstr "Méiyǒu jìshí qì" #: supervisor/shared/safe_mode.c msgid "Nordic system firmware failure assertion." -msgstr "" +msgstr "běi ōu xì tǒng gù jiàn gù zhàng duàn yán." #: ports/nrf/common-hal/_bleio/__init__.c msgid "Nordic system firmware out of memory" -msgstr "" +msgstr "běi ōu xì tǒng gù jiàn chū nèi cún" #: shared-bindings/ipaddress/IPv4Address.c shared-bindings/ipaddress/__init__.c msgid "Not a valid IP string" msgstr "Wúxiào de IP zìfú chuàn" +#: ports/nrf/common-hal/_bleio/PacketBuffer.c #: ports/nrf/common-hal/_bleio/__init__.c #: shared-bindings/_bleio/CharacteristicBuffer.c msgid "Not connected" @@ -2288,7 +2294,7 @@ msgstr "Wèizhī de ānquán cuòwù: 0x%04x" #: ports/nrf/common-hal/_bleio/__init__.c #, c-format msgid "Unknown system firmware error: %04x" -msgstr "" +msgstr "wèi zhī xì tǒng gù jiàn cuò wù: %04x" #: shared-bindings/_pixelbuf/PixelBuf.c #, c-format @@ -2545,10 +2551,6 @@ msgstr "fēnzhī bùzài fànwéi nèi" msgid "buffer is smaller than requested size" msgstr "huǎn chōng qū xiǎo yú qǐng qiú de dà xiǎo" -#: shared-bindings/audiocore/RawSample.c -msgid "buffer must be a bytes-like object" -msgstr "huǎnchōng qū bìxū shì zì jié lèi duìxiàng" - #: extmod/ulab/code/ulab_create.c extmod/ulab/code/utils/utils.c msgid "buffer size must be a multiple of element size" msgstr "huǎn chōng qū dà xiǎo bì xū shì yuán sù dà xiǎo de bèi shù" @@ -2996,7 +2998,7 @@ msgid "f-string: single '}' is not allowed" msgstr "f-string: bù yǔnxǔ shǐyòng dāngè '}'" #: shared-bindings/audiocore/WaveFile.c shared-bindings/audiomp3/MP3Decoder.c -#: shared-bindings/displayio/OnDiskBitmap.c +#: shared-bindings/displayio/OnDiskBitmap.c shared-bindings/synthio/__init__.c msgid "file must be a file opened in byte mode" msgstr "wénjiàn bìxū shì zài zì jié móshì xià dǎkāi de wénjiàn" @@ -3252,6 +3254,10 @@ msgstr "wú xiào bits_per_pixel %d, bì xū shì, 1, 4, 8, 16, 24, huò 32" msgid "invalid cert" msgstr "zhèngshū wúxiào" +#: py/compile.c +msgid "invalid decorator" +msgstr "wú xiào zhuāng shì" + #: extmod/uos_dupterm.c msgid "invalid dupterm index" msgstr "dupterm suǒyǐn wúxiào" @@ -3307,10 +3313,6 @@ 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 "IO bì xū shì RTC IO" - #: py/objtype.c msgid "issubclass() arg 1 must be a class" msgstr "issubclass() cānshù 1 bìxū shì yīgè lèi" @@ -3682,11 +3684,11 @@ msgstr "ord() yùqí zìfú, dàn chángdù zìfú chuàn %d" #: extmod/ulab/code/utils/utils.c msgid "out array is too small" -msgstr "" +msgstr "chū zhèn liè tài xiǎo" #: extmod/ulab/code/utils/utils.c msgid "out must be a float dense array" -msgstr "" +msgstr "chū bì xū shì yí gè fú dòng mì jí zhèn liè" #: shared-bindings/displayio/Bitmap.c msgid "out of range of source" @@ -3771,6 +3773,7 @@ msgstr "pow() yǒu 3 cānshù xūyào zhěngshù" #: ports/esp32s2/boards/adafruit_funhouse/mpconfigboard.h #: ports/esp32s2/boards/adafruit_magtag_2.9_grayscale/mpconfigboard.h #: ports/esp32s2/boards/adafruit_metro_esp32s2/mpconfigboard.h +#: ports/esp32s2/boards/artisense_rd00/mpconfigboard.h #: ports/esp32s2/boards/electroniccats_bastwifi/mpconfigboard.h #: ports/esp32s2/boards/espressif_kaluga_1/mpconfigboard.h #: ports/esp32s2/boards/espressif_saola_1_wroom/mpconfigboard.h @@ -3796,6 +3799,10 @@ msgstr "Zài qǐdòng shí àn qǐdòng ànniǔ.\n" msgid "pressing both buttons at start up.\n" msgstr "zài qǐdòng shí tóngshí àn xià liǎng gè ànniǔ.\n" +#: ports/nrf/boards/aramcon2_badge/mpconfigboard.h +msgid "pressing the left button at start up\n" +msgstr "" + #: ports/raspberrypi/common-hal/rp2pio/StateMachine.c msgid "pull masks conflict with direction masks" msgstr "lā kǒu zhào yǔ fāng xiàng miàn mó chōng tū" @@ -4071,10 +4078,6 @@ msgstr "wéi 1D shù zǔ dìng yì xiàn jǐng" 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 "chù fā jí bié bì xū wéi 0 huò 1" - #: py/obj.c msgid "tuple/list has wrong length" msgstr "yuán zǔ/lièbiǎo chángdù cuòwù" @@ -4209,10 +4212,6 @@ msgstr "Zhí bìxū fúhé %d zì jié" msgid "value_count must be > 0" msgstr "zhí jìshù bìxū wèi > 0" -#: ports/esp32s2/common-hal/alarm/pin/__init__.c -msgid "wakeup conflict" -msgstr "huàn xǐng chōng tū" - #: ports/esp32s2/common-hal/watchdog/WatchDogTimer.c msgid "watchdog not initialized" msgstr "wèi chū shǐ huà jiān shì qì" @@ -4299,6 +4298,30 @@ 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 "IOs 0, 2 & 4 do not support internal pullup in sleep" +#~ msgstr "IOS 0, 2 + 4 bù zhī chí shuì mián zhōng de nèi bù shàng lā" + +#~ msgid "buffer must be a bytes-like object" +#~ msgstr "huǎnchōng qū bìxū shì zì jié lèi duìxiàng" + +#~ msgid "io must be rtc io" +#~ msgstr "IO bì xū shì RTC IO" + +#~ msgid "trigger level must be 0 or 1" +#~ msgstr "chù fā jí bié bì xū wéi 0 huò 1" + +#~ msgid "wakeup conflict" +#~ msgstr "huàn xǐng chōng tū" + +#~ msgid "Attempted heap allocation when MicroPython VM not running." +#~ msgstr "MicroPython VM zài wèi yùnxíng shí chángshì fēnpèi duī." + +#~ msgid "MicroPython NLR jump failed. Likely memory corruption." +#~ msgstr "MicroPython NLR tiào zhuǎn shībài. Kěnéng shì nèicún sǔnhuài." + +#~ msgid "MicroPython fatal error." +#~ msgstr "MicroPython zhìmìng cuòwù." + #~ msgid "argument must be ndarray" #~ msgstr "Cānshù bìxū shì ndarray" diff --git a/main.c b/main.c index 755f8d5362..7020ab3851 100755 --- a/main.c +++ b/main.c @@ -404,10 +404,10 @@ STATIC bool run_code_py(safe_mode_t safe_mode) { new_status_color(BLACK); board_deinit(); if (!supervisor_workflow_active()) { - // Enter deep sleep. When we wake up we'll return from - // this loop. + // Enter true deep sleep. When we wake up we'll be back at the + // top of main(), not in this loop. common_hal_alarm_enter_deep_sleep(); - // Does not return. + // Does not return. } else { serial_write_compressed(translate("Pretending to deep sleep until alarm, CTRL-C or file write.\n")); } @@ -426,18 +426,6 @@ STATIC bool run_code_py(safe_mode_t safe_mode) { #if CIRCUITPY_ALARM common_hal_alarm_pretending_deep_sleep(); - bool serial_in = (serial_connected() && - serial_bytes_available()); - supervisor_set_run_reason(RUN_REASON_STARTUP); - board_init(); - if (serial_in) { - bool ctrl_d = serial_read() == CHAR_CTRL_D; - if (ctrl_d) { - supervisor_set_run_reason(RUN_REASON_REPL_RELOAD); - } - return ctrl_d; - } - return true; #else port_idle_until_interrupt(); #endif diff --git a/ports/atmel-samd/boards/rotary_trinkey_m0/board.c b/ports/atmel-samd/boards/adafruit_neokey_trinkey_m0/board.c similarity index 100% rename from ports/atmel-samd/boards/rotary_trinkey_m0/board.c rename to ports/atmel-samd/boards/adafruit_neokey_trinkey_m0/board.c diff --git a/ports/atmel-samd/boards/adafruit_neokey_trinkey_m0/mpconfigboard.h b/ports/atmel-samd/boards/adafruit_neokey_trinkey_m0/mpconfigboard.h new file mode 100644 index 0000000000..3cd85ac1bc --- /dev/null +++ b/ports/atmel-samd/boards/adafruit_neokey_trinkey_m0/mpconfigboard.h @@ -0,0 +1,58 @@ +#define MICROPY_HW_BOARD_NAME "Adafruit NeoKey Trinkey 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_PA00 1 +#define IGNORE_PIN_PA01 1 +#define IGNORE_PIN_PA02 1 +#define IGNORE_PIN_PA03 1 +#define IGNORE_PIN_PA04 1 +#define IGNORE_PIN_PA05 1 +#define IGNORE_PIN_PA06 1 +#define IGNORE_PIN_PA08 1 +#define IGNORE_PIN_PA09 1 +#define IGNORE_PIN_PA10 1 +#define IGNORE_PIN_PA11 1 +#define IGNORE_PIN_PA12 1 +#define IGNORE_PIN_PA13 1 +#define IGNORE_PIN_PA14 1 +#define IGNORE_PIN_PA16 1 +#define IGNORE_PIN_PA17 1 +#define IGNORE_PIN_PA18 1 +#define IGNORE_PIN_PA19 1 +#define IGNORE_PIN_PA20 1 +#define IGNORE_PIN_PA21 1 +// 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_PA29 1 +#define IGNORE_PIN_PA30 1 +#define IGNORE_PIN_PA31 1 +#define IGNORE_PIN_PB00 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 diff --git a/ports/atmel-samd/boards/adafruit_neokey_trinkey_m0/mpconfigboard.mk b/ports/atmel-samd/boards/adafruit_neokey_trinkey_m0/mpconfigboard.mk new file mode 100644 index 0000000000..56cbede39f --- /dev/null +++ b/ports/atmel-samd/boards/adafruit_neokey_trinkey_m0/mpconfigboard.mk @@ -0,0 +1,34 @@ +USB_VID = 0x239A +USB_PID = 0x8100 +USB_PRODUCT = "NeoKey Trinkey M0" +USB_MANUFACTURER = "Adafruit Industries LLC" + +CHIP_VARIANT = SAMD21E18A +CHIP_FAMILY = samd21 + +INTERNAL_FLASH_FILESYSTEM = 1 +LONGINT_IMPL = NONE + +CIRCUITPY_ANALOGIO = 0 +CIRCUITPY_ROTARYIO = 0 +CIRCUITPY_RTC = 0 +CIRCUITPY_SAMD = 0 +CIRCUITPY_PS2IO = 0 +CIRCUITPY_PULSEIO = 0 +CIRCUITPY_PWMIO = 0 +CIRCUITPY_AUDIOCORE = 0 +CIRCUITPY_BUSIO = 0 +CIRCUITPY_STORAGE = 1 + +CIRCUITPY_MATH = 1 +CIRCUITPY_PIXELBUF = 1 +CIRCUITPY_USB_MIDI = 1 +CIRCUITPY_TOUCHIO = 1 +CIRCUITPY_FULL_BUILD = 0 + +SUPEROPT_GC = 0 +SUPEROPT_VM = 0 + +# Include these Python libraries in firmware. +FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_NeoPixel +FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_HID diff --git a/ports/atmel-samd/boards/adafruit_neokey_trinkey_m0/pins.c b/ports/atmel-samd/boards/adafruit_neokey_trinkey_m0/pins.c new file mode 100644 index 0000000000..df8dfb0bfa --- /dev/null +++ b/ports/atmel-samd/boards/adafruit_neokey_trinkey_m0/pins.c @@ -0,0 +1,8 @@ +#include "shared-bindings/board/__init__.h" + +STATIC const mp_rom_map_elem_t board_global_dict_table[] = { + { MP_ROM_QSTR(MP_QSTR_TOUCH), MP_ROM_PTR(&pin_PA07) }, + { MP_ROM_QSTR(MP_QSTR_NEOPIXEL), MP_ROM_PTR(&pin_PA15) }, + { MP_ROM_QSTR(MP_QSTR_SWITCH), MP_ROM_PTR(&pin_PA28) }, +}; +MP_DEFINE_CONST_DICT(board_module_globals, board_global_dict_table); diff --git a/ports/atmel-samd/boards/adafruit_proxlight_trinkey_m0/board.c b/ports/atmel-samd/boards/adafruit_proxlight_trinkey_m0/board.c new file mode 100644 index 0000000000..cde441b3d9 --- /dev/null +++ b/ports/atmel-samd/boards/adafruit_proxlight_trinkey_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 "supervisor/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/adafruit_proxlight_trinkey_m0/mpconfigboard.h b/ports/atmel-samd/boards/adafruit_proxlight_trinkey_m0/mpconfigboard.h new file mode 100644 index 0000000000..a760fbe376 --- /dev/null +++ b/ports/atmel-samd/boards/adafruit_proxlight_trinkey_m0/mpconfigboard.h @@ -0,0 +1,58 @@ +#define MICROPY_HW_BOARD_NAME "Adafruit ProxLight Trinkey 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_PA01 1 +#define IGNORE_PIN_PA02 1 +#define IGNORE_PIN_PA04 1 +#define IGNORE_PIN_PA05 1 +#define IGNORE_PIN_PA06 1 +#define IGNORE_PIN_PA08 1 +#define IGNORE_PIN_PA09 1 +#define IGNORE_PIN_PA10 1 +#define IGNORE_PIN_PA11 1 +#define IGNORE_PIN_PA12 1 +#define IGNORE_PIN_PA13 1 +#define IGNORE_PIN_PA14 1 +#define IGNORE_PIN_PA18 1 +#define IGNORE_PIN_PA19 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_PA29 1 +#define IGNORE_PIN_PA30 1 +#define IGNORE_PIN_PA31 1 +#define IGNORE_PIN_PB00 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 DEFAULT_I2C_BUS_SCL (&pin_PA17) +#define DEFAULT_I2C_BUS_SDA (&pin_PA16) diff --git a/ports/atmel-samd/boards/adafruit_proxlight_trinkey_m0/mpconfigboard.mk b/ports/atmel-samd/boards/adafruit_proxlight_trinkey_m0/mpconfigboard.mk new file mode 100644 index 0000000000..92e7a17f3e --- /dev/null +++ b/ports/atmel-samd/boards/adafruit_proxlight_trinkey_m0/mpconfigboard.mk @@ -0,0 +1,33 @@ +USB_VID = 0x239A +USB_PID = 0x8104 +USB_PRODUCT = "ProxLight Trinkey M0" +USB_MANUFACTURER = "Adafruit Industries LLC" + +CHIP_VARIANT = SAMD21E18A +CHIP_FAMILY = samd21 + +INTERNAL_FLASH_FILESYSTEM = 1 +LONGINT_IMPL = NONE + +CIRCUITPY_ANALOGIO = 0 +CIRCUITPY_ROTARYIO = 0 +CIRCUITPY_RTC = 0 +CIRCUITPY_SAMD = 0 +CIRCUITPY_PS2IO = 0 +CIRCUITPY_PULSEIO = 0 +CIRCUITPY_PWMIO = 0 +CIRCUITPY_AUDIOCORE = 0 +CIRCUITPY_BUSIO = 1 +CIRCUITPY_STORAGE = 1 + +CIRCUITPY_MATH = 1 +CIRCUITPY_PIXELBUF = 0 +CIRCUITPY_USB_MIDI = 1 +CIRCUITPY_TOUCHIO = 1 +CIRCUITPY_FULL_BUILD = 0 + +SUPEROPT_GC = 0 +SUPEROPT_VM = 0 + +# Include these Python libraries in firmware. +FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_HID diff --git a/ports/atmel-samd/boards/adafruit_proxlight_trinkey_m0/pins.c b/ports/atmel-samd/boards/adafruit_proxlight_trinkey_m0/pins.c new file mode 100644 index 0000000000..21410f8ad1 --- /dev/null +++ b/ports/atmel-samd/boards/adafruit_proxlight_trinkey_m0/pins.c @@ -0,0 +1,15 @@ +#include "shared-bindings/board/__init__.h" + +STATIC const mp_rom_map_elem_t board_global_dict_table[] = { + { MP_ROM_QSTR(MP_QSTR_INTERRUPT), MP_ROM_PTR(&pin_PA00) }, + + { MP_ROM_QSTR(MP_QSTR_TOUCH2), MP_ROM_PTR(&pin_PA03) }, + { MP_ROM_QSTR(MP_QSTR_TOUCH1), MP_ROM_PTR(&pin_PA07) }, + + { MP_ROM_QSTR(MP_QSTR_NEOPIXEL), MP_ROM_PTR(&pin_PA15) }, + { MP_ROM_QSTR(MP_QSTR_SDA), MP_ROM_PTR(&pin_PA16) }, + { MP_ROM_QSTR(MP_QSTR_SCL), MP_ROM_PTR(&pin_PA17) }, + + { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) }, +}; +MP_DEFINE_CONST_DICT(board_module_globals, board_global_dict_table); diff --git a/ports/atmel-samd/boards/adafruit_rotary_trinkey_m0/board.c b/ports/atmel-samd/boards/adafruit_rotary_trinkey_m0/board.c new file mode 100644 index 0000000000..cde441b3d9 --- /dev/null +++ b/ports/atmel-samd/boards/adafruit_rotary_trinkey_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 "supervisor/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/rotary_trinkey_m0/mpconfigboard.h b/ports/atmel-samd/boards/adafruit_rotary_trinkey_m0/mpconfigboard.h similarity index 100% rename from ports/atmel-samd/boards/rotary_trinkey_m0/mpconfigboard.h rename to ports/atmel-samd/boards/adafruit_rotary_trinkey_m0/mpconfigboard.h diff --git a/ports/atmel-samd/boards/rotary_trinkey_m0/mpconfigboard.mk b/ports/atmel-samd/boards/adafruit_rotary_trinkey_m0/mpconfigboard.mk similarity index 97% rename from ports/atmel-samd/boards/rotary_trinkey_m0/mpconfigboard.mk rename to ports/atmel-samd/boards/adafruit_rotary_trinkey_m0/mpconfigboard.mk index b071378c1d..29cc9ee195 100644 --- a/ports/atmel-samd/boards/rotary_trinkey_m0/mpconfigboard.mk +++ b/ports/atmel-samd/boards/adafruit_rotary_trinkey_m0/mpconfigboard.mk @@ -18,7 +18,7 @@ CIRCUITPY_PULSEIO = 0 CIRCUITPY_PWMIO = 0 CIRCUITPY_AUDIOCORE = 0 CIRCUITPY_BUSIO = 0 -CIRCUITPY_STORAGE = 0 +CIRCUITPY_STORAGE = 1 CIRCUITPY_MATH = 0 CIRCUITPY_PIXELBUF = 1 diff --git a/ports/atmel-samd/boards/rotary_trinkey_m0/pins.c b/ports/atmel-samd/boards/adafruit_rotary_trinkey_m0/pins.c similarity index 100% rename from ports/atmel-samd/boards/rotary_trinkey_m0/pins.c rename to ports/atmel-samd/boards/adafruit_rotary_trinkey_m0/pins.c diff --git a/ports/atmel-samd/boards/adafruit_slide_trinkey_m0/board.c b/ports/atmel-samd/boards/adafruit_slide_trinkey_m0/board.c new file mode 100644 index 0000000000..cde441b3d9 --- /dev/null +++ b/ports/atmel-samd/boards/adafruit_slide_trinkey_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 "supervisor/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/adafruit_slide_trinkey_m0/mpconfigboard.h b/ports/atmel-samd/boards/adafruit_slide_trinkey_m0/mpconfigboard.h new file mode 100644 index 0000000000..1d9a4122df --- /dev/null +++ b/ports/atmel-samd/boards/adafruit_slide_trinkey_m0/mpconfigboard.h @@ -0,0 +1,58 @@ +#define MICROPY_HW_BOARD_NAME "Adafruit Slide Trinkey M0" +#define MICROPY_HW_MCU_NAME "samd21e18" + +#define MICROPY_HW_NEOPIXEL (&pin_PA06) + +#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_PA02 1 +#define IGNORE_PIN_PA03 1 +#define IGNORE_PIN_PA04 1 +#define IGNORE_PIN_PA05 1 +#define IGNORE_PIN_PA08 1 +#define IGNORE_PIN_PA09 1 +#define IGNORE_PIN_PA10 1 +#define IGNORE_PIN_PA11 1 +#define IGNORE_PIN_PA12 1 +#define IGNORE_PIN_PA13 1 +#define IGNORE_PIN_PA14 1 +#define IGNORE_PIN_PA15 1 +#define IGNORE_PIN_PA16 1 +#define IGNORE_PIN_PA17 1 +#define IGNORE_PIN_PA18 1 +#define IGNORE_PIN_PA19 1 +#define IGNORE_PIN_PA20 1 +#define IGNORE_PIN_PA21 1 +// 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_PA29 1 +#define IGNORE_PIN_PA30 1 +#define IGNORE_PIN_PA31 1 +#define IGNORE_PIN_PB00 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 diff --git a/ports/atmel-samd/boards/adafruit_slide_trinkey_m0/mpconfigboard.mk b/ports/atmel-samd/boards/adafruit_slide_trinkey_m0/mpconfigboard.mk new file mode 100644 index 0000000000..2bc2def52e --- /dev/null +++ b/ports/atmel-samd/boards/adafruit_slide_trinkey_m0/mpconfigboard.mk @@ -0,0 +1,35 @@ +USB_VID = 0x239A +USB_PID = 0x8102 +USB_PRODUCT = "Slide Trinkey M0" +USB_MANUFACTURER = "Adafruit Industries LLC" + +CHIP_VARIANT = SAMD21E18A +CHIP_FAMILY = samd21 + +INTERNAL_FLASH_FILESYSTEM = 1 +LONGINT_IMPL = NONE + +CIRCUITPY_ANALOGIO = 1 +CIRCUITPY_ROTARYIO = 0 +CIRCUITPY_RTC = 0 +CIRCUITPY_SAMD = 0 +CIRCUITPY_PS2IO = 0 +CIRCUITPY_PULSEIO = 0 +CIRCUITPY_PWMIO = 0 +CIRCUITPY_AUDIOCORE = 0 +CIRCUITPY_BUSIO = 0 +CIRCUITPY_STORAGE = 1 + +CIRCUITPY_MATH = 1 +CIRCUITPY_PIXELBUF = 1 +CIRCUITPY_USB_MIDI = 1 +CIRCUITPY_TOUCHIO = 1 +CIRCUITPY_FULL_BUILD = 0 + +SUPEROPT_GC = 0 +SUPEROPT_VM = 0 + +# Include these Python libraries in firmware. +FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_SimpleMath +FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_NeoPixel +FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_HID diff --git a/ports/atmel-samd/boards/adafruit_slide_trinkey_m0/pins.c b/ports/atmel-samd/boards/adafruit_slide_trinkey_m0/pins.c new file mode 100644 index 0000000000..c48c69206a --- /dev/null +++ b/ports/atmel-samd/boards/adafruit_slide_trinkey_m0/pins.c @@ -0,0 +1,8 @@ +#include "shared-bindings/board/__init__.h" + +STATIC const mp_rom_map_elem_t board_global_dict_table[] = { + //{ MP_ROM_QSTR(MP_QSTR_TOUCH), MP_ROM_PTR(&pin_PA07) }, + { MP_ROM_QSTR(MP_QSTR_NEOPIXEL), MP_ROM_PTR(&pin_PA06) }, + { MP_ROM_QSTR(MP_QSTR_POTENTIOMETER), MP_ROM_PTR(&pin_PA07) }, +}; +MP_DEFINE_CONST_DICT(board_module_globals, board_global_dict_table); diff --git a/ports/atmel-samd/boards/feather_m0_adalogger/mpconfigboard.h b/ports/atmel-samd/boards/feather_m0_adalogger/mpconfigboard.h index a0fde67ef6..704c0552d3 100644 --- a/ports/atmel-samd/boards/feather_m0_adalogger/mpconfigboard.h +++ b/ports/atmel-samd/boards/feather_m0_adalogger/mpconfigboard.h @@ -8,8 +8,8 @@ #define MICROPY_PORT_B (0) #define MICROPY_PORT_C (0) -#define DEFAULT_I2C_BUS_SCL (&pin_PA22) -#define DEFAULT_I2C_BUS_SDA (&pin_PA23) +#define DEFAULT_I2C_BUS_SDA (&pin_PA22) +#define DEFAULT_I2C_BUS_SCL (&pin_PA23) #define DEFAULT_SPI_BUS_SCK (&pin_PB11) #define DEFAULT_SPI_BUS_MOSI (&pin_PB10) diff --git a/ports/atmel-samd/boards/neopixel_trinkey_m0/mpconfigboard.mk b/ports/atmel-samd/boards/neopixel_trinkey_m0/mpconfigboard.mk index 8607385d22..0f90dba6a1 100644 --- a/ports/atmel-samd/boards/neopixel_trinkey_m0/mpconfigboard.mk +++ b/ports/atmel-samd/boards/neopixel_trinkey_m0/mpconfigboard.mk @@ -18,7 +18,7 @@ CIRCUITPY_PULSEIO = 0 CIRCUITPY_PWMIO = 0 CIRCUITPY_AUDIOCORE = 0 CIRCUITPY_BUSIO = 0 -CIRCUITPY_STORAGE = 0 +CIRCUITPY_STORAGE = 1 CIRCUITPY_MATH = 1 CIRCUITPY_PIXELBUF = 1 diff --git a/ports/atmel-samd/boards/sensebox_mcu/board.c b/ports/atmel-samd/boards/sensebox_mcu/board.c new file mode 100644 index 0000000000..7af05ba45a --- /dev/null +++ b/ports/atmel-samd/boards/sensebox_mcu/board.c @@ -0,0 +1,39 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2017 Scott Shawcroft for Adafruit Industries + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include "supervisor/board.h" +#include "mpconfigboard.h" +#include "hal/include/hal_gpio.h" + +void board_init(void) { +} + +bool board_requests_safe_mode(void) { + return false; +} + +void reset_board(void) { +} diff --git a/ports/atmel-samd/boards/sensebox_mcu/mpconfigboard.h b/ports/atmel-samd/boards/sensebox_mcu/mpconfigboard.h new file mode 100644 index 0000000000..13aca289f6 --- /dev/null +++ b/ports/atmel-samd/boards/sensebox_mcu/mpconfigboard.h @@ -0,0 +1,24 @@ +#define MICROPY_HW_BOARD_NAME "senseBox MCU" +#define MICROPY_HW_MCU_NAME "senseBox" + +#define MICROPY_HW_LED_STATUS (&pin_PA27) + +#define MICROPY_PORT_A (0) +#define MICROPY_PORT_B (0) +#define MICROPY_PORT_C (0) + +#define DEFAULT_I2C_BUS_SCL (&pin_PA09) +#define DEFAULT_I2C_BUS_SDA (&pin_PA08) + +#define DEFAULT_SPI_BUS_SCK (&pin_PA17) +#define DEFAULT_SPI_BUS_MOSI (&pin_PA16) +#define DEFAULT_SPI_BUS_MISO (&pin_PA19) + +#define DEFAULT_UART_BUS_RX (&pin_PA23) +#define DEFAULT_UART_BUS_TX (&pin_PA22) + +#define SAMD21_BOD33_LEVEL (6) + +// 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/sensebox_mcu/mpconfigboard.mk b/ports/atmel-samd/boards/sensebox_mcu/mpconfigboard.mk new file mode 100644 index 0000000000..f5ce4a5d13 --- /dev/null +++ b/ports/atmel-samd/boards/sensebox_mcu/mpconfigboard.mk @@ -0,0 +1,14 @@ +USB_VID = 0x04D8 +USB_PID = 0xEF67 +USB_PRODUCT = "senseBox MCU" +USB_MANUFACTURER = "senseBox" + +CHIP_VARIANT = SAMD21G18A +CHIP_FAMILY = samd21 + +INTERNAL_FLASH_FILESYSTEM = 1 +LONGINT_IMPL = NONE +CIRCUITPY_FULL_BUILD = 0 + +SUPEROPT_GC = 0 +SUPEROPT_VM = 0 diff --git a/ports/atmel-samd/boards/sensebox_mcu/pins.c b/ports/atmel-samd/boards/sensebox_mcu/pins.c new file mode 100644 index 0000000000..55afcc989e --- /dev/null +++ b/ports/atmel-samd/boards/sensebox_mcu/pins.c @@ -0,0 +1,71 @@ +#include "shared-bindings/board/__init__.h" + +STATIC const mp_rom_map_elem_t board_global_dict_table[] = { + + // Analog pins + { MP_ROM_QSTR(MP_QSTR_A1), MP_ROM_PTR(&pin_PA04) }, + { MP_ROM_QSTR(MP_QSTR_A2), MP_ROM_PTR(&pin_PA05) }, + { MP_ROM_QSTR(MP_QSTR_A3), MP_ROM_PTR(&pin_PA06) }, + { MP_ROM_QSTR(MP_QSTR_A4), MP_ROM_PTR(&pin_PA07) }, + { MP_ROM_QSTR(MP_QSTR_A5), MP_ROM_PTR(&pin_PA03) }, + { MP_ROM_QSTR(MP_QSTR_A6), MP_ROM_PTR(&pin_PA02) }, + + // Digital pins + // { MP_ROM_QSTR(MP_QSTR_D0), MP_ROM_PTR(&pin_PA20) }, + { MP_ROM_QSTR(MP_QSTR_D1), MP_ROM_PTR(&pin_PA04) }, + { MP_ROM_QSTR(MP_QSTR_D2), MP_ROM_PTR(&pin_PA05) }, + { MP_ROM_QSTR(MP_QSTR_D3), MP_ROM_PTR(&pin_PA06) }, + { MP_ROM_QSTR(MP_QSTR_D4), MP_ROM_PTR(&pin_PA07) }, + { MP_ROM_QSTR(MP_QSTR_D5), MP_ROM_PTR(&pin_PA03) }, + { MP_ROM_QSTR(MP_QSTR_D6), MP_ROM_PTR(&pin_PA02) }, + { MP_ROM_QSTR(MP_QSTR_D7), MP_ROM_PTR(&pin_PA27) }, + { MP_ROM_QSTR(MP_QSTR_D8), MP_ROM_PTR(&pin_PA28) }, + { MP_ROM_QSTR(MP_QSTR_D9), MP_ROM_PTR(&pin_PB02) }, + { MP_ROM_QSTR(MP_QSTR_D10), MP_ROM_PTR(&pin_PA22) }, + { MP_ROM_QSTR(MP_QSTR_D11), MP_ROM_PTR(&pin_PA23) }, + { MP_ROM_QSTR(MP_QSTR_D12), MP_ROM_PTR(&pin_PB08) }, + { MP_ROM_QSTR(MP_QSTR_D13), MP_ROM_PTR(&pin_PB09) }, + + // UART pins + { MP_ROM_QSTR(MP_QSTR_UART_PWR), MP_ROM_PTR(&pin_PB02) }, + { MP_ROM_QSTR(MP_QSTR_TX1), MP_ROM_PTR(&pin_PA22) }, + { MP_ROM_QSTR(MP_QSTR_RX1), MP_ROM_PTR(&pin_PA23) }, + { MP_ROM_QSTR(MP_QSTR_TX2), MP_ROM_PTR(&pin_PB08) }, + { MP_ROM_QSTR(MP_QSTR_RX2), MP_ROM_PTR(&pin_PB09) }, + { MP_ROM_QSTR(MP_QSTR_TX), MP_ROM_PTR(&pin_PA22) }, // alias of TX1 + { MP_ROM_QSTR(MP_QSTR_RX), MP_ROM_PTR(&pin_PA23) }, // alias of RX1 + + // SPI pins + { MP_ROM_QSTR(MP_QSTR_MOSI), MP_ROM_PTR(&pin_PA16) }, + { MP_ROM_QSTR(MP_QSTR_SCK), MP_ROM_PTR(&pin_PA17) }, + { MP_ROM_QSTR(MP_QSTR_MISO), MP_ROM_PTR(&pin_PA19) }, + + // I2C pins + { MP_ROM_QSTR(MP_QSTR_I2C_PWR), MP_ROM_PTR(&pin_PB11) }, + { MP_ROM_QSTR(MP_QSTR_SCL), MP_ROM_PTR(&pin_PA09) }, + { MP_ROM_QSTR(MP_QSTR_SDA), MP_ROM_PTR(&pin_PA08) }, + + // LED pins + { MP_ROM_QSTR(MP_QSTR_LED), MP_ROM_PTR(&pin_PA27) }, + { MP_ROM_QSTR(MP_QSTR_RED_LED), MP_ROM_PTR(&pin_PA27) }, + { MP_ROM_QSTR(MP_QSTR_GREEN_LED), MP_ROM_PTR(&pin_PA28) }, + + // XBEE pins + { MP_ROM_QSTR(MP_QSTR_XB1_PWR), MP_ROM_PTR(&pin_PB03) }, + { MP_ROM_QSTR(MP_QSTR_XB2_PWR), MP_ROM_PTR(&pin_PB10) }, + { MP_ROM_QSTR(MP_QSTR_XB1_CS), MP_ROM_PTR(&pin_PA18) }, + { MP_ROM_QSTR(MP_QSTR_XB2_CS), MP_ROM_PTR(&pin_PA14) }, + { MP_ROM_QSTR(MP_QSTR_XB1_INT), MP_ROM_PTR(&pin_PA21) }, + { MP_ROM_QSTR(MP_QSTR_XB2_INT), MP_ROM_PTR(&pin_PA15) }, + { MP_ROM_QSTR(MP_QSTR_XB1_RX), MP_ROM_PTR(&pin_PA23) }, + { MP_ROM_QSTR(MP_QSTR_XB1_TX), MP_ROM_PTR(&pin_PA22) }, + { MP_ROM_QSTR(MP_QSTR_XB2_RX), MP_ROM_PTR(&pin_PA11) }, + { MP_ROM_QSTR(MP_QSTR_XB2_TX), MP_ROM_PTR(&pin_PA10) }, + + + // Comm objects + { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) }, + { MP_ROM_QSTR(MP_QSTR_SPI), MP_ROM_PTR(&board_spi_obj) }, + { MP_ROM_QSTR(MP_QSTR_UART), MP_ROM_PTR(&board_uart_obj) }, +}; +MP_DEFINE_CONST_DICT(board_module_globals, board_global_dict_table); diff --git a/ports/atmel-samd/mpconfigport.mk b/ports/atmel-samd/mpconfigport.mk index 2962035cb9..f04055d43b 100644 --- a/ports/atmel-samd/mpconfigport.mk +++ b/ports/atmel-samd/mpconfigport.mk @@ -41,6 +41,7 @@ CIRCUITPY_BUILTINS_POW3 ?= 0 CIRCUITPY_COMPUTED_GOTO_SAVE_SPACE ?= 1 CIRCUITPY_FREQUENCYIO ?= 0 CIRCUITPY_JSON ?= 0 +CIRCUITPY_SYNTHIO ?= 0 CIRCUITPY_TOUCHIO_USE_NATIVE ?= 1 # No room for HCI _bleio on SAMD21. @@ -87,3 +88,22 @@ CIRCUITPY_FRAMEBUFFERIO ?= $(CIRCUITPY_FULL_BUILD) endif # samd51 ###################################################################### + +###################################################################### +# Put same51-only choices here. + +ifeq ($(CHIP_FAMILY),same51) + +# No native touchio on SAMD51. +CIRCUITPY_TOUCHIO_USE_NATIVE = 0 + +# The ?='s allow overriding in mpconfigboard.mk. + +CIRCUITPY_NETWORK ?= 0 +CIRCUITPY_PS2IO ?= 1 +CIRCUITPY_SAMD ?= 1 +CIRCUITPY_RGBMATRIX ?= $(CIRCUITPY_FULL_BUILD) +CIRCUITPY_FRAMEBUFFERIO ?= $(CIRCUITPY_FULL_BUILD) + +endif # same51 +###################################################################### diff --git a/ports/esp32s2/boards/atmegazero_esp32s2/board.c b/ports/esp32s2/boards/atmegazero_esp32s2/board.c new file mode 100644 index 0000000000..d8fd3a0a2b --- /dev/null +++ b/ports/esp32s2/boards/atmegazero_esp32s2/board.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 "supervisor/board.h" +#include "mpconfigboard.h" +#include "shared-bindings/microcontroller/Pin.h" + +void board_init(void) { + // USB + common_hal_never_reset_pin(&pin_GPIO19); + common_hal_never_reset_pin(&pin_GPIO20); + + // Debug UART +#ifdef DEBUG + common_hal_never_reset_pin(&pin_GPIO43); + common_hal_never_reset_pin(&pin_GPIO44); +#endif /* DEBUG */ + + // SPI Flash and RAM + common_hal_never_reset_pin(&pin_GPIO26); + common_hal_never_reset_pin(&pin_GPIO27); + common_hal_never_reset_pin(&pin_GPIO28); + common_hal_never_reset_pin(&pin_GPIO29); + common_hal_never_reset_pin(&pin_GPIO30); + common_hal_never_reset_pin(&pin_GPIO31); + common_hal_never_reset_pin(&pin_GPIO32); +} + +bool board_requests_safe_mode(void) { + return false; +} + +void reset_board(void) { + +} + +void board_deinit(void) { +} diff --git a/ports/esp32s2/boards/atmegazero_esp32s2/mpconfigboard.h b/ports/esp32s2/boards/atmegazero_esp32s2/mpconfigboard.h new file mode 100644 index 0000000000..3ef4e7eede --- /dev/null +++ b/ports/esp32s2/boards/atmegazero_esp32s2/mpconfigboard.h @@ -0,0 +1,47 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2019 Scott Shawcroft for Adafruit Industries + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +//Micropython setup + +#define MICROPY_HW_BOARD_NAME "ATMegaZero ESP32-S2" +#define MICROPY_HW_MCU_NAME "ESP32S2" + +#define CIRCUITPY_BOOT_BUTTON (&pin_GPIO0) +#define BOARD_USER_SAFE_MODE_ACTION translate("pressing boot button at start up.\n") + +#define AUTORESET_DELAY_MS 500 + +#define DEFAULT_I2C_BUS_SCL (&pin_GPIO9) +#define DEFAULT_I2C_BUS_SDA (&pin_GPIO8) + +#define DEFAULT_SPI_BUS_SCK (&pin_GPIO36) +#define DEFAULT_SPI_BUS_MOSI (&pin_GPIO35) +#define DEFAULT_SPI_BUS_MISO (&pin_GPIO37) + +#define DEFAULT_UART_BUS_RX (&pin_GPIO44) +#define DEFAULT_UART_BUS_TX (&pin_GPIO43) + +#define MICROPY_HW_NEOPIXEL (&pin_GPIO40) diff --git a/ports/esp32s2/boards/atmegazero_esp32s2/mpconfigboard.mk b/ports/esp32s2/boards/atmegazero_esp32s2/mpconfigboard.mk new file mode 100644 index 0000000000..9a5d947e6c --- /dev/null +++ b/ports/esp32s2/boards/atmegazero_esp32s2/mpconfigboard.mk @@ -0,0 +1,15 @@ +USB_VID = 0x239A +USB_PID = 0x8009 +USB_PRODUCT = "ATMegaZero ESP32-S2" +USB_MANUFACTURER = "ATMegaZero" + +INTERNAL_FLASH_FILESYSTEM = 1 +LONGINT_IMPL = MPZ + +# The default queue depth of 16 overflows on release builds, +# so increase it to 32. +CFLAGS += -DCFG_TUD_TASK_QUEUE_SZ=32 + +CIRCUITPY_ESP_FLASH_MODE=qio +CIRCUITPY_ESP_FLASH_FREQ=40m +CIRCUITPY_ESP_FLASH_SIZE=16MB diff --git a/ports/esp32s2/boards/atmegazero_esp32s2/pins.c b/ports/esp32s2/boards/atmegazero_esp32s2/pins.c new file mode 100644 index 0000000000..cfc4ef6223 --- /dev/null +++ b/ports/esp32s2/boards/atmegazero_esp32s2/pins.c @@ -0,0 +1,80 @@ +#include "shared-bindings/board/__init__.h" + +STATIC const mp_rom_map_elem_t board_global_dict_table[] = { + { MP_ROM_QSTR(MP_QSTR_IO0), MP_ROM_PTR(&pin_GPIO0) }, + { MP_ROM_QSTR(MP_QSTR_IO1), MP_ROM_PTR(&pin_GPIO1) }, + { MP_ROM_QSTR(MP_QSTR_IO2), MP_ROM_PTR(&pin_GPIO2) }, + { MP_ROM_QSTR(MP_QSTR_IO3), MP_ROM_PTR(&pin_GPIO3) }, + { MP_ROM_QSTR(MP_QSTR_IO4), MP_ROM_PTR(&pin_GPIO4) }, + { MP_ROM_QSTR(MP_QSTR_IO5), MP_ROM_PTR(&pin_GPIO5) }, + { MP_ROM_QSTR(MP_QSTR_IO6), MP_ROM_PTR(&pin_GPIO6) }, + { MP_ROM_QSTR(MP_QSTR_IO7), MP_ROM_PTR(&pin_GPIO7) }, + { MP_ROM_QSTR(MP_QSTR_IO8), MP_ROM_PTR(&pin_GPIO8) }, + { MP_ROM_QSTR(MP_QSTR_IO9), MP_ROM_PTR(&pin_GPIO9) }, + { MP_ROM_QSTR(MP_QSTR_IO10), MP_ROM_PTR(&pin_GPIO10) }, + { MP_ROM_QSTR(MP_QSTR_IO11), MP_ROM_PTR(&pin_GPIO11) }, + { MP_ROM_QSTR(MP_QSTR_IO12), MP_ROM_PTR(&pin_GPIO12) }, + { MP_ROM_QSTR(MP_QSTR_IO13), MP_ROM_PTR(&pin_GPIO13) }, + { MP_ROM_QSTR(MP_QSTR_IO14), MP_ROM_PTR(&pin_GPIO14) }, + { MP_ROM_QSTR(MP_QSTR_IO17), MP_ROM_PTR(&pin_GPIO17) }, + { MP_ROM_QSTR(MP_QSTR_IO18), MP_ROM_PTR(&pin_GPIO18) }, + { MP_ROM_QSTR(MP_QSTR_IO21), MP_ROM_PTR(&pin_GPIO21) }, + { MP_ROM_QSTR(MP_QSTR_IO33), MP_ROM_PTR(&pin_GPIO33) }, + { MP_ROM_QSTR(MP_QSTR_IO34), MP_ROM_PTR(&pin_GPIO34) }, + { MP_ROM_QSTR(MP_QSTR_IO35), MP_ROM_PTR(&pin_GPIO35) }, + { MP_ROM_QSTR(MP_QSTR_IO36), MP_ROM_PTR(&pin_GPIO36) }, + { MP_ROM_QSTR(MP_QSTR_IO37), MP_ROM_PTR(&pin_GPIO37) }, + { MP_ROM_QSTR(MP_QSTR_IO38), MP_ROM_PTR(&pin_GPIO38) }, + { MP_ROM_QSTR(MP_QSTR_IO40), MP_ROM_PTR(&pin_GPIO40) }, + { MP_ROM_QSTR(MP_QSTR_IO43), MP_ROM_PTR(&pin_GPIO43) }, + { MP_ROM_QSTR(MP_QSTR_IO44), MP_ROM_PTR(&pin_GPIO44) }, + + { MP_ROM_QSTR(MP_QSTR_PD5), MP_ROM_PTR(&pin_GPIO0) }, + { MP_ROM_QSTR(MP_QSTR_D5), MP_ROM_PTR(&pin_GPIO1) }, + { MP_ROM_QSTR(MP_QSTR_D6), MP_ROM_PTR(&pin_GPIO2) }, + { MP_ROM_QSTR(MP_QSTR_A5), MP_ROM_PTR(&pin_GPIO3) }, + { MP_ROM_QSTR(MP_QSTR_D7), MP_ROM_PTR(&pin_GPIO4) }, + { MP_ROM_QSTR(MP_QSTR_HWD), MP_ROM_PTR(&pin_GPIO5) }, + { MP_ROM_QSTR(MP_QSTR_A4), MP_ROM_PTR(&pin_GPIO6) }, + { MP_ROM_QSTR(MP_QSTR_D9), MP_ROM_PTR(&pin_GPIO7) }, + { MP_ROM_QSTR(MP_QSTR_D2), MP_ROM_PTR(&pin_GPIO8) }, + { MP_ROM_QSTR(MP_QSTR_D3), MP_ROM_PTR(&pin_GPIO9) }, + { MP_ROM_QSTR(MP_QSTR_D12), MP_ROM_PTR(&pin_GPIO10) }, + { MP_ROM_QSTR(MP_QSTR_D13), MP_ROM_PTR(&pin_GPIO11) }, + { MP_ROM_QSTR(MP_QSTR_A3), MP_ROM_PTR(&pin_GPIO12) }, + { MP_ROM_QSTR(MP_QSTR_A2), MP_ROM_PTR(&pin_GPIO13) }, + { MP_ROM_QSTR(MP_QSTR_AREF), MP_ROM_PTR(&pin_GPIO14) }, + { MP_ROM_QSTR(MP_QSTR_A0), MP_ROM_PTR(&pin_GPIO17) }, + { MP_ROM_QSTR(MP_QSTR_A1), MP_ROM_PTR(&pin_GPIO18) }, + { MP_ROM_QSTR(MP_QSTR_D10), MP_ROM_PTR(&pin_GPIO21) }, + { MP_ROM_QSTR(MP_QSTR_D4), MP_ROM_PTR(&pin_GPIO33) }, + { MP_ROM_QSTR(MP_QSTR_D8), MP_ROM_PTR(&pin_GPIO34) }, + { MP_ROM_QSTR(MP_QSTR_D14), MP_ROM_PTR(&pin_GPIO35) }, + { MP_ROM_QSTR(MP_QSTR_D15), MP_ROM_PTR(&pin_GPIO36) }, + { MP_ROM_QSTR(MP_QSTR_D16), MP_ROM_PTR(&pin_GPIO37) }, + { MP_ROM_QSTR(MP_QSTR_D11), MP_ROM_PTR(&pin_GPIO38) }, + { MP_ROM_QSTR(MP_QSTR_D1), MP_ROM_PTR(&pin_GPIO43) }, + { MP_ROM_QSTR(MP_QSTR_D2), MP_ROM_PTR(&pin_GPIO44) }, + + { MP_ROM_QSTR(MP_QSTR_SD_CS), MP_ROM_PTR(&pin_GPIO0) }, + + { MP_ROM_QSTR(MP_QSTR_SDA), MP_ROM_PTR(&pin_GPIO8) }, + { MP_ROM_QSTR(MP_QSTR_SCL), MP_ROM_PTR(&pin_GPIO9) }, + + { MP_ROM_QSTR(MP_QSTR_DAC1), MP_ROM_PTR(&pin_GPIO17) }, + { MP_ROM_QSTR(MP_QSTR_DAC2), MP_ROM_PTR(&pin_GPIO18) }, + + { MP_ROM_QSTR(MP_QSTR_MISO), MP_ROM_PTR(&pin_GPIO35) }, + { MP_ROM_QSTR(MP_QSTR_SCK), MP_ROM_PTR(&pin_GPIO36) }, + { MP_ROM_QSTR(MP_QSTR_MOSI), MP_ROM_PTR(&pin_GPIO37) }, + + { MP_ROM_QSTR(MP_QSTR_NEOPIXEL), MP_ROM_PTR(&pin_GPIO40) }, + + { MP_ROM_QSTR(MP_QSTR_TX), MP_ROM_PTR(&pin_GPIO43) }, + { MP_ROM_QSTR(MP_QSTR_RX), MP_ROM_PTR(&pin_GPIO44) }, + + { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) }, + { MP_ROM_QSTR(MP_QSTR_SPI), MP_ROM_PTR(&board_spi_obj) }, + { MP_ROM_QSTR(MP_QSTR_UART), MP_ROM_PTR(&board_uart_obj) }, +}; +MP_DEFINE_CONST_DICT(board_module_globals, board_global_dict_table); diff --git a/ports/esp32s2/boards/atmegazero_esp32s2/sdkconfig b/ports/esp32s2/boards/atmegazero_esp32s2/sdkconfig new file mode 100644 index 0000000000..f42e0784c4 --- /dev/null +++ b/ports/esp32s2/boards/atmegazero_esp32s2/sdkconfig @@ -0,0 +1,39 @@ +CONFIG_ESP32S2_SPIRAM_SUPPORT=y + +# +# SPI RAM config +# +# CONFIG_SPIRAM_TYPE_AUTO is not set +# CONFIG_SPIRAM_TYPE_ESPPSRAM16 is not set +# CONFIG_SPIRAM_TYPE_ESPPSRAM32 is not set +CONFIG_SPIRAM_TYPE_ESPPSRAM64=y +CONFIG_SPIRAM_SIZE=8388608 + +# +# PSRAM clock and cs IO for ESP32S2 +# +CONFIG_DEFAULT_PSRAM_CLK_IO=30 +CONFIG_DEFAULT_PSRAM_CS_IO=26 +# end of PSRAM clock and cs IO for ESP32S2 + +# CONFIG_SPIRAM_FETCH_INSTRUCTIONS is not set +# CONFIG_SPIRAM_RODATA is not set +# CONFIG_SPIRAM_SPEED_80M is not set +CONFIG_SPIRAM_SPEED_40M=y +# CONFIG_SPIRAM_SPEED_26M is not set +# CONFIG_SPIRAM_SPEED_20M is not set +CONFIG_SPIRAM=y +CONFIG_SPIRAM_BOOT_INIT=y +# CONFIG_SPIRAM_IGNORE_NOTFOUND is not set +CONFIG_SPIRAM_USE_MEMMAP=y +# CONFIG_SPIRAM_USE_CAPS_ALLOC is not set +# CONFIG_SPIRAM_USE_MALLOC is not set +CONFIG_SPIRAM_MEMTEST=y +# CONFIG_SPIRAM_ALLOW_BSS_SEG_EXTERNAL_MEMORY is not set +# end of SPI RAM config + +# +# LWIP +# +CONFIG_LWIP_LOCAL_HOSTNAME="ATMegaZero-Esp32s2" +# end of LWIP diff --git a/ports/nrf/boards/aramcon2_badge/board.c b/ports/nrf/boards/aramcon2_badge/board.c new file mode 100644 index 0000000000..1759822a2a --- /dev/null +++ b/ports/nrf/boards/aramcon2_badge/board.c @@ -0,0 +1,40 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2021 Uri Shaked + * Copyright (c) 2021 Benjamin Meisels + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include "supervisor/board.h" +#include "common-hal/microcontroller/Pin.h" + +void board_init(void) { +} + +bool board_requests_safe_mode(void) { + return false; +} + +void reset_board(void) { + +} diff --git a/ports/nrf/boards/aramcon2_badge/mpconfigboard.h b/ports/nrf/boards/aramcon2_badge/mpconfigboard.h new file mode 100644 index 0000000000..7691d1e461 --- /dev/null +++ b/ports/nrf/boards/aramcon2_badge/mpconfigboard.h @@ -0,0 +1,68 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2021 Uri Shaked + * Copyright (c) 2021 Benjamin Meisels + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +#include "nrfx/hal/nrf_gpio.h" + +#define MICROPY_HW_BOARD_NAME "ARAMCON2 Badge" +#define MICROPY_HW_MCU_NAME "nRF52840" + +#define MICROPY_HW_LED_STATUS (&pin_P1_11) + +// Board does not have a 32kHz crystal. It does have a 32MHz crystal. +#define BOARD_HAS_32KHZ_XTAL (0) + +#ifdef QSPI_FLASH_FILESYSTEM +#define MICROPY_QSPI_DATA0 NRF_GPIO_PIN_MAP(0, 22) +#define MICROPY_QSPI_DATA1 NRF_GPIO_PIN_MAP(0, 20) +#define MICROPY_QSPI_DATA2 NRF_GPIO_PIN_MAP(1, 4) +#define MICROPY_QSPI_DATA3 NRF_GPIO_PIN_MAP(1, 6) +#define MICROPY_QSPI_SCK NRF_GPIO_PIN_MAP(1, 0) +#define MICROPY_QSPI_CS NRF_GPIO_PIN_MAP(1, 2) +#endif + +#ifdef SPI_FLASH_FILESYSTEM +#define SPI_FLASH_MOSI_PIN &pin_P0_20 +#define SPI_FLASH_MISO_PIN &pin_P0_22 +#define SPI_FLASH_SCK_PIN &pin_P1_00 +#define SPI_FLASH_CS_PIN &pin_P1_02 +#endif + +#define CIRCUITPY_BOOT_BUTTON (&pin_P0_29) + +#define BOARD_USER_SAFE_MODE_ACTION translate("pressing the left button at start up\n") + +#define CIRCUITPY_AUTORELOAD_DELAY_MS 500 + +#define CIRCUITPY_INTERNAL_NVM_SIZE (4096) + +#define BOARD_FLASH_SIZE (FLASH_SIZE - 0x4000 - CIRCUITPY_INTERNAL_NVM_SIZE) + +#define DEFAULT_I2C_BUS_SCL (&pin_P0_28) +#define DEFAULT_I2C_BUS_SDA (&pin_P0_03) + +#define DEFAULT_SPI_BUS_SCK (&pin_P0_01) +#define DEFAULT_SPI_BUS_MOSI (&pin_P1_10) +#define DEFAULT_SPI_BUS_MISO (&pin_P1_09) diff --git a/ports/nrf/boards/aramcon2_badge/mpconfigboard.mk b/ports/nrf/boards/aramcon2_badge/mpconfigboard.mk new file mode 100644 index 0000000000..514712f489 --- /dev/null +++ b/ports/nrf/boards/aramcon2_badge/mpconfigboard.mk @@ -0,0 +1,11 @@ +USB_VID = 0x239A +USB_PID = 0x807C +USB_PRODUCT = "ARAMCON2 Badge" +USB_MANUFACTURER = "ARAMCON Badge Team" + +MCU_CHIP = nrf52840 + +QSPI_FLASH_FILESYSTEM = 1 +EXTERNAL_FLASH_DEVICES = "W25Q128JVxQ" + +CIRCUITPY_DISPLAYIO = 1 diff --git a/ports/nrf/boards/aramcon2_badge/pins.c b/ports/nrf/boards/aramcon2_badge/pins.c new file mode 100644 index 0000000000..0a44f0d5a9 --- /dev/null +++ b/ports/nrf/boards/aramcon2_badge/pins.c @@ -0,0 +1,42 @@ +#include "shared-bindings/board/__init__.h" + +STATIC const mp_rom_map_elem_t board_module_globals_table[] = { + { MP_ROM_QSTR(MP_QSTR_UP_BUTTON), MP_ROM_PTR(&pin_P0_31) }, + { MP_ROM_QSTR(MP_QSTR_LEFT_BUTTON), MP_ROM_PTR(&pin_P0_29) }, + { MP_ROM_QSTR(MP_QSTR_DOWN_BUTTON), MP_ROM_PTR(&pin_P1_13) }, + { MP_ROM_QSTR(MP_QSTR_RIGHT_BUTTON), MP_ROM_PTR(&pin_P0_02) }, + { MP_ROM_QSTR(MP_QSTR_ACTION_BUTTON), MP_ROM_PTR(&pin_P0_10) }, + + { MP_ROM_QSTR(MP_QSTR_LED), MP_ROM_PTR(&pin_P1_11) }, + + { MP_ROM_QSTR(MP_QSTR_SCL), MP_ROM_PTR(&pin_P0_28) }, + { MP_ROM_QSTR(MP_QSTR_SDA), MP_ROM_PTR(&pin_P0_03) }, + + { MP_ROM_QSTR(MP_QSTR_SCK), MP_ROM_PTR(&pin_P0_01) }, + { MP_ROM_QSTR(MP_QSTR_MOSI), MP_ROM_PTR(&pin_P1_10) }, + { MP_ROM_QSTR(MP_QSTR_MISO), MP_ROM_PTR(&pin_P1_09) }, + + { MP_ROM_QSTR(MP_QSTR_GPIO1), MP_ROM_PTR(&pin_P0_04) }, + { MP_ROM_QSTR(MP_QSTR_GPIO2), MP_ROM_PTR(&pin_P0_05) }, + + { MP_ROM_QSTR(MP_QSTR_D1), MP_ROM_PTR(&pin_P0_15) }, + { MP_ROM_QSTR(MP_QSTR_D2), MP_ROM_PTR(&pin_P0_00) }, + { MP_ROM_QSTR(MP_QSTR_D3), MP_ROM_PTR(&pin_P0_13) }, + { MP_ROM_QSTR(MP_QSTR_D4), MP_ROM_PTR(&pin_P0_24) }, + + { MP_ROM_QSTR(MP_QSTR_DISP_BUSY), MP_ROM_PTR(&pin_P0_26) }, + { MP_ROM_QSTR(MP_QSTR_DISP_CS), MP_ROM_PTR(&pin_P0_07) }, + { MP_ROM_QSTR(MP_QSTR_DISP_DC), MP_ROM_PTR(&pin_P0_12) }, + { MP_ROM_QSTR(MP_QSTR_DISP_RESET), MP_ROM_PTR(&pin_P0_06) }, + + { MP_ROM_QSTR(MP_QSTR_NEOPIXEL), MP_ROM_PTR(&pin_P0_08) }, + + { MP_ROM_QSTR(MP_QSTR_VIBRATION_MOTOR), MP_ROM_PTR(&pin_P0_17) }, + + { MP_ROM_QSTR(MP_QSTR_BATTERY_SENSE), MP_ROM_PTR(&pin_P0_30) }, + + { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) }, + { MP_ROM_QSTR(MP_QSTR_SPI), MP_ROM_PTR(&board_spi_obj) }, +}; + +MP_DEFINE_CONST_DICT(board_module_globals, board_module_globals_table); diff --git a/ports/nrf/boards/pca10100/mpconfigboard.mk b/ports/nrf/boards/pca10100/mpconfigboard.mk index 74080a1ed9..dd59eb96c9 100644 --- a/ports/nrf/boards/pca10100/mpconfigboard.mk +++ b/ports/nrf/boards/pca10100/mpconfigboard.mk @@ -7,6 +7,7 @@ MCU_CHIP = nrf52833 INTERNAL_FLASH_FILESYSTEM = 1 +CIRCUITPY_ALARM = 0 CIRCUITPY_AUDIOMP3 = 0 CIRCUITPY_BITBANGIO = 0 CIRCUITPY_BITMAPTOOLS = 0 diff --git a/ports/nrf/boards/simmel/mpconfigboard.mk b/ports/nrf/boards/simmel/mpconfigboard.mk index 005ec8af2f..e235fd1051 100644 --- a/ports/nrf/boards/simmel/mpconfigboard.mk +++ b/ports/nrf/boards/simmel/mpconfigboard.mk @@ -10,11 +10,13 @@ MCU_CHIP = nrf52833 INTERNAL_FLASH_FILESYSTEM = 1 +CIRCUITPY_ALARM = 0 CIRCUITPY_AESIO = 1 CIRCUITPY_AUDIOMP3 = 0 CIRCUITPY_BITMAPTOOLS = 0 CIRCUITPY_BUSDEVICE = 0 CIRCUITPY_BUSIO = 1 +CIRCUITPY_COUNTIO = 0 CIRCUITPY_DISPLAYIO = 0 CIRCUITPY_ERRNO = 0 CIRCUITPY_FRAMEBUFFERIO = 0 @@ -23,10 +25,13 @@ CIRCUITPY_MSGPACK = 0 CIRCUITPY_NEOPIXEL_WRITE = 0 CIRCUITPY_NVM = 0 CIRCUITPY_PIXELBUF = 0 +CIRCUITPY_PULSEIO = 0 +CIRCUITPY_PWMIO = 1 CIRCUITPY_RGBMATRIX = 0 CIRCUITPY_ROTARYIO = 0 CIRCUITPY_RTC = 1 CIRCUITPY_SDCARDIO = 0 +CIRCUITPY_SYNTHIO = 0 CIRCUITPY_TOUCHIO = 0 CIRCUITPY_ULAB = 0 CIRCUITPY_USB_CDC = 0 diff --git a/ports/nrf/common-hal/_bleio/Characteristic.c b/ports/nrf/common-hal/_bleio/Characteristic.c index 4c5de3124e..f651b93b6b 100644 --- a/ports/nrf/common-hal/_bleio/Characteristic.c +++ b/ports/nrf/common-hal/_bleio/Characteristic.c @@ -131,6 +131,10 @@ size_t common_hal_bleio_characteristic_get_value(bleio_characteristic_obj_t *sel return 0; } +size_t common_hal_bleio_characteristic_get_max_length(bleio_characteristic_obj_t *self) { + return self->max_length; +} + void common_hal_bleio_characteristic_set_value(bleio_characteristic_obj_t *self, mp_buffer_info_t *bufinfo) { // Do GATT operations only if this characteristic has been added to a registered service. if (self->handle != BLE_GATT_HANDLE_INVALID) { diff --git a/ports/nrf/common-hal/_bleio/PacketBuffer.c b/ports/nrf/common-hal/_bleio/PacketBuffer.c index 42fc3475d6..260e20514b 100644 --- a/ports/nrf/common-hal/_bleio/PacketBuffer.c +++ b/ports/nrf/common-hal/_bleio/PacketBuffer.c @@ -42,7 +42,8 @@ STATIC void write_to_ringbuf(bleio_packet_buffer_obj_t *self, uint8_t *data, uint16_t len) { if (len + sizeof(uint16_t) > ringbuf_capacity(&self->ringbuf)) { - // This shouldn't happen. + // This shouldn't happen but can if our buffer size was much smaller than + // the writes the client actually makes. return; } // Push all the data onto the ring buffer. @@ -189,7 +190,7 @@ STATIC bool packet_buffer_on_ble_server_evt(ble_evt_t *ble_evt, void *param) { void common_hal_bleio_packet_buffer_construct( bleio_packet_buffer_obj_t *self, bleio_characteristic_obj_t *characteristic, - size_t buffer_size) { + size_t buffer_size, size_t max_packet_size) { self->characteristic = characteristic; self->client = self->characteristic->service->is_remote; @@ -206,8 +207,11 @@ void common_hal_bleio_packet_buffer_construct( self->conn_handle = BLE_CONN_HANDLE_INVALID; } + // Cap the packet size to our implementation limits. + self->max_packet_size = MIN(max_packet_size, BLE_GATTS_VAR_ATTR_LEN_MAX - 3); + if (incoming) { - if (!ringbuf_alloc(&self->ringbuf, buffer_size * (sizeof(uint16_t) + characteristic->max_length), false)) { + if (!ringbuf_alloc(&self->ringbuf, buffer_size * (sizeof(uint16_t) + self->max_packet_size), false)) { mp_raise_ValueError(translate("Buffer too large and unable to allocate")); } } @@ -216,8 +220,8 @@ void common_hal_bleio_packet_buffer_construct( self->packet_queued = false; self->pending_index = 0; self->pending_size = 0; - self->outgoing[0] = m_malloc(characteristic->max_length, false); - self->outgoing[1] = m_malloc(characteristic->max_length, false); + self->outgoing[0] = m_malloc(self->max_packet_size, false); + self->outgoing[1] = m_malloc(self->max_packet_size, false); } else { self->outgoing[0] = NULL; self->outgoing[1] = NULL; @@ -296,10 +300,16 @@ mp_int_t common_hal_bleio_packet_buffer_write(bleio_packet_buffer_obj_t *self, u } uint16_t outgoing_packet_length = common_hal_bleio_packet_buffer_get_outgoing_packet_length(self); - if (len + header_len > outgoing_packet_length) { + uint16_t total_len = len + header_len; + if (total_len > outgoing_packet_length) { // Supplied data will not fit in a single BLE packet. - mp_raise_ValueError(translate("Total data to write is larger than outgoing_packet_length")); + mp_raise_ValueError_varg(translate("Total data to write is larger than %q"), MP_QSTR_outgoing_packet_length); } + if (total_len > self->max_packet_size) { + // Supplied data will not fit in a single BLE packet. + mp_raise_ValueError_varg(translate("Total data to write is larger than %q"), MP_QSTR_max_packet_size); + } + outgoing_packet_length = MIN(outgoing_packet_length, self->max_packet_size); if (len + self->pending_size > outgoing_packet_length) { // No room to append len bytes to packet. Wait until we get a free buffer, @@ -390,8 +400,9 @@ mp_int_t common_hal_bleio_packet_buffer_get_outgoing_packet_length(bleio_packet_ if (self->conn_handle != BLE_CONN_HANDLE_INVALID) { bleio_connection_internal_t *connection = bleio_conn_handle_to_connection(self->conn_handle); if (connection) { - return MIN(common_hal_bleio_connection_get_max_packet_length(connection), - self->characteristic->max_length); + return MIN(MIN(common_hal_bleio_connection_get_max_packet_length(connection), + self->max_packet_size), + self->characteristic->max_length); } } // There's no current connection, so we don't know the MTU, and @@ -406,11 +417,12 @@ mp_int_t common_hal_bleio_packet_buffer_get_outgoing_packet_length(bleio_packet_ if (self->conn_handle != BLE_CONN_HANDLE_INVALID) { bleio_connection_internal_t *connection = bleio_conn_handle_to_connection(self->conn_handle); if (connection) { - return common_hal_bleio_connection_get_max_packet_length(connection); + return MIN(common_hal_bleio_connection_get_max_packet_length(connection), + self->max_packet_size); } } } - return self->characteristic->max_length; + return MIN(self->characteristic->max_length, self->max_packet_size); } bool common_hal_bleio_packet_buffer_deinited(bleio_packet_buffer_obj_t *self) { diff --git a/ports/nrf/common-hal/_bleio/PacketBuffer.h b/ports/nrf/common-hal/_bleio/PacketBuffer.h index 94e0f11d80..6f2626565b 100644 --- a/ports/nrf/common-hal/_bleio/PacketBuffer.h +++ b/ports/nrf/common-hal/_bleio/PacketBuffer.h @@ -44,6 +44,7 @@ typedef struct { // We remember the conn_handle so we can do a NOTIFY/INDICATE to a client. // We can find out the conn_handle on a Characteristic write or a CCCD write (but not a read). volatile uint16_t conn_handle; + uint16_t max_packet_size; uint8_t pending_index; uint8_t write_type; bool client; diff --git a/ports/nrf/common-hal/alarm/SleepMemory.c b/ports/nrf/common-hal/alarm/SleepMemory.c index 367f305972..e20f893567 100644 --- a/ports/nrf/common-hal/alarm/SleepMemory.c +++ b/ports/nrf/common-hal/alarm/SleepMemory.c @@ -3,8 +3,7 @@ * * The MIT License (MIT) * - * Copyright (c) 2020 microDev - * Copyright (c) 2020 Dan Halbert for Adafruit Industries + * Copyright (c) 2021 Junji Sakai * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -57,22 +56,22 @@ void set_memory_retention(void) { // nRF52833 has RAM[0..7].Section[0..1] and RAM[8].Section[0,1] for(int block = 0; block <= 7; ++block) { nrf_power_rampower_mask_on(NRF_POWER, block, - NRF_POWER_RAMPOWER_S0RETENTION_MASK | - NRF_POWER_RAMPOWER_S1RETENTION_MASK); + NRF_POWER_RAMPOWER_S0RETENTION_MASK | + NRF_POWER_RAMPOWER_S1RETENTION_MASK); }; #ifdef NRF52840 nrf_power_rampower_mask_on(NRF_POWER, 8, - NRF_POWER_RAMPOWER_S0RETENTION_MASK | - NRF_POWER_RAMPOWER_S1RETENTION_MASK | - NRF_POWER_RAMPOWER_S2RETENTION_MASK | - NRF_POWER_RAMPOWER_S3RETENTION_MASK | - NRF_POWER_RAMPOWER_S4RETENTION_MASK | - NRF_POWER_RAMPOWER_S5RETENTION_MASK); + NRF_POWER_RAMPOWER_S0RETENTION_MASK | + NRF_POWER_RAMPOWER_S1RETENTION_MASK | + NRF_POWER_RAMPOWER_S2RETENTION_MASK | + NRF_POWER_RAMPOWER_S3RETENTION_MASK | + NRF_POWER_RAMPOWER_S4RETENTION_MASK | + NRF_POWER_RAMPOWER_S5RETENTION_MASK); #endif #ifdef NRF52833 nrf_power_rampower_mask_on(NRF_POWER, 8, - NRF_POWER_RAMPOWER_S0RETENTION_MASK | - NRF_POWER_RAMPOWER_S1RETENTION_MASK); + NRF_POWER_RAMPOWER_S0RETENTION_MASK | + NRF_POWER_RAMPOWER_S1RETENTION_MASK); #endif } @@ -93,7 +92,7 @@ void alarm_sleep_memory_reset(void) { if (!is_sleep_memory_valid()) { initialize_sleep_memory(); #ifdef NRF_DEBUG_PRINT - dbg_printf("sleep memory initialized\r\n"); + dbg_printf("sleep memory initialized\r\n"); #endif } } diff --git a/ports/nrf/common-hal/alarm/SleepMemory.h b/ports/nrf/common-hal/alarm/SleepMemory.h index 11cc4a8fb9..8fd702ea83 100644 --- a/ports/nrf/common-hal/alarm/SleepMemory.h +++ b/ports/nrf/common-hal/alarm/SleepMemory.h @@ -3,7 +3,7 @@ * * The MIT License (MIT) * - * Copyright (c) 2020 Dan Halbert for Adafruit Industries + * Copyright (c) 2021 Junji Sakai * * 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/ports/nrf/common-hal/alarm/__init__.c b/ports/nrf/common-hal/alarm/__init__.c index f678b5f22b..4c00cc4216 100644 --- a/ports/nrf/common-hal/alarm/__init__.c +++ b/ports/nrf/common-hal/alarm/__init__.c @@ -102,7 +102,7 @@ static const char* cause_str[] = { void print_wakeup_cause(nrf_sleep_source_t cause) { if (cause >= 0 && cause < NRF_SLEEP_WAKEUP_ZZZ) { dbg_printf("wakeup cause = NRF_SLEEP_WAKEUP_%s\r\n", - cause_str[(int)cause]); + cause_str[(int)cause]); } } #endif @@ -115,14 +115,14 @@ bool common_hal_alarm_woken_from_sleep(void) { } #endif return (cause == NRF_SLEEP_WAKEUP_GPIO || cause == NRF_SLEEP_WAKEUP_TIMER - || cause == NRF_SLEEP_WAKEUP_TOUCHPAD); + || cause == NRF_SLEEP_WAKEUP_TOUCHPAD); } nrf_sleep_source_t alarm_woken_from_sleep_2(void) { nrf_sleep_source_t cause = _get_wakeup_cause(); if (cause == NRF_SLEEP_WAKEUP_GPIO || - cause == NRF_SLEEP_WAKEUP_TIMER || - cause == NRF_SLEEP_WAKEUP_TOUCHPAD) { + cause == NRF_SLEEP_WAKEUP_TIMER || + cause == NRF_SLEEP_WAKEUP_TOUCHPAD) { return cause; } else { @@ -160,6 +160,9 @@ STATIC void _setup_sleep_alarms(bool deep_sleep, size_t n_alarms, const mp_obj_t alarm_touch_touchalarm_set_alarm(deep_sleep, n_alarms, alarms); } +// TODO: this handles all possible types of wakeup, which is redundant with main. +// revise to extract all parts essential to enabling sleep wakeup, but leave the +// alarm/non-alarm sorting to the existing main loop. nrf_sleep_source_t system_on_idle_until_alarm(int64_t timediff_ms, uint32_t prescaler) { bool have_timeout = false; uint64_t start_tick = 0, end_tick = 0; @@ -172,22 +175,22 @@ nrf_sleep_source_t system_on_idle_until_alarm(int64_t timediff_ms, uint32_t pres if (timediff_ms != -1) { have_timeout = true; #if 0 - int64_t now = common_hal_time_monotonic_ms(); - dbg_printf("now_ms=%ld timediff_ms=%ld\r\n", (long)now, (long)timediff_ms); + int64_t now = common_hal_time_monotonic_ms(); + dbg_printf("now_ms=%ld timediff_ms=%ld\r\n", (long)now, (long)timediff_ms); #endif - if (timediff_ms < 0) timediff_ms = 0; - if (prescaler == 0) { - // 1 tick = 1/1024 sec = 1000/1024 ms - // -> 1 ms = 1024/1000 ticks - tickdiff = (mp_uint_t)(timediff_ms * 1024 / 1000); // ms -> ticks - } - else { - // 1 tick = prescaler/1024 sec = prescaler*1000/1024 ms - // -> 1ms = 1024/(1000*prescaler) ticks - tickdiff = (mp_uint_t)(timediff_ms * 1024 / (1000 * prescaler)); - } - start_tick = port_get_raw_ticks(NULL); - end_tick = start_tick + tickdiff; + if (timediff_ms < 0) timediff_ms = 0; + if (prescaler == 0) { + // 1 tick = 1/1024 sec = 1000/1024 ms + // -> 1 ms = 1024/1000 ticks + tickdiff = (mp_uint_t)(timediff_ms * 1024 / 1000); // ms -> ticks + } + else { + // 1 tick = prescaler/1024 sec = prescaler*1000/1024 ms + // -> 1ms = 1024/(1000*prescaler) ticks + tickdiff = (mp_uint_t)(timediff_ms * 1024 / (1000 * prescaler)); + } + start_tick = port_get_raw_ticks(NULL); + end_tick = start_tick + tickdiff; } #if 0 dbg_printf("start_tick=%ld end_tick=%ld have_timeout=%c\r\n", (long)start_tick, (long)end_tick, have_timeout ? 'T' : 'F'); @@ -207,30 +210,30 @@ nrf_sleep_source_t system_on_idle_until_alarm(int64_t timediff_ms, uint32_t pres #endif while(1) { - if (mp_hal_is_interrupted()) { - WAKEUP_REASON('I'); - break; - } + if (mp_hal_is_interrupted()) { + WAKEUP_REASON('I'); + break; + } if (serial_connected() && serial_bytes_available()) { - WAKEUP_REASON('S'); - break; - } + WAKEUP_REASON('S'); + break; + } RUN_BACKGROUND_TASKS; - wakeup_cause = alarm_woken_from_sleep_2(); - if (wakeup_cause != NRF_SLEEP_WAKEUP_UNDEFINED) { - WAKEUP_REASON('0'+wakeup_cause); - break; - } - if (have_timeout) { - remaining = end_tick - port_get_raw_ticks(NULL); - // We break a bit early so we don't risk setting the alarm before the time when we call - // sleep. - if (remaining < 1) { - WAKEUP_REASON('t'); - break; - } - port_interrupt_after_ticks(remaining); - } + wakeup_cause = alarm_woken_from_sleep_2(); + if (wakeup_cause != NRF_SLEEP_WAKEUP_UNDEFINED) { + WAKEUP_REASON('0'+wakeup_cause); + break; + } + if (have_timeout) { + remaining = end_tick - port_get_raw_ticks(NULL); + // We break a bit early so we don't risk setting the alarm before the time when we call + // sleep. + if (remaining < 1) { + WAKEUP_REASON('t'); + break; + } + port_interrupt_after_ticks(remaining); + } // Idle until an interrupt happens. port_idle_until_interrupt(); #ifdef NRF_DEBUG_PRINT @@ -239,15 +242,15 @@ nrf_sleep_source_t system_on_idle_until_alarm(int64_t timediff_ms, uint32_t pres --ct; } #endif - if (have_timeout) { - remaining = end_tick - port_get_raw_ticks(NULL); - if (remaining <= 0) { - wakeup_cause = NRF_SLEEP_WAKEUP_TIMER; - sleepmem_wakeup_event = SLEEPMEM_WAKEUP_BY_TIMER; - WAKEUP_REASON('T'); - break; - } - } + if (have_timeout) { + remaining = end_tick - port_get_raw_ticks(NULL); + if (remaining <= 0) { + wakeup_cause = NRF_SLEEP_WAKEUP_TIMER; + sleepmem_wakeup_event = SLEEPMEM_WAKEUP_BY_TIMER; + WAKEUP_REASON('T'); + break; + } + } } #ifdef NRF_DEBUG_PRINT dbg_printf("%c\r\n", reason); @@ -324,7 +327,7 @@ void NORETURN common_hal_alarm_enter_deep_sleep(void) { #endif nrf_sleep_source_t cause; cause = system_on_idle_until_alarm(timediff_ms, - PRESCALER_VALUE_IN_DEEP_SLEEP); + PRESCALER_VALUE_IN_DEEP_SLEEP); (void)cause; #ifdef NRF_DEBUG_PRINT @@ -375,13 +378,13 @@ void common_hal_alarm_pretending_deep_sleep(void) { print_wakeup_cause(cause); #endif - alarm_reset(); + // alarm_reset(); #if 0 // if one of Alarm event occurred, reset myself if (cause == NRF_SLEEP_WAKEUP_GPIO || - cause == NRF_SLEEP_WAKEUP_TIMER || - cause == NRF_SLEEP_WAKEUP_TOUCHPAD) { + cause == NRF_SLEEP_WAKEUP_TIMER || + cause == NRF_SLEEP_WAKEUP_TOUCHPAD) { reset_cpu(); } // else, just return and go into REPL diff --git a/ports/nrf/common-hal/alarm/__init__.h b/ports/nrf/common-hal/alarm/__init__.h index 642fb7d93a..47051dbd72 100644 --- a/ports/nrf/common-hal/alarm/__init__.h +++ b/ports/nrf/common-hal/alarm/__init__.h @@ -31,13 +31,13 @@ #include "common-hal/alarm/SleepMemory.h" typedef enum { - NRF_SLEEP_WAKEUP_UNDEFINED, - NRF_SLEEP_WAKEUP_GPIO, - NRF_SLEEP_WAKEUP_TIMER, - NRF_SLEEP_WAKEUP_TOUCHPAD, - NRF_SLEEP_WAKEUP_VBUS, - NRF_SLEEP_WAKEUP_RESETPIN, - NRF_SLEEP_WAKEUP_ZZZ + NRF_SLEEP_WAKEUP_UNDEFINED, + NRF_SLEEP_WAKEUP_GPIO, + NRF_SLEEP_WAKEUP_TIMER, + NRF_SLEEP_WAKEUP_TOUCHPAD, + NRF_SLEEP_WAKEUP_VBUS, + NRF_SLEEP_WAKEUP_RESETPIN, + NRF_SLEEP_WAKEUP_ZZZ } nrf_sleep_source_t; extern const alarm_sleep_memory_obj_t alarm_sleep_memory_obj; diff --git a/ports/nrf/common-hal/alarm/pin/PinAlarm.c b/ports/nrf/common-hal/alarm/pin/PinAlarm.c index fcfd02f84c..59bb4a84a1 100644 --- a/ports/nrf/common-hal/alarm/pin/PinAlarm.c +++ b/ports/nrf/common-hal/alarm/pin/PinAlarm.c @@ -87,7 +87,7 @@ static void pinalarm_gpiote_handler(nrfx_gpiote_pin_t pin, nrf_gpiote_polarity_t bool alarm_pin_pinalarm_woke_us_up(void) { return (sleepmem_wakeup_event == SLEEPMEM_WAKEUP_BY_PIN && - sleepmem_wakeup_pin != WAKEUP_PIN_UNDEF); + sleepmem_wakeup_pin != WAKEUP_PIN_UNDEF); } mp_obj_t alarm_pin_pinalarm_get_wakeup_alarm(size_t n_alarms, const mp_obj_t *alarms) { @@ -97,7 +97,7 @@ mp_obj_t alarm_pin_pinalarm_get_wakeup_alarm(size_t n_alarms, const mp_obj_t *al continue; } alarm_pin_pinalarm_obj_t *alarm = MP_OBJ_TO_PTR(alarms[i]); - if (alarm->pin->number == sleepmem_wakeup_pin) { + if (alarm->pin->number == sleepmem_wakeup_pin) { return alarms[i]; } } @@ -130,8 +130,8 @@ void alarm_pin_pinalarm_reset(void) { continue; } reset_pin_number(i); - nrfx_gpiote_in_event_disable((nrfx_gpiote_pin_t)i); - nrfx_gpiote_in_uninit((nrfx_gpiote_pin_t)i); + nrfx_gpiote_in_event_disable((nrfx_gpiote_pin_t)i); + nrfx_gpiote_in_uninit((nrfx_gpiote_pin_t)i); } high_alarms = 0; @@ -178,15 +178,15 @@ static void configure_pins_for_sleep(void) { cfg.pull = NRF_GPIO_PIN_NOPULL; } err = nrfx_gpiote_in_init((nrfx_gpiote_pin_t)i, &cfg, - pinalarm_gpiote_handler); - assert(err == NRFX_SUCCESS); + pinalarm_gpiote_handler); + assert(err == NRFX_SUCCESS); nrfx_gpiote_in_event_enable((nrfx_gpiote_pin_t)i, true); if (((high_alarms & mask) != 0) && ((low_alarms & mask) == 0)) { nrf_gpio_cfg_sense_set((uint32_t)i, NRF_GPIO_PIN_SENSE_HIGH); - } + } if (((high_alarms & mask) == 0) && ((low_alarms & mask) != 0)) { nrf_gpio_cfg_sense_set((uint32_t)i, NRF_GPIO_PIN_SENSE_LOW); - } + } } } @@ -203,7 +203,7 @@ void alarm_pin_pinalarm_set_alarms(bool deep_sleep, size_t n_alarms, const mp_ob alarm_pin_pinalarm_obj_t *alarm = MP_OBJ_TO_PTR(alarms[i]); pin_number = alarm->pin->number; - //dbg_printf("alarm_pin_pinalarm_set_alarms(pin#=%d, val=%d, pull=%d)\r\n", pin_number, alarm->value, alarm->pull); + //dbg_printf("alarm_pin_pinalarm_set_alarms(pin#=%d, val=%d, pull=%d)\r\n", pin_number, alarm->value, alarm->pull); if (alarm->value) { high_alarms |= 1ull << pin_number; high_count++; @@ -222,8 +222,8 @@ void alarm_pin_pinalarm_set_alarms(bool deep_sleep, size_t n_alarms, const mp_ob else { // we don't setup gpio HW here but do them in // alarm_pin_pinalarm_prepare_for_deep_sleep() below - reset_reason_saved = 0; - pins_configured = false; + reset_reason_saved = 0; + pins_configured = false; } } else { @@ -234,9 +234,9 @@ void alarm_pin_pinalarm_set_alarms(bool deep_sleep, size_t n_alarms, const mp_ob void alarm_pin_pinalarm_prepare_for_deep_sleep(void) { if (!pins_configured) { configure_pins_for_sleep(); - pins_configured = true; + pins_configured = true; #ifdef NRF_DEBUG_PRINT - //dbg_dump_GPIOregs(); + //dbg_dump_GPIOregs(); #endif } } diff --git a/ports/nrf/common-hal/alarm/pin/PinAlarm.h b/ports/nrf/common-hal/alarm/pin/PinAlarm.h index 93672c1f2d..69684386fa 100644 --- a/ports/nrf/common-hal/alarm/pin/PinAlarm.h +++ b/ports/nrf/common-hal/alarm/pin/PinAlarm.h @@ -3,7 +3,7 @@ * * The MIT License (MIT) * - * Copyright (c) 2020 Dan Halbert for Adafruit Industries + * Copyright (c) 2021 Junji Sakai * * 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/ports/nrf/common-hal/alarm/time/TimeAlarm.h b/ports/nrf/common-hal/alarm/time/TimeAlarm.h index a824c52535..2f65764e19 100644 --- a/ports/nrf/common-hal/alarm/time/TimeAlarm.h +++ b/ports/nrf/common-hal/alarm/time/TimeAlarm.h @@ -3,7 +3,7 @@ * * The MIT License (MIT) * - * Copyright (c) 2020 Dan Halbert for Adafruit Industries + * Copyright (c) 2021 Junji Sakai * * 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/ports/nrf/common-hal/microcontroller/Processor.c b/ports/nrf/common-hal/microcontroller/Processor.c index 4baa4eaace..bcad002ffe 100644 --- a/ports/nrf/common-hal/microcontroller/Processor.c +++ b/ports/nrf/common-hal/microcontroller/Processor.c @@ -141,9 +141,9 @@ mcu_reset_reason_t common_hal_mcu_processor_get_reset_reason(void) { r = RESET_REASON_SOFTWARE; } else if ((reset_reason_saved & POWER_RESETREAS_OFF_Msk) || - (reset_reason_saved & POWER_RESETREAS_LPCOMP_Msk) || - (reset_reason_saved & POWER_RESETREAS_NFC_Msk) || - (reset_reason_saved & POWER_RESETREAS_VBUS_Msk)) { + (reset_reason_saved & POWER_RESETREAS_LPCOMP_Msk) || + (reset_reason_saved & POWER_RESETREAS_NFC_Msk) || + (reset_reason_saved & POWER_RESETREAS_VBUS_Msk)) { r = RESET_REASON_DEEP_SLEEP_ALARM; } return r; diff --git a/ports/nrf/mpconfigport.mk b/ports/nrf/mpconfigport.mk index a5766cf1fe..132aba208f 100644 --- a/ports/nrf/mpconfigport.mk +++ b/ports/nrf/mpconfigport.mk @@ -47,7 +47,7 @@ CIRCUITPY_COUNTIO = 0 CIRCUITPY_WATCHDOG ?= 1 # Sleep and Wakeup -CIRCUITPY_ALARM = 1 +CIRCUITPY_ALARM ?= 1 # nRF52840-specific diff --git a/ports/nrf/supervisor/debug_uart.c b/ports/nrf/supervisor/debug_uart.c index f770b661fc..9cf33279f7 100644 --- a/ports/nrf/supervisor/debug_uart.c +++ b/ports/nrf/supervisor/debug_uart.c @@ -1,6 +1,27 @@ /* - * debug functions - * (will be removed) + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2021 Jun2Sak + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION 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 @@ -33,11 +54,11 @@ static char _dbg_pbuf[DBG_PBUF_LEN+1]; void _debug_uart_uninit(void) { nrf_gpio_cfg(DEBUG_UART_TXPIN, - NRF_GPIO_PIN_DIR_INPUT, - NRF_GPIO_PIN_INPUT_DISCONNECT, - NRF_GPIO_PIN_NOPULL, - NRF_GPIO_PIN_S0S1, - NRF_GPIO_PIN_NOSENSE); + NRF_GPIO_PIN_DIR_INPUT, + NRF_GPIO_PIN_INPUT_DISCONNECT, + NRF_GPIO_PIN_NOPULL, + NRF_GPIO_PIN_S0S1, + NRF_GPIO_PIN_NOSENSE); nrfx_uarte_uninit(&_dbg_uart_inst); } @@ -59,11 +80,11 @@ void _debug_uart_init(void) { nrfx_uarte_init(&_dbg_uart_inst, &config, NULL); // drive config nrf_gpio_cfg(config.pseltxd, - NRF_GPIO_PIN_DIR_OUTPUT, - NRF_GPIO_PIN_INPUT_DISCONNECT, - NRF_GPIO_PIN_PULLUP, // orig=NOPULL - NRF_GPIO_PIN_H0H1, // orig=S0S1 - NRF_GPIO_PIN_NOSENSE); + NRF_GPIO_PIN_DIR_OUTPUT, + NRF_GPIO_PIN_INPUT_DISCONNECT, + NRF_GPIO_PIN_PULLUP, // orig=NOPULL + NRF_GPIO_PIN_H0H1, // orig=S0S1 + NRF_GPIO_PIN_NOSENSE); _dbg_uart_initialized = 1; return; } @@ -73,16 +94,16 @@ void _debug_print_substr(const char* text, uint32_t length) { int siz; while(length != 0) { if (length <= DBG_PBUF_LEN) { - siz = length; - } - else { - siz = DBG_PBUF_LEN; - } - memcpy(_dbg_pbuf, data, siz); - _dbg_pbuf[siz] = 0; - nrfx_uarte_tx(&_dbg_uart_inst, (uint8_t const*)_dbg_pbuf, siz); - data += siz; - length -= siz; + siz = length; + } + else { + siz = DBG_PBUF_LEN; + } + memcpy(_dbg_pbuf, data, siz); + _dbg_pbuf[siz] = 0; + nrfx_uarte_tx(&_dbg_uart_inst, (uint8_t const*)_dbg_pbuf, siz); + data += siz; + length -= siz; } } @@ -113,7 +134,7 @@ int dbg_check_RTCprescaler(void) { NRF_RTC_Type *r = rtc_instance.p_reg; if ((int)r->PRESCALER == 0) { dbg_printf("****** PRESCALER == 0\r\n"); - return -1; + return -1; } return 0; } @@ -135,20 +156,20 @@ void dbg_dump_GPIOregs(void) { const char cnf_sense_chr[] = "-?HL"; // sense high, sense low for(port=0, col=0; port<=1; ++port) { for(i=0; i<32; ++i) { - uint32_t cnf = gpio[port]->PIN_CNF[i]; - if (cnf != 0x0002) { // changed from default value - dbg_printf("[%d_%02d]:%c%c%c%d%c ", port, i, - (cnf & 1) ? 'O' : 'I', // output, input - (cnf & 2) ? 'd' : 'c', // disconnected, connected - cnf_pull_chr[(cnf >> 2) & 3], - (int)((cnf >> 8) & 7), // drive config 0-7 - cnf_sense_chr[(cnf >> 16) & 3]); - if (++col >= 6) { - dbg_printf("\r\n"); - col = 0; - } - } - } + uint32_t cnf = gpio[port]->PIN_CNF[i]; + if (cnf != 0x0002) { // changed from default value + dbg_printf("[%d_%02d]:%c%c%c%d%c ", port, i, + (cnf & 1) ? 'O' : 'I', // output, input + (cnf & 2) ? 'd' : 'c', // disconnected, connected + cnf_pull_chr[(cnf >> 2) & 3], + (int)((cnf >> 8) & 7), // drive config 0-7 + cnf_sense_chr[(cnf >> 16) & 3]); + if (++col >= 6) { + dbg_printf("\r\n"); + col = 0; + } + } + } } if (col > 0) dbg_printf("\r\n"); @@ -159,26 +180,26 @@ void dbg_dump_GPIOregs(void) { const char config_outinit_chr[] = "01"; // initial value is 0 or 1 for(i=0, col=0; i<8; ++i) { uint32_t conf = reg->CONFIG[i]; - if (conf != 0) { // changed from default value - dbg_printf("CONFIG[%d]:%d_%02d,%c%c%c ", i, - (int)((conf >> 13) & 1), (int)((conf >> 8) & 0x1F), - config_mode_chr[conf & 3], - config_pol_chr[(conf >> 16) & 3], - (conf & 3) == 3 ? - config_outinit_chr[(conf >> 20) & 1] : '-'); - if (++col >= 4) { - dbg_printf("\r\n"); - col = 0; - } - } + if (conf != 0) { // changed from default value + dbg_printf("CONFIG[%d]:%d_%02d,%c%c%c ", i, + (int)((conf >> 13) & 1), (int)((conf >> 8) & 0x1F), + config_mode_chr[conf & 3], + config_pol_chr[(conf >> 16) & 3], + (conf & 3) == 3 ? + config_outinit_chr[(conf >> 20) & 1] : '-'); + if (++col >= 4) { + dbg_printf("\r\n"); + col = 0; + } + } } if (col > 0) dbg_printf("\r\n"); for(i=0; i<8; ++i) { dbg_printf("EVENTS_IN[%d]:%X ", i, (int)(reg->EVENTS_IN[i])); - if ((i & 3) == 3) dbg_printf("\r\n"); + if ((i & 3) == 3) dbg_printf("\r\n"); } dbg_printf("EVENTS_PORT:%X INTENSET:%08X\r\n", - (int)(reg->EVENTS_PORT), (int)(reg->INTENSET)); + (int)(reg->EVENTS_PORT), (int)(reg->INTENSET)); } void dbg_dumpQSPIreg(void) { @@ -186,13 +207,13 @@ void dbg_dumpQSPIreg(void) { dbg_printf("QSPI\r\n"); r = NRF_QSPI->IFCONFIG0; dbg_printf("IFCONFIG0 READ=%ld write=%ld ADDR=%ld DPM=%ld PPSIZE=%ld\r\n", - r & 7, (r >> 3) & 7, (r >> 6) & 1, (r >> 7) & 1, (r >> 12) & 1); + r & 7, (r >> 3) & 7, (r >> 6) & 1, (r >> 7) & 1, (r >> 12) & 1); r = NRF_QSPI->IFCONFIG1; dbg_printf("IFCONFIG1 SCKDELAY=%ld SPIMODE=%ld SCKFREQ=%ld\r\n", - r & 0xFF, (r >> 25) & 1, (r >> 28) & 0xF); + r & 0xFF, (r >> 25) & 1, (r >> 28) & 0xF); r = NRF_QSPI->STATUS; dbg_printf("STATUS DPM=%ld READY=%ld SREG=0x%02lX\r\n", - (r >> 2) & 1, (r >> 3) & 1, (r >> 24) & 0xFF); + (r >> 2) & 1, (r >> 3) & 1, (r >> 24) & 0xFF); r = NRF_QSPI->DPMDUR; dbg_printf("DPMDUR ENTER=%ld EXIT=%ld\r\n", r & 0xFFFF, (r >> 16) & 0xFFFF); } diff --git a/ports/nrf/supervisor/port.c b/ports/nrf/supervisor/port.c index c984feb77d..e162c64837 100644 --- a/ports/nrf/supervisor/port.c +++ b/ports/nrf/supervisor/port.c @@ -109,7 +109,9 @@ void rtc_handler(nrfx_rtc_int_type_t int_type) { nrfx_rtc_cc_set(&rtc_instance, 0, 0, false); } else if (int_type == NRFX_RTC_INT_COMPARE1) { // used in light sleep + #if CIRCUITPY_ALARM sleepmem_wakeup_event = SLEEPMEM_WAKEUP_BY_TIMER; + #endif nrfx_rtc_cc_set(&rtc_instance, 1, 0, false); } } @@ -185,7 +187,9 @@ safe_mode_t port_init(void) { NRF_POWER->RESETREAS = reset_reason_saved; // clear wakeup event/pin when reset by reset-pin if (reset_reason_saved & NRF_POWER_RESETREAS_RESETPIN_MASK) { + #if CIRCUITPY_ALARM sleepmem_wakeup_event = SLEEPMEM_WAKEUP_BY_NONE; + #endif } // If the board was reset by the WatchDogTimer, we may diff --git a/ports/nrf/supervisor/qspi_flash.c b/ports/nrf/supervisor/qspi_flash.c index f2beb3e3a9..6d1bec4422 100644 --- a/ports/nrf/supervisor/qspi_flash.c +++ b/ports/nrf/supervisor/qspi_flash.c @@ -281,7 +281,7 @@ void qspi_flash_enter_sleep(void) { // set sck_delay tempolarily r = NRF_QSPI->IFCONFIG1; sck_delay_saved = (r & QSPI_IFCONFIG1_SCKDELAY_Msk) - >> QSPI_IFCONFIG1_SCKDELAY_Pos; + >> QSPI_IFCONFIG1_SCKDELAY_Pos; NRF_QSPI->IFCONFIG1 = (NRF_QSPI->IFCONFIG1 & ~QSPI_IFCONFIG1_SCKDELAY_Msk) | (SCK_DELAY << QSPI_IFCONFIG1_SCKDELAY_Pos); @@ -312,20 +312,20 @@ void qspi_flash_exit_sleep(void) { if (NRF_QSPI->STATUS & QSPI_STATUS_DPM_Msk) { // exit deep power-down mode NRF_QSPI->IFCONFIG1 &= ~QSPI_IFCONFIG1_DPMEN_Msk; - NRFX_DELAY_US(WAIT_AFTER_DPM_EXIT); + NRFX_DELAY_US(WAIT_AFTER_DPM_EXIT); - if (NRF_QSPI->STATUS & QSPI_STATUS_DPM_Msk) { + if (NRF_QSPI->STATUS & QSPI_STATUS_DPM_Msk) { #ifdef NRF_DEBUG_PRINT - dbg_printf("qspi flash: exiting DPM failed\r\n"); + dbg_printf("qspi flash: exiting DPM failed\r\n"); #endif - } - // restore sck_delay - if (sck_delay_saved == 0) { - sck_delay_saved = 10; // default - } - NRF_QSPI->IFCONFIG1 - = (NRF_QSPI->IFCONFIG1 & ~QSPI_IFCONFIG1_SCKDELAY_Msk) - | (sck_delay_saved << QSPI_IFCONFIG1_SCKDELAY_Pos); + } + // restore sck_delay + if (sck_delay_saved == 0) { + sck_delay_saved = 10; // default + } + NRF_QSPI->IFCONFIG1 + = (NRF_QSPI->IFCONFIG1 & ~QSPI_IFCONFIG1_SCKDELAY_Msk) + | (sck_delay_saved << QSPI_IFCONFIG1_SCKDELAY_Pos); } //dbg_dumpQSPIreg(); #endif diff --git a/ports/raspberrypi/boards/pimoroni_picolipo_16mb/board.c b/ports/raspberrypi/boards/pimoroni_picolipo_16mb/board.c new file mode 100644 index 0000000000..67486d4c23 --- /dev/null +++ b/ports/raspberrypi/boards/pimoroni_picolipo_16mb/board.c @@ -0,0 +1,37 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2021 Scott Shawcroft for Adafruit Industries + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include "supervisor/board.h" + +void board_init(void) { +} + +bool board_requests_safe_mode(void) { + return false; +} + +void reset_board(void) { +} diff --git a/ports/raspberrypi/boards/pimoroni_picolipo_16mb/mpconfigboard.h b/ports/raspberrypi/boards/pimoroni_picolipo_16mb/mpconfigboard.h new file mode 100644 index 0000000000..4261b9e006 --- /dev/null +++ b/ports/raspberrypi/boards/pimoroni_picolipo_16mb/mpconfigboard.h @@ -0,0 +1,10 @@ +#define MICROPY_HW_BOARD_NAME "Pimoroni Pico LiPo (16MB)" +#define MICROPY_HW_MCU_NAME "rp2040" + +#define MICROPY_HW_VBUS_DETECT (&pin_GPIO24) +#define MICROPY_HW_BAT_SENSE (&pin_GPIO29) + +#define MICROPY_HW_USER_SW (&pin_GPIO23) + +#define DEFAULT_I2C_BUS_SCL (&pin_GPIO5) +#define DEFAULT_I2C_BUS_SDA (&pin_GPIO4) diff --git a/ports/raspberrypi/boards/pimoroni_picolipo_16mb/mpconfigboard.mk b/ports/raspberrypi/boards/pimoroni_picolipo_16mb/mpconfigboard.mk new file mode 100644 index 0000000000..129f408e5e --- /dev/null +++ b/ports/raspberrypi/boards/pimoroni_picolipo_16mb/mpconfigboard.mk @@ -0,0 +1,11 @@ +USB_VID = 0x2E8A +USB_PID = 0x1003 +USB_PRODUCT = "Pimoroni Pico LiPo (16MB)" +USB_MANUFACTURER = "Pimoroni" + +CHIP_VARIANT = RP2040 +CHIP_FAMILY = rp2 + +EXTERNAL_FLASH_DEVICES = "W25Q128JVxQ" + +CIRCUITPY__EVE = 1 diff --git a/ports/raspberrypi/boards/pimoroni_picolipo_16mb/pins.c b/ports/raspberrypi/boards/pimoroni_picolipo_16mb/pins.c new file mode 100644 index 0000000000..229d510ead --- /dev/null +++ b/ports/raspberrypi/boards/pimoroni_picolipo_16mb/pins.c @@ -0,0 +1,52 @@ +#include "shared-bindings/board/__init__.h" + +STATIC const mp_rom_map_elem_t board_global_dict_table[] = { + { MP_ROM_QSTR(MP_QSTR_GP0), MP_ROM_PTR(&pin_GPIO0) }, + { MP_ROM_QSTR(MP_QSTR_GP1), MP_ROM_PTR(&pin_GPIO1) }, + { MP_ROM_QSTR(MP_QSTR_GP2), MP_ROM_PTR(&pin_GPIO2) }, + { MP_ROM_QSTR(MP_QSTR_GP3), MP_ROM_PTR(&pin_GPIO3) }, + + { MP_ROM_QSTR(MP_QSTR_SDA), MP_ROM_PTR(&pin_GPIO4) }, + { MP_ROM_QSTR(MP_QSTR_GP4), MP_ROM_PTR(&pin_GPIO4) }, + + { MP_ROM_QSTR(MP_QSTR_SCL), MP_ROM_PTR(&pin_GPIO5) }, + { MP_ROM_QSTR(MP_QSTR_GP5), MP_ROM_PTR(&pin_GPIO5) }, + + { MP_ROM_QSTR(MP_QSTR_GP6), MP_ROM_PTR(&pin_GPIO6) }, + { MP_ROM_QSTR(MP_QSTR_GP7), MP_ROM_PTR(&pin_GPIO7) }, + { MP_ROM_QSTR(MP_QSTR_GP8), MP_ROM_PTR(&pin_GPIO8) }, + { MP_ROM_QSTR(MP_QSTR_GP9), MP_ROM_PTR(&pin_GPIO9) }, + { MP_ROM_QSTR(MP_QSTR_GP10), MP_ROM_PTR(&pin_GPIO10) }, + { MP_ROM_QSTR(MP_QSTR_GP11), MP_ROM_PTR(&pin_GPIO11) }, + { MP_ROM_QSTR(MP_QSTR_GP12), MP_ROM_PTR(&pin_GPIO12) }, + { MP_ROM_QSTR(MP_QSTR_GP13), MP_ROM_PTR(&pin_GPIO13) }, + { MP_ROM_QSTR(MP_QSTR_GP14), MP_ROM_PTR(&pin_GPIO14) }, + { MP_ROM_QSTR(MP_QSTR_GP15), MP_ROM_PTR(&pin_GPIO15) }, + { MP_ROM_QSTR(MP_QSTR_GP16), MP_ROM_PTR(&pin_GPIO16) }, + { MP_ROM_QSTR(MP_QSTR_GP17), MP_ROM_PTR(&pin_GPIO17) }, + { MP_ROM_QSTR(MP_QSTR_GP18), MP_ROM_PTR(&pin_GPIO18) }, + { MP_ROM_QSTR(MP_QSTR_GP19), MP_ROM_PTR(&pin_GPIO19) }, + { MP_ROM_QSTR(MP_QSTR_GP20), MP_ROM_PTR(&pin_GPIO20) }, + { MP_ROM_QSTR(MP_QSTR_GP21), MP_ROM_PTR(&pin_GPIO21) }, + { MP_ROM_QSTR(MP_QSTR_GP22), MP_ROM_PTR(&pin_GPIO22) }, + + { MP_ROM_QSTR(MP_QSTR_USER_SW), MP_ROM_PTR(&pin_GPIO23) }, + { MP_ROM_QSTR(MP_QSTR_VBUS_DETECT), MP_ROM_PTR(&pin_GPIO24) }, + + { MP_ROM_QSTR(MP_QSTR_LED), MP_ROM_PTR(&pin_GPIO25) }, + { MP_ROM_QSTR(MP_QSTR_GP25), MP_ROM_PTR(&pin_GPIO25) }, + { MP_ROM_QSTR(MP_QSTR_GP26_A0), MP_ROM_PTR(&pin_GPIO26) }, + { MP_ROM_QSTR(MP_QSTR_GP26), MP_ROM_PTR(&pin_GPIO26) }, + { MP_ROM_QSTR(MP_QSTR_A0), MP_ROM_PTR(&pin_GPIO26) }, + { MP_ROM_QSTR(MP_QSTR_GP27_A1), MP_ROM_PTR(&pin_GPIO27) }, + { MP_ROM_QSTR(MP_QSTR_GP27), MP_ROM_PTR(&pin_GPIO27) }, + { MP_ROM_QSTR(MP_QSTR_A1), MP_ROM_PTR(&pin_GPIO27) }, + { MP_ROM_QSTR(MP_QSTR_GP28_A2), MP_ROM_PTR(&pin_GPIO28) }, + { MP_ROM_QSTR(MP_QSTR_GP28), MP_ROM_PTR(&pin_GPIO28) }, + { MP_ROM_QSTR(MP_QSTR_A2), MP_ROM_PTR(&pin_GPIO28) }, + { MP_ROM_QSTR(MP_QSTR_A3), MP_ROM_PTR(&pin_GPIO29) }, + { MP_ROM_QSTR(MP_QSTR_BAT_SENSE), MP_ROM_PTR(&pin_GPIO29) }, + + { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) }, +}; +MP_DEFINE_CONST_DICT(board_module_globals, board_global_dict_table); diff --git a/ports/raspberrypi/boards/pimoroni_picolipo_4mb/board.c b/ports/raspberrypi/boards/pimoroni_picolipo_4mb/board.c new file mode 100644 index 0000000000..67486d4c23 --- /dev/null +++ b/ports/raspberrypi/boards/pimoroni_picolipo_4mb/board.c @@ -0,0 +1,37 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2021 Scott Shawcroft for Adafruit Industries + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include "supervisor/board.h" + +void board_init(void) { +} + +bool board_requests_safe_mode(void) { + return false; +} + +void reset_board(void) { +} diff --git a/ports/raspberrypi/boards/pimoroni_picolipo_4mb/mpconfigboard.h b/ports/raspberrypi/boards/pimoroni_picolipo_4mb/mpconfigboard.h new file mode 100644 index 0000000000..e34a05abf2 --- /dev/null +++ b/ports/raspberrypi/boards/pimoroni_picolipo_4mb/mpconfigboard.h @@ -0,0 +1,10 @@ +#define MICROPY_HW_BOARD_NAME "Pimoroni Pico LiPo (4MB)" +#define MICROPY_HW_MCU_NAME "rp2040" + +#define MICROPY_HW_VBUS_DETECT (&pin_GPIO24) +#define MICROPY_HW_BAT_SENSE (&pin_GPIO29) + +#define MICROPY_HW_USER_SW (&pin_GPIO23) + +#define DEFAULT_I2C_BUS_SCL (&pin_GPIO5) +#define DEFAULT_I2C_BUS_SDA (&pin_GPIO4) diff --git a/ports/raspberrypi/boards/pimoroni_picolipo_4mb/mpconfigboard.mk b/ports/raspberrypi/boards/pimoroni_picolipo_4mb/mpconfigboard.mk new file mode 100644 index 0000000000..a82ee9c0ea --- /dev/null +++ b/ports/raspberrypi/boards/pimoroni_picolipo_4mb/mpconfigboard.mk @@ -0,0 +1,11 @@ +USB_VID = 0x2E8A +USB_PID = 0x1002 +USB_PRODUCT = "Pimoroni Pico LiPo (4MB)" +USB_MANUFACTURER = "Pimoroni" + +CHIP_VARIANT = RP2040 +CHIP_FAMILY = rp2 + +EXTERNAL_FLASH_DEVICES = "W25Q32JVxQ" + +CIRCUITPY__EVE = 1 diff --git a/ports/raspberrypi/boards/pimoroni_picolipo_4mb/pins.c b/ports/raspberrypi/boards/pimoroni_picolipo_4mb/pins.c new file mode 100644 index 0000000000..229d510ead --- /dev/null +++ b/ports/raspberrypi/boards/pimoroni_picolipo_4mb/pins.c @@ -0,0 +1,52 @@ +#include "shared-bindings/board/__init__.h" + +STATIC const mp_rom_map_elem_t board_global_dict_table[] = { + { MP_ROM_QSTR(MP_QSTR_GP0), MP_ROM_PTR(&pin_GPIO0) }, + { MP_ROM_QSTR(MP_QSTR_GP1), MP_ROM_PTR(&pin_GPIO1) }, + { MP_ROM_QSTR(MP_QSTR_GP2), MP_ROM_PTR(&pin_GPIO2) }, + { MP_ROM_QSTR(MP_QSTR_GP3), MP_ROM_PTR(&pin_GPIO3) }, + + { MP_ROM_QSTR(MP_QSTR_SDA), MP_ROM_PTR(&pin_GPIO4) }, + { MP_ROM_QSTR(MP_QSTR_GP4), MP_ROM_PTR(&pin_GPIO4) }, + + { MP_ROM_QSTR(MP_QSTR_SCL), MP_ROM_PTR(&pin_GPIO5) }, + { MP_ROM_QSTR(MP_QSTR_GP5), MP_ROM_PTR(&pin_GPIO5) }, + + { MP_ROM_QSTR(MP_QSTR_GP6), MP_ROM_PTR(&pin_GPIO6) }, + { MP_ROM_QSTR(MP_QSTR_GP7), MP_ROM_PTR(&pin_GPIO7) }, + { MP_ROM_QSTR(MP_QSTR_GP8), MP_ROM_PTR(&pin_GPIO8) }, + { MP_ROM_QSTR(MP_QSTR_GP9), MP_ROM_PTR(&pin_GPIO9) }, + { MP_ROM_QSTR(MP_QSTR_GP10), MP_ROM_PTR(&pin_GPIO10) }, + { MP_ROM_QSTR(MP_QSTR_GP11), MP_ROM_PTR(&pin_GPIO11) }, + { MP_ROM_QSTR(MP_QSTR_GP12), MP_ROM_PTR(&pin_GPIO12) }, + { MP_ROM_QSTR(MP_QSTR_GP13), MP_ROM_PTR(&pin_GPIO13) }, + { MP_ROM_QSTR(MP_QSTR_GP14), MP_ROM_PTR(&pin_GPIO14) }, + { MP_ROM_QSTR(MP_QSTR_GP15), MP_ROM_PTR(&pin_GPIO15) }, + { MP_ROM_QSTR(MP_QSTR_GP16), MP_ROM_PTR(&pin_GPIO16) }, + { MP_ROM_QSTR(MP_QSTR_GP17), MP_ROM_PTR(&pin_GPIO17) }, + { MP_ROM_QSTR(MP_QSTR_GP18), MP_ROM_PTR(&pin_GPIO18) }, + { MP_ROM_QSTR(MP_QSTR_GP19), MP_ROM_PTR(&pin_GPIO19) }, + { MP_ROM_QSTR(MP_QSTR_GP20), MP_ROM_PTR(&pin_GPIO20) }, + { MP_ROM_QSTR(MP_QSTR_GP21), MP_ROM_PTR(&pin_GPIO21) }, + { MP_ROM_QSTR(MP_QSTR_GP22), MP_ROM_PTR(&pin_GPIO22) }, + + { MP_ROM_QSTR(MP_QSTR_USER_SW), MP_ROM_PTR(&pin_GPIO23) }, + { MP_ROM_QSTR(MP_QSTR_VBUS_DETECT), MP_ROM_PTR(&pin_GPIO24) }, + + { MP_ROM_QSTR(MP_QSTR_LED), MP_ROM_PTR(&pin_GPIO25) }, + { MP_ROM_QSTR(MP_QSTR_GP25), MP_ROM_PTR(&pin_GPIO25) }, + { MP_ROM_QSTR(MP_QSTR_GP26_A0), MP_ROM_PTR(&pin_GPIO26) }, + { MP_ROM_QSTR(MP_QSTR_GP26), MP_ROM_PTR(&pin_GPIO26) }, + { MP_ROM_QSTR(MP_QSTR_A0), MP_ROM_PTR(&pin_GPIO26) }, + { MP_ROM_QSTR(MP_QSTR_GP27_A1), MP_ROM_PTR(&pin_GPIO27) }, + { MP_ROM_QSTR(MP_QSTR_GP27), MP_ROM_PTR(&pin_GPIO27) }, + { MP_ROM_QSTR(MP_QSTR_A1), MP_ROM_PTR(&pin_GPIO27) }, + { MP_ROM_QSTR(MP_QSTR_GP28_A2), MP_ROM_PTR(&pin_GPIO28) }, + { MP_ROM_QSTR(MP_QSTR_GP28), MP_ROM_PTR(&pin_GPIO28) }, + { MP_ROM_QSTR(MP_QSTR_A2), MP_ROM_PTR(&pin_GPIO28) }, + { MP_ROM_QSTR(MP_QSTR_A3), MP_ROM_PTR(&pin_GPIO29) }, + { MP_ROM_QSTR(MP_QSTR_BAT_SENSE), MP_ROM_PTR(&pin_GPIO29) }, + + { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) }, +}; +MP_DEFINE_CONST_DICT(board_module_globals, board_global_dict_table); diff --git a/ports/raspberrypi/boards/raspberry_pi_pico/pins.c b/ports/raspberrypi/boards/raspberry_pi_pico/pins.c index e1927bc80c..057eaec2af 100644 --- a/ports/raspberrypi/boards/raspberry_pi_pico/pins.c +++ b/ports/raspberrypi/boards/raspberry_pi_pico/pins.c @@ -24,18 +24,28 @@ STATIC const mp_rom_map_elem_t board_global_dict_table[] = { { MP_ROM_QSTR(MP_QSTR_GP20), MP_ROM_PTR(&pin_GPIO20) }, { MP_ROM_QSTR(MP_QSTR_GP21), MP_ROM_PTR(&pin_GPIO21) }, { MP_ROM_QSTR(MP_QSTR_GP22), MP_ROM_PTR(&pin_GPIO22) }, + { MP_ROM_QSTR(MP_QSTR_SMPS_MODE), MP_ROM_PTR(&pin_GPIO23) }, + { MP_ROM_QSTR(MP_QSTR_GP23), MP_ROM_PTR(&pin_GPIO23) }, + + { MP_ROM_QSTR(MP_QSTR_VBUS_SENSE), MP_ROM_PTR(&pin_GPIO24) }, + { MP_ROM_QSTR(MP_QSTR_GP24), MP_ROM_PTR(&pin_GPIO24) }, + { MP_ROM_QSTR(MP_QSTR_LED), MP_ROM_PTR(&pin_GPIO25) }, { MP_ROM_QSTR(MP_QSTR_GP25), MP_ROM_PTR(&pin_GPIO25) }, + { MP_ROM_QSTR(MP_QSTR_GP26_A0), MP_ROM_PTR(&pin_GPIO26) }, { MP_ROM_QSTR(MP_QSTR_GP26), MP_ROM_PTR(&pin_GPIO26) }, { MP_ROM_QSTR(MP_QSTR_A0), MP_ROM_PTR(&pin_GPIO26) }, + { MP_ROM_QSTR(MP_QSTR_GP27_A1), MP_ROM_PTR(&pin_GPIO27) }, { MP_ROM_QSTR(MP_QSTR_GP27), MP_ROM_PTR(&pin_GPIO27) }, { MP_ROM_QSTR(MP_QSTR_A1), MP_ROM_PTR(&pin_GPIO27) }, + { MP_ROM_QSTR(MP_QSTR_GP28_A2), MP_ROM_PTR(&pin_GPIO28) }, { MP_ROM_QSTR(MP_QSTR_GP28), MP_ROM_PTR(&pin_GPIO28) }, { MP_ROM_QSTR(MP_QSTR_A2), MP_ROM_PTR(&pin_GPIO28) }, + { MP_ROM_QSTR(MP_QSTR_A3), MP_ROM_PTR(&pin_GPIO29) }, { MP_ROM_QSTR(MP_QSTR_VOLTAGE_MONITOR), MP_ROM_PTR(&pin_GPIO29) }, }; diff --git a/ports/raspberrypi/boards/sparkfun_micromod_rp2040/board.c b/ports/raspberrypi/boards/sparkfun_micromod_rp2040/board.c new file mode 100644 index 0000000000..c4021a83e9 --- /dev/null +++ b/ports/raspberrypi/boards/sparkfun_micromod_rp2040/board.c @@ -0,0 +1,40 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2021 Scott Shawcroft for Adafruit Industries + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include "supervisor/board.h" + +#include "shared-bindings/microcontroller/Pin.h" +#include "src/rp2_common/hardware_gpio/include/hardware/gpio.h" + +void board_init(void) { +} + +bool board_requests_safe_mode(void) { + return false; +} + +void reset_board(void) { +} diff --git a/ports/raspberrypi/boards/sparkfun_micromod_rp2040/mpconfigboard.h b/ports/raspberrypi/boards/sparkfun_micromod_rp2040/mpconfigboard.h new file mode 100644 index 0000000000..d7dd7a6376 --- /dev/null +++ b/ports/raspberrypi/boards/sparkfun_micromod_rp2040/mpconfigboard.h @@ -0,0 +1,12 @@ +#define MICROPY_HW_BOARD_NAME "SparkFun MicroMod ATP - RP2040" +#define MICROPY_HW_MCU_NAME "rp2040" + +#define DEFAULT_I2C_BUS_SCL (&pin_GPIO5) +#define DEFAULT_I2C_BUS_SDA (&pin_GPIO4) + +#define DEFAULT_SPI_BUS_SCK (&pin_GPIO14) +#define DEFAULT_SPI_BUS_MOSI (&pin_GPIO15) +#define DEFAULT_SPI_BUS_MISO (&pin_GPIO12) + +#define DEFAULT_UART_BUS_RX (&pin_GPIO1) +#define DEFAULT_UART_BUS_TX (&pin_GPIO0) diff --git a/ports/raspberrypi/boards/sparkfun_micromod_rp2040/mpconfigboard.mk b/ports/raspberrypi/boards/sparkfun_micromod_rp2040/mpconfigboard.mk new file mode 100644 index 0000000000..2ed559d8db --- /dev/null +++ b/ports/raspberrypi/boards/sparkfun_micromod_rp2040/mpconfigboard.mk @@ -0,0 +1,9 @@ +USB_VID = 0x1B4F +USB_PID = 0x0024 +USB_PRODUCT = "MicroMod RP2040" +USB_MANUFACTURER = "SparkFun" + +CHIP_VARIANT = RP2040 +CHIP_FAMILY = rp2 + +EXTERNAL_FLASH_DEVICES = "W25Q128JVxM" diff --git a/ports/raspberrypi/boards/sparkfun_micromod_rp2040/pins.c b/ports/raspberrypi/boards/sparkfun_micromod_rp2040/pins.c new file mode 100644 index 0000000000..00d6c30cb8 --- /dev/null +++ b/ports/raspberrypi/boards/sparkfun_micromod_rp2040/pins.c @@ -0,0 +1,105 @@ +#include "shared-bindings/board/__init__.h" + +STATIC const mp_rom_map_elem_t board_global_dict_table[] = { + // D (Digital only) pins (D0,D1) + { MP_ROM_QSTR(MP_QSTR_D0), MP_ROM_PTR(&pin_GPIO7) }, // GPIO6 - D0 + { MP_ROM_QSTR(MP_QSTR_D1), MP_ROM_PTR(&pin_GPIO7) }, // GPIO7 - D1 + + // A (ADC) pins (A0,A1) + { MP_ROM_QSTR(MP_QSTR_A0), MP_ROM_PTR(&pin_GPIO26) }, // GPIO26 - A0 | ADC0 + { MP_ROM_QSTR(MP_QSTR_ADC0), MP_ROM_PTR(&pin_GPIO26) }, // ADC0 alias + { MP_ROM_QSTR(MP_QSTR_A1), MP_ROM_PTR(&pin_GPIO27) }, // GPIO27 - A1 | ADC1 + { MP_ROM_QSTR(MP_QSTR_ADC1), MP_ROM_PTR(&pin_GPIO27) }, // ADC1 alias + + // G (General/BUS) pins (G0-G7, G8 NC, G9-G10, G11 NC) + { MP_ROM_QSTR(MP_QSTR_G0), MP_ROM_PTR(&pin_GPIO16) }, // GPIO16 - G0 | BUS0 + { MP_ROM_QSTR(MP_QSTR_BUS0), MP_ROM_PTR(&pin_GPIO16) }, // BUS0 alias + { MP_ROM_QSTR(MP_QSTR_G1), MP_ROM_PTR(&pin_GPIO17) }, // GPIO17 - G1 | BUS1 + { MP_ROM_QSTR(MP_QSTR_BUS1), MP_ROM_PTR(&pin_GPIO17) }, // BUS1 alias + { MP_ROM_QSTR(MP_QSTR_G2), MP_ROM_PTR(&pin_GPIO18) }, // GPIO18 - G2 | BUS2 + { MP_ROM_QSTR(MP_QSTR_BUS2), MP_ROM_PTR(&pin_GPIO18) }, // BUS2 alias + { MP_ROM_QSTR(MP_QSTR_G3), MP_ROM_PTR(&pin_GPIO19) }, // GPIO19 - G3 | BUS3 + { MP_ROM_QSTR(MP_QSTR_BUS3), MP_ROM_PTR(&pin_GPIO19) }, // BUS3 alias + { MP_ROM_QSTR(MP_QSTR_G4), MP_ROM_PTR(&pin_GPIO20) }, // GPIO20 - G4 | BUS4 | SPI_CIPO + { MP_ROM_QSTR(MP_QSTR_BUS4), MP_ROM_PTR(&pin_GPIO20) }, // BUS4 alias + { MP_ROM_QSTR(MP_QSTR_G5), MP_ROM_PTR(&pin_GPIO21) }, // GPIO21 - G5 | BUS5 | SPI_CS + { MP_ROM_QSTR(MP_QSTR_BUS5), MP_ROM_PTR(&pin_GPIO21) }, // BUS5 alias + { MP_ROM_QSTR(MP_QSTR_G6), MP_ROM_PTR(&pin_GPIO22) }, // GPIO22 - G6 | BUS6 | SPI_SCK + { MP_ROM_QSTR(MP_QSTR_BUS6), MP_ROM_PTR(&pin_GPIO22) }, // BUS6 alias + { MP_ROM_QSTR(MP_QSTR_G7), MP_ROM_PTR(&pin_GPIO23) }, // GPIO23 - G7 | BUS7 | SPI_COPI + { MP_ROM_QSTR(MP_QSTR_BUS7), MP_ROM_PTR(&pin_GPIO23) }, // BUS7 alias + // NC - G8 + { MP_ROM_QSTR(MP_QSTR_G9), MP_ROM_PTR(&pin_GPIO28) }, // GPIO28- G9 | BUS9 | ADC_D- | CAM_HSYNC + { MP_ROM_QSTR(MP_QSTR_BUS9), MP_ROM_PTR(&pin_GPIO28) }, // BUS9 alias + { MP_ROM_QSTR(MP_QSTR_ADC_DM), MP_ROM_PTR(&pin_GPIO28) }, // ADC_DM alias + { MP_ROM_QSTR(MP_QSTR_CAM_HSYNC), MP_ROM_PTR(&pin_GPIO28) }, // CAM_HSYNC alias + { MP_ROM_QSTR(MP_QSTR_G10), MP_ROM_PTR(&pin_GPIO25) }, // GPIO25 - G10 | BUS10 | ADC_D+ | CAM_VSYNC + { MP_ROM_QSTR(MP_QSTR_BUS10), MP_ROM_PTR(&pin_GPIO25) }, // BUS10 alias + { MP_ROM_QSTR(MP_QSTR_ADC_DP), MP_ROM_PTR(&pin_GPIO25) }, // ADC_DP alias + { MP_ROM_QSTR(MP_QSTR_CAM_VSYNC), MP_ROM_PTR(&pin_GPIO25) }, // CAM_VSYNC alias + // NC - G11 + + // PWM pins (PWM0,PWM1) + { MP_ROM_QSTR(MP_QSTR_PWM0), MP_ROM_PTR(&pin_GPIO13) }, // GPIO13 - PWM0 + { MP_ROM_QSTR(MP_QSTR_PWM1), MP_ROM_PTR(&pin_GPIO24) }, // GPIO24 - PWM1 | AUD_MCLK + + // AUD (audio) + { MP_ROM_QSTR(MP_QSTR_AUD_MCLK), MP_ROM_PTR(&pin_GPIO24) }, // GPIO24 - AUD_MCLK | PWM1 + { MP_ROM_QSTR(MP_QSTR_AUD_OUT), MP_ROM_PTR(&pin_GPIO10) }, // GPIO10 - AUD_OUT | SDIO_DAT2 + { MP_ROM_QSTR(MP_QSTR_AUD_IN), MP_ROM_PTR(&pin_GPIO11) }, // GPIO11 - AUD_IN | SDIO_DAT1 + { MP_ROM_QSTR(MP_QSTR_AUD_LRCLK), MP_ROM_PTR(&pin_GPIO2) }, // GPIO2 - AUD_LRCLK | CTS1 + { MP_ROM_QSTR(MP_QSTR_AUD_BCLK), MP_ROM_PTR(&pin_GPIO3) }, // GPIO3 - AUD_BCLK | UART_RTS1 + + // Battery Voltage Monitor + { MP_ROM_QSTR(MP_QSTR_BATT_VIN3), MP_ROM_PTR(&pin_GPIO29) }, // GPIO29 - BATT_VIN/3 (ADC03) + + + // I2C + { MP_ROM_QSTR(MP_QSTR_SDA), MP_ROM_PTR(&pin_GPIO4) }, // GPIO4 - SDA + { MP_ROM_QSTR(MP_QSTR_SCL), MP_ROM_PTR(&pin_GPIO5) }, // GPIO5 - SCL + + { MP_ROM_QSTR(MP_QSTR_I2C_INT), MP_ROM_PTR(&pin_GPIO8) }, // GPIO9 - I2C_INT | TX2 + + // SPI + { MP_ROM_QSTR(MP_QSTR_CIPO), MP_ROM_PTR(&pin_GPIO20) }, // GPIO20 - CIPO | SPI_CIPO | G4 + { MP_ROM_QSTR(MP_QSTR_MISO), MP_ROM_PTR(&pin_GPIO20) }, // MISO alias + { MP_ROM_QSTR(MP_QSTR_COPI), MP_ROM_PTR(&pin_GPIO23) }, // GPIO23 - COPI | SPI_COPI | G7 + { MP_ROM_QSTR(MP_QSTR_MOSI), MP_ROM_PTR(&pin_GPIO23) }, // MOSI alias + { MP_ROM_QSTR(MP_QSTR_SCK), MP_ROM_PTR(&pin_GPIO22) }, // GPIO22 - SCK | SPI_SCK | G6 + { MP_ROM_QSTR(MP_QSTR_CS), MP_ROM_PTR(&pin_GPIO21) }, // GPIO21 - /CS | SPI_/CS | G5 + + // SDI/SPI1 + { MP_ROM_QSTR(MP_QSTR_SDIO_CLK), MP_ROM_PTR(&pin_GPIO14) }, // GPIO14 - SDIO SCK | SDIO_CLK + { MP_ROM_QSTR(MP_QSTR_SPI_SCK1), MP_ROM_PTR(&pin_GPIO14) }, // SPI_SCK1 alias + { MP_ROM_QSTR(MP_QSTR_SDIO_CMD), MP_ROM_PTR(&pin_GPIO15) }, // GPIO15 - SDIO CMD | SDIO_CMD + { MP_ROM_QSTR(MP_QSTR_SPI_COPI1), MP_ROM_PTR(&pin_GPIO15) },// SPI_COPI1 alias + { MP_ROM_QSTR(MP_QSTR_SDIO_DATA0), MP_ROM_PTR(&pin_GPIO12) },// GPIO12 - SDIO DATA0 | SDIO_DATA0 + { MP_ROM_QSTR(MP_QSTR_SPI_CIPO1), MP_ROM_PTR(&pin_GPIO12) }, // SPI_CIPO1 alias + { MP_ROM_QSTR(MP_QSTR_SDIO_DATA1), MP_ROM_PTR(&pin_GPIO11) },// GPIO11 - SDIO DATA1 | SDIO_DATA1 | AUD_IN + { MP_ROM_QSTR(MP_QSTR_SDIO_DATA2), MP_ROM_PTR(&pin_GPIO10) },// GPIO10 - SDIO DATA2 | SDIO_DATA2 | AUD_OUT + { MP_ROM_QSTR(MP_QSTR_SDIO_DATA3), MP_ROM_PTR(&pin_GPIO9) },// GPIO9 - SDIO DATA3 | SDIO_DATA3 | SPI_CS1 + { MP_ROM_QSTR(MP_QSTR_SPI_CS1), MP_ROM_PTR(&pin_GPIO9) }, // SPI_CS1 alias + + // Status LED + { MP_ROM_QSTR(MP_QSTR_LED1), MP_ROM_PTR(&pin_GPIO25) }, // GPIO25 - LED_BUILTIN | STAT | Blue LED | G10 + + // UART + { MP_ROM_QSTR(MP_QSTR_RX), MP_ROM_PTR(&pin_GPIO1) }, // GPIO1 - UART RX | UART_RX1 | RX1 + { MP_ROM_QSTR(MP_QSTR_RX1), MP_ROM_PTR(&pin_GPIO1) }, // RX1 alias + { MP_ROM_QSTR(MP_QSTR_TX), MP_ROM_PTR(&pin_GPIO0) }, // GPIO0 - UART TX | UART_TX1 | TX1 + { MP_ROM_QSTR(MP_QSTR_TX1), MP_ROM_PTR(&pin_GPIO0) }, // TX1 alias + { MP_ROM_QSTR(MP_QSTR_CTS), MP_ROM_PTR(&pin_GPIO2) }, // GPIO2 - UART CTS | CTS1 (TRACEDATA3) + { MP_ROM_QSTR(MP_QSTR_CTS1), MP_ROM_PTR(&pin_GPIO2) }, // CTS1 alias + { MP_ROM_QSTR(MP_QSTR_RTS), MP_ROM_PTR(&pin_GPIO3) }, // GPIO3 - UART RTS | RTS1 + { MP_ROM_QSTR(MP_QSTR_RTS1), MP_ROM_PTR(&pin_GPIO3) }, // RTS1 alias + + { MP_ROM_QSTR(MP_QSTR_RX2), MP_ROM_PTR(&pin_GPIO9) }, // GPIO9 - UART RX | UART_RX2 | RX2 | SDIO_DAT3 | SPI_CS1 + { MP_ROM_QSTR(MP_QSTR_TX2), MP_ROM_PTR(&pin_GPIO8) }, // GPIO8 - UART TX | UART_TX2 | TX2 | I2C_INT + + // Board objects + { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) }, + { MP_ROM_QSTR(MP_QSTR_SPI), MP_ROM_PTR(&board_spi_obj) }, + { MP_ROM_QSTR(MP_QSTR_UART), MP_ROM_PTR(&board_uart_obj) }, + +}; +MP_DEFINE_CONST_DICT(board_module_globals, board_global_dict_table); diff --git a/ports/raspberrypi/mpconfigport.mk b/ports/raspberrypi/mpconfigport.mk index cece99afa9..635f1a75e7 100644 --- a/ports/raspberrypi/mpconfigport.mk +++ b/ports/raspberrypi/mpconfigport.mk @@ -43,8 +43,7 @@ CIRCUITPY_AUDIOBUSIO ?= 1 CIRCUITPY_AUDIOCORE ?= 1 CIRCUITPY_AUDIOPWMIO ?= 1 -# These libraries require Cortex M4+ for fancy math instructions. -CIRCUITPY_AUDIOMIXER ?= 0 +CIRCUITPY_AUDIOMIXER = 1 INTERNAL_LIBM = 1 diff --git a/ports/stm/boards/stm32f411ce_blackpill_with_flash/mpconfigboard.mk b/ports/stm/boards/stm32f411ce_blackpill_with_flash/mpconfigboard.mk index 76acd7ed1e..211a658967 100644 --- a/ports/stm/boards/stm32f411ce_blackpill_with_flash/mpconfigboard.mk +++ b/ports/stm/boards/stm32f411ce_blackpill_with_flash/mpconfigboard.mk @@ -16,3 +16,5 @@ MCU_PACKAGE = UFQFPN48 LD_COMMON = boards/common_default.ld LD_FILE = boards/STM32F411_nvm_nofs.ld + +CIRCUITPY_SYNTHIO = 0 diff --git a/py/binary.c b/py/binary.c index 846058525f..cd61d74fa8 100644 --- a/py/binary.c +++ b/py/binary.c @@ -371,11 +371,7 @@ void mp_binary_set_val(char struct_type, char val_type, mp_obj_t val_in, byte ** } } - if (val_type == 'x') { - memset(p, 0, 1); - } else { - mp_binary_set_int(MIN((size_t)size, sizeof(val)), struct_type == '>', p, val); - } + mp_binary_set_int(MIN((size_t)size, sizeof(val)), struct_type == '>', p, val); } void mp_binary_set_val_array(char typecode, void *p, mp_uint_t index, mp_obj_t val_in) { diff --git a/py/circuitpy_defns.mk b/py/circuitpy_defns.mk index 0eedfe5249..5745c4f1d2 100644 --- a/py/circuitpy_defns.mk +++ b/py/circuitpy_defns.mk @@ -280,6 +280,9 @@ endif ifeq ($(CIRCUITPY_SUPERVISOR),1) SRC_PATTERNS += supervisor/% endif +ifeq ($(CIRCUITPY_SYNTHIO),1) +SRC_PATTERNS += synthio/% +endif ifeq ($(CIRCUITPY_TERMINALIO),1) SRC_PATTERNS += terminalio/% fontio/% endif @@ -524,6 +527,8 @@ SRC_SHARED_MODULE_ALL = \ socket/__init__.c \ storage/__init__.c \ struct/__init__.c \ + synthio/MidiTrack.c \ + synthio/__init__.c \ terminalio/Terminal.c \ terminalio/__init__.c \ time/__init__.c \ diff --git a/py/circuitpy_mpconfig.h b/py/circuitpy_mpconfig.h index eedda7ad73..801e1867e7 100644 --- a/py/circuitpy_mpconfig.h +++ b/py/circuitpy_mpconfig.h @@ -728,6 +728,13 @@ extern const struct _mp_obj_module_t supervisor_module; #define SUPERVISOR_MODULE #endif +#if CIRCUITPY_SYNTHIO +#define SYNTHIO_MODULE { MP_OBJ_NEW_QSTR(MP_QSTR_synthio), (mp_obj_t)&synthio_module }, +extern const struct _mp_obj_module_t synthio_module; +#else +#define SYNTHIO_MODULE +#endif + #if CIRCUITPY_TIME extern const struct _mp_obj_module_t time_module; #define TIME_MODULE { MP_OBJ_NEW_QSTR(MP_QSTR_time), (mp_obj_t)&time_module }, @@ -897,6 +904,7 @@ extern const struct _mp_obj_module_t msgpack_module; STORAGE_MODULE \ STRUCT_MODULE \ SUPERVISOR_MODULE \ + SYNTHIO_MODULE \ TOUCHIO_MODULE \ UHEAP_MODULE \ USB_CDC_MODULE \ diff --git a/py/circuitpy_mpconfig.mk b/py/circuitpy_mpconfig.mk index 51b590dcf3..600e56ee23 100644 --- a/py/circuitpy_mpconfig.mk +++ b/py/circuitpy_mpconfig.mk @@ -311,6 +311,9 @@ CFLAGS += -DCIRCUITPY_STRUCT=$(CIRCUITPY_STRUCT) CIRCUITPY_SUPERVISOR ?= 1 CFLAGS += -DCIRCUITPY_SUPERVISOR=$(CIRCUITPY_SUPERVISOR) +CIRCUITPY_SYNTHIO ?= $(CIRCUITPY_AUDIOCORE) +CFLAGS += -DCIRCUITPY_SYNTHIO=$(CIRCUITPY_SYNTHIO) + CIRCUITPY_TERMINALIO ?= $(CIRCUITPY_DISPLAYIO) CFLAGS += -DCIRCUITPY_TERMINALIO=$(CIRCUITPY_TERMINALIO) diff --git a/py/compile.c b/py/compile.c index 4a9fdc7db8..7971690d6d 100644 --- a/py/compile.c +++ b/py/compile.c @@ -768,7 +768,7 @@ STATIC bool compile_built_in_decorator(compiler_t *comp, int name_len, mp_parse_ } if (name_len != 2) { - compile_syntax_error(comp, name_nodes[0], translate("invalid micropython decorator")); + compile_syntax_error(comp, name_nodes[0], translate("invalid decorator")); return true; } diff --git a/py/makeqstrdata.py b/py/makeqstrdata.py index 0ad749005c..6a6125fe20 100644 --- a/py/makeqstrdata.py +++ b/py/makeqstrdata.py @@ -12,7 +12,6 @@ from __future__ import print_function import re import sys -from math import log import collections import gettext import os.path @@ -167,7 +166,7 @@ def compute_huffman_coding(translations, compression_filename): sum_len = 0 while True: # Until the dictionary is filled to capacity, use a heuristic to find - # the best "word" (2- to 9-gram) to add to it. + # the best "word" (3- to 9-gram) to add to it. # # The TextSplitter allows us to avoid considering parts of the text # that are already covered by a previously chosen word, for example @@ -179,32 +178,25 @@ def compute_huffman_coding(translations, compression_filename): for t in texts: for (found, word) in extractor.iter_words(t): if not found: - for substr in iter_substrings(word, minlen=2, maxlen=9): + for substr in iter_substrings(word, minlen=3, maxlen=9): counter[substr] += 1 # Score the candidates we found. This is an empirical formula only, # chosen for its effectiveness. scores = sorted( - ((s, (len(s) - 1) ** log(max(occ - 2, 1)), occ) for (s, occ) in counter.items()), + ((s, (len(s) - 1) ** (occ + 4)) for (s, occ) in counter.items() if occ > 4), key=lambda x: x[1], reverse=True, ) - # Do we have a "word" that occurred 5 times and got a score of at least - # 5? Horray. Pick the one with the highest score. - word = None - for (s, score, occ) in scores: - if occ < 5: - continue - if score < 5: - break - word = s + # Pick the one with the highest score. + if not scores: break + word = scores[0][0] + # If we can successfully add it to the dictionary, do so. Otherwise, # we've filled the dictionary to capacity and are done. - if not word: - break if sum_len + len(word) - 2 > max_words_len: break if len(words) == max_words: @@ -456,27 +448,24 @@ def parse_input_headers(infiles): return qcfgs, qstrs, i18ns +def escape_bytes(qstr): + if all(32 <= ord(c) <= 126 and c != "\\" and c != '"' for c in qstr): + # qstr is all printable ASCII so render it as-is (for easier debugging) + return qstr + else: + # qstr contains non-printable codes so render entire thing as hex pairs + qbytes = bytes_cons(qstr, "utf8") + return "".join(("\\x%02x" % b) for b in qbytes) def make_bytes(cfg_bytes_len, cfg_bytes_hash, qstr): qbytes = bytes_cons(qstr, "utf8") qlen = len(qbytes) qhash = compute_hash(qbytes, cfg_bytes_hash) - if all(32 <= ord(c) <= 126 and c != "\\" and c != '"' for c in qstr): - # qstr is all printable ASCII so render it as-is (for easier debugging) - qdata = qstr - else: - # qstr contains non-printable codes so render entire thing as hex pairs - qdata = "".join(("\\x%02x" % b) for b in qbytes) if qlen >= (1 << (8 * cfg_bytes_len)): print("qstr is too long:", qstr) assert False - qlen_str = ("\\x%02x" * cfg_bytes_len) % tuple( - ((qlen >> (8 * i)) & 0xFF) for i in range(cfg_bytes_len) - ) - qhash_str = ("\\x%02x" * cfg_bytes_hash) % tuple( - ((qhash >> (8 * i)) & 0xFF) for i in range(cfg_bytes_hash) - ) - return '(const byte*)"%s%s" "%s"' % (qhash_str, qlen_str, qdata) + qdata = escape_bytes(qstr) + return '%d, %d, "%s"' % (qhash, qlen, qdata) def print_qstr_data(encoding_table, qcfgs, qstrs, i18ns): @@ -489,10 +478,7 @@ def print_qstr_data(encoding_table, qcfgs, qstrs, i18ns): print("") # add NULL qstr with no hash or data - print( - 'QDEF(MP_QSTR_NULL, (const byte*)"%s%s" "")' - % ("\\x00" * cfg_bytes_hash, "\\x00" * cfg_bytes_len) - ) + print('QDEF(MP_QSTR_NULL, 0, 0, "")') total_qstr_size = 0 total_qstr_compressed_size = 0 diff --git a/py/modstruct.c b/py/modstruct.c index 1c5319608d..8f78fa234a 100644 --- a/py/modstruct.c +++ b/py/modstruct.c @@ -214,9 +214,11 @@ STATIC void struct_pack_into_internal(mp_obj_t fmt_in, byte *p, size_t n_args, c p += cnt; } else { while (cnt--) { - mp_binary_set_val(fmt_type, *fmt, args[i], &p); // Pad bytes don't have a corresponding argument. - if (*fmt != 'x') { + if (*fmt == 'x') { + mp_binary_set_val(fmt_type, *fmt, MP_OBJ_NEW_SMALL_INT(0), &p); + } else { + mp_binary_set_val(fmt_type, *fmt, args[i], &p); i++; } } diff --git a/py/mpstate.h b/py/mpstate.h index 139f23cb4f..1f6a2d00a1 100644 --- a/py/mpstate.h +++ b/py/mpstate.h @@ -197,7 +197,7 @@ typedef struct _mp_state_vm_t { // pointer and sizes to store interned string data // (qstr_last_chunk can be root pointer but is also stored in qstr pool) - byte *qstr_last_chunk; + char *qstr_last_chunk; size_t qstr_last_alloc; size_t qstr_last_used; diff --git a/py/qstr.c b/py/qstr.c index 2ae65379c7..af5ea58686 100644 --- a/py/qstr.c +++ b/py/qstr.c @@ -37,7 +37,6 @@ // NOTE: we are using linear arrays to store and search for qstr's (unique strings, interned strings) // ultimately we will replace this with a static hash table of some kind -// also probably need to include the length in the string data, to allow null bytes in the string #if MICROPY_DEBUG_VERBOSE // print debugging info #define DEBUG_printf DEBUG_printf @@ -46,34 +45,9 @@ #endif // A qstr is an index into the qstr pool. -// The data for a qstr contains (hash, length, data): -// - hash (configurable number of bytes) -// - length (configurable number of bytes) -// - data ("length" number of bytes) -// - \0 terminated (so they can be printed using printf) +// The data for a qstr is \0 terminated (so they can be printed using printf) -#if MICROPY_QSTR_BYTES_IN_HASH == 1 - #define Q_HASH_MASK (0xff) - #define Q_GET_HASH(q) ((mp_uint_t)(q)[0]) - #define Q_SET_HASH(q, hash) do { (q)[0] = (hash); } while (0) -#elif MICROPY_QSTR_BYTES_IN_HASH == 2 - #define Q_HASH_MASK (0xffff) - #define Q_GET_HASH(q) ((mp_uint_t)(q)[0] | ((mp_uint_t)(q)[1] << 8)) - #define Q_SET_HASH(q, hash) do { (q)[0] = (hash); (q)[1] = (hash) >> 8; } while (0) -#else - #error unimplemented qstr hash decoding -#endif -#define Q_GET_ALLOC(q) (MICROPY_QSTR_BYTES_IN_HASH + MICROPY_QSTR_BYTES_IN_LEN + Q_GET_LENGTH(q) + 1) -#define Q_GET_DATA(q) ((q) + MICROPY_QSTR_BYTES_IN_HASH + MICROPY_QSTR_BYTES_IN_LEN) -#if MICROPY_QSTR_BYTES_IN_LEN == 1 - #define Q_GET_LENGTH(q) ((q)[MICROPY_QSTR_BYTES_IN_HASH]) - #define Q_SET_LENGTH(q, len) do { (q)[MICROPY_QSTR_BYTES_IN_HASH] = (len); } while (0) -#elif MICROPY_QSTR_BYTES_IN_LEN == 2 - #define Q_GET_LENGTH(q) ((q)[MICROPY_QSTR_BYTES_IN_HASH] | ((q)[MICROPY_QSTR_BYTES_IN_HASH + 1] << 8)) - #define Q_SET_LENGTH(q, len) do { (q)[MICROPY_QSTR_BYTES_IN_HASH] = (len); (q)[MICROPY_QSTR_BYTES_IN_HASH + 1] = (len) >> 8; } while (0) -#else - #error unimplemented qstr length decoding -#endif +#define Q_HASH_MASK ((1 << (8 * MICROPY_QSTR_BYTES_IN_HASH)) - 1) #if MICROPY_PY_THREAD && !MICROPY_PY_THREAD_GIL #define QSTR_ENTER() mp_thread_mutex_lock(&MP_STATE_VM(qstr_mutex), 1) @@ -98,14 +72,25 @@ mp_uint_t qstr_compute_hash(const byte *data, size_t len) { return hash; } +const qstr_attr_t mp_qstr_const_attr[] = { + #ifndef NO_QSTR +#define QDEF(id, hash, len, str) { hash, len }, +#define TRANSLATION(id, length, compressed ...) + #include "genhdr/qstrdefs.generated.h" +#undef TRANSLATION +#undef QDEF + #endif +}; + const qstr_pool_t mp_qstr_const_pool = { NULL, // no previous pool 0, // no previous pool 10, // set so that the first dynamically allocated pool is twice this size; must be <= the len (just below) MP_QSTRnumber_of, // corresponds to number of strings in array just below + (qstr_attr_t *)mp_qstr_const_attr, { #ifndef NO_QSTR -#define QDEF(id, str) str, +#define QDEF(id, hash, len, str) str, #define TRANSLATION(id, length, compressed ...) #include "genhdr/qstrdefs.generated.h" #undef TRANSLATION @@ -130,20 +115,22 @@ void qstr_init(void) { #endif } -STATIC const byte *find_qstr(qstr q) { +STATIC const char *find_qstr(qstr q, qstr_attr_t *attr) { // search pool for this qstr // total_prev_len==0 in the final pool, so the loop will always terminate qstr_pool_t *pool = MP_STATE_VM(last_pool); while (q < pool->total_prev_len) { pool = pool->prev; } - assert(q - pool->total_prev_len < pool->len); - return pool->qstrs[q - pool->total_prev_len]; + q -= pool->total_prev_len; + assert(q < pool->len); + *attr = pool->attrs[q]; + return pool->qstrs[q]; } // qstr_mutex must be taken while in this function -STATIC qstr qstr_add(const byte *q_ptr) { - DEBUG_printf("QSTR: add hash=%d len=%d data=%.*s\n", Q_GET_HASH(q_ptr), Q_GET_LENGTH(q_ptr), Q_GET_LENGTH(q_ptr), Q_GET_DATA(q_ptr)); +STATIC qstr qstr_add(mp_uint_t hash, mp_uint_t len, const char *q_ptr) { + DEBUG_printf("QSTR: add hash=%d len=%d data=%.*s\n", hash, len, len, q_ptr); // make sure we have room in the pool for a new qstr if (MP_STATE_VM(last_pool)->len >= MP_STATE_VM(last_pool)->alloc) { @@ -151,11 +138,14 @@ STATIC qstr qstr_add(const byte *q_ptr) { if (new_pool_length > MICROPY_QSTR_POOL_MAX_ENTRIES) { new_pool_length = MICROPY_QSTR_POOL_MAX_ENTRIES; } - qstr_pool_t *pool = m_new_ll_obj_var_maybe(qstr_pool_t, const char *, new_pool_length); - if (pool == NULL) { + mp_uint_t pool_size = sizeof(qstr_pool_t) + sizeof(const char *) * new_pool_length; + void *chunk = m_malloc_maybe(pool_size + sizeof(qstr_attr_t) * new_pool_length, true); + if (chunk == NULL) { QSTR_EXIT(); m_malloc_fail(new_pool_length); } + qstr_pool_t *pool = (qstr_pool_t *)chunk; + pool->attrs = (qstr_attr_t *)(void *)((char *)chunk + pool_size); pool->prev = MP_STATE_VM(last_pool); pool->total_prev_len = MP_STATE_VM(last_pool)->total_prev_len + MP_STATE_VM(last_pool)->len; pool->alloc = new_pool_length; @@ -165,10 +155,14 @@ STATIC qstr qstr_add(const byte *q_ptr) { } // add the new qstr - MP_STATE_VM(last_pool)->qstrs[MP_STATE_VM(last_pool)->len++] = q_ptr; + mp_uint_t at = MP_STATE_VM(last_pool)->len; + MP_STATE_VM(last_pool)->attrs[at].hash = hash; + MP_STATE_VM(last_pool)->attrs[at].len = len; + MP_STATE_VM(last_pool)->qstrs[at] = q_ptr; + MP_STATE_VM(last_pool)->len++; // return id for the newly-added qstr - return MP_STATE_VM(last_pool)->total_prev_len + MP_STATE_VM(last_pool)->len - 1; + return MP_STATE_VM(last_pool)->total_prev_len + at; } qstr qstr_find_strn(const char *str, size_t str_len) { @@ -177,9 +171,10 @@ qstr qstr_find_strn(const char *str, size_t str_len) { // search pools for the data for (qstr_pool_t *pool = MP_STATE_VM(last_pool); pool != NULL; pool = pool->prev) { - for (const byte **q = pool->qstrs, **q_top = pool->qstrs + pool->len; q < q_top; q++) { - if (Q_GET_HASH(*q) == str_hash && Q_GET_LENGTH(*q) == str_len && memcmp(Q_GET_DATA(*q), str, str_len) == 0) { - return pool->total_prev_len + (q - pool->qstrs); + qstr_attr_t *attrs = pool->attrs; + for (mp_uint_t at = 0, top = pool->len; at < top; at++) { + if (attrs[at].hash == str_hash && attrs[at].len == str_len && memcmp(pool->qstrs[at], str, str_len) == 0) { + return pool->total_prev_len + at; } } } @@ -200,14 +195,14 @@ qstr qstr_from_strn(const char *str, size_t len) { // qstr does not exist in interned pool so need to add it // compute number of bytes needed to intern this string - size_t n_bytes = MICROPY_QSTR_BYTES_IN_HASH + MICROPY_QSTR_BYTES_IN_LEN + len + 1; + size_t n_bytes = len + 1; if (MP_STATE_VM(qstr_last_chunk) != NULL && MP_STATE_VM(qstr_last_used) + n_bytes > MP_STATE_VM(qstr_last_alloc)) { // not enough room at end of previously interned string so try to grow - byte *new_p = m_renew_maybe(byte, MP_STATE_VM(qstr_last_chunk), MP_STATE_VM(qstr_last_alloc), MP_STATE_VM(qstr_last_alloc) + n_bytes, false); + char *new_p = m_renew_maybe(char, MP_STATE_VM(qstr_last_chunk), MP_STATE_VM(qstr_last_alloc), MP_STATE_VM(qstr_last_alloc) + n_bytes, false); if (new_p == NULL) { // could not grow existing memory; shrink it to fit previous - (void)m_renew_maybe(byte, MP_STATE_VM(qstr_last_chunk), MP_STATE_VM(qstr_last_alloc), MP_STATE_VM(qstr_last_used), false); + (void)m_renew_maybe(char, MP_STATE_VM(qstr_last_chunk), MP_STATE_VM(qstr_last_alloc), MP_STATE_VM(qstr_last_used), false); MP_STATE_VM(qstr_last_chunk) = NULL; } else { // could grow existing memory @@ -221,10 +216,10 @@ qstr qstr_from_strn(const char *str, size_t len) { if (al < MICROPY_ALLOC_QSTR_CHUNK_INIT) { al = MICROPY_ALLOC_QSTR_CHUNK_INIT; } - MP_STATE_VM(qstr_last_chunk) = m_new_ll_maybe(byte, al); + MP_STATE_VM(qstr_last_chunk) = m_new_ll_maybe(char, al); if (MP_STATE_VM(qstr_last_chunk) == NULL) { // failed to allocate a large chunk so try with exact size - MP_STATE_VM(qstr_last_chunk) = m_new_ll_maybe(byte, n_bytes); + MP_STATE_VM(qstr_last_chunk) = m_new_ll_maybe(char, n_bytes); if (MP_STATE_VM(qstr_last_chunk) == NULL) { QSTR_EXIT(); m_malloc_fail(n_bytes); @@ -236,39 +231,41 @@ qstr qstr_from_strn(const char *str, size_t len) { } // allocate memory from the chunk for this new interned string's data - byte *q_ptr = MP_STATE_VM(qstr_last_chunk) + MP_STATE_VM(qstr_last_used); + char *q_ptr = MP_STATE_VM(qstr_last_chunk) + MP_STATE_VM(qstr_last_used); MP_STATE_VM(qstr_last_used) += n_bytes; // store the interned strings' data mp_uint_t hash = qstr_compute_hash((const byte *)str, len); - Q_SET_HASH(q_ptr, hash); - Q_SET_LENGTH(q_ptr, len); - memcpy(q_ptr + MICROPY_QSTR_BYTES_IN_HASH + MICROPY_QSTR_BYTES_IN_LEN, str, len); - q_ptr[MICROPY_QSTR_BYTES_IN_HASH + MICROPY_QSTR_BYTES_IN_LEN + len] = '\0'; - q = qstr_add(q_ptr); + memcpy(q_ptr, str, len); + q_ptr[len] = '\0'; + q = qstr_add(hash, len, q_ptr); } QSTR_EXIT(); return q; } mp_uint_t PLACE_IN_ITCM(qstr_hash)(qstr q) { - return Q_GET_HASH(find_qstr(q)); + qstr_attr_t attr; + find_qstr(q, &attr); + return attr.hash; } size_t qstr_len(qstr q) { - const byte *qd = find_qstr(q); - return Q_GET_LENGTH(qd); + qstr_attr_t attr; + find_qstr(q, &attr); + return attr.len; } const char *qstr_str(qstr q) { - const byte *qd = find_qstr(q); - return (const char *)Q_GET_DATA(qd); + qstr_attr_t attr; + return find_qstr(q, &attr); } const byte *qstr_data(qstr q, size_t *len) { - const byte *qd = find_qstr(q); - *len = Q_GET_LENGTH(qd); - return Q_GET_DATA(qd); + qstr_attr_t attr; + const char *qd = find_qstr(q, &attr); + *len = attr.len; + return (byte *)qd; } void qstr_pool_info(size_t *n_pool, size_t *n_qstr, size_t *n_str_data_bytes, size_t *n_total_bytes) { @@ -280,13 +277,14 @@ void qstr_pool_info(size_t *n_pool, size_t *n_qstr, size_t *n_str_data_bytes, si for (qstr_pool_t *pool = MP_STATE_VM(last_pool); pool != NULL && pool != &CONST_POOL; pool = pool->prev) { *n_pool += 1; *n_qstr += pool->len; - for (const byte **q = pool->qstrs, **q_top = pool->qstrs + pool->len; q < q_top; q++) { - *n_str_data_bytes += Q_GET_ALLOC(*q); + for (const qstr_attr_t *q = pool->attrs, *q_top = pool->attrs + pool->len; q < q_top; q++) { + *n_str_data_bytes += sizeof(*q) + q->len + 1; } #if MICROPY_ENABLE_GC - *n_total_bytes += gc_nbytes(pool); // this counts actual bytes used in heap + // this counts actual bytes used in heap + *n_total_bytes += gc_nbytes(pool) - sizeof(qstr_attr_t) * pool->alloc; #else - *n_total_bytes += sizeof(qstr_pool_t) + sizeof(qstr) * pool->alloc; + *n_total_bytes += sizeof(qstr_pool_t) + sizeof(const char *) * pool->alloc; #endif } *n_total_bytes += *n_str_data_bytes; @@ -297,8 +295,8 @@ void qstr_pool_info(size_t *n_pool, size_t *n_qstr, size_t *n_str_data_bytes, si void qstr_dump_data(void) { QSTR_ENTER(); for (qstr_pool_t *pool = MP_STATE_VM(last_pool); pool != NULL && pool != &CONST_POOL; pool = pool->prev) { - for (const byte **q = pool->qstrs, **q_top = pool->qstrs + pool->len; q < q_top; q++) { - mp_printf(&mp_plat_print, "Q(%s)\n", Q_GET_DATA(*q)); + for (const char **q = pool->qstrs, **q_top = pool->qstrs + pool->len; q < q_top; q++) { + mp_printf(&mp_plat_print, "Q(%s)\n", *q); } } QSTR_EXIT(); diff --git a/py/qstr.h b/py/qstr.h index c86e74324c..288bf5dbac 100644 --- a/py/qstr.h +++ b/py/qstr.h @@ -47,12 +47,30 @@ enum { typedef size_t qstr; +typedef struct _qstr_attr_t { + #if MICROPY_QSTR_BYTES_IN_HASH == 1 + uint8_t hash; + #elif MICROPY_QSTR_BYTES_IN_HASH == 2 + uint16_t hash; + #else + #error unimplemented qstr hash decoding + #endif + #if MICROPY_QSTR_BYTES_IN_LEN == 1 + uint8_t len; + #elif MICROPY_QSTR_BYTES_IN_LEN == 2 + uint16_t len; + #else + #error unimplemented qstr length decoding + #endif +} qstr_attr_t; + typedef struct _qstr_pool_t { struct _qstr_pool_t *prev; size_t total_prev_len; size_t alloc; size_t len; - const byte *qstrs[]; + qstr_attr_t *attrs; + const char *qstrs[]; } qstr_pool_t; #define QSTR_FROM_STR_STATIC(s) (qstr_from_strn((s), strlen(s))) diff --git a/py/repl.c b/py/repl.c index ccc8dd5c6b..6cc10bb007 100644 --- a/py/repl.c +++ b/py/repl.c @@ -281,6 +281,12 @@ size_t mp_repl_autocomplete(const char *str, size_t len, const mp_print_t *print ++str; } + // after "import", suggest built-in modules + static const char import_str[] = "import "; + if (len >= 7 && !memcmp(org_str, import_str, 7)) { + obj = MP_OBJ_NULL; + } + // look for matches size_t match_len; qstr q_first, q_last; @@ -291,19 +297,12 @@ size_t mp_repl_autocomplete(const char *str, size_t len, const mp_print_t *print if (q_first == 0) { // If there're no better alternatives, and if it's first word // in the line, try to complete "import". - static const char import_str[] = "import "; if (s_start == org_str && s_len > 0) { if (memcmp(s_start, import_str, s_len) == 0) { *compl_str = import_str + s_len; return sizeof(import_str) - 1 - s_len; } } - // after "import", suggest built-in modules - if (len >= 7 && !memcmp(org_str, import_str, 7)) { - obj = NULL; - match_str = find_completions( - s_start, s_len, obj, &match_len, &q_first, &q_last); - } if (q_first == 0) { *compl_str = " "; return s_len ? 0 : 4; diff --git a/shared-bindings/_bleio/Characteristic.c b/shared-bindings/_bleio/Characteristic.c index 0aa832cf21..b69b71d0c9 100644 --- a/shared-bindings/_bleio/Characteristic.c +++ b/shared-bindings/_bleio/Characteristic.c @@ -219,6 +219,23 @@ const mp_obj_property_t bleio_characteristic_value_obj = { (mp_obj_t)&mp_const_none_obj }, }; +//| max_length: int +//| """The max length of this characteristic.""" +//| +STATIC mp_obj_t bleio_characteristic_get_max_length(mp_obj_t self_in) { + bleio_characteristic_obj_t *self = MP_OBJ_TO_PTR(self_in); + + return MP_OBJ_NEW_SMALL_INT(common_hal_bleio_characteristic_get_max_length(self)); +} +STATIC MP_DEFINE_CONST_FUN_OBJ_1(bleio_characteristic_get_max_length_obj, bleio_characteristic_get_max_length); + +const mp_obj_property_t bleio_characteristic_max_length_obj = { + .base.type = &mp_type_property, + .proxy = { (mp_obj_t)&bleio_characteristic_get_max_length_obj, + (mp_obj_t)&mp_const_none_obj, + (mp_obj_t)&mp_const_none_obj }, +}; + //| descriptors: Descriptor //| """A tuple of :py:class:`Descriptor` objects related to this characteristic. (read-only)""" //| diff --git a/shared-bindings/_bleio/Characteristic.h b/shared-bindings/_bleio/Characteristic.h index a8486866f9..878d998a2d 100644 --- a/shared-bindings/_bleio/Characteristic.h +++ b/shared-bindings/_bleio/Characteristic.h @@ -40,6 +40,7 @@ extern bleio_characteristic_properties_t common_hal_bleio_characteristic_get_pro extern mp_obj_tuple_t *common_hal_bleio_characteristic_get_descriptors(bleio_characteristic_obj_t *self); extern bleio_service_obj_t *common_hal_bleio_characteristic_get_service(bleio_characteristic_obj_t *self); extern bleio_uuid_obj_t *common_hal_bleio_characteristic_get_uuid(bleio_characteristic_obj_t *self); +extern size_t common_hal_bleio_characteristic_get_max_length(bleio_characteristic_obj_t *self); extern size_t common_hal_bleio_characteristic_get_value(bleio_characteristic_obj_t *self, uint8_t *buf, size_t len); extern void common_hal_bleio_characteristic_add_descriptor(bleio_characteristic_obj_t *self, bleio_descriptor_obj_t *descriptor); extern void common_hal_bleio_characteristic_construct(bleio_characteristic_obj_t *self, bleio_service_obj_t *service, uint16_t handle, bleio_uuid_obj_t *uuid, bleio_characteristic_properties_t props, bleio_attribute_security_mode_t read_perm, bleio_attribute_security_mode_t write_perm, mp_int_t max_length, bool fixed_length, mp_buffer_info_t *initial_value_bufinfo); diff --git a/shared-bindings/_bleio/PacketBuffer.c b/shared-bindings/_bleio/PacketBuffer.c index 9412dee5d7..b54a48230b 100644 --- a/shared-bindings/_bleio/PacketBuffer.c +++ b/shared-bindings/_bleio/PacketBuffer.c @@ -44,7 +44,7 @@ //| When we're the server, we ignore all connections besides the first to subscribe to //| notifications.""" //| -//| def __init__(self, characteristic: Characteristic, *, buffer_size: int) -> None: +//| def __init__(self, characteristic: Characteristic, *, buffer_size: int, max_packet_size: Optional[int] = None) -> None: //| """Monitor the given Characteristic. Each time a new value is written to the Characteristic //| add the newly-written bytes to a FIFO buffer. //| @@ -55,14 +55,17 @@ //| It may be a local Characteristic provided by a Peripheral Service, or a remote Characteristic //| in a remote Service that a Central has connected to. //| :param int buffer_size: Size of ring buffer (in packets of the Characteristic's maximum -//| length) that stores incoming packets coming from the peer.""" +//| length) that stores incoming packets coming from the peer. +//| :param int max_packet_size: Maximum size of packets. Overrides value from the characteristic. +//| (Remote characteristics may not have the correct length.)""" //| ... //| STATIC mp_obj_t bleio_packet_buffer_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { - enum { ARG_characteristic, ARG_buffer_size }; + enum { ARG_characteristic, ARG_buffer_size, ARG_max_packet_size }; static const mp_arg_t allowed_args[] = { { MP_QSTR_characteristic, MP_ARG_REQUIRED | MP_ARG_OBJ }, { MP_QSTR_buffer_size, MP_ARG_KW_ONLY | MP_ARG_REQUIRED | MP_ARG_INT }, + { MP_QSTR_max_packet_size, MP_ARG_KW_ONLY | MP_ARG_OBJ, {.u_obj = mp_const_none}}, }; mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; @@ -79,10 +82,15 @@ STATIC mp_obj_t bleio_packet_buffer_make_new(const mp_obj_type_t *type, size_t n mp_raise_TypeError(translate("Expected a Characteristic")); } + size_t max_packet_size = common_hal_bleio_characteristic_get_max_length(characteristic); + if (args[ARG_max_packet_size].u_obj != mp_const_none) { + max_packet_size = mp_obj_get_int(args[ARG_max_packet_size].u_obj); + } + bleio_packet_buffer_obj_t *self = m_new_obj(bleio_packet_buffer_obj_t); self->base.type = &bleio_packet_buffer_type; - common_hal_bleio_packet_buffer_construct(self, MP_OBJ_TO_PTR(characteristic), buffer_size); + common_hal_bleio_packet_buffer_construct(self, MP_OBJ_TO_PTR(characteristic), buffer_size, max_packet_size); return MP_OBJ_FROM_PTR(self); } @@ -133,7 +141,7 @@ STATIC mp_obj_t bleio_packet_buffer_write(mp_uint_t n_args, const mp_obj_t *pos_ enum { ARG_data, ARG_header }; static const mp_arg_t allowed_args[] = { { MP_QSTR_data, MP_ARG_REQUIRED | MP_ARG_OBJ }, - { MP_QSTR_header, MP_ARG_KW_ONLY | MP_ARG_OBJ, {.u_obj = MP_OBJ_NULL}}, + { MP_QSTR_header, MP_ARG_KW_ONLY | MP_ARG_OBJ, {.u_obj = mp_const_none}}, }; mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; @@ -147,7 +155,7 @@ STATIC mp_obj_t bleio_packet_buffer_write(mp_uint_t n_args, const mp_obj_t *pos_ mp_buffer_info_t header_bufinfo; header_bufinfo.len = 0; - if (args[ARG_header].u_obj != MP_OBJ_NULL) { + if (args[ARG_header].u_obj != mp_const_none) { mp_get_buffer_raise(args[ARG_header].u_obj, &header_bufinfo, MP_BUFFER_READ); } diff --git a/shared-bindings/_bleio/PacketBuffer.h b/shared-bindings/_bleio/PacketBuffer.h index 65ce3ded1f..b300cb0215 100644 --- a/shared-bindings/_bleio/PacketBuffer.h +++ b/shared-bindings/_bleio/PacketBuffer.h @@ -33,7 +33,7 @@ extern const mp_obj_type_t bleio_packet_buffer_type; extern void common_hal_bleio_packet_buffer_construct( bleio_packet_buffer_obj_t *self, bleio_characteristic_obj_t *characteristic, - size_t buffer_size); + size_t buffer_size, size_t max_packet_size); mp_int_t common_hal_bleio_packet_buffer_write(bleio_packet_buffer_obj_t *self, uint8_t *data, size_t len, uint8_t *header, size_t header_len); mp_int_t common_hal_bleio_packet_buffer_readinto(bleio_packet_buffer_obj_t *self, uint8_t *data, size_t len); mp_int_t common_hal_bleio_packet_buffer_get_incoming_packet_length(bleio_packet_buffer_obj_t *self); diff --git a/shared-bindings/_typing/__init__.pyi b/shared-bindings/_typing/__init__.pyi index 9a6e963ea5..d1bf853f71 100644 --- a/shared-bindings/_typing/__init__.pyi +++ b/shared-bindings/_typing/__init__.pyi @@ -38,7 +38,7 @@ WriteableBuffer = Union[ """ AudioSample = Union[ - audiocore.WaveFile, audiocore.RawSample, audiomixer.Mixer, audiomp3.MP3Decoder + audiocore.WaveFile, audiocore.RawSample, audiomixer.Mixer, audiomp3.MP3Decoder, synthio.MidiTrack ] """Classes that implement the audiosample protocol @@ -46,6 +46,7 @@ AudioSample = Union[ - `audiocore.RawSample` - `audiomixer.Mixer` - `audiomp3.MP3Decoder` + - `synthio.MidiTrack` You can play these back with `audioio.AudioOut`, `audiobusio.I2SOut` or `audiopwmio.PWMAudioOut`. """ diff --git a/shared-bindings/audiocore/RawSample.c b/shared-bindings/audiocore/RawSample.c index 23a2d3f0be..13339222c1 100644 --- a/shared-bindings/audiocore/RawSample.c +++ b/shared-bindings/audiocore/RawSample.c @@ -30,7 +30,6 @@ #include "py/binary.h" #include "py/objproperty.h" #include "py/runtime.h" -#include "shared-bindings/microcontroller/Pin.h" #include "shared-bindings/util.h" #include "shared-bindings/audiocore/RawSample.h" #include "supervisor/shared/translate.h" @@ -83,26 +82,23 @@ STATIC mp_obj_t audioio_rawsample_make_new(const mp_obj_type_t *type, size_t n_a audioio_rawsample_obj_t *self = m_new_obj(audioio_rawsample_obj_t); self->base.type = &audioio_rawsample_type; mp_buffer_info_t bufinfo; - if (mp_get_buffer(args[ARG_buffer].u_obj, &bufinfo, MP_BUFFER_READ)) { - uint8_t bytes_per_sample = 1; - bool signed_samples = bufinfo.typecode == 'b' || bufinfo.typecode == 'h'; - if (bufinfo.typecode == 'h' || bufinfo.typecode == 'H') { - bytes_per_sample = 2; - } else if (bufinfo.typecode != 'b' && bufinfo.typecode != 'B' && bufinfo.typecode != BYTEARRAY_TYPECODE) { - mp_raise_ValueError(translate("sample_source buffer must be a bytearray or array of type 'h', 'H', 'b' or 'B'")); - } - common_hal_audioio_rawsample_construct(self, ((uint8_t *)bufinfo.buf), bufinfo.len, - bytes_per_sample, signed_samples, args[ARG_channel_count].u_int, - args[ARG_sample_rate].u_int); - } else { - mp_raise_TypeError(translate("buffer must be a bytes-like object")); + mp_get_buffer_raise(args[ARG_buffer].u_obj, &bufinfo, MP_BUFFER_READ); + uint8_t bytes_per_sample = 1; + bool signed_samples = bufinfo.typecode == 'b' || bufinfo.typecode == 'h'; + if (bufinfo.typecode == 'h' || bufinfo.typecode == 'H') { + bytes_per_sample = 2; + } else if (bufinfo.typecode != 'b' && bufinfo.typecode != 'B' && bufinfo.typecode != BYTEARRAY_TYPECODE) { + mp_raise_ValueError(translate("sample_source buffer must be a bytearray or array of type 'h', 'H', 'b' or 'B'")); } + common_hal_audioio_rawsample_construct(self, ((uint8_t *)bufinfo.buf), bufinfo.len, + bytes_per_sample, signed_samples, args[ARG_channel_count].u_int, + args[ARG_sample_rate].u_int); return MP_OBJ_FROM_PTR(self); } //| def deinit(self) -> None: -//| """Deinitialises the AudioOut and releases any hardware resources for reuse.""" +//| """Deinitialises the RawSample and releases any hardware resources for reuse.""" //| ... //| STATIC mp_obj_t audioio_rawsample_deinit(mp_obj_t self_in) { diff --git a/shared-bindings/audiocore/RawSample.h b/shared-bindings/audiocore/RawSample.h index b07add2dd1..71056f30c3 100644 --- a/shared-bindings/audiocore/RawSample.h +++ b/shared-bindings/audiocore/RawSample.h @@ -27,7 +27,6 @@ #ifndef MICROPY_INCLUDED_SHARED_BINDINGS_AUDIOIO_RAWSAMPLE_H #define MICROPY_INCLUDED_SHARED_BINDINGS_AUDIOIO_RAWSAMPLE_H -#include "common-hal/microcontroller/Pin.h" #include "shared-module/audiocore/RawSample.h" extern const mp_obj_type_t audioio_rawsample_type; diff --git a/shared-bindings/audiocore/WaveFile.c b/shared-bindings/audiocore/WaveFile.c index 73943f980f..5cf6deb2ed 100644 --- a/shared-bindings/audiocore/WaveFile.c +++ b/shared-bindings/audiocore/WaveFile.c @@ -44,7 +44,7 @@ //| """Load a .wav file for playback with `audioio.AudioOut` or `audiobusio.I2SOut`. //| //| :param typing.BinaryIO file: Already opened wave file -//| :param ~_typing.WriteableBuffer buffer: Optional pre-allocated buffer, that will be split in half and used for double-buffering of the data. If not provided, two 512 byte buffers are allocated internally. +//| :param ~_typing.WriteableBuffer buffer: Optional pre-allocated buffer, that will be split in half and used for double-buffering of the data. If not provided, two 256 byte buffers are allocated internally. //| //| //| Playing a wave file from flash:: diff --git a/shared-bindings/support_matrix.rst b/shared-bindings/support_matrix.rst index a2fb7987d2..2d2172122a 100644 --- a/shared-bindings/support_matrix.rst +++ b/shared-bindings/support_matrix.rst @@ -6,6 +6,11 @@ Module Support Matrix - Which Modules Are Available on Which Boards The following table lists the available built-in modules for each CircuitPython capable board. +.. raw:: html + +

(all)

+ +.. rst-class:: support-matrix-table .. list-table:: :header-rows: 1 :widths: 7, 50 diff --git a/shared-bindings/synthio/MidiTrack.c b/shared-bindings/synthio/MidiTrack.c new file mode 100644 index 0000000000..65fc7a4ee1 --- /dev/null +++ b/shared-bindings/synthio/MidiTrack.c @@ -0,0 +1,169 @@ +/* + * This file is part of the Micro Python project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2021 Artyom Skrobov + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include + +#include "lib/utils/context_manager_helpers.h" +#include "py/binary.h" +#include "py/objproperty.h" +#include "py/runtime.h" +#include "shared-bindings/util.h" +#include "shared-bindings/synthio/MidiTrack.h" +#include "supervisor/shared/translate.h" + +//| class MidiTrack: +//| """Simple square-wave MIDI synth""" +//| +//| def __init__(self, buffer: ReadableBuffer, tempo: int, *, sample_rate: int = 11025) -> None: +//| """Create a MidiTrack from the given stream of MIDI events. Only "Note On" and "Note Off" events +//| are supported; channel numbers and key velocities are ignored. Up to two notes may be on at the +//| same time. +//| +//| :param ~_typing.ReadableBuffer buffer: Stream of MIDI events, as stored in a MIDI file track chunk +//| :param int tempo: Tempo of the streamed events, in MIDI ticks per second +//| :param int sample_rate: The desired playback sample rate; higher sample rate requires more memory +//| +//| Simple melody:: +//| +//| import audioio +//| import board +//| import synthio +//| +//| dac = audioio.AudioOut(board.SPEAKER) +//| melody = synthio.MidiTrack(b"\\0\\x90H\\0*\\x80H\\0\\6\\x90J\\0*\\x80J\\0\\6\\x90L\\0*\\x80L\\0\\6\\x90J\\0" + +//| b"*\\x80J\\0\\6\\x90H\\0*\\x80H\\0\\6\\x90J\\0*\\x80J\\0\\6\\x90L\\0T\\x80L\\0" + +//| b"\\x0c\\x90H\\0T\\x80H\\0\\x0c\\x90H\\0T\\x80H\\0", tempo=640) +//| dac.play(melody) +//| print("playing") +//| while dac.playing: +//| pass +//| print("stopped")""" +//| ... +//| +STATIC mp_obj_t synthio_miditrack_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { + enum { ARG_buffer, ARG_tempo, ARG_sample_rate }; + static const mp_arg_t allowed_args[] = { + { MP_QSTR_buffer, MP_ARG_OBJ | MP_ARG_REQUIRED }, + { MP_QSTR_tempo, MP_ARG_INT | MP_ARG_REQUIRED }, + { MP_QSTR_sample_rate, MP_ARG_INT | MP_ARG_KW_ONLY, {.u_int = 11025} }, + }; + mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; + mp_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); + + mp_buffer_info_t bufinfo; + mp_get_buffer_raise(args[ARG_buffer].u_obj, &bufinfo, MP_BUFFER_READ); + + synthio_miditrack_obj_t *self = m_new_obj(synthio_miditrack_obj_t); + self->base.type = &synthio_miditrack_type; + + common_hal_synthio_miditrack_construct(self, + (uint8_t *)bufinfo.buf, bufinfo.len, + args[ARG_tempo].u_int, + args[ARG_sample_rate].u_int); + + return MP_OBJ_FROM_PTR(self); +} + +//| def deinit(self) -> None: +//| """Deinitialises the MidiTrack and releases any hardware resources for reuse.""" +//| ... +//| +STATIC mp_obj_t synthio_miditrack_deinit(mp_obj_t self_in) { + synthio_miditrack_obj_t *self = MP_OBJ_TO_PTR(self_in); + common_hal_synthio_miditrack_deinit(self); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_1(synthio_miditrack_deinit_obj, synthio_miditrack_deinit); + +STATIC void check_for_deinit(synthio_miditrack_obj_t *self) { + if (common_hal_synthio_miditrack_deinited(self)) { + raise_deinited_error(); + } +} + +//| def __enter__(self) -> MidiTrack: +//| """No-op used by Context Managers.""" +//| ... +//| +// Provided by context manager helper. + +//| def __exit__(self) -> None: +//| """Automatically deinitializes the hardware when exiting a context. See +//| :ref:`lifetime-and-contextmanagers` for more info.""" +//| ... +//| +STATIC mp_obj_t synthio_miditrack_obj___exit__(size_t n_args, const mp_obj_t *args) { + (void)n_args; + common_hal_synthio_miditrack_deinit(args[0]); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(synthio_miditrack___exit___obj, 4, 4, synthio_miditrack_obj___exit__); + +//| sample_rate: Optional[int] +//| """32 bit value that tells how quickly samples are played in Hertz (cycles per second).""" +//| +STATIC mp_obj_t synthio_miditrack_obj_get_sample_rate(mp_obj_t self_in) { + synthio_miditrack_obj_t *self = MP_OBJ_TO_PTR(self_in); + check_for_deinit(self); + return MP_OBJ_NEW_SMALL_INT(common_hal_synthio_miditrack_get_sample_rate(self)); +} +MP_DEFINE_CONST_FUN_OBJ_1(synthio_miditrack_get_sample_rate_obj, synthio_miditrack_obj_get_sample_rate); + +const mp_obj_property_t synthio_miditrack_sample_rate_obj = { + .base.type = &mp_type_property, + .proxy = {(mp_obj_t)&synthio_miditrack_get_sample_rate_obj, + (mp_obj_t)&mp_const_none_obj, + (mp_obj_t)&mp_const_none_obj}, +}; + +STATIC const mp_rom_map_elem_t synthio_miditrack_locals_dict_table[] = { + // Methods + { MP_ROM_QSTR(MP_QSTR_deinit), MP_ROM_PTR(&synthio_miditrack_deinit_obj) }, + { MP_ROM_QSTR(MP_QSTR___enter__), MP_ROM_PTR(&default___enter___obj) }, + { MP_ROM_QSTR(MP_QSTR___exit__), MP_ROM_PTR(&synthio_miditrack___exit___obj) }, + + // Properties + { MP_ROM_QSTR(MP_QSTR_sample_rate), MP_ROM_PTR(&synthio_miditrack_sample_rate_obj) }, +}; +STATIC MP_DEFINE_CONST_DICT(synthio_miditrack_locals_dict, synthio_miditrack_locals_dict_table); + +STATIC const audiosample_p_t synthio_miditrack_proto = { + MP_PROTO_IMPLEMENT(MP_QSTR_protocol_audiosample) + .sample_rate = (audiosample_sample_rate_fun)common_hal_synthio_miditrack_get_sample_rate, + .bits_per_sample = (audiosample_bits_per_sample_fun)common_hal_synthio_miditrack_get_bits_per_sample, + .channel_count = (audiosample_channel_count_fun)common_hal_synthio_miditrack_get_channel_count, + .reset_buffer = (audiosample_reset_buffer_fun)synthio_miditrack_reset_buffer, + .get_buffer = (audiosample_get_buffer_fun)synthio_miditrack_get_buffer, + .get_buffer_structure = (audiosample_get_buffer_structure_fun)synthio_miditrack_get_buffer_structure, +}; + +const mp_obj_type_t synthio_miditrack_type = { + { &mp_type_type }, + .name = MP_QSTR_MidiTrack, + .make_new = synthio_miditrack_make_new, + .locals_dict = (mp_obj_dict_t *)&synthio_miditrack_locals_dict, + .protocol = &synthio_miditrack_proto, +}; diff --git a/shared-bindings/synthio/MidiTrack.h b/shared-bindings/synthio/MidiTrack.h new file mode 100644 index 0000000000..d44d4c3bb7 --- /dev/null +++ b/shared-bindings/synthio/MidiTrack.h @@ -0,0 +1,43 @@ +/* + * This file is part of the Micro Python project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2021 Artyom Skrobov + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#ifndef MICROPY_INCLUDED_SHARED_BINDINGS_SYNTHIO_MIDITRACK_H +#define MICROPY_INCLUDED_SHARED_BINDINGS_SYNTHIO_MIDITRACK_H + +#include "shared-module/synthio/MidiTrack.h" + +extern const mp_obj_type_t synthio_miditrack_type; + +void common_hal_synthio_miditrack_construct(synthio_miditrack_obj_t *self, + const uint8_t *buffer, uint32_t len, uint32_t tempo, uint32_t sample_rate); + +void common_hal_synthio_miditrack_deinit(synthio_miditrack_obj_t *self); +bool common_hal_synthio_miditrack_deinited(synthio_miditrack_obj_t *self); +uint32_t common_hal_synthio_miditrack_get_sample_rate(synthio_miditrack_obj_t *self); +uint8_t common_hal_synthio_miditrack_get_bits_per_sample(synthio_miditrack_obj_t *self); +uint8_t common_hal_synthio_miditrack_get_channel_count(synthio_miditrack_obj_t *self); + +#endif // MICROPY_INCLUDED_SHARED_BINDINGS_SYNTHIO_MIDITRACK_H diff --git a/shared-bindings/synthio/__init__.c b/shared-bindings/synthio/__init__.c new file mode 100644 index 0000000000..d5165001fc --- /dev/null +++ b/shared-bindings/synthio/__init__.c @@ -0,0 +1,136 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2021 Artyom Skrobov + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include + +#include "py/mperrno.h" +#include "py/obj.h" +#include "py/runtime.h" +#include "extmod/vfs_fat.h" + +#include "shared-bindings/synthio/__init__.h" +#include "shared-bindings/synthio/MidiTrack.h" + +//| """Support for MIDI synthesis""" +//| +//| def from_file(file: typing.BinaryIO, *, sample_rate: int = 11025) -> MidiTrack: +//| """Create an AudioSample from an already opened MIDI file. +//| Currently, only single-track MIDI (type 0) is supported. +//| +//| :param typing.BinaryIO file: Already opened MIDI file +//| :param int sample_rate: The desired playback sample rate; higher sample rate requires more memory +//| +//| +//| Playing a MIDI file from flash:: +//| +//| import audioio +//| import board +//| import synthio +//| +//| data = open("single-track.midi", "rb") +//| midi = synthio.from_file(data) +//| a = audioio.AudioOut(board.A0) +//| +//| print("playing") +//| a.play(midi) +//| while a.playing: +//| pass +//| print("stopped")""" +//| ... +//| +STATIC mp_obj_t synthio_from_file(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { + enum { ARG_file, ARG_sample_rate }; + static const mp_arg_t allowed_args[] = { + { MP_QSTR_file, MP_ARG_OBJ | MP_ARG_REQUIRED }, + { MP_QSTR_sample_rate, MP_ARG_INT | MP_ARG_KW_ONLY, {.u_int = 11025} }, + }; + mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; + mp_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); + if (!MP_OBJ_IS_TYPE(args[ARG_file].u_obj, &mp_type_fileio)) { + mp_raise_TypeError(translate("file must be a file opened in byte mode")); + } + pyb_file_obj_t *file = MP_OBJ_TO_PTR(args[ARG_file].u_obj); + + uint8_t chunk_header[14]; + f_rewind(&file->fp); + UINT bytes_read; + if (f_read(&file->fp, chunk_header, sizeof(chunk_header), &bytes_read) != FR_OK) { + mp_raise_OSError(MP_EIO); + } + if (bytes_read != sizeof(chunk_header) || + memcmp(chunk_header, "MThd\0\0\0\6\0\0\0\1", 12)) { + mp_raise_ValueError(translate("Invalid MIDI file")); + // TODO: for a multi-track MIDI (type 1), return an AudioMixer + } + + uint16_t tempo; + if (chunk_header[12] & 0x80) { + tempo = -(int8_t)chunk_header[12] * chunk_header[13]; + } else { + tempo = 2 * ((chunk_header[12] << 8) | chunk_header[13]); + } + + if (f_read(&file->fp, chunk_header, 8, &bytes_read) != FR_OK) { + mp_raise_OSError(MP_EIO); + } + if (bytes_read != 8 || memcmp(chunk_header, "MTrk", 4)) { + mp_raise_ValueError(translate("Invalid MIDI file")); + } + uint32_t track_size = (chunk_header[4] << 24) | + (chunk_header[5] << 16) | (chunk_header[6] << 8) | chunk_header[7]; + uint8_t *buffer = m_malloc(track_size, false); + if (f_read(&file->fp, buffer, track_size, &bytes_read) != FR_OK) { + mp_raise_OSError(MP_EIO); + } + if (bytes_read != track_size) { + mp_raise_ValueError(translate("Invalid MIDI file")); + } + + synthio_miditrack_obj_t *result = m_new_obj(synthio_miditrack_obj_t); + result->base.type = &synthio_miditrack_type; + + common_hal_synthio_miditrack_construct(result, buffer, track_size, + tempo, args[ARG_sample_rate].u_int); + + m_free(buffer); + + return MP_OBJ_FROM_PTR(result); +} +MP_DEFINE_CONST_FUN_OBJ_KW(synthio_from_file_obj, 1, synthio_from_file); + + +STATIC const mp_rom_map_elem_t synthio_module_globals_table[] = { + { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_synthio) }, + { MP_ROM_QSTR(MP_QSTR_MidiTrack), MP_ROM_PTR(&synthio_miditrack_type) }, + { MP_ROM_QSTR(MP_QSTR_from_file), MP_ROM_PTR(&synthio_from_file_obj) }, +}; + +STATIC MP_DEFINE_CONST_DICT(synthio_module_globals, synthio_module_globals_table); + +const mp_obj_module_t synthio_module = { + .base = { &mp_type_module }, + .globals = (mp_obj_dict_t *)&synthio_module_globals, +}; diff --git a/shared-bindings/synthio/__init__.h b/shared-bindings/synthio/__init__.h new file mode 100644 index 0000000000..14af1a5805 --- /dev/null +++ b/shared-bindings/synthio/__init__.h @@ -0,0 +1,34 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2021 Artyom Skrobov + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#ifndef MICROPY_INCLUDED_SHARED_BINDINGS_SYNTHIO___INIT___H +#define MICROPY_INCLUDED_SHARED_BINDINGS_SYNTHIO___INIT___H + +#include "py/obj.h" + +// Nothing now. + +#endif // MICROPY_INCLUDED_SHARED_BINDINGS_SYNTHIO___INIT___H diff --git a/shared-module/audiomixer/Mixer.c b/shared-module/audiomixer/Mixer.c index fdcd2dbfbf..20731933c4 100644 --- a/shared-module/audiomixer/Mixer.c +++ b/shared-module/audiomixer/Mixer.c @@ -103,11 +103,28 @@ void audiomixer_mixer_reset_buffer(audiomixer_mixer_obj_t *self, __attribute__((always_inline)) static inline uint32_t add16signed(uint32_t a, uint32_t b) { + #if (defined(__ARM_ARCH_7EM__) && (__ARM_ARCH_7EM__ == 1)) return __QADD16(a, b); + #else + uint32_t result = 0; + for (int8_t i = 0; i < 2; i++) { + int16_t ai = a >> (sizeof(int16_t) * 8 * i); + int16_t bi = b >> (sizeof(int16_t) * 8 * i); + int32_t intermediate = (int32_t)ai + bi; + if (intermediate > SHRT_MAX) { + intermediate = SHRT_MAX; + } else if (intermediate < SHRT_MIN) { + intermediate = SHRT_MIN; + } + result |= (((uint32_t)intermediate) & 0xffff) << (sizeof(int16_t) * 8 * i); + } + return result; + #endif } __attribute__((always_inline)) static inline uint32_t mult16signed(uint32_t val, int32_t mul) { + #if (defined(__ARM_ARCH_7EM__) && (__ARM_ARCH_7EM__ == 1)) mul <<= 16; int32_t hi, lo; enum { bits = 16 }; // saturate to 16 bits @@ -118,18 +135,46 @@ static inline uint32_t mult16signed(uint32_t val, int32_t mul) { asm volatile ("ssat %0, %1, %2, asr %3" : "=r" (hi) : "I" (bits), "r" (hi), "I" (shift)); asm volatile ("pkhbt %0, %1, %2, lsl #16" : "=r" (val) : "r" (lo), "r" (hi)); // pack return val; + #else + uint32_t result = 0; + float mod_mul = (float)mul / (float)((1 << 15) - 1); + for (int8_t i = 0; i < 2; i++) { + int16_t ai = (val >> (sizeof(uint16_t) * 8 * i)); + int32_t intermediate = ai * mod_mul; + if (intermediate > SHRT_MAX) { + intermediate = SHRT_MAX; + } else if (intermediate < SHRT_MIN) { + intermediate = SHRT_MIN; + } + intermediate &= 0x0000FFFF; + result |= (((uint32_t)intermediate)) << (sizeof(int16_t) * 8 * i); + } + return result; + #endif } static inline uint32_t tounsigned8(uint32_t val) { + #if (defined(__ARM_ARCH_7EM__) && (__ARM_ARCH_7EM__ == 1)) return __UADD8(val, 0x80808080); + #else + return val ^ 0x80808080; + #endif } static inline uint32_t tounsigned16(uint32_t val) { + #if (defined(__ARM_ARCH_7EM__) && (__ARM_ARCH_7EM__ == 1)) return __UADD16(val, 0x80008000); + #else + return val ^ 0x80008000; + #endif } static inline uint32_t tosigned16(uint32_t val) { + #if (defined(__ARM_ARCH_7EM__) && (__ARM_ARCH_7EM__ == 1)) return __UADD16(val, 0x80008000); + #else + return val ^ 0x80008000; + #endif } static inline uint32_t unpack8(uint16_t val) { diff --git a/shared-module/struct/__init__.c b/shared-module/struct/__init__.c index 7a7ea845e7..258036c93b 100644 --- a/shared-module/struct/__init__.c +++ b/shared-module/struct/__init__.c @@ -153,9 +153,11 @@ void shared_modules_struct_pack_into(mp_obj_t fmt_in, byte *p, byte *end_p, size p += sz; } else { while (sz--) { - mp_binary_set_val(fmt_type, *fmt, args[i], &p); // Pad bytes don't have a corresponding argument. - if (*fmt != 'x') { + if (*fmt == 'x') { + mp_binary_set_val(fmt_type, *fmt, MP_OBJ_NEW_SMALL_INT(0), &p); + } else { + mp_binary_set_val(fmt_type, *fmt, args[i], &p); i++; } } diff --git a/shared-module/synthio/MidiTrack.c b/shared-module/synthio/MidiTrack.c new file mode 100644 index 0000000000..0827945ab5 --- /dev/null +++ b/shared-module/synthio/MidiTrack.c @@ -0,0 +1,212 @@ +/* + * This file is part of the Micro Python project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2021 Artyom Skrobov + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include "py/runtime.h" +#include "shared-bindings/synthio/MidiTrack.h" + +#define LOUDNESS 0x4000 // 0.5 +#define BITS_PER_SAMPLE 16 +#define BYTES_PER_SAMPLE (BITS_PER_SAMPLE / 8) +#define SILENCE 0x80 + +STATIC uint8_t parse_note(const uint8_t *buffer, uint32_t len, uint32_t *pos) { + if (*pos + 1 >= len) { + mp_raise_ValueError_varg(translate("Error in MIDI stream at position %d"), *pos); + } + uint8_t note = buffer[(*pos)++]; + if (note > 127 || buffer[(*pos)++] > 127) { + mp_raise_ValueError_varg(translate("Error in MIDI stream at position %d"), *pos); + } + return note; +} + +STATIC void terminate_span(synthio_miditrack_obj_t *self, uint16_t *dur, uint16_t *max_dur) { + if (*dur) { + self->track[self->total_spans - 1].dur = *dur; + if (*dur > *max_dur) { + *max_dur = *dur; + } + *dur = 0; + } else { + self->total_spans--; + } +} + +STATIC void add_span(synthio_miditrack_obj_t *self, uint8_t note1, uint8_t note2) { + synthio_midi_span_t span = { 0, {note1, note2} }; + self->track = m_realloc(self->track, + (self->total_spans + 1) * sizeof(synthio_midi_span_t)); + self->track[self->total_spans++] = span; +} + +void common_hal_synthio_miditrack_construct(synthio_miditrack_obj_t *self, + const uint8_t *buffer, uint32_t len, uint32_t tempo, uint32_t sample_rate) { + + synthio_midi_span_t initial = { 0, {SILENCE, SILENCE} }; + self->sample_rate = sample_rate; + self->track = m_malloc(sizeof(synthio_midi_span_t), false); + self->next_span = 0; + self->total_spans = 1; + *self->track = initial; + + uint16_t dur = 0, max_dur = 0; + uint32_t pos = 0; + while (pos < len) { + uint8_t c; + uint32_t delta = 0; + do { + c = buffer[pos++]; + delta <<= 7; + delta |= c & 0x7f; + } while ((c & 0x80) && (pos < len)); + + if (c & 0x80) { + mp_raise_ValueError_varg(translate("Error in MIDI stream at position %d"), pos); + } + + dur += delta * sample_rate / tempo; + + switch (buffer[pos++] >> 4) { + case 8: { // Note Off + uint8_t note = parse_note(buffer, len, &pos); + + // Ignore if not a note which is playing + synthio_midi_span_t last_span = self->track[self->total_spans - 1]; + if (last_span.note[0] == note || last_span.note[1] == note) { + terminate_span(self, &dur, &max_dur); + if (last_span.note[0] == note) { + add_span(self, last_span.note[1], SILENCE); + } else { + add_span(self, last_span.note[0], SILENCE); + } + } + break; + } + case 9: { // Note On + uint8_t note = parse_note(buffer, len, &pos); + + // Ignore if two notes are already playing + synthio_midi_span_t last_span = self->track[self->total_spans - 1]; + if (last_span.note[1] == SILENCE) { + terminate_span(self, &dur, &max_dur); + if (last_span.note[0] == SILENCE) { + add_span(self, note, SILENCE); + } else { + add_span(self, last_span.note[0], note); + } + } + break; + } + case 10: + case 11: + case 14: // two data bytes to ignore + parse_note(buffer, len, &pos); + break; + case 12: + case 13: // one data byte to ignore + if (pos >= len || buffer[pos++] > 127) { + mp_raise_ValueError_varg(translate("Error in MIDI stream at position %d"), pos); + } + break; + case 15: // the full syntax is too complicated, just assume it's "End of Track" event + pos = len; + break; + default: // invalid event + mp_raise_ValueError_varg(translate("Error in MIDI stream at position %d"), pos); + } + } + terminate_span(self, &dur, &max_dur); + + self->buffer_length = max_dur * BYTES_PER_SAMPLE; + self->buffer = m_malloc(self->buffer_length, false); +} + +void common_hal_synthio_miditrack_deinit(synthio_miditrack_obj_t *self) { + m_free(self->buffer); + self->buffer = NULL; + m_free(self->track); + self->track = NULL; +} +bool common_hal_synthio_miditrack_deinited(synthio_miditrack_obj_t *self) { + return self->buffer == NULL; +} + +uint32_t common_hal_synthio_miditrack_get_sample_rate(synthio_miditrack_obj_t *self) { + return self->sample_rate; +} +uint8_t common_hal_synthio_miditrack_get_bits_per_sample(synthio_miditrack_obj_t *self) { + return BITS_PER_SAMPLE; +} +uint8_t common_hal_synthio_miditrack_get_channel_count(synthio_miditrack_obj_t *self) { + return 1; +} + +void synthio_miditrack_reset_buffer(synthio_miditrack_obj_t *self, + bool single_channel, uint8_t channel) { + + self->next_span = 0; +} + +STATIC const uint16_t notes[] = {8372, 8870, 9397, 9956, 10548, 11175, 11840, + 12544, 13290, 14080, 14917, 15804}; // 9th octave + +audioio_get_buffer_result_t synthio_miditrack_get_buffer(synthio_miditrack_obj_t *self, + bool single_channel, uint8_t channel, uint8_t **buffer, uint32_t *buffer_length) { + + if (self->next_span >= self->total_spans) { + *buffer_length = 0; + return GET_BUFFER_DONE; + } + + synthio_midi_span_t span = self->track[self->next_span++]; + *buffer_length = span.dur * BYTES_PER_SAMPLE; + uint8_t octave1 = span.note[0] / 12; // 0..10 + uint8_t octave2 = span.note[1] / 12; // 0..10 + int32_t base_freq1 = notes[span.note[0] % 12]; + int32_t base_freq2 = notes[span.note[1] % 12]; + int32_t sample_rate = self->sample_rate; + + for (uint16_t i = 0; i < span.dur; i++) { + int16_t semiperiod1 = span.note[0] == SILENCE ? 0 : + ((base_freq1 * i * 2) / sample_rate) >> (10 - octave1); + int16_t semiperiod2 = span.note[1] == SILENCE ? semiperiod1 : + ((base_freq2 * i * 2) / sample_rate) >> (10 - octave2); + self->buffer[i] = ((semiperiod1 % 2 + semiperiod2 % 2) - 1) * LOUDNESS; + } + *buffer = (uint8_t *)self->buffer; + + return self->next_span >= self->total_spans ? + GET_BUFFER_DONE : GET_BUFFER_MORE_DATA; +} + +void synthio_miditrack_get_buffer_structure(synthio_miditrack_obj_t *self, bool single_channel, + bool *single_buffer, bool *samples_signed, uint32_t *max_buffer_length, uint8_t *spacing) { + + *single_buffer = true; + *samples_signed = true; + *max_buffer_length = self->buffer_length; + *spacing = 1; +} diff --git a/shared-module/synthio/MidiTrack.h b/shared-module/synthio/MidiTrack.h new file mode 100644 index 0000000000..bd058daaee --- /dev/null +++ b/shared-module/synthio/MidiTrack.h @@ -0,0 +1,65 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2021 Artyom Skrobov + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#ifndef MICROPY_INCLUDED_SHARED_MODULE_SYNTHIO_MIDITRACK_H +#define MICROPY_INCLUDED_SHARED_MODULE_SYNTHIO_MIDITRACK_H + +#include "py/obj.h" + +#include "shared-module/synthio/__init__.h" + +typedef struct { + uint16_t dur; + uint8_t note[2]; +} synthio_midi_span_t; + +typedef struct { + mp_obj_base_t base; + uint32_t sample_rate; + uint16_t *buffer; + uint16_t buffer_length; + synthio_midi_span_t *track; + uint16_t next_span; + uint16_t total_spans; +} synthio_miditrack_obj_t; + + +// These are not available from Python because it may be called in an interrupt. +void synthio_miditrack_reset_buffer(synthio_miditrack_obj_t *self, + bool single_channel, + uint8_t channel); + +audioio_get_buffer_result_t synthio_miditrack_get_buffer(synthio_miditrack_obj_t *self, + bool single_channel, + uint8_t channel, + uint8_t **buffer, + uint32_t *buffer_length); // length in bytes + +void synthio_miditrack_get_buffer_structure(synthio_miditrack_obj_t *self, bool single_channel, + bool *single_buffer, bool *samples_signed, + uint32_t *max_buffer_length, uint8_t *spacing); + +#endif // MICROPY_INCLUDED_SHARED_MODULE_SYNTHIO_MIDITRACK_H diff --git a/shared-module/synthio/__init__.c b/shared-module/synthio/__init__.c new file mode 100644 index 0000000000..e69de29bb2 diff --git a/shared-module/synthio/__init__.h b/shared-module/synthio/__init__.h new file mode 100644 index 0000000000..d9d98a5341 --- /dev/null +++ b/shared-module/synthio/__init__.h @@ -0,0 +1,32 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2021 Artyom Skrobov + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#ifndef MICROPY_INCLUDED_SHARED_MODULE_SYNTHIO__INIT__H +#define MICROPY_INCLUDED_SHARED_MODULE_SYNTHIO__INIT__H + +#include "shared-module/audiocore/__init__.h" + +#endif // MICROPY_INCLUDED_SHARED_MODULE_SYNTHIO__INIT__H diff --git a/supervisor/shared/cpu.c b/supervisor/shared/cpu.c new file mode 100644 index 0000000000..510225d197 --- /dev/null +++ b/supervisor/shared/cpu.c @@ -0,0 +1,40 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2021 Scott Shawcroft for Adafruit Industries + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include + +#include "supervisor/shared/cpu.h" + +bool cpu_interrupt_active(void) { + #if defined(__ARM_ARCH) && (__ARM_ARCH >= 6) + // Check VECTACTIVE in ICSR. We don't need to disable interrupts because if + // one occurs after we read, we won't continue until it is resolved. + return (*((volatile uint32_t *)0xE000ED04) & 0x1ff) != 0; + #else + // We don't know. + return false; + #endif +} diff --git a/supervisor/shared/cpu.h b/supervisor/shared/cpu.h new file mode 100644 index 0000000000..9e2bed1e55 --- /dev/null +++ b/supervisor/shared/cpu.h @@ -0,0 +1,36 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2021 Scott Shawcroft for Adafruit Industries + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#ifndef MICROPY_INCLUDED_SUPERVISOR_SHARED_CPU_H +#define MICROPY_INCLUDED_SUPERVISOR_SHARED_CPU_H + +#include +#include + +// True when we're in an interrupt handler. +bool cpu_interrupt_active(void); + +#endif // MICROPY_INCLUDED_SUPERVISOR_SHARED_CPU_H diff --git a/supervisor/shared/safe_mode.c b/supervisor/shared/safe_mode.c index f9e787c159..cd73e1b9f9 100644 --- a/supervisor/shared/safe_mode.c +++ b/supervisor/shared/safe_mode.c @@ -170,13 +170,13 @@ void print_safe_mode_message(safe_mode_t reason) { serial_write_compressed(translate("Crash into the HardFault_Handler.")); return; case MICROPY_NLR_JUMP_FAIL: - serial_write_compressed(translate("MicroPython NLR jump failed. Likely memory corruption.")); + serial_write_compressed(translate("NLR jump failed. Likely memory corruption.")); return; case MICROPY_FATAL_ERROR: - serial_write_compressed(translate("MicroPython fatal error.")); + serial_write_compressed(translate("Fatal error.")); break; case GC_ALLOC_OUTSIDE_VM: - serial_write_compressed(translate("Attempted heap allocation when MicroPython VM not running.")); + serial_write_compressed(translate("Attempted heap allocation when VM not running.")); break; #ifdef SOFTDEVICE_PRESENT // defined in ports/nrf/bluetooth/bluetooth_common.mk diff --git a/supervisor/shared/serial.c b/supervisor/shared/serial.c index c73d702c9c..beb2541a15 100644 --- a/supervisor/shared/serial.c +++ b/supervisor/shared/serial.c @@ -28,6 +28,7 @@ #include "py/mpconfig.h" +#include "supervisor/shared/cpu.h" #include "supervisor/shared/display.h" #include "shared-bindings/terminalio/Terminal.h" #include "supervisor/serial.h" @@ -77,9 +78,9 @@ void serial_early_init(void) { void serial_init(void) { usb_init(); -#ifdef NRF_DEBUG_PRINT + #ifdef NRF_DEBUG_PRINT _debug_uart_init(); -#endif + #endif } bool serial_connected(void) { @@ -149,13 +150,17 @@ void serial_write_substring(const char *text, uint32_t length) { uint32_t count = 0; while (count < length && tud_cdc_connected()) { count += tud_cdc_write(text + count, length - count); + // If we're in an interrupt, then don't wait for more room. Queue up what we can. + if (cpu_interrupt_active()) { + break; + } usb_background(); } #if defined(DEBUG_UART_TX) && defined(DEBUG_UART_RX) int uart_errcode; - common_hal_busio_uart_write(&debug_uart, (const uint8_t *) text, length, &uart_errcode); + common_hal_busio_uart_write(&debug_uart, (const uint8_t *)text, length, &uart_errcode); #endif #ifdef NRF_DEBUG_PRINT diff --git a/supervisor/shared/translate.c b/supervisor/shared/translate.c index c99cbf180d..7afbd43e21 100644 --- a/supervisor/shared/translate.c +++ b/supervisor/shared/translate.c @@ -129,7 +129,7 @@ __attribute__((always_inline)) #endif const compressed_string_t *translate(const char *original) { #ifndef NO_QSTR - #define QDEF(id, str) + #define QDEF(id, hash, len, str) #define TRANSLATION(id, firstbyte, ...) if (strcmp(original, id) == 0) { static const compressed_string_t v = { .data = firstbyte, .tail = { __VA_ARGS__ } }; return &v; } else #include "genhdr/qstrdefs.generated.h" #undef TRANSLATION diff --git a/supervisor/supervisor.mk b/supervisor/supervisor.mk index 1744c4f47f..c206ff96be 100644 --- a/supervisor/supervisor.mk +++ b/supervisor/supervisor.mk @@ -4,6 +4,7 @@ SRC_SUPERVISOR = \ supervisor/shared/autoreload.c \ supervisor/shared/background_callback.c \ supervisor/shared/board.c \ + supervisor/shared/cpu.c \ supervisor/shared/filesystem.c \ supervisor/shared/flash.c \ supervisor/shared/micropython.c \ diff --git a/tests/basics/struct1.py b/tests/basics/struct1.py index 107006cc3f..ec29ea9080 100644 --- a/tests/basics/struct1.py +++ b/tests/basics/struct1.py @@ -121,3 +121,5 @@ except: # check padding bytes print(struct.pack("xb", 3)) +# Make sure pack doesn't reuse a larger value and error +print(struct.pack("xH", 0x100)) diff --git a/tests/circuitpython-manual/audiocore/single-track.midi b/tests/circuitpython-manual/audiocore/single-track.midi new file mode 100755 index 0000000000000000000000000000000000000000..3b3dcea8221ff6e7592c835a25e6ea2789e04324 GIT binary patch literal 5123 zcmZ{oeM=)*7RGBs2q8$2UTH)mh=_zBStn$Ioy6i=9m=inm7xmCuwL*W)_Xqm?Vp?j?>7TXW`@!`JD47&S^C}TeQ+M zGs;e{8aO7|+0{qR>1Jl8Ej&kAf6_?%D9qvu=d_gd@aV~7u?p1&a)7}x2IpBs=!noE zAwzd=a~@>l#br7+N7--^r9;!nqR9jDE$kxfIFour>ci=u4QJ3>oDj&6S{{giAqHl0 zK%g4{8aO0bxY$8{PfY?$H>jaW4KdBwqoxnp*>88MX)80Nq!eFjnm(zffcE8~CMS51 z`>+pWpHOWK283z>Jwoo=8cjmZU20lVQ;nSSnrND{yUOjRyPWT`cUM6+{Pg@lU7P7U z^EK<(^R#1*vlDxqo{&-3w$d&EdbUo@v+UIRn!EN8`JD6bB=$24txv3L50Kw*wj^rN z`^3Apfjr@ymT`C_P(+{(ff@u#2-L(NCQyEh0G?9mn&TS;_iK^rILtVwRYH9N`uPzH z3v?Iga1GkW?vY!M+)fFpk?Pt#5SUGy{$J>~KrgZA;t}HEW8$%m-~*vf2xSP>q>31W zRl6F5Qn_vH2J4Pn2=2(*U&N}s&^{4~8~?=ycs^=lQvHh6FIA7WVpriDXZYO{yW*=Q0-Hfw(@&~dlZ0@ru`YHMe z*E`{Qr%s<9p{%0l0Coq^Zgx)Z>EyH`vBtA4O*^6ORx(gC+V>o=pq85s{Zft-WNq z%Ium9uF2raeoL=R1-k?6Zm@$w?H4c#RJ?(_jeLL|Eg7PW8HX!#k3q$?B(hp@Z?gey z7`Pq=*$9AKkr>}UIv95showk0at#7g! zp=WMjf^1HQ=I9fUuX%je6u+Pua|UZ+>gW>A0lu<@NXA_h-}qf2#V#p^dDtfbk=`acrFfJBZsJ=* z7n7P#aUtSf07jiCT5BopbDlXvrAdl=q_~CQCJG_aH4pOuf(k66)JG9F+2bZxoFuLZ zxk=AS+YrG3!f3zT_==NsIUSp78VeZD;Gl0%PX(Y6oYZop1^H^zmQWmnWI+nxqysqV z#u>0!Dj4jd&}RQeDnjs|1U?nfqd2JsK-1Yp%u2+Kh5&^CDU}|VHRe`(Zb(D-K86Gw z5-{RZBw{&<vq8hFu-K=x~)m3;D>spE30&WScO8%J`c8j7`Fb)sf#J-^DIM z*Krw(sK&e^Dn_<}zJO1Jy~r_*Q9Qrp*GGPAlgR^_Y=Q6@>o;UlBa@{=8r!dUZ=h?U zi;=-dVrp@Mn0f5_Q4%o&(npqVxaN#`c*^^=A5HoZb52Ei6+)QYyNPE^h;M|bU~qu0 zip|IYyf$P9{XHrC%nKS(&<1vgIr#=K@f|j0NO%i73uXb^pZpeMZ=&1f9AhW47MuUM zfpHOK0cG-1&e({N%NSV_Dx-TtQo23e#Oj9n$orgKPu`G;)@hK>NP#vy0#a2^_BqJF z&x4wF4vk-$&-7$NJ$Z{#ZSUtPc((Q7D}>oW*TQC>aK7s?0Eto0ipXrvJ1u%rbeZ^t zq@MU4tR7q$^-i^0d^RY%CjbBK39k*s77oUN&zQa$j-H3B1lz%>LNKwWUj<6S^YLTO zN@dC~tm(P=g^N}~VcZR(u7iW06RvpvNSnp;a6F29o^NuPQm{ww7xd zJ!@1{yZZ0|f`73yp3{uyGU(s-wF~INfsJU*O3uJu(7X5WSOTfP4&?LFMSxR@qD{Bj2L221 zl>`rY@N-w1c9-8to*mBNZk{LNf*3!ZQMYZm8Rxi91r)KSJy9IWBgXI&Y-5tVLn_FvQD zVL12z<4u&B`6B|Z_L7J$B8e(x)mSJr=G)69$A0R$ngj+m!UEX+|HMi zWc0a(KIU`$-%_0df$a9AYM1b}^e(=S%pU&>=Rn$ z^=-#rWB%at`>~em^>>%{s#d)cR;7x!!WVySBkSh=O@0Sp#MnOTkna8aZ^3^606o9) literal 0 HcmV?d00001 diff --git a/tools/build_board_info.py b/tools/build_board_info.py index 94f6e50af1..66ca48a02d 100644 --- a/tools/build_board_info.py +++ b/tools/build_board_info.py @@ -266,7 +266,7 @@ def generate_download_info(): # Delete the release we are replacing for board in current_info: info = current_info[board] - for version in info["versions"]: + for version in list(info["versions"]): previous_releases.add(version["version"]) previous_languages.update(version["languages"]) if version["stable"] == new_stable or ( diff --git a/tools/mpy-tool.py b/tools/mpy-tool.py index c989b63007..42d62fdf11 100755 --- a/tools/mpy-tool.py +++ b/tools/mpy-tool.py @@ -607,6 +607,20 @@ def freeze_mpy(base_qstrs, raw_codes): print(" MP_QSTR_%s," % new[i][1]) print("};") + print() + print("const qstr_attr_t mp_qstr_frozen_const_attr[] = {") + qstr_size = {"metadata": 0, "data": 0} + for _, _, qstr in new: + qbytes = qstrutil.bytes_cons(qstr, "utf8") + print(" {%d, %d}," % ( + qstrutil.compute_hash(qbytes, config.MICROPY_QSTR_BYTES_IN_HASH), + len(qbytes) + )) + qstr_size["metadata"] += ( + config.MICROPY_QSTR_BYTES_IN_LEN + config.MICROPY_QSTR_BYTES_IN_HASH + ) + qstr_size["data"] += len(qbytes) + print("};") print() print("extern const qstr_pool_t mp_qstr_const_pool;") print("const qstr_pool_t mp_qstr_frozen_const_pool = {") @@ -614,19 +628,10 @@ def freeze_mpy(base_qstrs, raw_codes): print(" MP_QSTRnumber_of, // previous pool size") print(" %u, // allocated entries" % len(new)) print(" %u, // used entries" % len(new)) + print(" (qstr_attr_t *)mp_qstr_frozen_const_attr,") print(" {") - qstr_size = {"metadata": 0, "data": 0} for _, _, qstr in new: - qstr_size["metadata"] += ( - config.MICROPY_QSTR_BYTES_IN_LEN + config.MICROPY_QSTR_BYTES_IN_HASH - ) - qstr_size["data"] += len(qstr) - print( - " %s," - % qstrutil.make_bytes( - config.MICROPY_QSTR_BYTES_IN_LEN, config.MICROPY_QSTR_BYTES_IN_HASH, qstr - ) - ) + print(" \"%s\"," % qstrutil.escape_bytes(qstr)) print(" },") print("};") From 7daba64cb11fba0ab978cd84f4d58034906ccd93 Mon Sep 17 00:00:00 2001 From: jun2sak Date: Sun, 25 Apr 2021 20:12:20 +0900 Subject: [PATCH 53/67] merge. --- lib/protomatter | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/protomatter b/lib/protomatter index 98017c5734..c2c81ded11 160000 --- a/lib/protomatter +++ b/lib/protomatter @@ -1 +1 @@ -Subproject commit 98017c57349e259fab70c6a7830436b19a55f6f4 +Subproject commit c2c81ded118484f8925bf81e270b416739cd72d9 From 872fff7fbbb8ca1297f7c5ec7760fa6536e9c233 Mon Sep 17 00:00:00 2001 From: jun2sak Date: Sun, 25 Apr 2021 23:59:21 +0900 Subject: [PATCH 54/67] simplify system_on_idle_until_alarm() --- ports/nrf/common-hal/alarm/__init__.c | 121 ++++++++------------------ 1 file changed, 37 insertions(+), 84 deletions(-) diff --git a/ports/nrf/common-hal/alarm/__init__.c b/ports/nrf/common-hal/alarm/__init__.c index 4c00cc4216..fb2938aebb 100644 --- a/ports/nrf/common-hal/alarm/__init__.c +++ b/ports/nrf/common-hal/alarm/__init__.c @@ -118,18 +118,6 @@ bool common_hal_alarm_woken_from_sleep(void) { || cause == NRF_SLEEP_WAKEUP_TOUCHPAD); } -nrf_sleep_source_t alarm_woken_from_sleep_2(void) { - nrf_sleep_source_t cause = _get_wakeup_cause(); - if (cause == NRF_SLEEP_WAKEUP_GPIO || - cause == NRF_SLEEP_WAKEUP_TIMER || - cause == NRF_SLEEP_WAKEUP_TOUCHPAD) { - return cause; - } - else { - return NRF_SLEEP_WAKEUP_UNDEFINED; - } -} - STATIC mp_obj_t _get_wake_alarm(size_t n_alarms, const mp_obj_t *alarms) { nrf_sleep_source_t cause = _get_wakeup_cause(); switch (cause) { @@ -163,7 +151,7 @@ STATIC void _setup_sleep_alarms(bool deep_sleep, size_t n_alarms, const mp_obj_t // TODO: this handles all possible types of wakeup, which is redundant with main. // revise to extract all parts essential to enabling sleep wakeup, but leave the // alarm/non-alarm sorting to the existing main loop. -nrf_sleep_source_t system_on_idle_until_alarm(int64_t timediff_ms, uint32_t prescaler) { +void system_on_idle_until_alarm(int64_t timediff_ms, uint32_t prescaler) { bool have_timeout = false; uint64_t start_tick = 0, end_tick = 0; int64_t tickdiff; @@ -197,7 +185,6 @@ nrf_sleep_source_t system_on_idle_until_alarm(int64_t timediff_ms, uint32_t pres #endif int64_t remaining; - nrf_sleep_source_t wakeup_cause = NRF_SLEEP_WAKEUP_UNDEFINED; sleepmem_wakeup_event = SLEEPMEM_WAKEUP_BY_NONE; sleepmem_wakeup_pin = WAKEUP_PIN_UNDEF; @@ -210,30 +197,29 @@ nrf_sleep_source_t system_on_idle_until_alarm(int64_t timediff_ms, uint32_t pres #endif while(1) { - if (mp_hal_is_interrupted()) { - WAKEUP_REASON('I'); - break; - } - if (serial_connected() && serial_bytes_available()) { - WAKEUP_REASON('S'); - break; - } - RUN_BACKGROUND_TASKS; - wakeup_cause = alarm_woken_from_sleep_2(); - if (wakeup_cause != NRF_SLEEP_WAKEUP_UNDEFINED) { - WAKEUP_REASON('0'+wakeup_cause); - break; - } - if (have_timeout) { - remaining = end_tick - port_get_raw_ticks(NULL); - // We break a bit early so we don't risk setting the alarm before the time when we call - // sleep. - if (remaining < 1) { - WAKEUP_REASON('t'); + if (mp_hal_is_interrupted()) { + WAKEUP_REASON('I'); break; } - port_interrupt_after_ticks(remaining); - } + if (serial_connected() && serial_bytes_available()) { + WAKEUP_REASON('S'); + break; + } + RUN_BACKGROUND_TASKS; + if (common_hal_alarm_woken_from_sleep()) { + WAKEUP_REASON('W'); + break; + } + if (have_timeout) { + remaining = end_tick - port_get_raw_ticks(NULL); + // We break a bit early so we don't risk setting the alarm before the time when we call + // sleep. + if (remaining < 1) { + WAKEUP_REASON('t'); + break; + } + port_interrupt_after_ticks(remaining); + } // Idle until an interrupt happens. port_idle_until_interrupt(); #ifdef NRF_DEBUG_PRINT @@ -242,16 +228,15 @@ nrf_sleep_source_t system_on_idle_until_alarm(int64_t timediff_ms, uint32_t pres --ct; } #endif - if (have_timeout) { - remaining = end_tick - port_get_raw_ticks(NULL); - if (remaining <= 0) { - wakeup_cause = NRF_SLEEP_WAKEUP_TIMER; - sleepmem_wakeup_event = SLEEPMEM_WAKEUP_BY_TIMER; - WAKEUP_REASON('T'); - break; + if (have_timeout) { + remaining = end_tick - port_get_raw_ticks(NULL); + if (remaining <= 0) { + sleepmem_wakeup_event = SLEEPMEM_WAKEUP_BY_TIMER; + WAKEUP_REASON('T'); + break; + } } } - } #ifdef NRF_DEBUG_PRINT dbg_printf("%c\r\n", reason); #endif @@ -271,12 +256,10 @@ nrf_sleep_source_t system_on_idle_until_alarm(int64_t timediff_ms, uint32_t pres } dbg_printf("lapse %6.1f sec\r\n", sec); #endif - - return wakeup_cause; } mp_obj_t common_hal_alarm_light_sleep_until_alarms(size_t n_alarms, const mp_obj_t *alarms) { - mp_obj_t r_obj = mp_const_none; + mp_obj_t wake_alarm; alarm_time_timealarm_clear_wakeup_time(); _setup_sleep_alarms(false, n_alarms, alarms); @@ -285,25 +268,16 @@ mp_obj_t common_hal_alarm_light_sleep_until_alarms(size_t n_alarms, const mp_obj #endif int64_t timediff_ms = alarm_time_timealarm_get_wakeup_timediff_ms(); - nrf_sleep_source_t cause = system_on_idle_until_alarm(timediff_ms, 0); - (void)cause; - -#ifdef NRF_DEBUG_PRINT - //dbg_printf("wakeup! "); - print_wakeup_cause(cause); -#endif + system_on_idle_until_alarm(timediff_ms, 0); if (mp_hal_is_interrupted()) { -#ifdef NRF_DEBUG_PRINT - dbg_printf("mp_hal_is_interrupted\r\n"); -#endif - r_obj = mp_const_none; + wake_alarm = mp_const_none; } else { - r_obj = _get_wake_alarm(n_alarms, alarms); + wake_alarm = _get_wake_alarm(n_alarms, alarms); } alarm_reset(); - return r_obj; + return wake_alarm; } void common_hal_alarm_set_deep_sleep_alarms(size_t n_alarms, const mp_obj_t *alarms) { @@ -325,14 +299,9 @@ void NORETURN common_hal_alarm_enter_deep_sleep(void) { #ifdef NRF_DEBUG_PRINT dbg_check_RTCprescaler(); //XXX #endif - nrf_sleep_source_t cause; - cause = system_on_idle_until_alarm(timediff_ms, - PRESCALER_VALUE_IN_DEEP_SLEEP); - (void)cause; + system_on_idle_until_alarm(timediff_ms, PRESCALER_VALUE_IN_DEEP_SLEEP); #ifdef NRF_DEBUG_PRINT - dbg_printf("wakeup! "); - print_wakeup_cause(cause); dbg_printf("RESET...\r\n\r\n"); #endif @@ -370,25 +339,9 @@ void common_hal_alarm_pretending_deep_sleep(void) { #endif int64_t timediff_ms = alarm_time_timealarm_get_wakeup_timediff_ms(); - nrf_sleep_source_t cause = system_on_idle_until_alarm(timediff_ms, 0); - (void)cause; + system_on_idle_until_alarm(timediff_ms, 0); -#ifdef NRF_DEBUG_PRINT - dbg_printf("wakeup! "); - print_wakeup_cause(cause); -#endif - - // alarm_reset(); - -#if 0 - // if one of Alarm event occurred, reset myself - if (cause == NRF_SLEEP_WAKEUP_GPIO || - cause == NRF_SLEEP_WAKEUP_TIMER || - cause == NRF_SLEEP_WAKEUP_TOUCHPAD) { - reset_cpu(); - } - // else, just return and go into REPL -#endif + alarm_reset(); } void common_hal_alarm_gc_collect(void) { From 43840363c2ac1709ff0ed456f042a7b31c82db41 Mon Sep 17 00:00:00 2001 From: Lucian Copeland Date: Mon, 26 Apr 2021 17:59:21 -0400 Subject: [PATCH 55/67] Fix submodule --- lib/protomatter | 2 +- ports/nrf/common-hal/alarm/__init__.c | 20 ++++++++++---------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/lib/protomatter b/lib/protomatter index c2c81ded11..98017c5734 160000 --- a/lib/protomatter +++ b/lib/protomatter @@ -1 +1 @@ -Subproject commit c2c81ded118484f8925bf81e270b416739cd72d9 +Subproject commit 98017c57349e259fab70c6a7830436b19a55f6f4 diff --git a/ports/nrf/common-hal/alarm/__init__.c b/ports/nrf/common-hal/alarm/__init__.c index fb2938aebb..3ce963f0d6 100644 --- a/ports/nrf/common-hal/alarm/__init__.c +++ b/ports/nrf/common-hal/alarm/__init__.c @@ -121,16 +121,16 @@ bool common_hal_alarm_woken_from_sleep(void) { STATIC mp_obj_t _get_wake_alarm(size_t n_alarms, const mp_obj_t *alarms) { nrf_sleep_source_t cause = _get_wakeup_cause(); switch (cause) { - case NRF_SLEEP_WAKEUP_TIMER: { - return alarm_time_timealarm_get_wakeup_alarm(n_alarms, alarms); - } - case NRF_SLEEP_WAKEUP_TOUCHPAD: { - return alarm_touch_touchalarm_get_wakeup_alarm(n_alarms, alarms); - } - case NRF_SLEEP_WAKEUP_GPIO: { - return alarm_pin_pinalarm_get_wakeup_alarm(n_alarms, alarms); - } - default: + case NRF_SLEEP_WAKEUP_TIMER: { + return alarm_time_timealarm_get_wakeup_alarm(n_alarms, alarms); + } + case NRF_SLEEP_WAKEUP_TOUCHPAD: { + return alarm_touch_touchalarm_get_wakeup_alarm(n_alarms, alarms); + } + case NRF_SLEEP_WAKEUP_GPIO: { + return alarm_pin_pinalarm_get_wakeup_alarm(n_alarms, alarms); + } + default: break; } return mp_const_none; From cbb2ff4ce7aca17aad8c95adb26e2132026e1298 Mon Sep 17 00:00:00 2001 From: Hosted Weblate Date: Tue, 27 Apr 2021 20:02:10 +0200 Subject: [PATCH 56/67] 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 | 32 ++++++++++----------------- locale/de_DE.po | 47 +++++++++++++++++++++++----------------- locale/el.po | 32 ++++++++++----------------- locale/en_GB.po | 47 +++++++++++++++++++++++----------------- locale/es.po | 47 +++++++++++++++++++++++----------------- locale/fil.po | 41 ++++++++++++++++++----------------- locale/fr.po | 47 +++++++++++++++++++++++----------------- locale/hi.po | 32 ++++++++++----------------- locale/it_IT.po | 41 ++++++++++++++++++----------------- locale/ja.po | 44 ++++++++++++++++++++----------------- locale/ko.po | 38 +++++++++++++++----------------- locale/nl.po | 47 +++++++++++++++++++++++----------------- locale/pl.po | 44 ++++++++++++++++++++----------------- locale/pt_BR.po | 47 +++++++++++++++++++++++----------------- locale/sv.po | 47 +++++++++++++++++++++++----------------- locale/zh_Latn_pinyin.po | 47 +++++++++++++++++++++++----------------- 17 files changed, 384 insertions(+), 340 deletions(-) diff --git a/locale/ID.po b/locale/ID.po index 97d3e15d18..9507fb0b22 100644 --- a/locale/ID.po +++ b/locale/ID.po @@ -753,14 +753,6 @@ msgid "" msgstr "" "Koneksi telah terputus dan tidak dapat lagi digunakan. Buat koneksi baru." -#: py/persistentcode.c -msgid "Corrupt .mpy file" -msgstr "File .mpy rusak" - -#: py/emitglue.c -msgid "Corrupt raw code" -msgstr "Kode raw rusak" - #: ports/cxd56/common-hal/camera/Camera.c msgid "Could not initialize Camera" msgstr "" @@ -2623,10 +2615,6 @@ msgstr "hanya mampu memiliki hingga 4 parameter untuk Thumb assembly" msgid "can only have up to 4 parameters to Xtensa assembly" msgstr "" -#: py/persistentcode.c -msgid "can only save bytecode" -msgstr "" - #: py/objtype.c msgid "can't add special method to already-subclassed class" msgstr "" @@ -3139,6 +3127,14 @@ msgstr "identifier didefinisi ulang sebagai global" msgid "identifier redefined as nonlocal" msgstr "identifier didefinisi ulang sebagai nonlocal" +#: py/persistentcode.c +msgid "incompatible .mpy file" +msgstr "" + +#: py/persistentcode.c +msgid "incompatible native .mpy architecture" +msgstr "" + #: py/objstr.c msgid "incomplete format" msgstr "" @@ -3258,6 +3254,10 @@ msgstr "" msgid "interval must be in range %s-%s" msgstr "" +#: py/compile.c +msgid "invalid architecture" +msgstr "" + #: lib/netutils/netutils.c msgid "invalid arguments" msgstr "argumen-argumen tidak valid" @@ -3267,10 +3267,6 @@ msgstr "argumen-argumen tidak valid" msgid "invalid bits_per_pixel %d, must be, 1, 4, 8, 16, 24, or 32" msgstr "" -#: extmod/modussl_axtls.c -msgid "invalid cert" -msgstr "cert tidak valid" - #: py/compile.c msgid "invalid decorator" msgstr "" @@ -3301,10 +3297,6 @@ msgstr "" msgid "invalid hostname" msgstr "" -#: extmod/modussl_axtls.c -msgid "invalid key" -msgstr "key tidak valid" - #: py/compile.c msgid "invalid micropython decorator" msgstr "micropython decorator tidak valid" @@ -4314,6 +4306,18 @@ msgstr "zi harus berjenis float" msgid "zi must be of shape (n_section, 2)" msgstr "" +#~ msgid "Corrupt .mpy file" +#~ msgstr "File .mpy rusak" + +#~ msgid "Corrupt raw code" +#~ msgstr "Kode raw rusak" + +#~ msgid "invalid cert" +#~ msgstr "cert tidak valid" + +#~ msgid "invalid key" +#~ msgstr "key tidak valid" + #~ msgid "Viper functions don't currently support more than 4 arguments" #~ msgstr "Fungsi Viper saat ini tidak mendukung lebih dari 4 argumen" diff --git a/locale/cs.po b/locale/cs.po index 79f18261a4..dab2eb901a 100644 --- a/locale/cs.po +++ b/locale/cs.po @@ -736,14 +736,6 @@ msgid "" "connection." msgstr "" -#: py/persistentcode.c -msgid "Corrupt .mpy file" -msgstr "" - -#: py/emitglue.c -msgid "Corrupt raw code" -msgstr "" - #: ports/cxd56/common-hal/camera/Camera.c msgid "Could not initialize Camera" msgstr "" @@ -2577,10 +2569,6 @@ msgstr "" msgid "can only have up to 4 parameters to Xtensa assembly" msgstr "" -#: py/persistentcode.c -msgid "can only save bytecode" -msgstr "" - #: py/objtype.c msgid "can't add special method to already-subclassed class" msgstr "" @@ -3093,6 +3081,14 @@ msgstr "" msgid "identifier redefined as nonlocal" msgstr "" +#: py/persistentcode.c +msgid "incompatible .mpy file" +msgstr "" + +#: py/persistentcode.c +msgid "incompatible native .mpy architecture" +msgstr "" + #: py/objstr.c msgid "incomplete format" msgstr "" @@ -3212,6 +3208,10 @@ msgstr "" msgid "interval must be in range %s-%s" msgstr "" +#: py/compile.c +msgid "invalid architecture" +msgstr "" + #: lib/netutils/netutils.c msgid "invalid arguments" msgstr "" @@ -3221,10 +3221,6 @@ msgstr "" msgid "invalid bits_per_pixel %d, must be, 1, 4, 8, 16, 24, or 32" msgstr "" -#: extmod/modussl_axtls.c -msgid "invalid cert" -msgstr "" - #: py/compile.c msgid "invalid decorator" msgstr "" @@ -3255,10 +3251,6 @@ msgstr "" msgid "invalid hostname" msgstr "" -#: extmod/modussl_axtls.c -msgid "invalid key" -msgstr "" - #: py/compile.c msgid "invalid micropython decorator" msgstr "" diff --git a/locale/de_DE.po b/locale/de_DE.po index 419e42b498..d8d3727bb6 100644 --- a/locale/de_DE.po +++ b/locale/de_DE.po @@ -751,14 +751,6 @@ msgstr "" "Die Verbindung wurde getrennt und kann nicht mehr verwendet werden. " "Erstellen Sie eine neue Verbindung." -#: py/persistentcode.c -msgid "Corrupt .mpy file" -msgstr "Beschädigte .mpy Datei" - -#: py/emitglue.c -msgid "Corrupt raw code" -msgstr "Beschädigter raw code" - #: ports/cxd56/common-hal/camera/Camera.c msgid "Could not initialize Camera" msgstr "Konnte Kamera nicht initialisieren" @@ -2636,10 +2628,6 @@ msgstr "kann nur bis zu 4 Parameter für die Thumb assembly haben" msgid "can only have up to 4 parameters to Xtensa assembly" msgstr "kann nur bis zu 4 Parameter für die Xtensa assembly haben" -#: py/persistentcode.c -msgid "can only save bytecode" -msgstr "kann nur Bytecode speichern" - #: py/objtype.c msgid "can't add special method to already-subclassed class" msgstr "" @@ -3166,6 +3154,14 @@ msgstr "Bezeichner als global neu definiert" msgid "identifier redefined as nonlocal" msgstr "Bezeichner als nonlocal definiert" +#: py/persistentcode.c +msgid "incompatible .mpy file" +msgstr "" + +#: py/persistentcode.c +msgid "incompatible native .mpy architecture" +msgstr "" + #: py/objstr.c msgid "incomplete format" msgstr "unvollständiges Format" @@ -3285,6 +3281,10 @@ msgstr "" msgid "interval must be in range %s-%s" msgstr "Das Intervall muss im Bereich %s-%s sein" +#: py/compile.c +msgid "invalid architecture" +msgstr "" + #: lib/netutils/netutils.c msgid "invalid arguments" msgstr "ungültige argumente" @@ -3294,10 +3294,6 @@ msgstr "ungültige argumente" msgid "invalid bits_per_pixel %d, must be, 1, 4, 8, 16, 24, or 32" msgstr "" -#: extmod/modussl_axtls.c -msgid "invalid cert" -msgstr "ungültiges cert" - #: py/compile.c msgid "invalid decorator" msgstr "" @@ -3328,10 +3324,6 @@ msgstr "ungültiger Formatbezeichner" msgid "invalid hostname" msgstr "" -#: extmod/modussl_axtls.c -msgid "invalid key" -msgstr "ungültiger Schlüssel" - #: py/compile.c msgid "invalid micropython decorator" msgstr "ungültiger micropython decorator" @@ -4357,6 +4349,21 @@ msgstr "" msgid "zi must be of shape (n_section, 2)" msgstr "" +#~ msgid "Corrupt .mpy file" +#~ msgstr "Beschädigte .mpy Datei" + +#~ msgid "Corrupt raw code" +#~ msgstr "Beschädigter raw code" + +#~ msgid "can only save bytecode" +#~ msgstr "kann nur Bytecode speichern" + +#~ msgid "invalid cert" +#~ msgstr "ungültiges cert" + +#~ msgid "invalid key" +#~ msgstr "ungültiger Schlüssel" + #~ msgid "Viper functions don't currently support more than 4 arguments" #~ msgstr "Viper-Funktionen unterstützen derzeit nicht mehr als 4 Argumente" diff --git a/locale/el.po b/locale/el.po index 9f3027016c..c2a73c577a 100644 --- a/locale/el.po +++ b/locale/el.po @@ -733,14 +733,6 @@ msgid "" "connection." msgstr "" -#: py/persistentcode.c -msgid "Corrupt .mpy file" -msgstr "" - -#: py/emitglue.c -msgid "Corrupt raw code" -msgstr "" - #: ports/cxd56/common-hal/camera/Camera.c msgid "Could not initialize Camera" msgstr "" @@ -2574,10 +2566,6 @@ msgstr "" msgid "can only have up to 4 parameters to Xtensa assembly" msgstr "" -#: py/persistentcode.c -msgid "can only save bytecode" -msgstr "" - #: py/objtype.c msgid "can't add special method to already-subclassed class" msgstr "" @@ -3090,6 +3078,14 @@ msgstr "" msgid "identifier redefined as nonlocal" msgstr "" +#: py/persistentcode.c +msgid "incompatible .mpy file" +msgstr "" + +#: py/persistentcode.c +msgid "incompatible native .mpy architecture" +msgstr "" + #: py/objstr.c msgid "incomplete format" msgstr "" @@ -3209,6 +3205,10 @@ msgstr "" msgid "interval must be in range %s-%s" msgstr "" +#: py/compile.c +msgid "invalid architecture" +msgstr "" + #: lib/netutils/netutils.c msgid "invalid arguments" msgstr "" @@ -3218,10 +3218,6 @@ msgstr "" msgid "invalid bits_per_pixel %d, must be, 1, 4, 8, 16, 24, or 32" msgstr "" -#: extmod/modussl_axtls.c -msgid "invalid cert" -msgstr "" - #: py/compile.c msgid "invalid decorator" msgstr "" @@ -3252,10 +3248,6 @@ msgstr "" msgid "invalid hostname" msgstr "" -#: extmod/modussl_axtls.c -msgid "invalid key" -msgstr "" - #: py/compile.c msgid "invalid micropython decorator" msgstr "" diff --git a/locale/en_GB.po b/locale/en_GB.po index ef1677f66d..2f1b10a1f3 100644 --- a/locale/en_GB.po +++ b/locale/en_GB.po @@ -748,14 +748,6 @@ msgstr "" "Connection has been disconnected and can no longer be used. Create a new " "connection." -#: py/persistentcode.c -msgid "Corrupt .mpy file" -msgstr "Corrupt .mpy file" - -#: py/emitglue.c -msgid "Corrupt raw code" -msgstr "Corrupt raw code" - #: ports/cxd56/common-hal/camera/Camera.c msgid "Could not initialize Camera" msgstr "Could not initialise camera" @@ -2618,10 +2610,6 @@ msgstr "Can only have up to 4 parameters to thumb assembly" msgid "can only have up to 4 parameters to Xtensa assembly" msgstr "Can only have up to 4 parameters to xtensa assembly" -#: py/persistentcode.c -msgid "can only save bytecode" -msgstr "Can only save bytecode" - #: py/objtype.c msgid "can't add special method to already-subclassed class" msgstr "Can't add special method to already-subclassed class" @@ -3137,6 +3125,14 @@ msgstr "identifier redefined as global" msgid "identifier redefined as nonlocal" msgstr "identifier redefined as nonlocal" +#: py/persistentcode.c +msgid "incompatible .mpy file" +msgstr "" + +#: py/persistentcode.c +msgid "incompatible native .mpy architecture" +msgstr "" + #: py/objstr.c msgid "incomplete format" msgstr "incomplete format" @@ -3256,6 +3252,10 @@ msgstr "interp is defined for 1D arrays of equal length" msgid "interval must be in range %s-%s" msgstr "interval must be in range %s-%s" +#: py/compile.c +msgid "invalid architecture" +msgstr "" + #: lib/netutils/netutils.c msgid "invalid arguments" msgstr "invalid arguments" @@ -3265,10 +3265,6 @@ msgstr "invalid arguments" msgid "invalid bits_per_pixel %d, must be, 1, 4, 8, 16, 24, or 32" msgstr "invalid bits_per_pixel %d, must be, 1, 4, 8, 16, 24, or 32" -#: extmod/modussl_axtls.c -msgid "invalid cert" -msgstr "invalid cert" - #: py/compile.c msgid "invalid decorator" msgstr "" @@ -3299,10 +3295,6 @@ msgstr "invalid format specifier" msgid "invalid hostname" msgstr "invalid hostname" -#: extmod/modussl_axtls.c -msgid "invalid key" -msgstr "invalid key" - #: py/compile.c #, fuzzy msgid "invalid micropython decorator" @@ -4314,6 +4306,21 @@ msgstr "zi must be of float type" msgid "zi must be of shape (n_section, 2)" msgstr "zi must be of shape (n_section, 2)" +#~ msgid "Corrupt .mpy file" +#~ msgstr "Corrupt .mpy file" + +#~ msgid "Corrupt raw code" +#~ msgstr "Corrupt raw code" + +#~ msgid "can only save bytecode" +#~ msgstr "Can only save bytecode" + +#~ msgid "invalid cert" +#~ msgstr "invalid cert" + +#~ msgid "invalid key" +#~ msgstr "invalid key" + #~ msgid "Viper functions don't currently support more than 4 arguments" #~ msgstr "Viper functions don't currently support more than 4 arguments" diff --git a/locale/es.po b/locale/es.po index 18c6f56821..3dfe2adc7b 100644 --- a/locale/es.po +++ b/locale/es.po @@ -757,14 +757,6 @@ msgstr "" "La conexión se ha desconectado y ya no se puede usar. Crea una nueva " "conexión." -#: py/persistentcode.c -msgid "Corrupt .mpy file" -msgstr "Archivo .mpy corrupto" - -#: py/emitglue.c -msgid "Corrupt raw code" -msgstr "Código crudo corrupto" - #: ports/cxd56/common-hal/camera/Camera.c msgid "Could not initialize Camera" msgstr "No se puede inicializar Camera" @@ -2651,10 +2643,6 @@ msgstr "solo puede tener hasta 4 parámetros para ensamblar Thumb" msgid "can only have up to 4 parameters to Xtensa assembly" msgstr "solo puede tener hasta 4 parámetros para ensamblador Xtensa" -#: py/persistentcode.c -msgid "can only save bytecode" -msgstr "solo puede almacenar bytecode" - #: py/objtype.c msgid "can't add special method to already-subclassed class" msgstr "no se puede agregar un método a una clase ya subclasificada" @@ -3174,6 +3162,14 @@ msgstr "identificador redefinido como global" msgid "identifier redefined as nonlocal" msgstr "identificador redefinido como nonlocal" +#: py/persistentcode.c +msgid "incompatible .mpy file" +msgstr "" + +#: py/persistentcode.c +msgid "incompatible native .mpy architecture" +msgstr "" + #: py/objstr.c msgid "incomplete format" msgstr "formato incompleto" @@ -3293,6 +3289,10 @@ msgstr "interp está definido para arreglos de 1D del mismo tamaño" msgid "interval must be in range %s-%s" msgstr "el intervalo debe ser der rango %s-%s" +#: py/compile.c +msgid "invalid architecture" +msgstr "" + #: lib/netutils/netutils.c msgid "invalid arguments" msgstr "argumentos inválidos" @@ -3302,10 +3302,6 @@ msgstr "argumentos inválidos" msgid "invalid bits_per_pixel %d, must be, 1, 4, 8, 16, 24, or 32" msgstr "los bits_per_pixel %d no son validos, deben ser 1, 4, 8, 16, 24 o 32" -#: extmod/modussl_axtls.c -msgid "invalid cert" -msgstr "certificado inválido" - #: py/compile.c msgid "invalid decorator" msgstr "decorador invalido" @@ -3336,10 +3332,6 @@ msgstr "especificador de formato inválido" msgid "invalid hostname" msgstr "hostname inválido" -#: extmod/modussl_axtls.c -msgid "invalid key" -msgstr "llave inválida" - #: py/compile.c msgid "invalid micropython decorator" msgstr "decorador de micropython inválido" @@ -4358,6 +4350,21 @@ 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 "Corrupt .mpy file" +#~ msgstr "Archivo .mpy corrupto" + +#~ msgid "Corrupt raw code" +#~ msgstr "Código crudo corrupto" + +#~ msgid "can only save bytecode" +#~ msgstr "solo puede almacenar bytecode" + +#~ msgid "invalid cert" +#~ msgstr "certificado inválido" + +#~ msgid "invalid key" +#~ msgstr "llave inválida" + #~ msgid "Viper functions don't currently support more than 4 arguments" #~ msgstr "funciones Viper no soportan por el momento, más de 4 argumentos" diff --git a/locale/fil.po b/locale/fil.po index 1e85ccbf4b..f5727a9da3 100644 --- a/locale/fil.po +++ b/locale/fil.po @@ -741,14 +741,6 @@ msgid "" "connection." msgstr "" -#: py/persistentcode.c -msgid "Corrupt .mpy file" -msgstr "" - -#: py/emitglue.c -msgid "Corrupt raw code" -msgstr "" - #: ports/cxd56/common-hal/camera/Camera.c msgid "Could not initialize Camera" msgstr "" @@ -2603,10 +2595,6 @@ msgstr "maaari lamang magkaroon ng hanggang 4 na parameter sa Thumb assembly" msgid "can only have up to 4 parameters to Xtensa assembly" msgstr "maaari lamang magkaroon ng hanggang 4 na parameter sa Xtensa assembly" -#: py/persistentcode.c -msgid "can only save bytecode" -msgstr "maaring i-save lamang ang bytecode" - #: py/objtype.c msgid "can't add special method to already-subclassed class" msgstr "" @@ -3131,6 +3119,14 @@ msgstr "identifier ginawang global" msgid "identifier redefined as nonlocal" msgstr "identifier ginawang nonlocal" +#: py/persistentcode.c +msgid "incompatible .mpy file" +msgstr "" + +#: py/persistentcode.c +msgid "incompatible native .mpy architecture" +msgstr "" + #: py/objstr.c msgid "incomplete format" msgstr "hindi kumpleto ang format" @@ -3250,6 +3246,10 @@ msgstr "" msgid "interval must be in range %s-%s" msgstr "" +#: py/compile.c +msgid "invalid architecture" +msgstr "" + #: lib/netutils/netutils.c msgid "invalid arguments" msgstr "mali ang mga argumento" @@ -3259,10 +3259,6 @@ msgstr "mali ang mga argumento" msgid "invalid bits_per_pixel %d, must be, 1, 4, 8, 16, 24, or 32" msgstr "" -#: extmod/modussl_axtls.c -msgid "invalid cert" -msgstr "mali ang cert" - #: py/compile.c msgid "invalid decorator" msgstr "" @@ -3293,10 +3289,6 @@ msgstr "mali ang format specifier" msgid "invalid hostname" msgstr "" -#: extmod/modussl_axtls.c -msgid "invalid key" -msgstr "mali ang key" - #: py/compile.c msgid "invalid micropython decorator" msgstr "mali ang micropython decorator" @@ -4317,6 +4309,15 @@ msgstr "" msgid "zi must be of shape (n_section, 2)" msgstr "" +#~ msgid "can only save bytecode" +#~ msgstr "maaring i-save lamang ang bytecode" + +#~ msgid "invalid cert" +#~ msgstr "mali ang cert" + +#~ msgid "invalid key" +#~ msgstr "mali ang key" + #~ msgid "Viper functions don't currently support more than 4 arguments" #~ msgstr "" #~ "Ang mga function ng Viper ay kasalukuyang hindi sumusuporta sa higit sa 4 " diff --git a/locale/fr.po b/locale/fr.po index 0e8bbe3232..4b314c155d 100644 --- a/locale/fr.po +++ b/locale/fr.po @@ -764,14 +764,6 @@ msgstr "" "La connexion a été déconnectée et ne peut plus être utilisée. Créez une " "nouvelle connexion." -#: py/persistentcode.c -msgid "Corrupt .mpy file" -msgstr "Fichier .mpy corrompu" - -#: py/emitglue.c -msgid "Corrupt raw code" -msgstr "Code brut corrompu" - #: ports/cxd56/common-hal/camera/Camera.c msgid "Could not initialize Camera" msgstr "Impossible d'initialiser Camera" @@ -2666,10 +2658,6 @@ msgstr "il peut y avoir jusqu'à 4 paramètres pour l'assemblage Thumb" msgid "can only have up to 4 parameters to Xtensa assembly" msgstr "maximum 4 paramètres pour l'assembleur Xtensa" -#: py/persistentcode.c -msgid "can only save bytecode" -msgstr "ne peut sauvegarder que du bytecode" - #: py/objtype.c msgid "can't add special method to already-subclassed class" msgstr "" @@ -3197,6 +3185,14 @@ msgstr "identifiant redéfini comme global" msgid "identifier redefined as nonlocal" msgstr "identifiant redéfini comme nonlocal" +#: py/persistentcode.c +msgid "incompatible .mpy file" +msgstr "" + +#: py/persistentcode.c +msgid "incompatible native .mpy architecture" +msgstr "" + #: py/objstr.c msgid "incomplete format" msgstr "format incomplet" @@ -3317,6 +3313,10 @@ msgstr "interp est défini pour les matrices 1D de longueur égale" msgid "interval must be in range %s-%s" msgstr "interval doit être dans la portée %s-%s" +#: py/compile.c +msgid "invalid architecture" +msgstr "" + #: lib/netutils/netutils.c msgid "invalid arguments" msgstr "arguments invalides" @@ -3326,10 +3326,6 @@ msgstr "arguments invalides" msgid "invalid bits_per_pixel %d, must be, 1, 4, 8, 16, 24, or 32" msgstr "bits_per_pixel %d est invalid, doit être 1, 4, 8, 16, 24 ou 32" -#: extmod/modussl_axtls.c -msgid "invalid cert" -msgstr "certificat invalide" - #: py/compile.c msgid "invalid decorator" msgstr "décorateur invalide" @@ -3360,10 +3356,6 @@ msgstr "spécification de format invalide" msgid "invalid hostname" msgstr "hostname incorrect" -#: extmod/modussl_axtls.c -msgid "invalid key" -msgstr "clé invalide" - #: py/compile.c msgid "invalid micropython decorator" msgstr "décorateur micropython invalide" @@ -4384,6 +4376,21 @@ 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 "Corrupt .mpy file" +#~ msgstr "Fichier .mpy corrompu" + +#~ msgid "Corrupt raw code" +#~ msgstr "Code brut corrompu" + +#~ msgid "can only save bytecode" +#~ msgstr "ne peut sauvegarder que du bytecode" + +#~ msgid "invalid cert" +#~ msgstr "certificat invalide" + +#~ msgid "invalid key" +#~ msgstr "clé invalide" + #~ msgid "Viper functions don't currently support more than 4 arguments" #~ msgstr "" #~ "les fonctions de Viper ne supportent pas plus de 4 arguments actuellement" diff --git a/locale/hi.po b/locale/hi.po index 135f9781f1..4d23454770 100644 --- a/locale/hi.po +++ b/locale/hi.po @@ -733,14 +733,6 @@ msgid "" "connection." msgstr "" -#: py/persistentcode.c -msgid "Corrupt .mpy file" -msgstr "" - -#: py/emitglue.c -msgid "Corrupt raw code" -msgstr "" - #: ports/cxd56/common-hal/camera/Camera.c msgid "Could not initialize Camera" msgstr "" @@ -2574,10 +2566,6 @@ msgstr "" msgid "can only have up to 4 parameters to Xtensa assembly" msgstr "" -#: py/persistentcode.c -msgid "can only save bytecode" -msgstr "" - #: py/objtype.c msgid "can't add special method to already-subclassed class" msgstr "" @@ -3090,6 +3078,14 @@ msgstr "" msgid "identifier redefined as nonlocal" msgstr "" +#: py/persistentcode.c +msgid "incompatible .mpy file" +msgstr "" + +#: py/persistentcode.c +msgid "incompatible native .mpy architecture" +msgstr "" + #: py/objstr.c msgid "incomplete format" msgstr "" @@ -3209,6 +3205,10 @@ msgstr "" msgid "interval must be in range %s-%s" msgstr "" +#: py/compile.c +msgid "invalid architecture" +msgstr "" + #: lib/netutils/netutils.c msgid "invalid arguments" msgstr "" @@ -3218,10 +3218,6 @@ msgstr "" msgid "invalid bits_per_pixel %d, must be, 1, 4, 8, 16, 24, or 32" msgstr "" -#: extmod/modussl_axtls.c -msgid "invalid cert" -msgstr "" - #: py/compile.c msgid "invalid decorator" msgstr "" @@ -3252,10 +3248,6 @@ msgstr "" msgid "invalid hostname" msgstr "" -#: extmod/modussl_axtls.c -msgid "invalid key" -msgstr "" - #: py/compile.c msgid "invalid micropython decorator" msgstr "" diff --git a/locale/it_IT.po b/locale/it_IT.po index 53b78ea1ef..e39ad7594f 100644 --- a/locale/it_IT.po +++ b/locale/it_IT.po @@ -751,14 +751,6 @@ msgid "" "connection." msgstr "" -#: py/persistentcode.c -msgid "Corrupt .mpy file" -msgstr "" - -#: py/emitglue.c -msgid "Corrupt raw code" -msgstr "" - #: ports/cxd56/common-hal/camera/Camera.c msgid "Could not initialize Camera" msgstr "" @@ -2621,10 +2613,6 @@ msgstr "sono disponibili fino a 4 parametri per il Xtensa assembly" msgid "can only have up to 4 parameters to Xtensa assembly" msgstr "sono disponibili fino a 4 parametri per il Xtensa assembly" -#: py/persistentcode.c -msgid "can only save bytecode" -msgstr "È possibile salvare solo bytecode" - #: py/objtype.c msgid "can't add special method to already-subclassed class" msgstr "" @@ -3144,6 +3132,14 @@ msgstr "identificatore ridefinito come globale" msgid "identifier redefined as nonlocal" msgstr "identificatore ridefinito come nonlocal" +#: py/persistentcode.c +msgid "incompatible .mpy file" +msgstr "" + +#: py/persistentcode.c +msgid "incompatible native .mpy architecture" +msgstr "" + #: py/objstr.c msgid "incomplete format" msgstr "formato incompleto" @@ -3263,6 +3259,10 @@ msgstr "" msgid "interval must be in range %s-%s" msgstr "" +#: py/compile.c +msgid "invalid architecture" +msgstr "" + #: lib/netutils/netutils.c msgid "invalid arguments" msgstr "argomenti non validi" @@ -3272,10 +3272,6 @@ msgstr "argomenti non validi" msgid "invalid bits_per_pixel %d, must be, 1, 4, 8, 16, 24, or 32" msgstr "" -#: extmod/modussl_axtls.c -msgid "invalid cert" -msgstr "certificato non valido" - #: py/compile.c msgid "invalid decorator" msgstr "" @@ -3306,10 +3302,6 @@ msgstr "specificatore di formato non valido" msgid "invalid hostname" msgstr "" -#: extmod/modussl_axtls.c -msgid "invalid key" -msgstr "chiave non valida" - #: py/compile.c msgid "invalid micropython decorator" msgstr "decoratore non valido in micropython" @@ -4336,6 +4328,15 @@ msgstr "" msgid "zi must be of shape (n_section, 2)" msgstr "" +#~ msgid "can only save bytecode" +#~ msgstr "È possibile salvare solo bytecode" + +#~ msgid "invalid cert" +#~ msgstr "certificato non valido" + +#~ msgid "invalid key" +#~ msgstr "chiave non valida" + #~ msgid "Viper functions don't currently support more than 4 arguments" #~ msgstr "Le funzioni Viper non supportano più di 4 argomenti al momento" diff --git a/locale/ja.po b/locale/ja.po index 6c833f6f49..5df538a05d 100644 --- a/locale/ja.po +++ b/locale/ja.po @@ -744,14 +744,6 @@ msgid "" "connection." msgstr "接続は切断済みでもう使えません。新しい接続を作成してください" -#: py/persistentcode.c -msgid "Corrupt .mpy file" -msgstr "破損した .mpy ファイル" - -#: py/emitglue.c -msgid "Corrupt raw code" -msgstr "破損したraw code" - #: ports/cxd56/common-hal/camera/Camera.c msgid "Could not initialize Camera" msgstr "カメラを初期化できません" @@ -2597,10 +2589,6 @@ msgstr "" msgid "can only have up to 4 parameters to Xtensa assembly" msgstr "" -#: py/persistentcode.c -msgid "can only save bytecode" -msgstr "" - #: py/objtype.c msgid "can't add special method to already-subclassed class" msgstr "サブクラス化済みのクラスに特殊メソッドを追加できません" @@ -3117,6 +3105,14 @@ msgstr "" msgid "identifier redefined as nonlocal" msgstr "" +#: py/persistentcode.c +msgid "incompatible .mpy file" +msgstr "" + +#: py/persistentcode.c +msgid "incompatible native .mpy architecture" +msgstr "" + #: py/objstr.c msgid "incomplete format" msgstr "" @@ -3237,6 +3233,10 @@ msgstr "" msgid "interval must be in range %s-%s" msgstr "intervalは%s-%sの範囲でなければなりません" +#: py/compile.c +msgid "invalid architecture" +msgstr "" + #: lib/netutils/netutils.c msgid "invalid arguments" msgstr "不正な引数" @@ -3246,10 +3246,6 @@ msgstr "不正な引数" msgid "invalid bits_per_pixel %d, must be, 1, 4, 8, 16, 24, or 32" msgstr "" -#: extmod/modussl_axtls.c -msgid "invalid cert" -msgstr "不正な証明書" - #: py/compile.c msgid "invalid decorator" msgstr "" @@ -3280,10 +3276,6 @@ msgstr "" msgid "invalid hostname" msgstr "不正なホスト名" -#: extmod/modussl_axtls.c -msgid "invalid key" -msgstr "不正な鍵" - #: py/compile.c msgid "invalid micropython decorator" msgstr "不正なmicropythonデコレータ" @@ -4295,6 +4287,18 @@ msgstr "ziはfloat値でなければなりません" msgid "zi must be of shape (n_section, 2)" msgstr "" +#~ msgid "Corrupt .mpy file" +#~ msgstr "破損した .mpy ファイル" + +#~ msgid "Corrupt raw code" +#~ msgstr "破損したraw code" + +#~ msgid "invalid cert" +#~ msgstr "不正な証明書" + +#~ msgid "invalid key" +#~ msgstr "不正な鍵" + #~ msgid "parameter annotation must be an identifier" #~ msgstr "引数アノテーションは識別子でなければなりません" diff --git a/locale/ko.po b/locale/ko.po index 1178d45dd6..06edd419c2 100644 --- a/locale/ko.po +++ b/locale/ko.po @@ -736,14 +736,6 @@ msgid "" "connection." msgstr "" -#: py/persistentcode.c -msgid "Corrupt .mpy file" -msgstr "" - -#: py/emitglue.c -msgid "Corrupt raw code" -msgstr "" - #: ports/cxd56/common-hal/camera/Camera.c msgid "Could not initialize Camera" msgstr "" @@ -2578,10 +2570,6 @@ msgstr "" msgid "can only have up to 4 parameters to Xtensa assembly" msgstr "" -#: py/persistentcode.c -msgid "can only save bytecode" -msgstr "" - #: py/objtype.c msgid "can't add special method to already-subclassed class" msgstr "" @@ -3094,6 +3082,14 @@ msgstr "" msgid "identifier redefined as nonlocal" msgstr "" +#: py/persistentcode.c +msgid "incompatible .mpy file" +msgstr "" + +#: py/persistentcode.c +msgid "incompatible native .mpy architecture" +msgstr "" + #: py/objstr.c msgid "incomplete format" msgstr "" @@ -3213,6 +3209,10 @@ msgstr "" msgid "interval must be in range %s-%s" msgstr "" +#: py/compile.c +msgid "invalid architecture" +msgstr "" + #: lib/netutils/netutils.c msgid "invalid arguments" msgstr "" @@ -3222,10 +3222,6 @@ msgstr "" msgid "invalid bits_per_pixel %d, must be, 1, 4, 8, 16, 24, or 32" msgstr "" -#: extmod/modussl_axtls.c -msgid "invalid cert" -msgstr "cert가 유효하지 않습니다" - #: py/compile.c msgid "invalid decorator" msgstr "" @@ -3256,10 +3252,6 @@ msgstr "형식 지정자(format specifier)가 유효하지 않습니다" msgid "invalid hostname" msgstr "" -#: extmod/modussl_axtls.c -msgid "invalid key" -msgstr "키가 유효하지 않습니다" - #: py/compile.c msgid "invalid micropython decorator" msgstr "" @@ -4268,6 +4260,12 @@ msgstr "" msgid "zi must be of shape (n_section, 2)" msgstr "" +#~ msgid "invalid cert" +#~ msgstr "cert가 유효하지 않습니다" + +#~ msgid "invalid key" +#~ msgstr "키가 유효하지 않습니다" + #~ msgid "bits must be 7, 8 or 9" #~ msgstr "비트(bits)는 7, 8 또는 9 여야합니다" diff --git a/locale/nl.po b/locale/nl.po index 3498a11820..57ff2337b8 100644 --- a/locale/nl.po +++ b/locale/nl.po @@ -744,14 +744,6 @@ msgstr "" "Verbinding is verbroken en kan niet langer gebruikt worden. Creëer een " "nieuwe verbinding." -#: py/persistentcode.c -msgid "Corrupt .mpy file" -msgstr "Corrupt .mpy bestand" - -#: py/emitglue.c -msgid "Corrupt raw code" -msgstr "Corrupt raw code" - #: ports/cxd56/common-hal/camera/Camera.c msgid "Could not initialize Camera" msgstr "Kon camera niet initialiseren" @@ -2625,10 +2617,6 @@ msgstr "kan slechts 4 parameters aan Thumb assembly geven" msgid "can only have up to 4 parameters to Xtensa assembly" msgstr "kan slechts 4 parameters aan Xtensa assembly geven" -#: py/persistentcode.c -msgid "can only save bytecode" -msgstr "kan alleen byte-code opslaan" - #: py/objtype.c msgid "can't add special method to already-subclassed class" msgstr "" @@ -3146,6 +3134,14 @@ msgstr "identifier is opnieuw gedefinieerd als global" msgid "identifier redefined as nonlocal" msgstr "identifier is opnieuw gedefinieerd als nonlocal" +#: py/persistentcode.c +msgid "incompatible .mpy file" +msgstr "" + +#: py/persistentcode.c +msgid "incompatible native .mpy architecture" +msgstr "" + #: py/objstr.c msgid "incomplete format" msgstr "incompleet formaat" @@ -3265,6 +3261,10 @@ msgstr "interp is gedefinieerd voor eendimensionale arrays van gelijke lengte" msgid "interval must be in range %s-%s" msgstr "interval moet binnen bereik %s-%s vallen" +#: py/compile.c +msgid "invalid architecture" +msgstr "" + #: lib/netutils/netutils.c msgid "invalid arguments" msgstr "ongeldige argumenten" @@ -3274,10 +3274,6 @@ msgstr "ongeldige argumenten" msgid "invalid bits_per_pixel %d, must be, 1, 4, 8, 16, 24, or 32" msgstr "" -#: extmod/modussl_axtls.c -msgid "invalid cert" -msgstr "ongeldig certificaat" - #: py/compile.c msgid "invalid decorator" msgstr "" @@ -3308,10 +3304,6 @@ msgstr "ongeldige formaatspecificatie" msgid "invalid hostname" msgstr "onjuiste hostnaam" -#: extmod/modussl_axtls.c -msgid "invalid key" -msgstr "ongeldige sleutel" - #: py/compile.c msgid "invalid micropython decorator" msgstr "ongeldige micropython decorator" @@ -4326,6 +4318,21 @@ 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 "Corrupt .mpy file" +#~ msgstr "Corrupt .mpy bestand" + +#~ msgid "Corrupt raw code" +#~ msgstr "Corrupt raw code" + +#~ msgid "can only save bytecode" +#~ msgstr "kan alleen byte-code opslaan" + +#~ msgid "invalid cert" +#~ msgstr "ongeldig certificaat" + +#~ msgid "invalid key" +#~ msgstr "ongeldige sleutel" + #~ msgid "Viper functions don't currently support more than 4 arguments" #~ msgstr "Viper-functies ondersteunen momenteel niet meer dan 4 argumenten" diff --git a/locale/pl.po b/locale/pl.po index 32d839de23..984ed10275 100644 --- a/locale/pl.po +++ b/locale/pl.po @@ -744,14 +744,6 @@ msgstr "" "Połączenie zostało rozłączone i nie można go już używać. Utwórz nowe " "połączenie." -#: py/persistentcode.c -msgid "Corrupt .mpy file" -msgstr "Uszkodzony plik .mpy" - -#: py/emitglue.c -msgid "Corrupt raw code" -msgstr "" - #: ports/cxd56/common-hal/camera/Camera.c msgid "Could not initialize Camera" msgstr "" @@ -2593,10 +2585,6 @@ msgstr "asembler Thumb może przyjąć do 4 parameterów" msgid "can only have up to 4 parameters to Xtensa assembly" msgstr "asembler Xtensa może przyjąć do 4 parameterów" -#: py/persistentcode.c -msgid "can only save bytecode" -msgstr "można zapisać tylko bytecode" - #: py/objtype.c msgid "can't add special method to already-subclassed class" msgstr "nie można dodać specjalnej metody do podklasy" @@ -3110,6 +3098,14 @@ msgstr "nazwa przedefiniowana jako globalna" msgid "identifier redefined as nonlocal" msgstr "nazwa przedefiniowana jako nielokalna" +#: py/persistentcode.c +msgid "incompatible .mpy file" +msgstr "" + +#: py/persistentcode.c +msgid "incompatible native .mpy architecture" +msgstr "" + #: py/objstr.c msgid "incomplete format" msgstr "niepełny format" @@ -3229,6 +3225,10 @@ msgstr "" msgid "interval must be in range %s-%s" msgstr "interwał musi mieścić się w zakresie %s-%s" +#: py/compile.c +msgid "invalid architecture" +msgstr "" + #: lib/netutils/netutils.c msgid "invalid arguments" msgstr "złe arguemnty" @@ -3238,10 +3238,6 @@ msgstr "złe arguemnty" msgid "invalid bits_per_pixel %d, must be, 1, 4, 8, 16, 24, or 32" msgstr "" -#: extmod/modussl_axtls.c -msgid "invalid cert" -msgstr "zły ceryfikat" - #: py/compile.c msgid "invalid decorator" msgstr "" @@ -3272,10 +3268,6 @@ msgstr "zła specyfikacja formatu" msgid "invalid hostname" msgstr "" -#: extmod/modussl_axtls.c -msgid "invalid key" -msgstr "zły klucz" - #: py/compile.c msgid "invalid micropython decorator" msgstr "zły dekorator micropythona" @@ -4286,6 +4278,18 @@ msgstr "" msgid "zi must be of shape (n_section, 2)" msgstr "" +#~ msgid "Corrupt .mpy file" +#~ msgstr "Uszkodzony plik .mpy" + +#~ msgid "can only save bytecode" +#~ msgstr "można zapisać tylko bytecode" + +#~ msgid "invalid cert" +#~ msgstr "zły ceryfikat" + +#~ msgid "invalid key" +#~ msgstr "zły klucz" + #~ msgid "Viper functions don't currently support more than 4 arguments" #~ msgstr "Funkcje Viper nie obsługują obecnie więcej niż 4 argumentów" diff --git a/locale/pt_BR.po b/locale/pt_BR.po index 3ca69c24e2..cfe04562a0 100644 --- a/locale/pt_BR.po +++ b/locale/pt_BR.po @@ -761,14 +761,6 @@ msgid "" msgstr "" "A conexão foi desconectada e não pode mais ser usada. Crie uma nova conexão." -#: py/persistentcode.c -msgid "Corrupt .mpy file" -msgstr "Arquivo .mpy corrompido" - -#: py/emitglue.c -msgid "Corrupt raw code" -msgstr "Código bruto corrompido" - #: ports/cxd56/common-hal/camera/Camera.c msgid "Could not initialize Camera" msgstr "Não foi possível inicializar a Câmera" @@ -2658,10 +2650,6 @@ msgstr "só pode haver até 4 parâmetros para a montagem Thumb" msgid "can only have up to 4 parameters to Xtensa assembly" msgstr "só pode haver até 4 parâmetros para a montagem Xtensa" -#: py/persistentcode.c -msgid "can only save bytecode" -msgstr "apenas o bytecode pode ser salvo" - #: py/objtype.c msgid "can't add special method to already-subclassed class" msgstr "não é possível adicionar o método especial à classe já subclassificada" @@ -3183,6 +3171,14 @@ msgstr "o identificador foi redefinido como global" msgid "identifier redefined as nonlocal" msgstr "o identificador foi redefinido como não-local" +#: py/persistentcode.c +msgid "incompatible .mpy file" +msgstr "" + +#: py/persistentcode.c +msgid "incompatible native .mpy architecture" +msgstr "" + #: py/objstr.c msgid "incomplete format" msgstr "formato incompleto" @@ -3303,6 +3299,10 @@ msgstr "o interp é definido para matrizes 1D de igual comprimento" msgid "interval must be in range %s-%s" msgstr "o intervalo deve estar entre %s-%s" +#: py/compile.c +msgid "invalid architecture" +msgstr "" + #: lib/netutils/netutils.c msgid "invalid arguments" msgstr "argumentos inválidos" @@ -3312,10 +3312,6 @@ msgstr "argumentos inválidos" msgid "invalid bits_per_pixel %d, must be, 1, 4, 8, 16, 24, or 32" msgstr "bits_per_pixel %d é inválido, deve ser, 1, 4, 8, 16, 24, ou 32" -#: extmod/modussl_axtls.c -msgid "invalid cert" -msgstr "certificado inválido" - #: py/compile.c msgid "invalid decorator" msgstr "decorador inválido" @@ -3346,10 +3342,6 @@ msgstr "o especificador do formato é inválido" msgid "invalid hostname" msgstr "o nome do host é inválido" -#: extmod/modussl_axtls.c -msgid "invalid key" -msgstr "chave inválida" - #: py/compile.c msgid "invalid micropython decorator" msgstr "o decorador micropython é inválido" @@ -4370,6 +4362,21 @@ 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 "Corrupt .mpy file" +#~ msgstr "Arquivo .mpy corrompido" + +#~ msgid "Corrupt raw code" +#~ msgstr "Código bruto corrompido" + +#~ msgid "can only save bytecode" +#~ msgstr "apenas o bytecode pode ser salvo" + +#~ msgid "invalid cert" +#~ msgstr "certificado inválido" + +#~ msgid "invalid key" +#~ msgstr "chave inválida" + #~ msgid "Viper functions don't currently support more than 4 arguments" #~ msgstr "Atualmente, as funções do Viper não suportam mais de 4 argumentos" diff --git a/locale/sv.po b/locale/sv.po index 8defcb5546..afa32f410a 100644 --- a/locale/sv.po +++ b/locale/sv.po @@ -750,14 +750,6 @@ msgstr "" "Anslutningen har kopplats bort och kan inte längre användas. Skapa en ny " "anslutning." -#: py/persistentcode.c -msgid "Corrupt .mpy file" -msgstr "Skadad .mpy-fil" - -#: py/emitglue.c -msgid "Corrupt raw code" -msgstr "Korrupt rå kod" - #: ports/cxd56/common-hal/camera/Camera.c msgid "Could not initialize Camera" msgstr "Kunde inte initiera Camera" @@ -2628,10 +2620,6 @@ msgstr "kan bara ha upp till 4 parametrar för Thumbs assembly" msgid "can only have up to 4 parameters to Xtensa assembly" msgstr "kan bara ha upp till 4 parametrar att Xtensa assembly" -#: py/persistentcode.c -msgid "can only save bytecode" -msgstr "kan bara spara bytecode" - #: py/objtype.c msgid "can't add special method to already-subclassed class" msgstr "kan inte lägga till särskild metod för redan subklassad klass" @@ -3149,6 +3137,14 @@ msgstr "identifieraren omdefinierad till global" msgid "identifier redefined as nonlocal" msgstr "identifieraren omdefinierad som icke-lokal" +#: py/persistentcode.c +msgid "incompatible .mpy file" +msgstr "" + +#: py/persistentcode.c +msgid "incompatible native .mpy architecture" +msgstr "" + #: py/objstr.c msgid "incomplete format" msgstr "ofullständigt format" @@ -3268,6 +3264,10 @@ msgstr "interp är definierad för 1D-matriser med samma längd" msgid "interval must be in range %s-%s" msgstr "interval måste vara i intervallet %s-%s" +#: py/compile.c +msgid "invalid architecture" +msgstr "" + #: lib/netutils/netutils.c msgid "invalid arguments" msgstr "ogiltiga argument" @@ -3277,10 +3277,6 @@ msgstr "ogiltiga argument" msgid "invalid bits_per_pixel %d, must be, 1, 4, 8, 16, 24, or 32" msgstr "ogiltig bits_per_pixel %d, måste vara 1, 4, 8, 16, 24 eller 32" -#: extmod/modussl_axtls.c -msgid "invalid cert" -msgstr "ogiltigt certifikat" - #: py/compile.c msgid "invalid decorator" msgstr "ogiltig dekorator" @@ -3311,10 +3307,6 @@ msgstr "ogiltig formatspecificerare" msgid "invalid hostname" msgstr "Ogiltigt värdnamn" -#: extmod/modussl_axtls.c -msgid "invalid key" -msgstr "ogiltig nyckel" - #: py/compile.c msgid "invalid micropython decorator" msgstr "ogiltig mikropython-dekorator" @@ -4329,6 +4321,21 @@ 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 "Corrupt .mpy file" +#~ msgstr "Skadad .mpy-fil" + +#~ msgid "Corrupt raw code" +#~ msgstr "Korrupt rå kod" + +#~ msgid "can only save bytecode" +#~ msgstr "kan bara spara bytecode" + +#~ msgid "invalid cert" +#~ msgstr "ogiltigt certifikat" + +#~ msgid "invalid key" +#~ msgstr "ogiltig nyckel" + #~ msgid "Viper functions don't currently support more than 4 arguments" #~ msgstr "Viper-funktioner stöder för närvarande inte mer än fyra argument" diff --git a/locale/zh_Latn_pinyin.po b/locale/zh_Latn_pinyin.po index 8a21a68f42..49bf62a3a6 100644 --- a/locale/zh_Latn_pinyin.po +++ b/locale/zh_Latn_pinyin.po @@ -749,14 +749,6 @@ msgid "" "connection." msgstr "Liánjiē yǐ duàn kāi, wúfǎ zài shǐyòng. Chuàngjiàn yīgè xīn de liánjiē." -#: py/persistentcode.c -msgid "Corrupt .mpy file" -msgstr "Fǔbài de .mpy wénjiàn" - -#: py/emitglue.c -msgid "Corrupt raw code" -msgstr "Sǔnhuài de yuánshǐ dàimǎ" - #: ports/cxd56/common-hal/camera/Camera.c msgid "Could not initialize Camera" msgstr "Wúfǎ chūshǐhuà xiàngjī" @@ -2626,10 +2618,6 @@ msgstr "zhǐyǒu Thumb zǔjiàn zuìduō 4 cānshù" msgid "can only have up to 4 parameters to Xtensa assembly" msgstr "zhǐyǒu Xtensa zǔjiàn zuìduō 4 cānshù" -#: py/persistentcode.c -msgid "can only save bytecode" -msgstr "zhǐ néng bǎocún zì jié mǎ jìlù" - #: py/objtype.c msgid "can't add special method to already-subclassed class" msgstr "wúfǎ tiānjiā tèshū fāngfǎ dào zi fēnlèi lèi" @@ -3148,6 +3136,14 @@ msgstr "biāozhì fú chóngxīn dìngyì wèi quánjú" msgid "identifier redefined as nonlocal" msgstr "biāozhì fú chóngxīn dìngyì wéi fēi běndì" +#: py/persistentcode.c +msgid "incompatible .mpy file" +msgstr "" + +#: py/persistentcode.c +msgid "incompatible native .mpy architecture" +msgstr "" + #: py/objstr.c msgid "incomplete format" msgstr "géshì bù wánzhěng" @@ -3267,6 +3263,10 @@ msgstr "interp shì wèi děng zhǎng de 1D shùzǔ dìngyì de" msgid "interval must be in range %s-%s" msgstr "Jiàngé bìxū zài %s-%s fànwéi nèi" +#: py/compile.c +msgid "invalid architecture" +msgstr "" + #: lib/netutils/netutils.c msgid "invalid arguments" msgstr "wúxiào de cānshù" @@ -3276,10 +3276,6 @@ msgstr "wúxiào de cānshù" msgid "invalid bits_per_pixel %d, must be, 1, 4, 8, 16, 24, or 32" msgstr "wú xiào bits_per_pixel %d, bì xū shì, 1, 4, 8, 16, 24, huò 32" -#: extmod/modussl_axtls.c -msgid "invalid cert" -msgstr "zhèngshū wúxiào" - #: py/compile.c msgid "invalid decorator" msgstr "wú xiào zhuāng shì" @@ -3310,10 +3306,6 @@ msgstr "wúxiào de géshì biāozhù" msgid "invalid hostname" msgstr "wú xiào zhǔ jī míng" -#: extmod/modussl_axtls.c -msgid "invalid key" -msgstr "wúxiào de mì yào" - #: py/compile.c msgid "invalid micropython decorator" msgstr "wúxiào de MicroPython zhuāngshì qì" @@ -4325,6 +4317,21 @@ 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 "Corrupt .mpy file" +#~ msgstr "Fǔbài de .mpy wénjiàn" + +#~ msgid "Corrupt raw code" +#~ msgstr "Sǔnhuài de yuánshǐ dàimǎ" + +#~ msgid "can only save bytecode" +#~ msgstr "zhǐ néng bǎocún zì jié mǎ jìlù" + +#~ msgid "invalid cert" +#~ msgstr "zhèngshū wúxiào" + +#~ msgid "invalid key" +#~ msgstr "wúxiào de mì yào" + #~ msgid "Viper functions don't currently support more than 4 arguments" #~ msgstr "Viper hánshù mùqián bù zhīchí chāoguò 4 gè cānshù" From 2d80f6b872008a5afc07bffbeaf7a1e0522287aa Mon Sep 17 00:00:00 2001 From: jposada202020 Date: Tue, 27 Apr 2021 17:11:42 -0400 Subject: [PATCH 57/67] Module_description_changes --- docs/design_guide.rst | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/docs/design_guide.rst b/docs/design_guide.rst index 5bd6bbd387..edd8c0a6f2 100644 --- a/docs/design_guide.rst +++ b/docs/design_guide.rst @@ -238,11 +238,34 @@ Module description After the license comment:: """ - `` - + `` ================================================= + + + * Author(s): + + Implementation Notes + -------------------- + + + **Hardware:** + + * Adafruit `Device Description + `_ (Product ID: ) + + **Software and Dependencies:** + + * Adafruit CircuitPython firmware for the supported boards: + https://circuitpython.org/downloads + * Adafruit's Bus Device library: + https://github.com/adafruit/Adafruit_CircuitPython_BusDevice + * Adafruit's Register library: + https://github.com/adafruit/Adafruit_CircuitPython_Register + """ + Class description ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ From 4d0e183ae11e291390f54d3d8ed749976866b7d0 Mon Sep 17 00:00:00 2001 From: jposada202020 Date: Tue, 27 Apr 2021 17:18:14 -0400 Subject: [PATCH 58/67] Module_description_changes --- docs/design_guide.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/design_guide.rst b/docs/design_guide.rst index edd8c0a6f2..5ba5788573 100644 --- a/docs/design_guide.rst +++ b/docs/design_guide.rst @@ -241,7 +241,7 @@ After the license comment:: `` ================================================= - + * Author(s): From a512dd230df419c204b7acd49c0cc7f9ebdce290 Mon Sep 17 00:00:00 2001 From: jposada202020 Date: Tue, 27 Apr 2021 17:34:45 -0400 Subject: [PATCH 59/67] word_order_better_phrasing --- docs/design_guide.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/design_guide.rst b/docs/design_guide.rst index 5ba5788573..e9a275dd41 100644 --- a/docs/design_guide.rst +++ b/docs/design_guide.rst @@ -409,7 +409,7 @@ Renders as: Documentation References to other Libraries ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ When you need to make references to documentation in other libraries you should refer the class using single -backticks ``:class:`~adafruit_motor.servo.Servo```. You must add also the reference in the ``conf.py`` file in the +backticks ``:class:`~adafruit_motor.servo.Servo```. You must also add the reference in the ``conf.py`` file in the ``intersphinx_mapping section`` adding a new entry:: "adafruit_motor": ("https://circuitpython.readthedocs.io/projects/motor/en/latest/", None,), From cb42acea53d4780a018db3bea253708d5d7dd404 Mon Sep 17 00:00:00 2001 From: jposada202020 Date: Tue, 27 Apr 2021 17:43:25 -0400 Subject: [PATCH 60/67] better_phrasing --- docs/design_guide.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/design_guide.rst b/docs/design_guide.rst index e9a275dd41..8ad0428afa 100644 --- a/docs/design_guide.rst +++ b/docs/design_guide.rst @@ -410,7 +410,7 @@ Documentation References to other Libraries ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ When you need to make references to documentation in other libraries you should refer the class using single backticks ``:class:`~adafruit_motor.servo.Servo```. You must also add the reference in the ``conf.py`` file in the -``intersphinx_mapping section`` adding a new entry:: +``intersphinx_mapping section`` by adding a new entry:: "adafruit_motor": ("https://circuitpython.readthedocs.io/projects/motor/en/latest/", None,), From 38c6234b84a701a0d1dca0ee7e40d53a82833f1e Mon Sep 17 00:00:00 2001 From: Reza Almanda Date: Wed, 28 Apr 2021 02:21:35 +0000 Subject: [PATCH 61/67] Translated using Weblate (Indonesian) Currently translated at 46.5% (452 of 972 strings) Translation: CircuitPython/main Translate-URL: https://hosted.weblate.org/projects/circuitpython/main/id/ --- locale/ID.po | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/locale/ID.po b/locale/ID.po index 9507fb0b22..8653094ab4 100644 --- a/locale/ID.po +++ b/locale/ID.po @@ -6,7 +6,7 @@ msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2021-01-04 12:55-0600\n" -"PO-Revision-Date: 2021-04-07 12:23+0000\n" +"PO-Revision-Date: 2021-04-28 16:11+0000\n" "Last-Translator: Reza Almanda \n" "Language-Team: LANGUAGE \n" "Language: ID\n" @@ -14,7 +14,7 @@ msgstr "" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=1; plural=0;\n" -"X-Generator: Weblate 4.6-dev\n" +"X-Generator: Weblate 4.7-dev\n" #: main.c msgid "" @@ -1662,11 +1662,11 @@ msgstr "Hanya 8 atau 16 bit mono dengan " #: ports/esp32s2/common-hal/wifi/__init__.c msgid "Only IPv4 addresses supported" -msgstr "" +msgstr "Hanya alamat IPv4 yang didukung" #: ports/esp32s2/common-hal/socketpool/SocketPool.c msgid "Only IPv4 sockets supported" -msgstr "" +msgstr "Hanysa socket IPv4 yang didukung" #: shared-module/displayio/OnDiskBitmap.c #, c-format @@ -1707,15 +1707,15 @@ msgstr "" #: ports/esp32s2/bindings/espidf/__init__.c ports/esp32s2/esp_error.c msgid "Operation timed out" -msgstr "" +msgstr "Waktu habis" #: ports/esp32s2/bindings/espidf/__init__.c ports/esp32s2/esp_error.c msgid "Out of memory" -msgstr "" +msgstr "Kehabisan memori" #: ports/esp32s2/common-hal/socketpool/SocketPool.c msgid "Out of sockets" -msgstr "" +msgstr "Kehabisan socket" #: ports/raspberrypi/bindings/rp2pio/StateMachine.c msgid "Out-buffer elements must be <= 4 bytes long" @@ -1761,7 +1761,7 @@ msgstr "ParallelBus belum didukung" #: ports/esp32s2/common-hal/audiobusio/__init__.c msgid "Peripheral in use" -msgstr "" +msgstr "Periferal sedang digunakan" #: py/moduerrno.c msgid "Permission denied" @@ -1773,7 +1773,7 @@ msgstr "" #: ports/raspberrypi/common-hal/rp2pio/StateMachine.c msgid "Pin count too large" -msgstr "" +msgstr "Jumlah pin terlalu besar" #: ports/atmel-samd/common-hal/analogio/AnalogIn.c #: ports/cxd56/common-hal/analogio/AnalogIn.c @@ -1815,7 +1815,7 @@ msgstr "" #: ports/raspberrypi/common-hal/rotaryio/IncrementalEncoder.c msgid "Pins must be sequential" -msgstr "" +msgstr "Pin harus berurutan" #: ports/raspberrypi/common-hal/audiopwmio/PWMAudioOut.c msgid "Pins must share PWM slice" @@ -4239,11 +4239,11 @@ msgstr "" #: ports/esp32s2/common-hal/wifi/Radio.c msgid "wifi is not enabled" -msgstr "" +msgstr "wifi tidak diaktifkan" #: shared-bindings/_bleio/Adapter.c msgid "window must be <= interval" -msgstr "" +msgstr "jendela harus <= interval" #: extmod/ulab/code/numpy/numerical/numerical.c msgid "wrong axis index" From bc8b254d4f0bd64c22d5f6836cb18f78f02a649f Mon Sep 17 00:00:00 2001 From: Alvaro Figueroa Date: Tue, 27 Apr 2021 19:50:57 +0000 Subject: [PATCH 62/67] Translated using Weblate (Spanish) Currently translated at 100.0% (972 of 972 strings) Translation: CircuitPython/main Translate-URL: https://hosted.weblate.org/projects/circuitpython/main/es/ --- locale/es.po | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/locale/es.po b/locale/es.po index 3dfe2adc7b..0bb384dd9d 100644 --- a/locale/es.po +++ b/locale/es.po @@ -8,7 +8,7 @@ msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2021-01-04 12:55-0600\n" -"PO-Revision-Date: 2021-04-25 18:43+0000\n" +"PO-Revision-Date: 2021-04-28 16:11+0000\n" "Last-Translator: Alvaro Figueroa \n" "Language-Team: \n" "Language: es\n" @@ -3164,11 +3164,11 @@ msgstr "identificador redefinido como nonlocal" #: py/persistentcode.c msgid "incompatible .mpy file" -msgstr "" +msgstr "archivo .mpy incompatible" #: py/persistentcode.c msgid "incompatible native .mpy architecture" -msgstr "" +msgstr "arquitectura nativa de .mpy incompatible" #: py/objstr.c msgid "incomplete format" @@ -3291,7 +3291,7 @@ msgstr "el intervalo debe ser der rango %s-%s" #: py/compile.c msgid "invalid architecture" -msgstr "" +msgstr "arquitectura inválida" #: lib/netutils/netutils.c msgid "invalid arguments" From 602835a62933a58085104d7760decfafe19c4da5 Mon Sep 17 00:00:00 2001 From: Hugo Dahl Date: Wed, 28 Apr 2021 00:56:51 +0000 Subject: [PATCH 63/67] Translated using Weblate (French) Currently translated at 100.0% (972 of 972 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 4b314c155d..7660ce4169 100644 --- a/locale/fr.po +++ b/locale/fr.po @@ -8,7 +8,7 @@ msgstr "" "Project-Id-Version: 0.1\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2021-01-04 12:55-0600\n" -"PO-Revision-Date: 2021-04-24 14:29+0000\n" +"PO-Revision-Date: 2021-04-28 16:11+0000\n" "Last-Translator: Hugo Dahl \n" "Language: fr\n" "MIME-Version: 1.0\n" @@ -3187,11 +3187,11 @@ msgstr "identifiant redéfini comme nonlocal" #: py/persistentcode.c msgid "incompatible .mpy file" -msgstr "" +msgstr "Fichier .mpy incompatible" #: py/persistentcode.c msgid "incompatible native .mpy architecture" -msgstr "" +msgstr "architecture native .mpy incompatible" #: py/objstr.c msgid "incomplete format" @@ -3315,7 +3315,7 @@ msgstr "interval doit être dans la portée %s-%s" #: py/compile.c msgid "invalid architecture" -msgstr "" +msgstr "architecture invalide" #: lib/netutils/netutils.c msgid "invalid arguments" From 4834a21b9c136a0faf673f7ea73791c88a66cb17 Mon Sep 17 00:00:00 2001 From: Wellington Terumi Uemura Date: Tue, 27 Apr 2021 20:41:16 +0000 Subject: [PATCH 64/67] Translated using Weblate (Portuguese (Brazil)) Currently translated at 100.0% (972 of 972 strings) Translation: CircuitPython/main Translate-URL: https://hosted.weblate.org/projects/circuitpython/main/pt_BR/ --- locale/pt_BR.po | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/locale/pt_BR.po b/locale/pt_BR.po index cfe04562a0..58a706d216 100644 --- a/locale/pt_BR.po +++ b/locale/pt_BR.po @@ -6,7 +6,7 @@ msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2021-01-04 12:55-0600\n" -"PO-Revision-Date: 2021-04-25 18:43+0000\n" +"PO-Revision-Date: 2021-04-28 16:11+0000\n" "Last-Translator: Wellington Terumi Uemura \n" "Language-Team: \n" "Language: pt_BR\n" @@ -3173,11 +3173,11 @@ msgstr "o identificador foi redefinido como não-local" #: py/persistentcode.c msgid "incompatible .mpy file" -msgstr "" +msgstr "arquivo .mpy incompatível" #: py/persistentcode.c msgid "incompatible native .mpy architecture" -msgstr "" +msgstr "arquivo .mpy com arquitetura nativa incompatível" #: py/objstr.c msgid "incomplete format" @@ -3301,7 +3301,7 @@ msgstr "o intervalo deve estar entre %s-%s" #: py/compile.c msgid "invalid architecture" -msgstr "" +msgstr "arquitetura inválida" #: lib/netutils/netutils.c msgid "invalid arguments" From 9b5d131bf69ba962d42adbfdd8188f86c6bbd409 Mon Sep 17 00:00:00 2001 From: Jonny Bergdahl Date: Wed, 28 Apr 2021 07:05:55 +0000 Subject: [PATCH 65/67] Translated using Weblate (Swedish) Currently translated at 100.0% (972 of 972 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 afa32f410a..7cee54cd84 100644 --- a/locale/sv.po +++ b/locale/sv.po @@ -6,7 +6,7 @@ msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2021-01-04 12:55-0600\n" -"PO-Revision-Date: 2021-04-24 14:29+0000\n" +"PO-Revision-Date: 2021-04-28 16:11+0000\n" "Last-Translator: Jonny Bergdahl \n" "Language-Team: LANGUAGE \n" "Language: sv\n" @@ -3139,11 +3139,11 @@ msgstr "identifieraren omdefinierad som icke-lokal" #: py/persistentcode.c msgid "incompatible .mpy file" -msgstr "" +msgstr "inkompatibel .mpy-fil" #: py/persistentcode.c msgid "incompatible native .mpy architecture" -msgstr "" +msgstr "inkompatibel nativ .mpy-arkitektur" #: py/objstr.c msgid "incomplete format" @@ -3266,7 +3266,7 @@ msgstr "interval måste vara i intervallet %s-%s" #: py/compile.c msgid "invalid architecture" -msgstr "" +msgstr "ogiltig arkitektur" #: lib/netutils/netutils.c msgid "invalid arguments" From 9cd255a55d40121c2322ea75fb85050a91125d6a Mon Sep 17 00:00:00 2001 From: Hosted Weblate Date: Wed, 28 Apr 2021 18:11:43 +0200 Subject: [PATCH 66/67] 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 | 5 ++++- locale/cs.po | 5 ++++- locale/de_DE.po | 5 ++++- locale/el.po | 5 ++++- locale/en_GB.po | 5 ++++- locale/es.po | 5 ++++- locale/fil.po | 5 ++++- locale/fr.po | 5 ++++- locale/hi.po | 5 ++++- locale/it_IT.po | 5 ++++- locale/ja.po | 5 ++++- locale/ko.po | 5 ++++- locale/nl.po | 5 ++++- locale/pl.po | 5 ++++- locale/pt_BR.po | 5 ++++- locale/sv.po | 5 ++++- locale/zh_Latn_pinyin.po | 5 ++++- 17 files changed, 68 insertions(+), 17 deletions(-) diff --git a/locale/ID.po b/locale/ID.po index 8653094ab4..ac07d1544d 100644 --- a/locale/ID.po +++ b/locale/ID.po @@ -698,6 +698,7 @@ msgstr "" "digunakan" #: ports/esp32s2/common-hal/alarm/pin/PinAlarm.c +#: ports/nrf/common-hal/alarm/pin/PinAlarm.c msgid "Cannot wake on pin edge. Only level." msgstr "" @@ -1307,7 +1308,8 @@ msgstr "Fase tidak valid" #: ports/atmel-samd/common-hal/audioio/AudioOut.c #: ports/atmel-samd/common-hal/touchio/TouchIn.c #: ports/esp32s2/common-hal/alarm/touch/TouchAlarm.c -#: ports/esp32s2/common-hal/touchio/TouchIn.c shared-bindings/pwmio/PWMOut.c +#: ports/esp32s2/common-hal/touchio/TouchIn.c +#: ports/nrf/common-hal/alarm/pin/PinAlarm.c shared-bindings/pwmio/PWMOut.c #: shared-module/rgbmatrix/RGBMatrix.c msgid "Invalid pin" msgstr "Pin tidak valid" @@ -1690,6 +1692,7 @@ msgid "Only one TouchAlarm can be set in deep sleep." msgstr "" #: ports/esp32s2/common-hal/alarm/time/TimeAlarm.c +#: ports/nrf/common-hal/alarm/time/TimeAlarm.c msgid "Only one alarm.time alarm can be set." msgstr "" diff --git a/locale/cs.po b/locale/cs.po index dab2eb901a..5c1d1d77ba 100644 --- a/locale/cs.po +++ b/locale/cs.po @@ -684,6 +684,7 @@ msgid "Cannot vary frequency on a timer that is already in use" msgstr "" #: ports/esp32s2/common-hal/alarm/pin/PinAlarm.c +#: ports/nrf/common-hal/alarm/pin/PinAlarm.c msgid "Cannot wake on pin edge. Only level." msgstr "" @@ -1288,7 +1289,8 @@ msgstr "" #: ports/atmel-samd/common-hal/audioio/AudioOut.c #: ports/atmel-samd/common-hal/touchio/TouchIn.c #: ports/esp32s2/common-hal/alarm/touch/TouchAlarm.c -#: ports/esp32s2/common-hal/touchio/TouchIn.c shared-bindings/pwmio/PWMOut.c +#: ports/esp32s2/common-hal/touchio/TouchIn.c +#: ports/nrf/common-hal/alarm/pin/PinAlarm.c shared-bindings/pwmio/PWMOut.c #: shared-module/rgbmatrix/RGBMatrix.c msgid "Invalid pin" msgstr "" @@ -1666,6 +1668,7 @@ msgid "Only one TouchAlarm can be set in deep sleep." msgstr "" #: ports/esp32s2/common-hal/alarm/time/TimeAlarm.c +#: ports/nrf/common-hal/alarm/time/TimeAlarm.c msgid "Only one alarm.time alarm can be set." msgstr "" diff --git a/locale/de_DE.po b/locale/de_DE.po index d8d3727bb6..e71d79d94f 100644 --- a/locale/de_DE.po +++ b/locale/de_DE.po @@ -694,6 +694,7 @@ msgstr "" "Die Frequenz eines bereits verwendeten Timers kann nicht variiert werden" #: ports/esp32s2/common-hal/alarm/pin/PinAlarm.c +#: ports/nrf/common-hal/alarm/pin/PinAlarm.c msgid "Cannot wake on pin edge. Only level." msgstr "Kann nicht auf Flanke wecken, nur auf Level." @@ -1308,7 +1309,8 @@ msgstr "Ungültige Phase" #: ports/atmel-samd/common-hal/audioio/AudioOut.c #: ports/atmel-samd/common-hal/touchio/TouchIn.c #: ports/esp32s2/common-hal/alarm/touch/TouchAlarm.c -#: ports/esp32s2/common-hal/touchio/TouchIn.c shared-bindings/pwmio/PWMOut.c +#: ports/esp32s2/common-hal/touchio/TouchIn.c +#: ports/nrf/common-hal/alarm/pin/PinAlarm.c shared-bindings/pwmio/PWMOut.c #: shared-module/rgbmatrix/RGBMatrix.c msgid "Invalid pin" msgstr "Ungültiger Pin" @@ -1693,6 +1695,7 @@ msgid "Only one TouchAlarm can be set in deep sleep." msgstr "" #: ports/esp32s2/common-hal/alarm/time/TimeAlarm.c +#: ports/nrf/common-hal/alarm/time/TimeAlarm.c msgid "Only one alarm.time alarm can be set." msgstr "" diff --git a/locale/el.po b/locale/el.po index c2a73c577a..de02ad0ca2 100644 --- a/locale/el.po +++ b/locale/el.po @@ -681,6 +681,7 @@ msgid "Cannot vary frequency on a timer that is already in use" msgstr "" #: ports/esp32s2/common-hal/alarm/pin/PinAlarm.c +#: ports/nrf/common-hal/alarm/pin/PinAlarm.c msgid "Cannot wake on pin edge. Only level." msgstr "" @@ -1285,7 +1286,8 @@ msgstr "" #: ports/atmel-samd/common-hal/audioio/AudioOut.c #: ports/atmel-samd/common-hal/touchio/TouchIn.c #: ports/esp32s2/common-hal/alarm/touch/TouchAlarm.c -#: ports/esp32s2/common-hal/touchio/TouchIn.c shared-bindings/pwmio/PWMOut.c +#: ports/esp32s2/common-hal/touchio/TouchIn.c +#: ports/nrf/common-hal/alarm/pin/PinAlarm.c shared-bindings/pwmio/PWMOut.c #: shared-module/rgbmatrix/RGBMatrix.c msgid "Invalid pin" msgstr "" @@ -1663,6 +1665,7 @@ msgid "Only one TouchAlarm can be set in deep sleep." msgstr "" #: ports/esp32s2/common-hal/alarm/time/TimeAlarm.c +#: ports/nrf/common-hal/alarm/time/TimeAlarm.c msgid "Only one alarm.time alarm can be set." msgstr "" diff --git a/locale/en_GB.po b/locale/en_GB.po index 2f1b10a1f3..d8ddf8f91f 100644 --- a/locale/en_GB.po +++ b/locale/en_GB.po @@ -692,6 +692,7 @@ msgid "Cannot vary frequency on a timer that is already in use" msgstr "Cannot vary frequency on a timer that is already in use" #: ports/esp32s2/common-hal/alarm/pin/PinAlarm.c +#: ports/nrf/common-hal/alarm/pin/PinAlarm.c msgid "Cannot wake on pin edge. Only level." msgstr "Cannot wake on pin edge. Only level." @@ -1302,7 +1303,8 @@ msgstr "Invalid phase" #: ports/atmel-samd/common-hal/audioio/AudioOut.c #: ports/atmel-samd/common-hal/touchio/TouchIn.c #: ports/esp32s2/common-hal/alarm/touch/TouchAlarm.c -#: ports/esp32s2/common-hal/touchio/TouchIn.c shared-bindings/pwmio/PWMOut.c +#: ports/esp32s2/common-hal/touchio/TouchIn.c +#: ports/nrf/common-hal/alarm/pin/PinAlarm.c shared-bindings/pwmio/PWMOut.c #: shared-module/rgbmatrix/RGBMatrix.c msgid "Invalid pin" msgstr "Invalid pin" @@ -1684,6 +1686,7 @@ msgid "Only one TouchAlarm can be set in deep sleep." msgstr "Only one TouchAlarm can be set in deep sleep." #: ports/esp32s2/common-hal/alarm/time/TimeAlarm.c +#: ports/nrf/common-hal/alarm/time/TimeAlarm.c msgid "Only one alarm.time alarm can be set." msgstr "Only one alarm.time alarm can be set." diff --git a/locale/es.po b/locale/es.po index 0bb384dd9d..61ec78ce0f 100644 --- a/locale/es.po +++ b/locale/es.po @@ -701,6 +701,7 @@ msgid "Cannot vary frequency on a timer that is already in use" msgstr "No puede variar la frecuencia en un temporizador que ya está en uso" #: ports/esp32s2/common-hal/alarm/pin/PinAlarm.c +#: ports/nrf/common-hal/alarm/pin/PinAlarm.c msgid "Cannot wake on pin edge. Only level." msgstr "No puede despertar en pin edge, solo en nivel." @@ -1319,7 +1320,8 @@ msgstr "Fase inválida" #: ports/atmel-samd/common-hal/audioio/AudioOut.c #: ports/atmel-samd/common-hal/touchio/TouchIn.c #: ports/esp32s2/common-hal/alarm/touch/TouchAlarm.c -#: ports/esp32s2/common-hal/touchio/TouchIn.c shared-bindings/pwmio/PWMOut.c +#: ports/esp32s2/common-hal/touchio/TouchIn.c +#: ports/nrf/common-hal/alarm/pin/PinAlarm.c shared-bindings/pwmio/PWMOut.c #: shared-module/rgbmatrix/RGBMatrix.c msgid "Invalid pin" msgstr "Pin inválido" @@ -1707,6 +1709,7 @@ msgid "Only one TouchAlarm can be set in deep sleep." msgstr "Solamente una TouchAlarm puede ser configurada durante deep sleep." #: ports/esp32s2/common-hal/alarm/time/TimeAlarm.c +#: ports/nrf/common-hal/alarm/time/TimeAlarm.c msgid "Only one alarm.time alarm can be set." msgstr "Solamente una alarm.time puede ser configurada." diff --git a/locale/fil.po b/locale/fil.po index f5727a9da3..511b273934 100644 --- a/locale/fil.po +++ b/locale/fil.po @@ -688,6 +688,7 @@ msgid "Cannot vary frequency on a timer that is already in use" msgstr "" #: ports/esp32s2/common-hal/alarm/pin/PinAlarm.c +#: ports/nrf/common-hal/alarm/pin/PinAlarm.c msgid "Cannot wake on pin edge. Only level." msgstr "" @@ -1300,7 +1301,8 @@ msgstr "Mali ang phase" #: ports/atmel-samd/common-hal/audioio/AudioOut.c #: ports/atmel-samd/common-hal/touchio/TouchIn.c #: ports/esp32s2/common-hal/alarm/touch/TouchAlarm.c -#: ports/esp32s2/common-hal/touchio/TouchIn.c shared-bindings/pwmio/PWMOut.c +#: ports/esp32s2/common-hal/touchio/TouchIn.c +#: ports/nrf/common-hal/alarm/pin/PinAlarm.c shared-bindings/pwmio/PWMOut.c #: shared-module/rgbmatrix/RGBMatrix.c msgid "Invalid pin" msgstr "Mali ang pin" @@ -1681,6 +1683,7 @@ msgid "Only one TouchAlarm can be set in deep sleep." msgstr "" #: ports/esp32s2/common-hal/alarm/time/TimeAlarm.c +#: ports/nrf/common-hal/alarm/time/TimeAlarm.c msgid "Only one alarm.time alarm can be set." msgstr "" diff --git a/locale/fr.po b/locale/fr.po index 7660ce4169..fee1a85a25 100644 --- a/locale/fr.po +++ b/locale/fr.po @@ -707,6 +707,7 @@ msgid "Cannot vary frequency on a timer that is already in use" msgstr "Impossible de faire varier la fréquence sur un minuteur déjà utilisée" #: ports/esp32s2/common-hal/alarm/pin/PinAlarm.c +#: ports/nrf/common-hal/alarm/pin/PinAlarm.c msgid "Cannot wake on pin edge. Only level." msgstr "Ne peut reveillé sur le board de broche. Seuleument à niveau." @@ -1331,7 +1332,8 @@ msgstr "Phase invalide" #: ports/atmel-samd/common-hal/audioio/AudioOut.c #: ports/atmel-samd/common-hal/touchio/TouchIn.c #: ports/esp32s2/common-hal/alarm/touch/TouchAlarm.c -#: ports/esp32s2/common-hal/touchio/TouchIn.c shared-bindings/pwmio/PWMOut.c +#: ports/esp32s2/common-hal/touchio/TouchIn.c +#: ports/nrf/common-hal/alarm/pin/PinAlarm.c shared-bindings/pwmio/PWMOut.c #: shared-module/rgbmatrix/RGBMatrix.c msgid "Invalid pin" msgstr "Broche invalide" @@ -1717,6 +1719,7 @@ msgid "Only one TouchAlarm can be set in deep sleep." msgstr "Seulement une TouchAlarm peu être réglée en someil profond." #: ports/esp32s2/common-hal/alarm/time/TimeAlarm.c +#: ports/nrf/common-hal/alarm/time/TimeAlarm.c msgid "Only one alarm.time alarm can be set." msgstr "Seulement une alarme alarm.time peut être réglée." diff --git a/locale/hi.po b/locale/hi.po index 4d23454770..4a4539ba2c 100644 --- a/locale/hi.po +++ b/locale/hi.po @@ -681,6 +681,7 @@ msgid "Cannot vary frequency on a timer that is already in use" msgstr "" #: ports/esp32s2/common-hal/alarm/pin/PinAlarm.c +#: ports/nrf/common-hal/alarm/pin/PinAlarm.c msgid "Cannot wake on pin edge. Only level." msgstr "" @@ -1285,7 +1286,8 @@ msgstr "" #: ports/atmel-samd/common-hal/audioio/AudioOut.c #: ports/atmel-samd/common-hal/touchio/TouchIn.c #: ports/esp32s2/common-hal/alarm/touch/TouchAlarm.c -#: ports/esp32s2/common-hal/touchio/TouchIn.c shared-bindings/pwmio/PWMOut.c +#: ports/esp32s2/common-hal/touchio/TouchIn.c +#: ports/nrf/common-hal/alarm/pin/PinAlarm.c shared-bindings/pwmio/PWMOut.c #: shared-module/rgbmatrix/RGBMatrix.c msgid "Invalid pin" msgstr "" @@ -1663,6 +1665,7 @@ msgid "Only one TouchAlarm can be set in deep sleep." msgstr "" #: ports/esp32s2/common-hal/alarm/time/TimeAlarm.c +#: ports/nrf/common-hal/alarm/time/TimeAlarm.c msgid "Only one alarm.time alarm can be set." msgstr "" diff --git a/locale/it_IT.po b/locale/it_IT.po index e39ad7594f..f641552686 100644 --- a/locale/it_IT.po +++ b/locale/it_IT.po @@ -698,6 +698,7 @@ msgid "Cannot vary frequency on a timer that is already in use" msgstr "" #: ports/esp32s2/common-hal/alarm/pin/PinAlarm.c +#: ports/nrf/common-hal/alarm/pin/PinAlarm.c msgid "Cannot wake on pin edge. Only level." msgstr "" @@ -1311,7 +1312,8 @@ msgstr "Fase non valida" #: ports/atmel-samd/common-hal/audioio/AudioOut.c #: ports/atmel-samd/common-hal/touchio/TouchIn.c #: ports/esp32s2/common-hal/alarm/touch/TouchAlarm.c -#: ports/esp32s2/common-hal/touchio/TouchIn.c shared-bindings/pwmio/PWMOut.c +#: ports/esp32s2/common-hal/touchio/TouchIn.c +#: ports/nrf/common-hal/alarm/pin/PinAlarm.c shared-bindings/pwmio/PWMOut.c #: shared-module/rgbmatrix/RGBMatrix.c msgid "Invalid pin" msgstr "Pin non valido" @@ -1695,6 +1697,7 @@ msgid "Only one TouchAlarm can be set in deep sleep." msgstr "" #: ports/esp32s2/common-hal/alarm/time/TimeAlarm.c +#: ports/nrf/common-hal/alarm/time/TimeAlarm.c msgid "Only one alarm.time alarm can be set." msgstr "" diff --git a/locale/ja.po b/locale/ja.po index 5df538a05d..c057a9d8a7 100644 --- a/locale/ja.po +++ b/locale/ja.po @@ -690,6 +690,7 @@ msgid "Cannot vary frequency on a timer that is already in use" msgstr "使用中のタイマー上では周波数を変えられません" #: ports/esp32s2/common-hal/alarm/pin/PinAlarm.c +#: ports/nrf/common-hal/alarm/pin/PinAlarm.c msgid "Cannot wake on pin edge. Only level." msgstr "" @@ -1298,7 +1299,8 @@ msgstr "不正なphase" #: ports/atmel-samd/common-hal/audioio/AudioOut.c #: ports/atmel-samd/common-hal/touchio/TouchIn.c #: ports/esp32s2/common-hal/alarm/touch/TouchAlarm.c -#: ports/esp32s2/common-hal/touchio/TouchIn.c shared-bindings/pwmio/PWMOut.c +#: ports/esp32s2/common-hal/touchio/TouchIn.c +#: ports/nrf/common-hal/alarm/pin/PinAlarm.c shared-bindings/pwmio/PWMOut.c #: shared-module/rgbmatrix/RGBMatrix.c msgid "Invalid pin" msgstr "不正なピン" @@ -1678,6 +1680,7 @@ msgid "Only one TouchAlarm can be set in deep sleep." msgstr "" #: ports/esp32s2/common-hal/alarm/time/TimeAlarm.c +#: ports/nrf/common-hal/alarm/time/TimeAlarm.c msgid "Only one alarm.time alarm can be set." msgstr "" diff --git a/locale/ko.po b/locale/ko.po index 06edd419c2..5add85aed8 100644 --- a/locale/ko.po +++ b/locale/ko.po @@ -684,6 +684,7 @@ msgid "Cannot vary frequency on a timer that is already in use" msgstr "" #: ports/esp32s2/common-hal/alarm/pin/PinAlarm.c +#: ports/nrf/common-hal/alarm/pin/PinAlarm.c msgid "Cannot wake on pin edge. Only level." msgstr "" @@ -1288,7 +1289,8 @@ msgstr "단계가 잘못되었습니다" #: ports/atmel-samd/common-hal/audioio/AudioOut.c #: ports/atmel-samd/common-hal/touchio/TouchIn.c #: ports/esp32s2/common-hal/alarm/touch/TouchAlarm.c -#: ports/esp32s2/common-hal/touchio/TouchIn.c shared-bindings/pwmio/PWMOut.c +#: ports/esp32s2/common-hal/touchio/TouchIn.c +#: ports/nrf/common-hal/alarm/pin/PinAlarm.c shared-bindings/pwmio/PWMOut.c #: shared-module/rgbmatrix/RGBMatrix.c msgid "Invalid pin" msgstr "핀이 잘못되었습니다" @@ -1666,6 +1668,7 @@ msgid "Only one TouchAlarm can be set in deep sleep." msgstr "" #: ports/esp32s2/common-hal/alarm/time/TimeAlarm.c +#: ports/nrf/common-hal/alarm/time/TimeAlarm.c msgid "Only one alarm.time alarm can be set." msgstr "" diff --git a/locale/nl.po b/locale/nl.po index 57ff2337b8..3a450d2112 100644 --- a/locale/nl.po +++ b/locale/nl.po @@ -688,6 +688,7 @@ msgid "Cannot vary frequency on a timer that is already in use" msgstr "Kan de frequentie van een timer die al in gebruik is niet variëren" #: ports/esp32s2/common-hal/alarm/pin/PinAlarm.c +#: ports/nrf/common-hal/alarm/pin/PinAlarm.c msgid "Cannot wake on pin edge. Only level." msgstr "" @@ -1299,7 +1300,8 @@ msgstr "Ongeldige fase" #: ports/atmel-samd/common-hal/audioio/AudioOut.c #: ports/atmel-samd/common-hal/touchio/TouchIn.c #: ports/esp32s2/common-hal/alarm/touch/TouchAlarm.c -#: ports/esp32s2/common-hal/touchio/TouchIn.c shared-bindings/pwmio/PWMOut.c +#: ports/esp32s2/common-hal/touchio/TouchIn.c +#: ports/nrf/common-hal/alarm/pin/PinAlarm.c shared-bindings/pwmio/PWMOut.c #: shared-module/rgbmatrix/RGBMatrix.c msgid "Invalid pin" msgstr "Ongeldige pin" @@ -1683,6 +1685,7 @@ msgid "Only one TouchAlarm can be set in deep sleep." msgstr "" #: ports/esp32s2/common-hal/alarm/time/TimeAlarm.c +#: ports/nrf/common-hal/alarm/time/TimeAlarm.c msgid "Only one alarm.time alarm can be set." msgstr "Slechts één alarm.time alarm kan worden ingesteld." diff --git a/locale/pl.po b/locale/pl.po index 984ed10275..1062baf66a 100644 --- a/locale/pl.po +++ b/locale/pl.po @@ -688,6 +688,7 @@ msgid "Cannot vary frequency on a timer that is already in use" msgstr "Nie można zmieniać częstotliwości timera, który jest już używany" #: ports/esp32s2/common-hal/alarm/pin/PinAlarm.c +#: ports/nrf/common-hal/alarm/pin/PinAlarm.c msgid "Cannot wake on pin edge. Only level." msgstr "" @@ -1298,7 +1299,8 @@ msgstr "Zła faza" #: ports/atmel-samd/common-hal/audioio/AudioOut.c #: ports/atmel-samd/common-hal/touchio/TouchIn.c #: ports/esp32s2/common-hal/alarm/touch/TouchAlarm.c -#: ports/esp32s2/common-hal/touchio/TouchIn.c shared-bindings/pwmio/PWMOut.c +#: ports/esp32s2/common-hal/touchio/TouchIn.c +#: ports/nrf/common-hal/alarm/pin/PinAlarm.c shared-bindings/pwmio/PWMOut.c #: shared-module/rgbmatrix/RGBMatrix.c msgid "Invalid pin" msgstr "Zła nóżka" @@ -1676,6 +1678,7 @@ msgid "Only one TouchAlarm can be set in deep sleep." msgstr "" #: ports/esp32s2/common-hal/alarm/time/TimeAlarm.c +#: ports/nrf/common-hal/alarm/time/TimeAlarm.c msgid "Only one alarm.time alarm can be set." msgstr "" diff --git a/locale/pt_BR.po b/locale/pt_BR.po index 58a706d216..afde2984c1 100644 --- a/locale/pt_BR.po +++ b/locale/pt_BR.po @@ -705,6 +705,7 @@ msgid "Cannot vary frequency on a timer that is already in use" msgstr "Não é possível variar a frequência em um timer que já esteja em uso" #: ports/esp32s2/common-hal/alarm/pin/PinAlarm.c +#: ports/nrf/common-hal/alarm/pin/PinAlarm.c msgid "Cannot wake on pin edge. Only level." msgstr "Não é possível acordar (wake) no pino edge. Nível apenas." @@ -1322,7 +1323,8 @@ msgstr "Fase Inválida" #: ports/atmel-samd/common-hal/audioio/AudioOut.c #: ports/atmel-samd/common-hal/touchio/TouchIn.c #: ports/esp32s2/common-hal/alarm/touch/TouchAlarm.c -#: ports/esp32s2/common-hal/touchio/TouchIn.c shared-bindings/pwmio/PWMOut.c +#: ports/esp32s2/common-hal/touchio/TouchIn.c +#: ports/nrf/common-hal/alarm/pin/PinAlarm.c shared-bindings/pwmio/PWMOut.c #: shared-module/rgbmatrix/RGBMatrix.c msgid "Invalid pin" msgstr "Pino inválido" @@ -1707,6 +1709,7 @@ msgid "Only one TouchAlarm can be set in deep sleep." msgstr "Apenas um TouchAlarm pode ser colocado em deep sleep." #: ports/esp32s2/common-hal/alarm/time/TimeAlarm.c +#: ports/nrf/common-hal/alarm/time/TimeAlarm.c msgid "Only one alarm.time alarm can be set." msgstr "Apenas um alarme alarm.time pode ser definido." diff --git a/locale/sv.po b/locale/sv.po index 7cee54cd84..0423871517 100644 --- a/locale/sv.po +++ b/locale/sv.po @@ -694,6 +694,7 @@ msgid "Cannot vary frequency on a timer that is already in use" msgstr "Det går inte att ändra frekvensen på en timer som redan används" #: ports/esp32s2/common-hal/alarm/pin/PinAlarm.c +#: ports/nrf/common-hal/alarm/pin/PinAlarm.c msgid "Cannot wake on pin edge. Only level." msgstr "Kan inte vakna på nivåskift, enbart nivå." @@ -1306,7 +1307,8 @@ msgstr "Ogiltig fas" #: ports/atmel-samd/common-hal/audioio/AudioOut.c #: ports/atmel-samd/common-hal/touchio/TouchIn.c #: ports/esp32s2/common-hal/alarm/touch/TouchAlarm.c -#: ports/esp32s2/common-hal/touchio/TouchIn.c shared-bindings/pwmio/PWMOut.c +#: ports/esp32s2/common-hal/touchio/TouchIn.c +#: ports/nrf/common-hal/alarm/pin/PinAlarm.c shared-bindings/pwmio/PWMOut.c #: shared-module/rgbmatrix/RGBMatrix.c msgid "Invalid pin" msgstr "Ogiltig pinne" @@ -1690,6 +1692,7 @@ msgid "Only one TouchAlarm can be set in deep sleep." msgstr "Endast ett TouchAlarm kan ställas in för djupsömn." #: ports/esp32s2/common-hal/alarm/time/TimeAlarm.c +#: ports/nrf/common-hal/alarm/time/TimeAlarm.c msgid "Only one alarm.time alarm can be set." msgstr "Endast ett alarm.time kan ställas in." diff --git a/locale/zh_Latn_pinyin.po b/locale/zh_Latn_pinyin.po index 49bf62a3a6..7c7db58dcd 100644 --- a/locale/zh_Latn_pinyin.po +++ b/locale/zh_Latn_pinyin.po @@ -695,6 +695,7 @@ msgid "Cannot vary frequency on a timer that is already in use" msgstr "Wúfǎ gēnggǎi yǐ zài shǐyòng de jìshí qì shàng de pínlǜ" #: ports/esp32s2/common-hal/alarm/pin/PinAlarm.c +#: ports/nrf/common-hal/alarm/pin/PinAlarm.c msgid "Cannot wake on pin edge. Only level." msgstr "wú fǎ zài yǐn jiǎo biān yuán huàn xǐng. jǐn jí bié." @@ -1308,7 +1309,8 @@ msgstr "Jiēduàn wúxiào" #: ports/atmel-samd/common-hal/audioio/AudioOut.c #: ports/atmel-samd/common-hal/touchio/TouchIn.c #: ports/esp32s2/common-hal/alarm/touch/TouchAlarm.c -#: ports/esp32s2/common-hal/touchio/TouchIn.c shared-bindings/pwmio/PWMOut.c +#: ports/esp32s2/common-hal/touchio/TouchIn.c +#: ports/nrf/common-hal/alarm/pin/PinAlarm.c shared-bindings/pwmio/PWMOut.c #: shared-module/rgbmatrix/RGBMatrix.c msgid "Invalid pin" msgstr "Wúxiào de yǐn jiǎo" @@ -1692,6 +1694,7 @@ msgid "Only one TouchAlarm can be set in deep sleep." msgstr "zhǐ yǒu yí gè chù mō bì kě yǐ shè zhì zài shēn dù shuì mián." #: ports/esp32s2/common-hal/alarm/time/TimeAlarm.c +#: ports/nrf/common-hal/alarm/time/TimeAlarm.c msgid "Only one alarm.time alarm can be set." msgstr "zhǐ néng shè zhì yí gè bào jǐng." From 5c4500dbfab8120bb13e5e5e8e12ba2d5de2fa7d Mon Sep 17 00:00:00 2001 From: Lucian Copeland Date: Wed, 28 Apr 2021 15:35:15 -0400 Subject: [PATCH 67/67] Fix MP type macros --- ports/nrf/common-hal/alarm/pin/PinAlarm.c | 4 ++-- ports/nrf/common-hal/alarm/time/TimeAlarm.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/ports/nrf/common-hal/alarm/pin/PinAlarm.c b/ports/nrf/common-hal/alarm/pin/PinAlarm.c index 59bb4a84a1..3c38cad1ac 100644 --- a/ports/nrf/common-hal/alarm/pin/PinAlarm.c +++ b/ports/nrf/common-hal/alarm/pin/PinAlarm.c @@ -93,7 +93,7 @@ bool alarm_pin_pinalarm_woke_us_up(void) { mp_obj_t alarm_pin_pinalarm_get_wakeup_alarm(size_t n_alarms, const mp_obj_t *alarms) { // First, check to see if we match any given alarms. for (size_t i = 0; i < n_alarms; i++) { - if (!MP_OBJ_IS_TYPE(alarms[i], &alarm_pin_pinalarm_type)) { + if (!mp_obj_is_type(alarms[i], &alarm_pin_pinalarm_type)) { continue; } alarm_pin_pinalarm_obj_t *alarm = MP_OBJ_TO_PTR(alarms[i]); @@ -197,7 +197,7 @@ void alarm_pin_pinalarm_set_alarms(bool deep_sleep, size_t n_alarms, const mp_ob int pin_number = -1; for (size_t i = 0; i < n_alarms; i++) { - if (!MP_OBJ_IS_TYPE(alarms[i], &alarm_pin_pinalarm_type)) { + if (!mp_obj_is_type(alarms[i], &alarm_pin_pinalarm_type)) { continue; } alarm_pin_pinalarm_obj_t *alarm = MP_OBJ_TO_PTR(alarms[i]); diff --git a/ports/nrf/common-hal/alarm/time/TimeAlarm.c b/ports/nrf/common-hal/alarm/time/TimeAlarm.c index 09409e7ce4..6fb1aea1ef 100644 --- a/ports/nrf/common-hal/alarm/time/TimeAlarm.c +++ b/ports/nrf/common-hal/alarm/time/TimeAlarm.c @@ -43,7 +43,7 @@ mp_float_t common_hal_alarm_time_timealarm_get_monotonic_time(alarm_time_timeala 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_timealarm_type)) { + if (mp_obj_is_type(alarms[i], &alarm_time_timealarm_type)) { return alarms[i]; } } @@ -82,7 +82,7 @@ void alarm_time_timealarm_set_alarms(bool deep_sleep, size_t n_alarms, const mp_ wakeup_time_saved = 0; for (size_t i = 0; i < n_alarms; i++) { - if (!MP_OBJ_IS_TYPE(alarms[i], &alarm_time_timealarm_type)) { + if (!mp_obj_is_type(alarms[i], &alarm_time_timealarm_type)) { continue; } if (timealarm_set) {