1 #include "bootloader.h"
2 #include "dev/watchdog.h"
3 #include <util/delay.h>
5 #include <avr/interrupt.h>
6 #include <avr/pgmspace.h>
11 #if !defined (MCUSR) && defined (MCUCSR)
12 #warning *** MCUSR not defined, using MCUCSR instead ***
16 volatile uint32_t Boot_Key ATTR_NO_INIT;
19 bootloader_is_present(
void) {
21 return pgm_read_word_far(BOOTLOADER_START_ADDRESS)!=0xFFFF;
29 Jump_To_Bootloader(
void)
42 Boot_Key = MAGIC_BOOT_KEY;
45 for (i = 0; i < 128; i++)
49 Boot_Key = MAGIC_BOOT_KEY;
54 extern void Bootloader_Jump_Check(
void) ATTR_INIT_SECTION(3);
57 Bootloader_Jump_Check(
void)
60 if(MCUSR & (1<<WDRF)) {
62 if(Boot_Key == MAGIC_BOOT_KEY) {
66 ((void (*)(void))BOOTLOADER_START_ADDRESS)();
71 Boot_Key = MAGIC_BOOT_KEY-4;