Statistics
| Branch: | Revision:

root / arduino-1.0 / hardware / arduino / firmwares / arduino-usbdfu / Descriptors.h @ 58d82c77

History | View | Annotate | Download (7.59 KB)

1
/*
2
             LUFA Library
3
     Copyright (C) Dean Camera, 2010.
4
              
5
  dean [at] fourwalledcubicle [dot] com
6
      www.fourwalledcubicle.com
7
*/
8

    
9
/*
10
  Copyright 2010  Dean Camera (dean [at] fourwalledcubicle [dot] com)
11

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.
20

21
  The author disclaim 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
28
  this software.
29
*/
30

    
31
/** \file
32
 *
33
 *  Header file for Descriptors.c.
34
 */
35

    
36
#ifndef _DESCRIPTORS_H_
37
#define _DESCRIPTORS_H_
38

    
39
        /* Includes: */
40
                #include <LUFA/Drivers/USB/USB.h>
41
                
42
        /* Product-specific definitions: */
43
                #define ARDUINO_UNO_PID                                0x0001
44
                #define ARDUINO_MEGA2560_PID                0x0010                
45

    
46
        /* Macros: */
47
                /** Descriptor type value for a DFU class functional descriptor. */
48
                #define DTYPE_DFUFunctional               0x21
49
                
50
                /** DFU attribute mask, indicating that the DFU device will detach and re-attach when a DFU_DETACH
51
                 *  command is issued, rather than the host issuing a USB Reset.
52
                 */
53
                #define ATTR_WILL_DETATCH                 (1 << 3)
54

    
55
                /** DFU attribute mask, indicating that the DFU device can communicate during the manifestation phase
56
                 *  (memory programming phase).
57
                 */
58
                #define ATTR_MANEFESTATION_TOLLERANT      (1 << 2)
59
                
60
                /** DFU attribute mask, indicating that the DFU device can accept DFU_UPLOAD requests to send data from
61
                 *  the device to the host.
62
                 */                
63
                #define ATTR_CAN_UPLOAD                   (1 << 1)
64

    
65
                /** DFU attribute mask, indicating that the DFU device can accept DFU_DNLOAD requests to send data from
66
                 *  the host to the device.
67
                 */                
68
                #define ATTR_CAN_DOWNLOAD                 (1 << 0)
69

    
70
                #if defined(__AVR_AT90USB1287__)
71
                        #define PRODUCT_ID_CODE               0x2FFB
72
                        #define AVR_SIGNATURE_1               0x1E
73
                        #define AVR_SIGNATURE_2               0x97
74
                        #define AVR_SIGNATURE_3               0x82
75
                #elif defined(__AVR_AT90USB1286__)
76
                        #define PRODUCT_ID_CODE               0x2FFB
77
                        #define AVR_SIGNATURE_1               0x1E
78
                        #define AVR_SIGNATURE_2               0x97
79
                        #define AVR_SIGNATURE_3               0x82
80
                #elif defined(__AVR_AT90USB647__)
81
                        #define PRODUCT_ID_CODE               0x2FF9
82
                        #define AVR_SIGNATURE_1               0x1E
83
                        #define AVR_SIGNATURE_2               0x96
84
                        #define AVR_SIGNATURE_3               0x82
85
                #elif defined(__AVR_AT90USB646__)
86
                        #define PRODUCT_ID_CODE               0x2FF9
87
                        #define AVR_SIGNATURE_1               0x1E
88
                        #define AVR_SIGNATURE_2               0x96
89
                        #define AVR_SIGNATURE_3               0x82
90
                #elif defined(__AVR_ATmega32U6__)
91
                        #define PRODUCT_ID_CODE               0x2FFB
92
                        #define AVR_SIGNATURE_1               0x1E
93
                        #define AVR_SIGNATURE_2               0x95
94
                        #define AVR_SIGNATURE_3               0x88
95
                #elif defined(__AVR_ATmega32U4__)
96
                        #define PRODUCT_ID_CODE               0x2FF4
97
                        #define AVR_SIGNATURE_1               0x1E
98
                        #define AVR_SIGNATURE_2               0x95
99
                        #define AVR_SIGNATURE_3               0x87
100
                #elif defined(__AVR_ATmega32U2__)
101
                        #define PRODUCT_ID_CODE               0x2FF0
102
                        #define AVR_SIGNATURE_1               0x1E
103
                        #define AVR_SIGNATURE_2               0x95
104
                        #define AVR_SIGNATURE_3               0x8A
105
                #elif defined(__AVR_ATmega16U4__)
106
                        #define PRODUCT_ID_CODE               0x2FF3
107
                        #define AVR_SIGNATURE_1               0x1E
108
                        #define AVR_SIGNATURE_2               0x94
109
                        #define AVR_SIGNATURE_3               0x88
110
                #elif defined(__AVR_ATmega16U2__)
111
                        #define PRODUCT_ID_CODE               0x2FEF
112
                        #define AVR_SIGNATURE_1               0x1E
113
                        #define AVR_SIGNATURE_2               0x94
114
                        #define AVR_SIGNATURE_3               0x89
115
                #elif defined(__AVR_AT90USB162__)
116
                        #define PRODUCT_ID_CODE               0x2FFA
117
                        #define AVR_SIGNATURE_1               0x1E
118
                        #define AVR_SIGNATURE_2               0x94
119
                        #define AVR_SIGNATURE_3               0x82
120
                #elif defined(__AVR_AT90USB82__)
121
                        #define PRODUCT_ID_CODE               0x2FEE
122
                        #define AVR_SIGNATURE_1               0x1E
123
                        #define AVR_SIGNATURE_2               0x93
124
                        #define AVR_SIGNATURE_3               0x89
125
                #elif defined(__AVR_ATmega8U2__)
126
                        #define PRODUCT_ID_CODE               0x2FF7
127
                        #define AVR_SIGNATURE_1               0x1E
128
                        #define AVR_SIGNATURE_2               0x93
129
                        #define AVR_SIGNATURE_3               0x82
130
                #else
131
                        #error The selected AVR part is not currently supported by this bootloader.
132
                #endif
133
                
134
                #if !defined(PRODUCT_ID_CODE)
135
                        #error Current AVR model is not supported by this bootloader.
136
                #endif
137
        
138
        /* Type Defines: */
139
                /** Type define for a DFU class function descriptor. This descriptor gives DFU class information
140
                 *  to the host when read, indicating the DFU device's capabilities.
141
                 */
142
                typedef struct
143
                {
144
                        USB_Descriptor_Header_t               Header; /**< Standard descriptor header structure */
145
                        
146
                        uint8_t                               Attributes; /**< DFU device attributes, a mask comprising of the
147
                                                                            *  ATTR_* macros listed in this source file
148
                                                                            */
149
                        uint16_t                              DetachTimeout; /**< Timeout in milliseconds between a USB_DETACH
150
                                                                                *  command being issued and the device detaching
151
                                                                                *  from the USB bus
152
                                                                                */                                                                                                                                        
153
                        uint16_t                              TransferSize; /**< Maximum number of bytes the DFU device can accept
154
                                                                              *  from the host in a transaction
155
                                                                              */                        
156
                        uint16_t                              DFUSpecification;        /**< BCD packed DFU specification number this DFU
157
                                                                                  *  device complies with
158
                                                                                  */
159
                } USB_DFU_Functional_Descriptor_t;
160
        
161
                /** Type define for the device configuration descriptor structure. This must be defined in the
162
                 *  application code, as the configuration descriptor contains several sub-descriptors which
163
                 *  vary between devices, and which describe the device's usage to the host.
164
                 */
165
                typedef struct
166
                {
167
                        USB_Descriptor_Configuration_Header_t Config;
168
                        USB_Descriptor_Interface_t            DFU_Interface;
169
                        USB_DFU_Functional_Descriptor_t       DFU_Functional;
170
                } USB_Descriptor_Configuration_t;
171
                
172
        /* Function Prototypes: */
173
                uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue,
174
                                                    const uint8_t wIndex,
175
                                                    void** const DescriptorAddress) ATTR_WARN_UNUSED_RESULT ATTR_NON_NULL_PTR_ARG(3);
176

    
177
#endif