62 static const uint8_t
ULY[] = {0U, 31U, 28U, 31U, 30U, 31U, 30U, 31U, 31U, 30U, 31U, 30U, 31U};
65 static const uint8_t
LY[] = {0U, 31U, 29U, 31U, 30U, 31U, 30U, 31U, 31U, 30U, 31U, 30U, 31U};
68 static const uint16_t
MONTH_DAYS[] = {0U, 0U, 31U, 59U, 90U, 120U, 151U, 181U, 212U, 243U, 273U, 304U, 334U};
106 RTC_Type * basePtr = g_rtcBase[instance];
230 if ((tifFlagSet ==
true) || (tofFlagSet ==
true) || (tceFlagSet ==
false))
323 uint32_t tempSeconds;
334 if (tempSeconds != seconds)
340 if (tempSeconds != seconds)
376 uint32_t seconds = 0;
545 bool yearLeap =
false;
546 uint32_t numberOfDays = 0U;
547 uint32_t tempSeconds;
573 while (numberOfDays >= daysInYear)
580 numberOfDays -= daysInYear;
606 for (i = 1U; i <= 12U; i++)
608 uint32_t daysInCurrentMonth = ((yearLeap ==
true) ? (uint32_t)
LY[i] : (uint32_t)
ULY[i]);
609 if (numberOfDays <= daysInCurrentMonth)
611 timeDate->
month = (uint16_t)i;
616 numberOfDays -= daysInCurrentMonth;
622 timeDate->
day = (uint16_t)numberOfDays;
687 bool returnCode =
true;
688 const uint8_t * pDays;
695 || (timeDate->
month < 1U) || (timeDate->
month > 12U)
696 || (timeDate->
day < 1U) || (timeDate->
day > 31U)
703 else if (timeDate->
day > pDays[timeDate->
month])
726 bool isYearLeap =
false;
728 if ((year % 4U) > 0U)
732 else if ((year % 100U) > 0U)
736 else if ((year % 400U) > 0U)
764 uint32_t tempSeconds;
776 if ((alarmConfig != NULL))
813 else if ((intConfig->
rtcCallback != NULL) && (intConfig != NULL))
921 uint32_t currentTime;
932 if(alarmTime > currentTime)
1006 uint32_t alarmInSec;
static void INT_SYS_ClearPending(IRQn_Type irqNumber)
Clear Pending Interrupt.
status_t RTC_HAL_ConfigureClockOut(RTC_Type *const base, rtc_clk_out_config_t config)
This function configures the Clock Out pin source.
rtc_interrupt_config_t * intConfig
#define RTC_SECONDS_IRQS_CH_COUNT
status_t RTC_HAL_Disable(RTC_Type *const base)
Disable RTC instance counter.
bool nonSupervisorAccessEnable
RTC Initialization structure Implements : rtc_init_config_t_Class.
bool timeInvalidIntEnable
static void RTC_HAL_SetTimeSecondsIntConf(RTC_Type *const base, rtc_second_int_cfg_t intCfg)
Configure Time Seconds interrupt.
status_t RTC_DRV_StartCounter(uint32_t instance)
Start RTC instance counter. Before calling this function the user should use RTC_DRV_SetTimeDate to c...
status_t RTC_DRV_StopCounter(uint32_t instance)
Disable RTC instance counter.
RTC interrupt configuration. It is used to configure interrupt other than Time Alarm and Time Seconds...
status_t RTC_DRV_ConfigureRegisterLock(uint32_t instance, const rtc_register_lock_config_t *const lockConfig)
This method configures register lock for the corresponding RTC instance. Remember that all the regist...
IRQn_Type
Defines the Interrupt Numbers definitions.
void RTC_DRV_GetTimeCompensation(uint32_t instance, uint8_t *compInterval, int8_t *compensation)
This retrieves the time compensation coefficients and saves them on the variables referenced by the p...
static void RTC_HAL_SetUpdateMode(RTC_Type *const base, bool updateEnable)
Set Update Mode of the registers when locked.
status_t RTC_DRV_GetCurrentTimeDate(uint32_t instance, rtc_timedate_t *const currentTime)
Get current time and date from RTC instance.
#define RTC_INSTANCE_COUNT
static bool RTC_HAL_GetTimeInvalidFlag(const RTC_Type *const base)
Get Time Invalid flag.
void RTC_DRV_GetAlarmConfig(uint32_t instance, rtc_alarm_config_t *alarmConfig)
Get alarm configuration for RTC instance.
status_t RTC_DRV_Init(uint32_t instance, const rtc_init_config_t *const rtcUserCfg)
This function initializes the RTC instance with the settings provided by the user via the rtcUserCfg ...
void RTC_DRV_ConvertSecondsToTimeDate(const uint32_t *const seconds, rtc_timedate_t *const timeDate)
Convert seconds to rtc_timedate_t structure.
static void RTC_HAL_SetTimeCompensation(RTC_Type *const base, int8_t compensationValue, uint8_t compensationInterval)
Set Time Compensation.
RTC alarm configuration Implements : rtc_alarm_config_t_Class.
void INT_SYS_DisableIRQ(IRQn_Type irqNumber)
Disables an interrupt for a given IRQ number.
static void RTC_HAL_SetTimeSecondsIntEnable(RTC_Type *const base, bool enable)
Enable TimeSeconds interrupt.
rtc_alarm_config_t * alarmConfig
static void RTC_HAL_SetTimeOverflowIntEnable(RTC_Type *const base, bool enable)
Enable TimeOverflow interrupt.
static bool RTC_DRV_CanWriteTCE(uint32_t instance)
status_t RTC_HAL_ConfigureRegisterLock(RTC_Type *const base, rtc_lock_register_select_t registerToConfig)
This function configures register lock status.
bool RTC_DRV_IsTimeDateCorrectFormat(const rtc_timedate_t *const timeDate)
Check if the date time struct is configured properly.
status_t RTC_DRV_ConfigureTimeCompensation(uint32_t instance, uint8_t compInterval, int8_t compensation)
This method configures time compensation. Data is passed by the compInterval and compensation paramet...
RTC Seconds Interrupt Configuration Implements : rtc_seconds_int_config_t_Class.
rtc_clk_out_config_t clockOutConfig
RTC Register Lock Configuration Implements : rtc_register_lock_config_t_Class.
static void RTC_HAL_GetCurrentTimeCompensation(const RTC_Type *const base, int8_t *compensationValue, uint8_t *compensationInterval)
Get TimeCompensation Value and Interval.
static RTC_Type *const g_rtcBase[RTC_INSTANCE_COUNT]
void RTC_DRV_SecondsIRQHandler(uint32_t instance)
This method is the API's Interrupt handler for RTC Second interrupt. This ISR will call the user call...
static uint32_t RTC_HAL_GetTimeSecondsRegister(const RTC_Type *const base)
Get Time Seconds Register Value.
static void RTC_HAL_SetLPOSelect(RTC_Type *const base, rtc_clk_select_t clk_select)
Select clock source for RTC prescaler.
status_t RTC_DRV_GetNextAlarmTime(uint32_t instance, rtc_timedate_t *const alarmTime)
Gets the next alarm time.
static void RTC_HAL_SetTimeAlarmRegister(RTC_Type *const base, uint32_t seconds)
Set Time Alarm Register.
static const uint8_t LY[]
void(* alarmCallback)(void *callbackParam)
status_t RTC_HAL_Enable(RTC_Type *const base)
Enable RTC instance counter.
status_t
Status return codes. Common error codes will be a unified enumeration (C enum) that will contain all ...
uint8_t compensationInterval
uint32_t repetitionInterval
static bool RTC_HAL_GetTimeAlarmFlag(const RTC_Type *const base)
Get the Time alarm flag.
void RTC_DRV_ConfigureFaultInt(uint32_t instance, rtc_interrupt_config_t *const intConfig)
This method configures fault interrupts such as:
void RTC_DRV_ConfigureSecondsInt(uint32_t instance, rtc_seconds_int_config_t *const intConfig)
This method configures the Time Seconds Interrupt with the configuration from the intConfig parameter...
static uint32_t RTC_HAL_GetTimeAlarmRegister(const RTC_Type *const base)
Get Time Alarm Register.
bool RTC_DRV_IsYearLeap(uint16_t year)
Check if the current year is leap.
rtc_second_int_cfg_t secondIntConfig
const IRQn_Type g_rtcIrqNumbers[RTC_IRQS_CH_COUNT]
Table used to store the RTC IRQ names.
void RTC_DRV_GetRegisterLock(uint32_t instance, rtc_register_lock_config_t *const lockConfig)
Get which registers are locked for RTC instance.
void(* rtcSecondsCallback)(void *callbackParam)
bool RTC_DRV_IsAlarmPending(uint32_t instance)
Check if alarm is pending.
void RTC_DRV_IRQHandler(uint32_t instance)
This method is the API's Interrupt handler for generic and alarm IRQ. It will handle the alarm repeti...
void * secondsCallbackParams
RTC Time Date structure Implements : rtc_timedate_t_Class.
rtc_clk_select_t clockSelect
bool RTC_HAL_IsRegisterLocked(const RTC_Type *const base, rtc_lock_register_select_t reg)
This function gets register lock status.
static const uint8_t ULY[]
static void RTC_HAL_SetNonSupervisorAccess(RTC_Type *const base, bool enable)
Set Non-Supervisor access mode.
status_t RTC_HAL_SetTimeSecondsRegister(RTC_Type *const base, uint32_t seconds)
Set Time Seconds Register.
static void RTC_HAL_ClearSoftwareReset(RTC_Type *const base)
Clear Software reset flag.
static bool RTC_HAL_GetTimeCounterEnable(const RTC_Type *const base)
Get the Time Counter Enable value.
void INT_SYS_EnableIRQ(IRQn_Type irqNumber)
Enables an interrupt for a given IRQ number.
status_t RTC_DRV_Deinit(uint32_t instance)
This function deinitializes the RTC instance. If the Control register is locked then this method retu...
status_t RTC_DRV_ConfigureAlarm(uint32_t instance, rtc_alarm_config_t *const alarmConfig)
This method configures the alarm with the configuration from the alarmConfig parameter.
static bool RTC_HAL_GetUpdateMode(const RTC_Type *const base)
Get the Update Mode of the registers when locked.
static void RTC_HAL_SetTimeInvalidIntEnable(RTC_Type *const base, bool enable)
Enable TimeInvalid interrupt.
#define SECONDS_IN_A_HOUR
void(* rtcCallback)(void *callbackParam)
const IRQn_Type g_rtcSecondsIrqNb[RTC_SECONDS_IRQS_CH_COUNT]
bool timeCompensationRegisterLock
static const uint16_t MONTH_DAYS[]
status_t RTC_HAL_Init(RTC_Type *const base)
Initialize RTC instance.
static bool RTC_HAL_GetTimeOverflowFlag(const RTC_Type *const base)
Get Time Overflow Flag.
static struct @19 g_rtcRuntimeConfig[RTC_INSTANCE_COUNT]
static RTC runtime structure, it is designed only for internal purposes such as storing interrupt con...
status_t RTC_DRV_SetTimeDate(uint32_t instance, const rtc_timedate_t *const time)
Set time and date for RTC instance. The user must stop the counter before using this function...
void RTC_DRV_ConvertTimeDateToSeconds(const rtc_timedate_t *const timeDate, uint32_t *const seconds)
Convert seconds to rtc_timedate_t structure.
static void RTC_HAL_SetSoftwareReset(RTC_Type *const base)
Trigger a software reset.
#define RTC_IRQS_CH_COUNT
static void RTC_HAL_SetTimeAlarmIntEnable(RTC_Type *const base, bool enable)
Enable TimeAlarm interrupt.
#define DAYS_IN_A_LEAP_YEAR
rtc_seconds_int_config_t * secondsIntConfig