xtensa/esp32: Fixed wdt typos

This commit is contained in:
Sara Souza 2020-12-22 10:50:54 -03:00 committed by Abdelatif Guettouche
parent 922cf0612b
commit 6a6121378c
9 changed files with 328 additions and 328 deletions

View File

@ -226,7 +226,7 @@ config ESP32_MWDT1
config ESP32_RWDT config ESP32_RWDT
bool "RTC Watchdog Timer" bool "RTC Watchdog Timer"
default n default n
select ESP32_WTD select ESP32_WDT
---help--- ---help---
Includes RWDT. This watchdog timer is from the RTC module. Includes RWDT. This watchdog timer is from the RTC module.
When it is selected, if the developer sets it to reset on expiration When it is selected, if the developer sets it to reset on expiration

View File

@ -163,9 +163,9 @@ CHIP_CSRCS += esp32_partition.c
endif endif
ifeq ($(CONFIG_ESP32_WDT),y) ifeq ($(CONFIG_ESP32_WDT),y)
CHIP_CSRCS += esp32_wtd.c CHIP_CSRCS += esp32_wdt.c
ifeq ($(CONFIG_WATCHDOG),y) ifeq ($(CONFIG_WATCHDOG),y)
CHIP_CSRCS += esp32_wtd_lowerhalf.c CHIP_CSRCS += esp32_wdt_lowerhalf.c
endif endif
endif endif

View File

@ -1,5 +1,5 @@
/**************************************************************************** /****************************************************************************
* arch/xtensa/src/esp32/esp32_wtd.h * arch/xtensa/src/esp32/esp32_wdt.h
* *
* Licensed to the Apache Software Foundation (ASF) under one or more * Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with * contributor license agreements. See the NOTICE file distributed with
@ -18,8 +18,8 @@
* *
****************************************************************************/ ****************************************************************************/
#ifndef __ARCH_XTENSA_SRC_ESP32_ESP32_WTD_H #ifndef __ARCH_XTENSA_SRC_ESP32_ESP32_WDT_H
#define __ARCH_XTENSA_SRC_ESP32_ESP32_WTD_H #define __ARCH_XTENSA_SRC_ESP32_ESP32_WDT_H
/**************************************************************************** /****************************************************************************
* Included Files * Included Files
@ -37,69 +37,69 @@
/* Helpers ******************************************************************/ /* Helpers ******************************************************************/
#define ESP32_WTD_START(d) ((d)->ops->start(d)) #define ESP32_WDT_START(d) ((d)->ops->start(d))
#define ESP32_WTD_STOP(d) ((d)->ops->stop(d)) #define ESP32_WDT_STOP(d) ((d)->ops->stop(d))
#define ESP32_WTD_LOCK(d) ((d)->ops->enablewp(d)) #define ESP32_WDT_LOCK(d) ((d)->ops->enablewp(d))
#define ESP32_WTD_UNLOCK(d) ((d)->ops->disablewp(d)) #define ESP32_WDT_UNLOCK(d) ((d)->ops->disablewp(d))
#define ESP32_WTD_PRE(d, v) ((d)->ops->pre(d, v)) #define ESP32_WDT_PRE(d, v) ((d)->ops->pre(d, v))
#define ESP32_WTD_STO(d, v, s) ((d)->ops->settimeout(d, v, s)) #define ESP32_WDT_STO(d, v, s) ((d)->ops->settimeout(d, v, s))
#define ESP32_WTD_FEED(d) ((d)->ops->feed(d)) #define ESP32_WDT_FEED(d) ((d)->ops->feed(d))
#define ESP32_WTD_STG_CONF(d, s, c) ((d)->ops->stg_conf(d, s, c)) #define ESP32_WDT_STG_CONF(d, s, c) ((d)->ops->stg_conf(d, s, c))
#define ESP32_RWDT_CLK(d) ((d)->ops->rtc_clk(d)) #define ESP32_RWDT_CLK(d) ((d)->ops->rtc_clk(d))
#define ESP32_WTD_SETISR(d, hnd, arg) ((d)->ops->setisr(d, hnd, arg)) #define ESP32_WDT_SETISR(d, hnd, arg) ((d)->ops->setisr(d, hnd, arg))
#define ESP32_WTD_ENABLEINT(d) ((d)->ops->enableint(d)) #define ESP32_WDT_ENABLEINT(d) ((d)->ops->enableint(d))
#define ESP32_WTD_DISABLEINT(d) ((d)->ops->disableint(d)) #define ESP32_WDT_DISABLEINT(d) ((d)->ops->disableint(d))
#define ESP32_WTD_ACKINT(d) ((d)->ops->ackint(d)) #define ESP32_WDT_ACKINT(d) ((d)->ops->ackint(d))
/**************************************************************************** /****************************************************************************
* Public Types * Public Types
****************************************************************************/ ****************************************************************************/
/* ESP32 WTD device */ /* ESP32 WDT device */
struct esp32_wtd_dev_s struct esp32_wdt_dev_s
{ {
struct esp32_wtd_ops_s *ops; struct esp32_wdt_ops_s *ops;
}; };
/* ESP32 WTD ops */ /* ESP32 WDT ops */
/* This is a struct containing the pointers to the wtd operations */ /* This is a struct containing the pointers to the wdt operations */
struct esp32_wtd_ops_s struct esp32_wdt_ops_s
{ {
/* WTD tasks */ /* WDT tasks */
CODE int (*start)(FAR struct esp32_wtd_dev_s *dev); CODE int (*start)(FAR struct esp32_wdt_dev_s *dev);
CODE int (*stop)(FAR struct esp32_wtd_dev_s *dev); CODE int (*stop)(FAR struct esp32_wdt_dev_s *dev);
/* WTD configuration */ /* WDT configuration */
CODE int (*enablewp)(FAR struct esp32_wtd_dev_s *dev); CODE int (*enablewp)(FAR struct esp32_wdt_dev_s *dev);
CODE int (*disablewp)(FAR struct esp32_wtd_dev_s *dev); CODE int (*disablewp)(FAR struct esp32_wdt_dev_s *dev);
CODE int (*pre)(FAR struct esp32_wtd_dev_s *dev, uint16_t value); CODE int (*pre)(FAR struct esp32_wdt_dev_s *dev, uint16_t value);
CODE int (*settimeout)(FAR struct esp32_wtd_dev_s *dev, CODE int (*settimeout)(FAR struct esp32_wdt_dev_s *dev,
uint32_t value, uint8_t stage); uint32_t value, uint8_t stage);
CODE int (*feed)(FAR struct esp32_wtd_dev_s *dev); CODE int (*feed)(FAR struct esp32_wdt_dev_s *dev);
CODE int (*stg_conf)(FAR struct esp32_wtd_dev_s *dev, CODE int (*stg_conf)(FAR struct esp32_wdt_dev_s *dev,
uint8_t stage, uint8_t conf); uint8_t stage, uint8_t conf);
CODE uint16_t (*rtc_clk)(FAR struct esp32_wtd_dev_s *dev); CODE uint16_t (*rtc_clk)(FAR struct esp32_wdt_dev_s *dev);
/* WTD interrupts */ /* WDT interrupts */
CODE int (*setisr)(FAR struct esp32_wtd_dev_s *dev, xcpt_t handler, CODE int (*setisr)(FAR struct esp32_wdt_dev_s *dev, xcpt_t handler,
FAR void * arg); FAR void * arg);
CODE int (*enableint)(FAR struct esp32_wtd_dev_s *dev); CODE int (*enableint)(FAR struct esp32_wdt_dev_s *dev);
CODE int (*disableint)(FAR struct esp32_wtd_dev_s *dev); CODE int (*disableint)(FAR struct esp32_wdt_dev_s *dev);
CODE int (*ackint)(FAR struct esp32_wtd_dev_s *dev); CODE int (*ackint)(FAR struct esp32_wdt_dev_s *dev);
}; };
/**************************************************************************** /****************************************************************************
* Public Function Prototypes * Public Function Prototypes
****************************************************************************/ ****************************************************************************/
FAR struct esp32_wtd_dev_s *esp32_wtd_init(uint8_t wdt_id); FAR struct esp32_wdt_dev_s *esp32_wdt_init(uint8_t wdt_id);
int esp32_wtd_deinit(FAR struct esp32_wtd_dev_s *dev); int esp32_wdt_deinit(FAR struct esp32_wdt_dev_s *dev);
bool esp32_wtd_is_running(FAR struct esp32_wtd_dev_s *dev); bool esp32_wdt_is_running(FAR struct esp32_wdt_dev_s *dev);
#endif /* __ARCH_XTENSA_SRC_ESP32_ESP32_WTD_H */ #endif /* __ARCH_XTENSA_SRC_ESP32_ESP32_WDT_H */

View File

@ -1,5 +1,5 @@
/**************************************************************************** /****************************************************************************
* arch/arm/src/esp32/esp32_wtd_lowerhalf.c * arch/arm/src/esp32/esp32_wdt_lowerhalf.c
* *
* Licensed to the Apache Software Foundation (ASF) under one or more * Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with * contributor license agreements. See the NOTICE file distributed with
@ -35,8 +35,8 @@
#include "xtensa.h" #include "xtensa.h"
#include "hardware/esp32_soc.h" #include "hardware/esp32_soc.h"
#include "esp32_wtd.h" #include "esp32_wdt.h"
#include "esp32_wtd_lowerhalf.h" #include "esp32_wdt_lowerhalf.h"
/**************************************************************************** /****************************************************************************
* Pre-processor Definitions * Pre-processor Definitions
@ -69,10 +69,10 @@
* well-known watchdog_lowerhalf_s structure. * well-known watchdog_lowerhalf_s structure.
*/ */
struct esp32_wtd_lowerhalf_s struct esp32_wdt_lowerhalf_s
{ {
FAR const struct watchdog_ops_s *ops; /* Lower half operations */ FAR const struct watchdog_ops_s *ops; /* Lower half operations */
FAR struct esp32_wtd_dev_s *wtd; /* esp32 watchdog driver */ FAR struct esp32_wdt_dev_s *wdt; /* esp32 watchdog driver */
uint32_t timeout; /* The current timeout */ uint32_t timeout; /* The current timeout */
enum wdt_peripherals peripheral; /* Indicates if it is from RTC or Timer Module */ enum wdt_peripherals peripheral; /* Indicates if it is from RTC or Timer Module */
uint32_t lastreset; /* The last reset time */ uint32_t lastreset; /* The last reset time */
@ -91,14 +91,14 @@ static int esp32_wdt_handler(int irq, FAR void *context, FAR void *arg);
/* "Lower half" driver methods **********************************************/ /* "Lower half" driver methods **********************************************/
static int esp32_wtd_start(FAR struct watchdog_lowerhalf_s *lower); static int esp32_wdt_start(FAR struct watchdog_lowerhalf_s *lower);
static int esp32_wtd_stop(FAR struct watchdog_lowerhalf_s *lower); static int esp32_wdt_stop(FAR struct watchdog_lowerhalf_s *lower);
static int esp32_wtd_keepalive(FAR struct watchdog_lowerhalf_s *lower); static int esp32_wdt_keepalive(FAR struct watchdog_lowerhalf_s *lower);
static int esp32_wtd_getstatus(FAR struct watchdog_lowerhalf_s *lower, static int esp32_wdt_getstatus(FAR struct watchdog_lowerhalf_s *lower,
FAR struct watchdog_status_s *status); FAR struct watchdog_status_s *status);
static int esp32_wtd_settimeout(FAR struct watchdog_lowerhalf_s *lower, static int esp32_wdt_settimeout(FAR struct watchdog_lowerhalf_s *lower,
uint32_t timeout); uint32_t timeout);
static xcpt_t esp32_wtd_capture(FAR struct watchdog_lowerhalf_s *lower, static xcpt_t esp32_wdt_capture(FAR struct watchdog_lowerhalf_s *lower,
xcpt_t handler); xcpt_t handler);
/**************************************************************************** /****************************************************************************
@ -109,19 +109,19 @@ static xcpt_t esp32_wtd_capture(FAR struct watchdog_lowerhalf_s *lower,
static const struct watchdog_ops_s g_esp32_wdg_ops = static const struct watchdog_ops_s g_esp32_wdg_ops =
{ {
.start = esp32_wtd_start, .start = esp32_wdt_start,
.stop = esp32_wtd_stop, .stop = esp32_wdt_stop,
.keepalive = esp32_wtd_keepalive, .keepalive = esp32_wdt_keepalive,
.getstatus = esp32_wtd_getstatus, .getstatus = esp32_wdt_getstatus,
.settimeout = esp32_wtd_settimeout, .settimeout = esp32_wdt_settimeout,
.capture = esp32_wtd_capture, .capture = esp32_wdt_capture,
.ioctl = NULL, .ioctl = NULL,
}; };
#ifdef CONFIG_ESP32_MWDT0 #ifdef CONFIG_ESP32_MWDT0
/* MWDT0 lower-half */ /* MWDT0 lower-half */
static struct esp32_wtd_lowerhalf_s g_esp32_mwdt0_lowerhalf = static struct esp32_wdt_lowerhalf_s g_esp32_mwdt0_lowerhalf =
{ {
.ops = &g_esp32_wdg_ops, .ops = &g_esp32_wdg_ops,
}; };
@ -130,7 +130,7 @@ static struct esp32_wtd_lowerhalf_s g_esp32_mwdt0_lowerhalf =
#ifdef CONFIG_ESP32_MWDT1 #ifdef CONFIG_ESP32_MWDT1
/* MWDT1 lower-half */ /* MWDT1 lower-half */
static struct esp32_wtd_lowerhalf_s g_esp32_mwdt1_lowerhalf = static struct esp32_wdt_lowerhalf_s g_esp32_mwdt1_lowerhalf =
{ {
.ops = &g_esp32_wdg_ops, .ops = &g_esp32_wdg_ops,
}; };
@ -139,14 +139,14 @@ static struct esp32_wtd_lowerhalf_s g_esp32_mwdt1_lowerhalf =
#ifdef CONFIG_ESP32_RWDT #ifdef CONFIG_ESP32_RWDT
/* RWDT lower-half */ /* RWDT lower-half */
static struct esp32_wtd_lowerhalf_s g_esp32_rwdt_lowerhalf = static struct esp32_wdt_lowerhalf_s g_esp32_rwdt_lowerhalf =
{ {
.ops = &g_esp32_wdg_ops, .ops = &g_esp32_wdg_ops,
}; };
#endif #endif
/**************************************************************************** /****************************************************************************
* Name: esp32_wtd_start * Name: esp32_wdt_start
* *
* Description: * Description:
* Start the watchdog timer, register a callback if there is one and * Start the watchdog timer, register a callback if there is one and
@ -162,10 +162,10 @@ static struct esp32_wtd_lowerhalf_s g_esp32_rwdt_lowerhalf =
* *
****************************************************************************/ ****************************************************************************/
static int esp32_wtd_start(FAR struct watchdog_lowerhalf_s *lower) static int esp32_wdt_start(FAR struct watchdog_lowerhalf_s *lower)
{ {
FAR struct esp32_wtd_lowerhalf_s *priv = FAR struct esp32_wdt_lowerhalf_s *priv =
(FAR struct esp32_wtd_lowerhalf_s *)lower; (FAR struct esp32_wdt_lowerhalf_s *)lower;
int ret = OK; int ret = OK;
irqstate_t flags; irqstate_t flags;
@ -188,7 +188,7 @@ static int esp32_wtd_start(FAR struct watchdog_lowerhalf_s *lower)
/* Unlock WDT */ /* Unlock WDT */
ESP32_WTD_UNLOCK(priv->wtd); ESP32_WDT_UNLOCK(priv->wdt);
/* No User Handler */ /* No User Handler */
@ -198,11 +198,11 @@ static int esp32_wtd_start(FAR struct watchdog_lowerhalf_s *lower)
if (priv->peripheral == TIMER) if (priv->peripheral == TIMER)
{ {
ESP32_WTD_STG_CONF(priv->wtd, STAGE_0, RESET_SYSTEM_TIMER); ESP32_WDT_STG_CONF(priv->wdt, STAGE_0, RESET_SYSTEM_TIMER);
} }
else else
{ {
ESP32_WTD_STG_CONF(priv->wtd, STAGE_0, RESET_SYSTEM_RTC); ESP32_WDT_STG_CONF(priv->wdt, STAGE_0, RESET_SYSTEM_RTC);
} }
} }
@ -212,30 +212,30 @@ static int esp32_wtd_start(FAR struct watchdog_lowerhalf_s *lower)
{ {
/* Then configure it to call the user handler on wdt expiration */ /* Then configure it to call the user handler on wdt expiration */
ESP32_WTD_STG_CONF(priv->wtd, STAGE_0, INTERRUPT_ON_TIMEOUT); ESP32_WDT_STG_CONF(priv->wdt, STAGE_0, INTERRUPT_ON_TIMEOUT);
/* Set the lower half handler and enable interrupt */ /* Set the lower half handler and enable interrupt */
flags = enter_critical_section(); flags = enter_critical_section();
ESP32_WTD_SETISR(priv->wtd, esp32_wdt_handler, priv); ESP32_WDT_SETISR(priv->wdt, esp32_wdt_handler, priv);
leave_critical_section(flags); leave_critical_section(flags);
ESP32_WTD_ENABLEINT(priv->wtd); ESP32_WDT_ENABLEINT(priv->wdt);
} }
flags = enter_critical_section(); flags = enter_critical_section();
priv->lastreset = clock_systime_ticks(); priv->lastreset = clock_systime_ticks();
ESP32_WTD_START(priv->wtd); ESP32_WDT_START(priv->wdt);
leave_critical_section(flags); leave_critical_section(flags);
/* Lock it again */ /* Lock it again */
ESP32_WTD_LOCK(priv->wtd); ESP32_WDT_LOCK(priv->wdt);
} }
errout: errout:
return ret; return ret;
} }
/**************************************************************************** /****************************************************************************
* Name: esp32_wtd_stop * Name: esp32_wdt_stop
* *
* Description: * Description:
* Stop the watchdog timer. In case a callback was previously configured, * Stop the watchdog timer. In case a callback was previously configured,
@ -247,33 +247,33 @@ static int esp32_wtd_start(FAR struct watchdog_lowerhalf_s *lower)
* *
****************************************************************************/ ****************************************************************************/
static int esp32_wtd_stop(FAR struct watchdog_lowerhalf_s *lower) static int esp32_wdt_stop(FAR struct watchdog_lowerhalf_s *lower)
{ {
FAR struct esp32_wtd_lowerhalf_s *priv = FAR struct esp32_wdt_lowerhalf_s *priv =
(FAR struct esp32_wtd_lowerhalf_s *)lower; (FAR struct esp32_wdt_lowerhalf_s *)lower;
irqstate_t flags; irqstate_t flags;
/* Unlock WDT */ /* Unlock WDT */
ESP32_WTD_UNLOCK(priv->wtd); ESP32_WDT_UNLOCK(priv->wdt);
/* Disable the WDT */ /* Disable the WDT */
ESP32_WTD_STOP(priv->wtd); ESP32_WDT_STOP(priv->wdt);
/* In case there is some callback registered, disable and deallocate */ /* In case there is some callback registered, disable and deallocate */
if (priv->handler != NULL) if (priv->handler != NULL)
{ {
ESP32_WTD_DISABLEINT(priv->wtd); ESP32_WDT_DISABLEINT(priv->wdt);
flags = enter_critical_section(); flags = enter_critical_section();
ESP32_WTD_SETISR(priv->wtd, NULL, NULL); ESP32_WDT_SETISR(priv->wdt, NULL, NULL);
leave_critical_section(flags); leave_critical_section(flags);
} }
/* Lock it again */ /* Lock it again */
ESP32_WTD_LOCK(priv->wtd); ESP32_WDT_LOCK(priv->wdt);
priv->started = false; priv->started = false;
@ -281,7 +281,7 @@ static int esp32_wtd_stop(FAR struct watchdog_lowerhalf_s *lower)
} }
/**************************************************************************** /****************************************************************************
* Name: esp32_wtd_keepalive * Name: esp32_wdt_keepalive
* *
* Description: * Description:
* Reset the watchdog timer, prevent any * Reset the watchdog timer, prevent any
@ -295,34 +295,34 @@ static int esp32_wtd_stop(FAR struct watchdog_lowerhalf_s *lower)
* *
****************************************************************************/ ****************************************************************************/
static int esp32_wtd_keepalive(FAR struct watchdog_lowerhalf_s *lower) static int esp32_wdt_keepalive(FAR struct watchdog_lowerhalf_s *lower)
{ {
FAR struct esp32_wtd_lowerhalf_s *priv = FAR struct esp32_wdt_lowerhalf_s *priv =
(FAR struct esp32_wtd_lowerhalf_s *)lower; (FAR struct esp32_wdt_lowerhalf_s *)lower;
irqstate_t flags; irqstate_t flags;
wdinfo("Entry\n"); wdinfo("Entry\n");
/* Unlock */ /* Unlock */
ESP32_WTD_UNLOCK(priv->wtd); ESP32_WDT_UNLOCK(priv->wdt);
/* Feed the dog and updates the lastreset variable */ /* Feed the dog and updates the lastreset variable */
flags = enter_critical_section(); flags = enter_critical_section();
priv->lastreset = clock_systime_ticks(); priv->lastreset = clock_systime_ticks();
ESP32_WTD_FEED(priv->wtd); ESP32_WDT_FEED(priv->wdt);
leave_critical_section(flags); leave_critical_section(flags);
/* Lock */ /* Lock */
ESP32_WTD_LOCK(priv->wtd); ESP32_WDT_LOCK(priv->wdt);
return OK; return OK;
} }
/**************************************************************************** /****************************************************************************
* Name: esp32_wtd_getstatus * Name: esp32_wdt_getstatus
* *
* Description: * Description:
* Get the current watchdog timer status * Get the current watchdog timer status
@ -334,11 +334,11 @@ static int esp32_wtd_keepalive(FAR struct watchdog_lowerhalf_s *lower)
* *
****************************************************************************/ ****************************************************************************/
static int esp32_wtd_getstatus(FAR struct watchdog_lowerhalf_s *lower, static int esp32_wdt_getstatus(FAR struct watchdog_lowerhalf_s *lower,
FAR struct watchdog_status_s *status) FAR struct watchdog_status_s *status)
{ {
FAR struct esp32_wtd_lowerhalf_s *priv = FAR struct esp32_wdt_lowerhalf_s *priv =
(FAR struct esp32_wtd_lowerhalf_s *)lower; (FAR struct esp32_wdt_lowerhalf_s *)lower;
uint32_t ticks; uint32_t ticks;
uint32_t elapsed; uint32_t elapsed;
@ -388,7 +388,7 @@ static int esp32_wtd_getstatus(FAR struct watchdog_lowerhalf_s *lower,
} }
/**************************************************************************** /****************************************************************************
* Name: esp32_wtd_settimeout * Name: esp32_wdt_settimeout
* *
* Description: * Description:
* Set a new timeout value (and reset the watchdog timer) * Set a new timeout value (and reset the watchdog timer)
@ -403,11 +403,11 @@ static int esp32_wtd_getstatus(FAR struct watchdog_lowerhalf_s *lower,
* *
****************************************************************************/ ****************************************************************************/
static int esp32_wtd_settimeout(FAR struct watchdog_lowerhalf_s *lower, static int esp32_wdt_settimeout(FAR struct watchdog_lowerhalf_s *lower,
uint32_t timeout) uint32_t timeout)
{ {
FAR struct esp32_wtd_lowerhalf_s *priv = FAR struct esp32_wdt_lowerhalf_s *priv =
(FAR struct esp32_wtd_lowerhalf_s *)lower; (FAR struct esp32_wdt_lowerhalf_s *)lower;
uint16_t rtc_cycles = 0; uint16_t rtc_cycles = 0;
uint32_t rtc_ms_max = 0; uint32_t rtc_ms_max = 0;
@ -416,7 +416,7 @@ static int esp32_wtd_settimeout(FAR struct watchdog_lowerhalf_s *lower,
/* Unlock WDT */ /* Unlock WDT */
ESP32_WTD_UNLOCK(priv->wtd); ESP32_WDT_UNLOCK(priv->wdt);
/* Write the timeout value */ /* Write the timeout value */
@ -437,7 +437,7 @@ static int esp32_wtd_settimeout(FAR struct watchdog_lowerhalf_s *lower,
else else
{ {
timeout = timeout*MS_CYCLES_TIMER; timeout = timeout*MS_CYCLES_TIMER;
ESP32_WTD_STO(priv->wtd, timeout, STAGE_0); ESP32_WDT_STO(priv->wdt, timeout, STAGE_0);
} }
} }
@ -445,7 +445,7 @@ static int esp32_wtd_settimeout(FAR struct watchdog_lowerhalf_s *lower,
else else
{ {
rtc_cycles = ESP32_RWDT_CLK(priv->wtd); rtc_cycles = ESP32_RWDT_CLK(priv->wdt);
rtc_ms_max = (uint32_t)(FULL_STAGE / rtc_cycles); rtc_ms_max = (uint32_t)(FULL_STAGE / rtc_cycles);
/* Is this timeout a valid value for RTC WDT? */ /* Is this timeout a valid value for RTC WDT? */
@ -459,23 +459,23 @@ static int esp32_wtd_settimeout(FAR struct watchdog_lowerhalf_s *lower,
else else
{ {
timeout = timeout*rtc_cycles; timeout = timeout*rtc_cycles;
ESP32_WTD_STO(priv->wtd, timeout, STAGE_0); ESP32_WDT_STO(priv->wdt, timeout, STAGE_0);
} }
} }
/* Reset the wdt */ /* Reset the wdt */
ESP32_WTD_FEED(priv->wtd); ESP32_WDT_FEED(priv->wdt);
/* Lock it again */ /* Lock it again */
ESP32_WTD_LOCK(priv->wtd); ESP32_WDT_LOCK(priv->wdt);
return OK; return OK;
} }
/**************************************************************************** /****************************************************************************
* Name: esp32_wtd_capture * Name: esp32_wdt_capture
* *
* Description: * Description:
* Don't reset on watchdog timer timeout; instead, call this user provider * Don't reset on watchdog timer timeout; instead, call this user provider
@ -496,11 +496,11 @@ static int esp32_wtd_settimeout(FAR struct watchdog_lowerhalf_s *lower,
* *
****************************************************************************/ ****************************************************************************/
static xcpt_t esp32_wtd_capture(FAR struct watchdog_lowerhalf_s *lower, static xcpt_t esp32_wdt_capture(FAR struct watchdog_lowerhalf_s *lower,
xcpt_t handler) xcpt_t handler)
{ {
FAR struct esp32_wtd_lowerhalf_s *priv = FAR struct esp32_wdt_lowerhalf_s *priv =
(FAR struct esp32_wtd_lowerhalf_s *)lower; (FAR struct esp32_wdt_lowerhalf_s *)lower;
irqstate_t flags; irqstate_t flags;
xcpt_t oldhandler; xcpt_t oldhandler;
@ -511,7 +511,7 @@ static xcpt_t esp32_wtd_capture(FAR struct watchdog_lowerhalf_s *lower,
oldhandler = priv->handler; oldhandler = priv->handler;
ESP32_WTD_UNLOCK(priv->wtd); ESP32_WDT_UNLOCK(priv->wdt);
flags = enter_critical_section(); flags = enter_critical_section();
@ -532,7 +532,7 @@ static xcpt_t esp32_wtd_capture(FAR struct watchdog_lowerhalf_s *lower,
if (oldhandler != NULL) if (oldhandler != NULL)
{ {
ESP32_WTD_SETISR(priv->wtd, NULL, NULL); ESP32_WDT_SETISR(priv->wdt, NULL, NULL);
} }
else else
{ {
@ -540,36 +540,36 @@ static xcpt_t esp32_wtd_capture(FAR struct watchdog_lowerhalf_s *lower,
* then change to interrupt. * then change to interrupt.
*/ */
ESP32_WTD_STG_CONF(priv->wtd, STAGE_0, INTERRUPT_ON_TIMEOUT); ESP32_WDT_STG_CONF(priv->wdt, STAGE_0, INTERRUPT_ON_TIMEOUT);
} }
/* Set the lower half handler and enable interrupt */ /* Set the lower half handler and enable interrupt */
ESP32_WTD_SETISR(priv->wtd, esp32_wdt_handler, priv); ESP32_WDT_SETISR(priv->wdt, esp32_wdt_handler, priv);
ESP32_WTD_ENABLEINT(priv->wtd); ESP32_WDT_ENABLEINT(priv->wdt);
} }
/* In case the user wants to disable the callback */ /* In case the user wants to disable the callback */
else else
{ {
ESP32_WTD_DISABLEINT(priv->wtd); ESP32_WDT_DISABLEINT(priv->wdt);
ESP32_WTD_SETISR(priv->wtd, NULL, NULL); ESP32_WDT_SETISR(priv->wdt, NULL, NULL);
/* Then configure it to reset on wdt expiration */ /* Then configure it to reset on wdt expiration */
if (priv->peripheral == TIMER) if (priv->peripheral == TIMER)
{ {
ESP32_WTD_STG_CONF(priv->wtd, STAGE_0, RESET_SYSTEM_TIMER); ESP32_WDT_STG_CONF(priv->wdt, STAGE_0, RESET_SYSTEM_TIMER);
} }
else else
{ {
ESP32_WTD_STG_CONF(priv->wtd, STAGE_0, RESET_SYSTEM_RTC); ESP32_WDT_STG_CONF(priv->wdt, STAGE_0, RESET_SYSTEM_RTC);
} }
} }
leave_critical_section(flags); leave_critical_section(flags);
ESP32_WTD_LOCK(priv->wtd); ESP32_WDT_LOCK(priv->wdt);
return oldhandler; return oldhandler;
} }
@ -577,9 +577,9 @@ static xcpt_t esp32_wtd_capture(FAR struct watchdog_lowerhalf_s *lower,
static int esp32_wdt_handler(int irq, FAR void *context, FAR void *arg) static int esp32_wdt_handler(int irq, FAR void *context, FAR void *arg)
{ {
FAR struct esp32_wtd_lowerhalf_s *priv = arg; FAR struct esp32_wdt_lowerhalf_s *priv = arg;
ESP32_WTD_UNLOCK(priv->wtd); ESP32_WDT_UNLOCK(priv->wdt);
/* Updates last reset var and feed the dog to reload the counter and /* Updates last reset var and feed the dog to reload the counter and
* to allow the application to continue executing. * to allow the application to continue executing.
@ -587,14 +587,14 @@ static int esp32_wdt_handler(int irq, FAR void *context, FAR void *arg)
#ifdef CONFIG_DEBUG_WATCHDOG #ifdef CONFIG_DEBUG_WATCHDOG
priv->lastreset = clock_systime_ticks(); priv->lastreset = clock_systime_ticks();
#endif #endif
ESP32_WTD_FEED(priv->wtd); ESP32_WDT_FEED(priv->wdt);
/* Run the user callback */ /* Run the user callback */
priv->handler(irq, context, priv->upper); priv->handler(irq, context, priv->upper);
ESP32_WTD_ACKINT(priv->wtd); /* Clear the Interrupt */ ESP32_WDT_ACKINT(priv->wdt); /* Clear the Interrupt */
ESP32_WTD_LOCK(priv->wtd); ESP32_WDT_LOCK(priv->wdt);
return OK; return OK;
} }
@ -604,7 +604,7 @@ static int esp32_wdt_handler(int irq, FAR void *context, FAR void *arg)
****************************************************************************/ ****************************************************************************/
/**************************************************************************** /****************************************************************************
* Name: esp32_wtd_initialize * Name: esp32_wdt_initialize
* *
* Description: * Description:
* Initialize the WDT watchdog timer. The watchdog timer is initialized * Initialize the WDT watchdog timer. The watchdog timer is initialized
@ -621,9 +621,9 @@ static int esp32_wdt_handler(int irq, FAR void *context, FAR void *arg)
* *
****************************************************************************/ ****************************************************************************/
int esp32_wtd_initialize(FAR const char *devpath, uint8_t wdt) int esp32_wdt_initialize(FAR const char *devpath, uint8_t wdt)
{ {
struct esp32_wtd_lowerhalf_s *lower = NULL; struct esp32_wdt_lowerhalf_s *lower = NULL;
int ret = OK; int ret = OK;
DEBUGASSERT(devpath); DEBUGASSERT(devpath);
@ -668,17 +668,17 @@ int esp32_wtd_initialize(FAR const char *devpath, uint8_t wdt)
lower->handler = NULL; lower->handler = NULL;
lower->timeout = 0; lower->timeout = 0;
lower->wtd = esp32_wtd_init(wdt); lower->wdt = esp32_wdt_init(wdt);
if (lower->wtd == NULL) if (lower->wdt == NULL)
{ {
ret = -EINVAL; ret = -EINVAL;
goto errout; goto errout;
} }
lower->started = esp32_wtd_is_running(lower->wtd); lower->started = esp32_wdt_is_running(lower->wdt);
ESP32_WTD_UNLOCK(lower->wtd); ESP32_WDT_UNLOCK(lower->wdt);
/* If it is a Main System Watchdog Timer configure the Prescale to /* If it is a Main System Watchdog Timer configure the Prescale to
* have a 500us period. * have a 500us period.
@ -686,10 +686,10 @@ int esp32_wtd_initialize(FAR const char *devpath, uint8_t wdt)
if (lower->peripheral == TIMER) if (lower->peripheral == TIMER)
{ {
ESP32_WTD_PRE(lower->wtd, PRE_VALUE); ESP32_WDT_PRE(lower->wdt, PRE_VALUE);
} }
ESP32_WTD_LOCK(lower->wtd); ESP32_WDT_LOCK(lower->wdt);
/* Register the watchdog driver as /dev/watchdogX. If the registration goes /* Register the watchdog driver as /dev/watchdogX. If the registration goes
* right the returned value from watchdog_register is a pointer to * right the returned value from watchdog_register is a pointer to

View File

@ -1,5 +1,5 @@
/**************************************************************************** /****************************************************************************
* arch/xtensa/src/esp32/esp32_wtd_lowerhalf.h * arch/xtensa/src/esp32/esp32_wdt_lowerhalf.h
* *
* Licensed to the Apache Software Foundation (ASF) under one or more * Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with * contributor license agreements. See the NOTICE file distributed with
@ -18,8 +18,8 @@
* *
****************************************************************************/ ****************************************************************************/
#ifndef __ARCH_XTENSA_SRC_ESP32_ESP32_WTD_LOWERHALF_H #ifndef __ARCH_XTENSA_SRC_ESP32_ESP32_WDT_LOWERHALF_H
#define __ARCH_XTENSA_SRC_ESP32_ESP32_WTD_LOWERHALF_H #define __ARCH_XTENSA_SRC_ESP32_ESP32_WDT_LOWERHALF_H
/**************************************************************************** /****************************************************************************
* Included Files * Included Files
@ -47,6 +47,6 @@ enum wdt_peripherals
* Name: esp32_timer_initialize * Name: esp32_timer_initialize
****************************************************************************/ ****************************************************************************/
int esp32_wtd_initialize(FAR const char *devpath, uint8_t timer); int esp32_wdt_initialize(FAR const char *devpath, uint8_t timer);
#endif /* __ARCH_XTENSA_SRC_ESP32_ESP32_WTD_LOWERHALF_H */ #endif /* __ARCH_XTENSA_SRC_ESP32_ESP32_WDT_LOWERHALF_H */

View File

@ -37,7 +37,7 @@
* Pre-processor Definitions * Pre-processor Definitions
****************************************************************************/ ****************************************************************************/
/* WTD defines */ /* WDT defines */
/* Offset relative to each wathdog timer instance memory base */ /* Offset relative to each wathdog timer instance memory base */

View File

@ -48,7 +48,7 @@
#define TIM1_INT_ENA_OFFSET 0x0074 #define TIM1_INT_ENA_OFFSET 0x0074
#define LOW_32_MASK 0xffffffff #define LOW_32_MASK 0xffffffff
/* WTD defines */ /* WDT defines */
#define WRITE_PROTECTION_KEY 0x050d83aa1 #define WRITE_PROTECTION_KEY 0x050d83aa1

View File

@ -27,7 +27,7 @@
#include <sys/types.h> #include <sys/types.h>
#include <debug.h> #include <debug.h>
#include "esp32_wtd_lowerhalf.h" #include "esp32_wdt_lowerhalf.h"
#include "esp32_board_wdt.h" #include "esp32_board_wdt.h"
/**************************************************************************** /****************************************************************************
@ -67,7 +67,7 @@ int board_wdt_init(void)
int ret = OK; int ret = OK;
#ifdef CONFIG_ESP32_MWDT0 #ifdef CONFIG_ESP32_MWDT0
ret = esp32_wtd_initialize("/dev/watchdog0", ESP32_MWDT0); ret = esp32_wdt_initialize("/dev/watchdog0", ESP32_MWDT0);
if (ret < 0) if (ret < 0)
{ {
syslog(LOG_ERR, syslog(LOG_ERR,
@ -78,7 +78,7 @@ int board_wdt_init(void)
#endif #endif
#ifdef CONFIG_ESP32_MWDT1 #ifdef CONFIG_ESP32_MWDT1
ret = esp32_wtd_initialize("/dev/watchdog1", ESP32_MWDT1); ret = esp32_wdt_initialize("/dev/watchdog1", ESP32_MWDT1);
if (ret < 0) if (ret < 0)
{ {
syslog(LOG_ERR, syslog(LOG_ERR,
@ -89,7 +89,7 @@ int board_wdt_init(void)
#endif #endif
#ifdef CONFIG_ESP32_RWDT #ifdef CONFIG_ESP32_RWDT
ret = esp32_wtd_initialize("/dev/watchdog2", ESP32_RWDT); ret = esp32_wdt_initialize("/dev/watchdog2", ESP32_RWDT);
if (ret < 0) if (ret < 0)
{ {
syslog(LOG_ERR, syslog(LOG_ERR,