refactor task wdt handling to platform layer
This commit is contained in:
parent
a63da92e82
commit
8d0a8a5763
|
@ -9,9 +9,10 @@
|
|||
#include <stdlib.h>
|
||||
#include "rom/spi_flash.h"
|
||||
|
||||
#include "platform_wdt.h"
|
||||
|
||||
#include "esp_image_format.h"
|
||||
#include "esp_flash_data_types.h"
|
||||
#include "esp_task_wdt.h"
|
||||
|
||||
#define FLASH_HDR_ADDR 0x1000
|
||||
|
||||
|
@ -175,14 +176,6 @@ uint32_t flash_rom_get_speed(void)
|
|||
|
||||
esp_err_t flash_erase(size_t sector)
|
||||
{
|
||||
#ifdef CONFIG_TASK_WDT
|
||||
// re-init the task WDT, simulates feeding for the IDLE task
|
||||
# ifdef CONFIG_TASK_WDT_PANIC
|
||||
esp_task_wdt_init(CONFIG_TASK_WDT_TIMEOUT_S, true);
|
||||
# else
|
||||
esp_task_wdt_init(CONFIG_TASK_WDT_TIMEOUT_S, false);
|
||||
# endif
|
||||
#endif
|
||||
|
||||
platform_wdt_feed();
|
||||
return spi_flash_erase_sector(sector);
|
||||
}
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
|
||||
#ifndef __PLATFORM_WDT_H__
|
||||
#define __PLATFORM_WDT_H__
|
||||
|
||||
int platform_wdt_feed( void );
|
||||
|
||||
#endif
|
|
@ -0,0 +1,30 @@
|
|||
/******************************************************************************
|
||||
* WDT api for NodeMCU
|
||||
* NodeMCU Team
|
||||
* 2018-04-04
|
||||
*******************************************************************************/
|
||||
|
||||
#include "platform.h"
|
||||
#include "esp_task_wdt.h"
|
||||
|
||||
#ifdef CONFIG_TASK_WDT
|
||||
static uint32_t task_wdt_timeout = CONFIG_TASK_WDT_TIMEOUT_S;
|
||||
|
||||
static bool task_wdt_panic =
|
||||
#ifdef CONFIG_TASK_WDT_PANIC
|
||||
true;
|
||||
#else
|
||||
false;
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
int platform_wdt_feed( void )
|
||||
{
|
||||
#ifdef CONFIG_TASK_WDT
|
||||
return esp_task_wdt_init(task_wdt_timeout, task_wdt_panic) == ESP_OK ? PLATFORM_OK : PLATFORM_ERR;
|
||||
#else
|
||||
return PLATFORM_OK;
|
||||
#endif
|
||||
}
|
Loading…
Reference in New Issue