| Xmega Application Note | |||||
AVR XMEGA Real Time Counter driver. More...
#include <compiler.h>#include <sysclk.h>#include <sleepmgr.h>#include <rtc.h>
Go to the source code of this file.
Data Structures | |
| struct | rtc_data_struct |
| Driver private struct. More... | |
Defines | |
| #define | RTC_COMPARE_INT_LEVEL RTC_COMPINTLVL_LO_gc |
| #define | RTC_OVERFLOW_INT_LEVEL RTC_OVFINTLVL_LO_gc |
Functions | |
| ISR (RTC_COMP_vect) | |
| Compare interrupt used for alarm. | |
| ISR (RTC_OVF_vect) | |
| Overflow interrupt handling high counter. | |
| bool | rtc_alarm_has_triggered (void) |
| Check if pending alarm have triggered. | |
| uint32_t | rtc_get_time (void) |
| Get current time. | |
| void | rtc_init (void) |
| Initialize the RTC. | |
| static bool | rtc_is_busy (void) |
| Check if RTC is busy synchronizing. | |
| void | rtc_set_alarm (uint32_t time) |
| Set alarm time. | |
| void | rtc_set_callback (rtc_callback_t callback) |
| Set callback to call on alarm. | |
| void | rtc_set_time (uint32_t time) |
| Set current time. | |
Variables | |
| struct rtc_data_struct | rtc_data |
| Driver private data. | |
AVR XMEGA Real Time Counter driver.
Copyright (C) 2010 Atmel Corporation. All rights reserved.
Definition in file rtc.c.
| #define RTC_COMPARE_INT_LEVEL RTC_COMPINTLVL_LO_gc |
Definition at line 52 of file rtc.c.
Referenced by rtc_alarm_has_triggered(), and rtc_set_alarm().
| #define RTC_OVERFLOW_INT_LEVEL RTC_OVFINTLVL_LO_gc |
Definition at line 46 of file rtc.c.
Referenced by ISR(), rtc_init(), and rtc_set_alarm().
| ISR | ( | RTC_COMP_vect | ) |
Compare interrupt used for alarm.
For internal use only.
Definition at line 201 of file rtc.c.
References rtc_data_struct::alarm_high, rtc_data_struct::alarm_low, rtc_data_struct::callback, rtc_data_struct::counter_high, rtc_data, and RTC_OVERFLOW_INT_LEVEL.
00202 { 00203 if (rtc_data.counter_high >= rtc_data.alarm_high) { 00204 RTC.INTCTRL = RTC_OVERFLOW_INT_LEVEL; 00205 if (rtc_data.callback) { 00206 uint32_t count = ((uint32_t)rtc_data.counter_high << 16) 00207 | RTC.CNT; 00208 uint32_t alarm = ((uint32_t)rtc_data.alarm_high << 16) 00209 | rtc_data.alarm_low; 00210 /* Workaround for errata. Count might not be updated 00211 * when waking up from sleep, so in this case use alarm 00212 * time pluss one. 00213 */ 00214 if (alarm >= count) 00215 count = alarm + 1; 00216 rtc_data.callback(count); 00217 } 00218 } 00219 }
| ISR | ( | RTC_OVF_vect | ) |
Overflow interrupt handling high counter.
For internal use only.
Definition at line 192 of file rtc.c.
References rtc_data_struct::counter_high, and rtc_data.
00193 { 00194 rtc_data.counter_high++; 00195 }
| static bool rtc_is_busy | ( | void | ) | [static] |
Check if RTC is busy synchronizing.
For internal use only.
Definition at line 80 of file rtc.c.
Referenced by rtc_set_alarm(), and rtc_set_time().
| struct rtc_data_struct rtc_data |
Driver private data.
For internal use only.
Definition at line 74 of file rtc.c.
Referenced by ISR(), rtc_get_time(), rtc_set_alarm(), rtc_set_callback(), and rtc_set_time().
Generated on Fri Oct 22 12:15:25 2010 for AVR1300 Using the Xmega ADC by 1.6.3
|