mirror of
https://github.com/DarkFlippers/unleashed-firmware
synced 2024-12-22 02:33:10 +00:00
20 lines
495 B
C
20 lines
495 B
C
|
#include "boot.h"
|
||
|
#include "stm32l4xx_ll_bus.h"
|
||
|
#include "stm32l4xx_ll_rcc.h"
|
||
|
#include "stm32l4xx_ll_rtc.h"
|
||
|
#include "stm32l4xx_ll_pwr.h"
|
||
|
|
||
|
#define BOOT_REQUEST_DFU 0xDF00B000
|
||
|
|
||
|
void boot_restart_in_dfu() {
|
||
|
// Request DFU on boot
|
||
|
LL_APB1_GRP1_EnableClock(LL_APB1_GRP1_PERIPH_PWR);
|
||
|
LL_PWR_EnableBkUpAccess();
|
||
|
// Enable RTC
|
||
|
LL_RCC_EnableRTC();
|
||
|
// Write backup registry
|
||
|
LL_RTC_BAK_SetRegister(RTC, LL_RTC_BKP_DR0, BOOT_REQUEST_DFU);
|
||
|
// Reset
|
||
|
NVIC_SystemReset();
|
||
|
}
|