Re-add in old Endpoint/Pipe workaround for unordered pipes - add new ORDERED_EP_CONFI...
[pub/USBasp.git] / Bootloaders / DFU / BootloaderDFU.h
index 43ea70f..3483958 100644 (file)
@@ -1,21 +1,21 @@
 /*
              LUFA Library
      Copyright (C) Dean Camera, 2010.
 /*
              LUFA Library
      Copyright (C) Dean Camera, 2010.
-              
+
   dean [at] fourwalledcubicle [dot] com
   dean [at] fourwalledcubicle [dot] com
-      www.fourwalledcubicle.com
+           www.lufa-lib.org
 */
 
 /*
   Copyright 2010  Dean Camera (dean [at] fourwalledcubicle [dot] com)
 
 */
 
 /*
   Copyright 2010  Dean Camera (dean [at] fourwalledcubicle [dot] com)
 
-  Permission to use, copy, modify, distribute, and sell this 
+  Permission to use, copy, modify, distribute, and sell this
   software and its documentation for any purpose is hereby granted
   software and its documentation for any purpose is hereby granted
-  without fee, provided that the above copyright notice appear in 
+  without fee, provided that the above copyright notice appear in
   all copies and that both that the copyright notice and this
   all copies and that both that the copyright notice and this
-  permission notice and warranty disclaimer appear in supporting 
-  documentation, and that the name of the author not be used in 
-  advertising or publicity pertaining to distribution of the 
+  permission notice and warranty disclaimer appear in supporting
+  documentation, and that the name of the author not be used in
+  advertising or publicity pertaining to distribution of the
   software without specific, written prior permission.
 
   The author disclaim all warranties with regard to this
   software without specific, written prior permission.
 
   The author disclaim all warranties with regard to this
                #include <avr/eeprom.h>
                #include <avr/power.h>
                #include <avr/interrupt.h>
                #include <avr/eeprom.h>
                #include <avr/power.h>
                #include <avr/interrupt.h>
+               #include <util/delay.h>
                #include <stdbool.h>
                #include <stdbool.h>
-       
+
                #include "Descriptors.h"
                #include "Descriptors.h"
-               
+
                #include <LUFA/Drivers/USB/USB.h>
                #include <LUFA/Drivers/USB/USB.h>
-       
+
        /* 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
        /* 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
@@ -64,7 +65,7 @@
                /** Minor bootloader version number. */
                #define BOOTLOADER_VERSION_REV   0
 
                /** Minor bootloader version number. */
                #define BOOTLOADER_VERSION_REV   0
 
-               /** Complete bootloader 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)
                 *  two individual bootloader version macros.
                 */
                #define BOOTLOADER_VERSION       ((BOOTLOADER_VERSION_MINOR << 4) | BOOTLOADER_VERSION_REV)
@@ -74,7 +75,7 @@
 
                /** Second byte of the bootloader identification bytes, used to identify a device's bootloader. */
                #define BOOTLOADER_ID_BYTE2      0xFB
 
                /** Second byte of the bootloader identification bytes, used to identify a device's bootloader. */
                #define BOOTLOADER_ID_BYTE2      0xFB
-               
+
                /** Convenience macro, used to determine if the issued command is the given one-byte long command.
                 *
                 *  \param[in] dataarr  Command byte array to check against
                /** Convenience macro, used to determine if the issued command is the given one-byte long command.
                 *
                 *  \param[in] dataarr  Command byte array to check against
@@ -89,7 +90,7 @@
                 *  \param[in] cb2      Second command byte to check
                 */
                #define IS_TWOBYTE_COMMAND(dataarr, cb1, cb2) ((dataarr[0] == (cb1)) && (dataarr[1] == (cb2)))
                 *  \param[in] cb2      Second command byte to check
                 */
                #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
                 *  a CRC of the complete firmware for error checking) and so is discarded.
                /** 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
                 *  a CRC of the complete firmware for error checking) and so is discarded.
                 *  Filler bytes are added to the start of each complete memory write command, and must be discarded.
                 */
                #define DFU_FILLER_BYTES_SIZE    26
                 *  Filler bytes are added to the start of each complete memory write command, and must be discarded.
                 */
                #define DFU_FILLER_BYTES_SIZE    26
-       
+
                /** DFU class command request to detach from the host. */
                /** DFU class command request to detach from the host. */
-               #define DFU_DETATCH              0x00
+               #define REQ_DFU_DETATCH          0x00
 
                /** DFU class command request to send data from the host to the bootloader. */
 
                /** DFU class command request to send data from the host to the bootloader. */
-               #define DFU_DNLOAD               0x01
+               #define REQ_DFU_DNLOAD           0x01
 
                /** DFU class command request to send data from the bootloader to the host. */
 
                /** DFU class command request to send data from the bootloader to the host. */
-               #define DFU_UPLOAD               0x02
+               #define REQ_DFU_UPLOAD           0x02
 
                /** DFU class command request to get the current DFU status and state from the bootloader. */
 
                /** DFU class command request to get the current DFU status and state from the bootloader. */
-               #define DFU_GETSTATUS            0x03
+               #define REQ_DFU_GETSTATUS        0x03
 
                /** DFU class command request to reset the current DFU status and state variables to their defaults. */
 
                /** DFU class command request to reset the current DFU status and state variables to their defaults. */
-               #define DFU_CLRSTATUS            0x04
+               #define REQ_DFU_CLRSTATUS        0x04
 
                /** DFU class command request to get the current DFU state of the bootloader. */
 
                /** DFU class command request to get the current DFU state of the bootloader. */
-               #define DFU_GETSTATE             0x05
+               #define REQ_DFU_GETSTATE         0x05
 
                /** DFU class command request to abort the current multi-request transfer and return to the dfuIDLE state. */
 
                /** DFU class command request to abort the current multi-request transfer and return to the dfuIDLE state. */
-               #define DFU_ABORT                0x06
+               #define REQ_DFU_ABORT            0x06
 
                /** DFU command to begin programming the device's memory. */
                #define COMMAND_PROG_START       0x01
 
                /** DFU command to begin programming the device's memory. */
                #define COMMAND_PROG_START       0x01
        /* Type Defines: */
                /** Type define for a non-returning function pointer to the loaded application. */
                typedef void (*AppPtr_t)(void) ATTR_NO_RETURN;
        /* Type Defines: */
                /** Type define for a non-returning function pointer to the loaded application. */
                typedef void (*AppPtr_t)(void) ATTR_NO_RETURN;
-               
+
                /** Type define for a structure containing a complete DFU command issued by the host. */
                typedef struct
                {
                /** Type define for a structure containing a complete DFU command issued by the host. */
                typedef struct
                {
                        errUNKNOWN                   = 14,
                        errSTALLEDPKT                = 15
                };
                        errUNKNOWN                   = 14,
                        errSTALLEDPKT                = 15
                };
-                               
+
        /* Function Prototypes: */
                void SetupHardware(void);
                void ResetHardware(void);
 
        /* Function Prototypes: */
                void SetupHardware(void);
                void ResetHardware(void);
 
-               void EVENT_USB_Device_UnhandledControlRequest(void);
+               void EVENT_USB_Device_ControlRequest(void);
 
                #if defined(INCLUDE_FROM_BOOTLOADER_C)
                        static void DiscardFillerBytes(uint8_t NumberOfBytes);
 
                #if defined(INCLUDE_FROM_BOOTLOADER_C)
                        static void DiscardFillerBytes(uint8_t NumberOfBytes);
                        static void ProcessWriteCommand(void);
                        static void ProcessReadCommand(void);
                #endif
                        static void ProcessWriteCommand(void);
                        static void ProcessReadCommand(void);
                #endif
-               
+
 #endif
 #endif
+