File tree 2 files changed +22
-12
lines changed
2 files changed +22
-12
lines changed Original file line number Diff line number Diff line change @@ -46,6 +46,18 @@ extern "C" {
46
46
#define RTC_BKP_VALUE 0x32F2
47
47
#endif
48
48
49
+ #if defined (HIDBL_F1 ) || defined (HIDBL_F4 )
50
+ #if !defined(HID_MAGIC_NUMBER_BKP_INDEX )
51
+ #if defined (HIDBL_F1 )
52
+ #define HID_MAGIC_NUMBER_BKP_INDEX LL_RTC_BKP_DR10
53
+ #elif defined (HIDBL_F4 )
54
+ #define HID_MAGIC_NUMBER_BKP_INDEX 0
55
+ #endif
56
+ #endif /* HID_MAGIC_NUMBER_BKP_INDEX */
57
+ #ifndef HID_MAGIC_NUMBER_BKP_VALUE
58
+ #define HID_MAGIC_NUMBER_BKP_VALUE 0x424C
59
+ #endif
60
+ #endif /* HIDBL_F1 || HIDBL_F4 */
49
61
50
62
/* Exported functions ------------------------------------------------------- */
51
63
static inline void resetBackupDomain (void )
Original file line number Diff line number Diff line change 23
23
/* Includes ------------------------------------------------------------------*/
24
24
#include "usbd_desc.h"
25
25
#include "usbd_cdc_if.h"
26
+ #include "backup.h"
26
27
27
28
#ifdef USE_USB_HS
28
29
#define CDC_MAX_PACKET_SIZE USB_OTG_HS_MAX_PACKET_SIZE
@@ -229,19 +230,16 @@ static int8_t USBD_CDC_Receive(uint8_t *Buf, uint32_t *Len)
229
230
*/
230
231
if (dtr_toggling > 3 ) {
231
232
if ((Buf [0 ] == '1' ) && (Buf [1 ] == 'E' ) && (Buf [2 ] == 'A' ) && (Buf [3 ] == 'F' )) {
233
+ #if defined (HIDBL_F1 ) || defined (HIDBL_F4 )
234
+ enableBackupDomain ();
232
235
#if defined (HIDBL_F1 )
233
- RTC_HandleTypeDef hrtc ;
234
- __HAL_RCC_PWR_CLK_ENABLE ();
235
- __HAL_RCC_BKP_CLK_ENABLE ();
236
- HAL_PWR_EnableBkUpAccess ();
237
- HAL_RTCEx_BKUPWrite (& hrtc , RTC_BKP_DR10 , 0x424C ); //Write the magic number 0x424C
238
-
239
- #elif defined (HIDBL_F4 )
240
- __HAL_RCC_PWR_CLK_ENABLE ();
241
- HAL_PWR_EnableBkUpAccess ();
242
- __BKPSRAM_CLK_ENABLE ();
243
- * (__IO uint32_t * )(BKPSRAM_BASE ) = 0x424C ; //Write the magic number 0x424C at Backup SRAM address 0x40024000
244
-
236
+ setBackupRegister (HID_MAGIC_NUMBER_BKP_INDEX , HID_MAGIC_NUMBER_BKP_VALUE );
237
+ #endif
238
+ #if defined (HIDBL_F4 )
239
+ writeBackupSRAM (HID_MAGIC_NUMBER_BKP_INDEX , & (uint32_t ) {
240
+ HID_MAGIC_NUMBER_BKP_VALUE
241
+ }, 1 );
242
+ #endif
245
243
#endif
246
244
HAL_NVIC_SystemReset ();
247
245
}
You can’t perform that action at this time.
0 commit comments