summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ports/stm32/main.c31
-rw-r--r--ports/stm32/modmachine.c5
-rw-r--r--ports/stm32/modmachine.h1
3 files changed, 17 insertions, 20 deletions
diff --git a/ports/stm32/main.c b/ports/stm32/main.c
index 5617747e9..1f39b9b9c 100644
--- a/ports/stm32/main.c
+++ b/ports/stm32/main.c
@@ -454,13 +454,21 @@ int main(void) {
#endif
pendsv_init();
led_init();
-#if MICROPY_HW_HAS_SWITCH
+ #if MICROPY_HW_HAS_SWITCH
switch_init0();
-#endif
+ #endif
+ machine_init();
+ #if MICROPY_HW_ENABLE_RTC
+ rtc_init_start(false);
+ #endif
spi_init0();
#if MICROPY_HW_ENABLE_HW_I2C
i2c_init0();
#endif
+ #if MICROPY_HW_HAS_SDCARD
+ sdcard_init();
+ #endif
+ storage_init();
#if defined(USE_DEVICE_MODE)
// default to internal flash being the usb medium
@@ -483,24 +491,6 @@ soft_reset:
led_state(4, 0);
uint reset_mode = update_reset_mode(1);
- machine_init();
-
-#if MICROPY_HW_ENABLE_RTC
- if (first_soft_reset) {
- rtc_init_start(false);
- }
-#endif
-
- // more sub-system init
-#if MICROPY_HW_HAS_SDCARD
- if (first_soft_reset) {
- sdcard_init();
- }
-#endif
- if (first_soft_reset) {
- storage_init();
- }
-
// Python threading init
#if MICROPY_PY_THREAD
mp_thread_init();
@@ -692,6 +682,7 @@ soft_reset_exit:
#if MICROPY_HW_ENABLE_CAN
can_deinit();
#endif
+ machine_deinit();
#if MICROPY_PY_THREAD
pyb_thread_deinit();
diff --git a/ports/stm32/modmachine.c b/ports/stm32/modmachine.c
index fba27a3bb..3645fe60e 100644
--- a/ports/stm32/modmachine.c
+++ b/ports/stm32/modmachine.c
@@ -99,6 +99,11 @@ void machine_init(void) {
RCC->CSR |= RCC_CSR_RMVF;
}
+void machine_deinit(void) {
+ // we are doing a soft-reset so change the reset_cause
+ reset_cause = PYB_RESET_SOFT;
+}
+
// machine.info([dump_alloc_table])
// Print out lots of information about the board.
STATIC mp_obj_t machine_info(size_t n_args, const mp_obj_t *args) {
diff --git a/ports/stm32/modmachine.h b/ports/stm32/modmachine.h
index 77668695f..81c6375c7 100644
--- a/ports/stm32/modmachine.h
+++ b/ports/stm32/modmachine.h
@@ -29,6 +29,7 @@
#include "py/obj.h"
void machine_init(void);
+void machine_deinit(void);
MP_DECLARE_CONST_FUN_OBJ_VAR_BETWEEN(machine_info_obj);
MP_DECLARE_CONST_FUN_OBJ_0(machine_unique_id_obj);