1 #include "bootloader.h"
2 #include "dev/watchdog.h"
3 #include <util/delay.h>
5 #include <avr/interrupt.h>
6 #include <avr/pgmspace.h>
8 #include <avr/pgmspace.h>
9 #include <avr/interrupt.h>
10 #include <avr/eeprom.h>
15 # warning *** MCUCSR not defined, using MCUSR instead ***
20 #ifndef EEPROM_MAGIC_BYTE_ADDR
21 #define EEPROM_MAGIC_BYTE_ADDR (uint8_t*)(E2END-3)
24 volatile uint32_t Boot_Key ATTR_NO_INIT;
26 extern void Bootloader_Jump_Check(
void) ATTR_INIT_SECTION(3);
29 bootloader_is_present(
void)
31 #if defined(BOOTLOADER_START_ADDRESS)
32 return pgm_read_word_far(BOOTLOADER_START_ADDRESS) != 0xFFFF;
39 Jump_To_Bootloader(
void)
51 for(i = 0; i < 200; i++) {
58 Boot_Key = MAGIC_BOOT_KEY;
60 eeprom_write_byte(EEPROM_MAGIC_BYTE_ADDR, 0xFF);
69 Bootloader_Jump_Check(
void)
74 if(MCUCSR & (1 << WDRF)) {
76 if(Boot_Key == MAGIC_BOOT_KEY) {
83 eeprom_write_byte(EEPROM_MAGIC_BYTE_ADDR, 0xFF);
88 ((void (*)(void))(BOOTLOADER_START_ADDRESS)) ();
97 for(i = 0; i < 200; i++) {
103 Boot_Key = MAGIC_BOOT_KEY - 4;
#define Usb_detach()
detaches from USB bus
This file contains the USB driver routines.
void watchdog_reboot(void)
Keeps control until the WDT throws a reset signal.
void watchdog_periodic(void)
Writes the WDT clear sequence.