You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by ac...@apache.org on 2020/12/16 19:36:08 UTC
[incubator-nuttx] branch master updated: xtensa/esp32: enables
started flag if the wdt was turned on in bootloader
This is an automated email from the ASF dual-hosted git repository.
acassis pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git
The following commit(s) were added to refs/heads/master by this push:
new 1acba41 xtensa/esp32: enables started flag if the wdt was turned on in bootloader
1acba41 is described below
commit 1acba417c42c3f66369a5c0d8f89043641201af1
Author: Sara Souza <sa...@espressif.com>
AuthorDate: Fri Dec 11 14:38:14 2020 -0300
xtensa/esp32: enables started flag if the wdt was turned on in bootloader
---
arch/xtensa/src/esp32/esp32_wtd.c | 58 +++++++++++++++++++++++++++++
arch/xtensa/src/esp32/esp32_wtd.h | 1 +
arch/xtensa/src/esp32/esp32_wtd_lowerhalf.c | 3 +-
3 files changed, 61 insertions(+), 1 deletion(-)
diff --git a/arch/xtensa/src/esp32/esp32_wtd.c b/arch/xtensa/src/esp32/esp32_wtd.c
index 624fb9a..0a38cc4 100644
--- a/arch/xtensa/src/esp32/esp32_wtd.c
+++ b/arch/xtensa/src/esp32/esp32_wtd.c
@@ -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 ***********************************************************/
@@ -208,6 +210,22 @@ static void esp32_wtd_modifyreg32(FAR struct esp32_wtd_dev_s *dev,
}
/****************************************************************************
+ * 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
*
* Description:
@@ -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;
+}
diff --git a/arch/xtensa/src/esp32/esp32_wtd.h b/arch/xtensa/src/esp32/esp32_wtd.h
index 282d768..01b08c1 100644
--- a/arch/xtensa/src/esp32/esp32_wtd.h
+++ b/arch/xtensa/src/esp32/esp32_wtd.h
@@ -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 */
diff --git a/arch/xtensa/src/esp32/esp32_wtd_lowerhalf.c b/arch/xtensa/src/esp32/esp32_wtd_lowerhalf.c
index 0555252..4da217e 100644
--- a/arch/xtensa/src/esp32/esp32_wtd_lowerhalf.c
+++ b/arch/xtensa/src/esp32/esp32_wtd_lowerhalf.c
@@ -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