GPS Device
Loading...
Searching...
No Matches
stm32f401re_rtc.c File Reference

RTC driver implementation. More...

#include "stm32f401re_rtc.h"
#include "err.h"
#include "stm32f401re_rcc.h"
#include "common.h"
#include "stm32f401re.h"
Include dependency graph for stm32f401re_rtc.c:

Go to the source code of this file.

Macros

#define RTC_BKP_DOMAIN_RST_INDICATOR_BKPxR   0
 Backup register index used to store the initialization sentinel pattern.
#define RTC_BKP_DOMAIN_RST_INDICATOR_PATTERN   0xABCD
 Sentinel value written to BKP0R after successful RTC initialization.

Functions

static void rtc_set_write_protection (EN_STATUS_te en_status)
 Enables or disables write protection of the RTC registers.
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.

Variables

bool initialized
 True after rtc_init has completed successfully in this boot session.

Detailed Description

RTC driver implementation.

Author
github.com/Baksi675
Version
0.1
Date
2026-01-23

Definition in file stm32f401re_rtc.c.

Macro Definition Documentation

◆ RTC_BKP_DOMAIN_RST_INDICATOR_BKPxR

#define RTC_BKP_DOMAIN_RST_INDICATOR_BKPxR   0

Backup register index used to store the initialization sentinel pattern.

If BKPxR[0] contains RTC_BKP_DOMAIN_RST_INDICATOR_PATTERN after a reset, the RTC backup domain was preserved and the peripheral does not need re-initialization. Call rcc_reset_bkpd to force re-initialization.

Definition at line 26 of file stm32f401re_rtc.c.

◆ RTC_BKP_DOMAIN_RST_INDICATOR_PATTERN

#define RTC_BKP_DOMAIN_RST_INDICATOR_PATTERN   0xABCD

Sentinel value written to BKP0R after successful RTC initialization.

Chosen to be an unlikely reset value. Presence in BKP0R indicates the RTC has been configured and the backup domain has not been cleared.

Definition at line 35 of file stm32f401re_rtc.c.

Variable Documentation

◆ initialized

bool initialized

True after rtc_init has completed successfully in this boot session.

Definition at line 38 of file stm32f401re_rtc.c.