La suite :
usb_config.h
FSconfig.h
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120 /******************************************************************** FileName: usb_config.h Dependencies: Always: GenericTypeDefs.h, usb_device.h Situational: usb_function_hid.h, usb_function_cdc.h, usb_function_msd.h, etc. Processor: PIC18 or PIC24 USB Microcontrollers Hardware: The code is natively intended to be used on the following hardware platforms: PICDEM? FS USB Demo Board, PIC18F87J50 FS USB Plug-In Module, or Explorer 16 + PIC24 USB PIM. The firmware may be modified for use on other USB platforms by editing the HardwareProfile.h file. Complier: Microchip C18 (for PIC18) or C30 (for PIC24) Company: Microchip Technology, Inc. Software License Agreement: The software supplied herewith by Microchip Technology Incorporated (the ?Company?) for its PIC® Microcontroller is intended and supplied to you, the Company?s customer, for use solely and exclusively on Microchip PIC Microcontroller products. The software is owned by the Company and/or its supplier, and is protected under applicable copyright laws. All rights are reserved. Any use in violation of the foregoing restrictions may subject the user to criminal sanctions under applicable laws, as well as to civil liability for the breach of the terms and conditions of this license. THIS SOFTWARE IS PROVIDED IN AN ?AS IS? CONDITION. NO WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. THE COMPANY SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER. ******************************************************************** File Description: Change History: Rev Date Description 1.0 11/19/2004 Initial release 2.1 02/26/2007 Updated for simplicity and to use common coding style *******************************************************************/ /********************************************************************* * Descriptor specific type definitions are defined in: usbd.h ********************************************************************/ #ifndef USBCFG_H #define USBCFG_H /** DEFINITIONS ****************************************************/ #define USB_EP0_BUFF_SIZE 8 // Valid Options: 8, 16, 32, or 64 bytes. // Using larger options take more SRAM, but // does not provide much advantage in most types // of applications. Exceptions to this, are applications // that use EP0 IN or OUT for sending large amounts of // application related data. #define USB_MAX_NUM_INT 1 // For tracking Alternate Setting #define USB_MAX_EP_NUMBER 2 //Device descriptor - if these two definitions are not defined then // a ROM USB_DEVICE_DESCRIPTOR variable by the exact name of device_dsc // must exist. #define USB_USER_DEVICE_DESCRIPTOR &device_dsc #define USB_USER_DEVICE_DESCRIPTOR_INCLUDE extern ROM USB_DEVICE_DESCRIPTOR device_dsc //Configuration descriptors - if these two definitions do not exist then // a ROM BYTE *ROM variable named exactly USB_CD_Ptr[] must exist. #define USB_USER_CONFIG_DESCRIPTOR USB_CD_Ptr #define USB_USER_CONFIG_DESCRIPTOR_INCLUDE extern ROM BYTE *ROM USB_CD_Ptr[] //Make sure only one of the below "#define USB_PING_PONG_MODE" //is uncommented. #define USB_PING_PONG_MODE USB_PING_PONG__NO_PING_PONG //#define USB_PING_PONG_MODE USB_PING_PONG__FULL_PING_PONG //#define USB_PING_PONG_MODE USB_PING_PONG__EP0_OUT_ONLY //#define USB_PING_PONG_MODE USB_PING_PONG__ALL_BUT_EP0 //NOTE: This mode is not supported in PIC18F4550 family rev A3 devices #define USB_POLLING /* Parameter definitions are defined in usb_device.h */ #define USB_PULLUP_OPTION USB_PULLUP_ENABLE // USB_PULLUP_DISABLED #define USB_TRANSCEIVER_OPTION USB_INTERNAL_TRANSCEIVER // USB_EXTERNAL_TRANSCEIVER #define USB_SPEED_OPTION USB_FULL_SPEED // USB_LOW_SPEED (not valid option for PIC24F devices) /** DEVICE CLASS USAGE *********************************************/ #define USB_SUPPORT_DEVICE #define USB_USE_MSD #define USB_USE_HID /** ENDPOINTS ALLOCATION *******************************************/ /* MSD */ #define MSD_INTF_ID 0x00 #define MSD_IN_EP_SIZE 64 #define MSD_OUT_EP_SIZE 64 #define MAX_LUN 0 #define MSD_DATA_IN_EP 1 #define MSD_DATA_OUT_EP 1 #define MSD_BUFFER_ADDRESS 0x600 /* HID */ #define HID_INTF_ID 0x01 #define HID_EP 2 #define HID_INT_OUT_EP_SIZE 3 #define HID_INT_IN_EP_SIZE 3 #define HID_NUM_OF_DSC 1 #define HID_RPT01_SIZE 29 /** DEFINITIONS ****************************************************/ #endif //USBCFG_H
usb_ch9.h
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206 /****************************************************************************** * * Microchip Memory Disk Drive File System * ****************************************************************************** * FileName: FSconfig.h * Dependencies: None * Processor: PIC18/PIC24/dsPIC30/dsPIC33 * Compiler: C18/C30 * Company: Microchip Technology, Inc. * Version: 1.0.0 * * Software License Agreement * * The software supplied herewith by Microchip Technology Incorporated * (the ?Company?) for its PICmicro® Microcontroller is intended and * supplied to you, the Company?s customer, for use solely and * exclusively on Microchip PICmicro Microcontroller products. The * software is owned by the Company and/or its supplier, and is * protected under applicable copyright laws. All rights are reserved. * Any use in violation of the foregoing restrictions may subject the * user to criminal sanctions under applicable laws, as well as to * civil liability for the breach of the terms and conditions of this * license. * * THIS SOFTWARE IS PROVIDED IN AN ?AS IS? CONDITION. NO WARRANTIES, * WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT NOT LIMITED * TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A * PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. THE COMPANY SHALL NOT, * IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL OR * CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER. * *****************************************************************************/ #ifndef _FS_DEF_ #include "HardwareProfile.h" /***************************************************************************/ /* Note: There are likely pin definitions present in the header file */ /* for your device (SP-SPI.h, CF-PMP.h, etc). You may wish to */ /* specify these as well */ /***************************************************************************/ // The FS_MAX_FILES_OPEN #define is only applicable when Dynamic // memeory allocation is not used (FS_DYNAMIC_MEM not defined). // Defines how many concurent open files can exist at the same time. // Takes up static memory. If you do not need to open more than one // file at the same time, then you should set this to 1 to reduce // memory usage #define FS_MAX_FILES_OPEN 3 /************************************************************************/ // The size of a sector // Must be 512, 1024, 2048, or 4096 // 512 bytes is the value used by most cards #define MEDIA_SECTOR_SIZE 512 /************************************************************************/ /* *******************************************************************************************************/ /************** Compiler options to enable/Disable Features based on user's application ******************/ /* *******************************************************************************************************/ // Uncomment this to use the FindFirst, FindNext, and FindPrev #define ALLOW_FILESEARCH /************************************************************************/ /************************************************************************/ // Comment this line out if you don't intend to write data to the card #define ALLOW_WRITES /************************************************************************/ // Comment this line out if you don't intend to format your card // Writes must be enabled to use the format function #define ALLOW_FORMATS /************************************************************************/ // Uncomment this definition if you're using directories // Writes must be enabled to use directories #define ALLOW_DIRS /************************************************************************/ // Allows the use of FSfopenpgm, FSremovepgm, etc with PIC18 #if defined(__18CXX) #define ALLOW_PGMFUNCTIONS #endif /************************************************************************/ // Allows the use of the FSfprintf function // Writes must be enabled to use the FSprintf function //#define ALLOW_FSFPRINTF /************************************************************************/ // If FAT32 support required then uncomment the following #define SUPPORT_FAT32 /* ******************************************************************************************************* */ // Select how you want the timestamps to be updated // Use the Real-time clock peripheral to set the clock // You must configure the RTC in your application code //#define USEREALTIMECLOCK // The user will update the timing variables manually using the SetClockVars function // The user should set the clock before they create a file or directory (Create time), // and before they close a file (last access time, last modified time) //#define USERDEFINEDCLOCK // Just increment the time- this will not produce accurate times and dates #define INCREMENTTIMESTAMP #ifdef USE_PIC18 #ifdef USEREALTIMECLOCK #error The PIC18 architecture does not have a Real-time clock and calander module #endif #endif #ifdef ALLOW_PGMFUNCTIONS #ifndef USE_PIC18 #error The pgm functions are unneccessary when not using PIC18 #endif #endif #ifndef USEREALTIMECLOCK #ifndef USERDEFINEDCLOCK #ifndef INCREMENTTIMESTAMP #error Please enable USEREALTIMECLOCK, USERDEFINEDCLOCK, or INCREMENTTIMESTAMP #endif #endif #endif /************************************************************************/ // Define FS_DYNAMIC_MEM to use malloc for allocating // FILE structure space. uncomment all three lines /************************************************************************/ #if 0 #define FS_DYNAMIC_MEM #ifdef USE_PIC18 #define FS_malloc SRAMalloc #define FS_free SRAMfree #else #define FS_malloc malloc #define FS_free free #endif #endif // Function definitions // Associate the physical layer functions with the correct physical layer #ifdef USE_SD_INTERFACE_WITH_SPI // SD-SPI.c and .h #define MDD_MediaInitialize MDD_SDSPI_MediaInitialize #define MDD_MediaDetect MDD_SDSPI_MediaDetect #define MDD_SectorRead MDD_SDSPI_SectorRead #define MDD_SectorWrite MDD_SDSPI_SectorWrite #define MDD_InitIO MDD_SDSPI_InitIO #define MDD_ShutdownMedia MDD_SDSPI_ShutdownMedia #define MDD_WriteProtectState MDD_SDSPI_WriteProtectState #define MDD_ReadSectorSize MDD_SDSPI_ReadSectorSize #define MDD_ReadCapacity MDD_SDSPI_ReadCapacity #elif defined USE_CF_INTERFACE_WITH_PMP // CF-PMP.c and .h #define MDD_MediaInitialize MDD_CFPMP_MediaInitialize #define MDD_MediaDetect MDD_CFPMP_MediaDetect #define MDD_SectorRead MDD_CFPMP_SectorRead #define MDD_SectorWrite MDD_CFPMP_SectorWrite #define MDD_InitIO MDD_CFPMP_InitIO #define MDD_ShutdownMedia MDD_CFPMP_ShutdownMedia #define MDD_WriteProtectState MDD_CFPMP_WriteProtectState #define MDD_CFwait MDD_CFPMP_CFwait #define MDD_CFwrite MDD_CFPMP_CFwrite #define MDD_CFread MDD_CFPMP_CFread #elif defined USE_MANUAL_CF_INTERFACE // CF-Bit transaction.c and .h #define MDD_MediaInitialize MDD_CFBT_MediaInitialize #define MDD_MediaDetect MDD_CFBT_MediaDetect #define MDD_SectorRead MDD_CFBT_SectorRead #define MDD_SectorWrite MDD_CFBT_SectorWrite #define MDD_InitIO MDD_CFBT_InitIO #define MDD_ShutdownMedia MDD_CFBT_ShutdownMedia #define MDD_WriteProtectState MDD_CFBT_WriteProtectState #define MDD_CFwait MDD_CFBT_CFwait #define MDD_CFwrite MDD_CFBT_CFwrite #define MDD_CFread MDD_CFBT_CFread #elif defined USE_USB_INTERFACE // USB host MSD library #define MDD_MediaInitialize USBHostMSDSCSIMediaInitialize #define MDD_MediaDetect USBHostMSDSCSIMediaDetect #define MDD_SectorRead USBHostMSDSCSISectorRead #define MDD_SectorWrite USBHostMSDSCSISectorWrite #define MDD_InitIO(); #define MDD_ShutdownMedia USBHostMSDSCSIMediaReset #define MDD_WriteProtectState USBHostMSDSCSIWriteProtectState #endif #endif
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392 /******************************************************************************* USB Chapter 9 Protocol (Header File) Description: This file defines data structures, constants, and macros that are used to to support the USB Device Framework protocol described in Chapter 9 of the USB 2.0 specification. *******************************************************************************/ //DOM-IGNORE-BEGIN /******************************************************************************* * FileName: usb_ch9.h * Dependencies: None * Processor: PIC18/PIC24/PIC32MX microcontrollers with USB module * Compiler: C18 v3.13+/C30 v2.01+/C32 v0.00.18+ * Company: Microchip Technology, Inc. * File Description: * This file contains the definitions and prototypes used for * specification chapter 9 compliance. Software License Agreement The software supplied herewith by Microchip Technology Incorporated (the “Company”) for its PICmicro® Microcontroller is intended and supplied to you, the Company’s customer, for use solely and exclusively on Microchip PICmicro Microcontroller products. The software is owned by the Company and/or its supplier, and is protected under applicable copyright laws. All rights are reserved. Any use in violation of the foregoing restrictions may subject the user to criminal sanctions under applicable laws, as well as to civil liability for the breach of the terms and conditions of this license. THIS SOFTWARE IS PROVIDED IN AN “AS IS” CONDITION. NO WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. THE COMPANY SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER. *******************************************************************************/ //DOM-IGNORE-END //DOM-IGNORE-BEGIN #ifndef _USB_CH9_H_ #define _USB_CH9_H_ //DOM-IGNORE-END // ***************************************************************************** // ***************************************************************************** // Section: USB Descriptors // ***************************************************************************** // ***************************************************************************** #define USB_DESCRIPTOR_DEVICE 0x01 // bDescriptorType for a Device Descriptor. #define USB_DESCRIPTOR_CONFIGURATION 0x02 // bDescriptorType for a Configuration Descriptor. #define USB_DESCRIPTOR_STRING 0x03 // bDescriptorType for a String Descriptor. #define USB_DESCRIPTOR_INTERFACE 0x04 // bDescriptorType for an Interface Descriptor. #define USB_DESCRIPTOR_ENDPOINT 0x05 // bDescriptorType for an Endpoint Descriptor. #define USB_DESCRIPTOR_DEVICE_QUALIFIER 0x06 // bDescriptorType for a Device Qualifier. #define USB_DESCRIPTOR_OTHER_SPEED 0x07 // bDescriptorType for a Other Speed Configuration. #define USB_DESCRIPTOR_INTERFACE_POWER 0x08 // bDescriptorType for Interface Power. #define USB_DESCRIPTOR_OTG 0x09 // bDescriptorType for an OTG Descriptor. // ***************************************************************************** /* USB Device Descriptor Structure This struct defines the structure of a USB Device Descriptor. Note that this structure may need to be packed, or even accessed as bytes, to properly access the correct fields when used on some device architectures. */ typedef struct __attribute__ ((packed)) _USB_DEVICE_DESCRIPTOR { BYTE bLength; // Length of this descriptor. BYTE bDescriptorType; // DEVICE descriptor type (USB_DESCRIPTOR_DEVICE). WORD bcdUSB; // USB Spec Release Number (BCD). BYTE bDeviceClass; // Class code (assigned by the USB-IF). 0xFF-Vendor specific. BYTE bDeviceSubClass; // Subclass code (assigned by the USB-IF). BYTE bDeviceProtocol; // Protocol code (assigned by the USB-IF). 0xFF-Vendor specific. BYTE bMaxPacketSize0; // Maximum packet size for endpoint 0. WORD idVendor; // Vendor ID (assigned by the USB-IF). WORD idProduct; // Product ID (assigned by the manufacturer). WORD bcdDevice; // Device release number (BCD). BYTE iManufacturer; // Index of String Descriptor describing the manufacturer. BYTE iProduct; // Index of String Descriptor describing the product. BYTE iSerialNumber; // Index of String Descriptor with the device's serial number. BYTE bNumConfigurations; // Number of possible configurations. } USB_DEVICE_DESCRIPTOR; // ***************************************************************************** /* USB Configuration Descriptor Structure This struct defines the structure of a USB Configuration Descriptor. Note that this structure may need to be packed, or even accessed as bytes, to properly access the correct fields when used on some device architectures. */ typedef struct __attribute__ ((packed)) _USB_CONFIGURATION_DESCRIPTOR { BYTE bLength; // Length of this descriptor. BYTE bDescriptorType; // CONFIGURATION descriptor type (USB_DESCRIPTOR_CONFIGURATION). WORD wTotalLength; // Total length of all descriptors for this configuration. BYTE bNumInterfaces; // Number of interfaces in this configuration. BYTE bConfigurationValue; // Value of this configuration (1 based). BYTE iConfiguration; // Index of String Descriptor describing the configuration. BYTE bmAttributes; // Configuration characteristics. BYTE bMaxPower; // Maximum power consumed by this configuration. } USB_CONFIGURATION_DESCRIPTOR; // Attributes bits #define USB_CFG_DSC_REQUIRED 0x80 // Required attribute #define USB_CFG_DSC_SELF_PWR (0x40|USB_CFG_DSC_REQUIRED) // Device is self powered. #define USB_CFG_DSC_REM_WAKE (0x20|USB_CFG_DSC_REQUIRED) // Device can request remote wakup // ***************************************************************************** /* USB Interface Descriptor Structure This struct defines the structure of a USB Interface Descriptor. Note that this structure may need to be packed, or even accessed as bytes, to properly access the correct fields when used on some device architectures. */ typedef struct __attribute__ ((packed)) _USB_INTERFACE_DESCRIPTOR { BYTE bLength; // Length of this descriptor. BYTE bDescriptorType; // INTERFACE descriptor type (USB_DESCRIPTOR_INTERFACE). BYTE bInterfaceNumber; // Number of this interface (0 based). BYTE bAlternateSetting; // Value of this alternate interface setting. BYTE bNumEndpoints; // Number of endpoints in this interface. BYTE bInterfaceClass; // Class code (assigned by the USB-IF). 0xFF-Vendor specific. BYTE bInterfaceSubClass; // Subclass code (assigned by the USB-IF). BYTE bInterfaceProtocol; // Protocol code (assigned by the USB-IF). 0xFF-Vendor specific. BYTE iInterface; // Index of String Descriptor describing the interface. } USB_INTERFACE_DESCRIPTOR; // ***************************************************************************** /* USB Endpoint Descriptor Structure This struct defines the structure of a USB Endpoint Descriptor. Note that this structure may need to be packed, or even accessed as bytes, to properly access the correct fields when used on some device architectures. */ typedef struct __attribute__ ((packed)) _USB_ENDPOINT_DESCRIPTOR { BYTE bLength; // Length of this descriptor. BYTE bDescriptorType; // ENDPOINT descriptor type (USB_DESCRIPTOR_ENDPOINT). BYTE bEndpointAddress; // Endpoint address. Bit 7 indicates direction (0=OUT, 1=IN). BYTE bmAttributes; // Endpoint transfer type. WORD wMaxPacketSize; // Maximum packet size. BYTE bInterval; // Polling interval in frames. } USB_ENDPOINT_DESCRIPTOR; // Endpoint Direction #define EP_DIR_IN 0x80 // Data flows from device to host #define EP_DIR_OUT 0x00 // Data flows from host to device // ****************************************************************** // USB Endpoint Attributes // ****************************************************************** // Section: Transfer Types #define EP_ATTR_CONTROL (0<<0) // Endoint used for control transfers #define EP_ATTR_ISOCH (1<<0) // Endpoint used for isochronous transfers #define EP_ATTR_BULK (2<<0) // Endpoint used for bulk transfers #define EP_ATTR_INTR (3<<0) // Endpoint used for interrupt transfers // Section: Synchronization Types (for isochronous enpoints) #define EP_ATTR_NO_SYNC (0<<2) // No Synchronization #define EP_ATTR_ASYNC (1<<2) // Asynchronous #define EP_ATTR_ADAPT (2<<2) // Adaptive synchronization #define EP_ATTR_SYNC (3<<2) // Synchronous // Section: Usage Types (for isochronous endpoints) #define EP_ATTR_DATA (0<<4) // Data Endpoint #define EP_ATTR_FEEDBACK (1<<4) // Feedback endpoint #define EP_ATTR_IMP_FB (2<<4) // Implicit Feedback data EP // Section: Max Packet Sizes #define EP_MAX_PKT_INTR_LS 8 // Max low-speed interrupt packet #define EP_MAX_PKT_INTR_FS 64 // Max full-speed interrupt packet #define EP_MAX_PKT_ISOCH_FS 1023 // Max full-speed isochronous packet #define EP_MAX_PKT_BULK_FS 64 // Max full-speed bulk packet #define EP_LG_PKT_BULK_FS 32 // Large full-speed bulk packet #define EP_MED_PKT_BULK_FS 16 // Medium full-speed bulk packet #define EP_SM_PKT_BULK_FS 8 // Small full-speed bulk packet // ***************************************************************************** /* USB OTG Descriptor Structure This struct defines the structure of a USB OTG Descriptor. Note that this structure may need to be packed, or even accessed as bytes, to properly access the correct fields when used on some device architectures. */ typedef struct __attribute__ ((packed)) _USB_OTG_DESCRIPTOR { BYTE bLength; // Length of this descriptor. BYTE bDescriptorType; // OTG descriptor type (USB_DESCRIPTOR_OTG). BYTE bmAttributes; // OTG attributes. } USB_OTG_DESCRIPTOR; // ****************************************************************** // Section: USB String Descriptor Structure // ****************************************************************** // This structure describes the USB string descriptor. The string // descriptor provides user-readable information about various aspects of // the device. The first string desriptor (string descriptor zero (0)), // provides a list of the number of languages supported by the set of // string descriptors for this device instead of an actual string. // // Note: The strings are in 2-byte-per-character unicode, not ASCII. // // Note: This structure only describes the "header" of the string // descriptor. The actual data (either the language ID array or the // array of unicode characters making up the string, must be allocated // immediately following this header with no padding between them. typedef struct __attribute__ ((packed)) _USB_STRING_DSC { BYTE bLength; // Size of this descriptor BYTE bDescriptorType; // Type, USB_DSC_STRING } USB_STRING_DESCRIPTOR; // ****************************************************************** // Section: USB Device Qualifier Descriptor Structure // ****************************************************************** // This structure describes the device qualifier descriptor. The device // qualifier descriptor provides overall device information if the device // supports "other" speeds. // // Note: A high-speed device may support "other" speeds (ie. full or low). // If so, it may need to implement the the device qualifier and other // speed descriptors. typedef struct __attribute__ ((packed)) _USB_DEVICE_QUALIFIER_DESCRIPTOR { BYTE bLength; // Size of this descriptor BYTE bType; // Type, always USB_DESCRIPTOR_DEVICE_QUALIFIER WORD bcdUSB; // USB spec version, in BCD BYTE bDeviceClass; // Device class code BYTE bDeviceSubClass; // Device sub-class code BYTE bDeviceProtocol; // Device protocol BYTE bMaxPacketSize0; // EP0, max packet size BYTE bNumConfigurations; // Number of "other-speed" configurations BYTE bReserved; // Always zero (0) } USB_DEVICE_QUALIFIER_DESCRIPTOR; // ****************************************************************** // Section: USB Setup Packet Structure // ****************************************************************** // This structure describes the data contained in a USB standard device // request's setup packet. It is the data packet sent from the host to // the device to control and configure the device. // // Note: Refer to the USB 2.0 specification for additional details on the // usage of the setup packet and standard device requests. typedef struct __attribute__ ((packed)) SetupPkt { union // offset description { // ------ ------------------------ BYTE bmRequestType; // 0 Bit-map of request type struct { BYTE recipient: 5; // Recipient of the request BYTE type: 2; // Type of request BYTE direction: 1; // Direction of data X-fer }; }requestInfo; BYTE bRequest; // 1 Request type UINT16 wValue; // 2 Depends on bRequest UINT16 wIndex; // 4 Depends on bRequest UINT16 wLength; // 6 Depends on bRequest } SETUP_PKT, *PSETUP_PKT; // ****************************************************************** // ****************************************************************** // Section: USB Specification Constants // ****************************************************************** // ****************************************************************** // Section: Valid PID Values //DOM-IGNORE-BEGIN #define PID_OUT 0x1 // PID for an OUT token #define PID_ACK 0x2 // PID for an ACK handshake #define PID_DATA0 0x3 // PID for DATA0 data #define PID_PING 0x4 // Special PID PING #define PID_SOF 0x5 // PID for a SOF token #define PID_NYET 0x6 // PID for a NYET handshake #define PID_DATA2 0x7 // PID for DATA2 data #define PID_SPLIT 0x8 // Special PID SPLIT #define PID_IN 0x9 // PID for a IN token #define PID_NAK 0xA // PID for a NAK handshake #define PID_DATA1 0xB // PID for DATA1 data #define PID_PRE 0xC // Special PID PRE (Same as PID_ERR) #define PID_ERR 0xC // Special PID ERR (Same as PID_PRE) #define PID_SETUP 0xD // PID for a SETUP token #define PID_STALL 0xE // PID for a STALL handshake #define PID_MDATA 0xF // PID for MDATA data #define PID_MASK_DATA 0x03 // Data PID mask #define PID_MASK_DATA_SHIFTED (PID_MASK_DATA << 2) // Data PID shift to proper position //DOM-IGNORE-END // Section: USB Token Types //DOM-IGNORE-BEGIN #define USB_TOKEN_OUT 0x01 // U1TOK - OUT token #define USB_TOKEN_IN 0x09 // U1TOK - IN token #define USB_TOKEN_SETUP 0x0D // U1TOK - SETUP token //DOM-IGNORE-END // Section: OTG Descriptor Constants #define OTG_HNP_SUPPORT 0x02 // OTG Descriptor bmAttributes - HNP support flag #define OTG_SRP_SUPPORT 0x01 // OTG Descriptor bmAttributes - SRP support flag // Section: Endpoint Directions #define USB_IN_EP 0x80 // IN endpoint mask #define USB_OUT_EP 0x00 // OUT endpoint mask // Section: Standard Device Requests #define USB_REQUEST_GET_STATUS 0 // Standard Device Request - GET STATUS #define USB_REQUEST_CLEAR_FEATURE 1 // Standard Device Request - CLEAR FEATURE #define USB_REQUEST_SET_FEATURE 3 // Standard Device Request - SET FEATURE #define USB_REQUEST_SET_ADDRESS 5 // Standard Device Request - SET ADDRESS #define USB_REQUEST_GET_DESCRIPTOR 6 // Standard Device Request - GET DESCRIPTOR #define USB_REQUEST_SET_DESCRIPTOR 7 // Standard Device Request - SET DESCRIPTOR #define USB_REQUEST_GET_CONFIGURATION 8 // Standard Device Request - GET CONFIGURATION #define USB_REQUEST_SET_CONFIGURATION 9 // Standard Device Request - SET CONFIGURATION #define USB_REQUEST_GET_INTERFACE 10 // Standard Device Request - GET INTERFACE #define USB_REQUEST_SET_INTERFACE 11 // Standard Device Request - SET INTERFACE #define USB_REQUEST_SYNCH_FRAME 12 // Standard Device Request - SYNCH FRAME #define USB_FEATURE_ENDPOINT_HALT 0 // CLEAR/SET FEATURE - Endpoint Halt #define USB_FEATURE_DEVICE_REMOTE_WAKEUP 1 // CLEAR/SET FEATURE - Device remote wake-up #define USB_FEATURE_TEST_MODE 2 // CLEAR/SET FEATURE - Test mode // Section: Setup Data Constants #define USB_SETUP_HOST_TO_DEVICE 0x00 // Device Request bmRequestType transfer direction - host to device transfer #define USB_SETUP_DEVICE_TO_HOST 0x80 // Device Request bmRequestType transfer direction - device to host transfer #define USB_SETUP_TYPE_STANDARD 0x00 // Device Request bmRequestType type - standard #define USB_SETUP_TYPE_CLASS 0x20 // Device Request bmRequestType type - class #define USB_SETUP_TYPE_VENDOR 0x40 // Device Request bmRequestType type - vendor #define USB_SETUP_RECIPIENT_DEVICE 0x00 // Device Request bmRequestType recipient - device #define USB_SETUP_RECIPIENT_INTERFACE 0x01 // Device Request bmRequestType recipient - interface #define USB_SETUP_RECIPIENT_ENDPOINT 0x02 // Device Request bmRequestType recipient - endpoint #define USB_SETUP_RECIPIENT_OTHER 0x03 // Device Request bmRequestType recipient - other // Section: OTG SET FEATURE Constants #define OTG_FEATURE_B_HNP_ENABLE 3 // SET FEATURE OTG - Enable B device to perform HNP #define OTG_FEATURE_A_HNP_SUPPORT 4 // SET FEATURE OTG - A device supports HNP #define OTG_FEATURE_A_ALT_HNP_SUPPORT 5 // SET FEATURE OTG - Another port on the A device supports HNP // Section: USB Endpoint Transfer Types #define USB_TRANSFER_TYPE_CONTROL 0x00 // Endpoint is a control endpoint. #define USB_TRANSFER_TYPE_ISOCHRONOUS 0x01 // Endpoint is an isochronous endpoint. #define USB_TRANSFER_TYPE_BULK 0x02 // Endpoint is a bulk endpoint. #define USB_TRANSFER_TYPE_INTERRUPT 0x03 // Endpoint is an interrupt endpoint. // Section: Standard Feature Selectors for CLEAR_FEATURE Requests #define USB_FEATURE_ENDPOINT_STALL 0 // Endpoint recipient #define USB_FEATURE_DEVICE_REMOTE_WAKEUP 1 // Device recipient #define USB_FEATURE_TEST_MODE 2 // Device recipient // Section: USB Class Code Definitions #define USB_HUB_CLASSCODE 0x09 // Class code for a hub. #endif // _USB_CH9_H_ /************************************************************************* * EOF */
Partager