Watchdog and reset sytem drivers


Defines

#define Is_ext_reset()   ((MCUSR&(1<<EXTRF)) ? TRUE:FALSE)
#define Ack_ext_reset()   (MCUSR= ~(1<<EXTRF))
#define Is_POR_reset()   ((MCUSR&(1<<(MCUSR= ~(1<<PORF)))) ? TRUE:FALSE)
#define Ack_POR_reset()   (MCUSR= ~(1<<PORF))
#define Is_BOD_reset()   ((MCUSR&(1<<BORF)) ? TRUE:FALSE)
#define Ack_BOD_reset()   (MCUSR= ~(1<<BORF))
#define Is_wdt_reset()   ((MCUSR&(1<<WDRF)) ? TRUE:FALSE)
#define Ack_wdt_reset()   (MCUSR= ~(1<<WDRF))
#define Wdt_ack_interrupt()   (WDTCSR = (U8)(1<<WDIF))
#define Is_wdt_interrupt()   (WDTCSR&(1<<WDIF) ? TRUE:FALSE)
#define Is_not_wdt_interrupt()   (WDTCSR&(1<<WDIF) ? FALSE:TRUE)
#define Is_wdt_early_warning()   (WDTCKD&(1<<WDEWIF) ? TRUE:FALSE)
#define Is_not_wdt_early_warning()   (WDTCKD&(1<<WDEWIF) ? FALSE:TRUE)
#define WDTO_16MS   0
#define WDTO_32MS   1
#define WDTO_64MS   2
#define WDTO_125MS   3
#define WDTO_250MS   4
#define WDTO_500MS   5
#define WDTO_1S   6
#define WDTO_2S   7
#define WDTO_4S   8
#define WDTO_8S   9
#define Soft_reset()   {asm("jmp 0000");}

Functions

void wdtdrv_disable (void)
 This functions stops the hardware watchdog timer.
void wdtdrv_enable (U8 timeout)
 This functions activates the hardware watchdog timer.
void wdtdrv_interrupt_enable (U8 timeout)
 This functions activates the hardware watchdog timer Interrupt Mode only.
void wdtdrv_interrupt_reset_enable (U8 timeout)
 This functions activates the hardware watchdog timer Interrupt & System Reset Mode.

Define Documentation

 
#define Is_ext_reset (  )     ((MCUSR&(1<<EXTRF)) ? TRUE:FALSE)

Definition at line 57 of file wdt_drv.h.

 
#define Ack_ext_reset (  )     (MCUSR= ~(1<<EXTRF))

Definition at line 58 of file wdt_drv.h.

 
#define Is_POR_reset (  )     ((MCUSR&(1<<(MCUSR= ~(1<<PORF)))) ? TRUE:FALSE)

Definition at line 59 of file wdt_drv.h.

 
#define Ack_POR_reset (  )     (MCUSR= ~(1<<PORF))

Definition at line 60 of file wdt_drv.h.

 
#define Is_BOD_reset (  )     ((MCUSR&(1<<BORF)) ? TRUE:FALSE)

Definition at line 61 of file wdt_drv.h.

 
#define Ack_BOD_reset (  )     (MCUSR= ~(1<<BORF))

Definition at line 62 of file wdt_drv.h.

 
#define Is_wdt_reset (  )     ((MCUSR&(1<<WDRF)) ? TRUE:FALSE)

Definition at line 63 of file wdt_drv.h.

 
#define Ack_wdt_reset (  )     (MCUSR= ~(1<<WDRF))

Definition at line 64 of file wdt_drv.h.

Referenced by wdtdrv_disable(), wdtdrv_enable(), wdtdrv_interrupt_enable(), and wdtdrv_interrupt_reset_enable().

 
#define Wdt_ack_interrupt (  )     (WDTCSR = (U8)(1<<WDIF))

Definition at line 66 of file wdt_drv.h.

 
#define Is_wdt_interrupt (  )     (WDTCSR&(1<<WDIF) ? TRUE:FALSE)

Definition at line 67 of file wdt_drv.h.

 
#define Is_not_wdt_interrupt (  )     (WDTCSR&(1<<WDIF) ? FALSE:TRUE)

Definition at line 68 of file wdt_drv.h.

 
#define Is_wdt_early_warning (  )     (WDTCKD&(1<<WDEWIF) ? TRUE:FALSE)

Definition at line 69 of file wdt_drv.h.

 
#define Is_not_wdt_early_warning (  )     (WDTCKD&(1<<WDEWIF) ? FALSE:TRUE)

Definition at line 70 of file wdt_drv.h.

#define WDTO_16MS   0

Definition at line 72 of file wdt_drv.h.

Referenced by usb_general_interrupt(), and usb_task().

#define WDTO_32MS   1

Definition at line 73 of file wdt_drv.h.

#define WDTO_64MS   2

Definition at line 74 of file wdt_drv.h.

#define WDTO_125MS   3

Definition at line 75 of file wdt_drv.h.

#define WDTO_250MS   4

Definition at line 76 of file wdt_drv.h.

#define WDTO_500MS   5

Definition at line 77 of file wdt_drv.h.

#define WDTO_1S   6

Definition at line 78 of file wdt_drv.h.

#define WDTO_2S   7

Definition at line 79 of file wdt_drv.h.

#define WDTO_4S   8

Definition at line 80 of file wdt_drv.h.

#define WDTO_8S   9

Definition at line 81 of file wdt_drv.h.

 
#define Soft_reset (  )     {asm("jmp 0000");}

Definition at line 110 of file wdt_drv.h.


Function Documentation

void wdtdrv_disable ( void   ) 

This functions stops the hardware watchdog timer.

Definition at line 61 of file wdt_drv.c.

References Ack_wdt_reset, and Wdt_reset_instruction.

00062 {
00063    U8 save_int=Get_interrupt_state();
00064    Disable_interrupt();
00065 #ifdef  __GNUC__
00066    Ack_wdt_reset();
00067    wdt_disable();
00068 #else
00069    Ack_wdt_reset();
00070    Wdt_reset_instruction();
00071    WDTCSR = (1<<WDCE) | (1<<WDE);
00072    WDTCSR = 0x00;
00073 #endif
00074    if(save_int) { Enable_interrupt(); }
00075 }

void wdtdrv_enable ( U8  timeout  ) 

This functions activates the hardware watchdog timer.

Parameters:
timeout (WDTO_x)
This functions activates the hardware watchdog timer.

Parameters:
timeout (WDTO_x)

Definition at line 86 of file wdt_drv.c.

References Ack_wdt_reset, and Wdt_reset_instruction.

00087 {
00088    U8 save_int=Get_interrupt_state();
00089    Disable_interrupt();
00090 #ifdef  __GNUC__
00091    Ack_wdt_reset();
00092    wdt_enable(timeout);
00093 #else
00094    timeout = (1<<WDE)| (timeout & 0x08 ? (1<<WDP3) : 0x00) | (timeout & 0x07);
00095    Disable_interrupt();
00096    Wdt_reset_instruction();
00097    WDTCSR = (1<<WDCE) | (1<<WDE);
00098    WDTCSR = timeout;
00099 #endif
00100    if(save_int) { Enable_interrupt(); }
00101 }

void wdtdrv_interrupt_enable ( U8  timeout  ) 

This functions activates the hardware watchdog timer Interrupt Mode only.

Parameters:
timeout (WDTO_x)

Definition at line 112 of file wdt_drv.c.

References Ack_wdt_reset, and Wdt_reset_instruction.

00113 {
00114    U8 save_int=Get_interrupt_state();
00115 #ifdef  __GNUC__
00116    Ack_wdt_reset();
00117     __asm__ __volatile__ (  \
00118         "in __tmp_reg__,__SREG__" "\n\t"    \
00119         "cli" "\n\t"    \
00120         "wdr" "\n\t"    \
00121         "sts %0,%1" "\n\t"  \
00122         "out __SREG__,__tmp_reg__" "\n\t"   \
00123         "sts %0,%2" \
00124         : /* no outputs */  \
00125         : "M" (_SFR_MEM_ADDR(_WD_CONTROL_REG)), \
00126         "r" (_BV(_WD_CHANGE_BIT) | _BV(WDE)), \
00127         "r" ((uint8_t) ((timeout & 0x08 ? _WD_PS3_MASK : 0x00) | \
00128             _BV(WDIE) | (timeout & 0x07)) ) \
00129         : "r0"  \
00130     );
00131 #else
00132    timeout = (1<<WDIE)| (timeout & 0x08 ? (1<<WDP3) : 0x00) | (timeout & 0x07);
00133    Disable_interrupt();
00134    Wdt_reset_instruction();
00135    WDTCSR = (1<<WDCE) | (1<<WDE);
00136    WDTCSR = timeout;
00137 #endif
00138    if(save_int) { Enable_interrupt(); }
00139 }

void wdtdrv_interrupt_reset_enable ( U8  timeout  ) 

This functions activates the hardware watchdog timer Interrupt & System Reset Mode.

Parameters:
timeout (WDTO_x)

Definition at line 150 of file wdt_drv.c.

References Ack_wdt_reset, and Wdt_reset_instruction.

00151 {
00152    U8 save_int=Get_interrupt_state();
00153    Disable_interrupt();
00154 #ifdef  __GNUC__
00155    Ack_wdt_reset();
00156     __asm__ __volatile__ (  \
00157         "in __tmp_reg__,__SREG__" "\n\t"    \
00158         "cli" "\n\t"    \
00159         "wdr" "\n\t"    \
00160         "sts %0,%1" "\n\t"  \
00161         "out __SREG__,__tmp_reg__" "\n\t"   \
00162         "sts %0,%2" \
00163         : /* no outputs */  \
00164         : "M" (_SFR_MEM_ADDR(_WD_CONTROL_REG)), \
00165         "r" (_BV(_WD_CHANGE_BIT) | _BV(WDE)), \
00166         "r" ((uint8_t) ((timeout & 0x08 ? _WD_PS3_MASK : 0x00) | \
00167             _BV(WDE) | _BV(WDIE) | (timeout & 0x07)) ) \
00168         : "r0"  \
00169     );
00170 #else
00171    timeout = (1<<WDIE)|(1<<WDE)| (timeout & 0x08 ? (1<<WDP3) : 0x00) | (timeout & 0x07);
00172    Disable_interrupt();
00173    Wdt_reset_instruction();
00174    WDTCSR = (1<<WDCE) | (1<<WDE);
00175    WDTCSR = timeout;
00176 #endif
00177    if(save_int) { Enable_interrupt(); }
00178 }


Generated on Mon Sep 14 13:51:29 2009 for ATMEL by  doxygen 1.5.3