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().
This commit is contained in:
parent
12464f1bd2
commit
4607be3768
@ -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();
|
||||
|
@ -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) {
|
||||
|
@ -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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user