#include #include #include #include #include #include #include "bootloader.h" #ifdef PROTOCOL_LUFA #include #endif /* Boot Section Size in *BYTEs* * Teensy halfKay 512 * Teensy++ halfKay 1024 * Atmel DFU loader 4096 * LUFA bootloader 4096 */ #ifndef BOOT_SIZE #define BOOT_SIZE 512 #endif #define FLASH_SIZE (FLASHEND + 1L) #define BOOTLOADER_START (FLASH_SIZE - BOOT_SIZE) /* * Entering the Bootloader via Software * http://www.fourwalledcubicle.com/files/LUFA/Doc/120730/html/_page__software_bootloader_start.html */ #define BOOTLOADER_RESET_KEY 0xB007B007 uint32_t reset_key __attribute__ ((section (".noinit"))); /* initialize MCU status by watchdog reset */ void bootloader_jump(void) { #ifdef PROTOCOL_LUFA USB_Disable(); cli(); _delay_ms(2000); #endif #ifdef PROTOCOL_PJRC cli(); UDCON = 1; USBCON = (1<