X-Git-Url: http://git.linex4red.de/pub/USBasp.git/blobdiff_plain/d711e37d2f10f8df9a9ffdf974935c1f1d0a7906..18b0d408a9e68cbc1ce36da89d74a799d7fc31de:/Bootloaders/DFU/BootloaderDFU.h diff --git a/Bootloaders/DFU/BootloaderDFU.h b/Bootloaders/DFU/BootloaderDFU.h index b90fee13f..aac341f8c 100644 --- a/Bootloaders/DFU/BootloaderDFU.h +++ b/Bootloaders/DFU/BootloaderDFU.h @@ -42,20 +42,28 @@ #include #include #include + #include #include #include "Descriptors.h" - #include // USB Functionality - + #include + /* Macros: */ + /** Configuration define. Define this token to true to case the bootloader to reject all memory commands + * until a memory erase has been performed. When used in conjunction with the lockbits of the AVR, this + * can protect the AVR's firmware from being dumped from a secured AVR. When false, memory operations are + * allowed at any time. + */ + #define SECURE_MODE false + /** Major bootloader version number. */ #define BOOTLOADER_VERSION_MINOR 2 /** Minor bootloader version number. */ #define BOOTLOADER_VERSION_REV 0 - /** Complete bootloder version number expressed as a packed byte, constructed from the + /** Complete bootloader version number expressed as a packed byte, constructed from the * two individual bootloader version macros. */ #define BOOTLOADER_VERSION ((BOOTLOADER_VERSION_MINOR << 4) | BOOTLOADER_VERSION_REV) @@ -68,18 +76,18 @@ /** Convenience macro, used to determine if the issued command is the given one-byte long command. * - * \param dataarr Command byte array to check against - * \param cb1 First command byte to check + * \param[in] dataarr Command byte array to check against + * \param[in] cb1 First command byte to check */ - #define IS_ONEBYTE_COMMAND(dataarr, cb1) (dataarr[0] == cb1) + #define IS_ONEBYTE_COMMAND(dataarr, cb1) (dataarr[0] == (cb1)) /** Convenience macro, used to determine if the issued command is the given two-byte long command. * - * \param dataarr Command byte array to check against - * \param cb1 First command byte to check - * \param cb2 Second command byte to check + * \param[in] dataarr Command byte array to check against + * \param[in] cb1 First command byte to check + * \param[in] cb2 Second command byte to check */ - #define IS_TWOBYTE_COMMAND(dataarr, cb1, cb2) ((dataarr[0] == cb1) && (dataarr[1] == cb2)) + #define IS_TWOBYTE_COMMAND(dataarr, cb1, cb2) ((dataarr[0] == (cb1)) && (dataarr[1] == (cb2))) /** Length of the DFU file suffix block, appended to the end of each complete memory write command. * The DFU file suffix is currently unused (but is designed to give extra file information, such as @@ -92,7 +100,7 @@ */ #define DFU_FILLER_BYTES_SIZE 26 - /** DFU class command request to detatch from the host. */ + /** DFU class command request to detach from the host. */ #define DFU_DETATCH 0x00 /** DFU class command request to send data from the host to the bootloader. */ @@ -133,7 +141,7 @@ /** Type define for a non-returning function pointer to the loaded application. */ typedef void (*AppPtr_t)(void) ATTR_NO_RETURN; - /** Type define for a strucuture containing a complete DFU command issued by the host. */ + /** Type define for a structure containing a complete DFU command issued by the host. */ typedef struct { uint8_t Command; /**< Single byte command to perform, one of the COMMAND_* macro values */ @@ -178,15 +186,13 @@ errUNKNOWN = 14, errSTALLEDPKT = 15 }; - - /* Event Handlers: */ - /** Indicates that this module will catch the USB_Disconnect event when thrown by the library. */ - HANDLES_EVENT(USB_Disconnect); - - /** Indicates that this module will catch the USB_UnhandledControlPacket event when thrown by the library. */ - HANDLES_EVENT(USB_UnhandledControlPacket); - + /* Function Prototypes: */ + void SetupHardware(void); + void ResetHardware(void); + + void EVENT_USB_Device_UnhandledControlRequest(void); + #if defined(INCLUDE_FROM_BOOTLOADER_C) static void DiscardFillerBytes(uint8_t NumberOfBytes); static void ProcessBootloaderCommand(void);