/* return kStatus_Success: success in setting the RTC alarm kStatus_InvalidArgument: Error because the alarm datetime format is incorrect kStatus_Fail: Error because the alarm time has already passed  */
status_t RTC_SetAlarm(RTC_Type *base, const rtc_datetime_t *alarmTime)
/* return kStatus_Success: success in setting the RTC alarm kStatus_InvalidArgument: Error because the alarm datetime format is incorrect kStatus_Fail: Error because the alarm time has already passed  */
status_t RTC_SetAlarm(RTC_Type *base, const rtc_datetime_t *alarmTime)
{
    assert(alarmTime != NULL);
    uint32_t alarmSeconds = 0;
    uint32_t currSeconds  = 0;
    if (!(RTC_CheckDatetimeFormat(alarmTime)))
    {
        return kStatus_InvalidArgument;
    }
    alarmSeconds = RTC_ConvertDatetimeToSeconds(alarmTime);
    currSeconds = RTC_GetSecondsTimerCount(base);
    if (alarmSeconds < currSeconds)
    {
        return kStatus_Fail;
    }
    base->MATCH = alarmSeconds;
    return kStatus_Success;
}