15.9.1.2.1 Initialization Code
Create an rtc_module struct and add to the main application source file, outside of any functions:
Copy-paste the following setup code to your application:struct
rtc_module rtc_instance;
void
configure_rtc_calendar(
void
)
{
/* Initialize RTC in calendar mode. */
struct
rtc_calendar_config config_rtc_calendar;
rtc_calendar_get_config_defaults(&config_rtc_calendar);
struct
rtc_calendar_time alarm;
rtc_calendar_get_time_defaults(&alarm);
alarm.year = 2013;
alarm.month = 1;
alarm.day = 1;
alarm.hour = 0;
alarm.minute = 0;
alarm.second = 4;
config_rtc_calendar.clock_24h =
true
;
config_rtc_calendar.alarm[0].time = alarm;
config_rtc_calendar.alarm[0].mask = RTC_CALENDAR_ALARM_MASK_YEAR;
rtc_calendar_init(&rtc_instance, RTC, &config_rtc_calendar);
rtc_calendar_enable(&rtc_instance);
}