diff --git a/arch/risc-v/src/esp32c3/esp32c3_systemreset.c b/arch/risc-v/src/esp32c3/esp32c3_systemreset.c index 6214f52dec..88b0d74d99 100644 --- a/arch/risc-v/src/esp32c3/esp32c3_systemreset.c +++ b/arch/risc-v/src/esp32c3/esp32c3_systemreset.c @@ -113,6 +113,25 @@ int esp32c3_unregister_shutdown_handler(shutdown_handler_t handler) return -EINVAL; } +/**************************************************************************** + * Name: up_shutdown_handler + * + * Description: + * Process all registered shutdown callback functions. + * + ****************************************************************************/ + +void up_shutdown_handler(void) +{ + for (int i = SHUTDOWN_HANDLERS_NO - 1; i >= 0; i--) + { + if (shutdown_handlers[i]) + { + shutdown_handlers[i](); + } + } +} + /**************************************************************************** * Name: up_systemreset * @@ -123,14 +142,6 @@ int esp32c3_unregister_shutdown_handler(shutdown_handler_t handler) void up_systemreset(void) { - for (int i = SHUTDOWN_HANDLERS_NO - 1; i >= 0; i--) - { - if (shutdown_handlers[i]) - { - shutdown_handlers[i](); - } - } - putreg32(RTC_CNTL_SW_SYS_RST, RTC_CNTL_OPTIONS0_REG); /* Wait for the reset */ diff --git a/arch/risc-v/src/esp32c3/esp32c3_systemreset.h b/arch/risc-v/src/esp32c3/esp32c3_systemreset.h index c47d3d1984..184b506244 100644 --- a/arch/risc-v/src/esp32c3/esp32c3_systemreset.h +++ b/arch/risc-v/src/esp32c3/esp32c3_systemreset.h @@ -86,6 +86,16 @@ int esp32c3_register_shutdown_handler(shutdown_handler_t handler); int esp32c3_unregister_shutdown_handler(shutdown_handler_t handler); +/**************************************************************************** + * Name: up_shutdown_handler + * + * Description: + * Process all registered shutdown callback functions. + * + ****************************************************************************/ + +void up_shutdown_handler(void); + #ifdef __cplusplus } #endif diff --git a/arch/risc-v/src/esp32c3/esp32c3_wifi_adapter.c b/arch/risc-v/src/esp32c3/esp32c3_wifi_adapter.c index 9518bce306..5a456d0bab 100644 --- a/arch/risc-v/src/esp32c3/esp32c3_wifi_adapter.c +++ b/arch/risc-v/src/esp32c3/esp32c3_wifi_adapter.c @@ -7192,6 +7192,8 @@ int esp32c3_wifi_bt_coexist_init(void) void esp_wifi_stop_callback(void) { + wlinfo("Trying to stop Wi-Fi..."); + int ret = esp_wifi_stop(); if (ret) { diff --git a/boards/risc-v/esp32c3/esp32c3-devkit/src/esp32c3_reset.c b/boards/risc-v/esp32c3/esp32c3-devkit/src/esp32c3_reset.c index 5eb0045138..5434b8acbb 100644 --- a/boards/risc-v/esp32c3/esp32c3-devkit/src/esp32c3_reset.c +++ b/boards/risc-v/esp32c3/esp32c3-devkit/src/esp32c3_reset.c @@ -24,6 +24,9 @@ #include +#include +#include +#include #include #include @@ -55,6 +58,23 @@ int board_reset(int status) { +#ifdef CONFIG_BOARD_ASSERT_RESET_VALUE + syslog(LOG_INFO, "reboot status=%d\n", status); + + switch (status) + { + case EXIT_SUCCESS: + up_shutdown_handler(); + break; + case CONFIG_BOARD_ASSERT_RESET_VALUE: + break; + default: + break; + } +#else + up_shutdown_handler(); +#endif + up_systemreset(); return 0;