10 #ifndef ACE_TIME_STM32_F1_RTC_H
11 #define ACE_TIME_STM32_F1_RTC_H
15 #if defined(STM32F1xx)
19 #define RTC_CRH RTC->CRH
20 #define RTC_CRL RTC->CRL
21 #define RTC_PRLH RTC->PRLH
22 #define RTC_PRLL RTC->PRLL
23 #define RTC_CNTH RTC->CNTH
24 #define RTC_CNTL RTC->CNTL
26 #define RCC_APB1ENR RCC->APB1ENR
27 #define RCC_BDCR RCC->BDCR
28 #define PWR_CR PWR->CR
41 #define RTC_INIT_REG BKP->DR1
42 #define RTC_INIT_BIT 0
43 #define RTC_INIT_FLAG (1 << RTC_INIT_BIT)
80 void setTime(uint32_t time);
89 bool isInitialized() {
90 return (RTC_INIT_REG & RTC_INIT_FLAG) == RTC_INIT_FLAG;
95 RTC_CRL &= ~RTC_CRL_RSF;
96 while ((RTC_CRL & RTC_CRL_RSF) == 0);
100 while ((RTC_CRL & RTC_CRL_RTOFF) == 0);
103 void enableBackupWrites() {
104 PWR_CR |= PWR_CR_DBP;
107 void disableBackupWrites() {
108 PWR_CR &= ~PWR_CR_DBP;
111 void enterConfigMode() {
112 RTC_CRL |= RTC_CRL_CNF;
115 void exitConfigMode() {
116 RTC_CRL &= ~RTC_CRL_CNF;
119 void enableClockInterface() {
120 RCC_APB1ENR |= RCC_APB1ENR_PWREN | RCC_APB1ENR_BKPEN;