32 lines
569 B
C
32 lines
569 B
C
#include "restart.h"
|
|
#include "stm32f4xx_hal.h"
|
|
|
|
typedef enum {
|
|
RESTART_NONE = 0,
|
|
RESTART_DEFAULT,
|
|
RESTART_BOOTLOADER
|
|
} RESTART_Target;
|
|
|
|
RESTART_Target restart_target = RESTART_NONE;
|
|
|
|
void request_restart_to_default(void) {
|
|
restart_target = RESTART_DEFAULT;
|
|
}
|
|
|
|
void request_restart_to_bootloader(void) {
|
|
restart_target = RESTART_BOOTLOADER;
|
|
}
|
|
|
|
void restart_check(void) {
|
|
if (restart_target == RESTART_NONE) {
|
|
return;
|
|
}
|
|
|
|
if (restart_target == RESTART_BOOTLOADER) {
|
|
// Magic value
|
|
*((unsigned long *)0x2001FFF0) = 0xB0A720AD;
|
|
}
|
|
|
|
HAL_NVIC_SystemReset();
|
|
}
|