@@ -48,7 +48,7 @@ extern "C" {
4848
4949
5050/* Exported functions ------------------------------------------------------- */
51- static inline void resetBackupRegister (void )
51+ static inline void resetBackupDomain (void )
5252{
5353#ifdef HAL_PWR_MODULE_ENABLED
5454 /* Enable access to the RTC registers */
@@ -63,7 +63,7 @@ static inline void resetBackupRegister(void)
6363 __HAL_RCC_BACKUPRESET_RELEASE ();
6464}
6565
66- static inline void enableBackupRegister (void )
66+ static inline void enableBackupDomain (void )
6767{
6868 /* Enable Power Clock */
6969#ifdef __HAL_RCC_PWR_IS_CLK_DISABLED
@@ -76,19 +76,27 @@ static inline void enableBackupRegister(void)
7676 HAL_PWR_EnableBkUpAccess ();
7777#endif
7878#ifdef __HAL_RCC_BKP_CLK_ENABLE
79- /* Enable BKP CLK enable for backup registers */
79+ /* Enable BKP CLK for backup registers */
8080 __HAL_RCC_BKP_CLK_ENABLE ();
8181#endif
82+ #ifdef __HAL_RCC_BKPSRAM_CLK_ENABLE
83+ /* Enable BKPSRAM CLK for backup SRAM */
84+ __HAL_RCC_BKPSRAM_CLK_ENABLE ();
85+ #endif
8286}
8387
84- static inline void disableBackupRegister (void )
88+ static inline void disableBackupDomain (void )
8589{
8690#ifdef HAL_PWR_MODULE_ENABLED
8791 /* Forbid access to Backup domain */
8892 HAL_PWR_DisableBkUpAccess ();
8993#endif
94+ #ifdef __HAL_RCC_BKPSRAM_CLK_DISABLE
95+ /* Disnable BKPSRAM CLK for backup SRAM */
96+ __HAL_RCC_BKPSRAM_CLK_DISABLE ();
97+ #endif
9098#ifdef __HAL_RCC_BKP_CLK_DISABLE
91- /* Disable BKP CLK enable for backup registers */
99+ /* Disable BKP CLK for backup registers */
92100 __HAL_RCC_BKP_CLK_DISABLE ();
93101#endif
94102 /* Disable Power Clock */
@@ -131,6 +139,36 @@ static inline uint32_t getBackupRegister(uint32_t index)
131139#endif
132140}
133141
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+
134172#ifdef __cplusplus
135173}
136174#endif
0 commit comments