You cannot just add in that function call to enable repeat alarm operation (or at least I do not think you can).
I took the existing rtc demo from the following path in KSDK_1.3:
I modified it to set up RTC for repeat alarm that will repeat once a minute (currently the repeat alarm configured for resolution of 1 minute or longer time).
The source code is attached (main.c) and all you have to do is change a #define to use default code or use repeat alarm mode:
|#define REPEAT_ALARM_TEST 1||//DES 1=repeat alarm test, 0=default code|
The code you gave addresses how to set up either a repeat alarm or single case alarm. That I do understand.
I want to adjust the alarm in the case I adjust the time due to settings or clock drift.
If I have an alarm going off every 15 minutes, and I find out my time is off forward, I don't want to wait a longer than my repeat alarm time of 15 minutes. Setting the RTC backwards causes a previously set alarm to actually take longer.
The Repeat alarm and alarm interrupt share an isr function called RTC_DRV_AlarmIntAction, which has a flaw* itself.
Since I have a repeat alarm, it calculates the new alarm time regardless of whether the alarm is a repeat alarm or the new alarm I set. I don't think there are two registers that hold alarm values, then RTC_DRV_SetAlarm should override the old alarm.
*RTC_DRV_AlarmIntAction had a problem with rollovers of time. Once the time passed the max of each category, it would check if the time was valid in RTC_DRV_SetAlarm. In my case if the time went passed 15 minutes, it would never alarm again. I added two lines to convert back and forth to fix it.
void RTC_DRV_AlarmIntAction(uint32_t instance)
RTC_Type *rtcBase = g_rtcBase[instance];
if (s_rtcRepeatAlarmState != NULL)
s_rtcRepeatAlarmState->alarmTime.year += s_rtcRepeatAlarmState->alarmRepTime.year;
s_rtcRepeatAlarmState->alarmTime.month += s_rtcRepeatAlarmState->alarmRepTime.month;
s_rtcRepeatAlarmState->alarmTime.day += s_rtcRepeatAlarmState->alarmRepTime.day;
s_rtcRepeatAlarmState->alarmTime.hour += s_rtcRepeatAlarmState->alarmRepTime.hour;
s_rtcRepeatAlarmState->alarmTime.minute += s_rtcRepeatAlarmState->alarmRepTime.minute;
RTC_HAL_ConvertDatetimeToSecs(&s_rtcRepeatAlarmState->alarmTime,&seconds); /*Edit - JRP */
RTC_HAL_ConvertSecsToDatetime(&seconds, &s_rtcRepeatAlarmState->alarmTime); /*Edit - JRP */
RTC_DRV_SetAlarm(instance, &s_rtcRepeatAlarmState->alarmTime, true);
/* Writing to the alarm register clears the TAF flag in the Status register */