00001
00058 #include "wdt_driver.h"
00059
00060
00061
00073 void WDT_Enable( void )
00074 {
00075 uint8_t temp = WDT.CTRL | WDT_ENABLE_bm | WDT_CEN_bm;
00076 CCP = CCP_IOREG_gc;
00077 WDT.CTRL = temp;
00078
00079
00080 while(WDT_IsSyncBusy()){
00081
00082 }
00083 }
00084
00085
00086
00100 void WDT_EnableAndSetTimeout( WDT_PER_t period )
00101 {
00102 uint8_t temp = WDT_ENABLE_bm | WDT_CEN_bm | period;
00103 CCP = CCP_IOREG_gc;
00104 WDT.CTRL = temp;
00105
00106
00107 while(WDT_IsSyncBusy()){
00108
00109 }
00110 }
00111
00112
00113
00125 void WDT_Disable( void )
00126 {
00127 uint8_t temp = (WDT.CTRL & ~WDT_ENABLE_bm) | WDT_CEN_bm;
00128 CCP = CCP_IOREG_gc;
00129 WDT.CTRL = temp;
00130 }
00131
00132
00138 bool WDT_IsWindowModeEnabled( void )
00139 {
00140 uint8_t wdwm_enabled = (WDT.WINCTRL & WDT_WEN_bm);
00141 return wdwm_enabled;
00142 }
00143
00159 bool WDT_EnableWindowMode( void )
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
00167 while(WDT_IsSyncBusy()){
00168
00169 }
00170
00171 return wd_enable;
00172 }
00173
00174
00175
00193 bool WDT_EnableWindowModeAndSetTimeout( WDT_WPER_t period )
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
00201 while(WDT_IsSyncBusy()){
00202
00203 }
00204
00205 return wd_enable;
00206 }
00207
00208
00220 void WDT_DisableWindowMode( void )
00221 {
00222 uint8_t temp = (WDT.WINCTRL & ~WDT_WEN_bm) | WDT_WCEN_bm;
00223 CCP = CCP_IOREG_gc;
00224 WDT.WINCTRL = temp;
00225 }