@@ -69,8 +69,16 @@ static inline void resetBackupDomain(void)
69
69
*/
70
70
HAL_PWR_EnableBkUpAccess ();
71
71
#endif
72
+ #if defined(__HAL_RCC_BACKUPRESET_FORCE )
72
73
__HAL_RCC_BACKUPRESET_FORCE ();
73
74
__HAL_RCC_BACKUPRESET_RELEASE ();
75
+ #endif
76
+ #if defined(LL_APB0_GRP1_PERIPH_RTC )
77
+ LL_RCC_DisableRTC ();
78
+ /* Wait until RTC is disabled */
79
+ while (LL_RCC_IsEnabledRTC ());
80
+ LL_RCC_EnableRTC ();
81
+ #endif
74
82
}
75
83
76
84
static inline void enableBackupDomain (void )
@@ -91,6 +99,23 @@ static inline void enableBackupDomain(void)
91
99
/* Enable RTC CLK for TAMP backup registers */
92
100
__HAL_RCC_RTCAPB_CLK_ENABLE ();
93
101
#endif
102
+ #if defined(LL_APB0_GRP1_PERIPH_RTC )
103
+ if (!LL_RCC_IsEnabledRTC ()) {
104
+ if (LL_RCC_LSE_IsEnabled ()) {
105
+ LL_RCC_LSCO_SetSource (LL_RCC_LSCO_CLKSOURCE_LSE );
106
+ } else {
107
+ /* Configure the Low Speed Clock to LSI */
108
+ LL_RCC_LSCO_SetSource (LL_RCC_LSCO_CLKSOURCE_LSI );
109
+ if (!LL_RCC_LSI_IsEnabled ()) {
110
+ /* Enable LSI */
111
+ LL_RCC_LSI_Enable ();
112
+ /* Wait until LSI is ready */
113
+ while (!LL_RCC_LSI_IsReady ());
114
+ }
115
+ }
116
+ LL_RCC_EnableRTC ();
117
+ }
118
+ #endif
94
119
}
95
120
96
121
static inline void disableBackupDomain (void )
@@ -111,13 +136,16 @@ static inline void disableBackupDomain(void)
111
136
/* Disable RTC CLK for TAMP backup registers */
112
137
__HAL_RCC_RTCAPB_CLK_DISABLE ();
113
138
#endif
139
+ #if defined(LL_APB0_GRP1_PERIPH_RTC )
140
+ LL_RCC_DisableRTC ();
141
+ #endif
114
142
}
115
143
116
144
static inline void setBackupRegister (uint32_t index , uint32_t value )
117
145
{
118
146
#if defined(BKP_BASE )
119
147
LL_RTC_BKP_SetRegister (BKP , index , value );
120
- #elif defined(RTC_BKP0R )
148
+ #elif defined(RTC_BKP0R ) || defined( RTC_BKP0R_BKP )
121
149
LL_RTC_BAK_SetRegister (RTC , index , value );
122
150
#elif defined(TAMP_BKP0R )
123
151
#if defined(STM32G4xx ) || defined(STM32H5xx ) || defined(STM32L5xx ) || \
@@ -141,7 +169,7 @@ static inline uint32_t getBackupRegister(uint32_t index)
141
169
{
142
170
#if defined(BKP_BASE )
143
171
return LL_RTC_BKP_GetRegister (BKP , index );
144
- #elif defined(RTC_BKP0R )
172
+ #elif defined(RTC_BKP0R ) || defined( RTC_BKP0R_BKP )
145
173
return LL_RTC_BAK_GetRegister (RTC , index );
146
174
#elif defined(TAMP_BKP0R )
147
175
#if defined(STM32G4xx ) || defined(STM32H5xx ) || defined(STM32L5xx ) || \
0 commit comments