XMEGA Application Note


rtc_driver.c

Go to the documentation of this file.
00001 /* This file has been prepared for Doxygen automatic documentation generation.*/
00059 #include "rtc_driver.h"
00060 
00061 
00074 void RTC_Initialize( uint16_t period,
00075                      uint16_t count,
00076                      uint16_t compareValue,
00077                      RTC_PRESCALER_t prescaler )
00078 {
00079         RTC.PER = period - 1;
00080         RTC.CNT = count;
00081         RTC.COMP = compareValue;
00082         RTC.CTRL = ( RTC.CTRL & ~RTC_PRESCALER_gm ) | prescaler;
00083 }
00084 
00085 
00090 void RTC_SetOverflowIntLevel( RTC_OVFINTLVL_t intLevel )
00091 {
00092         RTC.INTCTRL = ( RTC.INTCTRL & ~RTC_OVFINTLVL_gm ) | intLevel;
00093 }
00094 
00095 
00100 void RTC_SetCompareIntLevel( RTC_COMPINTLVL_t intLevel )
00101 {
00102         RTC.INTCTRL = ( RTC.INTCTRL & ~RTC_COMPINTLVL_gm ) | intLevel;
00103 }
00104 
00105 
00112 void RTC_SetIntLevels( RTC_OVFINTLVL_t ovfIntLevel,
00113                        RTC_COMPINTLVL_t compIntLevel )
00114 {
00115         RTC.INTCTRL = ( RTC.INTCTRL &
00116                       ~( RTC_COMPINTLVL_gm | RTC_OVFINTLVL_gm ) ) |
00117                       ovfIntLevel |
00118                       compIntLevel;
00119 }
00120 
00121 
00137 void RTC_SetAlarm( uint16_t alarmTimeout )
00138 {
00139         /* Calculate compare time. */
00140         uint16_t compareValue = RTC.CNT + alarmTimeout;
00141 
00142         /* Wrap on period. */
00143         if (compareValue > RTC.PER){
00144                 compareValue -= RTC.PER;
00145         }
00146 
00147         /* Add the timeout value to get the absolute time of the alarm. */
00148         RTC.COMP = compareValue;
00149 }
00150 
00151 
00159 void RTC_SetPrescaler( RTC_PRESCALER_t prescaler )
00160 {
00161         RTC.CTRL = ( RTC.CTRL & ~RTC_PRESCALER_gm ) | prescaler;
00162 }
@DOC_TITLE@
Generated on Mon Nov 9 13:44:26 2009 for XMEGA power consumption evaluation code by doxygen 1.5.9