]> git.friedersdorff.com Git - max/tmk_keyboard.git/blob - tmk_core/common/chibios/bootloader.c
93f2e3785a5b003a6ea70550e5299612491352be
[max/tmk_keyboard.git] / tmk_core / common / chibios / bootloader.c
1 #include "bootloader.h"
2
3 #include "ch.h"
4
5 #ifdef BOOTLOADER_ADDRESS
6 #define SYMVAL(sym) (uint32_t)(((uint8_t *)&(sym)) - ((uint8_t *)0))
7 extern uint32_t __ram0_end__;
8
9 void bootloader_jump(void) {
10   *((unsigned long *)(SYMVAL(__ram0_end__) - 4)) = 0xDEADBEEF; // set magic flag => reset handler will jump into boot loader
11    NVIC_SystemReset();
12 }
13 #else /* BOOTLOADER_ADDRESS */
14 void bootloader_jump(void) {}
15 #endif /* BOOTLOADER_ADDRESS */
16