added reset flag for user application read/write

This commit is contained in:
Bogdan Pilyugin 2022-09-24 10:55:49 +02:00
parent c6d1c2dffe
commit c8d42a282b
2 changed files with 14 additions and 0 deletions

View File

@ -35,5 +35,7 @@
esp_err_t spi_device_polling_transmit_synchronized(spi_device_handle_t handle, spi_transaction_t *trans_desc); esp_err_t spi_device_polling_transmit_synchronized(spi_device_handle_t handle, spi_transaction_t *trans_desc);
bool GetUserAppNeedReset(void);
void SetUserAppNeedReset(bool res);
#endif /* COMPONENTS_WEBGUIAPPCOMPONENT_INCLUDE_WEBGUIAPP_H_ */ #endif /* COMPONENTS_WEBGUIAPPCOMPONENT_INCLUDE_WEBGUIAPP_H_ */

View File

@ -56,6 +56,7 @@ SemaphoreHandle_t xSemaphoreSPIHandle = NULL;
StaticSemaphore_t xSemaphoreSPIBuf; StaticSemaphore_t xSemaphoreSPIBuf;
static int NetworkStartTimeout = 0; static int NetworkStartTimeout = 0;
static bool isUserAppNeedReset = false;
static void InitSysIO(void); static void InitSysIO(void);
static void InitSysSPI(void); static void InitSysSPI(void);
@ -87,6 +88,7 @@ esp_err_t WebGuiAppInit(void)
// partition table. This size mismatch may cause NVS initialization to fail. // partition table. This size mismatch may cause NVS initialization to fail.
// 2.NVS partition contains data in new format and cannot be recognized by this version of code. // 2.NVS partition contains data in new format and cannot be recognized by this version of code.
// If this happens, we erase NVS partition and initialize NVS again. // If this happens, we erase NVS partition and initialize NVS again.
isUserAppNeedReset = true;
ESP_ERROR_CHECK(nvs_flash_erase()); ESP_ERROR_CHECK(nvs_flash_erase());
ESP_ERROR_CHECK(nvs_flash_init()); ESP_ERROR_CHECK(nvs_flash_init());
ESP_ERROR_CHECK(ResetInitSysConfig()); ESP_ERROR_CHECK(ResetInitSysConfig());
@ -399,3 +401,13 @@ void DelayedRestart(void)
{ {
xTaskCreate(DelayedRestartTask, "RestartTask", 1024 * 4, (void*) 0, 3, NULL); xTaskCreate(DelayedRestartTask, "RestartTask", 1024 * 4, (void*) 0, 3, NULL);
} }
bool GetUserAppNeedReset(void)
{
return isUserAppNeedReset;
}
void SetUserAppNeedReset(bool res)
{
isUserAppNeedReset = res;
}