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>
19 #ifndef EEPROM_MAGIC_BYTE_ADDR
20 #define EEPROM_MAGIC_BYTE_ADDR (uint8_t*)(E2END-3)
23 volatile uint32_t Boot_Key ATTR_NO_INIT;
25 extern void Bootloader_Jump_Check(
void) ATTR_INIT_SECTION(3);
28 bootloader_is_present(
void)
30 #if defined(BOOTLOADER_START_ADDRESS)
31 return pgm_read_word_far(BOOTLOADER_START_ADDRESS) != 0xFFFF;
38 Jump_To_Bootloader(
void)
50 for(i = 0; i < 200; i++) {
57 Boot_Key = MAGIC_BOOT_KEY;
59 eeprom_write_byte(EEPROM_MAGIC_BYTE_ADDR, 0xFF);
68 Bootloader_Jump_Check(
void)
73 if(MCUCSR & (1 << WDRF)) {
75 if(Boot_Key == MAGIC_BOOT_KEY) {
82 eeprom_write_byte(EEPROM_MAGIC_BYTE_ADDR, 0xFF);
87 ((void (*)(void))(BOOTLOADER_START_ADDRESS)) ();
96 for(i = 0; i < 200; i++) {
102 Boot_Key = MAGIC_BOOT_KEY - 4;
This file contains the USB driver routines.
#define Usb_detach()
detaches from USB bus
void watchdog_reboot(void)
Keeps control until the WDT throws a reset signal.
void watchdog_periodic(void)
Writes the WDT clear sequence.