mirror of
https://github.com/apache/nuttx.git
synced 2026-05-20 20:44:39 +08:00
SAM3/4: Add watchdog timer support. From Bob Doisin
This commit is contained in:
@@ -7233,3 +7233,7 @@
|
||||
* configs/sam4s-xplained-pro: Added card detect (kind of broken
|
||||
still); added proc/vfat mounting during init to save some typing.
|
||||
From Bob Doison (2014-4-21).
|
||||
* configs/sam4s-xplained-pro: Boost PLLA to 240MHz to allow USB. From
|
||||
Bob Doison (2014-4-21).
|
||||
* arch/arm/src/sam34/sam_wdt.c/.h: Add watchdog driver. From Bob
|
||||
Doison (2014-4-21).
|
||||
|
||||
@@ -1189,10 +1189,10 @@ endmenu # USB Full Speed Device Controller driver (DCD) options
|
||||
endif # SAM34_UDP
|
||||
|
||||
if SAM34_WDT
|
||||
comment "AT91SAM3/4 Watchdog Configuration"|
|
||||
menu "AT91SAM3/4 Watchdog Configuration"
|
||||
|
||||
config WDT_ENABLED_ON_RESET
|
||||
bool "Enabled on reset"
|
||||
bool "Watchdog Enabled on reset"
|
||||
default n
|
||||
---help---
|
||||
The WDT can be enabled at reset. This is controlled by the WDTAUTO
|
||||
@@ -1204,7 +1204,7 @@ config WDT_ENABLED_ON_RESET
|
||||
enabled.
|
||||
|
||||
config WDT_DISABLE_ON_RESET
|
||||
bool "Disable on reset"
|
||||
bool "Disable watchdog on reset"
|
||||
default n
|
||||
depends on WDT_ENABLED_ON_RESET
|
||||
---help---
|
||||
@@ -1212,4 +1212,42 @@ config WDT_DISABLE_ON_RESET
|
||||
configure and disable the watchdog timer very early in the boot
|
||||
sequence.
|
||||
|
||||
config WDT_TIMEOUT
|
||||
int "Watchdog Timeout (ms)"
|
||||
default 4000
|
||||
depends on !WDT_DISABLE_ON_RESET
|
||||
---help---
|
||||
Watchdog timeout value in milliseconds.
|
||||
|
||||
config WDT_MINTIME
|
||||
int "Watchdog Minimum Time (ms)"
|
||||
default 2000
|
||||
depends on !WDT_DISABLE_ON_RESET
|
||||
---help---
|
||||
Minimum watchdog kick interval
|
||||
|
||||
menuconfig WDT_THREAD
|
||||
bool "Watchdog Kicker Thread"
|
||||
depends on !WDT_DISABLE_ON_RESET
|
||||
default y
|
||||
|
||||
if WDT_THREAD
|
||||
|
||||
config WDT_THREAD_NAME
|
||||
string "Watchdog Thread Name"
|
||||
default "wdog"
|
||||
|
||||
config WDT_THREAD_INTERVAL
|
||||
int "Watchdog Thread Interval (ms)"
|
||||
default 2000
|
||||
|
||||
config WDT_THREAD_PRIORITY
|
||||
int "Watchdog Thread Priority"
|
||||
default 99
|
||||
|
||||
config WDT_THREAD_STACKSIZE
|
||||
int "Watchdog Thread Stacksize"
|
||||
default 1024
|
||||
endif # WDT_THREAD
|
||||
endmenu #"AT91SAM3/4 Watchdog device driver options"
|
||||
endif # SAM34_WDT
|
||||
|
||||
@@ -133,3 +133,7 @@ endif
|
||||
ifeq ($(CONFIG_SAM34_RTC),y)
|
||||
CHIP_CSRCS += sam_rtc.c
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_SAM34_WDT),y)
|
||||
CHIP_CSRCS += sam_wdt.c
|
||||
endif
|
||||
|
||||
@@ -73,14 +73,16 @@
|
||||
/* Watchdog Timer Mode Register */
|
||||
|
||||
#define WDT_MR_WDV_SHIFT (0) /* Bits 0-11: Watchdog Counter Value */
|
||||
#define WDT_MR_WDV_MASK (0xfff << WDT_MR_WDV_SHIFT)
|
||||
#define WDT_MR_WDV_MAX 0xfff
|
||||
#define WDT_MR_WDV_MASK (WDT_MR_WDV_MAX << WDT_MR_WDV_SHIFT)
|
||||
# define WDT_MR_WDV(n) ((uint32_t)(n) << WDT_MR_WDV_SHIFT)
|
||||
#define WDT_MR_WDFIEN (1 << 12) /* Bit 12: Watchdog Fault Interrupt Enable */
|
||||
#define WDT_MR_WDRSTEN (1 << 13) /* Bit 13: Watchdog Reset Enable */
|
||||
#define WDT_MR_WDRPROC (1 << 14) /* Bit 14: Watchdog Reset Processor */
|
||||
#define WDT_MR_WDDIS (1 << 15) /* Bit 15: Watchdog Disable */
|
||||
#define WDT_MR_WDD_SHIFT (16) /* Bits 16-27: Watchdog Delta Value */
|
||||
#define WDT_MR_WDD_MASK (0xfff << WDT_MR_WDD_SHIFT)
|
||||
#define WDT_MR_WDD_MAX 0xfff
|
||||
#define WDT_MR_WDD_MASK (WDT_MR_WDD_MAX << WDT_MR_WDD_SHIFT)
|
||||
# define WDT_MR_WDD(n) ((uint32_t)(n) << WDT_MR_WDD_SHIFT)
|
||||
#define WDT_MR_WDDBGHLT (1 << 28) /* Bit 28: Watchdog Debug Halt */
|
||||
#define WDT_MR_WDIDLEHLT (1 << 29) /* Bit 29: Watchdog Idle Halt */
|
||||
|
||||
@@ -121,7 +121,9 @@ static inline void sam_efcsetup(void)
|
||||
|
||||
static inline void sam_wdtsetup(void)
|
||||
{
|
||||
#if !defined(CONFIG_SAM34_WDT) || (defined(CONFIG_WDT_ENABLED_ON_RESET) && defined(CONFIG_WDT_DISABLE_ON_RESET))
|
||||
putreg32(WDT_MR_WDDIS, SAM_WDT_MR);
|
||||
#endif
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
|
||||
@@ -931,7 +931,7 @@ static int up_interrupt(int irq, void *context)
|
||||
handled = true;
|
||||
}
|
||||
|
||||
/* Handle outgoing, transmit bytes. XRDY: There is no character in the
|
||||
/* Handle outgoing, transmit bytes. TXRDY: There is no character in the
|
||||
* US_THR.
|
||||
*/
|
||||
|
||||
|
||||
@@ -57,9 +57,6 @@
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
#if defined(CONFIG_WDT_ENABLED_ON_RESET) && defined(CONFIG_WDT_DISABLE_ON_RESET)
|
||||
# define NEED_WDT_DISABLE
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
@@ -124,11 +121,6 @@ void __start(void)
|
||||
*dest++ = *src++;
|
||||
}
|
||||
|
||||
#ifdef NEED_WDT_DISABLE
|
||||
/* Disable the watchdog timer */
|
||||
# warning Missing logic
|
||||
#endif
|
||||
|
||||
/* Copy any necessary code sections from FLASH to RAM. The correct
|
||||
* destination in SRAM is geive by _sramfuncs and _eramfuncs. The
|
||||
* temporary location is in flash after the data initalization code
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,96 @@
|
||||
/****************************************************************************
|
||||
* arch/arm/src/sam34/sam_wdt.h
|
||||
*
|
||||
* Copyright (C) 2012 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name NuttX nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __ARCH_ARM_SRC_SAM34_WDT_H
|
||||
#define __ARCH_ARM_SRC_SAM34_WDT_H
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include "chip.h"
|
||||
#include "chip/sam_wdt.h"
|
||||
|
||||
#ifdef CONFIG_WATCHDOG
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __ASSEMBLY__
|
||||
|
||||
#undef EXTERN
|
||||
#if defined(__cplusplus)
|
||||
#define EXTERN extern "C"
|
||||
extern "C" {
|
||||
#else
|
||||
#define EXTERN extern
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: sam_wdtinitialize
|
||||
*
|
||||
* Description:
|
||||
* Initialize the watchdog timer. The watchdog timer is initialized and
|
||||
* registers as 'devpath. The initial state of the watchdog time is
|
||||
* disabled.
|
||||
*
|
||||
* Input Parameters:
|
||||
* devpath - The full path to the watchdog. This should be of the form
|
||||
* /dev/watchdog0
|
||||
*
|
||||
* Returned Values:
|
||||
* None
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_SAM34_WDT
|
||||
EXTERN void sam_wdtinitialize(FAR const char *devpath);
|
||||
#endif
|
||||
|
||||
#undef EXTERN
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __ASSEMBLY__ */
|
||||
#endif /* CONFIG_WATCHDOG */
|
||||
#endif /* __ARCH_ARM_SRC_STM32_STM32_WDG_H */
|
||||
Reference in New Issue
Block a user