mirror of
https://github.com/apache/nuttx.git
synced 2026-05-21 04:52:02 +08:00
risc-v/esp32c3: Add support for MWDT0 and MWDT1
This commit is contained in:
committed by
Abdelatif Guettouche
parent
7b8c72ec1b
commit
291a5755cc
@@ -104,6 +104,10 @@ config ESP32C3_CPU_FREQ_MHZ
|
||||
|
||||
menu "ESP32-C3 Peripheral Support"
|
||||
|
||||
config ESP32C3_WDT
|
||||
bool
|
||||
default n
|
||||
|
||||
config ESP32C3_GPIO_IRQ
|
||||
bool "GPIO pin interrupts"
|
||||
---help---
|
||||
@@ -119,6 +123,33 @@ config ESP32C3_UART1
|
||||
default n
|
||||
select UART1_SERIALDRIVER
|
||||
|
||||
config ESP32C3_MWDT0
|
||||
bool "Main System Watchdog Timer (Group 0)"
|
||||
default n
|
||||
select ESP32C3_WDT
|
||||
---help---
|
||||
Includes MWDT0. This watchdog timer is part of the Group 0
|
||||
timer submodule.
|
||||
|
||||
config ESP32C3_MWDT1
|
||||
bool "Main System Watchdog Timer (Group 1)"
|
||||
default n
|
||||
select ESP32C3_WDT
|
||||
---help---
|
||||
Includes MWDT1. This watchdog timer is part of the Group 0
|
||||
timer submodule.
|
||||
|
||||
config ESP32C3_RWDT
|
||||
bool "RTC Watchdog Timer"
|
||||
default n
|
||||
select ESP32C3_WDT
|
||||
---help---
|
||||
Includes RWDT. This watchdog timer is from the RTC module.
|
||||
When it is selected, if the developer sets it to reset on expiration
|
||||
it will reset Main System and the RTC module. If you don't want
|
||||
to have the RTC module reset, please, use the Timers' Module WDTs.
|
||||
They will only reset Main System.
|
||||
|
||||
endmenu
|
||||
|
||||
endif # ARCH_CHIP_ESP32C3
|
||||
|
||||
@@ -53,3 +53,10 @@ CHIP_CSRCS = esp32c3_allocateheap.c esp32c3_start.c esp32c3_idle.c
|
||||
CHIP_CSRCS += esp32c3_irq.c esp32c3_timerisr.c
|
||||
CHIP_CSRCS += esp32c3_clockconfig.c esp32c3_gpio.c
|
||||
CHIP_CSRCS += esp32c3_serial.c esp32c3_lowputc.c
|
||||
|
||||
ifeq ($(CONFIG_ESP32C3_WDT),y)
|
||||
CHIP_CSRCS += esp32c3_wdt.c
|
||||
ifeq ($(CONFIG_WATCHDOG),y)
|
||||
CHIP_CSRCS += esp32c3_wdt_lowerhalf.c
|
||||
endif
|
||||
endif
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,147 @@
|
||||
/****************************************************************************
|
||||
* arch/riscv/src/esp32c3/esp32c3_wdt.h
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership. The
|
||||
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __ARCH_RISCV_SRC_ESP32C3_ESP32C3_WDT_H
|
||||
#define __ARCH_RISCV_SRC_ESP32C3_ESP32C3_WDT_H
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
#include <stdint.h>
|
||||
#include <nuttx/irq.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/* Helpers ******************************************************************/
|
||||
|
||||
#define ESP32C3_WDT_START(d) ((d)->ops->start(d))
|
||||
#define ESP32C3_WDT_STOP(d) ((d)->ops->stop(d))
|
||||
#define ESP32C3_WDT_LOCK(d) ((d)->ops->enablewp(d))
|
||||
#define ESP32C3_WDT_UNLOCK(d) ((d)->ops->disablewp(d))
|
||||
#define ESP32C3_MWDT_PRE(d, v) ((d)->ops->pre(d, v))
|
||||
#define ESP32C3_WDT_STO(d, v, s) ((d)->ops->settimeout(d, v, s))
|
||||
#define ESP32C3_WDT_FEED(d) ((d)->ops->feed(d))
|
||||
#define ESP32C3_WDT_STG_CONF(d, s, c) ((d)->ops->stg_conf(d, s, c))
|
||||
#define ESP32C3_MWDT_UPD_CONF(d) ((d)->ops->upd_conf(d))
|
||||
#define ESP32C3_RWDT_CLK(d) ((d)->ops->rtc_clk(d))
|
||||
#define ESP32C3_WDT_SETISR(d, hnd, arg) ((d)->ops->setisr(d, hnd, arg))
|
||||
#define ESP32C3_WDT_ENABLEINT(d) ((d)->ops->enableint(d))
|
||||
#define ESP32C3_WDT_DISABLEINT(d) ((d)->ops->disableint(d))
|
||||
#define ESP32C3_WDT_ACKINT(d) ((d)->ops->ackint(d))
|
||||
|
||||
/****************************************************************************
|
||||
* Public Types
|
||||
****************************************************************************/
|
||||
|
||||
/* Instances of Watchdog Timer */
|
||||
|
||||
enum esp32c3_wdt_inst_e
|
||||
{
|
||||
ESP32C3_WDT_MWDT0 = 0, /* Main System Watchdog Timer (MWDT) of Timer Group 0 */
|
||||
ESP32C3_WDT_MWDT1, /* Main System Watchdog Timer (MWDT) of Timer Group 1 */
|
||||
ESP32C3_WDT_RWDT /* RTC Watchdog Timer (RWDT) */
|
||||
};
|
||||
|
||||
/* Stages of a Watchdog Timer. A WDT has 4 stages. */
|
||||
|
||||
enum esp32c3_wdt_stage_e
|
||||
{
|
||||
ESP32C3_WDT_STAGE0 = 0, /* Stage 0 */
|
||||
ESP32C3_WDT_STAGE1 = 1, /* Stage 1 */
|
||||
ESP32C3_WDT_STAGE2 = 2, /* Stage 2 */
|
||||
ESP32C3_WDT_STAGE3 = 3 /* Stage 3 */
|
||||
};
|
||||
|
||||
/**
|
||||
* Behavior of the WDT stage if it times out.
|
||||
*
|
||||
* @note These enum values should be compatible with the
|
||||
* corresponding register field values.
|
||||
*/
|
||||
|
||||
enum esp32c3_wdt_stage_action_e
|
||||
{
|
||||
ESP32C3_WDT_STAGE_ACTION_OFF = 0, /* Disabled. This stage will have no effects on the system. */
|
||||
ESP32C3_WDT_STAGE_ACTION_INT = 1, /* Trigger an interrupt when the stage expires. */
|
||||
ESP32C3_WDT_STAGE_ACTION_RESET_CPU = 2, /* Reset a CPU core when the stage expires. */
|
||||
ESP32C3_WDT_STAGE_ACTION_RESET_SYSTEM = 3, /* Reset the main system when the stage expires.
|
||||
* This includes the CPU and all peripherals.
|
||||
* The RTC is an exception and will not be reset.
|
||||
*/
|
||||
ESP32C3_WDT_STAGE_ACTION_RESET_RTC = 4 /* Reset the main system and the RTC when the stage expires.
|
||||
* ONLY AVAILABLE FOR RWDT.
|
||||
*/
|
||||
};
|
||||
|
||||
/* ESP32 WDT device */
|
||||
|
||||
struct esp32c3_wdt_dev_s
|
||||
{
|
||||
struct esp32c3_wdt_ops_s *ops;
|
||||
};
|
||||
|
||||
/* ESP32 WDT ops */
|
||||
|
||||
/* This is a struct containing the pointers to the wdt operations */
|
||||
|
||||
struct esp32c3_wdt_ops_s
|
||||
{
|
||||
/* WDT tasks */
|
||||
|
||||
void (*start)(struct esp32c3_wdt_dev_s *dev);
|
||||
void (*stop)(struct esp32c3_wdt_dev_s *dev);
|
||||
|
||||
/* WDT configuration */
|
||||
|
||||
void (*enablewp)(struct esp32c3_wdt_dev_s *dev);
|
||||
void (*disablewp)(struct esp32c3_wdt_dev_s *dev);
|
||||
void (*pre)(struct esp32c3_wdt_dev_s *dev, uint16_t value);
|
||||
int32_t (*settimeout)(struct esp32c3_wdt_dev_s *dev,
|
||||
uint32_t value,
|
||||
enum esp32c3_wdt_stage_e stage);
|
||||
void (*feed)(struct esp32c3_wdt_dev_s *dev);
|
||||
int32_t (*stg_conf)(struct esp32c3_wdt_dev_s *dev,
|
||||
enum esp32c3_wdt_stage_e stage,
|
||||
enum esp32c3_wdt_stage_action_e conf);
|
||||
void (*upd_conf)(struct esp32c3_wdt_dev_s *dev);
|
||||
uint16_t (*rtc_clk)(struct esp32c3_wdt_dev_s *dev);
|
||||
|
||||
/* WDT interrupts */
|
||||
|
||||
int32_t (*setisr)(struct esp32c3_wdt_dev_s *dev, xcpt_t handler,
|
||||
void * arg);
|
||||
void (*enableint)(struct esp32c3_wdt_dev_s *dev);
|
||||
void (*disableint)(struct esp32c3_wdt_dev_s *dev);
|
||||
void (*ackint)(struct esp32c3_wdt_dev_s *dev);
|
||||
};
|
||||
|
||||
/****************************************************************************
|
||||
* Public Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
struct esp32c3_wdt_dev_s *esp32c3_wdt_init(enum esp32c3_wdt_inst_e wdt_id);
|
||||
void esp32c3_wdt_deinit(struct esp32c3_wdt_dev_s *dev);
|
||||
bool esp32c3_wdt_is_running(struct esp32c3_wdt_dev_s *dev);
|
||||
|
||||
#endif /* __ARCH_RISCV_SRC_ESP32C3_ESP32C3_WDT_H */
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,58 @@
|
||||
/****************************************************************************
|
||||
* arch/riscv/src/esp32c3/esp32c3_wdt_lowerhalf.h
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership. The
|
||||
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __ARCH_RISCV_SRC_ESP32C3_ESP32C3_WDT_LOWERHALF_H
|
||||
#define __ARCH_RISCV_SRC_ESP32C3_ESP32C3_WDT_LOWERHALF_H
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include "esp32c3_wdt.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Public Types
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: esp32c3_wdt_initialize
|
||||
*
|
||||
* Description:
|
||||
* Initialize the watchdog timer. The watchdog timer is initialized
|
||||
* and registered as 'devpath'.
|
||||
*
|
||||
* Input Parameters:
|
||||
* devpath - The full path to the watchdog. This should
|
||||
* be of the form /dev/watchdogX
|
||||
* wdt - WDT instance to be initialized.
|
||||
*
|
||||
* Returned Values:
|
||||
* Zero (OK) is returned on success; a negated errno value is returned on
|
||||
* any failure.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int esp32c3_wdt_initialize(const char *devpath, enum esp32c3_wdt_inst_e wdt);
|
||||
|
||||
#endif /* __ARCH_RISCV_SRC_ESP32C3_ESP32C3_WDT_LOWERHALF_H */
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -96,6 +96,33 @@ Configurations
|
||||
The pin is configured as a rising edge interrupt, so after issuing the
|
||||
above command, connect it to 3.3V.
|
||||
|
||||
watchdog
|
||||
--------
|
||||
|
||||
This configuration tests the watchdog timers. It includes the 2 MWDTS,
|
||||
adds driver support, registers the WDTs as devices and includes the watchdog
|
||||
example application.
|
||||
|
||||
To test it, just run the following command:
|
||||
|
||||
`nsh> wdog -i /dev/watchdogX`
|
||||
|
||||
Where X ix the watchdog instance.
|
||||
|
||||
watcher
|
||||
-------
|
||||
|
||||
This configuration tests the watchdog timers in the capture mode.
|
||||
It includes the 2 MWDTS, adds driver support, registers the WDTs as devices
|
||||
and includes the watcher and watched example applications.
|
||||
|
||||
To test it, just run the following command:
|
||||
|
||||
```
|
||||
nsh> watcher
|
||||
nsh> watched
|
||||
```
|
||||
|
||||
Building and flashing
|
||||
=====================
|
||||
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
#
|
||||
# This file is autogenerated: PLEASE DO NOT EDIT IT.
|
||||
#
|
||||
# You can use "make menuconfig" to make any modifications to the installed .config file.
|
||||
# You can then do "make savedefconfig" to generate a new defconfig file that includes your
|
||||
# modifications.
|
||||
#
|
||||
# CONFIG_NSH_ARGCAT is not set
|
||||
# CONFIG_NSH_CMDOPT_HEXDUMP is not set
|
||||
# CONFIG_NSH_CMDPARMS is not set
|
||||
CONFIG_ARCH="risc-v"
|
||||
CONFIG_ARCH_BOARD="esp32c3-devkit"
|
||||
CONFIG_ARCH_BOARD_ESP32C3_DEVKIT=y
|
||||
CONFIG_ARCH_CHIP="esp32c3"
|
||||
CONFIG_ARCH_CHIP_ESP32C3=y
|
||||
CONFIG_ARCH_CHIP_ESP32C3WROOM02=y
|
||||
CONFIG_ARCH_INTERRUPTSTACK=1536
|
||||
CONFIG_ARCH_RISCV=y
|
||||
CONFIG_ARCH_STACKDUMP=y
|
||||
CONFIG_BOARD_LOOPSPERMSEC=15000
|
||||
CONFIG_BUILTIN=y
|
||||
CONFIG_DEV_ZERO=y
|
||||
CONFIG_ESP32C3_MWDT0=y
|
||||
CONFIG_ESP32C3_MWDT1=y
|
||||
CONFIG_EXAMPLES_WATCHDOG=y
|
||||
CONFIG_FS_PROCFS=y
|
||||
CONFIG_IDLETHREAD_STACKSIZE=2048
|
||||
CONFIG_INTELHEX_BINARY=y
|
||||
CONFIG_LIBC_PERROR_STDOUT=y
|
||||
CONFIG_LIBC_STRERROR=y
|
||||
CONFIG_MAX_TASKS=8
|
||||
CONFIG_NFILE_DESCRIPTORS=6
|
||||
CONFIG_NSH_ARCHINIT=y
|
||||
CONFIG_NSH_BUILTIN_APPS=y
|
||||
CONFIG_NSH_FILEIOSIZE=512
|
||||
CONFIG_NSH_READLINE=y
|
||||
CONFIG_NSH_STRERROR=y
|
||||
CONFIG_PREALLOC_TIMERS=0
|
||||
CONFIG_RAW_BINARY=y
|
||||
CONFIG_RR_INTERVAL=200
|
||||
CONFIG_SCHED_WAITPID=y
|
||||
CONFIG_START_DAY=29
|
||||
CONFIG_START_MONTH=11
|
||||
CONFIG_START_YEAR=2019
|
||||
CONFIG_SYSTEM_NSH=y
|
||||
CONFIG_UART0_SERIAL_CONSOLE=y
|
||||
CONFIG_USER_ENTRYPOINT="nsh_main"
|
||||
CONFIG_WATCHDOG=y
|
||||
@@ -0,0 +1,51 @@
|
||||
#
|
||||
# This file is autogenerated: PLEASE DO NOT EDIT IT.
|
||||
#
|
||||
# You can use "make menuconfig" to make any modifications to the installed .config file.
|
||||
# You can then do "make savedefconfig" to generate a new defconfig file that includes your
|
||||
# modifications.
|
||||
#
|
||||
# CONFIG_NSH_ARGCAT is not set
|
||||
# CONFIG_NSH_CMDOPT_HEXDUMP is not set
|
||||
# CONFIG_NSH_CMDPARMS is not set
|
||||
CONFIG_ARCH="risc-v"
|
||||
CONFIG_ARCH_BOARD="esp32c3-devkit"
|
||||
CONFIG_ARCH_BOARD_ESP32C3_DEVKIT=y
|
||||
CONFIG_ARCH_CHIP="esp32c3"
|
||||
CONFIG_ARCH_CHIP_ESP32C3=y
|
||||
CONFIG_ARCH_CHIP_ESP32C3WROOM02=y
|
||||
CONFIG_ARCH_INTERRUPTSTACK=1536
|
||||
CONFIG_ARCH_RISCV=y
|
||||
CONFIG_ARCH_STACKDUMP=y
|
||||
CONFIG_BOARD_LOOPSPERMSEC=15000
|
||||
CONFIG_BUILTIN=y
|
||||
CONFIG_DEV_ZERO=y
|
||||
CONFIG_DRIVER_NOTE=y
|
||||
CONFIG_ESP32C3_MWDT0=y
|
||||
CONFIG_ESP32C3_MWDT1=y
|
||||
CONFIG_EXAMPLES_WATCHER=y
|
||||
CONFIG_FS_FAT=y
|
||||
CONFIG_FS_PROCFS=y
|
||||
CONFIG_IDLETHREAD_STACKSIZE=2048
|
||||
CONFIG_INTELHEX_BINARY=y
|
||||
CONFIG_LIBC_PERROR_STDOUT=y
|
||||
CONFIG_LIBC_STRERROR=y
|
||||
CONFIG_MAX_TASKS=8
|
||||
CONFIG_NFILE_DESCRIPTORS=6
|
||||
CONFIG_NSH_ARCHINIT=y
|
||||
CONFIG_NSH_BUILTIN_APPS=y
|
||||
CONFIG_NSH_FILEIOSIZE=512
|
||||
CONFIG_NSH_READLINE=y
|
||||
CONFIG_NSH_STRERROR=y
|
||||
CONFIG_PREALLOC_TIMERS=0
|
||||
CONFIG_RAW_BINARY=y
|
||||
CONFIG_RR_INTERVAL=200
|
||||
CONFIG_SCHED_INSTRUMENTATION=y
|
||||
CONFIG_SCHED_WAITPID=y
|
||||
CONFIG_START_DAY=29
|
||||
CONFIG_START_MONTH=11
|
||||
CONFIG_START_YEAR=2019
|
||||
CONFIG_SYSTEM_NSH=y
|
||||
CONFIG_UART0_SERIAL_CONSOLE=y
|
||||
CONFIG_USER_ENTRYPOINT="nsh_main"
|
||||
CONFIG_WATCHDOG=y
|
||||
@@ -34,6 +34,10 @@ ifeq ($(CONFIG_DEV_GPIO),y)
|
||||
CSRCS += esp32c3_gpio.c
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_WATCHDOG),y)
|
||||
CSRCS += esp32c3_wdt.c
|
||||
endif
|
||||
|
||||
SCRIPTIN = $(SCRIPTDIR)$(DELIM)esp32c3.template.ld
|
||||
SCRIPTOUT = $(SCRIPTDIR)$(DELIM)esp32c3_out.ld
|
||||
|
||||
|
||||
@@ -25,9 +25,7 @@
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
#include <nuttx/compiler.h>
|
||||
#include <stdint.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
@@ -71,5 +69,21 @@ int esp32c3_bringup(void);
|
||||
int esp32c3_gpio_init(void);
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: board_wdt_init
|
||||
*
|
||||
* Description:
|
||||
* Configure the timer driver.
|
||||
*
|
||||
* Returned Value:
|
||||
* Zero (OK) is returned on success; A negated errno value is returned
|
||||
* to indicate the nature of any failure.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_WATCHDOG
|
||||
int board_wdt_init(void);
|
||||
#endif
|
||||
|
||||
#endif /* __ASSEMBLY__ */
|
||||
#endif /* __BOARDS_RISCV_ESP32C3_ESP32C3_DEVKIT_SRC_ESP32C3_DEVKIT_H */
|
||||
|
||||
@@ -22,15 +22,6 @@
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <debug.h>
|
||||
|
||||
#include <nuttx/board.h>
|
||||
#include <arch/board/board.h>
|
||||
|
||||
#include "esp32c3-devkit.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
@@ -85,6 +85,18 @@ int esp32c3_bringup(void)
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_WATCHDOG
|
||||
/* Configure watchdog timer */
|
||||
|
||||
ret = board_wdt_init();
|
||||
if (ret < 0)
|
||||
{
|
||||
syslog(LOG_ERR,
|
||||
"ERROR: Failed to initialize watchdog drivers: %d\n",
|
||||
ret);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* If we got here then perhaps not all initialization was successful, but
|
||||
* at least enough succeeded to bring-up NSH with perhaps reduced
|
||||
* capabilities.
|
||||
|
||||
@@ -0,0 +1,94 @@
|
||||
/****************************************************************************
|
||||
* boards/risc-v/esp32c3/esp32c3-devkit/src/esp32c3_wdt.c
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership. The
|
||||
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include "esp32c3_wdt_lowerhalf.h"
|
||||
#include "esp32c3_wdt.h"
|
||||
|
||||
#include "esp32c3-devkit.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: board_wdt_init
|
||||
*
|
||||
* Description:
|
||||
* Configure the watchdog timer driver.
|
||||
*
|
||||
* Returned Value:
|
||||
* Zero (OK) is returned on success; A negated errno value is returned
|
||||
* to indicate the nature of any failure.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int board_wdt_init(void)
|
||||
{
|
||||
int ret = OK;
|
||||
|
||||
#ifdef CONFIG_ESP32C3_MWDT0
|
||||
ret = esp32c3_wdt_initialize("/dev/watchdog0", ESP32C3_WDT_MWDT0);
|
||||
if (ret < 0)
|
||||
{
|
||||
syslog(LOG_ERR,
|
||||
"ERROR: Failed to initialize watchdog driver: %d\n",
|
||||
ret);
|
||||
return ret;
|
||||
}
|
||||
#endif /* CONFIG_ESP32C3_MWDT0 */
|
||||
|
||||
#ifdef CONFIG_ESP32C3_MWDT1
|
||||
ret = esp32c3_wdt_initialize("/dev/watchdog1", ESP32C3_WDT_MWDT1);
|
||||
if (ret < 0)
|
||||
{
|
||||
syslog(LOG_ERR,
|
||||
"ERROR: Failed to initialize watchdog driver: %d\n",
|
||||
ret);
|
||||
return ret;
|
||||
}
|
||||
#endif /* CONFIG_ESP32C3_MWDT1 */
|
||||
|
||||
#ifdef CONFIG_ESP32C3_RWDT
|
||||
ret = esp32c3_wdt_initialize("/dev/watchdog2", ESP32C3_WDT_RWDT);
|
||||
if (ret < 0)
|
||||
{
|
||||
syslog(LOG_ERR,
|
||||
"ERROR: Failed to initialize watchdog driver: %d\n",
|
||||
ret);
|
||||
return ret;
|
||||
}
|
||||
#endif /* CONFIG_ESP32C3_RWDT */
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user