Line No. | Rev | Author | Line |
---|---|---|---|
1 | 32 | kaklik | /****************************************************************************** |
2 | |||
3 | USB Host Communication Device Class(CDC) driver Header file |
||
4 | |||
5 | Description: |
||
6 | This is the header file for a USB Embedded Host that is using the Communication |
||
7 | Device Class. |
||
8 | |||
9 | This file should be included with usb_host.h to provide the USB hardware |
||
10 | interface. It must be included after the application-specific usb_config.h |
||
11 | file and after the USB Embedded Host header file usb_host.h, as definitions |
||
12 | in those files are required for proper compilation. |
||
13 | |||
14 | Acronyms/abbreviations used by this class: |
||
15 | * CDC - Communication Device Class |
||
16 | * ACM - Abstract Control Module |
||
17 | |||
18 | To interface with usb_host.c, the routine USBHostCDCInitialize() should be |
||
19 | specified as the Initialize() function, and USBHostCDCEventHandler() should |
||
20 | be specified as the EventHandler() function in the usbClientDrvTable[] array |
||
21 | declared in usb_config.h. |
||
22 | |||
23 | This driver can be configured to use transfer events from usb_host.c. Transfer |
||
24 | events require more RAM and ROM than polling, but it cuts down or even |
||
25 | eliminates the required polling of the various USBxxxTasks functions. For this |
||
26 | class, USBHostCDCTasks() is compiled out if transfer events from usb_host.c |
||
27 | are used. However, USBHostTasks() still must be called to provide attach, |
||
28 | enumeration, and detach services. If transfer events from usb_host.c |
||
29 | are going to be used, USB_ENABLE_TRANSFER_EVENT should be defined. If transfer |
||
30 | status is going to be polled, USB_ENABLE_TRANSFER_EVENT should not be defined. |
||
31 | CDC client layer transfer events are also enables once USB_ENABLE_TRANSFER_EVENT |
||
32 | is defined. The application must define USB_HOST_APP_EVENT_HANDLER in file usb_config.h. |
||
33 | All the CDC client layer event are called back using this function handler. This eliminates |
||
34 | the need of polling for transfer status by the application, however handing of these events |
||
35 | should be taken care by the application. |
||
36 | |||
37 | Transfer of Data Class Interface can be performed with BULK transfers, |
||
38 | hence USB_SUPPORT_BULK_TRANSFERS must be defined. Data Class Interface can also use |
||
39 | ISOCHRONOUS transfers,however the CDC client is not tested for ISOCHRONOUS transfers. |
||
40 | |||
41 | |||
42 | *******************************************************************************/ |
||
43 | //DOM-IGNORE-BEGIN |
||
44 | /******************************************************************************* |
||
45 | |||
46 | * FileName: usb_host_cdc.h |
||
47 | * Dependencies: None |
||
48 | * Processor: PIC24/dsPIC30/dsPIC33/PIC32MX |
||
49 | * Compiler: C30 v2.01/C32 v0.00.18 |
||
50 | * Company: Microchip Technology, Inc. |
||
51 | |||
52 | Software License Agreement |
||
53 | |||
54 | The software supplied herewith by Microchip Technology Incorporated |
||
55 | (the Company) for its PICmicro® Microcontroller is intended and |
||
56 | supplied to you, the Companys customer, for use solely and |
||
57 | exclusively on Microchip PICmicro Microcontroller products. The |
||
58 | software is owned by the Company and/or its supplier, and is |
||
59 | protected under applicable copyright laws. All rights are reserved. |
||
60 | Any use in violation of the foregoing restrictions may subject the |
||
61 | user to criminal sanctions under applicable laws, as well as to |
||
62 | civil liability for the breach of the terms and conditions of this |
||
63 | license. |
||
64 | |||
65 | THIS SOFTWARE IS PROVIDED IN AN AS IS CONDITION. NO WARRANTIES, |
||
66 | WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT NOT LIMITED |
||
67 | TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A |
||
68 | PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. THE COMPANY SHALL NOT, |
||
69 | IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL OR |
||
70 | CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER. |
||
71 | |||
72 | Change History: |
||
73 | Rev Description |
||
74 | ---- ------------------------------------------------ |
||
75 | 2.6 Changed format of 'bcdCDC' from word to array of byte. |
||
76 | |||
77 | 2.6a No change |
||
78 | |||
79 | 2.7 Modified the code to allow connection of USB-RS232 dongles that do |
||
80 | not fully comply with CDC specifications |
||
81 | |||
82 | Modified API USBHostCDC_Api_Send_OUT_Data to allow data transfers |
||
83 | more than 256 bytes |
||
84 | |||
85 | 2.7a removed freezCDC() function |
||
86 | ********************************************************************************/ |
||
87 | //DOM-IGNORE-END |
||
88 | |||
89 | //DOM-IGNORE-BEGIN |
||
90 | #ifndef _USB_HOST_CDC_H_ |
||
91 | #define _USB_HOST_CDC_H_ |
||
92 | //DOM-IGNORE-END |
||
93 | |||
94 | // ***************************************************************************** |
||
95 | // ***************************************************************************** |
||
96 | // Section: Constants |
||
97 | // ***************************************************************************** |
||
98 | // ***************************************************************************** |
||
99 | |||
100 | // ***************************************************************************** |
||
101 | // CDC Class Error Codes |
||
102 | // ***************************************************************************** |
||
103 | |||
104 | #define USB_CDC_CLASS_ERROR USB_ERROR_CLASS_DEFINED |
||
105 | |||
106 | #define USB_CDC_COMMAND_PASSED USB_SUCCESS // Command was successful. |
||
107 | #define USB_CDC_COMMAND_FAILED (USB_CDC_CLASS_ERROR | 0x01) // Command failed at the device. |
||
108 | #define USB_CDC_PHASE_ERROR (USB_CDC_CLASS_ERROR | 0x02) // Command had a phase error at the device. |
||
109 | #define USB_CDC_DEVICE_NOT_FOUND (USB_CDC_CLASS_ERROR | 0x03) // Device with the specified address is not available. |
||
110 | #define USB_CDC_DEVICE_BUSY (USB_CDC_CLASS_ERROR | 0x04) // A transfer is currently in progress. |
||
111 | #define USB_CDC_NO_REPORT_DESCRIPTOR (USB_CDC_CLASS_ERROR | 0x05) // No report descriptor found |
||
112 | #define USB_CDC_INTERFACE_ERROR (USB_CDC_CLASS_ERROR | 0x06) // The interface layer cannot support the device. |
||
113 | #define USB_CDC_REPORT_DESCRIPTOR_BAD (USB_CDC_CLASS_ERROR | 0x05) // Report Descriptor for not proper |
||
114 | #define USB_CDC_RESET_ERROR (USB_CDC_CLASS_ERROR | 0x0A) // An error occurred while resetting the device. |
||
115 | #define USB_CDC_ILLEGAL_REQUEST (USB_CDC_CLASS_ERROR | 0x0B) // Cannot perform requested operation. |
||
116 | |||
117 | |||
118 | // ***************************************************************************** |
||
119 | // Section: Interface and Protocol Constants |
||
120 | // ***************************************************************************** |
||
121 | |||
122 | #define DEVICE_CLASS_CDC 0x02 // CDC Interface Class Code |
||
123 | #define USB_CDC_COMM_INTF 0x02 // Communication Interface Class Code |
||
124 | |||
125 | /* Communication Interface Class SubClass Codes */ |
||
126 | #define USB_CDC_DIRECT_LINE_CONTROL_MODEL 0x01 // Direct Line Control Model |
||
127 | #define USB_CDC_ABSTRACT_CONTROL_MODEL 0x02 // Abstract Control Model |
||
128 | #define USB_CDC_TELEPHONE_CONTROL_MODEL 0x03 // Telephone Control Model |
||
129 | #define USB_CDC_MULTI_CHANNEL_CONTROL_MODEL 0x04 // Multi-Channel Control Model |
||
130 | #define USB_CDC_CAPI_CONTROL_MODEL 0x05 // CAPI Control Model |
||
131 | #define USB_CDC_ETHERNET_NETWORKING_CONTROL_MODEL 0x06 // Ethernet Networking Control Model |
||
132 | #define USB_CDC_ATM_NETWORKING_CONTROL_MODEL 0x07 // ATM Networking Control Model |
||
133 | #define USB_CDC_WIRELESS_HANDSET_CONTROL_MODEL 0x08 // Wireless Handset Control Model |
||
134 | #define USB_CDC_DEVICE_MANAGEMENT 0x09 // Device Management |
||
135 | #define USB_CDC_MOBILE_DIRECT_LINE_MODEL 0x0A // Mobile Direct Line Model |
||
136 | #define USB_CDC_OBEX 0x0B // OBEX |
||
137 | #define USB_CDC_ETHERNET_EMULATION_MODEL 0x0C // Ethernet Emulation Model |
||
138 | |||
139 | /* Communication Interface Class Control Protocol Codes */ |
||
140 | /* First Cut V.250 AT Commands will be supported .. other protocols ??? */ |
||
141 | /* For more.... see Table 5 in USB CDC Specification 1.2 */ |
||
142 | #define USB_CDC_V25TER 0x01 // Common AT commands ("Hayes(TM)") |
||
143 | |||
144 | /* Data Interface Class Codes */ |
||
145 | #define USB_CDC_DATA_INTF 0x0A |
||
146 | |||
147 | /* Data Interface Class Protocol Codes */ |
||
148 | #define USB_CDC_NO_PROTOCOL 0x00 // No class specific protocol required |
||
149 | /* For more.... see Table 7 in USB CDC Specification 1.2 */ |
||
150 | |||
151 | /* Functional Descriptor Details */ |
||
152 | /* Type Values for the bDscType Field */ |
||
153 | #define USB_CDC_CS_INTERFACE 0x24 |
||
154 | #define USB_CDC_CS_ENDPOINT 0x25 |
||
155 | |||
156 | /* bDscSubType in Functional Descriptors */ |
||
157 | #define USB_CDC_DSC_FN_HEADER 0x00 |
||
158 | #define USB_CDC_DSC_FN_CALL_MGT 0x01 |
||
159 | #define USB_CDC_DSC_FN_ACM 0x02 // ACM - Abstract Control Management |
||
160 | #define USB_CDC_DSC_FN_DLM 0x03 // DLM - Direct Line Managment |
||
161 | #define USB_CDC_DSC_FN_TELEPHONE_RINGER 0x04 |
||
162 | #define USB_CDC_DSC_FN_RPT_CAPABILITIES 0x05 |
||
163 | #define USB_CDC_DSC_FN_UNION 0x06 |
||
164 | #define USB_CDC_DSC_FN_COUNTRY_SELECTION 0x07 |
||
165 | #define USB_CDC_DSC_FN_TEL_OP_MODES 0x08 |
||
166 | #define USB_CDC_DSC_FN_USB_TERMINAL 0x09 |
||
167 | /* more.... see Table 13 in USB CDC Specification 1.2 */ |
||
168 | |||
169 | |||
170 | /* bRequestCode - Class Specific Request codes */ |
||
171 | /* Type Values for the bRequest Field */ |
||
172 | #define USB_CDC_SEND_ENCAPSULATED_COMMAND 0x00 // Issues a command in the format of the supported control protocol. |
||
173 | #define USB_CDC_GET_ENCAPSULATED_REQUEST 0x01 // Requests a response in the format of the supported control protocol. |
||
174 | #define USB_CDC_SET_COMM_FEATURE 0x02 // Controls the settings for a particular communications feature. |
||
175 | #define USB_CDC_GET_COMM_FEATURE 0x03 // Returns the current settings for the communications feature. |
||
176 | #define USB_CDC_SET_LINE_CODING 0x20 // Configures DTE rate, stop-bits, parity, and number-of-character bits. |
||
177 | #define USB_CDC_GET_LINE_CODING 0x21 // Requests current DTE rate, stop-bits, parity, and number-of-character bits. |
||
178 | #define USB_CDC_SET_CONTROL_LINE_STATE 0x22 // [V24] signal used to tell the DCE device the DTE device is now present. |
||
179 | #define USB_CDC_SEND_BREAK 0x23 // Sends special carrier modulation used to specify [V24] style break. |
||
180 | |||
181 | |||
182 | // ***************************************************************************** |
||
183 | // Additional return values for USBHostCDCDeviceStatus (see USBHostDeviceStatus also) |
||
184 | // ***************************************************************************** |
||
185 | |||
186 | #define USB_CDC_DEVICE_DETACHED 0x50 // Device is detached. |
||
187 | #define USB_CDC_INITIALIZING 0x51 // Device is initializing. |
||
188 | #define USB_CDC_NORMAL_RUNNING 0x53 // Device is running and available for data transfers. |
||
189 | #define USB_CDC_DEVICE_HOLDING 0x54 // Device is holding due to error |
||
190 | #define USB_CDC_RESETTING_DEVICE 0x55 // Device is being reset. |
||
191 | |||
192 | // ***************************************************************************** |
||
193 | // Section: CDC Event Definition |
||
194 | // ***************************************************************************** |
||
195 | |||
196 | // If the application has not defined an offset for CDC events, set it to 0. |
||
197 | #ifndef EVENT_CDC_OFFSET |
||
198 | #define EVENT_CDC_OFFSET 0 |
||
199 | #endif |
||
200 | |||
201 | //#ifndef EVENT_CDC_BASE |
||
202 | // #define EVENT_CDC_BASE 400 // need to add base in usb_common.h |
||
203 | //#endif |
||
204 | |||
205 | #define EVENT_CDC_NONE EVENT_CDC_BASE + EVENT_CDC_OFFSET + 0 // No event occured (NULL event) |
||
206 | #define EVENT_CDC_ATTACH EVENT_CDC_BASE + EVENT_CDC_OFFSET + 1 // No event occured (NULL event) |
||
207 | #define EVENT_CDC_COMM_READ_DONE EVENT_CDC_BASE + EVENT_CDC_OFFSET + 2 // A CDC Communication Read transfer has completed |
||
208 | #define EVENT_CDC_COMM_WRITE_DONE EVENT_CDC_BASE + EVENT_CDC_OFFSET + 3 // A CDC Communication Write transfer has completed |
||
209 | #define EVENT_CDC_DATA_READ_DONE EVENT_CDC_BASE + EVENT_CDC_OFFSET + 4 // A CDC Data Read transfer has completed |
||
210 | #define EVENT_CDC_DATA_WRITE_DONE EVENT_CDC_BASE + EVENT_CDC_OFFSET + 5 // A CDC Data Write transfer has completed |
||
211 | #define EVENT_CDC_RESET EVENT_CDC_BASE + EVENT_CDC_OFFSET + 6 // CDC reset complete |
||
212 | #define EVENT_CDC_NAK_TIMEOUT EVENT_CDC_BASE + EVENT_CDC_OFFSET + 7 // CDC device NAK timeout has occurred |
||
213 | |||
214 | |||
215 | #define USB_CDC_LINE_CODING_LENGTH 0x07 // Number of bytes Line Coding transfer |
||
216 | #define USB_CDC_CONTROL_LINE_LENGTH 0x02 // Number of bytes Control line transfer |
||
217 | #define USB_CDC_MAX_PACKET_SIZE 0x200 // Max transfer size is 64 bytes for Full Speed USB |
||
218 | //****************************************************************************** |
||
219 | //****************************************************************************** |
||
220 | // Data Structures |
||
221 | //****************************************************************************** |
||
222 | //****************************************************************************** |
||
223 | typedef union _USB_CDC_LINE_CODING |
||
224 | { |
||
225 | struct |
||
226 | { |
||
227 | BYTE _byte[USB_CDC_LINE_CODING_LENGTH]; |
||
228 | }; |
||
229 | struct |
||
230 | { |
||
231 | DWORD_VAL dwDTERate; // Data terminal rate, in bits per second. |
||
232 | BYTE bCharFormat; // Stop bits 0:1 Stop bit, 1:1.5 Stop bits, 2:2 Stop bits |
||
233 | BYTE bParityType; // Parity 0:None, 1:Odd, 2:Even, 3:Mark, 4:Space |
||
234 | BYTE bDataBits; // Data bits (5, 6, 7, 8 or 16) |
||
235 | }; |
||
236 | } USB_CDC_LINE_CODING; |
||
237 | |||
238 | typedef union _USB_CDC_CONTROL_SIGNAL_BITMAP |
||
239 | { |
||
240 | BYTE _byte; |
||
241 | struct |
||
242 | { |
||
243 | unsigned DTE_PRESENT:1; // [0] Not Present [1] Present |
||
244 | unsigned CARRIER_CONTROL:1; // [0] Deactivate [1] Activate |
||
245 | }; |
||
246 | } USB_CDC_CONTROL_SIGNAL_BITMAP; |
||
247 | |||
248 | /* Functional Descriptor Structure - See CDC Specification 1.2 for details */ |
||
249 | |||
250 | /* Header Functional Descriptor */ |
||
251 | typedef struct _USB_CDC_HEADER_FN_DSC |
||
252 | { |
||
253 | BYTE bFNLength; // Size of this functional descriptor, in bytes. |
||
254 | BYTE bDscType; // CS_INTERFACE |
||
255 | BYTE bDscSubType; // Header. This is defined in [USBCDC1.2], which defines this as a header. |
||
256 | BYTE bcdCDC[2]; // USB Class Definitions for Communications Devices Specification release number in binary-coded decimal. |
||
257 | } USB_CDC_HEADER_FN_DSC; |
||
258 | |||
259 | /* Abstract Control Management Functional Descriptor */ |
||
260 | typedef struct _USB_CDC_ACM_FN_DSC |
||
261 | { |
||
262 | BYTE bFNLength; // Size of this functional descriptor, in bytes. |
||
263 | BYTE bDscType; // CS_INTERFACE |
||
264 | BYTE bDscSubType; // Abstract Control Management functional descriptor subtype as defined in [USBCDC1.2]. |
||
265 | BYTE bmCapabilities; // The capabilities that this configuration supports. (A bit value of zero means that the request is not supported.) |
||
266 | } USB_CDC_ACM_FN_DSC; |
||
267 | |||
268 | /* Union Functional Descriptor */ |
||
269 | typedef struct _USB_CDC_UNION_FN_DSC |
||
270 | { |
||
271 | BYTE bFNLength; // Size of this functional descriptor, in bytes. |
||
272 | BYTE bDscType; // CS_INTERFACE |
||
273 | BYTE bDscSubType; // Union Descriptor Functional Descriptor subtype as defined in [USBCDC1.2]. |
||
274 | BYTE bMasterIntf; // Interface number of the control (Communications Class) interface |
||
275 | BYTE bSaveIntf0; // Interface number of the subordinate (Data Class) interface |
||
276 | } USB_CDC_UNION_FN_DSC; |
||
277 | |||
278 | /* Call Management Functional Descriptor */ |
||
279 | typedef struct _USB_CDC_CALL_MGT_FN_DSC |
||
280 | { |
||
281 | BYTE bFNLength; // Size of this functional descriptor, in bytes. |
||
282 | BYTE bDscType; // CS_INTERFACE |
||
283 | BYTE bDscSubType; // Call Management functional descriptor subtype, as defined in [USBCDC1.2]. |
||
284 | BYTE bmCapabilities; // The capabilities that this configuration supports: |
||
285 | BYTE bDataInterface; // Interface number of Data Class interface optionally used for call management. |
||
286 | } USB_CDC_CALL_MGT_FN_DSC; |
||
287 | |||
288 | /* |
||
289 | This structure stores communication interface details of the attached CDC device |
||
290 | */ |
||
291 | typedef struct _COMM_INTERFACE_DETAILS |
||
292 | { |
||
293 | BYTE interfaceNum; // communication interface number |
||
294 | BYTE noOfEndpoints; // Number endpoints for communication interface |
||
295 | /* Functional Descriptor Details */ |
||
296 | USB_CDC_HEADER_FN_DSC Header_Fn_Dsc; // Header Function Descriptor |
||
297 | USB_CDC_ACM_FN_DSC ACM_Fn_Desc; // Abstract Control Model Function Descriptor |
||
298 | USB_CDC_UNION_FN_DSC Union_Fn_Desc; // Union Function Descriptor |
||
299 | USB_CDC_CALL_MGT_FN_DSC Call_Mgt_Fn_Desc; // Call Management Function Descriptor |
||
300 | /* Endpoint Descriptor Details*/ |
||
301 | WORD endpointMaxDataSize; // Max data size for a interface. |
||
302 | WORD endpointInDataSize; // Max data size for a interface. |
||
303 | WORD endpointOutDataSize; // Max data size for a interface. |
||
304 | BYTE endpointPollInterval; // Polling rate of corresponding interface. |
||
305 | BYTE endpointType; // Endpoint type - either Isochronous or Bulk |
||
306 | BYTE endpointIN; // IN endpoint for comm interface. |
||
307 | BYTE endpointOUT; // IN endpoint for comm interface. |
||
308 | |||
309 | } COMM_INTERFACE_DETAILS; |
||
310 | |||
311 | |||
312 | /* |
||
313 | This structure stores data interface details of the attached CDC device |
||
314 | */ |
||
315 | typedef struct _DATA_INTERFACE_DETAILS |
||
316 | { |
||
317 | BYTE interfaceNum; // Data interface number |
||
318 | BYTE noOfEndpoints; // number of endpoints associated with data interface |
||
319 | |||
320 | /* Endpoint Descriptor Details*/ |
||
321 | WORD endpointInDataSize; // Max data size for a interface. |
||
322 | WORD endpointOutDataSize; // Max data size for a interface. |
||
323 | BYTE endpointType; // Endpoint type - either Isochronous or Bulk |
||
324 | BYTE endpointIN; // IN endpoint for comm interface. |
||
325 | BYTE endpointOUT; // IN endpoint for comm interface. |
||
326 | } DATA_INTERFACE_DETAILS; |
||
327 | |||
328 | /* |
||
329 | This structure is used to hold information about an attached CDC device |
||
330 | */ |
||
331 | typedef struct _USB_CDC_DEVICE_INFO |
||
332 | { |
||
333 | BYTE* userData; // Data pointer to application buffer. |
||
334 | WORD reportSize; // Total length of user data |
||
335 | WORD remainingBytes; // Number bytes remaining to be transferrerd in case user data length is more than 64 bytes |
||
336 | WORD bytesTransferred; // Number of bytes transferred to/from the user's data buffer. |
||
337 | union |
||
338 | { |
||
339 | struct |
||
340 | { |
||
341 | BYTE bfDirection : 1; // Direction of current transfer (0=OUT, 1=IN). |
||
342 | BYTE bfReset : 1; // Flag indicating to perform CDC Reset. |
||
343 | BYTE bfClearDataIN : 1; // Flag indicating to clear the IN endpoint. |
||
344 | BYTE bfClearDataOUT : 1; // Flag indicating to clear the OUT endpoint. |
||
345 | }; |
||
346 | BYTE val; |
||
347 | } flags; |
||
348 | BYTE driverSupported; // If CDC driver supports requested Class,Subclass & Protocol. |
||
349 | BYTE deviceAddress; // Address of the device on the bus. |
||
350 | BYTE errorCode; // Error code of last error. |
||
351 | BYTE state; // State machine state of the device. |
||
352 | BYTE returnState; // State to return to after performing error handling. |
||
353 | BYTE noOfInterfaces; // Total number of interfaces in the device. |
||
354 | BYTE interface; // Interface number of current transfer. |
||
355 | BYTE endpointDATA; // Endpoint to use for the current transfer. |
||
356 | BYTE commRequest; // Current Communication code |
||
357 | BYTE clientDriverID; // Client driver ID for device requests. |
||
358 | COMM_INTERFACE_DETAILS commInterface; // This structure stores communication interface details. |
||
359 | DATA_INTERFACE_DETAILS dataInterface; // This structure stores data interface details. |
||
360 | } USB_CDC_DEVICE_INFO; |
||
361 | |||
362 | |||
363 | // ***************************************************************************** |
||
364 | // Section: Function Prototypes |
||
365 | // ***************************************************************************** |
||
366 | |||
367 | |||
368 | /******************************************************************************* |
||
369 | Function: |
||
370 | USBHostCDCRead_DATA( address,interface,size,data,endpointData) |
||
371 | |||
372 | Summary: |
||
373 | This function intiates a read request from a attached CDC device. |
||
374 | |||
375 | Description: |
||
376 | This function starts a CDC read transfer. |
||
377 | |||
378 | Preconditions: |
||
379 | None |
||
380 | |||
381 | Parameters: |
||
382 | address - Device address |
||
383 | interface - interface number of the requested transfer |
||
384 | size - Number of bytes to be read from the device |
||
385 | data - address of location where received data is to be stored |
||
386 | endpointDATA - endpoint details on which the transfer is requested |
||
387 | |||
388 | Return Values: |
||
389 | USB_SUCCESS - Request started successfully |
||
390 | USB_CDC_DEVICE_NOT_FOUND - No device with specified address |
||
391 | USB_CDC_DEVICE_BUSY - Device not in proper state for |
||
392 | performing a transfer |
||
393 | Remarks: |
||
394 | None |
||
395 | *******************************************************************************/ |
||
396 | #define USBHostCDCRead_DATA( address,interface,size,data,endpointData) \ |
||
397 | USBHostCDCTransfer( address,0,1,interface, size,data,endpointData) |
||
398 | |||
399 | /******************************************************************************* |
||
400 | Function: |
||
401 | USBHostCDCSend_DATA( address,interface,size,data,endpointData) |
||
402 | |||
403 | Summary: |
||
404 | This function intiates a write request to a attached CDC device. |
||
405 | |||
406 | Description: |
||
407 | This function starts a CDC write transfer. |
||
408 | |||
409 | Preconditions: |
||
410 | None |
||
411 | |||
412 | Parameters: |
||
413 | address - Device address |
||
414 | interface - interface number of the requested transfer |
||
415 | size - Number of bytes to be transfered to the device |
||
416 | data - address of location where the data to be transferred is stored |
||
417 | endpointDATA - endpoint details on which the transfer is requested |
||
418 | |||
419 | Return Values: |
||
420 | USB_SUCCESS - Request started successfully |
||
421 | USB_CDC_DEVICE_NOT_FOUND - No device with specified address |
||
422 | USB_CDC_DEVICE_BUSY - Device not in proper state for |
||
423 | performing a transfer |
||
424 | Remarks: |
||
425 | None |
||
426 | *******************************************************************************/ |
||
427 | #define USBHostCDCSend_DATA( address,interface,size,data,endpointData) \ |
||
428 | USBHostCDCTransfer( address,0,0,interface, size,data,endpointData) |
||
429 | |||
430 | |||
431 | /******************************************************************************* |
||
432 | Function: |
||
433 | BYTE USBHostCDCDeviceStatus( BYTE deviceAddress ) |
||
434 | |||
435 | Summary: |
||
436 | This function determines the status of a CDC device. |
||
437 | |||
438 | Description: |
||
439 | This function determines the status of a CDC device. |
||
440 | |||
441 | Preconditions: None |
||
442 | |||
443 | Parameters: |
||
444 | BYTE deviceAddress - address of device to query |
||
445 | |||
446 | Return Values: |
||
447 | USB_CDC_DEVICE_NOT_FOUND - Illegal device address, or the |
||
448 | device is not an CDC |
||
449 | USB_CDC_INITIALIZING - CDC is attached and in the |
||
450 | process of initializing |
||
451 | USB_PROCESSING_REPORT_DESCRIPTOR - CDC device is detected and report |
||
452 | descriptor is being parsed |
||
453 | USB_CDC_NORMAL_RUNNING - CDC Device is running normal, |
||
454 | ready to send and receive reports |
||
455 | USB_CDC_DEVICE_HOLDING - Device is holding due to error |
||
456 | USB_CDC_DEVICE_DETACHED - CDC detached. |
||
457 | |||
458 | Remarks: |
||
459 | None |
||
460 | *******************************************************************************/ |
||
461 | BYTE USBHostCDCDeviceStatus( BYTE deviceAddress ); |
||
462 | |||
463 | /******************************************************************************* |
||
464 | Function: |
||
465 | BYTE USBHostCDCResetDevice( BYTE deviceAddress ) |
||
466 | |||
467 | Summary: |
||
468 | This function starts a CDC reset. |
||
469 | |||
470 | Description: |
||
471 | This function starts a CDC reset. A reset can be |
||
472 | issued only if the device is attached and not being initialized. |
||
473 | |||
474 | Precondition: |
||
475 | None |
||
476 | |||
477 | Parameters: |
||
478 | BYTE deviceAddress - Device address |
||
479 | |||
480 | Return Values: |
||
481 | USB_SUCCESS - Reset started |
||
482 | USB_MSD_DEVICE_NOT_FOUND - No device with specified address |
||
483 | USB_MSD_ILLEGAL_REQUEST - Device is in an illegal state for reset |
||
484 | |||
485 | Remarks: |
||
486 | None |
||
487 | *******************************************************************************/ |
||
488 | BYTE USBHostCDCResetDevice( BYTE deviceAddress ); |
||
489 | |||
490 | /******************************************************************************* |
||
491 | Function: |
||
492 | void USBHostCDCTasks( void ) |
||
493 | |||
494 | Summary: |
||
495 | This function performs the maintenance tasks required by CDC class |
||
496 | |||
497 | Description: |
||
498 | This function performs the maintenance tasks required by the CDC |
||
499 | class. If transfer events from the host layer are not being used, then |
||
500 | it should be called on a regular basis by the application. If transfer |
||
501 | events from the host layer are being used, this function is compiled out, |
||
502 | and does not need to be called. |
||
503 | |||
504 | Precondition: |
||
505 | USBHostCDCInitialize() has been called. |
||
506 | |||
507 | Parameters: |
||
508 | None - None |
||
509 | |||
510 | Returns: |
||
511 | None |
||
512 | |||
513 | Remarks: |
||
514 | None |
||
515 | *******************************************************************************/ |
||
516 | void USBHostCDCTasks( void ); |
||
517 | |||
518 | /******************************************************************************* |
||
519 | Function: |
||
520 | USBHostCDCTransfer( BYTE deviceAddress, BYTE direction, BYTE reportid, BYTE size, BYTE *data) |
||
521 | |||
522 | Summary: |
||
523 | This function starts a CDC transfer. |
||
524 | |||
525 | Description: |
||
526 | This function starts a CDC transfer. A read/write wrapper is provided in application |
||
527 | interface file to access this function. |
||
528 | |||
529 | Preconditions: |
||
530 | None |
||
531 | |||
532 | Parameters: |
||
533 | BYTE deviceAddress - Device address |
||
534 | BYTE request - Request type for Communication Interface |
||
535 | BYTE direction - 1=read, 0=write |
||
536 | BYTE interfaceNum - interface number of the requested transfer |
||
537 | BYTE size - Byte size of the data buffer |
||
538 | BYTE *data - Pointer to the data buffer |
||
539 | BYTE endpointDATA - endpoint details on which the transfer is requested |
||
540 | |||
541 | Return Values: |
||
542 | USB_SUCCESS - Request started successfully |
||
543 | USB_CDC_DEVICE_NOT_FOUND - No device with specified address |
||
544 | USB_CDC_DEVICE_BUSY - Device not in proper state for |
||
545 | performing a transfer |
||
546 | Remarks: |
||
547 | None |
||
548 | *******************************************************************************/ |
||
549 | BYTE USBHostCDCTransfer( BYTE deviceAddress,BYTE request , BYTE direction, BYTE interfaceNum, WORD size, BYTE *data , BYTE endpointDATA); |
||
550 | |||
551 | /******************************************************************************* |
||
552 | Function: |
||
553 | BOOL USBHostCDCTransferIsComplete( BYTE deviceAddress, |
||
554 | BYTE *errorCode, DWORD *byteCount ) |
||
555 | |||
556 | Summary: |
||
557 | This function indicates whether or not the last transfer is complete. |
||
558 | |||
559 | Description: |
||
560 | This function indicates whether or not the last transfer is complete. |
||
561 | If the functions returns TRUE, the returned byte count and error |
||
562 | code are valid. Since only one transfer can be performed at once |
||
563 | and only one endpoint can be used, we only need to know the |
||
564 | device address. |
||
565 | |||
566 | Precondition: |
||
567 | None |
||
568 | |||
569 | Parameters: |
||
570 | BYTE deviceAddress - Device address |
||
571 | BYTE *errorCode - Error code from last transfer |
||
572 | DWORD *byteCount - Number of bytes transferred |
||
573 | |||
574 | Return Values: |
||
575 | TRUE - Transfer is complete, errorCode is valid |
||
576 | FALSE - Transfer is not complete, errorCode is not valid |
||
577 | *******************************************************************************/ |
||
578 | BOOL USBHostCDCTransferIsComplete( BYTE deviceAddress, BYTE *errorCode, BYTE *byteCount ); |
||
579 | |||
580 | |||
581 | // ***************************************************************************** |
||
582 | // ***************************************************************************** |
||
583 | // USB Host Callback Function Prototypes |
||
584 | // ***************************************************************************** |
||
585 | // ***************************************************************************** |
||
586 | |||
587 | /******************************************************************************* |
||
588 | Function: |
||
589 | BOOL USBHostCDCInitialize( BYTE address, DWORD flags, BYTE clientDriverID ) |
||
590 | |||
591 | Summary: |
||
592 | This function is the initialization routine for this client driver. |
||
593 | |||
594 | Description: |
||
595 | This function is the initialization routine for this client driver. It |
||
596 | is called by the host layer when the USB device is being enumerated.For a |
||
597 | CDC device we need to look into CDC descriptor, interface descriptor and |
||
598 | endpoint descriptor. |
||
599 | |||
600 | Precondition: |
||
601 | None |
||
602 | |||
603 | Parameters: |
||
604 | BYTE address - Address of the new device |
||
605 | DWORD flags - Initialization flags |
||
606 | BYTE clientDriverID - Client driver identification for device requests |
||
607 | |||
608 | Return Values: |
||
609 | TRUE - We can support the device. |
||
610 | FALSE - We cannot support the device. |
||
611 | |||
612 | Remarks: |
||
613 | None |
||
614 | *******************************************************************************/ |
||
615 | BOOL USBHostCDCInitialize( BYTE address, DWORD flags, BYTE clientDriverID ); |
||
616 | |||
617 | /******************************************************************************* |
||
618 | Function: |
||
619 | BOOL USBHostCDCEventHandler( BYTE address, USB_EVENT event, |
||
620 | void *data, DWORD size ) |
||
621 | |||
622 | Precondition: |
||
623 | The device has been initialized. |
||
624 | |||
625 | Summary: |
||
626 | This function is the event handler for this client driver. |
||
627 | |||
628 | Description: |
||
629 | This function is the event handler for this client driver. It is called |
||
630 | by the host layer when various events occur. |
||
631 | |||
632 | Parameters: |
||
633 | BYTE address - Address of the device |
||
634 | USB_EVENT event - Event that has occurred |
||
635 | void *data - Pointer to data pertinent to the event |
||
636 | DWORD size - Size of the data |
||
637 | |||
638 | Return Values: |
||
639 | TRUE - Event was handled |
||
640 | FALSE - Event was not handled |
||
641 | |||
642 | Remarks: |
||
643 | None |
||
644 | *******************************************************************************/ |
||
645 | BOOL USBHostCDCEventHandler( BYTE address, USB_EVENT event, void *data, DWORD size ); |
||
646 | |||
647 | /******************************************************************************* |
||
648 | Function: |
||
649 | BOOL USBHostCDCInitAddress( BYTE address, DWORD flags, BYTE clientDriverID ) |
||
650 | |||
651 | Precondition: |
||
652 | The device has been enumerated without any errors. |
||
653 | |||
654 | Summary: |
||
655 | This function intializes the address of the attached CDC device. |
||
656 | |||
657 | Description: |
||
658 | This function intializes the address of the attached CDC device. Once the |
||
659 | device is enumerated without any errors, the CDC client call this function. |
||
660 | For all the transfer requesets this address is used to indentify the CDC |
||
661 | device. |
||
662 | |||
663 | |||
664 | Parameters: |
||
665 | BYTE address - Address of the new device |
||
666 | DWORD flags - Initialization flags |
||
667 | BYTE clientDriverID - Client driver identification for device requests |
||
668 | |||
669 | Return Values: |
||
670 | TRUE - We can support the device. |
||
671 | FALSE - We cannot support the device. |
||
672 | |||
673 | Remarks: |
||
674 | None |
||
675 | *******************************************************************************/ |
||
676 | BOOL USBHostCDCInitAddress( BYTE address, DWORD flags, BYTE clientDriverID ); |
||
677 | |||
678 | #endif |
Powered by WebSVN v2.8.3