| Xmega IEC60730 Class B Library 1.0 |

All Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Functions
Real Time Counter Driver

## Detailed Description

This is a basic driver for the Real Time Counter (RTC).

The RTC is used to generate interrupts periodically for both the CPU frequency and the interrupt self-diagnostic routines. Depending on the specific device, an RTC or an RTC32 will be used. In both cases the RTC is clocked independently from the CPU with a 32.768 kHz oscillator scaled down to 1024 Hz.

The interrupt period can be configured in the driver through CLASSB_RTC_INT_PERIOD. Further, the RTC module is setup with classb_rtc_setup(). Note that interrupts should be enabled in the main application with `sei()`.

Note that it is possible to use a different RTC driver. The only requirement is that it defines the constants for the interrupt period CLASSB_RTC_INT_PERIOD and the RTC frequency CLASSB_RTC_FREQ.

## Functions
| ISR (RTC_TEST_COMP_vect)
| This is the RTC compare interrupt.

## RTC Settings and Class B Interface.
Settings and RTC information. These two constants give information about the RTC to the Class B tests. Therefore, they need to be defined with correct values. As long as these are defined, any RTC driver can be used.
#define | CLASSB_RTC_INT_PERIOD 2048UL
| RTC interrupt period.
#define | CLASSB_RTC_FREQ 1024UL
| RTC frequency.

## Test declarations.
Set which Class B tests are included in the RTC interrupt. These symbols can be defined at the compiler level or in this file.
#define | CLASSB_FREQ_TEST
| Test for the CPU frequency.
#define | CLASSB_INT_MON
| Interrupt monitor.

## Functions
void | vbat_init (void)
bool | rtc_is_busy (void)
void | classb_rtc_setup ()
| This function sets up the RTC to be used in Class B tests.

## Macro Definition Documentation

#define CLASSB_RTC_INT_PERIOD 2048UL

RTC interrupt period.

This constant is used to configure the period of the RTC compare interrupt. In addition, it is used in the Class B tests. An example value is `2048UL`.

Note:
  This is a 16- or 32-bit value depending on the RTC hardware module.

Definition at line 95 of file classb_rtc_common.h.

Referenced by classb_rtc_setup().

#define CLASSB_RTC_FREQ 1024UL

RTC frequency.

This gives information to the Class B tests. However, the RTC frequency is hard coded in this driver to 1024 Hz. More details in classb_rtc_setup().

Definition at line 103 of file classb_rtc_common.h.

## Function Documentation

void classb_rtc_setup | ( |  | ) |

This function sets up the RTC to be used in Class B tests.

The RTC oscillator is enabled, compare interrupts are configured and RTC is enabled.

Definition at line 100 of file classb_rtc_common.c.

References CLASSB_RTC_INT_PERIOD.

ISR | ( | RTC_TEST_COMP_vect |  | ) |

This is the RTC compare interrupt.

Actions required in Class B tests are implemented as callbacks. Note that this requires a number of symbols to be defined, either in a header file or at the compiler level.

It is possible to add user-defined code to the RTC interrupt through CLASSB_ACTIONS_RTC().

Definition at line 133 of file classb_rtc_common.c.

References CLASSB_ACTIONS_RTC, classb_freq_callback(), and classb_intmon_callback().

Here is the call graph for this function: