@@ -48,7 +48,7 @@ extern "C" {
48
48
49
49
50
50
/* Exported functions ------------------------------------------------------- */
51
- static inline void resetBackupRegister (void )
51
+ static inline void resetBackupDomain (void )
52
52
{
53
53
#ifdef HAL_PWR_MODULE_ENABLED
54
54
/* Enable access to the RTC registers */
@@ -63,7 +63,7 @@ static inline void resetBackupRegister(void)
63
63
__HAL_RCC_BACKUPRESET_RELEASE ();
64
64
}
65
65
66
- static inline void enableBackupRegister (void )
66
+ static inline void enableBackupDomain (void )
67
67
{
68
68
/* Enable Power Clock */
69
69
#ifdef __HAL_RCC_PWR_IS_CLK_DISABLED
@@ -76,19 +76,27 @@ static inline void enableBackupRegister(void)
76
76
HAL_PWR_EnableBkUpAccess ();
77
77
#endif
78
78
#ifdef __HAL_RCC_BKP_CLK_ENABLE
79
- /* Enable BKP CLK enable for backup registers */
79
+ /* Enable BKP CLK for backup registers */
80
80
__HAL_RCC_BKP_CLK_ENABLE ();
81
81
#endif
82
+ #ifdef __HAL_RCC_BKPSRAM_CLK_ENABLE
83
+ /* Enable BKPSRAM CLK for backup SRAM */
84
+ __HAL_RCC_BKPSRAM_CLK_ENABLE ();
85
+ #endif
82
86
}
83
87
84
- static inline void disableBackupRegister (void )
88
+ static inline void disableBackupDomain (void )
85
89
{
86
90
#ifdef HAL_PWR_MODULE_ENABLED
87
91
/* Forbid access to Backup domain */
88
92
HAL_PWR_DisableBkUpAccess ();
89
93
#endif
94
+ #ifdef __HAL_RCC_BKPSRAM_CLK_DISABLE
95
+ /* Disnable BKPSRAM CLK for backup SRAM */
96
+ __HAL_RCC_BKPSRAM_CLK_DISABLE ();
97
+ #endif
90
98
#ifdef __HAL_RCC_BKP_CLK_DISABLE
91
- /* Disable BKP CLK enable for backup registers */
99
+ /* Disable BKP CLK for backup registers */
92
100
__HAL_RCC_BKP_CLK_DISABLE ();
93
101
#endif
94
102
/* Disable Power Clock */
@@ -131,6 +139,36 @@ static inline uint32_t getBackupRegister(uint32_t index)
131
139
#endif
132
140
}
133
141
142
+ static inline void writeBackupSRAM (uint32_t offset , uint32_t * data , uint32_t length )
143
+ {
144
+ #if defined(BKPSRAM_BASE )
145
+ uint32_t i = 0 ;
146
+ /* Write 32-Bit data to Backup SRAM */
147
+ for (i = 0 ; i < length ; i ++ ) {
148
+ * (__IO uint32_t * )(BKPSRAM_BASE + (offset + i ) * 4 ) = data [i ];
149
+ }
150
+ #else
151
+ UNUSED (offset );
152
+ UNUSED (data );
153
+ UNUSED (length );
154
+ #endif
155
+ }
156
+
157
+ static inline void readBackupSRAM (uint32_t offset , uint32_t * data , uint32_t length )
158
+ {
159
+ #if defined(BKPSRAM_BASE )
160
+ uint32_t i = 0 ;
161
+ /* Read 32-Bit data from Backup SRAM */
162
+ for (i = 0 ; i < length ; i ++ ) {
163
+ data [i ] = * (__IO uint32_t * )(BKPSRAM_BASE + (offset + i ) * 4 );
164
+ }
165
+ #else
166
+ UNUSED (offset );
167
+ UNUSED (data );
168
+ UNUSED (length );
169
+ #endif
170
+ }
171
+
134
172
#ifdef __cplusplus
135
173
}
136
174
#endif
0 commit comments