This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "stm32f0xx.h" | |
#include "stm32f0xx_hal_flash.h" | |
#include "usb_device.h" | |
// Idea: We want to be able to jump to the bootloader from application | |
// Problems: | |
// 1. Once usb is initialized in application mode you cannot reinitialize it from bootloader. Thats why we do a system reset as first step | |
// 2. The bootloader will immediately jump back to application unless the first page of the flash has been cleared. That's why we erase the first page of the flash before jumping | |
// 3. Clock and other stuff must be reset before jumping into bootloader. We copied that from the example. See JumpToBootloader code below |