123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144 |
- #ifndef _CDC_H_
- #define _CDC_H_
-
- #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>
-
- #if !defined(__OPTIMIZE_SIZE__)
- #error This bootloader requires that it be optimized for size, not speed, to fit into the target device. Change optimization settings and try again.
- #endif
-
-
- #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
-
-
- 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',
- };
-
-
- typedef void (*AppPtr_t)(void) ATTR_NO_RETURN;
-
- static void CDC_Task(void);
- static void SetupHardware(void);
- void Application_Jump_Check(void) ATTR_INIT_SECTION(3);
- void EVENT_USB_Device_ConfigurationChanged(void);
- #if defined(INCLUDE_FROM_BOOTLOADERCDC_C) || defined(__DOXYGEN__)
- #if !defined(NO_BLOCK_SUPPORT)
- static void ReadWriteMemoryBlock(const uint8_t Command);
- #endif
- static uint8_t FetchNextCommandByte(void);
- static void WriteNextResponseByte(const uint8_t Response);
- #endif
- #endif
|