LUFA Library - CDC Class Bootloader
BootloaderCDC.h File Reference
#include <avr/io.h>
#include <avr/wdt.h>
#include <avr/boot.h>
#include <avr/eeprom.h>
#include <avr/power.h>
#include <avr/interrupt.h>
#include <stdbool.h>
#include "Descriptors.h"
#include "BootloaderAPI.h"
#include "Config/AppConfig.h"
#include <LUFA/Drivers/USB/USB.h>
#include <LUFA/Drivers/Board/LEDs.h>
#include <LUFA/Platform/Platform.h>

Macros

#define BOOTLOADER_VERSION_MAJOR   0x01
 
#define BOOTLOADER_VERSION_MINOR   0x00
 
#define BOOTLOADER_HWVERSION_MAJOR   0x01
 
#define BOOTLOADER_HWVERSION_MINOR   0x00
 
#define SOFTWARE_IDENTIFIER   "LUFACDC"
 
#define MAGIC_BOOT_KEY   0xDC42
 

Typedefs

typedef void(* AppPtr_t )(void) ATTR_NO_RETURN
 

Enumerations

enum  AVR109_Memories {
  MEMORY_TYPE_FLASH = 'F',
  MEMORY_TYPE_EEPROM = 'E'
}
 
enum  AVR109_Commands {
  AVR109_COMMAND_Sync = 27,
  AVR109_COMMAND_ReadEEPROM = 'd',
  AVR109_COMMAND_WriteEEPROM = 'D',
  AVR109_COMMAND_ReadFLASHWord = 'R',
  AVR109_COMMAND_WriteFlashPage = 'm',
  AVR109_COMMAND_FillFlashPageWordLow = 'c',
  AVR109_COMMAND_FillFlashPageWordHigh = 'C',
  AVR109_COMMAND_GetBlockWriteSupport = 'b',
  AVR109_COMMAND_BlockWrite = 'B',
  AVR109_COMMAND_BlockRead = 'g',
  AVR109_COMMAND_ReadExtendedFuses = 'Q',
  AVR109_COMMAND_ReadHighFuses = 'N',
  AVR109_COMMAND_ReadLowFuses = 'F',
  AVR109_COMMAND_ReadLockbits = 'r',
  AVR109_COMMAND_WriteLockbits = 'l',
  AVR109_COMMAND_EraseFLASH = 'e',
  AVR109_COMMAND_ReadSignature = 's',
  AVR109_COMMAND_ReadBootloaderSWVersion = 'V',
  AVR109_COMMAND_ReadBootloaderHWVersion = 'v',
  AVR109_COMMAND_ReadBootloaderIdentifier = 'S',
  AVR109_COMMAND_ReadBootloaderInterface = 'p',
  AVR109_COMMAND_SetCurrentAddress = 'A',
  AVR109_COMMAND_ReadAutoAddressIncrement = 'a',
  AVR109_COMMAND_ReadPartCode = 't',
  AVR109_COMMAND_EnterProgrammingMode = 'P',
  AVR109_COMMAND_LeaveProgrammingMode = 'L',
  AVR109_COMMAND_SelectDeviceType = 'T',
  AVR109_COMMAND_SetLED = 'x',
  AVR109_COMMAND_ClearLED = 'y',
  AVR109_COMMAND_ExitBootloader = 'E'
}
 

Functions

static void CDC_Task (void)
 
static void SetupHardware (void)
 
void Application_Jump_Check (void) ATTR_INIT_SECTION(3)
 
void EVENT_USB_Device_ConfigurationChanged (void)
 
static void ReadWriteMemoryBlock (const uint8_t Command)
 
static uint8_t FetchNextCommandByte (void)
 
static void WriteNextResponseByte (const uint8_t Response)
 

Detailed Description

Header file for BootloaderCDC.c.

Macro Definition Documentation

#define BOOTLOADER_HWVERSION_MAJOR   0x01

Hardware version major of the CDC bootloader.

#define BOOTLOADER_HWVERSION_MINOR   0x00

Hardware version minor of the CDC bootloader.

#define BOOTLOADER_VERSION_MAJOR   0x01

Version major of the CDC bootloader.

#define BOOTLOADER_VERSION_MINOR   0x00

Version minor of the CDC bootloader.

#define MAGIC_BOOT_KEY   0xDC42

Magic bootloader key to unlock forced application start mode.

#define SOFTWARE_IDENTIFIER   "LUFACDC"

Eight character bootloader firmware identifier reported to the host when requested.

Typedef Documentation

typedef void(* AppPtr_t)(void) ATTR_NO_RETURN

Type define for a non-returning pointer to the start of the loaded application in flash memory.

Enumeration Type Documentation

Possible commands that can be issued to the bootloader.

Enumerator
AVR109_COMMAND_Sync 
AVR109_COMMAND_ReadEEPROM 
AVR109_COMMAND_WriteEEPROM 
AVR109_COMMAND_ReadFLASHWord 
AVR109_COMMAND_WriteFlashPage 
AVR109_COMMAND_FillFlashPageWordLow 
AVR109_COMMAND_FillFlashPageWordHigh 
AVR109_COMMAND_GetBlockWriteSupport 
AVR109_COMMAND_BlockWrite 
AVR109_COMMAND_BlockRead 
AVR109_COMMAND_ReadExtendedFuses 
AVR109_COMMAND_ReadHighFuses 
AVR109_COMMAND_ReadLowFuses 
AVR109_COMMAND_ReadLockbits 
AVR109_COMMAND_WriteLockbits 
AVR109_COMMAND_EraseFLASH 
AVR109_COMMAND_ReadSignature 
AVR109_COMMAND_ReadBootloaderSWVersion 
AVR109_COMMAND_ReadBootloaderHWVersion 
AVR109_COMMAND_ReadBootloaderIdentifier 
AVR109_COMMAND_ReadBootloaderInterface 
AVR109_COMMAND_SetCurrentAddress 
AVR109_COMMAND_ReadAutoAddressIncrement 
AVR109_COMMAND_ReadPartCode 
AVR109_COMMAND_EnterProgrammingMode 
AVR109_COMMAND_LeaveProgrammingMode 
AVR109_COMMAND_SelectDeviceType 
AVR109_COMMAND_SetLED 
AVR109_COMMAND_ClearLED 
AVR109_COMMAND_ExitBootloader 

Possible memory types that can be addressed via the bootloader.

Enumerator
MEMORY_TYPE_FLASH 
MEMORY_TYPE_EEPROM 

Function Documentation

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.

static void CDC_Task ( void  )
static
void EVENT_USB_Device_ConfigurationChanged ( void  )

Event handler for the USB_ConfigurationChanged event. This configures the device's endpoints ready to relay data to and from the attached USB host.

static uint8_t FetchNextCommandByte ( void  )
static
static void ReadWriteMemoryBlock ( const uint8_t  Command)
static
static void SetupHardware ( void  )
static
static void WriteNextResponseByte ( const uint8_t  Response)
static