/* return kStatus_Success: success in setting the SNVS RTC alarm kStatus_InvalidArgument: Error because the alarm datetime format is incorrect kStatus_Fail: Error because the alarm time has already passed  */
status_t SNVS_HP_RTC_SetAlarm(SNVS_Type *base, const snvs_hp_rtc_datetime_t *alarmTime)
/* return kStatus_Success: success in setting the SNVS RTC alarm kStatus_InvalidArgument: Error because the alarm datetime format is incorrect kStatus_Fail: Error because the alarm time has already passed  */
status_t SNVS_HP_RTC_SetAlarm(SNVS_Type *base, const snvs_hp_rtc_datetime_t *alarmTime)
{
    assert(alarmTime);
    uint32_t alarmSeconds = 0U;
    uint32_t currSeconds  = 0U;
    uint32_t tmp          = base->HPCR;
    if (!(SNVS_HP_CheckDatetimeFormat(alarmTime)))
    {
        return kStatus_InvalidArgument;
    }
    alarmSeconds = SNVS_HP_ConvertDatetimeToSeconds(alarmTime);
    currSeconds  = SNVS_HP_RTC_GetSeconds(base);
    if (alarmSeconds < currSeconds)
    {
        return kStatus_Fail;
    }
    base->HPCR &= ~SNVS_HPCR_HPTA_EN_MASK;
    while (base->HPCR & SNVS_HPCR_HPTA_EN_MASK)
    {
    }
    base->HPTAMR = (uint32_t)(alarmSeconds >> 17U);
    base->HPTALR = (uint32_t)(alarmSeconds << 15U);
    base->HPCR = tmp;
    return kStatus_Success;
}