xtensa/esp32: enables started flag if the wdt was turned on in bootloader
This commit is contained in:
parent
6339fcfdd3
commit
1acba417c4
@ -68,6 +68,8 @@ static void esp32_wtd_modifyreg32(FAR struct esp32_wtd_dev_s *dev,
|
||||
uint32_t offset,
|
||||
uint32_t clearbits,
|
||||
uint32_t setbits);
|
||||
static uint32_t esp32_wtd_getreg(FAR struct esp32_wtd_dev_s *dev,
|
||||
uint32_t offset);
|
||||
|
||||
/* WTD operations ***********************************************************/
|
||||
|
||||
@ -207,6 +209,22 @@ static void esp32_wtd_modifyreg32(FAR struct esp32_wtd_dev_s *dev,
|
||||
clearbits, setbits);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: esp32_wtd_getreg
|
||||
*
|
||||
* Description:
|
||||
* Get a 32-bit register value by offset
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static uint32_t esp32_wtd_getreg(FAR struct esp32_wtd_dev_s *dev,
|
||||
uint32_t offset)
|
||||
{
|
||||
DEBUGASSERT(dev);
|
||||
|
||||
return getreg32(((struct esp32_wtd_priv_s *)dev)->base + offset);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: esp32_wtd_start
|
||||
*
|
||||
@ -957,3 +975,43 @@ int esp32_wtd_deinit(FAR struct esp32_wtd_dev_s *dev)
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: esp32_wtd_is_running
|
||||
*
|
||||
* Description:
|
||||
* Checks if the wdt was already turned on. For example, RTC may has been
|
||||
* enabled in bootloader.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
bool esp32_wtd_is_running(FAR struct esp32_wtd_dev_s *dev)
|
||||
{
|
||||
uint32_t status = 0;
|
||||
DEBUGASSERT(dev);
|
||||
|
||||
/* If it is a RWDT */
|
||||
|
||||
if (((struct esp32_wtd_priv_s *)dev)->base ==
|
||||
RTC_CNTL_OPTIONS0_REG)
|
||||
{
|
||||
status = esp32_wtd_getreg(dev, RWDT_CONFIG0_OFFSET);
|
||||
if (status & RTC_CNTL_WDT_EN)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/* If it is a MWDT */
|
||||
|
||||
else
|
||||
{
|
||||
status = esp32_wtd_getreg(dev, MWDT_CONFIG0_OFFSET);
|
||||
if (status & TIMG_WDT_EN)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -100,5 +100,6 @@ struct esp32_wtd_ops_s
|
||||
|
||||
FAR struct esp32_wtd_dev_s *esp32_wtd_init(uint8_t wdt_id);
|
||||
int esp32_wtd_deinit(FAR struct esp32_wtd_dev_s *dev);
|
||||
bool esp32_wtd_is_running(FAR struct esp32_wtd_dev_s *dev);
|
||||
|
||||
#endif /* __ARCH_XTENSA_SRC_ESP32_ESP32_WTD_H */
|
||||
|
@ -666,7 +666,6 @@ int esp32_wtd_initialize(FAR const char *devpath, uint8_t wdt)
|
||||
|
||||
/* Initialize the elements of lower half state structure */
|
||||
|
||||
lower->started = false;
|
||||
lower->handler = NULL;
|
||||
lower->timeout = 0;
|
||||
lower->wtd = esp32_wtd_init(wdt);
|
||||
@ -677,6 +676,8 @@ int esp32_wtd_initialize(FAR const char *devpath, uint8_t wdt)
|
||||
goto errout;
|
||||
}
|
||||
|
||||
lower->started = esp32_wtd_is_running(lower->wtd);
|
||||
|
||||
ESP32_WTD_UNLOCK(lower->wtd);
|
||||
|
||||
/* If it is a Main System Watchdog Timer configure the Prescale to
|
||||
|
Loading…
Reference in New Issue
Block a user