3      Copyright (C) Dean Camera, 2014. 
   5   dean [at] fourwalledcubicle [dot] com 
  10   Copyright 2014  Dean Camera (dean [at] fourwalledcubicle [dot] com) 
  12   Permission to use, copy, modify, distribute, and sell this 
  13   software and its documentation for any purpose is hereby granted 
  14   without fee, provided that the above copyright notice appear in 
  15   all copies and that both that the copyright notice and this 
  16   permission notice and warranty disclaimer appear in supporting 
  17   documentation, and that the name of the author not be used in 
  18   advertising or publicity pertaining to distribution of the 
  19   software without specific, written prior permission. 
  21   The author disclaims all warranties with regard to this 
  22   software, including all implied warranties of merchantability 
  23   and fitness.  In no event shall the author be liable for any 
  24   special, indirect or consequential damages or any damages 
  25   whatsoever resulting from loss of use, data or profits, whether 
  26   in an action of contract, negligence or other tortious action, 
  27   arising out of or in connection with the use or performance of 
  33  *  Header file for Descriptors.c. 
  36 #ifndef _DESCRIPTORS_H_ 
  37 #define _DESCRIPTORS_H_ 
  40                 #include <LUFA/Drivers/USB/USB.h> 
  42                 #include "Config/AppConfig.h" 
  45                 /** Descriptor type value for a DFU class functional descriptor. */ 
  46                 #define DTYPE_DFUFunctional               0x21 
  48                 /** DFU attribute mask, indicating that the DFU device will detach and re-attach when a DFU_DETACH 
  49                  *  command is issued, rather than the host issuing a USB Reset. 
  51                 #define ATTR_WILL_DETATCH                 (1 << 3) 
  53                 /** DFU attribute mask, indicating that the DFU device can communicate during the manifestation phase 
  54                  *  (memory programming phase). 
  56                 #define ATTR_MANEFESTATION_TOLLERANT      (1 << 2) 
  58                 /** DFU attribute mask, indicating that the DFU device can accept DFU_UPLOAD requests to send data from 
  59                  *  the device to the host. 
  61                 #define ATTR_CAN_UPLOAD                   (1 << 1) 
  63                 /** DFU attribute mask, indicating that the DFU device can accept DFU_DNLOAD requests to send data from 
  64                  *  the host to the device. 
  66                 #define ATTR_CAN_DOWNLOAD                 (1 << 0) 
  68                 #if defined(__AVR_AT90USB1287__) 
  69                         #define PRODUCT_ID_CODE               0x2FFB 
  70                         #define AVR_SIGNATURE_1               0x1E 
  71                         #define AVR_SIGNATURE_2               0x97 
  72                         #define AVR_SIGNATURE_3               0x82 
  73                 #elif defined(__AVR_AT90USB647__) 
  74                         #define PRODUCT_ID_CODE               0x2FF9 
  75                         #define AVR_SIGNATURE_1               0x1E 
  76                         #define AVR_SIGNATURE_2               0x96 
  77                         #define AVR_SIGNATURE_3               0x82 
  78                 #elif defined(__AVR_AT90USB1286__) 
  79                         #define PRODUCT_ID_CODE               0x2FFB 
  80                         #define AVR_SIGNATURE_1               0x1E 
  81                         #define AVR_SIGNATURE_2               0x97 
  82                         #define AVR_SIGNATURE_3               0x82 
  83                 #elif defined(__AVR_AT90USB646__) 
  84                         #define PRODUCT_ID_CODE               0x2FF9 
  85                         #define AVR_SIGNATURE_1               0x1E 
  86                         #define AVR_SIGNATURE_2               0x96 
  87                         #define AVR_SIGNATURE_3               0x82 
  88                 #elif defined(__AVR_ATmega32U4__) 
  89                         #define PRODUCT_ID_CODE               0x2FF4 
  90                         #define AVR_SIGNATURE_1               0x1E 
  91                         #define AVR_SIGNATURE_2               0x95 
  92                         #define AVR_SIGNATURE_3               0x87 
  93                 #elif defined(__AVR_ATmega16U4__) 
  94                         #define PRODUCT_ID_CODE               0x2FF3 
  95                         #define AVR_SIGNATURE_1               0x1E 
  96                         #define AVR_SIGNATURE_2               0x94 
  97                         #define AVR_SIGNATURE_3               0x88 
  98                 #elif defined(__AVR_ATmega32U2__) 
  99                         #define PRODUCT_ID_CODE               0x2FF0 
 100                         #define AVR_SIGNATURE_1               0x1E 
 101                         #define AVR_SIGNATURE_2               0x95 
 102                         #define AVR_SIGNATURE_3               0x8A 
 103                 #elif defined(__AVR_ATmega16U2__) 
 104                         #define PRODUCT_ID_CODE               0x2FEF 
 105                         #define AVR_SIGNATURE_1               0x1E 
 106                         #define AVR_SIGNATURE_2               0x94 
 107                         #define AVR_SIGNATURE_3               0x89 
 108                 #elif defined(__AVR_AT90USB162__) 
 109                         #define PRODUCT_ID_CODE               0x2FFA 
 110                         #define AVR_SIGNATURE_1               0x1E 
 111                         #define AVR_SIGNATURE_2               0x94 
 112                         #define AVR_SIGNATURE_3               0x82 
 113                 #elif defined(__AVR_ATmega8U2__) 
 114                         #define PRODUCT_ID_CODE               0x2FEE 
 115                         #define AVR_SIGNATURE_1               0x1E 
 116                         #define AVR_SIGNATURE_2               0x93 
 117                         #define AVR_SIGNATURE_3               0x89 
 118                 #elif defined(__AVR_AT90USB82__) 
 119                         #define PRODUCT_ID_CODE               0x2FF7 
 120                         #define AVR_SIGNATURE_1               0x1E 
 121                         #define AVR_SIGNATURE_2               0x94 
 122                         #define AVR_SIGNATURE_3               0x82 
 124                         #error The selected AVR part is not currently supported by this bootloader. 
 127                 #if !defined(PRODUCT_ID_CODE) 
 128                         #error Current AVR model is not supported by this bootloader. 
 132                 /** Type define for a DFU class function descriptor. This descriptor gives DFU class information 
 133                  *  to the host when read, indicating the DFU device's capabilities. 
 137                         USB_Descriptor_Header_t Header
; /**< Standard descriptor header structure */ 
 139                         uint8_t                 Attributes
; /**< DFU device attributes, a mask comprising of the 
 140                                                              *  ATTR_* macros listed in this source file 
 142                         uint16_t                DetachTimeout
; /**< Timeout in milliseconds between a USB_DETACH 
 143                                                                 *  command being issued and the device detaching 
 146                         uint16_t                TransferSize
; /**< Maximum number of bytes the DFU device can accept 
 147                                                                *  from the host in a transaction 
 149                         uint16_t                DFUSpecification
; /**< BCD packed DFU specification number this DFU 
 150                                                                    *  device complies with 
 152                 } USB_Descriptor_DFU_Functional_t
; 
 154                 /** Type define for the device configuration descriptor structure. This must be defined in the 
 155                  *  application code, as the configuration descriptor contains several sub-descriptors which 
 156                  *  vary between devices, and which describe the device's usage to the host. 
 160                         USB_Descriptor_Configuration_Header_t Config
; 
 163                         USB_Descriptor_Interface_t            DFU_Interface
; 
 164                         USB_Descriptor_DFU_Functional_t       DFU_Functional
; 
 165                 } USB_Descriptor_Configuration_t
; 
 167                 /** Enum for the device interface descriptor IDs within the device. Each interface descriptor 
 168                  *  should have a unique ID index associated with it, which can be used to refer to the 
 169                  *  interface from other descriptors. 
 171                 enum InterfaceDescriptors_t
 
 173                         INTERFACE_ID_DFU 
= 0, /**< DFU interface descriptor ID */ 
 176                 /** Enum for the device string descriptor IDs within the device. Each string descriptor should 
 177                  *  have a unique ID index associated with it, which can be used to refer to the string from 
 180                 enum StringDescriptors_t
 
 182                         STRING_ID_Language     
= 0, /**< Supported Languages string descriptor ID (must be zero) */ 
 183                         STRING_ID_Manufacturer 
= 1, /**< Manufacturer string ID */ 
 184                         STRING_ID_Product      
= 2, /**< Product string ID */ 
 187         /* Function Prototypes: */ 
 188                 uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue
, 
 189                                                     const uint8_t wIndex
, 
 190                                                     const void** const DescriptorAddress
) 
 191                                                     ATTR_WARN_UNUSED_RESULT 
ATTR_NON_NULL_PTR_ARG(3);