drivers/watchdog/wdt.c File Reference

Watchdog driver for the AVR32 WDT. More...

#include <debug.h>
#include <io.h>
#include <util.h>
#include <watchdog.h>
#include <chip/clk.h>

Include dependency graph for wdt.c:

Go to the source code of this file.

Defines

#define WDT_CTRL   0x00
 Control Register.
#define WDT_CTRL_KEY1   (0x55 << 24)
 1st write key
#define WDT_CTRL_KEY2   (0xaa << 24)
 2nd write key
#define WDT_CTRL_PSEL(x)   ((x) << 8)
 Prescale Select.
#define WDT_CTRL_EN   (1 << 0)
 WDT Enable.
#define WDT_CLR   0x04
 Clear Register.
#define wdt_read_reg(reg)   mmio_read32((void *)(WDT_BASE + WDT_##reg))
 Return the value of WDT register reg.
#define wdt_write_reg(reg, val)   mmio_write32((void *)(WDT_BASE + WDT_##reg), val)
 Write the value val to WDT register reg.

Functions

void watchdog_set_timeout (unsigned long timeout_ms)
 Initialize the watchdog.
void watchdog_enable (void)
 Enable the watchdog.
void watchdog_disable (void)
 Enable the watchdog.
void watchdog_reset (void)
 Reset the watchdog.


Detailed Description

Watchdog driver for the AVR32 WDT.

Author:
Atmel Corporation: http://www.atmel.com
Support and FAQ: http://support.atmel.no/

Definition in file wdt.c.


Define Documentation

#define WDT_CLR   0x04

Clear Register.

Definition at line 52 of file wdt.c.

#define WDT_CTRL   0x00

Control Register.

Definition at line 47 of file wdt.c.

#define WDT_CTRL_EN   (1 << 0)

WDT Enable.

Definition at line 51 of file wdt.c.

Referenced by watchdog_disable(), and watchdog_enable().

#define WDT_CTRL_KEY1   (0x55 << 24)

1st write key

Definition at line 48 of file wdt.c.

Referenced by watchdog_disable(), watchdog_enable(), and watchdog_set_timeout().

#define WDT_CTRL_KEY2   (0xaa << 24)

2nd write key

Definition at line 49 of file wdt.c.

Referenced by watchdog_disable(), watchdog_enable(), and watchdog_set_timeout().

#define WDT_CTRL_PSEL (  )     ((x) << 8)

Prescale Select.

Definition at line 50 of file wdt.c.

Referenced by watchdog_set_timeout().

#define wdt_read_reg ( reg   )     mmio_read32((void *)(WDT_BASE + WDT_##reg))

Return the value of WDT register reg.

For internal use only.

Definition at line 58 of file wdt.c.

Referenced by watchdog_disable(), and watchdog_enable().

#define wdt_write_reg ( reg,
val   )     mmio_write32((void *)(WDT_BASE + WDT_##reg), val)

Write the value val to WDT register reg.

For internal use only.

Definition at line 65 of file wdt.c.

Referenced by watchdog_disable(), watchdog_enable(), watchdog_reset(), and watchdog_set_timeout().


Function Documentation

void watchdog_disable ( void   ) 

Enable the watchdog.

After calling this function, the watchdog will stop counting and will not reset the chip even if watchdog_reset() isn't called regularly.

Definition at line 115 of file wdt.c.

References WDT_CTRL_EN, WDT_CTRL_KEY1, WDT_CTRL_KEY2, wdt_read_reg, and wdt_write_reg.

void watchdog_enable ( void   ) 

Enable the watchdog.

After calling this function, the watchdog will be counting and the chip will be reset if watchdog_reset() isn't called regularly before the timeout expires.

Definition at line 100 of file wdt.c.

References WDT_CTRL_EN, WDT_CTRL_KEY1, WDT_CTRL_KEY2, wdt_read_reg, and wdt_write_reg.

void watchdog_reset ( void   ) 

Reset the watchdog.

This function will reset the watchdog counter and must be called regularly while the watchdog is running. If the counter reaches the configured timeout, the chip will be reset.

Definition at line 131 of file wdt.c.

References wdt_write_reg.

void watchdog_set_timeout ( unsigned long  timeout_ms  ) 

Initialize the watchdog.

Note:
The actual timeout will never be less than the specified value, but may at worst be slightly more than twice the value specified.
Parameters:
timeout_ms The minimum timeout in milliseconds after which the watchdog will expire.

Definition at line 77 of file wdt.c.

References dbg_info, ilog2(), WDT_CTRL_KEY1, WDT_CTRL_KEY2, WDT_CTRL_PSEL, and wdt_write_reg.

Here is the call graph for this function:


Generated on Tue Sep 15 10:20:26 2009 for libavr32 by  doxygen 1.5.8