#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 * USBaspLoader 2048 */ #ifndef BOOTLOADER_SIZE #warning To use bootloader_jump() you need to define BOOTLOADER_SIZE in config.h. #define BOOTLOADER_SIZE 4096 #endif #define FLASH_SIZE (FLASHEND + 1L) #define BOOTLOADER_START (FLASH_SIZE - BOOTLOADER_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<