LUFA Library - Mass Storage Class Bootloader
|
#include "BootloaderMassStorage.h"
Functions | |
void | Application_Jump_Check (void) |
int | main (void) |
static void | SetupHardware (void) |
ISR (TIMER1_OVF_vect, ISR_BLOCK) | |
void | EVENT_USB_Device_Connect (void) |
void | EVENT_USB_Device_Disconnect (void) |
void | EVENT_USB_Device_ConfigurationChanged (void) |
void | EVENT_USB_Device_ControlRequest (void) |
bool | CALLBACK_MS_Device_SCSICommandReceived (USB_ClassInfo_MS_Device_t *const MSInterfaceInfo) |
Variables | |
USB_ClassInfo_MS_Device_t | Disk_MS_Interface |
bool | RunBootloader = true |
uint16_t | MagicBootKey |
static uint8_t | TicksSinceLastCommand = 0 |
Main source file for the Mass Storage class bootloader. This file contains the complete bootloader logic.
void Application_Jump_Check | ( | void | ) |
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 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.
bool CALLBACK_MS_Device_SCSICommandReceived | ( | USB_ClassInfo_MS_Device_t *const | MSInterfaceInfo) |
Mass Storage class driver callback function the reception of SCSI commands from the host, which must be processed.
[in] | MSInterfaceInfo | Pointer to the Mass Storage class interface configuration structure being referenced |
void EVENT_USB_Device_ConfigurationChanged | ( | void | ) |
Event handler for the library USB Configuration Changed event.
void EVENT_USB_Device_Connect | ( | void | ) |
Event handler for the USB_Connect event. This indicates that the device is enumerating via the status LEDs.
void EVENT_USB_Device_ControlRequest | ( | void | ) |
Event handler for the library USB Control Request reception event.
void EVENT_USB_Device_Disconnect | ( | void | ) |
Event handler for the USB_Disconnect event. This indicates that the device is no longer connected to a host via the status LEDs and stops the Mass Storage management task.
ISR | ( | TIMER1_OVF_vect | , |
ISR_BLOCK | |||
) |
ISR to periodically toggle the LEDs on the board to indicate that the bootloader is active.
int main | ( | void | ) |
Main program entry point. This routine configures the hardware required by the application, then enters a loop to run the application tasks in sequence.
|
static |
Configures the board hardware and chip peripherals for the demo's functionality.
USB_ClassInfo_MS_Device_t Disk_MS_Interface |
LUFA Mass Storage Class driver interface configuration and state information. This structure is passed to all Mass Storage Class driver functions, so that multiple instances of the same class within a device can be differentiated from one another.
uint16_t MagicBootKey |
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 MAGIC_BOOT_KEY the special init function Application_Jump_Check() will force the application to start.
bool RunBootloader = true |
Flag to indicate if the bootloader should be running, or should exit and allow the application code to run via a soft reset. When cleared, the bootloader will abort, the USB interface will shut down and the application started via a forced watchdog reset.
|
static |
Indicates if the bootloader is allowed to exit immediately if RunBootloader is false
. During shutdown all pending commands must be processed before jumping to the user-application, thus this tracks the main program loop iterations since a SCSI command from the host was received.