aboutsummaryrefslogtreecommitdiff
path: root/ports/stm32/main.c
diff options
context:
space:
mode:
authorDamien George2018-02-05 15:48:28 +1100
committerDamien George2018-02-05 15:52:36 +1100
commit4607be3768b0f6fd187fb7f17545ec3a7d28b94c (patch)
tree2ea5a22b9aa67d9e50e99d340b020dc6c1cab76a /ports/stm32/main.c
parent12464f1bd2c63af012d1ce47c79f9afbfefd71e2 (diff)
stm32/main: Reorder some init calls to put them before soft-reset loop.
The calls to rtc_init_start(), sdcard_init() and storage_init() are all guarded by a check for first_soft_reset, so it's simpler to just put them all before the soft-reset loop, without the check. The call to machine_init() can also go before the soft-reset loop because it is only needed to check the reset cause which can happen once at the first boot. To allow this to work, the reset cause must be set to SOFT upon a soft-reset, which is the role of the new function machine_deinit().
Diffstat (limited to 'ports/stm32/main.c')
-rw-r--r--ports/stm32/main.c31
1 files changed, 11 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();