AVR1631 - Energy Meter Reference Design with ATxmega32A4  Rev 1.0
 All Data Structures Files Functions Variables Typedefs Macros
rtc_driver.c
Go to the documentation of this file.
1 /* This file has been prepared for Doxygen automatic documentation generation.*/
60 #include "rtc_driver.h"
61 
62 
75 void RTC_Initialize( uint16_t period,
76  uint16_t count,
77  uint16_t compareValue,
78  RTC_PRESCALER_t prescaler )
79 {
80  RTC.PER = period - 1;
81  RTC.CNT = count;
82  RTC.COMP = compareValue;
83  RTC.CTRL = ( RTC.CTRL & ~RTC_PRESCALER_gm ) | prescaler;
84 }
85 
86 
91 //void RTC_SetOverflowIntLevel( RTC_OVFINTLVL_t intLevel )
92 //{
93  //RTC.INTCTRL = ( RTC.INTCTRL & ~RTC_OVFINTLVL_gm ) | intLevel;
94 //}
95 //
96 
101 //void RTC_SetCompareIntLevel( RTC_COMPINTLVL_t intLevel )
102 //{
103  //RTC.INTCTRL = ( RTC.INTCTRL & ~RTC_COMPINTLVL_gm ) | intLevel;
104 //}
105 //
106 
113 void RTC_SetIntLevels( RTC_OVFINTLVL_t ovfIntLevel,
114  RTC_COMPINTLVL_t compIntLevel )
115 {
116  RTC.INTCTRL = ( RTC.INTCTRL &
117  ~( RTC_COMPINTLVL_gm | RTC_OVFINTLVL_gm ) ) |
118  ovfIntLevel |
119  compIntLevel;
120 }
121 
122 
138 //void RTC_SetAlarm( uint16_t alarmTimeout )
139 //{
141  //uint16_t compareValue = RTC.CNT + alarmTimeout;
142 //
144  //if (compareValue > RTC.PER){
145  //compareValue -= RTC.PER;
146  //}
147 //
149  //RTC.COMP = compareValue;
150 //}
151 //
152 //
160 //void RTC_SetPrescaler( RTC_PRESCALER_t prescaler )
161 //{
162  //RTC.CTRL = ( RTC.CTRL & ~RTC_PRESCALER_gm ) | prescaler;
163 //}
164 //