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.
|
||||
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
|
||||
mp_init();
|
||||
|
||||
@ -321,9 +316,8 @@ soft_reset:
|
||||
#endif
|
||||
rtc_init_start(false);
|
||||
#if MICROPY_PY_LWIP
|
||||
// lwIP doesn't allow to reinitialise itself by subsequent calls to this function
|
||||
// because the system timeout list (next_timeout) is only ever reset by BSS clearing.
|
||||
// So for now we only init the lwIP stack once on power-up.
|
||||
// lwIP can only be initialized once, because the system timeout
|
||||
// list (next_timeout), is only ever reset by BSS clearing.
|
||||
if (first_soft_reset) {
|
||||
lwip_init();
|
||||
#if LWIP_MDNS_RESPONDER
|
||||
@ -332,20 +326,19 @@ soft_reset:
|
||||
}
|
||||
systick_enable_dispatch(SYSTICK_DISPATCH_LWIP, mod_network_lwip_poll_wrapper);
|
||||
#endif
|
||||
|
||||
#if MICROPY_PY_BLUETOOTH
|
||||
mp_bluetooth_hci_init();
|
||||
#endif
|
||||
|
||||
#if MICROPY_PY_NETWORK_CYW43
|
||||
if (first_soft_reset) {
|
||||
cyw43_init(&cyw43_state);
|
||||
uint8_t buf[8];
|
||||
memcpy(&buf[0], "PYBD", 4);
|
||||
mp_hal_get_mac_ascii(MP_HAL_MAC_WLAN0, 8, 4, (char *) &buf[4]);
|
||||
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_password(&cyw43_state, 8, (const uint8_t *) "pybd0123");
|
||||
}
|
||||
cyw43_init(&cyw43_state);
|
||||
uint8_t buf[8];
|
||||
memcpy(&buf[0], "PYBD", 4);
|
||||
mp_hal_get_mac_ascii(MP_HAL_MAC_WLAN0, 8, 4, (char *) &buf[4]);
|
||||
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_password(&cyw43_state, 8, (const uint8_t *) "pybd0123");
|
||||
#endif
|
||||
|
||||
pyb_usb_init0();
|
||||
@ -361,10 +354,9 @@ soft_reset:
|
||||
py_imu_init();
|
||||
#endif // MICROPY_PY_IMU
|
||||
|
||||
#if MICROPY_PY_NETWORK
|
||||
mod_network_init();
|
||||
|
||||
// Remove the BASEPRI masking (if any)
|
||||
irq_set_base_priority(0);
|
||||
#endif
|
||||
|
||||
#if MICROPY_HW_ENABLE_SDCARD
|
||||
// Initialize storage
|
||||
@ -462,9 +454,7 @@ else {
|
||||
// report if SDRAM failed
|
||||
#if MICROPY_HW_SDRAM_SIZE
|
||||
if (first_soft_reset && (!sdram_ok)) {
|
||||
char buf[512];
|
||||
snprintf(buf, sizeof(buf), "Failed to init sdram!");
|
||||
__fatal_error(buf);
|
||||
__fatal_error("Failed to init sdram!");
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -532,20 +522,7 @@ else {
|
||||
usbdbg_set_irq_enabled(false);
|
||||
nlr_pop();
|
||||
} else {
|
||||
mp_obj_print_exception(&mp_plat_print, (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();
|
||||
mp_obj_print_exception(MP_PYTHON_PRINTER, (mp_obj_t) nlr.ret_val);
|
||||
}
|
||||
}
|
||||
|
||||
@ -553,19 +530,11 @@ else {
|
||||
|
||||
soft_reset_exit:
|
||||
// soft reset
|
||||
mp_printf(&mp_plat_print, "MPY: soft reboot\n");
|
||||
mp_printf(MP_PYTHON_PRINTER, "MPY: soft reboot\n");
|
||||
|
||||
// Flush filesystem storage.
|
||||
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
|
||||
systick_disable_dispatch(SYSTICK_DISPATCH_LWIP);
|
||||
#endif
|
||||
@ -575,6 +544,9 @@ soft_reset_exit:
|
||||
#if MICROPY_PY_NETWORK
|
||||
mod_network_deinit();
|
||||
#endif
|
||||
#if MICROPY_PY_NETWORK_CYW43
|
||||
cyw43_deinit(&cyw43_state);
|
||||
#endif
|
||||
timer_deinit();
|
||||
i2c_deinit_all();
|
||||
spi_deinit_all();
|
||||
@ -589,9 +561,8 @@ soft_reset_exit:
|
||||
py_audio_deinit();
|
||||
#endif
|
||||
imlib_deinit_all();
|
||||
|
||||
gc_sweep_all();
|
||||
mp_deinit();
|
||||
|
||||
first_soft_reset = false;
|
||||
goto soft_reset;
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user