From 40118bcf57f026fd6a58733501c759a9ba87e835 Mon Sep 17 00:00:00 2001 From: Scott Shawcroft Date: Wed, 2 Dec 2020 18:05:29 -0800 Subject: [PATCH] Add `board_deinit` for use with sleep This changes lots of files to unify `board.h` across ports. It adds `board_deinit` when CIRCUITPY_ALARM is set. `main.c` uses it to deinit the board before deep sleeping (even when pretending.) Deep sleep is now a two step process for the port. First, the port should prepare to deep sleep based on the given alarms. It should set alarms for both deep and pretend sleep. In particular, the pretend versions should be set immediately so that we don't miss an alarm as we shutdown. These alarms should also wake from `port_idle_until_interrupt` which is used when pretending to deep sleep. Second, when real deep sleeping, `alarm_enter_deep_sleep` is called. The port should set any alarms it didn't during prepare based on data it saved internally during prepare. ESP32-S2 sleep is a bit reorganized to locate more logic with TimeAlarm. This will help it scale to more alarm types. Fixes #3786 --- Makefile | 2 +- locale/circuitpython.pot | 19 ++- main.c | 76 +++++++-- .../atmel-samd/boards/8086_commander/board.c | 2 +- .../boards/aloriumtech_evo_m51/board.c | 2 +- .../atmel-samd/boards/arduino_mkr1300/board.c | 2 +- .../atmel-samd/boards/arduino_mkrzero/board.c | 2 +- .../boards/arduino_nano_33_iot/board.c | 2 +- ports/atmel-samd/boards/arduino_zero/board.c | 2 +- .../boards/bast_pro_mini_m0/board.c | 2 +- .../boards/bdmicro_vina_d21/board.c | 2 +- .../boards/bdmicro_vina_d51/board.c | 2 +- ports/atmel-samd/boards/blm_badge/board.c | 4 +- ports/atmel-samd/boards/board.h | 47 ------ .../boards/capablerobot_usbhub/board.c | 2 +- .../atmel-samd/boards/catwan_usbstick/board.c | 2 +- .../boards/circuitbrains_basic_m0/board.c | 2 +- .../boards/circuitbrains_deluxe_m4/board.c | 2 +- .../boards/circuitplayground_express/board.c | 4 +- .../circuitplayground_express_crickit/board.c | 4 +- .../board.c | 4 +- ports/atmel-samd/boards/cp32-m4/board.c | 2 +- ports/atmel-samd/boards/cp_sapling_m0/board.c | 2 +- .../boards/cp_sapling_m0_spiflash/board.c | 2 +- .../atmel-samd/boards/datalore_ip_m4/board.c | 2 +- .../atmel-samd/boards/datum_distance/board.c | 2 +- ports/atmel-samd/boards/datum_imu/board.c | 2 +- ports/atmel-samd/boards/datum_light/board.c | 2 +- ports/atmel-samd/boards/datum_weather/board.c | 2 +- .../boards/dynossat_edu_eps/board.c | 2 +- .../boards/dynossat_edu_obc/board.c | 2 +- .../boards/escornabot_makech/board.c | 2 +- .../boards/feather_m0_adalogger/board.c | 2 +- .../boards/feather_m0_basic/board.c | 2 +- .../boards/feather_m0_express/board.c | 2 +- .../boards/feather_m0_express_crickit/board.c | 2 +- .../boards/feather_m0_rfm69/board.c | 2 +- .../boards/feather_m0_rfm9x/board.c | 2 +- .../boards/feather_m0_supersized/board.c | 2 +- .../atmel-samd/boards/feather_m4_can/board.c | 2 +- .../boards/feather_m4_express/board.c | 2 +- .../boards/feather_radiofruit_zigbee/board.c | 2 +- ports/atmel-samd/boards/fluff_m0/board.c | 2 +- ports/atmel-samd/boards/gemma_m0/board.c | 2 +- .../boards/grandcentral_m4_express/board.c | 2 +- .../boards/hallowing_m0_express/board.c | 2 +- .../boards/hallowing_m0_express/pins.c | 2 +- .../boards/hallowing_m4_express/board.c | 2 +- .../boards/itsybitsy_m0_express/board.c | 2 +- .../boards/itsybitsy_m4_express/board.c | 2 +- .../atmel-samd/boards/kicksat-sprite/board.c | 2 +- ports/atmel-samd/boards/kicksat-sprite/pins.c | 2 +- .../boards/loc_ber_m4_base_board/board.c | 2 +- .../atmel-samd/boards/matrixportal_m4/board.c | 2 +- ports/atmel-samd/boards/meowmeow/board.c | 2 +- .../boards/metro_m0_express/board.c | 2 +- .../boards/metro_m4_airlift_lite/board.c | 2 +- .../boards/metro_m4_express/board.c | 2 +- ports/atmel-samd/boards/mini_sam_m4/board.c | 2 +- ports/atmel-samd/boards/monster_m4sk/board.c | 2 +- ports/atmel-samd/boards/monster_m4sk/pins.c | 2 +- .../atmel-samd/boards/ndgarage_ndbit6/board.c | 2 +- .../boards/ndgarage_ndbit6_v2/board.c | 2 +- ports/atmel-samd/boards/nfc_copy_cat/board.c | 2 +- ports/atmel-samd/boards/openbook_m4/board.c | 2 +- ports/atmel-samd/boards/openbook_m4/pins.c | 2 +- ports/atmel-samd/boards/pewpew10/board.c | 2 +- ports/atmel-samd/boards/pewpew_m4/board.c | 2 +- ports/atmel-samd/boards/picoplanet/board.c | 2 +- ports/atmel-samd/boards/pirkey_m0/board.c | 2 +- ports/atmel-samd/boards/pybadge/board.c | 4 +- ports/atmel-samd/boards/pybadge/pins.c | 2 +- .../atmel-samd/boards/pybadge_airlift/board.c | 4 +- .../atmel-samd/boards/pybadge_airlift/pins.c | 2 +- ports/atmel-samd/boards/pycubed/board.c | 2 +- ports/atmel-samd/boards/pycubed/pins.c | 2 +- ports/atmel-samd/boards/pycubed_mram/board.c | 2 +- ports/atmel-samd/boards/pycubed_mram/pins.c | 2 +- ports/atmel-samd/boards/pygamer/board.c | 4 +- ports/atmel-samd/boards/pygamer/pins.c | 2 +- .../atmel-samd/boards/pygamer_advance/board.c | 4 +- .../atmel-samd/boards/pygamer_advance/pins.c | 2 +- ports/atmel-samd/boards/pyportal/board.c | 2 +- ports/atmel-samd/boards/pyportal/pins.c | 2 +- .../atmel-samd/boards/pyportal_titano/board.c | 2 +- .../atmel-samd/boards/pyportal_titano/pins.c | 2 +- ports/atmel-samd/boards/pyruler/board.c | 2 +- ports/atmel-samd/boards/qtpy_m0/board.c | 2 +- .../boards/qtpy_m0_haxpress/board.c | 2 +- ports/atmel-samd/boards/robohatmm1_m4/board.c | 2 +- ports/atmel-samd/boards/sam32/board.c | 2 +- .../atmel-samd/boards/same54_xplained/board.c | 2 +- .../boards/seeeduino_wio_terminal/board.c | 2 +- .../atmel-samd/boards/seeeduino_xiao/board.c | 2 +- ports/atmel-samd/boards/serpente/board.c | 2 +- ports/atmel-samd/boards/shirtty/board.c | 2 +- ports/atmel-samd/boards/snekboard/board.c | 2 +- .../boards/sparkfun_lumidrive/board.c | 2 +- .../sparkfun_qwiic_micro_no_flash/board.c | 2 +- .../sparkfun_qwiic_micro_with_flash/board.c | 2 +- .../boards/sparkfun_redboard_turbo/board.c | 2 +- .../boards/sparkfun_samd21_dev/board.c | 2 +- .../boards/sparkfun_samd21_mini/board.c | 2 +- .../boards/sparkfun_samd51_thing_plus/board.c | 2 +- .../boards/stringcar_m0_express/board.c | 2 +- .../boards/trellis_m4_express/board.c | 2 +- ports/atmel-samd/boards/trinket_m0/board.c | 2 +- .../boards/trinket_m0_haxpress/board.c | 2 +- ports/atmel-samd/boards/uartlogger2/board.c | 2 +- ports/atmel-samd/boards/uchip/board.c | 2 +- ports/atmel-samd/boards/ugame10/board.c | 2 +- .../winterbloom_big_honking_button/board.c | 2 +- .../atmel-samd/boards/winterbloom_sol/board.c | 2 +- ports/atmel-samd/boards/xinabox_cc03/board.c | 2 +- ports/atmel-samd/boards/xinabox_cs11/board.c | 2 +- ports/atmel-samd/common-hal/busio/SPI.c | 2 +- ports/atmel-samd/common-hal/sdioio/SDCard.c | 1 - ports/atmel-samd/supervisor/port.c | 4 +- ports/cxd56/boards/board.h | 45 ------ ports/cxd56/boards/spresense/board.c | 2 +- ports/cxd56/supervisor/port.c | 4 +- .../adafruit_magtag_2.9_grayscale/board.c | 22 ++- .../boards/adafruit_metro_esp32s2/board.c | 5 +- .../boards/electroniccats_bastwifi/board.c | 5 +- .../esp32s2/boards/espressif_kaluga_1/board.c | 5 +- .../boards/espressif_saola_1_wroom/board.c | 5 +- .../boards/espressif_saola_1_wrover/board.c | 5 +- .../esp32s2/boards/microdev_micro_s2/board.c | 5 +- .../boards/muselab_nanoesp32_s2/board.c | 5 +- .../boards/targett_module_clip_wroom/board.c | 5 +- .../boards/targett_module_clip_wrover/board.c | 5 +- .../boards/unexpectedmaker_feathers2/board.c | 5 +- .../board.c | 5 +- ports/esp32s2/common-hal/alarm/__init__.c | 150 ++++++------------ .../esp32s2/common-hal/alarm/time/TimeAlarm.c | 64 ++++++++ .../esp32s2/common-hal/alarm/time/TimeAlarm.h | 7 + ports/esp32s2/common-hal/busio/SPI.c | 1 - ports/esp32s2/supervisor/port.c | 24 +-- ports/litex/boards/board.h | 45 ------ ports/litex/boards/fomu/board.c | 3 +- ports/litex/supervisor/port.c | 4 +- ports/mimxrt10xx/board.h | 1 + .../mimxrt10xx/boards/feather_m7_1011/board.c | 3 +- .../boards/feather_m7_1011/flash_config.c | 4 +- .../mimxrt10xx/boards/feather_m7_1011/pins.c | 2 +- .../boards/feather_mimxrt1011/board.c | 3 +- .../boards/feather_mimxrt1011/flash_config.c | 4 +- .../boards/feather_mimxrt1011/pins.c | 2 +- .../boards/feather_mimxrt1062/board.c | 3 +- .../boards/feather_mimxrt1062/flash_config.c | 3 +- .../boards/feather_mimxrt1062/pins.c | 2 +- .../boards/{board.h => flash_config.h} | 20 +-- ports/mimxrt10xx/boards/imxrt1010_evk/board.c | 3 +- .../boards/imxrt1010_evk/flash_config.c | 3 +- ports/mimxrt10xx/boards/imxrt1010_evk/pins.c | 2 +- ports/mimxrt10xx/boards/imxrt1020_evk/board.c | 3 +- .../boards/imxrt1020_evk/flash_config.c | 3 +- ports/mimxrt10xx/boards/imxrt1020_evk/pins.c | 2 +- ports/mimxrt10xx/boards/imxrt1060_evk/board.c | 3 +- .../boards/imxrt1060_evk/flash_config.c | 3 +- ports/mimxrt10xx/boards/imxrt1060_evk/pins.c | 2 +- ports/mimxrt10xx/boards/metro_m7_1011/board.c | 3 +- .../boards/metro_m7_1011/flash_config.c | 3 +- ports/mimxrt10xx/boards/metro_m7_1011/pins.c | 2 +- ports/mimxrt10xx/boards/teensy40/board.c | 3 +- .../mimxrt10xx/boards/teensy40/flash_config.c | 3 +- ports/mimxrt10xx/boards/teensy40/pins.c | 2 +- ports/mimxrt10xx/boards/teensy41/board.c | 3 +- .../mimxrt10xx/boards/teensy41/flash_config.c | 3 +- ports/mimxrt10xx/boards/teensy41/pins.c | 2 +- .../supervisor/flexspi_nor_flash_ops.c | 2 +- ports/mimxrt10xx/supervisor/internal_flash.c | 2 +- ports/mimxrt10xx/supervisor/port.c | 4 +- ports/nrf/boards/ADM_B_NRF52840_1/board.c | 2 +- ports/nrf/boards/TG-Watch02A/board.c | 2 +- ports/nrf/boards/aramcon_badge_2019/board.c | 2 +- ports/nrf/boards/arduino_nano_33_ble/board.c | 2 +- .../bless_dev_board_multi_sensor/board.c | 2 +- ports/nrf/boards/board.h | 45 ------ .../circuitplayground_bluefruit/board.c | 4 +- .../nrf/boards/clue_nrf52840_express/board.c | 2 +- ports/nrf/boards/clue_nrf52840_express/pins.c | 2 +- ports/nrf/boards/electronut_labs_blip/board.c | 2 +- .../nrf/boards/electronut_labs_papyr/board.c | 2 +- .../boards/feather_bluefruit_sense/board.c | 2 +- .../boards/feather_nrf52840_express/board.c | 2 +- ports/nrf/boards/hiibot_bluefi/board.c | 2 +- ports/nrf/boards/hiibot_bluefi/pins.c | 2 +- ports/nrf/boards/ikigaisense_vita/board.c | 2 +- .../boards/itsybitsy_nrf52840_express/board.c | 2 +- .../boards/makerdiary_m60_keyboard/board.c | 2 +- .../nrf/boards/makerdiary_m60_keyboard/pins.c | 2 +- .../makerdiary_nrf52840_m2_devkit/board.c | 2 +- .../makerdiary_nrf52840_m2_devkit/pins.c | 2 +- .../boards/makerdiary_nrf52840_mdk/board.c | 2 +- .../board.c | 2 +- .../nrf/boards/metro_nrf52840_express/board.c | 2 +- ports/nrf/boards/nice_nano/board.c | 2 +- ports/nrf/boards/ohs2020_badge/board.c | 2 +- ports/nrf/boards/particle_argon/board.c | 2 +- ports/nrf/boards/particle_boron/board.c | 2 +- ports/nrf/boards/particle_xenon/board.c | 2 +- ports/nrf/boards/pca10056/board.c | 2 +- ports/nrf/boards/pca10059/board.c | 2 +- ports/nrf/boards/pca10100/board.c | 2 +- ports/nrf/boards/pitaya_go/board.c | 2 +- ports/nrf/boards/raytac_mdbt50q-db-40/board.c | 2 +- ports/nrf/boards/simmel/board.c | 2 +- .../nrf/boards/sparkfun_nrf52840_mini/board.c | 2 +- ports/nrf/boards/teknikio_bluebird/board.c | 2 +- .../tinkeringtech_scoutmakes_azul/board.c | 2 +- ports/nrf/supervisor/port.c | 4 +- ports/stm/boards/board.h | 45 ------ ports/stm/boards/espruino_pico/board.c | 2 +- ports/stm/boards/espruino_wifi/board.c | 2 +- .../boards/feather_stm32f405_express/board.c | 2 +- ports/stm/boards/meowbit_v121/board.c | 2 +- ports/stm/boards/nucleo_f746zg/board.c | 2 +- ports/stm/boards/nucleo_f767zi/board.c | 2 +- ports/stm/boards/nucleo_h743zi_2/board.c | 2 +- ports/stm/boards/openmv_h7/board.c | 2 +- ports/stm/boards/pyb_nano_v2/board.c | 2 +- ports/stm/boards/pyboard_v11/board.c | 2 +- .../stm/boards/stm32f411ce_blackpill/board.c | 2 +- .../stm/boards/stm32f411ve_discovery/board.c | 2 +- .../stm/boards/stm32f412zg_discovery/board.c | 2 +- ports/stm/boards/stm32f4_discovery/board.c | 2 +- ports/stm/boards/stm32f746g_discovery/board.c | 2 +- ports/stm/boards/thunderpack_v11/board.c | 2 +- ports/stm/boards/thunderpack_v12/board.c | 2 +- ports/stm/common-hal/busio/SPI.c | 2 +- ports/stm/common-hal/sdioio/SDCard.c | 2 +- ports/stm/supervisor/port.c | 4 +- py/circuitpy_mpconfig.h | 6 + shared-bindings/alarm/__init__.c | 44 ++--- shared-bindings/alarm/__init__.h | 17 +- {ports/esp32s2/boards => supervisor}/board.h | 22 ++- supervisor/port.h | 9 +- supervisor/shared/board.c | 19 ++- supervisor/shared/board.h | 14 +- supervisor/shared/tick.c | 4 +- 241 files changed, 590 insertions(+), 675 deletions(-) delete mode 100644 ports/atmel-samd/boards/board.h delete mode 100644 ports/cxd56/boards/board.h delete mode 100644 ports/litex/boards/board.h create mode 100644 ports/mimxrt10xx/board.h rename ports/mimxrt10xx/boards/{board.h => flash_config.h} (75%) delete mode 100644 ports/nrf/boards/board.h delete mode 100644 ports/stm/boards/board.h rename {ports/esp32s2/boards => supervisor}/board.h (77%) diff --git a/Makefile b/Makefile index e553b85e8b..a1807c308f 100644 --- a/Makefile +++ b/Makefile @@ -265,7 +265,7 @@ update-frozen-libraries: @echo "Updating all frozen libraries to latest tagged version." cd frozen; for library in *; do cd $$library; ../../tools/git-checkout-latest-tag.sh; cd ..; done -one-of-each: samd21 samd51 esp32s2 litex mimxrt10xx nrf stm +one-of-each: samd21 litex mimxrt10xx nrf stm samd21: $(MAKE) -C ports/atmel-samd BOARD=trinket_m0 diff --git a/locale/circuitpython.pot b/locale/circuitpython.pot index b136e9dd26..11ca8c8140 100644 --- a/locale/circuitpython.pot +++ b/locale/circuitpython.pot @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-11-27 23:57-0500\n" +"POT-Creation-Date: 2020-12-08 09:56-0800\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -498,8 +498,8 @@ msgstr "" msgid "Buffer must be a multiple of 512 bytes" msgstr "" -#: shared-bindings/bitbangio/I2C.c shared-bindings/busdevice/I2CDevice.c -#: shared-bindings/busio/I2C.c +#: shared-bindings/adafruit_bus_device/I2CDevice.c +#: shared-bindings/bitbangio/I2C.c shared-bindings/busio/I2C.c msgid "Buffer must be at least length 1" msgstr "" @@ -1296,7 +1296,7 @@ msgstr "" msgid "No DMA channel found" msgstr "" -#: shared-module/busdevice/I2CDevice.c +#: shared-module/adafruit_bus_device/I2CDevice.c #, c-format msgid "No I2C device at address: %x" msgstr "" @@ -1503,6 +1503,7 @@ msgstr "" msgid "Pin does not have ADC capabilities" msgstr "" +#: shared-bindings/adafruit_bus_device/SPIDevice.c #: shared-bindings/digitalio/DigitalInOut.c msgid "Pin is input only" msgstr "" @@ -1555,7 +1556,11 @@ msgid "Prefix buffer must be on the heap" msgstr "" #: main.c -msgid "Press any key to enter the REPL. Use CTRL-D to reload." +msgid "Press any key to enter the REPL. Use CTRL-D to reload.\n" +msgstr "" + +#: main.c +msgid "Pretending to deep sleep until alarm, any key or file write.\n" msgstr "" #: shared-bindings/digitalio/DigitalInOut.c @@ -2026,6 +2031,10 @@ msgstr "" msgid "WiFi password must be between 8 and 63 characters" msgstr "" +#: main.c +msgid "Woken up by alarm.\n" +msgstr "" + #: ports/nrf/common-hal/_bleio/PacketBuffer.c msgid "Writes not supported on Characteristic" msgstr "" diff --git a/main.c b/main.c index 48c89d8adc..9eb4787299 100755 --- a/main.c +++ b/main.c @@ -46,6 +46,7 @@ #include "background.h" #include "mpconfigboard.h" #include "supervisor/background_callback.h" +#include "supervisor/board.h" #include "supervisor/cpu.h" #include "supervisor/filesystem.h" #include "supervisor/memory.h" @@ -64,8 +65,6 @@ #include "shared-bindings/microcontroller/Processor.h" #include "shared-bindings/supervisor/Runtime.h" -#include "boards/board.h" - #if CIRCUITPY_ALARM #include "shared-bindings/alarm/__init__.h" #endif @@ -303,13 +302,6 @@ STATIC bool run_code_py(safe_mode_t safe_mode) { if (result.return_code & PYEXEC_FORCED_EXIT) { return reload_requested; } - - #if CIRCUITPY_ALARM - if (result.return_code & PYEXEC_DEEP_SLEEP) { - common_hal_alarm_enter_deep_sleep(); - // Does not return. - } - #endif } // Program has finished running. @@ -326,24 +318,47 @@ STATIC bool run_code_py(safe_mode_t safe_mode) { rgb_status_animation_t animation; prep_rgb_status_animation(&result, found_main, safe_mode, &animation); + bool asleep = false; while (true) { - RUN_BACKGROUND_TASKS; if (reload_requested) { + #if CIRCUITPY_ALARM + if (asleep) { + board_init(); + } + #endif supervisor_set_run_reason(RUN_REASON_AUTO_RELOAD); reload_requested = false; return true; } if (serial_connected() && serial_bytes_available()) { + #if CIRCUITPY_ALARM + if (asleep) { + board_init(); + } + #endif // Skip REPL if reload was requested. bool ctrl_d = serial_read() == CHAR_CTRL_D; if (ctrl_d) { supervisor_set_run_reason(RUN_REASON_REPL_RELOAD); } - return (ctrl_d); + return ctrl_d; } + // Check for a deep sleep alarm and restart the VM. This can happen if + // an alarm alerts faster than our USB delay or if we pretended to deep + // sleep. + #if CIRCUITPY_ALARM + if (asleep && alarm_woken_from_sleep()) { + serial_write_compressed(translate("Woken up by alarm.\n")); + board_init(); + supervisor_set_run_reason(RUN_REASON_STARTUP); + // TODO: Reset any volatile memory the user may have access to. + return true; + } + #endif + if (!serial_connected_before_animation && serial_connected()) { if (!serial_connected_at_start) { print_code_py_status_message(safe_mode); @@ -351,7 +366,7 @@ STATIC bool run_code_py(safe_mode_t safe_mode) { print_safe_mode_message(safe_mode); serial_write("\n"); - serial_write_compressed(translate("Press any key to enter the REPL. Use CTRL-D to reload.")); + serial_write_compressed(translate("Press any key to enter the REPL. Use CTRL-D to reload.\n")); } if (serial_connected_before_animation && !serial_connected()) { serial_connected_at_start = false; @@ -360,12 +375,47 @@ STATIC bool run_code_py(safe_mode_t safe_mode) { // Refresh the ePaper display if we have one. That way it'll show an error message. #if CIRCUITPY_DISPLAYIO + // Don't refresh the display if we're about to deep sleep. + #if CIRCUITPY_ALARM + refreshed_epaper_display = refreshed_epaper_display || result.return_code & PYEXEC_DEEP_SLEEP; + #endif if (!refreshed_epaper_display) { refreshed_epaper_display = maybe_refresh_epaperdisplay(); } #endif - tick_rgb_status_animation(&animation); + // Sleep until our next interrupt. + #if CIRCUITPY_ALARM + if (result.return_code & PYEXEC_DEEP_SLEEP) { + // Make sure we have been awake long enough for USB to connect (enumeration delay). + int64_t connecting_delay_ticks = CIRCUITPY_USB_CONNECTED_SLEEP_DELAY * 1024 - port_get_raw_ticks(NULL); + if (connecting_delay_ticks > 0) { + // Set when we've waited long enough so that we wake up from the + // sleep_until_interrupt below and loop around to the real deep + // sleep in the else clause. + port_interrupt_after_ticks(connecting_delay_ticks); + // Deep sleep if we're not connected to a host. + } else if (!asleep) { + asleep = true; + new_status_color(BLACK); + board_deinit(); + if (!supervisor_workflow_active()) { + // Enter true deep sleep. When we wake up we'll be back at the + // top of main(), not in this loop. + alarm_enter_deep_sleep(); + // Does not return. + } else { + serial_write_compressed(translate("Pretending to deep sleep until alarm, any key or file write.\n")); + } + } + } + #endif + + if (!asleep) { + tick_rgb_status_animation(&animation); + } else { + port_idle_until_interrupt(); + } } } diff --git a/ports/atmel-samd/boards/8086_commander/board.c b/ports/atmel-samd/boards/8086_commander/board.c index d7e856d611..84960e73cf 100644 --- a/ports/atmel-samd/boards/8086_commander/board.c +++ b/ports/atmel-samd/boards/8086_commander/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" void board_init(void) { } diff --git a/ports/atmel-samd/boards/aloriumtech_evo_m51/board.c b/ports/atmel-samd/boards/aloriumtech_evo_m51/board.c index 1e9ab029e2..5973eeec1b 100644 --- a/ports/atmel-samd/boards/aloriumtech_evo_m51/board.c +++ b/ports/atmel-samd/boards/aloriumtech_evo_m51/board.c @@ -28,7 +28,7 @@ // Author: Bryan Craker // Date: 2020-05-20 -#include "boards/board.h" +#include "supervisor/board.h" #include "mpconfigboard.h" void board_init(void) { diff --git a/ports/atmel-samd/boards/arduino_mkr1300/board.c b/ports/atmel-samd/boards/arduino_mkr1300/board.c index 770bc82593..112b173ecc 100644 --- a/ports/atmel-samd/boards/arduino_mkr1300/board.c +++ b/ports/atmel-samd/boards/arduino_mkr1300/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" #include "mpconfigboard.h" #include "hal/include/hal_gpio.h" diff --git a/ports/atmel-samd/boards/arduino_mkrzero/board.c b/ports/atmel-samd/boards/arduino_mkrzero/board.c index 0f60736a24..7af05ba45a 100644 --- a/ports/atmel-samd/boards/arduino_mkrzero/board.c +++ b/ports/atmel-samd/boards/arduino_mkrzero/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" #include "mpconfigboard.h" #include "hal/include/hal_gpio.h" diff --git a/ports/atmel-samd/boards/arduino_nano_33_iot/board.c b/ports/atmel-samd/boards/arduino_nano_33_iot/board.c index 770bc82593..112b173ecc 100644 --- a/ports/atmel-samd/boards/arduino_nano_33_iot/board.c +++ b/ports/atmel-samd/boards/arduino_nano_33_iot/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" #include "mpconfigboard.h" #include "hal/include/hal_gpio.h" diff --git a/ports/atmel-samd/boards/arduino_zero/board.c b/ports/atmel-samd/boards/arduino_zero/board.c index 770bc82593..112b173ecc 100644 --- a/ports/atmel-samd/boards/arduino_zero/board.c +++ b/ports/atmel-samd/boards/arduino_zero/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" #include "mpconfigboard.h" #include "hal/include/hal_gpio.h" diff --git a/ports/atmel-samd/boards/bast_pro_mini_m0/board.c b/ports/atmel-samd/boards/bast_pro_mini_m0/board.c index c8e20206a1..6baa43ffaa 100644 --- a/ports/atmel-samd/boards/bast_pro_mini_m0/board.c +++ b/ports/atmel-samd/boards/bast_pro_mini_m0/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" void board_init(void) { diff --git a/ports/atmel-samd/boards/bdmicro_vina_d21/board.c b/ports/atmel-samd/boards/bdmicro_vina_d21/board.c index bd63baa6fd..bb1c5335c1 100644 --- a/ports/atmel-samd/boards/bdmicro_vina_d21/board.c +++ b/ports/atmel-samd/boards/bdmicro_vina_d21/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" #include "mpconfigboard.h" void board_init(void) diff --git a/ports/atmel-samd/boards/bdmicro_vina_d51/board.c b/ports/atmel-samd/boards/bdmicro_vina_d51/board.c index bd63baa6fd..bb1c5335c1 100644 --- a/ports/atmel-samd/boards/bdmicro_vina_d51/board.c +++ b/ports/atmel-samd/boards/bdmicro_vina_d51/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" #include "mpconfigboard.h" void board_init(void) diff --git a/ports/atmel-samd/boards/blm_badge/board.c b/ports/atmel-samd/boards/blm_badge/board.c index ee353c8108..e374899a66 100644 --- a/ports/atmel-samd/boards/blm_badge/board.c +++ b/ports/atmel-samd/boards/blm_badge/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" #include "supervisor/shared/board.h" void board_init(void) { @@ -35,5 +35,5 @@ bool board_requests_safe_mode(void) { } void reset_board(void) { - board_reset_user_neopixels(); + board_reset_user_neopixels(&pin_PA05, 10); } diff --git a/ports/atmel-samd/boards/board.h b/ports/atmel-samd/boards/board.h deleted file mode 100644 index 4f0ae9d728..0000000000 --- a/ports/atmel-samd/boards/board.h +++ /dev/null @@ -1,47 +0,0 @@ -/* - * This file is part of the MicroPython project, http://micropython.org/ - * - * The MIT License (MIT) - * - * Copyright (c) 2017 Scott Shawcroft for Adafruit Industries - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -// This file defines board specific functions. - -#ifndef MICROPY_INCLUDED_ATMEL_SAMD_BOARDS_BOARD_H -#define MICROPY_INCLUDED_ATMEL_SAMD_BOARDS_BOARD_H - -#include - -#include "py/mpconfig.h" - -// Initializes board related state once on start up. -void board_init(void); - -// Returns true if the user initiates safe mode in a board specific way. -// Also add BOARD_USER_SAFE_MODE in mpconfigboard.h to explain the board specific -// way. -bool board_requests_safe_mode(void); - -// Reset the state of off MCU components such as neopixels. -void reset_board(void); - -#endif // MICROPY_INCLUDED_ATMEL_SAMD_BOARDS_BOARD_H diff --git a/ports/atmel-samd/boards/capablerobot_usbhub/board.c b/ports/atmel-samd/boards/capablerobot_usbhub/board.c index 46385f094f..d65582379e 100644 --- a/ports/atmel-samd/boards/capablerobot_usbhub/board.c +++ b/ports/atmel-samd/boards/capablerobot_usbhub/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" #include "mpconfigboard.h" #include "hal/include/hal_gpio.h" #include "common-hal/microcontroller/Pin.h" diff --git a/ports/atmel-samd/boards/catwan_usbstick/board.c b/ports/atmel-samd/boards/catwan_usbstick/board.c index c8e20206a1..6baa43ffaa 100644 --- a/ports/atmel-samd/boards/catwan_usbstick/board.c +++ b/ports/atmel-samd/boards/catwan_usbstick/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" void board_init(void) { diff --git a/ports/atmel-samd/boards/circuitbrains_basic_m0/board.c b/ports/atmel-samd/boards/circuitbrains_basic_m0/board.c index efafd152db..59d573ce9f 100755 --- a/ports/atmel-samd/boards/circuitbrains_basic_m0/board.c +++ b/ports/atmel-samd/boards/circuitbrains_basic_m0/board.c @@ -25,7 +25,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" #include "mpconfigboard.h" #include "hal/include/hal_gpio.h" diff --git a/ports/atmel-samd/boards/circuitbrains_deluxe_m4/board.c b/ports/atmel-samd/boards/circuitbrains_deluxe_m4/board.c index efafd152db..59d573ce9f 100755 --- a/ports/atmel-samd/boards/circuitbrains_deluxe_m4/board.c +++ b/ports/atmel-samd/boards/circuitbrains_deluxe_m4/board.c @@ -25,7 +25,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" #include "mpconfigboard.h" #include "hal/include/hal_gpio.h" diff --git a/ports/atmel-samd/boards/circuitplayground_express/board.c b/ports/atmel-samd/boards/circuitplayground_express/board.c index 85c37ee622..f771c214b3 100644 --- a/ports/atmel-samd/boards/circuitplayground_express/board.c +++ b/ports/atmel-samd/boards/circuitplayground_express/board.c @@ -26,7 +26,7 @@ #include -#include "boards/board.h" +#include "supervisor/board.h" #include "common-hal/microcontroller/Pin.h" #include "supervisor/shared/board.h" #include "hal/include/hal_gpio.h" @@ -53,5 +53,5 @@ bool board_requests_safe_mode(void) { } void reset_board(void) { - board_reset_user_neopixels(); + board_reset_user_neopixels(&pin_PB23, 10); } diff --git a/ports/atmel-samd/boards/circuitplayground_express_crickit/board.c b/ports/atmel-samd/boards/circuitplayground_express_crickit/board.c index 21217caac9..13fed598eb 100644 --- a/ports/atmel-samd/boards/circuitplayground_express_crickit/board.c +++ b/ports/atmel-samd/boards/circuitplayground_express_crickit/board.c @@ -26,7 +26,7 @@ #include -#include "boards/board.h" +#include "supervisor/board.h" #include "common-hal/microcontroller/Pin.h" #include "hal/include/hal_gpio.h" #include "supervisor/shared/board.h" @@ -53,5 +53,5 @@ bool board_requests_safe_mode(void) { } void reset_board(void) { - board_reset_user_neopixels(); + board_reset_user_neopixels(&pin_PB23, 10); } diff --git a/ports/atmel-samd/boards/circuitplayground_express_displayio/board.c b/ports/atmel-samd/boards/circuitplayground_express_displayio/board.c index 21217caac9..13fed598eb 100644 --- a/ports/atmel-samd/boards/circuitplayground_express_displayio/board.c +++ b/ports/atmel-samd/boards/circuitplayground_express_displayio/board.c @@ -26,7 +26,7 @@ #include -#include "boards/board.h" +#include "supervisor/board.h" #include "common-hal/microcontroller/Pin.h" #include "hal/include/hal_gpio.h" #include "supervisor/shared/board.h" @@ -53,5 +53,5 @@ bool board_requests_safe_mode(void) { } void reset_board(void) { - board_reset_user_neopixels(); + board_reset_user_neopixels(&pin_PB23, 10); } diff --git a/ports/atmel-samd/boards/cp32-m4/board.c b/ports/atmel-samd/boards/cp32-m4/board.c index 0f60736a24..7af05ba45a 100644 --- a/ports/atmel-samd/boards/cp32-m4/board.c +++ b/ports/atmel-samd/boards/cp32-m4/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" #include "mpconfigboard.h" #include "hal/include/hal_gpio.h" diff --git a/ports/atmel-samd/boards/cp_sapling_m0/board.c b/ports/atmel-samd/boards/cp_sapling_m0/board.c index ce56366762..cde441b3d9 100644 --- a/ports/atmel-samd/boards/cp_sapling_m0/board.c +++ b/ports/atmel-samd/boards/cp_sapling_m0/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" #include "common-hal/microcontroller/Pin.h" #include "supervisor/shared/board.h" #include "hal/include/hal_gpio.h" diff --git a/ports/atmel-samd/boards/cp_sapling_m0_spiflash/board.c b/ports/atmel-samd/boards/cp_sapling_m0_spiflash/board.c index ce56366762..cde441b3d9 100644 --- a/ports/atmel-samd/boards/cp_sapling_m0_spiflash/board.c +++ b/ports/atmel-samd/boards/cp_sapling_m0_spiflash/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" #include "common-hal/microcontroller/Pin.h" #include "supervisor/shared/board.h" #include "hal/include/hal_gpio.h" diff --git a/ports/atmel-samd/boards/datalore_ip_m4/board.c b/ports/atmel-samd/boards/datalore_ip_m4/board.c index 0f60736a24..7af05ba45a 100644 --- a/ports/atmel-samd/boards/datalore_ip_m4/board.c +++ b/ports/atmel-samd/boards/datalore_ip_m4/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" #include "mpconfigboard.h" #include "hal/include/hal_gpio.h" diff --git a/ports/atmel-samd/boards/datum_distance/board.c b/ports/atmel-samd/boards/datum_distance/board.c index c8e20206a1..6baa43ffaa 100644 --- a/ports/atmel-samd/boards/datum_distance/board.c +++ b/ports/atmel-samd/boards/datum_distance/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" void board_init(void) { diff --git a/ports/atmel-samd/boards/datum_imu/board.c b/ports/atmel-samd/boards/datum_imu/board.c index c8e20206a1..6baa43ffaa 100644 --- a/ports/atmel-samd/boards/datum_imu/board.c +++ b/ports/atmel-samd/boards/datum_imu/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" void board_init(void) { diff --git a/ports/atmel-samd/boards/datum_light/board.c b/ports/atmel-samd/boards/datum_light/board.c index c8e20206a1..6baa43ffaa 100644 --- a/ports/atmel-samd/boards/datum_light/board.c +++ b/ports/atmel-samd/boards/datum_light/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" void board_init(void) { diff --git a/ports/atmel-samd/boards/datum_weather/board.c b/ports/atmel-samd/boards/datum_weather/board.c index c8e20206a1..6baa43ffaa 100644 --- a/ports/atmel-samd/boards/datum_weather/board.c +++ b/ports/atmel-samd/boards/datum_weather/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" void board_init(void) { diff --git a/ports/atmel-samd/boards/dynossat_edu_eps/board.c b/ports/atmel-samd/boards/dynossat_edu_eps/board.c index c8e20206a1..6baa43ffaa 100644 --- a/ports/atmel-samd/boards/dynossat_edu_eps/board.c +++ b/ports/atmel-samd/boards/dynossat_edu_eps/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" void board_init(void) { diff --git a/ports/atmel-samd/boards/dynossat_edu_obc/board.c b/ports/atmel-samd/boards/dynossat_edu_obc/board.c index c8e20206a1..6baa43ffaa 100644 --- a/ports/atmel-samd/boards/dynossat_edu_obc/board.c +++ b/ports/atmel-samd/boards/dynossat_edu_obc/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" void board_init(void) { diff --git a/ports/atmel-samd/boards/escornabot_makech/board.c b/ports/atmel-samd/boards/escornabot_makech/board.c index 881e15e0c5..5afe2fb655 100644 --- a/ports/atmel-samd/boards/escornabot_makech/board.c +++ b/ports/atmel-samd/boards/escornabot_makech/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" void board_init(void) { diff --git a/ports/atmel-samd/boards/feather_m0_adalogger/board.c b/ports/atmel-samd/boards/feather_m0_adalogger/board.c index c8e20206a1..6baa43ffaa 100644 --- a/ports/atmel-samd/boards/feather_m0_adalogger/board.c +++ b/ports/atmel-samd/boards/feather_m0_adalogger/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" void board_init(void) { diff --git a/ports/atmel-samd/boards/feather_m0_basic/board.c b/ports/atmel-samd/boards/feather_m0_basic/board.c index c8e20206a1..6baa43ffaa 100644 --- a/ports/atmel-samd/boards/feather_m0_basic/board.c +++ b/ports/atmel-samd/boards/feather_m0_basic/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" void board_init(void) { diff --git a/ports/atmel-samd/boards/feather_m0_express/board.c b/ports/atmel-samd/boards/feather_m0_express/board.c index c8e20206a1..6baa43ffaa 100644 --- a/ports/atmel-samd/boards/feather_m0_express/board.c +++ b/ports/atmel-samd/boards/feather_m0_express/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" void board_init(void) { diff --git a/ports/atmel-samd/boards/feather_m0_express_crickit/board.c b/ports/atmel-samd/boards/feather_m0_express_crickit/board.c index c8e20206a1..6baa43ffaa 100644 --- a/ports/atmel-samd/boards/feather_m0_express_crickit/board.c +++ b/ports/atmel-samd/boards/feather_m0_express_crickit/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" void board_init(void) { diff --git a/ports/atmel-samd/boards/feather_m0_rfm69/board.c b/ports/atmel-samd/boards/feather_m0_rfm69/board.c index c8e20206a1..6baa43ffaa 100644 --- a/ports/atmel-samd/boards/feather_m0_rfm69/board.c +++ b/ports/atmel-samd/boards/feather_m0_rfm69/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" void board_init(void) { diff --git a/ports/atmel-samd/boards/feather_m0_rfm9x/board.c b/ports/atmel-samd/boards/feather_m0_rfm9x/board.c index c8e20206a1..6baa43ffaa 100644 --- a/ports/atmel-samd/boards/feather_m0_rfm9x/board.c +++ b/ports/atmel-samd/boards/feather_m0_rfm9x/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" void board_init(void) { diff --git a/ports/atmel-samd/boards/feather_m0_supersized/board.c b/ports/atmel-samd/boards/feather_m0_supersized/board.c index c8e20206a1..6baa43ffaa 100644 --- a/ports/atmel-samd/boards/feather_m0_supersized/board.c +++ b/ports/atmel-samd/boards/feather_m0_supersized/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" void board_init(void) { diff --git a/ports/atmel-samd/boards/feather_m4_can/board.c b/ports/atmel-samd/boards/feather_m4_can/board.c index 8096b9b8ea..5fca974e9e 100644 --- a/ports/atmel-samd/boards/feather_m4_can/board.c +++ b/ports/atmel-samd/boards/feather_m4_can/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" #include "mpconfigboard.h" void board_init(void) { diff --git a/ports/atmel-samd/boards/feather_m4_express/board.c b/ports/atmel-samd/boards/feather_m4_express/board.c index 8096b9b8ea..5fca974e9e 100644 --- a/ports/atmel-samd/boards/feather_m4_express/board.c +++ b/ports/atmel-samd/boards/feather_m4_express/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" #include "mpconfigboard.h" void board_init(void) { diff --git a/ports/atmel-samd/boards/feather_radiofruit_zigbee/board.c b/ports/atmel-samd/boards/feather_radiofruit_zigbee/board.c index c8e20206a1..6baa43ffaa 100755 --- a/ports/atmel-samd/boards/feather_radiofruit_zigbee/board.c +++ b/ports/atmel-samd/boards/feather_radiofruit_zigbee/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" void board_init(void) { diff --git a/ports/atmel-samd/boards/fluff_m0/board.c b/ports/atmel-samd/boards/fluff_m0/board.c index c8e20206a1..6baa43ffaa 100644 --- a/ports/atmel-samd/boards/fluff_m0/board.c +++ b/ports/atmel-samd/boards/fluff_m0/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" void board_init(void) { diff --git a/ports/atmel-samd/boards/gemma_m0/board.c b/ports/atmel-samd/boards/gemma_m0/board.c index c8e20206a1..6baa43ffaa 100644 --- a/ports/atmel-samd/boards/gemma_m0/board.c +++ b/ports/atmel-samd/boards/gemma_m0/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" void board_init(void) { diff --git a/ports/atmel-samd/boards/grandcentral_m4_express/board.c b/ports/atmel-samd/boards/grandcentral_m4_express/board.c index 7599f02b8e..5ed8c84049 100644 --- a/ports/atmel-samd/boards/grandcentral_m4_express/board.c +++ b/ports/atmel-samd/boards/grandcentral_m4_express/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" #include "mpconfigboard.h" #include "hal/include/hal_gpio.h" diff --git a/ports/atmel-samd/boards/hallowing_m0_express/board.c b/ports/atmel-samd/boards/hallowing_m0_express/board.c index 14a2bdb816..8b922d6bef 100644 --- a/ports/atmel-samd/boards/hallowing_m0_express/board.c +++ b/ports/atmel-samd/boards/hallowing_m0_express/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" #include "shared-bindings/board/__init__.h" #include "shared-bindings/displayio/FourWire.h" diff --git a/ports/atmel-samd/boards/hallowing_m0_express/pins.c b/ports/atmel-samd/boards/hallowing_m0_express/pins.c index 3e670a676f..5d1dda51ac 100644 --- a/ports/atmel-samd/boards/hallowing_m0_express/pins.c +++ b/ports/atmel-samd/boards/hallowing_m0_express/pins.c @@ -1,6 +1,6 @@ #include "shared-bindings/board/__init__.h" -#include "boards/board.h" +#include "supervisor/board.h" #include "shared-module/displayio/__init__.h" STATIC const mp_rom_map_elem_t board_global_dict_table[] = { diff --git a/ports/atmel-samd/boards/hallowing_m4_express/board.c b/ports/atmel-samd/boards/hallowing_m4_express/board.c index 61e797d652..f51d4282d3 100644 --- a/ports/atmel-samd/boards/hallowing_m4_express/board.c +++ b/ports/atmel-samd/boards/hallowing_m4_express/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" #include "mpconfigboard.h" #include "hal/include/hal_gpio.h" #include "shared-bindings/busio/SPI.h" diff --git a/ports/atmel-samd/boards/itsybitsy_m0_express/board.c b/ports/atmel-samd/boards/itsybitsy_m0_express/board.c index d7e856d611..84960e73cf 100644 --- a/ports/atmel-samd/boards/itsybitsy_m0_express/board.c +++ b/ports/atmel-samd/boards/itsybitsy_m0_express/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" void board_init(void) { } diff --git a/ports/atmel-samd/boards/itsybitsy_m4_express/board.c b/ports/atmel-samd/boards/itsybitsy_m4_express/board.c index 0f60736a24..7af05ba45a 100644 --- a/ports/atmel-samd/boards/itsybitsy_m4_express/board.c +++ b/ports/atmel-samd/boards/itsybitsy_m4_express/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" #include "mpconfigboard.h" #include "hal/include/hal_gpio.h" diff --git a/ports/atmel-samd/boards/kicksat-sprite/board.c b/ports/atmel-samd/boards/kicksat-sprite/board.c index 75cdfbc824..d7f78e764a 100644 --- a/ports/atmel-samd/boards/kicksat-sprite/board.c +++ b/ports/atmel-samd/boards/kicksat-sprite/board.c @@ -27,7 +27,7 @@ #include -#include "boards/board.h" +#include "supervisor/board.h" #include "py/mpconfig.h" void board_init(void) { diff --git a/ports/atmel-samd/boards/kicksat-sprite/pins.c b/ports/atmel-samd/boards/kicksat-sprite/pins.c index 87d894c589..27ee903231 100644 --- a/ports/atmel-samd/boards/kicksat-sprite/pins.c +++ b/ports/atmel-samd/boards/kicksat-sprite/pins.c @@ -1,5 +1,5 @@ #include "shared-bindings/board/__init__.h" -#include "boards/board.h" +#include "supervisor/board.h" STATIC const mp_rom_map_elem_t board_global_dict_table[] = { { MP_ROM_QSTR(MP_QSTR_SCK), MP_ROM_PTR(&pin_PA05) }, diff --git a/ports/atmel-samd/boards/loc_ber_m4_base_board/board.c b/ports/atmel-samd/boards/loc_ber_m4_base_board/board.c index 0f60736a24..7af05ba45a 100644 --- a/ports/atmel-samd/boards/loc_ber_m4_base_board/board.c +++ b/ports/atmel-samd/boards/loc_ber_m4_base_board/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" #include "mpconfigboard.h" #include "hal/include/hal_gpio.h" diff --git a/ports/atmel-samd/boards/matrixportal_m4/board.c b/ports/atmel-samd/boards/matrixportal_m4/board.c index 2d4f302391..52ecd83025 100644 --- a/ports/atmel-samd/boards/matrixportal_m4/board.c +++ b/ports/atmel-samd/boards/matrixportal_m4/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" #include "mpconfigboard.h" #include "hal/include/hal_gpio.h" diff --git a/ports/atmel-samd/boards/meowmeow/board.c b/ports/atmel-samd/boards/meowmeow/board.c index 881e15e0c5..5afe2fb655 100644 --- a/ports/atmel-samd/boards/meowmeow/board.c +++ b/ports/atmel-samd/boards/meowmeow/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" void board_init(void) { diff --git a/ports/atmel-samd/boards/metro_m0_express/board.c b/ports/atmel-samd/boards/metro_m0_express/board.c index bd63baa6fd..bb1c5335c1 100644 --- a/ports/atmel-samd/boards/metro_m0_express/board.c +++ b/ports/atmel-samd/boards/metro_m0_express/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" #include "mpconfigboard.h" void board_init(void) diff --git a/ports/atmel-samd/boards/metro_m4_airlift_lite/board.c b/ports/atmel-samd/boards/metro_m4_airlift_lite/board.c index 0f60736a24..7af05ba45a 100644 --- a/ports/atmel-samd/boards/metro_m4_airlift_lite/board.c +++ b/ports/atmel-samd/boards/metro_m4_airlift_lite/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" #include "mpconfigboard.h" #include "hal/include/hal_gpio.h" diff --git a/ports/atmel-samd/boards/metro_m4_express/board.c b/ports/atmel-samd/boards/metro_m4_express/board.c index 0f60736a24..7af05ba45a 100644 --- a/ports/atmel-samd/boards/metro_m4_express/board.c +++ b/ports/atmel-samd/boards/metro_m4_express/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" #include "mpconfigboard.h" #include "hal/include/hal_gpio.h" diff --git a/ports/atmel-samd/boards/mini_sam_m4/board.c b/ports/atmel-samd/boards/mini_sam_m4/board.c index 0f60736a24..7af05ba45a 100644 --- a/ports/atmel-samd/boards/mini_sam_m4/board.c +++ b/ports/atmel-samd/boards/mini_sam_m4/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" #include "mpconfigboard.h" #include "hal/include/hal_gpio.h" diff --git a/ports/atmel-samd/boards/monster_m4sk/board.c b/ports/atmel-samd/boards/monster_m4sk/board.c index 45fea9d529..2b757d0914 100644 --- a/ports/atmel-samd/boards/monster_m4sk/board.c +++ b/ports/atmel-samd/boards/monster_m4sk/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" #include "mpconfigboard.h" #include "hal/include/hal_gpio.h" #include "shared-bindings/busio/SPI.h" diff --git a/ports/atmel-samd/boards/monster_m4sk/pins.c b/ports/atmel-samd/boards/monster_m4sk/pins.c index 7272b9ed86..c3eff7cc30 100644 --- a/ports/atmel-samd/boards/monster_m4sk/pins.c +++ b/ports/atmel-samd/boards/monster_m4sk/pins.c @@ -1,6 +1,6 @@ #include "shared-bindings/board/__init__.h" -#include "boards/board.h" +#include "supervisor/board.h" #include "shared-module/displayio/__init__.h" STATIC const mp_rom_map_elem_t board_global_dict_table[] = { diff --git a/ports/atmel-samd/boards/ndgarage_ndbit6/board.c b/ports/atmel-samd/boards/ndgarage_ndbit6/board.c index 0f60736a24..7af05ba45a 100644 --- a/ports/atmel-samd/boards/ndgarage_ndbit6/board.c +++ b/ports/atmel-samd/boards/ndgarage_ndbit6/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" #include "mpconfigboard.h" #include "hal/include/hal_gpio.h" diff --git a/ports/atmel-samd/boards/ndgarage_ndbit6_v2/board.c b/ports/atmel-samd/boards/ndgarage_ndbit6_v2/board.c index 0f60736a24..7af05ba45a 100644 --- a/ports/atmel-samd/boards/ndgarage_ndbit6_v2/board.c +++ b/ports/atmel-samd/boards/ndgarage_ndbit6_v2/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" #include "mpconfigboard.h" #include "hal/include/hal_gpio.h" diff --git a/ports/atmel-samd/boards/nfc_copy_cat/board.c b/ports/atmel-samd/boards/nfc_copy_cat/board.c index c8e20206a1..6baa43ffaa 100644 --- a/ports/atmel-samd/boards/nfc_copy_cat/board.c +++ b/ports/atmel-samd/boards/nfc_copy_cat/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" void board_init(void) { diff --git a/ports/atmel-samd/boards/openbook_m4/board.c b/ports/atmel-samd/boards/openbook_m4/board.c index 07dd1741ac..a110779a6a 100644 --- a/ports/atmel-samd/boards/openbook_m4/board.c +++ b/ports/atmel-samd/boards/openbook_m4/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" #include "mpconfigboard.h" #include "hal/include/hal_gpio.h" #include "shared-bindings/busio/SPI.h" diff --git a/ports/atmel-samd/boards/openbook_m4/pins.c b/ports/atmel-samd/boards/openbook_m4/pins.c index 47de3043d9..45a7bc1dd0 100644 --- a/ports/atmel-samd/boards/openbook_m4/pins.c +++ b/ports/atmel-samd/boards/openbook_m4/pins.c @@ -1,6 +1,6 @@ #include "shared-bindings/board/__init__.h" -#include "boards/board.h" +#include "supervisor/board.h" #include "shared-module/displayio/__init__.h" STATIC const mp_rom_map_elem_t board_global_dict_table[] = { diff --git a/ports/atmel-samd/boards/pewpew10/board.c b/ports/atmel-samd/boards/pewpew10/board.c index d7e856d611..84960e73cf 100644 --- a/ports/atmel-samd/boards/pewpew10/board.c +++ b/ports/atmel-samd/boards/pewpew10/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" void board_init(void) { } diff --git a/ports/atmel-samd/boards/pewpew_m4/board.c b/ports/atmel-samd/boards/pewpew_m4/board.c index d02e0dc01d..26bd53cad1 100644 --- a/ports/atmel-samd/boards/pewpew_m4/board.c +++ b/ports/atmel-samd/boards/pewpew_m4/board.c @@ -25,7 +25,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" #include "mpconfigboard.h" #include "hal/include/hal_gpio.h" #include "shared-bindings/busio/SPI.h" diff --git a/ports/atmel-samd/boards/picoplanet/board.c b/ports/atmel-samd/boards/picoplanet/board.c index d7e856d611..84960e73cf 100644 --- a/ports/atmel-samd/boards/picoplanet/board.c +++ b/ports/atmel-samd/boards/picoplanet/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" void board_init(void) { } diff --git a/ports/atmel-samd/boards/pirkey_m0/board.c b/ports/atmel-samd/boards/pirkey_m0/board.c index c8e20206a1..6baa43ffaa 100644 --- a/ports/atmel-samd/boards/pirkey_m0/board.c +++ b/ports/atmel-samd/boards/pirkey_m0/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" void board_init(void) { diff --git a/ports/atmel-samd/boards/pybadge/board.c b/ports/atmel-samd/boards/pybadge/board.c index 35f228c75a..188bf7bf6c 100644 --- a/ports/atmel-samd/boards/pybadge/board.c +++ b/ports/atmel-samd/boards/pybadge/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" #include "mpconfigboard.h" #include "hal/include/hal_gpio.h" #include "shared-bindings/busio/SPI.h" @@ -123,5 +123,5 @@ bool board_requests_safe_mode(void) { } void reset_board(void) { - board_reset_user_neopixels(); + board_reset_user_neopixels(&pin_PA15, 5); } diff --git a/ports/atmel-samd/boards/pybadge/pins.c b/ports/atmel-samd/boards/pybadge/pins.c index ca65d9df46..a1802bb071 100644 --- a/ports/atmel-samd/boards/pybadge/pins.c +++ b/ports/atmel-samd/boards/pybadge/pins.c @@ -1,6 +1,6 @@ #include "shared-bindings/board/__init__.h" -#include "boards/board.h" +#include "supervisor/board.h" #include "shared-module/displayio/__init__.h" STATIC const mp_rom_map_elem_t board_global_dict_table[] = { diff --git a/ports/atmel-samd/boards/pybadge_airlift/board.c b/ports/atmel-samd/boards/pybadge_airlift/board.c index fe3e4a0171..de7eeda096 100644 --- a/ports/atmel-samd/boards/pybadge_airlift/board.c +++ b/ports/atmel-samd/boards/pybadge_airlift/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" #include "mpconfigboard.h" #include "hal/include/hal_gpio.h" #include "shared-bindings/busio/SPI.h" @@ -101,5 +101,5 @@ bool board_requests_safe_mode(void) { } void reset_board(void) { - board_reset_user_neopixels(); + board_reset_user_neopixels(&pin_PA15, 5); } diff --git a/ports/atmel-samd/boards/pybadge_airlift/pins.c b/ports/atmel-samd/boards/pybadge_airlift/pins.c index 9ee579be14..cdf8071da8 100644 --- a/ports/atmel-samd/boards/pybadge_airlift/pins.c +++ b/ports/atmel-samd/boards/pybadge_airlift/pins.c @@ -1,6 +1,6 @@ #include "shared-bindings/board/__init__.h" -#include "boards/board.h" +#include "supervisor/board.h" #include "shared-module/displayio/__init__.h" STATIC const mp_rom_map_elem_t board_global_dict_table[] = { diff --git a/ports/atmel-samd/boards/pycubed/board.c b/ports/atmel-samd/boards/pycubed/board.c index 0bf586ad8e..f092a8d20e 100644 --- a/ports/atmel-samd/boards/pycubed/board.c +++ b/ports/atmel-samd/boards/pycubed/board.c @@ -27,7 +27,7 @@ #include -#include "boards/board.h" +#include "supervisor/board.h" #include "py/mpconfig.h" #include "shared-bindings/nvm/ByteArray.h" #include "common-hal/microcontroller/Pin.h" diff --git a/ports/atmel-samd/boards/pycubed/pins.c b/ports/atmel-samd/boards/pycubed/pins.c index e494fb54bf..93f349ffa4 100644 --- a/ports/atmel-samd/boards/pycubed/pins.c +++ b/ports/atmel-samd/boards/pycubed/pins.c @@ -1,5 +1,5 @@ #include "shared-bindings/board/__init__.h" -#include "boards/board.h" +#include "supervisor/board.h" STATIC const mp_rom_map_elem_t board_global_dict_table[] = { { MP_ROM_QSTR(MP_QSTR_SCK), MP_ROM_PTR(&pin_PA13) }, diff --git a/ports/atmel-samd/boards/pycubed_mram/board.c b/ports/atmel-samd/boards/pycubed_mram/board.c index 0bf586ad8e..f092a8d20e 100644 --- a/ports/atmel-samd/boards/pycubed_mram/board.c +++ b/ports/atmel-samd/boards/pycubed_mram/board.c @@ -27,7 +27,7 @@ #include -#include "boards/board.h" +#include "supervisor/board.h" #include "py/mpconfig.h" #include "shared-bindings/nvm/ByteArray.h" #include "common-hal/microcontroller/Pin.h" diff --git a/ports/atmel-samd/boards/pycubed_mram/pins.c b/ports/atmel-samd/boards/pycubed_mram/pins.c index e494fb54bf..93f349ffa4 100644 --- a/ports/atmel-samd/boards/pycubed_mram/pins.c +++ b/ports/atmel-samd/boards/pycubed_mram/pins.c @@ -1,5 +1,5 @@ #include "shared-bindings/board/__init__.h" -#include "boards/board.h" +#include "supervisor/board.h" STATIC const mp_rom_map_elem_t board_global_dict_table[] = { { MP_ROM_QSTR(MP_QSTR_SCK), MP_ROM_PTR(&pin_PA13) }, diff --git a/ports/atmel-samd/boards/pygamer/board.c b/ports/atmel-samd/boards/pygamer/board.c index b478b5947c..4614e347cd 100644 --- a/ports/atmel-samd/boards/pygamer/board.c +++ b/ports/atmel-samd/boards/pygamer/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" #include "mpconfigboard.h" #include "hal/include/hal_gpio.h" #include "shared-bindings/busio/SPI.h" @@ -123,5 +123,5 @@ bool board_requests_safe_mode(void) { } void reset_board(void) { - board_reset_user_neopixels(); + board_reset_user_neopixels(&pin_PA15, 5); } diff --git a/ports/atmel-samd/boards/pygamer/pins.c b/ports/atmel-samd/boards/pygamer/pins.c index 107d780a8a..8bfaa64792 100644 --- a/ports/atmel-samd/boards/pygamer/pins.c +++ b/ports/atmel-samd/boards/pygamer/pins.c @@ -1,6 +1,6 @@ #include "shared-bindings/board/__init__.h" -#include "boards/board.h" +#include "supervisor/board.h" #include "shared-module/displayio/__init__.h" STATIC const mp_rom_map_elem_t board_global_dict_table[] = { diff --git a/ports/atmel-samd/boards/pygamer_advance/board.c b/ports/atmel-samd/boards/pygamer_advance/board.c index 7dfe07c00d..39bf65602e 100644 --- a/ports/atmel-samd/boards/pygamer_advance/board.c +++ b/ports/atmel-samd/boards/pygamer_advance/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" #include "mpconfigboard.h" #include "hal/include/hal_gpio.h" #include "shared-bindings/busio/SPI.h" @@ -101,5 +101,5 @@ bool board_requests_safe_mode(void) { } void reset_board(void) { - board_reset_user_neopixels(); + board_reset_user_neopixels(&pin_PA15, 5); } diff --git a/ports/atmel-samd/boards/pygamer_advance/pins.c b/ports/atmel-samd/boards/pygamer_advance/pins.c index 653a1bb2ef..8db63f2f0c 100644 --- a/ports/atmel-samd/boards/pygamer_advance/pins.c +++ b/ports/atmel-samd/boards/pygamer_advance/pins.c @@ -1,6 +1,6 @@ #include "shared-bindings/board/__init__.h" -#include "boards/board.h" +#include "supervisor/board.h" #include "shared-module/displayio/__init__.h" STATIC const mp_rom_map_elem_t board_global_dict_table[] = { diff --git a/ports/atmel-samd/boards/pyportal/board.c b/ports/atmel-samd/boards/pyportal/board.c index cd94f68875..db474a8209 100644 --- a/ports/atmel-samd/boards/pyportal/board.c +++ b/ports/atmel-samd/boards/pyportal/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" #include "mpconfigboard.h" #include "hal/include/hal_gpio.h" diff --git a/ports/atmel-samd/boards/pyportal/pins.c b/ports/atmel-samd/boards/pyportal/pins.c index 461ee98da5..1a18464922 100644 --- a/ports/atmel-samd/boards/pyportal/pins.c +++ b/ports/atmel-samd/boards/pyportal/pins.c @@ -1,6 +1,6 @@ #include "shared-bindings/board/__init__.h" -#include "boards/board.h" +#include "supervisor/board.h" #include "shared-module/displayio/__init__.h" // This mapping only includes functional names because pins broken diff --git a/ports/atmel-samd/boards/pyportal_titano/board.c b/ports/atmel-samd/boards/pyportal_titano/board.c index dc417f5d14..59a25c4acf 100644 --- a/ports/atmel-samd/boards/pyportal_titano/board.c +++ b/ports/atmel-samd/boards/pyportal_titano/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" #include "mpconfigboard.h" #include "hal/include/hal_gpio.h" diff --git a/ports/atmel-samd/boards/pyportal_titano/pins.c b/ports/atmel-samd/boards/pyportal_titano/pins.c index 461ee98da5..1a18464922 100644 --- a/ports/atmel-samd/boards/pyportal_titano/pins.c +++ b/ports/atmel-samd/boards/pyportal_titano/pins.c @@ -1,6 +1,6 @@ #include "shared-bindings/board/__init__.h" -#include "boards/board.h" +#include "supervisor/board.h" #include "shared-module/displayio/__init__.h" // This mapping only includes functional names because pins broken diff --git a/ports/atmel-samd/boards/pyruler/board.c b/ports/atmel-samd/boards/pyruler/board.c index d7e856d611..84960e73cf 100644 --- a/ports/atmel-samd/boards/pyruler/board.c +++ b/ports/atmel-samd/boards/pyruler/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" void board_init(void) { } diff --git a/ports/atmel-samd/boards/qtpy_m0/board.c b/ports/atmel-samd/boards/qtpy_m0/board.c index 1a65a561f7..6b948a9a7a 100644 --- a/ports/atmel-samd/boards/qtpy_m0/board.c +++ b/ports/atmel-samd/boards/qtpy_m0/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" #include "common-hal/microcontroller/Pin.h" #include "supervisor/shared/board.h" #include "hal/include/hal_gpio.h" diff --git a/ports/atmel-samd/boards/qtpy_m0_haxpress/board.c b/ports/atmel-samd/boards/qtpy_m0_haxpress/board.c index 1a65a561f7..6b948a9a7a 100644 --- a/ports/atmel-samd/boards/qtpy_m0_haxpress/board.c +++ b/ports/atmel-samd/boards/qtpy_m0_haxpress/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" #include "common-hal/microcontroller/Pin.h" #include "supervisor/shared/board.h" #include "hal/include/hal_gpio.h" diff --git a/ports/atmel-samd/boards/robohatmm1_m4/board.c b/ports/atmel-samd/boards/robohatmm1_m4/board.c index 0f60736a24..7af05ba45a 100644 --- a/ports/atmel-samd/boards/robohatmm1_m4/board.c +++ b/ports/atmel-samd/boards/robohatmm1_m4/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" #include "mpconfigboard.h" #include "hal/include/hal_gpio.h" diff --git a/ports/atmel-samd/boards/sam32/board.c b/ports/atmel-samd/boards/sam32/board.c index e032601440..560edd9c2c 100644 --- a/ports/atmel-samd/boards/sam32/board.c +++ b/ports/atmel-samd/boards/sam32/board.c @@ -27,7 +27,7 @@ #include -#include "boards/board.h" +#include "supervisor/board.h" #include "py/mpconfig.h" #include "common-hal/digitalio/DigitalInOut.h" diff --git a/ports/atmel-samd/boards/same54_xplained/board.c b/ports/atmel-samd/boards/same54_xplained/board.c index 7599f02b8e..5ed8c84049 100644 --- a/ports/atmel-samd/boards/same54_xplained/board.c +++ b/ports/atmel-samd/boards/same54_xplained/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" #include "mpconfigboard.h" #include "hal/include/hal_gpio.h" diff --git a/ports/atmel-samd/boards/seeeduino_wio_terminal/board.c b/ports/atmel-samd/boards/seeeduino_wio_terminal/board.c index 49db498608..53c43cd441 100644 --- a/ports/atmel-samd/boards/seeeduino_wio_terminal/board.c +++ b/ports/atmel-samd/boards/seeeduino_wio_terminal/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" #include "mpconfigboard.h" #include "hal/include/hal_gpio.h" #include "shared-bindings/busio/SPI.h" diff --git a/ports/atmel-samd/boards/seeeduino_xiao/board.c b/ports/atmel-samd/boards/seeeduino_xiao/board.c index 0f60736a24..7af05ba45a 100644 --- a/ports/atmel-samd/boards/seeeduino_xiao/board.c +++ b/ports/atmel-samd/boards/seeeduino_xiao/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" #include "mpconfigboard.h" #include "hal/include/hal_gpio.h" diff --git a/ports/atmel-samd/boards/serpente/board.c b/ports/atmel-samd/boards/serpente/board.c index d7e856d611..84960e73cf 100644 --- a/ports/atmel-samd/boards/serpente/board.c +++ b/ports/atmel-samd/boards/serpente/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" void board_init(void) { } diff --git a/ports/atmel-samd/boards/shirtty/board.c b/ports/atmel-samd/boards/shirtty/board.c index d7e856d611..84960e73cf 100644 --- a/ports/atmel-samd/boards/shirtty/board.c +++ b/ports/atmel-samd/boards/shirtty/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" void board_init(void) { } diff --git a/ports/atmel-samd/boards/snekboard/board.c b/ports/atmel-samd/boards/snekboard/board.c index c8e20206a1..6baa43ffaa 100644 --- a/ports/atmel-samd/boards/snekboard/board.c +++ b/ports/atmel-samd/boards/snekboard/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" void board_init(void) { diff --git a/ports/atmel-samd/boards/sparkfun_lumidrive/board.c b/ports/atmel-samd/boards/sparkfun_lumidrive/board.c index c8e20206a1..6baa43ffaa 100755 --- a/ports/atmel-samd/boards/sparkfun_lumidrive/board.c +++ b/ports/atmel-samd/boards/sparkfun_lumidrive/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" void board_init(void) { diff --git a/ports/atmel-samd/boards/sparkfun_qwiic_micro_no_flash/board.c b/ports/atmel-samd/boards/sparkfun_qwiic_micro_no_flash/board.c index c8e20206a1..6baa43ffaa 100644 --- a/ports/atmel-samd/boards/sparkfun_qwiic_micro_no_flash/board.c +++ b/ports/atmel-samd/boards/sparkfun_qwiic_micro_no_flash/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" void board_init(void) { diff --git a/ports/atmel-samd/boards/sparkfun_qwiic_micro_with_flash/board.c b/ports/atmel-samd/boards/sparkfun_qwiic_micro_with_flash/board.c index c8e20206a1..6baa43ffaa 100644 --- a/ports/atmel-samd/boards/sparkfun_qwiic_micro_with_flash/board.c +++ b/ports/atmel-samd/boards/sparkfun_qwiic_micro_with_flash/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" void board_init(void) { diff --git a/ports/atmel-samd/boards/sparkfun_redboard_turbo/board.c b/ports/atmel-samd/boards/sparkfun_redboard_turbo/board.c index c8e20206a1..6baa43ffaa 100755 --- a/ports/atmel-samd/boards/sparkfun_redboard_turbo/board.c +++ b/ports/atmel-samd/boards/sparkfun_redboard_turbo/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" void board_init(void) { diff --git a/ports/atmel-samd/boards/sparkfun_samd21_dev/board.c b/ports/atmel-samd/boards/sparkfun_samd21_dev/board.c index 0f60736a24..7af05ba45a 100644 --- a/ports/atmel-samd/boards/sparkfun_samd21_dev/board.c +++ b/ports/atmel-samd/boards/sparkfun_samd21_dev/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" #include "mpconfigboard.h" #include "hal/include/hal_gpio.h" diff --git a/ports/atmel-samd/boards/sparkfun_samd21_mini/board.c b/ports/atmel-samd/boards/sparkfun_samd21_mini/board.c index 0f60736a24..7af05ba45a 100644 --- a/ports/atmel-samd/boards/sparkfun_samd21_mini/board.c +++ b/ports/atmel-samd/boards/sparkfun_samd21_mini/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" #include "mpconfigboard.h" #include "hal/include/hal_gpio.h" diff --git a/ports/atmel-samd/boards/sparkfun_samd51_thing_plus/board.c b/ports/atmel-samd/boards/sparkfun_samd51_thing_plus/board.c index 8096b9b8ea..5fca974e9e 100644 --- a/ports/atmel-samd/boards/sparkfun_samd51_thing_plus/board.c +++ b/ports/atmel-samd/boards/sparkfun_samd51_thing_plus/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" #include "mpconfigboard.h" void board_init(void) { diff --git a/ports/atmel-samd/boards/stringcar_m0_express/board.c b/ports/atmel-samd/boards/stringcar_m0_express/board.c index d7e856d611..84960e73cf 100644 --- a/ports/atmel-samd/boards/stringcar_m0_express/board.c +++ b/ports/atmel-samd/boards/stringcar_m0_express/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" void board_init(void) { } diff --git a/ports/atmel-samd/boards/trellis_m4_express/board.c b/ports/atmel-samd/boards/trellis_m4_express/board.c index a9b5f81631..e6f8b59179 100644 --- a/ports/atmel-samd/boards/trellis_m4_express/board.c +++ b/ports/atmel-samd/boards/trellis_m4_express/board.c @@ -26,7 +26,7 @@ #include -#include "boards/board.h" +#include "supervisor/board.h" #include "py/mpconfig.h" #include "common-hal/digitalio/DigitalInOut.h" diff --git a/ports/atmel-samd/boards/trinket_m0/board.c b/ports/atmel-samd/boards/trinket_m0/board.c index d7e856d611..84960e73cf 100644 --- a/ports/atmel-samd/boards/trinket_m0/board.c +++ b/ports/atmel-samd/boards/trinket_m0/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" void board_init(void) { } diff --git a/ports/atmel-samd/boards/trinket_m0_haxpress/board.c b/ports/atmel-samd/boards/trinket_m0_haxpress/board.c index d7e856d611..84960e73cf 100644 --- a/ports/atmel-samd/boards/trinket_m0_haxpress/board.c +++ b/ports/atmel-samd/boards/trinket_m0_haxpress/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" void board_init(void) { } diff --git a/ports/atmel-samd/boards/uartlogger2/board.c b/ports/atmel-samd/boards/uartlogger2/board.c index 0f60736a24..7af05ba45a 100644 --- a/ports/atmel-samd/boards/uartlogger2/board.c +++ b/ports/atmel-samd/boards/uartlogger2/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" #include "mpconfigboard.h" #include "hal/include/hal_gpio.h" diff --git a/ports/atmel-samd/boards/uchip/board.c b/ports/atmel-samd/boards/uchip/board.c index 0f60736a24..7af05ba45a 100644 --- a/ports/atmel-samd/boards/uchip/board.c +++ b/ports/atmel-samd/boards/uchip/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" #include "mpconfigboard.h" #include "hal/include/hal_gpio.h" diff --git a/ports/atmel-samd/boards/ugame10/board.c b/ports/atmel-samd/boards/ugame10/board.c index 9f2b8d039d..918fe2d59d 100644 --- a/ports/atmel-samd/boards/ugame10/board.c +++ b/ports/atmel-samd/boards/ugame10/board.c @@ -25,7 +25,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" #include "shared-bindings/board/__init__.h" #include "shared-bindings/displayio/FourWire.h" diff --git a/ports/atmel-samd/boards/winterbloom_big_honking_button/board.c b/ports/atmel-samd/boards/winterbloom_big_honking_button/board.c index c8e20206a1..6baa43ffaa 100644 --- a/ports/atmel-samd/boards/winterbloom_big_honking_button/board.c +++ b/ports/atmel-samd/boards/winterbloom_big_honking_button/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" void board_init(void) { diff --git a/ports/atmel-samd/boards/winterbloom_sol/board.c b/ports/atmel-samd/boards/winterbloom_sol/board.c index 8096b9b8ea..5fca974e9e 100644 --- a/ports/atmel-samd/boards/winterbloom_sol/board.c +++ b/ports/atmel-samd/boards/winterbloom_sol/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" #include "mpconfigboard.h" void board_init(void) { diff --git a/ports/atmel-samd/boards/xinabox_cc03/board.c b/ports/atmel-samd/boards/xinabox_cc03/board.c index 770bc82593..112b173ecc 100644 --- a/ports/atmel-samd/boards/xinabox_cc03/board.c +++ b/ports/atmel-samd/boards/xinabox_cc03/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" #include "mpconfigboard.h" #include "hal/include/hal_gpio.h" diff --git a/ports/atmel-samd/boards/xinabox_cs11/board.c b/ports/atmel-samd/boards/xinabox_cs11/board.c index 770bc82593..112b173ecc 100644 --- a/ports/atmel-samd/boards/xinabox_cs11/board.c +++ b/ports/atmel-samd/boards/xinabox_cs11/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" #include "mpconfigboard.h" #include "hal/include/hal_gpio.h" diff --git a/ports/atmel-samd/common-hal/busio/SPI.c b/ports/atmel-samd/common-hal/busio/SPI.c index 189fd93b54..9646f9cf1e 100644 --- a/ports/atmel-samd/common-hal/busio/SPI.c +++ b/ports/atmel-samd/common-hal/busio/SPI.c @@ -31,7 +31,7 @@ #include "hpl_sercom_config.h" #include "peripheral_clk_config.h" -#include "boards/board.h" +#include "supervisor/board.h" #include "common-hal/microcontroller/Pin.h" #include "hal/include/hal_gpio.h" #include "hal/include/hal_spi_m_sync.h" diff --git a/ports/atmel-samd/common-hal/sdioio/SDCard.c b/ports/atmel-samd/common-hal/sdioio/SDCard.c index 4d2539aa5a..14c6f29de1 100644 --- a/ports/atmel-samd/common-hal/sdioio/SDCard.c +++ b/ports/atmel-samd/common-hal/sdioio/SDCard.c @@ -28,7 +28,6 @@ #include "py/mperrno.h" #include "py/runtime.h" -#include "boards/board.h" #include "common-hal/microcontroller/Pin.h" #include "shared-bindings/sdioio/SDCard.h" #include "shared-bindings/microcontroller/Pin.h" diff --git a/ports/atmel-samd/supervisor/port.c b/ports/atmel-samd/supervisor/port.c index fc1d1198e2..7d02789e82 100644 --- a/ports/atmel-samd/supervisor/port.c +++ b/ports/atmel-samd/supervisor/port.c @@ -27,7 +27,7 @@ #include #include -#include "boards/board.h" +#include "supervisor/board.h" #include "supervisor/port.h" // ASF 4 @@ -543,7 +543,7 @@ void port_interrupt_after_ticks(uint32_t ticks) { _port_interrupt_after_ticks(ticks); } -void port_sleep_until_interrupt(void) { +void port_idle_until_interrupt(void) { #ifdef SAM_D5X_E5X // Clear the FPU interrupt because it can prevent us from sleeping. if (__get_FPSCR() & ~(0x9f)) { diff --git a/ports/cxd56/boards/board.h b/ports/cxd56/boards/board.h deleted file mode 100644 index 597ae72e6a..0000000000 --- a/ports/cxd56/boards/board.h +++ /dev/null @@ -1,45 +0,0 @@ -/* - * This file is part of the MicroPython project, http://micropython.org/ - * - * The MIT License (MIT) - * - * Copyright 2019 Sony Semiconductor Solutions Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -// This file defines board specific functions. - -#ifndef MICROPY_INCLUDED_CXD56_BOARDS_BOARD_H -#define MICROPY_INCLUDED_CXD56_BOARDS_BOARD_H - -#include - -// Initializes board related state once on start up. -void board_init(void); - -// Returns true if the user initiates safe mode in a board specific way. -// Also add BOARD_USER_SAFE_MODE in mpconfigboard.h to explain the board specific -// way. -bool board_requests_safe_mode(void); - -// Reset the state of off MCU components such as neopixels. -void reset_board(void); - -#endif // MICROPY_INCLUDED_CXD56_BOARDS_BOARD_H diff --git a/ports/cxd56/boards/spresense/board.c b/ports/cxd56/boards/spresense/board.c index 2af7cfdcf2..fd27d3493a 100644 --- a/ports/cxd56/boards/spresense/board.c +++ b/ports/cxd56/boards/spresense/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" void board_init(void) { diff --git a/ports/cxd56/supervisor/port.c b/ports/cxd56/supervisor/port.c index d69f357799..523d6a496b 100644 --- a/ports/cxd56/supervisor/port.c +++ b/ports/cxd56/supervisor/port.c @@ -33,7 +33,7 @@ #include "sched/sched.h" -#include "boards/board.h" +#include "supervisor/board.h" #include "supervisor/port.h" #include "supervisor/background_callback.h" @@ -169,6 +169,6 @@ void port_disable_tick(void) { void port_interrupt_after_ticks(uint32_t ticks) { } -void port_sleep_until_interrupt(void) { +void port_idle_until_interrupt(void) { // TODO: Implement sleep. } diff --git a/ports/esp32s2/boards/adafruit_magtag_2.9_grayscale/board.c b/ports/esp32s2/boards/adafruit_magtag_2.9_grayscale/board.c index ecd44e423c..a9d1074f72 100644 --- a/ports/esp32s2/boards/adafruit_magtag_2.9_grayscale/board.c +++ b/ports/esp32s2/boards/adafruit_magtag_2.9_grayscale/board.c @@ -24,7 +24,8 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" + #include "mpconfigboard.h" #include "shared-bindings/busio/SPI.h" #include "shared-bindings/displayio/FourWire.h" @@ -32,6 +33,10 @@ #include "shared-module/displayio/__init__.h" #include "supervisor/shared/board.h" +#include "components/log/include/esp_log.h" + +static const char* TAG = "board"; + #define DELAY 0x80 // This is an ILO373 control chip. The display is a 2.9" grayscale EInk. @@ -167,3 +172,18 @@ bool board_requests_safe_mode(void) { void reset_board(void) { } + +void board_deinit(void) { + displayio_epaperdisplay_obj_t* display = &displays[0].epaper_display; + if (display->base.type == &displayio_epaperdisplay_type) { + size_t i = 0; + while (common_hal_displayio_epaperdisplay_get_busy(display)) { + RUN_BACKGROUND_TASKS; + i++; + } + ESP_LOGI(TAG, "waited %d iterations for display", i); + } else { + ESP_LOGI(TAG, "didn't wait for display"); + } + common_hal_displayio_release_displays(); +} diff --git a/ports/esp32s2/boards/adafruit_metro_esp32s2/board.c b/ports/esp32s2/boards/adafruit_metro_esp32s2/board.c index 7380be6da6..5abd1ce1b3 100644 --- a/ports/esp32s2/boards/adafruit_metro_esp32s2/board.c +++ b/ports/esp32s2/boards/adafruit_metro_esp32s2/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" #include "mpconfigboard.h" #include "shared-bindings/microcontroller/Pin.h" @@ -41,3 +41,6 @@ bool board_requests_safe_mode(void) { void reset_board(void) { } + +void board_deinit(void) { +} diff --git a/ports/esp32s2/boards/electroniccats_bastwifi/board.c b/ports/esp32s2/boards/electroniccats_bastwifi/board.c index 9f708874bf..ff5d9cfb6c 100644 --- a/ports/esp32s2/boards/electroniccats_bastwifi/board.c +++ b/ports/esp32s2/boards/electroniccats_bastwifi/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" #include "mpconfigboard.h" #include "shared-bindings/microcontroller/Pin.h" @@ -45,3 +45,6 @@ bool board_requests_safe_mode(void) { void reset_board(void) { } + +void board_deinit(void) { +} diff --git a/ports/esp32s2/boards/espressif_kaluga_1/board.c b/ports/esp32s2/boards/espressif_kaluga_1/board.c index 9f708874bf..ff5d9cfb6c 100644 --- a/ports/esp32s2/boards/espressif_kaluga_1/board.c +++ b/ports/esp32s2/boards/espressif_kaluga_1/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" #include "mpconfigboard.h" #include "shared-bindings/microcontroller/Pin.h" @@ -45,3 +45,6 @@ bool board_requests_safe_mode(void) { void reset_board(void) { } + +void board_deinit(void) { +} diff --git a/ports/esp32s2/boards/espressif_saola_1_wroom/board.c b/ports/esp32s2/boards/espressif_saola_1_wroom/board.c index 9f708874bf..ff5d9cfb6c 100644 --- a/ports/esp32s2/boards/espressif_saola_1_wroom/board.c +++ b/ports/esp32s2/boards/espressif_saola_1_wroom/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" #include "mpconfigboard.h" #include "shared-bindings/microcontroller/Pin.h" @@ -45,3 +45,6 @@ bool board_requests_safe_mode(void) { void reset_board(void) { } + +void board_deinit(void) { +} diff --git a/ports/esp32s2/boards/espressif_saola_1_wrover/board.c b/ports/esp32s2/boards/espressif_saola_1_wrover/board.c index 9f708874bf..ff5d9cfb6c 100644 --- a/ports/esp32s2/boards/espressif_saola_1_wrover/board.c +++ b/ports/esp32s2/boards/espressif_saola_1_wrover/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" #include "mpconfigboard.h" #include "shared-bindings/microcontroller/Pin.h" @@ -45,3 +45,6 @@ bool board_requests_safe_mode(void) { void reset_board(void) { } + +void board_deinit(void) { +} diff --git a/ports/esp32s2/boards/microdev_micro_s2/board.c b/ports/esp32s2/boards/microdev_micro_s2/board.c index 1dc30b5af8..abd22091ee 100644 --- a/ports/esp32s2/boards/microdev_micro_s2/board.c +++ b/ports/esp32s2/boards/microdev_micro_s2/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" #include "mpconfigboard.h" #include "shared-bindings/microcontroller/Pin.h" @@ -54,3 +54,6 @@ bool board_requests_safe_mode(void) { void reset_board(void) { } + +void board_deinit(void) { +} diff --git a/ports/esp32s2/boards/muselab_nanoesp32_s2/board.c b/ports/esp32s2/boards/muselab_nanoesp32_s2/board.c index 9f708874bf..ff5d9cfb6c 100644 --- a/ports/esp32s2/boards/muselab_nanoesp32_s2/board.c +++ b/ports/esp32s2/boards/muselab_nanoesp32_s2/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" #include "mpconfigboard.h" #include "shared-bindings/microcontroller/Pin.h" @@ -45,3 +45,6 @@ bool board_requests_safe_mode(void) { void reset_board(void) { } + +void board_deinit(void) { +} diff --git a/ports/esp32s2/boards/targett_module_clip_wroom/board.c b/ports/esp32s2/boards/targett_module_clip_wroom/board.c index 7f5de0e0dd..c2022d292e 100644 --- a/ports/esp32s2/boards/targett_module_clip_wroom/board.c +++ b/ports/esp32s2/boards/targett_module_clip_wroom/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" #include "mpconfigboard.h" #include "shared-bindings/microcontroller/Pin.h" @@ -49,3 +49,6 @@ bool board_requests_safe_mode(void) { void reset_board(void) { } + +void board_deinit(void) { +} diff --git a/ports/esp32s2/boards/targett_module_clip_wrover/board.c b/ports/esp32s2/boards/targett_module_clip_wrover/board.c index 83dcb920a8..5a9fbcbee7 100644 --- a/ports/esp32s2/boards/targett_module_clip_wrover/board.c +++ b/ports/esp32s2/boards/targett_module_clip_wrover/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" #include "mpconfigboard.h" #include "shared-bindings/microcontroller/Pin.h" @@ -49,3 +49,6 @@ bool board_requests_safe_mode(void) { void reset_board(void) { } + +void board_deinit(void) { +} diff --git a/ports/esp32s2/boards/unexpectedmaker_feathers2/board.c b/ports/esp32s2/boards/unexpectedmaker_feathers2/board.c index 1dc30b5af8..abd22091ee 100644 --- a/ports/esp32s2/boards/unexpectedmaker_feathers2/board.c +++ b/ports/esp32s2/boards/unexpectedmaker_feathers2/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" #include "mpconfigboard.h" #include "shared-bindings/microcontroller/Pin.h" @@ -54,3 +54,6 @@ bool board_requests_safe_mode(void) { void reset_board(void) { } + +void board_deinit(void) { +} diff --git a/ports/esp32s2/boards/unexpectedmaker_feathers2_prerelease/board.c b/ports/esp32s2/boards/unexpectedmaker_feathers2_prerelease/board.c index 1dc30b5af8..abd22091ee 100644 --- a/ports/esp32s2/boards/unexpectedmaker_feathers2_prerelease/board.c +++ b/ports/esp32s2/boards/unexpectedmaker_feathers2_prerelease/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" #include "mpconfigboard.h" #include "shared-bindings/microcontroller/Pin.h" @@ -54,3 +54,6 @@ bool board_requests_safe_mode(void) { void reset_board(void) { } + +void board_deinit(void) { +} diff --git a/ports/esp32s2/common-hal/alarm/__init__.c b/ports/esp32s2/common-hal/alarm/__init__.c index 11e173fe2e..529179200d 100644 --- a/ports/esp32s2/common-hal/alarm/__init__.c +++ b/ports/esp32s2/common-hal/alarm/__init__.c @@ -32,38 +32,41 @@ #include "shared-bindings/alarm/pin/PinAlarm.h" #include "shared-bindings/alarm/time/TimeAlarm.h" #include "shared-bindings/microcontroller/__init__.h" -#include "shared-bindings/time/__init__.h" #include "shared-bindings/wifi/__init__.h" +#include "supervisor/port.h" +#include "supervisor/shared/workflow.h" + #include "common-hal/alarm/__init__.h" -#include "esp_log.h" #include "esp_sleep.h" -STATIC mp_obj_tuple_t *_deep_sleep_alarms; - void alarm_reset(void) { - _deep_sleep_alarms = mp_const_empty_tuple; -} - -void common_hal_alarm_disable_all(void) { + alarm_time_timealarm_reset(); esp_sleep_disable_wakeup_source(ESP_SLEEP_WAKEUP_ALL); } -mp_obj_t common_hal_alarm_get_wake_alarm(void) { - switch (esp_sleep_get_wakeup_cause()) { +STATIC esp_sleep_wakeup_cause_t _get_wakeup_cause(void) { + if (alarm_time_timealarm_woke_us_up()) { + return ESP_SLEEP_WAKEUP_TIMER; + } + + return esp_sleep_get_wakeup_cause(); +} + +bool alarm_woken_from_sleep(void) { + return _get_wakeup_cause() != ESP_SLEEP_WAKEUP_UNDEFINED; +} + +STATIC mp_obj_t _get_wake_alarm(size_t n_alarms, const mp_obj_t *alarms) { + switch (_get_wakeup_cause()) { case ESP_SLEEP_WAKEUP_TIMER: { - // Wake up from timer. - alarm_time_time_alarm_obj_t *timer = m_new_obj(alarm_time_time_alarm_obj_t); - timer->base.type = &alarm_time_time_alarm_type; - return timer; + return alarm_time_timealarm_get_wakeup_alarm(n_alarms, alarms); } case ESP_SLEEP_WAKEUP_EXT0: { - // Wake up from GPIO - alarm_pin_pin_alarm_obj_t *ext0 = m_new_obj(alarm_pin_pin_alarm_obj_t); - ext0->base.type = &alarm_pin_pin_alarm_type; - return ext0; + // TODO: implement pin alarm wake. + break; } case ESP_SLEEP_WAKEUP_TOUCHPAD: @@ -79,16 +82,19 @@ mp_obj_t common_hal_alarm_get_wake_alarm(void) { return mp_const_none; } +mp_obj_t common_hal_alarm_get_wake_alarm(void) { + return _get_wake_alarm(0, NULL); +} + // Set up light sleep or deep sleep alarms. -STATIC void setup_sleep_alarms(size_t n_alarms, const mp_obj_t *alarms) { +STATIC void _setup_sleep_alarms(bool deep_sleep, size_t n_alarms, const mp_obj_t *alarms) { bool time_alarm_set = false; alarm_time_time_alarm_obj_t *time_alarm = MP_OBJ_NULL; for (size_t i = 0; i < n_alarms; i++) { if (MP_OBJ_IS_TYPE(alarms[i], &alarm_pin_pin_alarm_type)) { mp_raise_NotImplementedError(translate("PinAlarm not yet implemented")); - } - else if (MP_OBJ_IS_TYPE(alarms[i], &alarm_time_time_alarm_type)) { + } else if (MP_OBJ_IS_TYPE(alarms[i], &alarm_time_time_alarm_type)) { if (time_alarm_set) { mp_raise_ValueError(translate("Only one alarm.time alarm can be set.")); } @@ -97,102 +103,50 @@ STATIC void setup_sleep_alarms(size_t n_alarms, const mp_obj_t *alarms) { } } - if (time_alarm != MP_OBJ_NULL) { - // Compute how long to actually sleep, considering the time now. - mp_float_t now_secs = uint64_to_float(common_hal_time_monotonic_ms()) / 1000.0f; - mp_float_t wakeup_in_secs = MAX(0.0f, time_alarm->monotonic_time - now_secs); - const uint64_t sleep_for_us = (uint64_t) (wakeup_in_secs * 1000000); - ESP_LOGI("ALARM", "will sleep for us: %lld", sleep_for_us); - esp_sleep_enable_timer_wakeup(sleep_for_us); + if (time_alarm_set) { + alarm_time_timealarm_set_alarm(time_alarm); } } -mp_obj_t common_hal_alarm_wait_until_alarms(size_t n_alarms, const mp_obj_t *alarms) { - if (n_alarms == 0) { - return mp_const_none; - } - - bool time_alarm_set = false; - alarm_time_time_alarm_obj_t *time_alarm = MP_OBJ_NULL; - - for (size_t i = 0; i < n_alarms; i++) { - if (MP_OBJ_IS_TYPE(alarms[i], &alarm_pin_pin_alarm_type)) { - mp_raise_NotImplementedError(translate("PinAlarm not yet implemented")); - } - else if (MP_OBJ_IS_TYPE(alarms[i], &alarm_time_time_alarm_type)) { - if (time_alarm_set) { - mp_raise_ValueError(translate("Only one alarm.time alarm can be set.")); - } - time_alarm = MP_OBJ_TO_PTR(alarms[i]); - time_alarm_set = true; +STATIC void _idle_until_alarm(void) { + // Poll for alarms. + while (!mp_hal_is_interrupted()) { + RUN_BACKGROUND_TASKS; + // Allow ctrl-C interrupt. + if (alarm_woken_from_sleep()) { + return; } + + port_idle_until_interrupt(); } - - ESP_LOGI("ALARM", "waiting for alarms"); - - if (time_alarm_set && n_alarms == 1) { - // If we're only checking time, avoid a polling loop, so maybe we can save some power. - const mp_float_t now_secs = uint64_to_float(common_hal_time_monotonic_ms()) / 1000.0f; - const mp_float_t wakeup_in_secs = MAX(0.0f, time_alarm->monotonic_time - now_secs); - const uint32_t delay_ms = (uint32_t) (wakeup_in_secs * 1000.0f); - ESP_LOGI("ALARM", "Delay for ms: %d", delay_ms); - common_hal_time_delay_ms((uint32_t) delay_ms); - } else { - // Poll for alarms. - while (true) { - RUN_BACKGROUND_TASKS; - // Allow ctrl-C interrupt. - if (mp_hal_is_interrupted()) { - return mp_const_none; - } - - // TODO: Check PinAlarms. - - if (time_alarm != MP_OBJ_NULL && - common_hal_time_monotonic_ms() * 1000.f >= time_alarm->monotonic_time) { - return time_alarm; - } - } - } - - return mp_const_none; } // Is it safe to do a light sleep? Check whether WiFi is on or there are // other ongoing tasks that should not be shut down. -static bool light_sleep_ok(void) { - return !common_hal_wifi_radio_get_enabled(&common_hal_wifi_radio_obj); +STATIC bool _light_sleep_ok(void) { + return !common_hal_wifi_radio_get_enabled(&common_hal_wifi_radio_obj) && !supervisor_workflow_active(); } mp_obj_t common_hal_alarm_light_sleep_until_alarms(size_t n_alarms, const mp_obj_t *alarms) { - if (n_alarms == 0) { - return mp_const_none; - } + _setup_sleep_alarms(false, n_alarms, alarms); - if (light_sleep_ok()) { - ESP_LOGI("ALARM", "start light sleep"); - setup_sleep_alarms(n_alarms, alarms); + // Light sleep can break some functionality so only do it when possible. Otherwise we idle. + if (_light_sleep_ok()) { esp_light_sleep_start(); - return common_hal_alarm_get_wake_alarm(); } else { - // Don't do an ESP32 light sleep. - return common_hal_alarm_wait_until_alarms(n_alarms, alarms); + _idle_until_alarm(); } + mp_obj_t wake_alarm = _get_wake_alarm(n_alarms, alarms); + alarm_reset(); + return wake_alarm; } -void common_hal_alarm_exit_and_deep_sleep_until_alarms(size_t n_alarms, const mp_obj_t *alarms) { - setup_sleep_alarms(n_alarms, alarms); - - // Raise an exception, which will be processed in main.c. - mp_raise_arg1(&mp_type_DeepSleepRequest, NULL); +void common_hal_alarm_set_deep_sleep_alarms(size_t n_alarms, const mp_obj_t *alarms) { + _setup_sleep_alarms(true, n_alarms, alarms); } -void common_hal_alarm_prepare_for_deep_sleep(void) { - // Turn off WiFi and anything else that should be shut down cleanly. - common_hal_wifi_radio_set_enabled(&common_hal_wifi_radio_obj, false); -} - -void NORETURN common_hal_alarm_enter_deep_sleep(void) { - ESP_LOGI("ALARM", "start deep sleep"); +void NORETURN alarm_enter_deep_sleep(void) { + // The ESP-IDF caches the deep sleep settings and applies them before sleep. + // We don't need to worry about resetting them in the interim. esp_deep_sleep_start(); } diff --git a/ports/esp32s2/common-hal/alarm/time/TimeAlarm.c b/ports/esp32s2/common-hal/alarm/time/TimeAlarm.c index 7af3694630..34c8b00523 100644 --- a/ports/esp32s2/common-hal/alarm/time/TimeAlarm.c +++ b/ports/esp32s2/common-hal/alarm/time/TimeAlarm.c @@ -27,8 +27,12 @@ #include "esp_sleep.h" #include "py/runtime.h" +#include "supervisor/esp_port.h" + +#include "components/esp_timer/include/esp_timer.h" #include "shared-bindings/alarm/time/TimeAlarm.h" +#include "shared-bindings/time/__init__.h" void common_hal_alarm_time_time_alarm_construct(alarm_time_time_alarm_obj_t *self, mp_float_t monotonic_time) { self->monotonic_time = monotonic_time; @@ -37,3 +41,63 @@ void common_hal_alarm_time_time_alarm_construct(alarm_time_time_alarm_obj_t *sel mp_float_t common_hal_alarm_time_time_alarm_get_monotonic_time(alarm_time_time_alarm_obj_t *self) { return self->monotonic_time; } + +mp_obj_t alarm_time_timealarm_get_wakeup_alarm(size_t n_alarms, const mp_obj_t *alarms) { + // First, check to see if we match + for (size_t i = 0; i < n_alarms; i++) { + if (MP_OBJ_IS_TYPE(alarms[i], &alarm_time_time_alarm_type)) { + return alarms[i]; + } + } + alarm_time_time_alarm_obj_t *timer = m_new_obj(alarm_time_time_alarm_obj_t); + timer->base.type = &alarm_time_time_alarm_type; + return timer; +} + +esp_timer_handle_t pretend_sleep_timer; +STATIC bool woke_up = false; + +// This is run in the timer task. We use it to wake the main CircuitPython task. +void timer_callback(void *arg) { + (void) arg; + woke_up = true; + if (sleeping_circuitpython_task) { + xTaskNotifyGive(sleeping_circuitpython_task); + } +} + +bool alarm_time_timealarm_woke_us_up(void) { + return woke_up; +} + +void alarm_time_timealarm_reset(void) { + esp_timer_stop(pretend_sleep_timer); + esp_timer_delete(pretend_sleep_timer); + pretend_sleep_timer = NULL; + woke_up = false; +} + +void alarm_time_timealarm_set_alarm(alarm_time_time_alarm_obj_t *self) { + if (pretend_sleep_timer != NULL) { + esp_timer_stop(pretend_sleep_timer); + } else { + // Configure the timer to use during pretend sleep. + esp_timer_create_args_t args; + args.callback = timer_callback; + args.arg = NULL; + args.dispatch_method = ESP_TIMER_TASK; + args.name = "Pretend deep sleep"; + esp_timer_create(&args, &pretend_sleep_timer); + } + + // Compute how long to actually sleep, considering the time now. + mp_float_t now_secs = uint64_to_float(common_hal_time_monotonic_ms()) / 1000.0f; + mp_float_t wakeup_in_secs = MAX(0.0f, self->monotonic_time - now_secs); + const uint64_t sleep_for_us = (uint64_t) (wakeup_in_secs * 1000000); + esp_sleep_enable_timer_wakeup(sleep_for_us); + + // Also set the RTC interrupt so it can wake our task. This will be wiped out + // if we actually deep sleep. + woke_up = false; + esp_timer_start_once(pretend_sleep_timer, sleep_for_us); +} diff --git a/ports/esp32s2/common-hal/alarm/time/TimeAlarm.h b/ports/esp32s2/common-hal/alarm/time/TimeAlarm.h index b540541f4d..04c553009e 100644 --- a/ports/esp32s2/common-hal/alarm/time/TimeAlarm.h +++ b/ports/esp32s2/common-hal/alarm/time/TimeAlarm.h @@ -31,3 +31,10 @@ typedef struct { mp_obj_base_t base; mp_float_t monotonic_time; // values compatible with time.monotonic_time() } alarm_time_time_alarm_obj_t; + +// Find the alarm object that caused us to wake up or create an equivalent one. +mp_obj_t alarm_time_timealarm_get_wakeup_alarm(size_t n_alarms, const mp_obj_t *alarms); +// Check for the wake up alarm from pretend deep sleep. +bool alarm_time_timealarm_woke_us_up(void); +void alarm_time_timealarm_set_alarm(alarm_time_time_alarm_obj_t *self); +void alarm_time_timealarm_reset(void); diff --git a/ports/esp32s2/common-hal/busio/SPI.c b/ports/esp32s2/common-hal/busio/SPI.c index da738bbfdd..562881585d 100644 --- a/ports/esp32s2/common-hal/busio/SPI.c +++ b/ports/esp32s2/common-hal/busio/SPI.c @@ -28,7 +28,6 @@ #include "py/mperrno.h" #include "py/runtime.h" -#include "boards/board.h" #include "shared-bindings/microcontroller/Pin.h" #include "supervisor/shared/rgb_led_status.h" diff --git a/ports/esp32s2/supervisor/port.c b/ports/esp32s2/supervisor/port.c index 6222cd2904..954fb93309 100644 --- a/ports/esp32s2/supervisor/port.c +++ b/ports/esp32s2/supervisor/port.c @@ -27,8 +27,8 @@ #include #include +#include "supervisor/board.h" #include "supervisor/port.h" -#include "boards/board.h" #include "modules/module.h" #include "py/runtime.h" #include "supervisor/esp_port.h" @@ -239,27 +239,31 @@ void port_enable_tick(void) { // Disable 1/1024 second tick. void port_disable_tick(void) { esp_timer_stop(_tick_timer); + + // CircuitPython's VM is run in a separate FreeRTOS task from TinyUSB. + // Tick disable can happen via auto-reload so poke the main task here. + if (sleeping_circuitpython_task != NULL) { + xTaskNotifyGive(sleeping_circuitpython_task); + } } TickType_t sleep_time_duration; void port_interrupt_after_ticks(uint32_t ticks) { sleep_time_duration = (ticks * 100)/1024; - sleeping_circuitpython_task = xTaskGetCurrentTaskHandle(); } -void port_sleep_until_interrupt(void) { - - uint32_t NotifyValue = 0; +void port_idle_until_interrupt(void) { + uint32_t notify_value = 0; if (sleep_time_duration == 0) { return; } - xTaskNotifyWait(0x01,0x01,&NotifyValue, - sleep_time_duration ); - if (NotifyValue == 1) { - sleeping_circuitpython_task = NULL; - mp_handle_pending(); + sleeping_circuitpython_task = xTaskGetCurrentTaskHandle(); + xTaskNotifyWait(0x01, 0x01, ¬ify_value, sleep_time_duration ); + sleeping_circuitpython_task = NULL; + if (notify_value == 1) { + mp_handle_pending(); } } diff --git a/ports/litex/boards/board.h b/ports/litex/boards/board.h deleted file mode 100644 index 837b371904..0000000000 --- a/ports/litex/boards/board.h +++ /dev/null @@ -1,45 +0,0 @@ -/* - * This file is part of the MicroPython project, http://micropython.org/ - * - * The MIT License (MIT) - * - * Copyright (c) 2017 Scott Shawcroft for Adafruit Industries - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -// This file defines board specific functions. - -#ifndef MICROPY_INCLUDED_LITEX_BOARDS_BOARD_H -#define MICROPY_INCLUDED_LITEX_BOARDS_BOARD_H - -#include - -// Initializes board related state once on start up. -void board_init(void); - -// Returns true if the user initiates safe mode in a board specific way. -// Also add BOARD_USER_SAFE_MODE in mpconfigboard.h to explain the board specific -// way. -bool board_requests_safe_mode(void); - -// Reset the state of off MCU components such as neopixels. -void reset_board(void); - -#endif // MICROPY_INCLUDED_LITEX_BOARDS_BOARD_H diff --git a/ports/litex/boards/fomu/board.c b/ports/litex/boards/fomu/board.c index 97e1ecadd6..a90f22f81e 100644 --- a/ports/litex/boards/fomu/board.c +++ b/ports/litex/boards/fomu/board.c @@ -24,7 +24,8 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" + #include "mpconfigboard.h" #include "csr.h" diff --git a/ports/litex/supervisor/port.c b/ports/litex/supervisor/port.c index f5c362ea6e..4dea020652 100644 --- a/ports/litex/supervisor/port.c +++ b/ports/litex/supervisor/port.c @@ -26,9 +26,9 @@ */ #include +#include "supervisor/board.h" #include "supervisor/port.h" #include "supervisor/shared/tick.h" -#include "boards/board.h" #include "irq.h" #include "csr.h" @@ -147,5 +147,5 @@ void port_interrupt_after_ticks(uint32_t ticks) { } // TODO: Add sleep support if the SoC supports sleep. -void port_sleep_until_interrupt(void) { +void port_idle_until_interrupt(void) { } diff --git a/ports/mimxrt10xx/board.h b/ports/mimxrt10xx/board.h new file mode 100644 index 0000000000..1c9596e7d2 --- /dev/null +++ b/ports/mimxrt10xx/board.h @@ -0,0 +1 @@ +// Empty but needed for the SDK diff --git a/ports/mimxrt10xx/boards/feather_m7_1011/board.c b/ports/mimxrt10xx/boards/feather_m7_1011/board.c index ed543e1b06..1db1dd6861 100644 --- a/ports/mimxrt10xx/boards/feather_m7_1011/board.c +++ b/ports/mimxrt10xx/boards/feather_m7_1011/board.c @@ -25,7 +25,8 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" +#include "boards/flash_config.h" #include "mpconfigboard.h" #include "shared-bindings/microcontroller/Pin.h" diff --git a/ports/mimxrt10xx/boards/feather_m7_1011/flash_config.c b/ports/mimxrt10xx/boards/feather_m7_1011/flash_config.c index 282464c75d..9ba3e168f5 100644 --- a/ports/mimxrt10xx/boards/feather_m7_1011/flash_config.c +++ b/ports/mimxrt10xx/boards/feather_m7_1011/flash_config.c @@ -5,9 +5,9 @@ * SPDX-License-Identifier: BSD-3-Clause */ -#include "fsl_flexspi_nor_boot.h" -#include "boards/board.h" +#include "boards/flash_config.h" +#include "fsl_flexspi_nor_boot.h" __attribute__((section(".boot_hdr.ivt"))) /************************************* diff --git a/ports/mimxrt10xx/boards/feather_m7_1011/pins.c b/ports/mimxrt10xx/boards/feather_m7_1011/pins.c index 09e3217614..04fbeea59b 100644 --- a/ports/mimxrt10xx/boards/feather_m7_1011/pins.c +++ b/ports/mimxrt10xx/boards/feather_m7_1011/pins.c @@ -1,6 +1,6 @@ #include "shared-bindings/board/__init__.h" -#include "boards/board.h" +#include "supervisor/board.h" STATIC const mp_rom_map_elem_t board_global_dict_table[] = { // Analog diff --git a/ports/mimxrt10xx/boards/feather_mimxrt1011/board.c b/ports/mimxrt10xx/boards/feather_mimxrt1011/board.c index ed543e1b06..1db1dd6861 100644 --- a/ports/mimxrt10xx/boards/feather_mimxrt1011/board.c +++ b/ports/mimxrt10xx/boards/feather_mimxrt1011/board.c @@ -25,7 +25,8 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" +#include "boards/flash_config.h" #include "mpconfigboard.h" #include "shared-bindings/microcontroller/Pin.h" diff --git a/ports/mimxrt10xx/boards/feather_mimxrt1011/flash_config.c b/ports/mimxrt10xx/boards/feather_mimxrt1011/flash_config.c index 51cc0f164b..eafc9ac3af 100644 --- a/ports/mimxrt10xx/boards/feather_mimxrt1011/flash_config.c +++ b/ports/mimxrt10xx/boards/feather_mimxrt1011/flash_config.c @@ -5,9 +5,9 @@ * SPDX-License-Identifier: BSD-3-Clause */ -#include "fsl_flexspi_nor_boot.h" -#include "boards/board.h" +#include "boards/flash_config.h" +#include "fsl_flexspi_nor_boot.h" __attribute__((section(".boot_hdr.ivt"))) /************************************* diff --git a/ports/mimxrt10xx/boards/feather_mimxrt1011/pins.c b/ports/mimxrt10xx/boards/feather_mimxrt1011/pins.c index 2c6c1ce93e..4e5de8de27 100644 --- a/ports/mimxrt10xx/boards/feather_mimxrt1011/pins.c +++ b/ports/mimxrt10xx/boards/feather_mimxrt1011/pins.c @@ -1,6 +1,6 @@ #include "shared-bindings/board/__init__.h" -#include "boards/board.h" +#include "supervisor/board.h" STATIC const mp_rom_map_elem_t board_global_dict_table[] = { // Analog diff --git a/ports/mimxrt10xx/boards/feather_mimxrt1062/board.c b/ports/mimxrt10xx/boards/feather_mimxrt1062/board.c index 9878a62a29..26f55f96e1 100644 --- a/ports/mimxrt10xx/boards/feather_mimxrt1062/board.c +++ b/ports/mimxrt10xx/boards/feather_mimxrt1062/board.c @@ -25,7 +25,8 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" +#include "boards/flash_config.h" #include "mpconfigboard.h" #include "shared-bindings/microcontroller/Pin.h" diff --git a/ports/mimxrt10xx/boards/feather_mimxrt1062/flash_config.c b/ports/mimxrt10xx/boards/feather_mimxrt1062/flash_config.c index 51cc0f164b..fef1c11e3e 100644 --- a/ports/mimxrt10xx/boards/feather_mimxrt1062/flash_config.c +++ b/ports/mimxrt10xx/boards/feather_mimxrt1062/flash_config.c @@ -5,8 +5,9 @@ * SPDX-License-Identifier: BSD-3-Clause */ +#include "boards/flash_config.h" + #include "fsl_flexspi_nor_boot.h" -#include "boards/board.h" __attribute__((section(".boot_hdr.ivt"))) diff --git a/ports/mimxrt10xx/boards/feather_mimxrt1062/pins.c b/ports/mimxrt10xx/boards/feather_mimxrt1062/pins.c index eb287b87aa..d372b951f6 100644 --- a/ports/mimxrt10xx/boards/feather_mimxrt1062/pins.c +++ b/ports/mimxrt10xx/boards/feather_mimxrt1062/pins.c @@ -1,6 +1,6 @@ #include "shared-bindings/board/__init__.h" -#include "boards/board.h" +#include "supervisor/board.h" STATIC const mp_rom_map_elem_t board_global_dict_table[] = { // Analog diff --git a/ports/mimxrt10xx/boards/board.h b/ports/mimxrt10xx/boards/flash_config.h similarity index 75% rename from ports/mimxrt10xx/boards/board.h rename to ports/mimxrt10xx/boards/flash_config.h index 678c223ae0..25f1550ae8 100644 --- a/ports/mimxrt10xx/boards/board.h +++ b/ports/mimxrt10xx/boards/flash_config.h @@ -26,26 +26,16 @@ // This file defines board specific functions. -#ifndef MICROPY_INCLUDED_MIMXRT10XX_BOARDS_BOARD_H -#define MICROPY_INCLUDED_MIMXRT10XX_BOARDS_BOARD_H +#ifndef MICROPY_INCLUDED_MIMXRT10XX_BOARDS_FLASH_CONFIG_H +#define MICROPY_INCLUDED_MIMXRT10XX_BOARDS_FLASH_CONFIG_H #include -#include "py/mpconfig.h" +#include "mpconfigboard.h" // For flash size settings + #include "fsl_common.h" #include "fsl_flexspi_nor_config.h" -// Initializes board related state once on start up. -void board_init(void); - -// Returns true if the user initiates safe mode in a board specific way. -// Also add BOARD_USER_SAFE_MODE in mpconfigboard.h to explain the board specific -// way. -bool board_requests_safe_mode(void); - -// Reset the state of off MCU components such as neopixels. -void reset_board(void); - #define SEQUENCE(first, second, third, fourth) first, second, third, fourth #define TWO_EMPTY_STEPS 0x00000000 #define EMPTY_SEQUENCE SEQUENCE(TWO_EMPTY_STEPS, TWO_EMPTY_STEPS, TWO_EMPTY_STEPS, TWO_EMPTY_STEPS) @@ -53,4 +43,4 @@ void reset_board(void); // FlexSPI configuration that stores command info. extern const flexspi_nor_config_t qspiflash_config; -#endif // MICROPY_INCLUDED_MIMXRT10XX_BOARDS_BOARD_H +#endif // MICROPY_INCLUDED_MIMXRT10XX_BOARDS_FLASH_CONFIG_H diff --git a/ports/mimxrt10xx/boards/imxrt1010_evk/board.c b/ports/mimxrt10xx/boards/imxrt1010_evk/board.c index ba3498581c..8519893a5f 100644 --- a/ports/mimxrt10xx/boards/imxrt1010_evk/board.c +++ b/ports/mimxrt10xx/boards/imxrt1010_evk/board.c @@ -25,7 +25,8 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" +#include "boards/flash_config.h" #include "mpconfigboard.h" #include "shared-bindings/microcontroller/Pin.h" diff --git a/ports/mimxrt10xx/boards/imxrt1010_evk/flash_config.c b/ports/mimxrt10xx/boards/imxrt1010_evk/flash_config.c index 19573bd993..00ee47c985 100644 --- a/ports/mimxrt10xx/boards/imxrt1010_evk/flash_config.c +++ b/ports/mimxrt10xx/boards/imxrt1010_evk/flash_config.c @@ -5,8 +5,9 @@ * SPDX-License-Identifier: BSD-3-Clause */ +#include "boards/flash_config.h" + #include "fsl_flexspi_nor_boot.h" -#include "boards/board.h" __attribute__((section(".boot_hdr.ivt"))) diff --git a/ports/mimxrt10xx/boards/imxrt1010_evk/pins.c b/ports/mimxrt10xx/boards/imxrt1010_evk/pins.c index a0221a2ad2..4aad9aaeb3 100644 --- a/ports/mimxrt10xx/boards/imxrt1010_evk/pins.c +++ b/ports/mimxrt10xx/boards/imxrt1010_evk/pins.c @@ -1,6 +1,6 @@ #include "shared-bindings/board/__init__.h" -#include "boards/board.h" +#include "supervisor/board.h" STATIC const mp_rom_map_elem_t board_global_dict_table[] = { { MP_OBJ_NEW_QSTR(MP_QSTR_D0), MP_ROM_PTR(&pin_GPIO_09) }, diff --git a/ports/mimxrt10xx/boards/imxrt1020_evk/board.c b/ports/mimxrt10xx/boards/imxrt1020_evk/board.c index d5166b3560..531c0c6f62 100644 --- a/ports/mimxrt10xx/boards/imxrt1020_evk/board.c +++ b/ports/mimxrt10xx/boards/imxrt1020_evk/board.c @@ -25,7 +25,8 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" +#include "boards/flash_config.h" #include "mpconfigboard.h" #include "shared-bindings/microcontroller/Pin.h" diff --git a/ports/mimxrt10xx/boards/imxrt1020_evk/flash_config.c b/ports/mimxrt10xx/boards/imxrt1020_evk/flash_config.c index 40b566618e..4c3ba47179 100644 --- a/ports/mimxrt10xx/boards/imxrt1020_evk/flash_config.c +++ b/ports/mimxrt10xx/boards/imxrt1020_evk/flash_config.c @@ -5,8 +5,9 @@ * SPDX-License-Identifier: BSD-3-Clause */ +#include "boards/flash_config.h" + #include "fsl_flexspi_nor_boot.h" -#include "boards/board.h" __attribute__((section(".boot_hdr.ivt"))) diff --git a/ports/mimxrt10xx/boards/imxrt1020_evk/pins.c b/ports/mimxrt10xx/boards/imxrt1020_evk/pins.c index ef8115a64f..2052a12429 100644 --- a/ports/mimxrt10xx/boards/imxrt1020_evk/pins.c +++ b/ports/mimxrt10xx/boards/imxrt1020_evk/pins.c @@ -1,6 +1,6 @@ #include "shared-bindings/board/__init__.h" -#include "boards/board.h" +#include "supervisor/board.h" STATIC const mp_rom_map_elem_t board_global_dict_table[] = { { MP_OBJ_NEW_QSTR(MP_QSTR_D0), MP_ROM_PTR(&pin_GPIO_AD_B1_09) }, diff --git a/ports/mimxrt10xx/boards/imxrt1060_evk/board.c b/ports/mimxrt10xx/boards/imxrt1060_evk/board.c index 25bc4e8c9d..e7d74ab49f 100644 --- a/ports/mimxrt10xx/boards/imxrt1060_evk/board.c +++ b/ports/mimxrt10xx/boards/imxrt1060_evk/board.c @@ -25,7 +25,8 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" +#include "boards/flash_config.h" #include "mpconfigboard.h" #include "shared-bindings/microcontroller/Pin.h" diff --git a/ports/mimxrt10xx/boards/imxrt1060_evk/flash_config.c b/ports/mimxrt10xx/boards/imxrt1060_evk/flash_config.c index d79a8d0f91..502e21a3b0 100644 --- a/ports/mimxrt10xx/boards/imxrt1060_evk/flash_config.c +++ b/ports/mimxrt10xx/boards/imxrt1060_evk/flash_config.c @@ -5,8 +5,9 @@ * SPDX-License-Identifier: BSD-3-Clause */ +#include "boards/flash_config.h" + #include "fsl_flexspi_nor_boot.h" -#include "boards/board.h" __attribute__((section(".boot_hdr.ivt"))) diff --git a/ports/mimxrt10xx/boards/imxrt1060_evk/pins.c b/ports/mimxrt10xx/boards/imxrt1060_evk/pins.c index 2d268952d1..b24e4dc86d 100644 --- a/ports/mimxrt10xx/boards/imxrt1060_evk/pins.c +++ b/ports/mimxrt10xx/boards/imxrt1060_evk/pins.c @@ -1,6 +1,6 @@ #include "shared-bindings/board/__init__.h" -#include "boards/board.h" +#include "supervisor/board.h" STATIC const mp_rom_map_elem_t board_global_dict_table[] = { { MP_OBJ_NEW_QSTR(MP_QSTR_D0), MP_ROM_PTR(&pin_GPIO_AD_B1_07) }, diff --git a/ports/mimxrt10xx/boards/metro_m7_1011/board.c b/ports/mimxrt10xx/boards/metro_m7_1011/board.c index ed543e1b06..1db1dd6861 100644 --- a/ports/mimxrt10xx/boards/metro_m7_1011/board.c +++ b/ports/mimxrt10xx/boards/metro_m7_1011/board.c @@ -25,7 +25,8 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" +#include "boards/flash_config.h" #include "mpconfigboard.h" #include "shared-bindings/microcontroller/Pin.h" diff --git a/ports/mimxrt10xx/boards/metro_m7_1011/flash_config.c b/ports/mimxrt10xx/boards/metro_m7_1011/flash_config.c index 30ce67523e..991bc43e45 100644 --- a/ports/mimxrt10xx/boards/metro_m7_1011/flash_config.c +++ b/ports/mimxrt10xx/boards/metro_m7_1011/flash_config.c @@ -5,8 +5,9 @@ * SPDX-License-Identifier: BSD-3-Clause */ +#include "boards/flash_config.h" + #include "fsl_flexspi_nor_boot.h" -#include "boards/board.h" __attribute__((section(".boot_hdr.ivt"))) diff --git a/ports/mimxrt10xx/boards/metro_m7_1011/pins.c b/ports/mimxrt10xx/boards/metro_m7_1011/pins.c index e884934134..ea9ae55290 100644 --- a/ports/mimxrt10xx/boards/metro_m7_1011/pins.c +++ b/ports/mimxrt10xx/boards/metro_m7_1011/pins.c @@ -1,6 +1,6 @@ #include "shared-bindings/board/__init__.h" -#include "boards/board.h" +#include "supervisor/board.h" STATIC const mp_rom_map_elem_t board_global_dict_table[] = { // Analog diff --git a/ports/mimxrt10xx/boards/teensy40/board.c b/ports/mimxrt10xx/boards/teensy40/board.c index 09f0bf3f2a..33ad5ff04a 100644 --- a/ports/mimxrt10xx/boards/teensy40/board.c +++ b/ports/mimxrt10xx/boards/teensy40/board.c @@ -25,7 +25,8 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" +#include "boards/flash_config.h" #include "mpconfigboard.h" #include "shared-bindings/microcontroller/Pin.h" diff --git a/ports/mimxrt10xx/boards/teensy40/flash_config.c b/ports/mimxrt10xx/boards/teensy40/flash_config.c index 30ce67523e..991bc43e45 100644 --- a/ports/mimxrt10xx/boards/teensy40/flash_config.c +++ b/ports/mimxrt10xx/boards/teensy40/flash_config.c @@ -5,8 +5,9 @@ * SPDX-License-Identifier: BSD-3-Clause */ +#include "boards/flash_config.h" + #include "fsl_flexspi_nor_boot.h" -#include "boards/board.h" __attribute__((section(".boot_hdr.ivt"))) diff --git a/ports/mimxrt10xx/boards/teensy40/pins.c b/ports/mimxrt10xx/boards/teensy40/pins.c index 9066ce0d20..64b4aa7f69 100644 --- a/ports/mimxrt10xx/boards/teensy40/pins.c +++ b/ports/mimxrt10xx/boards/teensy40/pins.c @@ -1,6 +1,6 @@ #include "shared-bindings/board/__init__.h" -#include "boards/board.h" +#include "supervisor/board.h" STATIC const mp_rom_map_elem_t board_global_dict_table[] = { // With USB on left. Bottom edge. diff --git a/ports/mimxrt10xx/boards/teensy41/board.c b/ports/mimxrt10xx/boards/teensy41/board.c index 09f0bf3f2a..33ad5ff04a 100644 --- a/ports/mimxrt10xx/boards/teensy41/board.c +++ b/ports/mimxrt10xx/boards/teensy41/board.c @@ -25,7 +25,8 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" +#include "boards/flash_config.h" #include "mpconfigboard.h" #include "shared-bindings/microcontroller/Pin.h" diff --git a/ports/mimxrt10xx/boards/teensy41/flash_config.c b/ports/mimxrt10xx/boards/teensy41/flash_config.c index 7b2bfb768d..c0e0c86f98 100644 --- a/ports/mimxrt10xx/boards/teensy41/flash_config.c +++ b/ports/mimxrt10xx/boards/teensy41/flash_config.c @@ -5,8 +5,9 @@ * SPDX-License-Identifier: BSD-3-Clause */ +#include "boards/flash_config.h" + #include "fsl_flexspi_nor_boot.h" -#include "boards/board.h" __attribute__((section(".boot_hdr.ivt"))) diff --git a/ports/mimxrt10xx/boards/teensy41/pins.c b/ports/mimxrt10xx/boards/teensy41/pins.c index 5eb5ab0f55..cf24513019 100644 --- a/ports/mimxrt10xx/boards/teensy41/pins.c +++ b/ports/mimxrt10xx/boards/teensy41/pins.c @@ -1,6 +1,6 @@ #include "shared-bindings/board/__init__.h" -#include "boards/board.h" +#include "supervisor/board.h" STATIC const mp_rom_map_elem_t board_global_dict_table[] = { // With USB on left. Bottom edge. diff --git a/ports/mimxrt10xx/supervisor/flexspi_nor_flash_ops.c b/ports/mimxrt10xx/supervisor/flexspi_nor_flash_ops.c index 353ba3176d..bd471f9305 100644 --- a/ports/mimxrt10xx/supervisor/flexspi_nor_flash_ops.c +++ b/ports/mimxrt10xx/supervisor/flexspi_nor_flash_ops.c @@ -9,7 +9,7 @@ #include "fsl_flexspi.h" #include "internal_flash.h" -#include "boards/board.h" +#include "boards/flash_config.h" #include "supervisor/linker.h" status_t PLACE_IN_ITCM(flexspi_nor_write_enable)(FLEXSPI_Type *base, uint32_t baseAddr) diff --git a/ports/mimxrt10xx/supervisor/internal_flash.c b/ports/mimxrt10xx/supervisor/internal_flash.c index e194cbed96..9c0d9f8956 100644 --- a/ports/mimxrt10xx/supervisor/internal_flash.c +++ b/ports/mimxrt10xx/supervisor/internal_flash.c @@ -30,7 +30,7 @@ #include #include -#include "boards/board.h" +#include "boards/flash_config.h" #include "extmod/vfs.h" #include "extmod/vfs_fat.h" #include "py/mphal.h" diff --git a/ports/mimxrt10xx/supervisor/port.c b/ports/mimxrt10xx/supervisor/port.c index 1be2b10396..33a85d2b72 100644 --- a/ports/mimxrt10xx/supervisor/port.c +++ b/ports/mimxrt10xx/supervisor/port.c @@ -31,7 +31,7 @@ * SPDX-License-Identifier: BSD-3-Clause */ -#include "boards/board.h" +#include "supervisor/board.h" #include "supervisor/port.h" #include "fsl_device_registers.h" @@ -403,7 +403,7 @@ void port_interrupt_after_ticks(uint32_t ticks) { SNVS->HPCR |= SNVS_HPCR_HPTA_EN_MASK; } -void port_sleep_until_interrupt(void) { +void port_idle_until_interrupt(void) { // App note here: https://www.nxp.com/docs/en/application-note/AN12085.pdf // Clear the FPU interrupt because it can prevent us from sleeping. diff --git a/ports/nrf/boards/ADM_B_NRF52840_1/board.c b/ports/nrf/boards/ADM_B_NRF52840_1/board.c index 4421970eef..7817933281 100644 --- a/ports/nrf/boards/ADM_B_NRF52840_1/board.c +++ b/ports/nrf/boards/ADM_B_NRF52840_1/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" void board_init(void) { } diff --git a/ports/nrf/boards/TG-Watch02A/board.c b/ports/nrf/boards/TG-Watch02A/board.c index 4421970eef..7817933281 100644 --- a/ports/nrf/boards/TG-Watch02A/board.c +++ b/ports/nrf/boards/TG-Watch02A/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" void board_init(void) { } diff --git a/ports/nrf/boards/aramcon_badge_2019/board.c b/ports/nrf/boards/aramcon_badge_2019/board.c index efb449285b..8f3830b000 100644 --- a/ports/nrf/boards/aramcon_badge_2019/board.c +++ b/ports/nrf/boards/aramcon_badge_2019/board.c @@ -25,7 +25,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" #include "common-hal/microcontroller/Pin.h" void board_init(void) { diff --git a/ports/nrf/boards/arduino_nano_33_ble/board.c b/ports/nrf/boards/arduino_nano_33_ble/board.c index ddfcde2848..d1689e9ddc 100644 --- a/ports/nrf/boards/arduino_nano_33_ble/board.c +++ b/ports/nrf/boards/arduino_nano_33_ble/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" #include "nrf.h" #include "nrf_rtc.h" diff --git a/ports/nrf/boards/bless_dev_board_multi_sensor/board.c b/ports/nrf/boards/bless_dev_board_multi_sensor/board.c index 71b9a06577..6970294ecc 100644 --- a/ports/nrf/boards/bless_dev_board_multi_sensor/board.c +++ b/ports/nrf/boards/bless_dev_board_multi_sensor/board.c @@ -1,4 +1,4 @@ -#include "boards/board.h" +#include "supervisor/board.h" void board_init(void) { } diff --git a/ports/nrf/boards/board.h b/ports/nrf/boards/board.h deleted file mode 100644 index ec98f04fbe..0000000000 --- a/ports/nrf/boards/board.h +++ /dev/null @@ -1,45 +0,0 @@ -/* - * This file is part of the MicroPython project, http://micropython.org/ - * - * The MIT License (MIT) - * - * Copyright (c) 2017 Scott Shawcroft for Adafruit Industries - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -// This file defines board specific functions. - -#ifndef MICROPY_INCLUDED_NRF_BOARDS_BOARD_H -#define MICROPY_INCLUDED_NRF_BOARDS_BOARD_H - -#include - -// Initializes board related state once on start up. -void board_init(void); - -// Returns true if the user initiates safe mode in a board specific way. -// Also add BOARD_USER_SAFE_MODE in mpconfigboard.h to explain the board specific -// way. -bool board_requests_safe_mode(void); - -// Reset the state of off MCU components such as neopixels. -void reset_board(void); - -#endif // MICROPY_INCLUDED_NRF_BOARDS_BOARD_H diff --git a/ports/nrf/boards/circuitplayground_bluefruit/board.c b/ports/nrf/boards/circuitplayground_bluefruit/board.c index 3aa6857da2..ff731d8f98 100644 --- a/ports/nrf/boards/circuitplayground_bluefruit/board.c +++ b/ports/nrf/boards/circuitplayground_bluefruit/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" #include "mpconfigboard.h" #include "py/obj.h" #include "peripherals/nrf/pins.h" @@ -49,5 +49,5 @@ void reset_board(void) { NRF_GPIO_PIN_NOSENSE); nrf_gpio_pin_write(POWER_SWITCH_PIN->number, false); - board_reset_user_neopixels(); + board_reset_user_neopixels(&pin_P0_13, 10); } diff --git a/ports/nrf/boards/clue_nrf52840_express/board.c b/ports/nrf/boards/clue_nrf52840_express/board.c index 523bd7677b..cd46ce75d3 100644 --- a/ports/nrf/boards/clue_nrf52840_express/board.c +++ b/ports/nrf/boards/clue_nrf52840_express/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" #include "mpconfigboard.h" #include "shared-bindings/busio/SPI.h" diff --git a/ports/nrf/boards/clue_nrf52840_express/pins.c b/ports/nrf/boards/clue_nrf52840_express/pins.c index ab0738893c..61d77cedc9 100644 --- a/ports/nrf/boards/clue_nrf52840_express/pins.c +++ b/ports/nrf/boards/clue_nrf52840_express/pins.c @@ -1,6 +1,6 @@ #include "shared-bindings/board/__init__.h" -#include "boards/board.h" +#include "supervisor/board.h" #include "shared-module/displayio/__init__.h" STATIC const mp_rom_map_elem_t board_module_globals_table[] = { diff --git a/ports/nrf/boards/electronut_labs_blip/board.c b/ports/nrf/boards/electronut_labs_blip/board.c index 4421970eef..7817933281 100644 --- a/ports/nrf/boards/electronut_labs_blip/board.c +++ b/ports/nrf/boards/electronut_labs_blip/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" void board_init(void) { } diff --git a/ports/nrf/boards/electronut_labs_papyr/board.c b/ports/nrf/boards/electronut_labs_papyr/board.c index 4421970eef..7817933281 100644 --- a/ports/nrf/boards/electronut_labs_papyr/board.c +++ b/ports/nrf/boards/electronut_labs_papyr/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" void board_init(void) { } diff --git a/ports/nrf/boards/feather_bluefruit_sense/board.c b/ports/nrf/boards/feather_bluefruit_sense/board.c index 4421970eef..7817933281 100644 --- a/ports/nrf/boards/feather_bluefruit_sense/board.c +++ b/ports/nrf/boards/feather_bluefruit_sense/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" void board_init(void) { } diff --git a/ports/nrf/boards/feather_nrf52840_express/board.c b/ports/nrf/boards/feather_nrf52840_express/board.c index 4421970eef..7817933281 100644 --- a/ports/nrf/boards/feather_nrf52840_express/board.c +++ b/ports/nrf/boards/feather_nrf52840_express/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" void board_init(void) { } diff --git a/ports/nrf/boards/hiibot_bluefi/board.c b/ports/nrf/boards/hiibot_bluefi/board.c index 93e31aef0c..a3fd5cf129 100644 --- a/ports/nrf/boards/hiibot_bluefi/board.c +++ b/ports/nrf/boards/hiibot_bluefi/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" #include "mpconfigboard.h" #include "shared-bindings/busio/SPI.h" diff --git a/ports/nrf/boards/hiibot_bluefi/pins.c b/ports/nrf/boards/hiibot_bluefi/pins.c index bce4ee52dd..c7879c4c21 100644 --- a/ports/nrf/boards/hiibot_bluefi/pins.c +++ b/ports/nrf/boards/hiibot_bluefi/pins.c @@ -1,6 +1,6 @@ #include "shared-bindings/board/__init__.h" -#include "boards/board.h" +#include "supervisor/board.h" #include "shared-module/displayio/__init__.h" STATIC const mp_rom_map_elem_t board_module_globals_table[] = { diff --git a/ports/nrf/boards/ikigaisense_vita/board.c b/ports/nrf/boards/ikigaisense_vita/board.c index 4421970eef..7817933281 100644 --- a/ports/nrf/boards/ikigaisense_vita/board.c +++ b/ports/nrf/boards/ikigaisense_vita/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" void board_init(void) { } diff --git a/ports/nrf/boards/itsybitsy_nrf52840_express/board.c b/ports/nrf/boards/itsybitsy_nrf52840_express/board.c index 4421970eef..7817933281 100644 --- a/ports/nrf/boards/itsybitsy_nrf52840_express/board.c +++ b/ports/nrf/boards/itsybitsy_nrf52840_express/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" void board_init(void) { } diff --git a/ports/nrf/boards/makerdiary_m60_keyboard/board.c b/ports/nrf/boards/makerdiary_m60_keyboard/board.c index 4421970eef..7817933281 100644 --- a/ports/nrf/boards/makerdiary_m60_keyboard/board.c +++ b/ports/nrf/boards/makerdiary_m60_keyboard/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" void board_init(void) { } diff --git a/ports/nrf/boards/makerdiary_m60_keyboard/pins.c b/ports/nrf/boards/makerdiary_m60_keyboard/pins.c index 63c3ad1711..fc85fa24b0 100644 --- a/ports/nrf/boards/makerdiary_m60_keyboard/pins.c +++ b/ports/nrf/boards/makerdiary_m60_keyboard/pins.c @@ -1,6 +1,6 @@ #include "shared-bindings/board/__init__.h" -#include "boards/board.h" +#include "supervisor/board.h" #include "shared-module/displayio/__init__.h" STATIC const mp_rom_map_elem_t board_module_globals_table[] = { diff --git a/ports/nrf/boards/makerdiary_nrf52840_m2_devkit/board.c b/ports/nrf/boards/makerdiary_nrf52840_m2_devkit/board.c index e08d00daca..569106ec2a 100644 --- a/ports/nrf/boards/makerdiary_nrf52840_m2_devkit/board.c +++ b/ports/nrf/boards/makerdiary_nrf52840_m2_devkit/board.c @@ -25,7 +25,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" #include "mpconfigboard.h" #include "shared-bindings/busio/SPI.h" diff --git a/ports/nrf/boards/makerdiary_nrf52840_m2_devkit/pins.c b/ports/nrf/boards/makerdiary_nrf52840_m2_devkit/pins.c index 7dc6db18fa..1892868330 100644 --- a/ports/nrf/boards/makerdiary_nrf52840_m2_devkit/pins.c +++ b/ports/nrf/boards/makerdiary_nrf52840_m2_devkit/pins.c @@ -1,6 +1,6 @@ #include "shared-bindings/board/__init__.h" -#include "boards/board.h" +#include "supervisor/board.h" #include "shared-module/displayio/__init__.h" STATIC const mp_rom_map_elem_t board_module_globals_table[] = { diff --git a/ports/nrf/boards/makerdiary_nrf52840_mdk/board.c b/ports/nrf/boards/makerdiary_nrf52840_mdk/board.c index 4421970eef..7817933281 100644 --- a/ports/nrf/boards/makerdiary_nrf52840_mdk/board.c +++ b/ports/nrf/boards/makerdiary_nrf52840_mdk/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" void board_init(void) { } diff --git a/ports/nrf/boards/makerdiary_nrf52840_mdk_usb_dongle/board.c b/ports/nrf/boards/makerdiary_nrf52840_mdk_usb_dongle/board.c index 4421970eef..7817933281 100644 --- a/ports/nrf/boards/makerdiary_nrf52840_mdk_usb_dongle/board.c +++ b/ports/nrf/boards/makerdiary_nrf52840_mdk_usb_dongle/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" void board_init(void) { } diff --git a/ports/nrf/boards/metro_nrf52840_express/board.c b/ports/nrf/boards/metro_nrf52840_express/board.c index 4421970eef..7817933281 100644 --- a/ports/nrf/boards/metro_nrf52840_express/board.c +++ b/ports/nrf/boards/metro_nrf52840_express/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" void board_init(void) { } diff --git a/ports/nrf/boards/nice_nano/board.c b/ports/nrf/boards/nice_nano/board.c index 4421970eef..7817933281 100644 --- a/ports/nrf/boards/nice_nano/board.c +++ b/ports/nrf/boards/nice_nano/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" void board_init(void) { } diff --git a/ports/nrf/boards/ohs2020_badge/board.c b/ports/nrf/boards/ohs2020_badge/board.c index ec52690ced..20abf4e2a9 100644 --- a/ports/nrf/boards/ohs2020_badge/board.c +++ b/ports/nrf/boards/ohs2020_badge/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" #include "mpconfigboard.h" #include "shared-bindings/busio/SPI.h" diff --git a/ports/nrf/boards/particle_argon/board.c b/ports/nrf/boards/particle_argon/board.c index f891f54a13..a41f0ae06e 100644 --- a/ports/nrf/boards/particle_argon/board.c +++ b/ports/nrf/boards/particle_argon/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" void board_init(void) { } diff --git a/ports/nrf/boards/particle_boron/board.c b/ports/nrf/boards/particle_boron/board.c index f891f54a13..a41f0ae06e 100644 --- a/ports/nrf/boards/particle_boron/board.c +++ b/ports/nrf/boards/particle_boron/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" void board_init(void) { } diff --git a/ports/nrf/boards/particle_xenon/board.c b/ports/nrf/boards/particle_xenon/board.c index f891f54a13..a41f0ae06e 100644 --- a/ports/nrf/boards/particle_xenon/board.c +++ b/ports/nrf/boards/particle_xenon/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" void board_init(void) { } diff --git a/ports/nrf/boards/pca10056/board.c b/ports/nrf/boards/pca10056/board.c index 4421970eef..7817933281 100644 --- a/ports/nrf/boards/pca10056/board.c +++ b/ports/nrf/boards/pca10056/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" void board_init(void) { } diff --git a/ports/nrf/boards/pca10059/board.c b/ports/nrf/boards/pca10059/board.c index 4421970eef..7817933281 100644 --- a/ports/nrf/boards/pca10059/board.c +++ b/ports/nrf/boards/pca10059/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" void board_init(void) { } diff --git a/ports/nrf/boards/pca10100/board.c b/ports/nrf/boards/pca10100/board.c index f891f54a13..a41f0ae06e 100644 --- a/ports/nrf/boards/pca10100/board.c +++ b/ports/nrf/boards/pca10100/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" void board_init(void) { } diff --git a/ports/nrf/boards/pitaya_go/board.c b/ports/nrf/boards/pitaya_go/board.c index 4421970eef..7817933281 100644 --- a/ports/nrf/boards/pitaya_go/board.c +++ b/ports/nrf/boards/pitaya_go/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" void board_init(void) { } diff --git a/ports/nrf/boards/raytac_mdbt50q-db-40/board.c b/ports/nrf/boards/raytac_mdbt50q-db-40/board.c index 4421970eef..7817933281 100644 --- a/ports/nrf/boards/raytac_mdbt50q-db-40/board.c +++ b/ports/nrf/boards/raytac_mdbt50q-db-40/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" void board_init(void) { } diff --git a/ports/nrf/boards/simmel/board.c b/ports/nrf/boards/simmel/board.c index f891f54a13..a41f0ae06e 100644 --- a/ports/nrf/boards/simmel/board.c +++ b/ports/nrf/boards/simmel/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" void board_init(void) { } diff --git a/ports/nrf/boards/sparkfun_nrf52840_mini/board.c b/ports/nrf/boards/sparkfun_nrf52840_mini/board.c index 4421970eef..7817933281 100644 --- a/ports/nrf/boards/sparkfun_nrf52840_mini/board.c +++ b/ports/nrf/boards/sparkfun_nrf52840_mini/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" void board_init(void) { } diff --git a/ports/nrf/boards/teknikio_bluebird/board.c b/ports/nrf/boards/teknikio_bluebird/board.c index 4421970eef..7817933281 100644 --- a/ports/nrf/boards/teknikio_bluebird/board.c +++ b/ports/nrf/boards/teknikio_bluebird/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" void board_init(void) { } diff --git a/ports/nrf/boards/tinkeringtech_scoutmakes_azul/board.c b/ports/nrf/boards/tinkeringtech_scoutmakes_azul/board.c index 4421970eef..7817933281 100644 --- a/ports/nrf/boards/tinkeringtech_scoutmakes_azul/board.c +++ b/ports/nrf/boards/tinkeringtech_scoutmakes_azul/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" void board_init(void) { } diff --git a/ports/nrf/supervisor/port.c b/ports/nrf/supervisor/port.c index 5f1c9f1ba9..00485d8588 100644 --- a/ports/nrf/supervisor/port.c +++ b/ports/nrf/supervisor/port.c @@ -26,7 +26,7 @@ #include #include "supervisor/port.h" -#include "boards/board.h" +#include "supervisor/board.h" #include "nrfx/hal/nrf_clock.h" #include "nrfx/hal/nrf_power.h" @@ -307,7 +307,7 @@ void port_interrupt_after_ticks(uint32_t ticks) { nrfx_rtc_cc_set(&rtc_instance, 0, current_ticks + diff, true); } -void port_sleep_until_interrupt(void) { +void port_idle_until_interrupt(void) { #if defined(MICROPY_QSPI_CS) qspi_disable(); #endif diff --git a/ports/stm/boards/board.h b/ports/stm/boards/board.h deleted file mode 100644 index 22d9e99be0..0000000000 --- a/ports/stm/boards/board.h +++ /dev/null @@ -1,45 +0,0 @@ -/* - * This file is part of the MicroPython project, http://micropython.org/ - * - * The MIT License (MIT) - * - * Copyright (c) 2017 Scott Shawcroft for Adafruit Industries - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -// This file defines board specific functions. - -#ifndef MICROPY_INCLUDED_STM32F4_BOARDS_BOARD_H -#define MICROPY_INCLUDED_STM32F4_BOARDS_BOARD_H - -#include - -// Initializes board related state once on start up. -void board_init(void); - -// Returns true if the user initiates safe mode in a board specific way. -// Also add BOARD_USER_SAFE_MODE in mpconfigboard.h to explain the board specific -// way. -bool board_requests_safe_mode(void); - -// Reset the state of off MCU components such as neopixels. -void reset_board(void); - -#endif // MICROPY_INCLUDED_STM32F4_BOARDS_BOARD_H diff --git a/ports/stm/boards/espruino_pico/board.c b/ports/stm/boards/espruino_pico/board.c index 82b0c506ed..f8e462f938 100644 --- a/ports/stm/boards/espruino_pico/board.c +++ b/ports/stm/boards/espruino_pico/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" #include "mpconfigboard.h" void board_init(void) { diff --git a/ports/stm/boards/espruino_wifi/board.c b/ports/stm/boards/espruino_wifi/board.c index 4421970eef..7817933281 100644 --- a/ports/stm/boards/espruino_wifi/board.c +++ b/ports/stm/boards/espruino_wifi/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" void board_init(void) { } diff --git a/ports/stm/boards/feather_stm32f405_express/board.c b/ports/stm/boards/feather_stm32f405_express/board.c index 82b0c506ed..f8e462f938 100644 --- a/ports/stm/boards/feather_stm32f405_express/board.c +++ b/ports/stm/boards/feather_stm32f405_express/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" #include "mpconfigboard.h" void board_init(void) { diff --git a/ports/stm/boards/meowbit_v121/board.c b/ports/stm/boards/meowbit_v121/board.c index f67b4a49db..4a8014a3a1 100644 --- a/ports/stm/boards/meowbit_v121/board.c +++ b/ports/stm/boards/meowbit_v121/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" #include "mpconfigboard.h" #include "shared-bindings/board/__init__.h" diff --git a/ports/stm/boards/nucleo_f746zg/board.c b/ports/stm/boards/nucleo_f746zg/board.c index 4421970eef..7817933281 100644 --- a/ports/stm/boards/nucleo_f746zg/board.c +++ b/ports/stm/boards/nucleo_f746zg/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" void board_init(void) { } diff --git a/ports/stm/boards/nucleo_f767zi/board.c b/ports/stm/boards/nucleo_f767zi/board.c index 4421970eef..7817933281 100644 --- a/ports/stm/boards/nucleo_f767zi/board.c +++ b/ports/stm/boards/nucleo_f767zi/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" void board_init(void) { } diff --git a/ports/stm/boards/nucleo_h743zi_2/board.c b/ports/stm/boards/nucleo_h743zi_2/board.c index 4421970eef..7817933281 100644 --- a/ports/stm/boards/nucleo_h743zi_2/board.c +++ b/ports/stm/boards/nucleo_h743zi_2/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" void board_init(void) { } diff --git a/ports/stm/boards/openmv_h7/board.c b/ports/stm/boards/openmv_h7/board.c index 4421970eef..7817933281 100644 --- a/ports/stm/boards/openmv_h7/board.c +++ b/ports/stm/boards/openmv_h7/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" void board_init(void) { } diff --git a/ports/stm/boards/pyb_nano_v2/board.c b/ports/stm/boards/pyb_nano_v2/board.c index 82b0c506ed..f8e462f938 100644 --- a/ports/stm/boards/pyb_nano_v2/board.c +++ b/ports/stm/boards/pyb_nano_v2/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" #include "mpconfigboard.h" void board_init(void) { diff --git a/ports/stm/boards/pyboard_v11/board.c b/ports/stm/boards/pyboard_v11/board.c index 4421970eef..7817933281 100644 --- a/ports/stm/boards/pyboard_v11/board.c +++ b/ports/stm/boards/pyboard_v11/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" void board_init(void) { } diff --git a/ports/stm/boards/stm32f411ce_blackpill/board.c b/ports/stm/boards/stm32f411ce_blackpill/board.c index 82b0c506ed..f8e462f938 100644 --- a/ports/stm/boards/stm32f411ce_blackpill/board.c +++ b/ports/stm/boards/stm32f411ce_blackpill/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" #include "mpconfigboard.h" void board_init(void) { diff --git a/ports/stm/boards/stm32f411ve_discovery/board.c b/ports/stm/boards/stm32f411ve_discovery/board.c index 4421970eef..7817933281 100644 --- a/ports/stm/boards/stm32f411ve_discovery/board.c +++ b/ports/stm/boards/stm32f411ve_discovery/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" void board_init(void) { } diff --git a/ports/stm/boards/stm32f412zg_discovery/board.c b/ports/stm/boards/stm32f412zg_discovery/board.c index 4421970eef..7817933281 100644 --- a/ports/stm/boards/stm32f412zg_discovery/board.c +++ b/ports/stm/boards/stm32f412zg_discovery/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" void board_init(void) { } diff --git a/ports/stm/boards/stm32f4_discovery/board.c b/ports/stm/boards/stm32f4_discovery/board.c index 4421970eef..7817933281 100644 --- a/ports/stm/boards/stm32f4_discovery/board.c +++ b/ports/stm/boards/stm32f4_discovery/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" void board_init(void) { } diff --git a/ports/stm/boards/stm32f746g_discovery/board.c b/ports/stm/boards/stm32f746g_discovery/board.c index aafc69cf02..db2c727271 100644 --- a/ports/stm/boards/stm32f746g_discovery/board.c +++ b/ports/stm/boards/stm32f746g_discovery/board.c @@ -25,7 +25,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" #include "stm32f7xx_hal.h" #include "common-hal/microcontroller/Pin.h" diff --git a/ports/stm/boards/thunderpack_v11/board.c b/ports/stm/boards/thunderpack_v11/board.c index 4421970eef..7817933281 100644 --- a/ports/stm/boards/thunderpack_v11/board.c +++ b/ports/stm/boards/thunderpack_v11/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" void board_init(void) { } diff --git a/ports/stm/boards/thunderpack_v12/board.c b/ports/stm/boards/thunderpack_v12/board.c index 4421970eef..7817933281 100644 --- a/ports/stm/boards/thunderpack_v12/board.c +++ b/ports/stm/boards/thunderpack_v12/board.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "boards/board.h" +#include "supervisor/board.h" void board_init(void) { } diff --git a/ports/stm/common-hal/busio/SPI.c b/ports/stm/common-hal/busio/SPI.c index 29fbdee569..20ee0f6e15 100644 --- a/ports/stm/common-hal/busio/SPI.c +++ b/ports/stm/common-hal/busio/SPI.c @@ -32,7 +32,7 @@ #include "py/runtime.h" #include "shared-bindings/microcontroller/__init__.h" -#include "boards/board.h" +#include "supervisor/board.h" #include "supervisor/shared/translate.h" #include "shared-bindings/microcontroller/Pin.h" diff --git a/ports/stm/common-hal/sdioio/SDCard.c b/ports/stm/common-hal/sdioio/SDCard.c index 5f6010f01a..de0e8d1119 100644 --- a/ports/stm/common-hal/sdioio/SDCard.c +++ b/ports/stm/common-hal/sdioio/SDCard.c @@ -31,7 +31,7 @@ #include "shared-bindings/microcontroller/__init__.h" #include "shared-bindings/util.h" -#include "boards/board.h" +#include "supervisor/board.h" #include "supervisor/shared/translate.h" #include "common-hal/microcontroller/Pin.h" #include "shared-bindings/microcontroller/Pin.h" diff --git a/ports/stm/supervisor/port.c b/ports/stm/supervisor/port.c index dba1cf21ee..3103a07160 100644 --- a/ports/stm/supervisor/port.c +++ b/ports/stm/supervisor/port.c @@ -27,7 +27,7 @@ #include #include "supervisor/port.h" -#include "boards/board.h" +#include "supervisor/board.h" #include "lib/timeutils/timeutils.h" #include "common-hal/microcontroller/Pin.h" @@ -436,7 +436,7 @@ void port_interrupt_after_ticks(uint32_t ticks) { alarmed_already = false; } -void port_sleep_until_interrupt(void) { +void port_idle_until_interrupt(void) { // Clear the FPU interrupt because it can prevent us from sleeping. if (__get_FPSCR() & ~(0x9f)) { __set_FPSCR(__get_FPSCR() & ~(0x9f)); diff --git a/py/circuitpy_mpconfig.h b/py/circuitpy_mpconfig.h index f04112bfcd..0bd889ccdf 100644 --- a/py/circuitpy_mpconfig.h +++ b/py/circuitpy_mpconfig.h @@ -912,6 +912,12 @@ void supervisor_run_background_tasks_if_tick(void); #define CIRCUITPY_PYSTACK_SIZE 1536 #endif + +// Wait this long imediately after startup to see if we are connected to USB. +#ifndef CIRCUITPY_USB_CONNECTED_SLEEP_DELAY +#define CIRCUITPY_USB_CONNECTED_SLEEP_DELAY 5 +#endif + #define CIRCUITPY_BOOT_OUTPUT_FILE "/boot_out.txt" #define CIRCUITPY_VERBOSE_BLE 0 diff --git a/shared-bindings/alarm/__init__.c b/shared-bindings/alarm/__init__.c index a1f1a2f8c2..5420b8404b 100644 --- a/shared-bindings/alarm/__init__.c +++ b/shared-bindings/alarm/__init__.c @@ -36,9 +36,6 @@ #include "supervisor/shared/autoreload.h" #include "supervisor/shared/workflow.h" -// Wait this long imediately after startup to see if we are connected to USB. -#define CIRCUITPY_USB_CONNECTED_SLEEP_DELAY 5 - //| """Alarms and sleep //| //| Provides alarms that trigger based on time intervals or on external events, such as pin @@ -93,21 +90,13 @@ void validate_objs_are_alarms(size_t n_args, const mp_obj_t *objs) { //| ... //| STATIC mp_obj_t alarm_light_sleep_until_alarms(size_t n_args, const mp_obj_t *args) { + if (n_args == 0) { + return mp_const_none; + } + validate_objs_are_alarms(n_args, args); - // See if we are connected to a host. - // Make sure we have been awake long enough for USB to connect (enumeration delay). - int64_t connecting_delay_msec = CIRCUITPY_USB_CONNECTED_SLEEP_DELAY * 1024 - supervisor_ticks_ms64(); - if (connecting_delay_msec > 0) { - common_hal_time_delay_ms(connecting_delay_msec * 1000 / 1024); - } - - if (supervisor_workflow_active()) { - common_hal_alarm_wait_until_alarms(n_args, args); - } else { - common_hal_alarm_light_sleep_until_alarms(n_args, args); - } - return mp_const_none; + return common_hal_alarm_light_sleep_until_alarms(n_args, args); } MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(alarm_light_sleep_until_alarms_obj, 1, MP_OBJ_FUN_ARGS_MAX, alarm_light_sleep_until_alarms); @@ -151,26 +140,13 @@ MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(alarm_light_sleep_until_alarms_obj, 1, MP_OB STATIC mp_obj_t alarm_exit_and_deep_sleep_until_alarms(size_t n_args, const mp_obj_t *args) { validate_objs_are_alarms(n_args, args); - // Shut down WiFi, etc. - common_hal_alarm_prepare_for_deep_sleep(); + // Validate the alarms and set them. + common_hal_alarm_set_deep_sleep_alarms(n_args, args); - // See if we are connected to a host. - // Make sure we have been awake long enough for USB to connect (enumeration delay). - int64_t connecting_delay_msec = CIRCUITPY_USB_CONNECTED_SLEEP_DELAY * 1024 - supervisor_ticks_ms64(); - if (connecting_delay_msec > 0) { - common_hal_time_delay_ms(connecting_delay_msec * 1000 / 1024); - } + // Raise an exception, which will be processed in main.c. + mp_raise_arg1(&mp_type_DeepSleepRequest, NULL); - if (supervisor_workflow_active()) { - // Simulate deep sleep by waiting for an alarm and then restarting when done. - common_hal_alarm_wait_until_alarms(n_args, args); - reload_requested = true; - supervisor_set_run_reason(RUN_REASON_STARTUP); - mp_raise_reload_exception(); - } else { - common_hal_alarm_exit_and_deep_sleep_until_alarms(n_args, args); - // Does not return. - } + // Doesn't get here. return mp_const_none; } MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(alarm_exit_and_deep_sleep_until_alarms_obj, 1, MP_OBJ_FUN_ARGS_MAX, alarm_exit_and_deep_sleep_until_alarms); diff --git a/shared-bindings/alarm/__init__.h b/shared-bindings/alarm/__init__.h index 380c65ea8c..5a8c613d9d 100644 --- a/shared-bindings/alarm/__init__.h +++ b/shared-bindings/alarm/__init__.h @@ -31,13 +31,22 @@ #include "common-hal/alarm/__init__.h" -extern mp_obj_t common_hal_alarm_wait_until_alarms(size_t n_alarms, const mp_obj_t *alarms); extern mp_obj_t common_hal_alarm_light_sleep_until_alarms(size_t n_alarms, const mp_obj_t *alarms); -extern void common_hal_alarm_exit_and_deep_sleep_until_alarms(size_t n_alarms, const mp_obj_t *alarms); -extern void common_hal_alarm_prepare_for_deep_sleep(void); -extern NORETURN void common_hal_alarm_enter_deep_sleep(void); + +// Deep sleep is a two step process. Alarms are set when the VM is valid but +// everything is reset before entering deep sleep. Furthermore, deep sleep may +// not actually happen if the user is connected to the device. In this case, the +// supervisor will idle using `port_wait_for_interrupt`. After each call, it will +// call alarm_woken_from_sleep to see if we've been woken by an alarm and if so, +// it will exit idle as if deep sleep was exited. +extern void common_hal_alarm_set_deep_sleep_alarms(size_t n_alarms, const mp_obj_t *alarms); +// Deep sleep is entered outside of the VM so we omit the `common_hal_` prefix. +extern NORETURN void alarm_enter_deep_sleep(void); // Used by wake-up code. extern void common_hal_alarm_set_wake_alarm(mp_obj_t alarm); +// True if an alarm is alerting. This is most useful for pretend deep sleep. +extern bool alarm_woken_from_sleep(void); + #endif // MICROPY_INCLUDED_SHARED_BINDINGS_ALARM___INIT___H diff --git a/ports/esp32s2/boards/board.h b/supervisor/board.h similarity index 77% rename from ports/esp32s2/boards/board.h rename to supervisor/board.h index 2f0db81356..939ee1c194 100644 --- a/ports/esp32s2/boards/board.h +++ b/supervisor/board.h @@ -24,22 +24,30 @@ * THE SOFTWARE. */ -// This file defines board specific functions. - -#ifndef MICROPY_INCLUDED_ESP32S2_BOARDS_BOARD_H -#define MICROPY_INCLUDED_ESP32S2_BOARDS_BOARD_H +#ifndef MICROPY_INCLUDED_SUPERVISOR_BOARD_H +#define MICROPY_INCLUDED_SUPERVISOR_BOARD_H #include -// Initializes board related state once on start up. -void board_init(void); +#include "supervisor/shared/safe_mode.h" // Returns true if the user initiates safe mode in a board specific way. // Also add BOARD_USER_SAFE_MODE in mpconfigboard.h to explain the board specific // way. bool board_requests_safe_mode(void); +// Initializes board related state once on start up. +void board_init(void); + // Reset the state of off MCU components such as neopixels. void reset_board(void); -#endif // MICROPY_INCLUDED_ESP32S2_BOARDS_BOARD_H +#if CIRCUITPY_ALARM +// Deinit the board. This should put the board in deep sleep durable, low power +// state. It should not prevent the user access method from working (such as +// disabling USB, BLE or flash) because CircuitPython may continue to run. +void board_deinit(void); +#endif + + +#endif // MICROPY_INCLUDED_SUPERVISOR_BOARD_H diff --git a/supervisor/port.h b/supervisor/port.h index 5bc06bc4e1..862400986b 100644 --- a/supervisor/port.h +++ b/supervisor/port.h @@ -49,9 +49,6 @@ void reset_cpu(void) NORETURN; // Reset the microcontroller state. void reset_port(void); -// Reset the rest of the board. -void reset_board(void); - // Reset to the bootloader void reset_to_bootloader(void) NORETURN; @@ -89,8 +86,9 @@ void port_disable_tick(void); // Only the common sleep routine should use it. void port_interrupt_after_ticks(uint32_t ticks); -// Sleep the CPU until an interrupt is received. -void port_sleep_until_interrupt(void); +// Sleep the CPU until an interrupt is received. We call this idle because it +// may not be a system level sleep. +void port_idle_until_interrupt(void); // Execute port specific actions during background tasks. void port_background_task(void); @@ -100,4 +98,5 @@ void port_background_task(void); // work" should be done in port_background_task() instead. void port_start_background_task(void); void port_finish_background_task(void); + #endif // MICROPY_INCLUDED_SUPERVISOR_PORT_H diff --git a/supervisor/shared/board.c b/supervisor/shared/board.c index e3eb8fd0d7..111aa0e3c9 100644 --- a/supervisor/shared/board.c +++ b/supervisor/shared/board.c @@ -26,23 +26,22 @@ #include "supervisor/shared/board.h" +#if CIRCUITPY_DIGITALIO && CIRCUITPY_NEOPIXEL_WRITE + +#include + #include "shared-bindings/digitalio/DigitalInOut.h" #include "shared-bindings/neopixel_write/__init__.h" -#ifdef USER_NEOPIXELS_PIN - -// The maximum number of user neopixels right now is 10, on Circuit Playgrounds. -// PyBadge and PyGamer have max 5 -#define USER_NEOPIXELS_MAX_COUNT 10 - -void board_reset_user_neopixels(void) { +void board_reset_user_neopixels(mcu_pin_obj_t* pin, size_t count) { // Turn off on-board NeoPixel string - uint8_t empty[USER_NEOPIXELS_MAX_COUNT * 3] = { 0 }; + uint8_t empty[count * 3]; + memset(empty, 0, count); digitalio_digitalinout_obj_t neopixel_pin; - common_hal_digitalio_digitalinout_construct(&neopixel_pin, USER_NEOPIXELS_PIN); + common_hal_digitalio_digitalinout_construct(&neopixel_pin, pin); common_hal_digitalio_digitalinout_switch_to_output(&neopixel_pin, false, DRIVE_MODE_PUSH_PULL); - common_hal_neopixel_write(&neopixel_pin, empty, USER_NEOPIXELS_MAX_COUNT * 3); + common_hal_neopixel_write(&neopixel_pin, empty, count * 3); common_hal_digitalio_digitalinout_deinit(&neopixel_pin); } diff --git a/supervisor/shared/board.h b/supervisor/shared/board.h index 0e4d73455d..cdeefbf222 100644 --- a/supervisor/shared/board.h +++ b/supervisor/shared/board.h @@ -24,15 +24,13 @@ * THE SOFTWARE. */ -#ifndef MICROPY_INCLUDED_SUPERVISOR_BOARD_H -#define MICROPY_INCLUDED_SUPERVISOR_BOARD_H +#ifndef MICROPY_INCLUDED_SUPERVISOR_SHARED_BOARD_H +#define MICROPY_INCLUDED_SUPERVISOR_SHARED_BOARD_H -#include "py/mpconfig.h" +#include -#ifdef USER_NEOPIXELS_PIN +#include "shared-bindings/microcontroller/Pin.h" -void board_reset_user_neopixels(void); +void board_reset_user_neopixels(mcu_pin_obj_t* pin, size_t count); -#endif - -#endif // MICROPY_INCLUDED_SUPERVISOR_BOARD_H +#endif // MICROPY_INCLUDED_SUPERVISOR_SHARED_BOARD_H diff --git a/supervisor/shared/tick.c b/supervisor/shared/tick.c index a2855a5706..d37a585eb2 100644 --- a/supervisor/shared/tick.c +++ b/supervisor/shared/tick.c @@ -156,8 +156,8 @@ void mp_hal_delay_ms(mp_uint_t delay) { break; } port_interrupt_after_ticks(remaining); - // Sleep until an interrupt happens. - port_sleep_until_interrupt(); + // Idle until an interrupt happens. + port_idle_until_interrupt(); remaining = end_tick - port_get_raw_ticks(NULL); } }