Functions | |
__STATIC_INLINE uint32_t | Cy_RTC_ConvertDayOfWeek (uint32_t day, uint32_t month, uint32_t year) |
Returns a day of the week for a year, month, and day of month that are passed through parameters. More... | |
__STATIC_INLINE bool | Cy_RTC_IsLeapYear (uint32_t year) |
Checks whether the year passed through the parameter is leap or not. More... | |
__STATIC_INLINE uint32_t | Cy_RTC_DaysInMonth (uint32_t month, uint32_t year) |
Returns a number of days in a month passed through the parameters. More... | |
__STATIC_INLINE void | Cy_RTC_SyncFromRtc (void) |
The Synchronizer updates RTC values into AHB RTC user registers from the actual RTC. More... | |
__STATIC_INLINE cy_en_rtc_status_t | Cy_RTC_WriteEnable (cy_en_rtc_write_status_t writeEnable) |
Set/Clear writeable option for RTC user registers. More... | |
__STATIC_INLINE uint32_t | Cy_RTC_GetSyncStatus (void) |
Return current status of CY_RTC_BUSY. More... | |
__STATIC_INLINE cy_en_rtc_hours_format_t | Cy_RTC_GetHoursFormat (void) |
Returns current 12/24 hours format. More... | |
__STATIC_INLINE bool | Cy_RTC_IsExternalResetOccurred (void) |
The function checks the reset cause and returns the Boolean result. More... | |
__STATIC_INLINE void | Cy_RTC_SyncToRtcAhbDateAndTime (uint32_t timeBcd, uint32_t dateBcd) |
This function updates new time and date into the time and date RTC AHB registers. More... | |
__STATIC_INLINE void | Cy_RTC_SyncToRtcAhbAlarm (uint32_t alarmTimeBcd, uint32_t alarmDateBcd, cy_en_rtc_alarm_t alarmIndex) |
This function updates new alarm time and date into the alarm tire and date RTC AHB registers. More... | |
__STATIC_INLINE uint32_t Cy_RTC_ConvertDayOfWeek | ( | uint32_t | day, |
uint32_t | month, | ||
uint32_t | year | ||
) |
Returns a day of the week for a year, month, and day of month that are passed through parameters.
Zeller's congruence is used to calculate the day of the week. RTC HW block does not provide the converting function for day of week. This function should be called before Cy_RTC_SetDateAndTime() to get the day of week.
For the Georgian calendar, Zeller's congruence is: h = (q + [13 * (m + 1)] + K + [K/4] + [J/4] - 2J) mod 7
h - The day of the week (0 = Saturday, 1 = Sunday, 2 = Monday, ., 6 = Friday). q - The day of the month. m - The month (3 = March, 4 = April, 5 = May, ..., 14 = February) K - The year of the century (year mod 100). J - The zero-based century (actually [year/100]) For example, the zero-based centuries for 1995 and 2000 are 19 and 20 respectively (not to be confused with the common ordinal century enumeration which indicates 20th for both cases).
day | The day of the month, Valid range 1..31. |
month | The month of the year, see Month definitions. |
year | The year value. Valid range non-zero value. |
__STATIC_INLINE bool Cy_RTC_IsLeapYear | ( | uint32_t | year | ) |
Checks whether the year passed through the parameter is leap or not.
This API is for checking an invalid value input for leap year. RTC HW block does not provide a validation checker against time/date values, the valid range of days in Month should be checked before SetDateAndTime() function call. Leap year is identified as a year that is a multiple of 4 or 400 but not 100.
year | The year to be checked. Valid range non-zero value. |
__STATIC_INLINE uint32_t Cy_RTC_DaysInMonth | ( | uint32_t | month, |
uint32_t | year | ||
) |
Returns a number of days in a month passed through the parameters.
This API is for checking an invalid value input for days. RTC HW block does not provide a validation checker against time/date values, the valid range of days in Month should be checked before SetDateAndTime() function call.
month | The month of the year, see Month definitions. |
year | A year value. Valid range non-zero value. |
__STATIC_INLINE void Cy_RTC_SyncFromRtc | ( | void | ) |
The Synchronizer updates RTC values into AHB RTC user registers from the actual RTC.
By calling this function, the actual RTC register values is copied to AHB user registers.
__STATIC_INLINE cy_en_rtc_status_t Cy_RTC_WriteEnable | ( | cy_en_rtc_write_status_t | writeEnable | ) |
Set/Clear writeable option for RTC user registers.
When the Write bit is set, data can be written into the RTC user registers. After all the RTC writes are done, the firmware must clear (call Cy_RTC_WriteEnable(RTC_WRITE_DISABLED)) the Write bit for the RTC update to take effect.
Set/Clear cannot be done if the RTC is still busy with a previous update (CY_RTC_BUSY = 1) or RTC Reading is executing.
writeEnable | Write status, see cy_en_rtc_write_status_t. |
__STATIC_INLINE uint32_t Cy_RTC_GetSyncStatus | ( | void | ) |
Return current status of CY_RTC_BUSY.
The status indicates synchronization between the RTC user register and the actual RTC register. CY_RTC_BUSY bit is set if it is synchronizing. It is not possible to set the Read or Write bit until CY_RTC_BUSY clears.
__STATIC_INLINE cy_en_rtc_hours_format_t Cy_RTC_GetHoursFormat | ( | void | ) |
Returns current 12/24 hours format.
__STATIC_INLINE bool Cy_RTC_IsExternalResetOccurred | ( | void | ) |
The function checks the reset cause and returns the Boolean result.
__STATIC_INLINE void Cy_RTC_SyncToRtcAhbDateAndTime | ( | uint32_t | timeBcd, |
uint32_t | dateBcd | ||
) |
This function updates new time and date into the time and date RTC AHB registers.
timeBcd | The BCD-formatted time variable which has the same bit masks as the RTC_TIME register: |
[0:6] - Calendar seconds in BCD, the range 0-59.
[14:8] - Calendar minutes in BCD, the range 0-59.
[21:16] - Calendar hours in BCD, value depends on the 12/24-hour mode.
12HR: [21]:0 = AM, 1 = PM, [20:16] = 1 - 12;
24HR: [21:16] = 0-23.
[22] - Selects the 12/24-hour mode: 1 - 12-hour, 0 - 24-hour.
[26:24] - A calendar day of the week, the range 1 - 7, where 1 - Sunday.
dateBcd | The BCD-formatted time variable which has the same bit masks as the RTC_DATE register: |
[5:0] - A calendar day of a month in BCD, the range 1-31.
[12:8] - A calendar month in BCD, the range 1-12.
[23:16] - A calendar year in BCD, the range 0-99.
The RTC AHB registers can be updated only under condition that the Write bit is set and the RTC busy bit is cleared (RTC_BUSY = 0). Call the Cy_RTC_WriteEnable(CY_RTC_WRITE_ENABLED) and ensure that Cy_RTC_WriteEnable() returned CY_RTC_SUCCESS. Then you can call Cy_RTC_SyncToRtcAhbDateAndTime(). Do not forget to clear the RTC Write bit to finish an RTC register update by calling Cy_RTC_WriteEnable(CY_RTC_WRITE_DISABLED) after you executed Cy_RTC_SyncToRtcAhbDateAndTime(). Ensure that Cy_RTC_WriteEnable() returned CY_RTC_SUCCESS.
__STATIC_INLINE void Cy_RTC_SyncToRtcAhbAlarm | ( | uint32_t | alarmTimeBcd, |
uint32_t | alarmDateBcd, | ||
cy_en_rtc_alarm_t | alarmIndex | ||
) |
This function updates new alarm time and date into the alarm tire and date RTC AHB registers.
alarmTimeBcd | The BCD-formatted time variable which has the same bit masks as the ALMx_TIME register time fields: |
[0:6] - Alarm seconds in BCD, the range 0-59.
[7] - Alarm seconds Enable: 0 - ignore, 1 - match.
[14:8] - Alarm minutes in BCD, the range 0-59.
[15] - Alarm minutes Enable: 0 - ignore, 1 - match.
[21:16] - Alarm hours in BCD, value depending on the 12/24-hour mode (RTC_CTRL_12HR)
12HR: [21]:0 = AM, 1 = PM, [20:16] = 1 - 12;
24HR: [21:16] = the range 0-23.
[23] - Alarm hours Enable: 0 - ignore, 1 - match.
[26:24] - An alarm day of the week, the range 1 - 7, where 1 - Monday.
[31] - An alarm day of the week Enable: 0 - ignore, 1 - match.
alarmDateBcd | The BCD-formatted date variable which has the same bit masks as the ALMx_DATE register date fields: [5:0] - An alarm day of a month in BCD, the range 1-31. [7] - An alarm day of a month Enable: 0 - ignore, 1 - match. [12:8] - An alarm month in BCD, the range 1-12. [15] - An alarm month Enable: 0 - ignore, 1 - match. [31] - The Enable alarm: 0 - Alarm is disabled, 1 - Alarm is enabled. |
alarmIndex | The alarm index to be configured, see cy_en_rtc_alarm_t. |
The RTC AHB registers can be updated only under condition that the Write bit is set and the RTC busy bit is cleared (RTC_BUSY = 0). Call the Cy_RTC_WriteEnable(CY_RTC_WRITE_ENABLED) and ensure that Cy_RTC_WriteEnable() returned CY_RTC_SUCCESS. Then you can call Cy_RTC_SyncToRtcAhbDateAndTime(). Do not forget to clear the RTC Write bit to finish an RTC register update by calling the Cy_RTC_WriteEnable(CY_RTC_WRITE_DISABLED) after you executed Cy_RTC_SyncToRtcAhbDateAndTime(). Ensure that Cy_RTC_WriteEnable() returned CY_RTC_SUCCESS.