GPS Device
Loading...
Searching...
No Matches
RTC Internal Helpers

Functions

static void rtc_set_write_protection (EN_STATUS_te en_status)
 Enables or disables write protection of the RTC registers.

Detailed Description

Function Documentation

◆ rtc_set_write_protection()

void rtc_set_write_protection ( EN_STATUS_te en_status)
static

Enables or disables write protection of the RTC registers.

The RTC write protection key sequence is defined by the STM32F401RE reference manual:

  • Disable (unlock): write 0xCA then 0x53 to RTC_WPR.
  • Enable (lock): write any invalid key (0xFF) to RTC_WPR.

Must be called before and after any write to RTC configuration registers (RTC_TR, RTC_DR, RTC_CR, RTC_PRER, RTC_ISR).

Parameters
[in]en_statusENABLE to re-lock registers, DISABLE to unlock them.

Definition at line 186 of file stm32f401re_rtc.c.

186 {
187 if(en_status == ENABLE) {
188 RTC->RTC_WPR = 0xFF; // Any invalid key re-enables write protection
189 }
190 else if(en_status == DISABLE) {
191 RTC->RTC_WPR = 0xCA; // First key
192 RTC->RTC_WPR = 0x53; // Second key — unlocks write access
193 }
194}
@ ENABLE
Definition common.h:100
@ DISABLE
Definition common.h:97
#define RTC
Here is the caller graph for this function: