Be doubly-certain that the incomming CDC class driver's endpoint/pipe is flushed...
[pub/USBasp.git] / Bootloaders / DFU / BootloaderDFU.h
index 21e8fce..ca53266 100644 (file)
@@ -1,21 +1,21 @@
 /*\r
              LUFA Library\r
-     Copyright (C) Dean Camera, 2009.\r
+     Copyright (C) Dean Camera, 2010.\r
               \r
   dean [at] fourwalledcubicle [dot] com\r
       www.fourwalledcubicle.com\r
 */\r
 \r
 /*\r
-  Copyright 2009  Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
-\r
-  Permission to use, copy, modify, and distribute this software\r
-  and its documentation for any purpose and without fee is hereby\r
-  granted, provided that the above copyright notice appear in all\r
-  copies and that both that the copyright notice and this\r
-  permission notice and warranty disclaimer appear in supporting\r
-  documentation, and that the name of the author not be used in\r
-  advertising or publicity pertaining to distribution of the\r
+  Copyright 2010  Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+  Permission to use, copy, modify, distribute, and sell this \r
+  software and its documentation for any purpose is hereby granted\r
+  without fee, provided that the above copyright notice appear in \r
+  all copies and that both that the copyright notice and this\r
+  permission notice and warranty disclaimer appear in supporting \r
+  documentation, and that the name of the author not be used in \r
+  advertising or publicity pertaining to distribution of the \r
   software without specific, written prior permission.\r
 \r
   The author disclaim all warranties with regard to this\r
        \r
                #include "Descriptors.h"\r
                \r
-               #include <LUFA/Drivers/USB/USB.h>                // USB Functionality\r
-               \r
+               #include <LUFA/Drivers/USB/USB.h>\r
+       \r
        /* Macros: */\r
+               /** Configuration define. Define this token to true to case the bootloader to reject all memory commands\r
+                *  until a memory erase has been performed. When used in conjunction with the lockbits of the AVR, this\r
+                *  can protect the AVR's firmware from being dumped from a secured AVR. When false, memory operations are\r
+                *  allowed at any time.\r
+                */\r
+               #define SECURE_MODE              false\r
+\r
                /** Major bootloader version number. */\r
                #define BOOTLOADER_VERSION_MINOR 2\r
 \r
                /** Minor bootloader version number. */\r
                #define BOOTLOADER_VERSION_REV   0\r
 \r
-               /** Complete bootloder version number expressed as a packed byte, constructed from the \r
+               /** Complete bootloader version number expressed as a packed byte, constructed from the \r
                 *  two individual bootloader version macros.\r
                 */\r
                #define BOOTLOADER_VERSION       ((BOOTLOADER_VERSION_MINOR << 4) | BOOTLOADER_VERSION_REV)\r
                \r
                /** Convenience macro, used to determine if the issued command is the given one-byte long command.\r
                 *\r
-                *  \param dataarr  Command byte array to check against\r
-                *  \param cb1      First command byte to check\r
+                *  \param[in] dataarr  Command byte array to check against\r
+                *  \param[in] cb1      First command byte to check\r
                 */\r
-               #define IS_ONEBYTE_COMMAND(dataarr, cb1)       (dataarr[0] == cb1)\r
+               #define IS_ONEBYTE_COMMAND(dataarr, cb1)       (dataarr[0] == (cb1))\r
 \r
                /** Convenience macro, used to determine if the issued command is the given two-byte long command.\r
                 *\r
-                *  \param dataarr  Command byte array to check against\r
-                *  \param cb1      First command byte to check\r
-                *  \param cb2      Second command byte to check\r
+                *  \param[in] dataarr  Command byte array to check against\r
+                *  \param[in] cb1      First command byte to check\r
+                *  \param[in] cb2      Second command byte to check\r
                 */\r
-               #define IS_TWOBYTE_COMMAND(dataarr, cb1, cb2) ((dataarr[0] == cb1) && (dataarr[1] == cb2))\r
+               #define IS_TWOBYTE_COMMAND(dataarr, cb1, cb2) ((dataarr[0] == (cb1)) && (dataarr[1] == (cb2)))\r
        \r
                /** Length of the DFU file suffix block, appended to the end of each complete memory write command.\r
                 *  The DFU file suffix is currently unused (but is designed to give extra file information, such as\r
                 */\r
                #define DFU_FILLER_BYTES_SIZE    26\r
        \r
-               /** DFU class command request to detatch from the host. */\r
+               /** DFU class command request to detach from the host. */\r
                #define DFU_DETATCH              0x00\r
 \r
                /** DFU class command request to send data from the host to the bootloader. */\r
                /** Type define for a non-returning function pointer to the loaded application. */\r
                typedef void (*AppPtr_t)(void) ATTR_NO_RETURN;\r
                \r
-               /** Type define for a strucuture containing a complete DFU command issued by the host. */\r
+               /** Type define for a structure containing a complete DFU command issued by the host. */\r
                typedef struct\r
                {\r
                        uint8_t  Command; /**< Single byte command to perform, one of the COMMAND_* macro values */\r
                        errUNKNOWN                   = 14,\r
                        errSTALLEDPKT                = 15\r
                };\r
-               \r
-       /* Event Handlers: */\r
-               /** Indicates that this module will catch the USB_Disconnect event when thrown by the library. */\r
-               HANDLES_EVENT(USB_Disconnect);\r
-\r
-               /** Indicates that this module will catch the USB_UnhandledControlPacket event when thrown by the library. */\r
-               HANDLES_EVENT(USB_UnhandledControlPacket);\r
-               \r
+                               \r
        /* Function Prototypes: */\r
+               void SetupHardware(void);\r
+               void ResetHardware(void);\r
+\r
+               void EVENT_USB_Device_UnhandledControlRequest(void);\r
+\r
                #if defined(INCLUDE_FROM_BOOTLOADER_C)\r
                        static void DiscardFillerBytes(uint8_t NumberOfBytes);\r
                        static void ProcessBootloaderCommand(void);\r