Driver for the RTC (32-bit Real Time Counter).
The RTC enables periodic interrupts at long intervals, or accurate measurement of real-time sequences. Can be clocked from internal RC oscillator or external 32 kHz crystal.
Modules | |
Related Project(s) | |
In this section you can find all the projects related to the RTC - Real Time Counter. | |
Functions | |
void | rtc_clear_interrupt (volatile avr32_rtc_t *rtc) |
Clear the interrupt flag. Call this function once you handled the interrupt. More... | |
void | rtc_disable (volatile avr32_rtc_t *rtc) |
Disable the RTC. More... | |
void | rtc_disable_interrupt (volatile avr32_rtc_t *rtc) |
Disable the interrupt feature of the RTC. More... | |
void | rtc_disable_wake_up (volatile avr32_rtc_t *rtc) |
Disable the wake up feature of the RTC. More... | |
void | rtc_enable (volatile avr32_rtc_t *rtc) |
Enable the RTC. More... | |
void | rtc_enable_interrupt (volatile avr32_rtc_t *rtc) |
Enable the interrupt feature of the RTC. An interrupt is raised when the value of the RTC is equal to its top value. More... | |
void | rtc_enable_wake_up (volatile avr32_rtc_t *rtc) |
Enable the wake up feature of the RTC. More... | |
unsigned long | rtc_get_top_value (volatile avr32_rtc_t *rtc) |
This function returns the RTC current top value. More... | |
unsigned long | rtc_get_value (volatile avr32_rtc_t *rtc) |
This function returns the RTC current value. More... | |
int | rtc_init (volatile avr32_rtc_t *rtc, unsigned char osc_type, unsigned char psel) |
This function will initialize the RTC module. If you use the 32 KHz oscillator, it will enable this module. This function also set the top value of the RTC to 0xFFFFFFFF and the value to 0. More... | |
int | rtc_interrupt_enabled (volatile avr32_rtc_t *rtc) |
Get the status of interrupts. More... | |
int | rtc_is_busy (volatile avr32_rtc_t *rtc) |
This function checks if the RTC is busy or not. More... | |
int | rtc_is_interrupt (volatile avr32_rtc_t *rtc) |
Check if an interrupt is raised. More... | |
void | rtc_set_top_value (volatile avr32_rtc_t *rtc, unsigned long top) |
This function sets the RTC current top value. More... | |
void | rtc_set_value (volatile avr32_rtc_t *rtc, unsigned long val) |
This function sets the RTC current value. More... | |
Oscillator Types | |
#define | RTC_OSC_32KHZ 1 |
#define | RTC_OSC_RC 0 |
Predefined PSEL Values | |
#define | RTC_PSEL_32KHZ_1HZ 14 |
The PSEL value to set the RTC source clock (after the prescaler) to 1 Hz, when using an external 32-kHz crystal. More... | |
#define | RTC_PSEL_RC_1_76HZ 15 |
The PSEL value to set the RTC source clock (after the prescaler) to 1.76 Hz, when using the internal RC oscillator (~ 115 kHz). More... | |
#define RTC_OSC_32KHZ 1 |
Referenced by main(), and rtc_init().
#define RTC_OSC_RC 0 |
Referenced by timer_init().
#define RTC_PSEL_32KHZ_1HZ 14 |
The PSEL value to set the RTC source clock (after the prescaler) to 1 Hz, when using an external 32-kHz crystal.
Referenced by main().
#define RTC_PSEL_RC_1_76HZ 15 |
The PSEL value to set the RTC source clock (after the prescaler) to 1.76 Hz, when using the internal RC oscillator (~ 115 kHz).
void rtc_clear_interrupt | ( | volatile avr32_rtc_t * | rtc | ) |
Clear the interrupt flag. Call this function once you handled the interrupt.
rtc | Base address of the RTC (i.e. &AVR32_RTC). |
References cpu_irq_disable, cpu_irq_enable, and cpu_irq_is_enabled.
void rtc_disable | ( | volatile avr32_rtc_t * | rtc | ) |
Disable the RTC.
rtc | Base address of the RTC (i.e. &AVR32_RTC). |
References rtc_is_busy().
Referenced by main().
void rtc_disable_interrupt | ( | volatile avr32_rtc_t * | rtc | ) |
Disable the interrupt feature of the RTC.
rtc | Base address of the RTC (i.e. &AVR32_RTC). |
References cpu_irq_disable, cpu_irq_enable, and cpu_irq_is_enabled.
void rtc_disable_wake_up | ( | volatile avr32_rtc_t * | rtc | ) |
Disable the wake up feature of the RTC.
rtc | Base address of the RTC (i.e. &AVR32_RTC). |
References rtc_is_busy().
void rtc_enable | ( | volatile avr32_rtc_t * | rtc | ) |
Enable the RTC.
rtc | Base address of the RTC (i.e. &AVR32_RTC). |
References rtc_is_busy().
Referenced by main(), and timer_init().
void rtc_enable_interrupt | ( | volatile avr32_rtc_t * | rtc | ) |
Enable the interrupt feature of the RTC. An interrupt is raised when the value of the RTC is equal to its top value.
rtc | Base address of the RTC (i.e. &AVR32_RTC). |
Referenced by main(), and timer_init().
void rtc_enable_wake_up | ( | volatile avr32_rtc_t * | rtc | ) |
Enable the wake up feature of the RTC.
rtc | Base address of the RTC (i.e. &AVR32_RTC). |
References rtc_is_busy().
unsigned long rtc_get_top_value | ( | volatile avr32_rtc_t * | rtc | ) |
This function returns the RTC current top value.
rtc | Base address of the RTC (i.e. &AVR32_RTC). |
unsigned long rtc_get_value | ( | volatile avr32_rtc_t * | rtc | ) |
This function returns the RTC current value.
rtc | Base address of the RTC (i.e. &AVR32_RTC). |
int rtc_init | ( | volatile avr32_rtc_t * | rtc, |
unsigned char | osc_type, | ||
unsigned char | psel | ||
) |
This function will initialize the RTC module. If you use the 32 KHz oscillator, it will enable this module. This function also set the top value of the RTC to 0xFFFFFFFF and the value to 0.
rtc | Base address of the RTC (i.e. &AVR32_RTC). |
osc_type | The oscillator you want to use. If you need a better accuracy, use the 32 KHz oscillator (i.e. RTC_OSC_32KHZ). |
psel | The preselector value for the corresponding oscillator (4-bits). To obtain this value, you can use this formula: psel = log(Fosc/Frtc)/log(2)-1, where Fosc is the frequency of the oscillator you are using (32 KHz or 115 KHz) and Frtc the frequency desired. |
References pm_enable_clk32(), pm_enable_osc32_crystal(), rtc_is_busy(), RTC_OSC_32KHZ, rtc_set_top_value(), and rtc_set_value().
Referenced by main(), and timer_init().
int rtc_interrupt_enabled | ( | volatile avr32_rtc_t * | rtc | ) |
Get the status of interrupts.
rtc | Base address of the RTC (i.e. &AVR32_RTC). |
int rtc_is_busy | ( | volatile avr32_rtc_t * | rtc | ) |
This function checks if the RTC is busy or not.
rtc | Base address of the RTC (i.e. &AVR32_RTC). |
Referenced by rtc_disable(), rtc_disable_wake_up(), rtc_enable(), rtc_enable_wake_up(), rtc_init(), rtc_set_top_value(), and rtc_set_value().
int rtc_is_interrupt | ( | volatile avr32_rtc_t * | rtc | ) |
Check if an interrupt is raised.
rtc | Base address of the RTC (i.e. &AVR32_RTC). |
void rtc_set_top_value | ( | volatile avr32_rtc_t * | rtc, |
unsigned long | top | ||
) |
This function sets the RTC current top value.
rtc | Base address of the RTC (i.e. &AVR32_RTC). |
top | The top value you want to store. |
References rtc_is_busy().
Referenced by main(), rtc_init(), and timer_init().
void rtc_set_value | ( | volatile avr32_rtc_t * | rtc, |
unsigned long | val | ||
) |
This function sets the RTC current value.
rtc | Base address of the RTC (i.e. &AVR32_RTC). |
val | The value you want to store. |
References rtc_is_busy(), and val.
Referenced by rtc_init().