Xmega Application Note | |||||
#include "wdt_driver.h"
Go to the source code of this file.
Functions | |
void | WDT_Disable (void) |
Disable Watchdog without changing prescaler settings. | |
void | WDT_DisableWindowMode (void) |
Disable window mode without changing prescaler settings. | |
void | WDT_Enable (void) |
Enable Watchdog without changing prescaler settings. | |
void | WDT_EnableAndSetTimeout (WDT_PER_t period) |
Enable Watchdog and set prescaler. | |
bool | WDT_EnableWindowMode (void) |
Enable window mode without changing prescaler settings. | |
bool | WDT_EnableWindowModeAndSetTimeout (WDT_WPER_t period) |
Enable window mode and set prescaler. | |
bool | WDT_IsWindowModeEnabled (void) |
Return status of window mode enable bit. |
This file contains the function implementations for the XMEGA Watchdog driver.
The driver is not intended for size and/or speed critical code, since most functions are just a few lines of code, and the function call overhead would decrease code performance. The driver is intended for rapid prototyping and documentation purposes for getting started with the XMEGA Watchdog module.
For size and/or speed critical code, it is recommended to copy the function contents directly into your application instead of making a function call. Another way is to define all the functions as macros.
Copyright (c) 2009, Atmel Corporation All rights reserved.
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. The name of ATMEL may not be used to endorse or promote products derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY ATMEL "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 EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL 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.
Definition in file wdt_driver.c.
void WDT_Disable | ( | void | ) |
Disable Watchdog without changing prescaler settings.
This function disables the Watchdog without changing the prescaler settings. If it is enabled at a later time, the prescaler setting can be reused. Note that the Watchdog can only be disabled in Safety Level 1.
The function writes the correct signature to the Configuration Change Protection register before writing the CTRL register. Interrupts are automatically ignored during the change enable period. Disable functions operate asynchronously with immidiate effect.
Definition at line 125 of file wdt_driver.c.
Referenced by wdt_sw_enable_example().
00126 { 00127 uint8_t temp = (WDT.CTRL & ~WDT_ENABLE_bm) | WDT_CEN_bm; 00128 CCP = CCP_IOREG_gc; 00129 WDT.CTRL = temp; 00130 }
void WDT_DisableWindowMode | ( | void | ) |
Disable window mode without changing prescaler settings.
This function disables window mode without changing the prescaler settings. If it is enabled at a later time, the prescaler setting can be reused. Note that window mode can be disabled in Safety Level 1 and 2.
The function writes the correct signature to the Configuration Change Protection register before writing the WINCTRL register. Interrupts are automatically ignored during the change enable period. Disable functions operate asynchronously with immidiate effect.
Definition at line 220 of file wdt_driver.c.
Referenced by wdt_fuse_enable_example().
00221 { 00222 uint8_t temp = (WDT.WINCTRL & ~WDT_WEN_bm) | WDT_WCEN_bm; 00223 CCP = CCP_IOREG_gc; 00224 WDT.WINCTRL = temp; 00225 }
void WDT_Enable | ( | void | ) |
Enable Watchdog without changing prescaler settings.
This function enables the Watchdog without changing prescaler settings. The Watchdog will be reset automatically.
The function writes the correct signature to the Configuration Change Protection register before writing the CTRL register. Interrupts are automatically ignored during the change enable period. The function will wait for the watchdog to be synchronized to the other clock domains. before proceeding
Definition at line 73 of file wdt_driver.c.
References WDT_IsSyncBusy.
00074 { 00075 uint8_t temp = WDT.CTRL | WDT_ENABLE_bm | WDT_CEN_bm; 00076 CCP = CCP_IOREG_gc; 00077 WDT.CTRL = temp; 00078 00079 /* Wait for WD to synchronize with new settings. */ 00080 while(WDT_IsSyncBusy()){ 00081 00082 } 00083 }
void WDT_EnableAndSetTimeout | ( | WDT_PER_t | period | ) |
Enable Watchdog and set prescaler.
This function enables the Watchdog and applies prescaler settings. The Watchdog will be reset automatically.
The function writes the correct signature to the Configuration Change Protection register before writing the CTRL register. Interrupts are automatically ignored during the change enable period. TThe function will wait for the watchdog to be synchronized to the other clock domains. before proceeding
period | Watchdog Timer timeout period |
Definition at line 100 of file wdt_driver.c.
References WDT_IsSyncBusy.
Referenced by wdt_sw_enable_example().
00101 { 00102 uint8_t temp = WDT_ENABLE_bm | WDT_CEN_bm | period; 00103 CCP = CCP_IOREG_gc; 00104 WDT.CTRL = temp; 00105 00106 /* Wait for WD to synchronize with new settings. */ 00107 while(WDT_IsSyncBusy()){ 00108 00109 } 00110 }
bool WDT_EnableWindowMode | ( | void | ) |
Enable window mode without changing prescaler settings.
This function enables window mode without changing prescaler settings. The WD must be enabled before enabling window mode and a true value is returned if this condition is met.
The function writes the correct signature to the Configuration Change Protection register before writing the WINCTRL register. Interrupts are automatically ignored during the change enable period. The function will wait for the watchdog to be synchronized to the other clock domains. before proceeding.
true | The WD is enabled before enabling window mode | |
false | The WD is not enabled before enabling window mode. |
Definition at line 159 of file wdt_driver.c.
References WDT_IsSyncBusy.
Referenced by wdt_fuse_enable_example().
00160 { 00161 uint8_t wd_enable = WDT.CTRL & WDT_ENABLE_bm; 00162 uint8_t temp = WDT.WINCTRL | WDT_WEN_bm | WDT_WCEN_bm; 00163 CCP = CCP_IOREG_gc; 00164 WDT.WINCTRL = temp; 00165 00166 /* Wait for WD to synchronize with new settings. */ 00167 while(WDT_IsSyncBusy()){ 00168 00169 } 00170 00171 return wd_enable; 00172 }
bool WDT_EnableWindowModeAndSetTimeout | ( | WDT_WPER_t | period | ) |
Enable window mode and set prescaler.
This function enables window mode and applies prescaler settings. The WD must be enabled before enabling window mode and a true value is returned if this condition is met.
The function writes the correct signature to the Configuration Change Protection register before writing the WINCTRL register. Interrupts are automatically ignored during the change enable period. The function will wait for the watchdog to be synchronized to the other clock domains. before proceeding
period | Window mode "closed" timeout period |
true | The WD is enabled before enabling window mode | |
false | The WD is not enabled before enabling window mode. |
Definition at line 193 of file wdt_driver.c.
References WDT_IsSyncBusy.
Referenced by wdt_sw_enable_example().
00194 { 00195 uint8_t wd_enable = WDT.CTRL & WDT_ENABLE_bm; 00196 uint8_t temp = WDT_WEN_bm | WDT_WCEN_bm | period; 00197 CCP = CCP_IOREG_gc; 00198 WDT.WINCTRL = temp; 00199 00200 /* Wait for WD to synchronize with new settings. */ 00201 while(WDT_IsSyncBusy()){ 00202 00203 } 00204 00205 return wd_enable; 00206 }
bool WDT_IsWindowModeEnabled | ( | void | ) |
Return status of window mode enable bit.
true | The WD Window Mode is enabled. | |
false | The WD Eindow Mode is not enabled. |
Definition at line 138 of file wdt_driver.c.
Referenced by wdt_fuse_enable_example().
Generated on Thu Apr 16 15:20:09 2009 for AVR1310 Using the XMEGA Watchdog by ![]() |