/* return kStatus_Success: success in setting the SNVS SRTC alarm kStatus_InvalidArgument: Error because the alarm datetime format is incorrect kStatus_Fail: Error because the alarm time has already passed or is beyond resolution  */
status_t SNVS_LP_SRTC_SetAlarm(SNVS_Type *base, const snvs_lp_srtc_datetime_t *alarmTime)
/* return kStatus_Success: success in setting the SNVS SRTC alarm kStatus_InvalidArgument: Error because the alarm datetime format is incorrect kStatus_Fail: Error because the alarm time has already passed or is beyond resolution  */
status_t SNVS_LP_SRTC_SetAlarm(SNVS_Type *base, const snvs_lp_srtc_datetime_t *alarmTime)
{
    assert(alarmTime != NULL);
    uint32_t alarmSeconds = 0U;
    uint32_t currSeconds  = 0U;
    uint32_t tmp          = base->LPCR;
    if (!(SNVS_LP_CheckDatetimeFormat(alarmTime)))
    {
        return kStatus_InvalidArgument;
    }
    alarmSeconds = SNVS_LP_ConvertDatetimeToSeconds(alarmTime);
    currSeconds  = SNVS_LP_SRTC_GetSeconds(base);
    if (alarmSeconds <= currSeconds)
    {
        return kStatus_Fail;
    }
    base->LPCR &= ~SNVS_LPCR_LPTA_EN_MASK;
    while ((base->LPCR & SNVS_LPCR_LPTA_EN_MASK) != 0U)
    {
    }
    base->LPTAR = alarmSeconds;
    base->LPCR = tmp;
    return kStatus_Success;
}