summaryrefslogtreecommitdiff
path: root/ports/stm
diff options
context:
space:
mode:
authorScott Shawcroft <scott@tannewt.org>2020-12-02 18:05:29 -0800
committerScott Shawcroft <scott@tannewt.org>2020-12-08 10:52:25 -0800
commit40118bcf57f026fd6a58733501c759a9ba87e835 (patch)
treec3f00ed7deaa7dcb6effde8afb97413b5e6fcbde /ports/stm
parent1df033465a366724fbbab5ff48082593722f7c41 (diff)
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
Diffstat (limited to 'ports/stm')
-rw-r--r--ports/stm/boards/board.h45
-rw-r--r--ports/stm/boards/espruino_pico/board.c2
-rw-r--r--ports/stm/boards/espruino_wifi/board.c2
-rw-r--r--ports/stm/boards/feather_stm32f405_express/board.c2
-rw-r--r--ports/stm/boards/meowbit_v121/board.c2
-rw-r--r--ports/stm/boards/nucleo_f746zg/board.c2
-rw-r--r--ports/stm/boards/nucleo_f767zi/board.c2
-rw-r--r--ports/stm/boards/nucleo_h743zi_2/board.c2
-rw-r--r--ports/stm/boards/openmv_h7/board.c2
-rw-r--r--ports/stm/boards/pyb_nano_v2/board.c2
-rw-r--r--ports/stm/boards/pyboard_v11/board.c2
-rw-r--r--ports/stm/boards/stm32f411ce_blackpill/board.c2
-rw-r--r--ports/stm/boards/stm32f411ve_discovery/board.c2
-rw-r--r--ports/stm/boards/stm32f412zg_discovery/board.c2
-rw-r--r--ports/stm/boards/stm32f4_discovery/board.c2
-rw-r--r--ports/stm/boards/stm32f746g_discovery/board.c2
-rw-r--r--ports/stm/boards/thunderpack_v11/board.c2
-rw-r--r--ports/stm/boards/thunderpack_v12/board.c2
-rw-r--r--ports/stm/common-hal/busio/SPI.c2
-rw-r--r--ports/stm/common-hal/sdioio/SDCard.c2
-rw-r--r--ports/stm/supervisor/port.c4
21 files changed, 21 insertions, 66 deletions
diff --git a/ports/stm/boards/board.h b/ports/stm/boards/board.h
deleted file mode 100644
index 22d9e99be..000000000
--- 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 <stdbool.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_STM32F4_BOARDS_BOARD_H
diff --git a/ports/stm/boards/espruino_pico/board.c b/ports/stm/boards/espruino_pico/board.c
index 82b0c506e..f8e462f93 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 4421970ee..781793328 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 82b0c506e..f8e462f93 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 f67b4a49d..4a8014a3a 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 4421970ee..781793328 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 4421970ee..781793328 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 4421970ee..781793328 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 4421970ee..781793328 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 82b0c506e..f8e462f93 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 4421970ee..781793328 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 82b0c506e..f8e462f93 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 4421970ee..781793328 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 4421970ee..781793328 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 4421970ee..781793328 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 aafc69cf0..db2c72727 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 4421970ee..781793328 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 4421970ee..781793328 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 29fbdee56..20ee0f6e1 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 5f6010f01..de0e8d111 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 dba1cf21e..3103a0716 100644
--- a/ports/stm/supervisor/port.c
+++ b/ports/stm/supervisor/port.c
@@ -27,7 +27,7 @@
#include <stdint.h>
#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));