mirror of
https://github.com/openmv/openmv.git
synced 2025-11-04 14:49:50 +08:00
ports/stm32: Deinit CYW43 on soft-reset.
This commit is contained in:
parent
75d968051b
commit
eaeff63f34
@ -276,11 +276,6 @@ soft_reset:
|
|||||||
// Initialize the stack and GC memory.
|
// Initialize the stack and GC memory.
|
||||||
mp_init_gc_stack(&_sstack, &_estack, &_heap_start, &_heap_end, 1024);
|
mp_init_gc_stack(&_sstack, &_estack, &_heap_start, &_heap_end, 1024);
|
||||||
|
|
||||||
#if MICROPY_ENABLE_PYSTACK
|
|
||||||
static mp_obj_t pystack[384];
|
|
||||||
mp_pystack_init(pystack, &pystack[384]);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Micro Python init
|
// Micro Python init
|
||||||
mp_init();
|
mp_init();
|
||||||
|
|
||||||
@ -321,9 +316,8 @@ soft_reset:
|
|||||||
#endif
|
#endif
|
||||||
rtc_init_start(false);
|
rtc_init_start(false);
|
||||||
#if MICROPY_PY_LWIP
|
#if MICROPY_PY_LWIP
|
||||||
// lwIP doesn't allow to reinitialise itself by subsequent calls to this function
|
// lwIP can only be initialized once, because the system timeout
|
||||||
// because the system timeout list (next_timeout) is only ever reset by BSS clearing.
|
// list (next_timeout), is only ever reset by BSS clearing.
|
||||||
// So for now we only init the lwIP stack once on power-up.
|
|
||||||
if (first_soft_reset) {
|
if (first_soft_reset) {
|
||||||
lwip_init();
|
lwip_init();
|
||||||
#if LWIP_MDNS_RESPONDER
|
#if LWIP_MDNS_RESPONDER
|
||||||
@ -332,12 +326,12 @@ soft_reset:
|
|||||||
}
|
}
|
||||||
systick_enable_dispatch(SYSTICK_DISPATCH_LWIP, mod_network_lwip_poll_wrapper);
|
systick_enable_dispatch(SYSTICK_DISPATCH_LWIP, mod_network_lwip_poll_wrapper);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if MICROPY_PY_BLUETOOTH
|
#if MICROPY_PY_BLUETOOTH
|
||||||
mp_bluetooth_hci_init();
|
mp_bluetooth_hci_init();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if MICROPY_PY_NETWORK_CYW43
|
#if MICROPY_PY_NETWORK_CYW43
|
||||||
if (first_soft_reset) {
|
|
||||||
cyw43_init(&cyw43_state);
|
cyw43_init(&cyw43_state);
|
||||||
uint8_t buf[8];
|
uint8_t buf[8];
|
||||||
memcpy(&buf[0], "PYBD", 4);
|
memcpy(&buf[0], "PYBD", 4);
|
||||||
@ -345,7 +339,6 @@ soft_reset:
|
|||||||
cyw43_wifi_ap_set_ssid(&cyw43_state, 8, buf);
|
cyw43_wifi_ap_set_ssid(&cyw43_state, 8, buf);
|
||||||
cyw43_wifi_ap_set_auth(&cyw43_state, CYW43_AUTH_WPA2_AES_PSK);
|
cyw43_wifi_ap_set_auth(&cyw43_state, CYW43_AUTH_WPA2_AES_PSK);
|
||||||
cyw43_wifi_ap_set_password(&cyw43_state, 8, (const uint8_t *) "pybd0123");
|
cyw43_wifi_ap_set_password(&cyw43_state, 8, (const uint8_t *) "pybd0123");
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
pyb_usb_init0();
|
pyb_usb_init0();
|
||||||
@ -361,10 +354,9 @@ soft_reset:
|
|||||||
py_imu_init();
|
py_imu_init();
|
||||||
#endif // MICROPY_PY_IMU
|
#endif // MICROPY_PY_IMU
|
||||||
|
|
||||||
|
#if MICROPY_PY_NETWORK
|
||||||
mod_network_init();
|
mod_network_init();
|
||||||
|
#endif
|
||||||
// Remove the BASEPRI masking (if any)
|
|
||||||
irq_set_base_priority(0);
|
|
||||||
|
|
||||||
#if MICROPY_HW_ENABLE_SDCARD
|
#if MICROPY_HW_ENABLE_SDCARD
|
||||||
// Initialize storage
|
// Initialize storage
|
||||||
@ -462,9 +454,7 @@ else {
|
|||||||
// report if SDRAM failed
|
// report if SDRAM failed
|
||||||
#if MICROPY_HW_SDRAM_SIZE
|
#if MICROPY_HW_SDRAM_SIZE
|
||||||
if (first_soft_reset && (!sdram_ok)) {
|
if (first_soft_reset && (!sdram_ok)) {
|
||||||
char buf[512];
|
__fatal_error("Failed to init sdram!");
|
||||||
snprintf(buf, sizeof(buf), "Failed to init sdram!");
|
|
||||||
__fatal_error(buf);
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -532,20 +522,7 @@ else {
|
|||||||
usbdbg_set_irq_enabled(false);
|
usbdbg_set_irq_enabled(false);
|
||||||
nlr_pop();
|
nlr_pop();
|
||||||
} else {
|
} else {
|
||||||
mp_obj_print_exception(&mp_plat_print, (mp_obj_t) nlr.ret_val);
|
mp_obj_print_exception(MP_PYTHON_PRINTER, (mp_obj_t) nlr.ret_val);
|
||||||
}
|
|
||||||
|
|
||||||
if (usbdbg_is_busy() && nlr_push(&nlr) == 0) {
|
|
||||||
// Enable IDE interrupt
|
|
||||||
usbdbg_set_irq_enabled(true);
|
|
||||||
#if OMV_WIFIDBG_ENABLE && MICROPY_PY_WINC1500
|
|
||||||
wifidbg_set_irq_enabled(openmv_config.wifidbg);
|
|
||||||
#endif
|
|
||||||
// Wait for the current command to finish.
|
|
||||||
usbdbg_wait_for_command(1000);
|
|
||||||
// Disable IDE interrupts
|
|
||||||
usbdbg_set_irq_enabled(false);
|
|
||||||
nlr_pop();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -553,19 +530,11 @@ else {
|
|||||||
|
|
||||||
soft_reset_exit:
|
soft_reset_exit:
|
||||||
// soft reset
|
// soft reset
|
||||||
mp_printf(&mp_plat_print, "MPY: soft reboot\n");
|
mp_printf(MP_PYTHON_PRINTER, "MPY: soft reboot\n");
|
||||||
|
|
||||||
// Flush filesystem storage.
|
// Flush filesystem storage.
|
||||||
storage_flush();
|
storage_flush();
|
||||||
|
|
||||||
// Call GC sweep first, before deinitializing networking drivers
|
|
||||||
// such as WINC/CYW43 which need to be active to close sockets
|
|
||||||
// when their finalizers are called by GC.
|
|
||||||
gc_sweep_all();
|
|
||||||
|
|
||||||
// Disable all other IRQs except Systick
|
|
||||||
irq_set_base_priority(IRQ_PRI_SYSTICK + 1);
|
|
||||||
|
|
||||||
#if MICROPY_PY_LWIP
|
#if MICROPY_PY_LWIP
|
||||||
systick_disable_dispatch(SYSTICK_DISPATCH_LWIP);
|
systick_disable_dispatch(SYSTICK_DISPATCH_LWIP);
|
||||||
#endif
|
#endif
|
||||||
@ -575,6 +544,9 @@ soft_reset_exit:
|
|||||||
#if MICROPY_PY_NETWORK
|
#if MICROPY_PY_NETWORK
|
||||||
mod_network_deinit();
|
mod_network_deinit();
|
||||||
#endif
|
#endif
|
||||||
|
#if MICROPY_PY_NETWORK_CYW43
|
||||||
|
cyw43_deinit(&cyw43_state);
|
||||||
|
#endif
|
||||||
timer_deinit();
|
timer_deinit();
|
||||||
i2c_deinit_all();
|
i2c_deinit_all();
|
||||||
spi_deinit_all();
|
spi_deinit_all();
|
||||||
@ -589,9 +561,8 @@ soft_reset_exit:
|
|||||||
py_audio_deinit();
|
py_audio_deinit();
|
||||||
#endif
|
#endif
|
||||||
imlib_deinit_all();
|
imlib_deinit_all();
|
||||||
|
gc_sweep_all();
|
||||||
mp_deinit();
|
mp_deinit();
|
||||||
|
|
||||||
first_soft_reset = false;
|
first_soft_reset = false;
|
||||||
goto soft_reset;
|
goto soft_reset;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user