AllJoyn/Samples/BACnetAdapter/bacnet-stack-0.8.2/ports/xplained/ASF/xmega/drivers/rtc32/rtc32.c
void rtc_init(void)
{
    sysclk_enable_module(SYSCLK_PORT_GEN, SYSCLK_RTC);
    // Set up VBAT system and start oscillator
    vbat_init();

    // Disable the RTC32 module before setting it up
    RTC32.CTRL = 0;

    while (rtc_is_busy());

    // Set up maximum period and start at 0
    RTC32.PER = 0xffffffff;
    RTC32.CNT = 0;

    while (rtc_is_busy());

    RTC32.INTCTRL = 0;
    RTC32.CTRL = RTC32_ENABLE_bm;

    // Make sure it's sync'ed before return
    while (rtc_is_busy());
}
/**
 * \brief Initialize the 32kHz oscillator and RTC32
 *
 * Starts up the 32kHz oscillator in the backup system and initializes the
 * RTC32.
 *
 * \note When the backup system is used, the function \ref
 * rtc_vbat_system_check should be called to determine if a re-initialization
 * must be done.
 */
\brief Initialize the 32kHz oscillator and RTC32
Starts up the 32kHz oscillator in the backup system and initializes the
RTC32.

\note When the backup system is used, the function \ref
rtc_vbat_system_check should be called to determine if a re-initialization
must be done.
\ brief Initialize the 32kHz oscillator and RTC32 Starts up the 32kHz oscillator in the backup system and initializes the RTC32 . \ note When the backup system is used the function \ ref rtc_vbat_system_check should be called to determine if a re - initialization must be done .
void rtc_init(void)
{
    sysclk_enable_module(SYSCLK_PORT_GEN, SYSCLK_RTC);
    vbat_init();
    RTC32.CTRL = 0;
    while (rtc_is_busy());
    RTC32.PER = 0xffffffff;
    RTC32.CNT = 0;
    while (rtc_is_busy());
    RTC32.INTCTRL = 0;
    RTC32.CTRL = RTC32_ENABLE_bm;
    while (rtc_is_busy());
}
void rtc_init ( void ) { sysclk_enable_module ( SYSCLK_PORT_GEN , SYSCLK_RTC ) ; vbat_init ( ) ; RTC32 . CTRL = 0 ; while ( rtc_is_busy ( ) ) ; RTC32 . PER = 0xffffffff ; RTC32 . CNT = 0 ; while ( rtc_is_busy ( ) ) ; RTC32 . INTCTRL = 0 ; RTC32 . CTRL = RTC32_ENABLE_bm ; while ( rtc_is_busy ( ) ) ; }
\brief Initialize the 32kHz oscillator and RTC32
 Starts up the 32kHz oscillator in the backup system and initializes the
 RTC32.
\ brief Initialize the 32kHz oscillator and RTC32 Starts up the 32kHz oscillator in the backup system and initializes the RTC32 .
// Set up VBAT system and start oscillator // Disable the RTC32 module before setting it up // Set up maximum period and start at 0 // Make sure it's sync'ed before return