mirror of
https://github.com/apache/nuttx.git
synced 2025-01-12 22:08:35 +08:00
Compare commits
3 commits
1fc0b87f1d
...
22c8c72491
Author | SHA1 | Date | |
---|---|---|---|
|
22c8c72491 | ||
|
43797ea6cc | ||
|
0945bc0fb8 |
5 changed files with 158 additions and 0 deletions
|
@ -39,6 +39,7 @@
|
|||
|
||||
#include "soc/periph_defs.h"
|
||||
#include "esp_private/periph_ctrl.h"
|
||||
#include "hardware/esp32s3_system.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Private Types
|
||||
|
@ -937,6 +938,8 @@ struct esp32s3_tim_dev_s *esp32s3_tim_init(int timer)
|
|||
case ESP32S3_TIMER0:
|
||||
{
|
||||
tim = &g_esp32s3_tim0_priv;
|
||||
modifyreg32(SYSTEM_PERIP_CLK_EN0_REG, 0, SYSTEM_TIMERGROUP_CLK_EN);
|
||||
modifyreg32(SYSTEM_PERIP_RST_EN0_REG, SYSTEM_TIMERGROUP_RST_M, 0);
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
|
@ -945,6 +948,9 @@ struct esp32s3_tim_dev_s *esp32s3_tim_init(int timer)
|
|||
case ESP32S3_TIMER1:
|
||||
{
|
||||
tim = &g_esp32s3_tim1_priv;
|
||||
modifyreg32(SYSTEM_PERIP_CLK_EN0_REG, 0,
|
||||
SYSTEM_TIMERGROUP1_CLK_EN);
|
||||
modifyreg32(SYSTEM_PERIP_RST_EN0_REG, SYSTEM_TIMERGROUP1_RST_M, 0);
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -33,6 +33,7 @@
|
|||
#include "hardware/esp32s3_rtccntl.h"
|
||||
#include "hardware/esp32s3_tim.h"
|
||||
#include "hardware/esp32s3_efuse.h"
|
||||
#include "hardware/esp32s3_system.h"
|
||||
|
||||
#include "esp32s3_irq.h"
|
||||
#include "esp32s3_rtc_gpio.h"
|
||||
|
@ -991,6 +992,8 @@ struct esp32s3_wdt_dev_s *esp32s3_wdt_init(enum esp32s3_wdt_inst_e wdt_id)
|
|||
case ESP32S3_WDT_MWDT0:
|
||||
{
|
||||
wdt = &g_esp32s3_mwdt0_priv;
|
||||
modifyreg32(SYSTEM_PERIP_CLK_EN0_REG, 0, SYSTEM_TIMERGROUP_CLK_EN);
|
||||
modifyreg32(SYSTEM_PERIP_RST_EN0_REG, SYSTEM_TIMERGROUP_RST_M, 0);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -1000,6 +1003,9 @@ struct esp32s3_wdt_dev_s *esp32s3_wdt_init(enum esp32s3_wdt_inst_e wdt_id)
|
|||
case ESP32S3_WDT_MWDT1:
|
||||
{
|
||||
wdt = &g_esp32s3_mwdt1_priv;
|
||||
modifyreg32(SYSTEM_PERIP_CLK_EN0_REG, 0,
|
||||
SYSTEM_TIMERGROUP1_CLK_EN);
|
||||
modifyreg32(SYSTEM_PERIP_RST_EN0_REG, SYSTEM_TIMERGROUP1_RST_M, 0);
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -439,6 +439,14 @@ menuconfig WATCHDOG_AUTOMONITOR
|
|||
|
||||
if WATCHDOG_AUTOMONITOR
|
||||
|
||||
config WATCHDOG_TIMEOUT_NOTIFIER
|
||||
bool "Enable watchdog timeout notifier"
|
||||
default n
|
||||
---help---
|
||||
The watchdog timeout notifier chain mechanism supports users registering
|
||||
custom callback functions, which will be called when the watchdog timer
|
||||
managed by Auto-monitor times out.
|
||||
|
||||
choice
|
||||
prompt "Auto-monitor keepalive by"
|
||||
default WATCHDOG_AUTOMONITOR_BY_WDOG
|
||||
|
|
|
@ -71,6 +71,20 @@
|
|||
# endif
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_WATCHDOG_AUTOMONITOR_BY_ONESHOT)
|
||||
# define WATCHDOG_NOTIFIER_ACTION WATCHDOG_KEEPALIVE_BY_ONESHOT
|
||||
#elif defined(CONFIG_WATCHDOG_AUTOMONITOR_BY_TIMER)
|
||||
# define WATCHDOG_NOTIFIER_ACTION WATCHDOG_KEEPALIVE_BY_TIMER
|
||||
#elif defined(CONFIG_WATCHDOG_AUTOMONITOR_BY_WDOG)
|
||||
# define WATCHDOG_NOTIFIER_ACTION WATCHDOG_KEEPALIVE_BY_WDOG
|
||||
#elif defined(CONFIG_WATCHDOG_AUTOMONITOR_BY_WORKER)
|
||||
# define WATCHDOG_NOTIFIER_ACTION WATCHDOG_KEEPALIVE_BY_WORKER
|
||||
#elif defined(CONFIG_WATCHDOG_AUTOMONITOR_BY_CAPTURE)
|
||||
# define WATCHDOG_NOTIFIER_ACTION WATCHDOG_KEEPALIVE_BY_CAPTURE
|
||||
#elif defined(CONFIG_WATCHDOG_AUTOMONITOR_BY_IDLE)
|
||||
# define WATCHDOG_NOTIFIER_ACTION WATCHDOG_KEEPALIVE_BY_IDLE
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Private Type Definitions
|
||||
****************************************************************************/
|
||||
|
@ -135,6 +149,10 @@ static const struct file_operations g_wdogops =
|
|||
wdog_ioctl, /* ioctl */
|
||||
};
|
||||
|
||||
#ifdef CONFIG_WATCHDOG_TIMEOUT_NOTIFIER
|
||||
static ATOMIC_NOTIFIER_HEAD(g_watchdog_notifier_list);
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
@ -699,6 +717,55 @@ static int wdog_ioctl(FAR struct file *filep, int cmd, unsigned long arg)
|
|||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_WATCHDOG_TIMEOUT_NOTIFIER
|
||||
/****************************************************************************
|
||||
* Name: watchdog_notifier_chain_register
|
||||
*
|
||||
* Description:
|
||||
* Add notifier to the watchdog notifier chain
|
||||
*
|
||||
* Input Parameters:
|
||||
* nb - New entry in notifier chain
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
void watchdog_notifier_chain_register(FAR struct notifier_block *nb)
|
||||
{
|
||||
atomic_notifier_chain_register(&g_watchdog_notifier_list, nb);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: watchdog_notifier_chain_unregister
|
||||
*
|
||||
* Description:
|
||||
* Remove notifier from the watchdog notifier chain
|
||||
*
|
||||
* Input Parameters:
|
||||
* nb - Entry to remove from notifier chain
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
void watchdog_notifier_chain_unregister(FAR struct notifier_block *nb)
|
||||
{
|
||||
atomic_notifier_chain_unregister(&g_watchdog_notifier_list, nb);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: watchdog_automonitor_timeout
|
||||
*
|
||||
* Description:
|
||||
* This function can be called in the watchdog timeout interrupt handler.
|
||||
* If so, callbacks on the watchdog timer notify chain are called when the
|
||||
* watchdog timer times out.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
void watchdog_automonitor_timeout(void)
|
||||
{
|
||||
atomic_notifier_call_chain(&g_watchdog_notifier_list, action, data);
|
||||
}
|
||||
#endif /* CONFIG_WATCHDOG_TIMEOUT_NOTIFIER */
|
||||
|
||||
/****************************************************************************
|
||||
* Name: watchdog_register
|
||||
*
|
||||
|
|
|
@ -31,6 +31,7 @@
|
|||
#include <nuttx/compiler.h>
|
||||
#include <nuttx/irq.h>
|
||||
#include <nuttx/fs/ioctl.h>
|
||||
#include <nuttx/notifier.h>
|
||||
|
||||
#ifdef CONFIG_WATCHDOG
|
||||
|
||||
|
@ -88,6 +89,35 @@
|
|||
#define WDFLAGS_CAPTURE (1 << 2) /* 1=Call the user function when the
|
||||
* watchdog timer expires */
|
||||
|
||||
/* Keepalive Actions ********************************************************/
|
||||
|
||||
/* According to the keepalive action specified by the Auto-monitor, callback
|
||||
* functions registered on the watchdog notifier chain may take corresponding
|
||||
* actions.
|
||||
*
|
||||
* These are detected and handled by the "upper half" watchdog timer driver.
|
||||
*
|
||||
* WATCHDOG_KEEPALIVE_BY_ONESHOT - The watchdog timer is keepalive by
|
||||
* oneshot timer.
|
||||
* WATCHDOG_KEEPALIVE_BY_TIMER - The watchdog timer is keepalive by
|
||||
* timer.
|
||||
* WATCHDOG_KEEPALIVE_BY_WDOG - The watchdog timer is keepalive by
|
||||
* wdog.
|
||||
* WATCHDOG_KEEPALIVE_BY_WORKER - The watchdog timer is keepalive by
|
||||
* worker queue.
|
||||
* WATCHDOG_KEEPALIVE_BY_CAPTURE - The watchdog timer is keepalive by
|
||||
* capture.
|
||||
* WATCHDOG_KEEPALIVE_BY_IDLE - The watchdog timer is keepalive by
|
||||
* idle task.
|
||||
*/
|
||||
|
||||
#define WATCHDOG_KEEPALIVE_BY_ONESHOT 0
|
||||
#define WATCHDOG_KEEPALIVE_BY_TIMER 1
|
||||
#define WATCHDOG_KEEPALIVE_BY_WDOG 2
|
||||
#define WATCHDOG_KEEPALIVE_BY_WORKER 3
|
||||
#define WATCHDOG_KEEPALIVE_BY_CAPTURE 4
|
||||
#define WATCHDOG_KEEPALIVE_BY_IDLE 5
|
||||
|
||||
/****************************************************************************
|
||||
* Public Types
|
||||
****************************************************************************/
|
||||
|
@ -197,6 +227,47 @@ extern "C"
|
|||
#define EXTERN extern
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_WATCHDOG_TIMEOUT_NOTIFIER
|
||||
/****************************************************************************
|
||||
* Name: watchdog_notifier_chain_register
|
||||
*
|
||||
* Description:
|
||||
* Add notifier to the watchdog notifier chain
|
||||
*
|
||||
* Input Parameters:
|
||||
* nb - New entry in notifier chain
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
void watchdog_notifier_chain_register(FAR struct notifier_block *nb);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: watchdog_notifier_chain_unregister
|
||||
*
|
||||
* Description:
|
||||
* Remove notifier from the watchdog notifier chain
|
||||
*
|
||||
* Input Parameters:
|
||||
* nb - Entry to remove from notifier chain
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
void watchdog_notifier_chain_unregister(FAR struct notifier_block *nb);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: watchdog_automonitor_timeout
|
||||
*
|
||||
* Description:
|
||||
* This function can be called in the watchdog timeout interrupt handler.
|
||||
* If so, callbacks on the watchdog timer notify chain are called when the
|
||||
* watchdog timer times out.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
void watchdog_automonitor_timeout(void);
|
||||
|
||||
#endif /* CONFIG_WATCHDOG_TIMEOUT_NOTIFIER */
|
||||
|
||||
/****************************************************************************
|
||||
* Name: watchdog_register
|
||||
*
|
||||
|
|
Loading…
Reference in a new issue