|
GPS Device
|
Public functions to interact with the RTC peripheral. More...

Functions | |
| ERR_te | rtc_init (void) |
| Initializes the RTC peripheral. | |
| void | rtc_set_calendar (CALENDAR_ts const *date) |
| Sets the RTC calendar (date and weekday). | |
| void | rtc_set_time (TIME_ts const *time) |
| Sets the RTC time (hours, minutes, seconds). | |
| void | rtc_get_time (TIME_ts *time) |
| Reads the current time from the RTC. | |
Public functions to interact with the RTC peripheral.
| ERR_te rtc_init | ( | void | ) |
Initializes the RTC peripheral.
Enables the PWR and backup domain access, starts the LSE oscillator, selects LSE as the RTC clock source, enables the RTC, and configures the prescalers for a 1 Hz tick (PREDIV_A = 127, PREDIV_S = 255) with 24-hour format.
If the backup register sentinel pattern is already present, the RTC is assumed to be running with a valid configuration and the function returns immediately without modifying the time or calendar.
Definition at line 49 of file stm32f401re_rtc.c.


| void rtc_set_calendar | ( | CALENDAR_ts const * | date | ) |
Sets the RTC calendar (date and weekday).
Enters RTC INIT mode, writes the date, month, weekday, and year to RTC_DR in BCD format, then exits INIT mode. Write protection is disabled and re-enabled around the operation.
| [in] | date | Pointer to the calendar structure to write. |
Definition at line 109 of file stm32f401re_rtc.c.


| void rtc_set_time | ( | TIME_ts const * | time | ) |
Sets the RTC time (hours, minutes, seconds).
Enters RTC INIT mode, writes hours, minutes, and seconds to RTC_TR in BCD format using DEC_TO_BCD, then exits INIT mode. Write protection is disabled and re-enabled around the operation.
| [in] | time | Pointer to the time structure to write. |
Definition at line 131 of file stm32f401re_rtc.c.


| void rtc_get_time | ( | TIME_ts * | time | ) |
Reads the current time from the RTC.
Reads RTC_TR atomically using the shadow register double-read technique: reads TR, reads DR (to unlock the shadow registers), reads TR again, and repeats if the two TR reads differ. Converts BCD values to decimal using BCD_TO_DEC before storing in time.
| [out] | time | Pointer to the time structure that will receive the current hours, minutes, and seconds. |
Definition at line 149 of file stm32f401re_rtc.c.
