summaryrefslogtreecommitdiffstats
path: root/tmk_core/protocol/lufa/LUFA-git/Bootloaders
diff options
context:
space:
mode:
Diffstat (limited to 'tmk_core/protocol/lufa/LUFA-git/Bootloaders')
-rw-r--r--tmk_core/protocol/lufa/LUFA-git/Bootloaders/CDC/BootloaderAPI.c75
-rw-r--r--tmk_core/protocol/lufa/LUFA-git/Bootloaders/CDC/BootloaderAPI.h58
-rw-r--r--tmk_core/protocol/lufa/LUFA-git/Bootloaders/CDC/BootloaderAPITable.S91
-rw-r--r--tmk_core/protocol/lufa/LUFA-git/Bootloaders/CDC/BootloaderCDC.c641
-rw-r--r--tmk_core/protocol/lufa/LUFA-git/Bootloaders/CDC/BootloaderCDC.h144
-rw-r--r--tmk_core/protocol/lufa/LUFA-git/Bootloaders/CDC/BootloaderCDC.txt240
-rw-r--r--tmk_core/protocol/lufa/LUFA-git/Bootloaders/CDC/Config/AppConfig.h50
-rw-r--r--tmk_core/protocol/lufa/LUFA-git/Bootloaders/CDC/Config/LUFAConfig.h93
-rw-r--r--tmk_core/protocol/lufa/LUFA-git/Bootloaders/CDC/Descriptors.c244
-rw-r--r--tmk_core/protocol/lufa/LUFA-git/Bootloaders/CDC/Descriptors.h158
-rw-r--r--tmk_core/protocol/lufa/LUFA-git/Bootloaders/CDC/LUFA CDC Bootloader.inf66
-rw-r--r--tmk_core/protocol/lufa/LUFA-git/Bootloaders/CDC/asf.xml161
-rw-r--r--tmk_core/protocol/lufa/LUFA-git/Bootloaders/CDC/doxyfile2365
-rw-r--r--tmk_core/protocol/lufa/LUFA-git/Bootloaders/CDC/makefile55
-rw-r--r--tmk_core/protocol/lufa/LUFA-git/Bootloaders/DFU/BootloaderAPI.c76
-rw-r--r--tmk_core/protocol/lufa/LUFA-git/Bootloaders/DFU/BootloaderAPI.h58
-rw-r--r--tmk_core/protocol/lufa/LUFA-git/Bootloaders/DFU/BootloaderAPITable.S91
-rw-r--r--tmk_core/protocol/lufa/LUFA-git/Bootloaders/DFU/BootloaderDFU.c804
-rw-r--r--tmk_core/protocol/lufa/LUFA-git/Bootloaders/DFU/BootloaderDFU.h216
-rw-r--r--tmk_core/protocol/lufa/LUFA-git/Bootloaders/DFU/BootloaderDFU.txt233
-rw-r--r--tmk_core/protocol/lufa/LUFA-git/Bootloaders/DFU/Config/AppConfig.h48
-rw-r--r--tmk_core/protocol/lufa/LUFA-git/Bootloaders/DFU/Config/LUFAConfig.h93
-rw-r--r--tmk_core/protocol/lufa/LUFA-git/Bootloaders/DFU/Descriptors.c185
-rw-r--r--tmk_core/protocol/lufa/LUFA-git/Bootloaders/DFU/Descriptors.h194
-rw-r--r--tmk_core/protocol/lufa/LUFA-git/Bootloaders/DFU/asf.xml156
-rw-r--r--tmk_core/protocol/lufa/LUFA-git/Bootloaders/DFU/doxyfile2365
-rw-r--r--tmk_core/protocol/lufa/LUFA-git/Bootloaders/DFU/makefile55
-rw-r--r--tmk_core/protocol/lufa/LUFA-git/Bootloaders/HID/BootloaderHID.c190
-rw-r--r--tmk_core/protocol/lufa/LUFA-git/Bootloaders/HID/BootloaderHID.h73
-rw-r--r--tmk_core/protocol/lufa/LUFA-git/Bootloaders/HID/BootloaderHID.txt105
-rw-r--r--tmk_core/protocol/lufa/LUFA-git/Bootloaders/HID/Config/LUFAConfig.h93
-rw-r--r--tmk_core/protocol/lufa/LUFA-git/Bootloaders/HID/Descriptors.c187
-rw-r--r--tmk_core/protocol/lufa/LUFA-git/Bootloaders/HID/Descriptors.h80
-rw-r--r--tmk_core/protocol/lufa/LUFA-git/Bootloaders/HID/HostLoaderApp/Makefile39
-rw-r--r--tmk_core/protocol/lufa/LUFA-git/Bootloaders/HID/HostLoaderApp/Makefile.bsd21
-rw-r--r--tmk_core/protocol/lufa/LUFA-git/Bootloaders/HID/HostLoaderApp/gpl3.txt674
-rw-r--r--tmk_core/protocol/lufa/LUFA-git/Bootloaders/HID/HostLoaderApp/hid_bootloader_cli.c1010
-rw-r--r--tmk_core/protocol/lufa/LUFA-git/Bootloaders/HID/HostLoaderApp_Python/hid_bootloader_loader.py120
-rw-r--r--tmk_core/protocol/lufa/LUFA-git/Bootloaders/HID/asf.xml123
-rw-r--r--tmk_core/protocol/lufa/LUFA-git/Bootloaders/HID/doxyfile2367
-rw-r--r--tmk_core/protocol/lufa/LUFA-git/Bootloaders/HID/makefile48
-rw-r--r--tmk_core/protocol/lufa/LUFA-git/Bootloaders/MassStorage/BootloaderAPI.c76
-rw-r--r--tmk_core/protocol/lufa/LUFA-git/Bootloaders/MassStorage/BootloaderAPI.h63
-rw-r--r--tmk_core/protocol/lufa/LUFA-git/Bootloaders/MassStorage/BootloaderAPITable.S102
-rw-r--r--tmk_core/protocol/lufa/LUFA-git/Bootloaders/MassStorage/BootloaderMassStorage.c238
-rw-r--r--tmk_core/protocol/lufa/LUFA-git/Bootloaders/MassStorage/BootloaderMassStorage.h99
-rw-r--r--tmk_core/protocol/lufa/LUFA-git/Bootloaders/MassStorage/BootloaderMassStorage.txt225
-rw-r--r--tmk_core/protocol/lufa/LUFA-git/Bootloaders/MassStorage/Config/AppConfig.h47
-rw-r--r--tmk_core/protocol/lufa/LUFA-git/Bootloaders/MassStorage/Config/LUFAConfig.h93
-rw-r--r--tmk_core/protocol/lufa/LUFA-git/Bootloaders/MassStorage/Descriptors.c157
-rw-r--r--tmk_core/protocol/lufa/LUFA-git/Bootloaders/MassStorage/Descriptors.h88
-rw-r--r--tmk_core/protocol/lufa/LUFA-git/Bootloaders/MassStorage/Lib/SCSI.c294
-rw-r--r--tmk_core/protocol/lufa/LUFA-git/Bootloaders/MassStorage/Lib/SCSI.h84
-rw-r--r--tmk_core/protocol/lufa/LUFA-git/Bootloaders/MassStorage/Lib/VirtualFAT.c482
-rw-r--r--tmk_core/protocol/lufa/LUFA-git/Bootloaders/MassStorage/Lib/VirtualFAT.h302
-rw-r--r--tmk_core/protocol/lufa/LUFA-git/Bootloaders/MassStorage/asf.xml156
-rw-r--r--tmk_core/protocol/lufa/LUFA-git/Bootloaders/MassStorage/doxyfile2365
-rw-r--r--tmk_core/protocol/lufa/LUFA-git/Bootloaders/MassStorage/makefile68
-rw-r--r--tmk_core/protocol/lufa/LUFA-git/Bootloaders/Printer/BootloaderAPI.c75
-rw-r--r--tmk_core/protocol/lufa/LUFA-git/Bootloaders/Printer/BootloaderAPI.h56
-rw-r--r--tmk_core/protocol/lufa/LUFA-git/Bootloaders/Printer/BootloaderAPITable.S91
-rw-r--r--tmk_core/protocol/lufa/LUFA-git/Bootloaders/Printer/BootloaderPrinter.c431
-rw-r--r--tmk_core/protocol/lufa/LUFA-git/Bootloaders/Printer/BootloaderPrinter.h108
-rw-r--r--tmk_core/protocol/lufa/LUFA-git/Bootloaders/Printer/BootloaderPrinter.txt190
-rw-r--r--tmk_core/protocol/lufa/LUFA-git/Bootloaders/Printer/Config/LUFAConfig.h93
-rw-r--r--tmk_core/protocol/lufa/LUFA-git/Bootloaders/Printer/Descriptors.c194
-rw-r--r--tmk_core/protocol/lufa/LUFA-git/Bootloaders/Printer/Descriptors.h96
-rw-r--r--tmk_core/protocol/lufa/LUFA-git/Bootloaders/Printer/asf.xml159
-rw-r--r--tmk_core/protocol/lufa/LUFA-git/Bootloaders/Printer/doxyfile2365
-rw-r--r--tmk_core/protocol/lufa/LUFA-git/Bootloaders/Printer/makefile55
-rw-r--r--tmk_core/protocol/lufa/LUFA-git/Bootloaders/makefile46
71 files changed, 23043 insertions, 0 deletions
diff --git a/tmk_core/protocol/lufa/LUFA-git/Bootloaders/CDC/BootloaderAPI.c b/tmk_core/protocol/lufa/LUFA-git/Bootloaders/CDC/BootloaderAPI.c
new file mode 100644
index 0000000000..f7564e9827
--- /dev/null
+++ b/tmk_core/protocol/lufa/LUFA-git/Bootloaders/CDC/BootloaderAPI.c
@@ -0,0 +1,75 @@
+/*
+ LUFA Library
+ Copyright (C) Dean Camera, 2014.
+
+ dean [at] fourwalledcubicle [dot] com
+ www.lufa-lib.org
+*/
+
+/*
+ Copyright 2014 Dean Camera (dean [at] fourwalledcubicle [dot] com)
+
+ Permission to use, copy, modify, distribute, and sell this
+ software and its documentation for any purpose is hereby granted
+ without fee, provided that the above copyright notice appear in
+ all copies and that both that the copyright notice and this
+ permission notice and warranty disclaimer appear in supporting
+ documentation, and that the name of the author not be used in
+ advertising or publicity pertaining to distribution of the
+ software without specific, written prior permission.
+
+ The author disclaims all warranties with regard to this
+ software, including all implied warranties of merchantability
+ and fitness. In no event shall the author be liable for any
+ special, indirect or consequential damages or any damages
+ whatsoever resulting from loss of use, data or profits, whether
+ in an action of contract, negligence or other tortious action,
+ arising out of or in connection with the use or performance of
+ this software.
+*/
+
+/** \file
+ *
+ * Bootloader user application API functions.
+ */
+
+#include "BootloaderAPI.h"
+
+void BootloaderAPI_ErasePage(const uint32_t Address)
+{
+ boot_page_erase_safe(Address);
+ boot_spm_busy_wait();
+ boot_rww_enable();
+}
+
+void BootloaderAPI_WritePage(const uint32_t Address)
+{
+ boot_page_write_safe(Address);
+ boot_spm_busy_wait();
+ boot_rww_enable();
+}
+
+void BootloaderAPI_FillWord(const uint32_t Address, const uint16_t Word)
+{
+ boot_page_fill_safe(Address, Word);
+}
+
+uint8_t BootloaderAPI_ReadSignature(const uint16_t Address)
+{
+ return boot_signature_byte_get(Address);
+}
+
+uint8_t BootloaderAPI_ReadFuse(const uint16_t Address)
+{
+ return boot_lock_fuse_bits_get(Address);
+}
+
+uint8_t BootloaderAPI_ReadLock(void)
+{
+ return boot_lock_fuse_bits_get(GET_LOCK_BITS);
+}
+
+void BootloaderAPI_WriteLock(const uint8_t LockBits)
+{
+ boot_lock_bits_set_safe(LockBits);
+}
diff --git a/tmk_core/protocol/lufa/LUFA-git/Bootloaders/CDC/BootloaderAPI.h b/tmk_core/protocol/lufa/LUFA-git/Bootloaders/CDC/BootloaderAPI.h
new file mode 100644
index 0000000000..2462cacdd0
--- /dev/null
+++ b/tmk_core/protocol/lufa/LUFA-git/Bootloaders/CDC/BootloaderAPI.h
@@ -0,0 +1,58 @@
+/*
+ LUFA Library
+ Copyright (C) Dean Camera, 2014.
+
+ dean [at] fourwalledcubicle [dot] com
+ www.lufa-lib.org
+*/
+
+/*
+ Copyright 2014 Dean Camera (dean [at] fourwalledcubicle [dot] com)
+
+ Permission to use, copy, modify, distribute, and sell this
+ software and its documentation for any purpose is hereby granted
+ without fee, provided that the above copyright notice appear in
+ all copies and that both that the copyright notice and this
+ permission notice and warranty disclaimer appear in supporting
+ documentation, and that the name of the author not be used in
+ advertising or publicity pertaining to distribution of the
+ software without specific, written prior permission.
+
+ The author disclaims all warranties with regard to this
+ software, including all implied warranties of merchantability
+ and fitness. In no event shall the author be liable for any
+ special, indirect or consequential damages or any damages
+ whatsoever resulting from loss of use, data or profits, whether
+ in an action of contract, negligence or other tortious action,
+ arising out of or in connection with the use or performance of
+ this software.
+*/
+
+/** \file
+ *
+ * Header file for BootloaderAPI.c.
+ */
+
+#ifndef _BOOTLOADER_API_H_
+#define _BOOTLOADER_API_H_
+
+ /* Includes: */
+ #include <avr/io.h>
+ #include <avr/boot.h>
+ #include <stdbool.h>
+
+ #include <LUFA/Common/Common.h>
+
+ #include "Config/AppConfig.h"
+
+ /* Function Prototypes: */
+ void BootloaderAPI_ErasePage(const uint32_t Address);
+ void BootloaderAPI_WritePage(const uint32_t Address);
+ void BootloaderAPI_FillWord(const uint32_t Address, const uint16_t Word);
+ uint8_t BootloaderAPI_ReadSignature(const uint16_t Address);
+ uint8_t BootloaderAPI_ReadFuse(const uint16_t Address);
+ uint8_t BootloaderAPI_ReadLock(void);
+ void BootloaderAPI_WriteLock(const uint8_t LockBits);
+
+#endif
+
diff --git a/tmk_core/protocol/lufa/LUFA-git/Bootloaders/CDC/BootloaderAPITable.S b/tmk_core/protocol/lufa/LUFA-git/Bootloaders/CDC/BootloaderAPITable.S
new file mode 100644
index 0000000000..69ebd387a9
--- /dev/null
+++ b/tmk_core/protocol/lufa/LUFA-git/Bootloaders/CDC/BootloaderAPITable.S
@@ -0,0 +1,91 @@
+/*
+ LUFA Library
+ Copyright (C) Dean Camera, 2014.
+
+ dean [at] fourwalledcubicle [dot] com
+ www.lufa-lib.org
+*/
+
+/*
+ Copyright 2014 Dean Camera (dean [at] fourwalledcubicle [dot] com)
+
+ Permission to use, copy, modify, distribute, and sell this
+ software and its documentation for any purpose is hereby granted
+ without fee, provided that the above copyright notice appear in
+ all copies and that both that the copyright notice and this
+ permission notice and warranty disclaimer appear in supporting
+ documentation, and that the name of the author not be used in
+ advertising or publicity pertaining to distribution of the
+ software without specific, written prior permission.
+
+ The author disclaims all warranties with regard to this
+ software, including all implied warranties of merchantability
+ and fitness. In no event shall the author be liable for any
+ special, indirect or consequential damages or any damages
+ whatsoever resulting from loss of use, data or profits, whether
+ in an action of contract, negligence or other tortious action,
+ arising out of or in connection with the use or performance of
+ this software.
+*/
+
+; Trampolines to actual API implementations if the target address is outside the
+; range of a rjmp instruction (can happen with large bootloader sections)
+.section .apitable_trampolines, "ax"
+.global BootloaderAPI_Trampolines
+BootloaderAPI_Trampolines:
+
+ BootloaderAPI_ErasePage_Trampoline:
+ jmp BootloaderAPI_ErasePage
+ BootloaderAPI_WritePage_Trampoline:
+ jmp BootloaderAPI_WritePage
+ BootloaderAPI_FillWord_Trampoline:
+ jmp BootloaderAPI_FillWord
+ BootloaderAPI_ReadSignature_Trampoline:
+ jmp BootloaderAPI_ReadSignature
+ BootloaderAPI_ReadFuse_Trampoline:
+ jmp BootloaderAPI_ReadFuse
+ BootloaderAPI_ReadLock_Trampoline:
+ jmp BootloaderAPI_ReadLock
+ BootloaderAPI_WriteLock_Trampoline:
+ jmp BootloaderAPI_WriteLock
+ BootloaderAPI_UNUSED1:
+ ret
+ BootloaderAPI_UNUSED2:
+ ret
+ BootloaderAPI_UNUSED3:
+ ret
+ BootloaderAPI_UNUSED4:
+ ret
+ BootloaderAPI_UNUSED5:
+ ret
+
+
+
+; API function jump table
+.section .apitable_jumptable, "ax"
+.global BootloaderAPI_JumpTable
+BootloaderAPI_JumpTable:
+
+ rjmp BootloaderAPI_ErasePage_Trampoline
+ rjmp BootloaderAPI_WritePage_Trampoline
+ rjmp BootloaderAPI_FillWord_Trampoline
+ rjmp BootloaderAPI_ReadSignature_Trampoline
+ rjmp BootloaderAPI_ReadFuse_Trampoline
+ rjmp BootloaderAPI_ReadLock_Trampoline
+ rjmp BootloaderAPI_WriteLock_Trampoline
+ rjmp BootloaderAPI_UNUSED1 ; UNUSED ENTRY 1
+ rjmp BootloaderAPI_UNUSED2 ; UNUSED ENTRY 2
+ rjmp BootloaderAPI_UNUSED3 ; UNUSED ENTRY 3
+ rjmp BootloaderAPI_UNUSED4 ; UNUSED ENTRY 4
+ rjmp BootloaderAPI_UNUSED5 ; UNUSED ENTRY 5
+
+
+
+; Bootloader table signatures and information
+.section .apitable_signatures, "ax"
+.global BootloaderAPI_Signatures
+BootloaderAPI_Signatures:
+
+ .long BOOT_START_ADDR ; Start address of the bootloader
+ .word 0xDF00 ; Signature for the CDC class bootloader
+ .word 0xDCFB ; Signature for a LUFA class bootloader
diff --git a/tmk_core/protocol/lufa/LUFA-git/Bootloaders/CDC/BootloaderCDC.c b/tmk_core/protocol/lufa/LUFA-git/Bootloaders/CDC/BootloaderCDC.c
new file mode 100644
index 0000000000..f66a483e6e
--- /dev/null
+++ b/tmk_core/protocol/lufa/LUFA-git/Bootloaders/CDC/BootloaderCDC.c
@@ -0,0 +1,641 @@
+/*
+ LUFA Library
+ Copyright (C) Dean Camera, 2014.
+
+ dean [at] fourwalledcubicle [dot] com
+ www.lufa-lib.org
+*/
+
+/*
+ Copyright 2014 Dean Camera (dean [at] fourwalledcubicle [dot] com)
+
+ Permission to use, copy, modify, distribute, and sell this
+ software and its documentation for any purpose is hereby granted
+ without fee, provided that the above copyright notice appear in
+ all copies and that both that the copyright notice and this
+ permission notice and warranty disclaimer appear in supporting
+ documentation, and that the name of the author not be used in
+ advertising or publicity pertaining to distribution of the
+ software without specific, written prior permission.
+
+ The author disclaims all warranties with regard to this
+ software, including all implied warranties of merchantability
+ and fitness. In no event shall the author be liable for any
+ special, indirect or consequential damages or any damages
+ whatsoever resulting from loss of use, data or profits, whether
+ in an action of contract, negligence or other tortious action,
+ arising out of or in connection with the use or performance of
+ this software.
+*/
+
+/** \file
+ *
+ * Main source file for the CDC class bootloader. This file contains the complete bootloader logic.
+ */
+
+#define INCLUDE_FROM_BOOTLOADERCDC_C
+#include "BootloaderCDC.h"
+
+/** Contains the current baud rate and other settings of the first virtual serial port. This must be retained as some
+ * operating systems will not open the port unless the settings can be set successfully.
+ */
+static CDC_LineEncoding_t LineEncoding = { .BaudRateBPS = 0,
+ .CharFormat = CDC_LINEENCODING_OneStopBit,
+ .ParityType = CDC_PARITY_None,
+ .DataBits = 8 };
+
+/** Current address counter. This stores the current address of the FLASH or EEPROM as set by the host,
+ * and is used when reading or writing to the AVRs memory (either FLASH or EEPROM depending on the issued
+ * command.)
+ */
+static uint32_t CurrAddress;
+
+/** Flag to indicate if the bootloader should be running, or should exit and allow the application code to run
+ * via a watchdog reset. When cleared the bootloader will exit, starting the watchdog and entering an infinite
+ * loop until the AVR restarts and the application runs.
+ */
+static bool RunBootloader = true;
+
+/** Magic lock for forced application start. If the HWBE fuse is programmed and BOOTRST is unprogrammed, the bootloader
+ * will start if the /HWB line of the AVR is held low and the system is reset. However, if the /HWB line is still held
+ * low when the application attempts to start via a watchdog reset, the bootloader will re-start. If set to the value
+ * \ref MAGIC_BOOT_KEY the special init function \ref Application_Jump_Check() will force the application to start.
+ */
+uint16_t MagicBootKey ATTR_NO_INIT;
+
+
+/** Special startup routine to check if the bootloader was started via a watchdog reset, and if the magic application
+ * start key has been loaded into \ref MagicBootKey. If the bootloader started via the watchdog and the key is valid,
+ * this will force the user application to start via a software jump.
+ */
+void Application_Jump_Check(void)
+{
+ bool JumpToApplication = false;
+
+ #if ((BOARD == BOARD_XPLAIN) || (BOARD == BOARD_XPLAIN_REV1))
+ /* Disable JTAG debugging */
+ JTAG_DISABLE();
+
+ /* Enable pull-up on the JTAG TCK pin so we can use it to select the mode */
+ PORTF |= (1 << 4);
+ Delay_MS(10);
+
+ /* If the TCK pin is not jumpered to ground, start the user application instead */
+ JumpToApplication |= ((PINF & (1 << 4)) != 0);
+
+ /* Re-enable JTAG debugging */
+ JTAG_ENABLE();
+ #endif
+
+ /* If the reset source was the bootloader and the key is correct, clear it and jump to the application */
+ if ((MCUSR & (1 << WDRF)) && (MagicBootKey == MAGIC_BOOT_KEY))
+ JumpToApplication |= true;
+
+ /* If a request has been made to jump to the user application, honor it */
+ if (JumpToApplication)
+ {
+ /* Turn off the watchdog */
+ MCUSR &= ~(1<<WDRF);
+ wdt_disable();
+
+ /* Clear the boot key and jump to the user application */
+ MagicBootKey = 0;
+
+ // cppcheck-suppress constStatement
+ ((void (*)(void))0x0000)();
+ }
+}
+
+/** Main program entry point. This routine configures the hardware required by the bootloader, then continuously
+ * runs the bootloader processing routine until instructed to soft-exit, or hard-reset via the watchdog to start
+ * the loaded application code.
+ */
+int main(void)
+{
+ /* Setup hardware required for the bootloader */
+ SetupHardware();
+
+ /* Turn on first LED on the board to indicate that the bootloader has started */
+ LEDs_SetAllLEDs(LEDS_LED1);
+
+ /* Enable global interrupts so that the USB stack can function */
+ GlobalInterruptEnable();
+
+ while (RunBootloader)
+ {
+ CDC_Task();
+ USB_USBTask();
+ }
+
+ /* Disconnect from the host - USB interface will be reset later along with the AVR */
+ USB_Detach();
+
+ /* Unlock the forced application start mode of the bootloader if it is restarted */
+ MagicBootKey = MAGIC_BOOT_KEY;
+
+ /* Enable the watchdog and force a timeout to reset the AVR */
+ wdt_enable(WDTO_250MS);
+
+ for (;;);
+}
+
+/** Configures all hardware required for the bootloader. */
+static void SetupHardware(void)
+{
+ /* Disable watchdog if enabled by bootloader/fuses */
+ MCUSR &= ~(1 << WDRF);
+ wdt_disable();
+
+ /* Disable clock division */
+ clock_prescale_set(clock_div_1);
+
+ /* Relocate the interrupt vector table to the bootloader section */
+ MCUCR = (1 << IVCE);
+ MCUCR = (1 << IVSEL);
+
+ /* Initialize the USB and other board hardware drivers */
+ USB_Init();
+ LEDs_Init();
+
+ /* Bootloader active LED toggle timer initialization */
+ TIMSK1 = (1 << TOIE1);
+ TCCR1B = ((1 << CS11) | (1 << CS10));
+}
+
+/** ISR to periodically toggle the LEDs on the board to indicate that the bootloader is active. */
+ISR(TIMER1_OVF_vect, ISR_BLOCK)
+{
+ LEDs_ToggleLEDs(LEDS_LED1 | LEDS_LED2);
+}
+
+/** Event handler for the USB_ConfigurationChanged event. This configures the device's endpoints ready
+ * to relay data to and from the attached USB host.
+ */
+void EVENT_USB_Device_ConfigurationChanged(void)
+{
+ /* Setup CDC Notification, Rx and Tx Endpoints */
+ Endpoint_ConfigureEndpoint(CDC_NOTIFICATION_EPADDR, EP_TYPE_INTERRUPT,
+ CDC_NOTIFICATION_EPSIZE, 1);
+
+ Endpoint_ConfigureEndpoint(CDC_TX_EPADDR, EP_TYPE_BULK, CDC_TXRX_EPSIZE, 1);
+
+ Endpoint_ConfigureEndpoint(CDC_RX_EPADDR, EP_TYPE_BULK, CDC_TXRX_EPSIZE, 1);
+}
+
+/** Event handler for the USB_ControlRequest event. This is used to catch and process control requests sent to