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
|
//*****************************************************************************
//
// usbdcdc.h - USBLib support for generic CDC ACM (serial) device.
//
// Copyright (c) 2008-2012 Texas Instruments Incorporated. All rights reserved.
// Software License Agreement
//
// Texas Instruments (TI) is supplying this software for use solely and
// exclusively on TI's microcontroller products. The software is owned by
// TI and/or its suppliers, and is protected under applicable copyright
// laws. You may not combine this software with "viral" open-source
// software in order to form a larger program.
//
// THIS SOFTWARE IS PROVIDED "AS IS" AND WITH ALL FAULTS.
// 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. TI SHALL NOT, UNDER ANY
// CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR CONSEQUENTIAL
// DAMAGES, FOR ANY REASON WHATSOEVER.
//
// This is part of revision 9453 of the Stellaris USB Library.
//
//*****************************************************************************
#ifndef __USBDCDC_H__
#define __USBDCDC_H__
//*****************************************************************************
//
// If building with a C++ compiler, make all of the definitions in this header
// have a C binding.
//
//*****************************************************************************
#ifdef __cplusplus
extern "C"
{
#endif
//*****************************************************************************
//
//! \addtogroup cdc_device_class_api
//! @{
//
//*****************************************************************************
//*****************************************************************************
//
// PRIVATE
//
// The first few sections of this header are private defines that are used by
// the USB CDC Serial code and are here only to help with the application
// allocating the correct amount of memory for the CDC Serial device code.
//
//*****************************************************************************
//*****************************************************************************
//
// PRIVATE
//
// This enumeration holds the various states that the device can be in during
// normal operation.
//
//*****************************************************************************
typedef enum
{
//
// Unconfigured.
//
CDC_STATE_UNCONFIGURED,
//
// No outstanding transaction remains to be completed.
//
CDC_STATE_IDLE,
//
// Waiting on completion of a send or receive transaction.
//
CDC_STATE_WAIT_DATA,
//
// Waiting for client to process data.
//
CDC_STATE_WAIT_CLIENT
}
tCDCState;
//*****************************************************************************
//
// PRIVATE
//
// This structure defines the private instance data and state variables for the
// CDC Serial device. The memory for this structure is pointed to by the
// psPrivateCDCSerData field in the tUSBDCDCDevice structure passed on
// USBDCDCInit().
//
//*****************************************************************************
typedef struct
{
unsigned long ulUSBBase;
tDeviceInfo *psDevInfo;
tConfigDescriptor *psConfDescriptor;
volatile tCDCState eCDCRxState;
volatile tCDCState eCDCTxState;
volatile tCDCState eCDCRequestState;
volatile tCDCState eCDCInterruptState;
volatile unsigned char ucPendingRequest;
unsigned short usBreakDuration;
unsigned short usControlLineState;
unsigned short usSerialState;
volatile unsigned short usDeferredOpFlags;
unsigned short usLastTxSize;
tLineCoding sLineCoding;
volatile tBoolean bRxBlocked;
volatile tBoolean bControlBlocked;
volatile tBoolean bConnected;
unsigned char ucControlEndpoint;
unsigned char ucBulkINEndpoint;
unsigned char ucBulkOUTEndpoint;
unsigned char ucInterfaceControl;
unsigned char ucInterfaceData;
}
tCDCSerInstance;
#ifndef DEPRECATED
//*****************************************************************************
//
// The number of bytes of workspace required by the CDC device class driver.
// The client must provide a block of RAM of at least this size in the
// psPrivateCDCSerData field of the tUSBCDCDevice structure passed on
// USBDCDCInit().
//
// This value is deprecated and should not be used, any new code should just
// pass in a tUSBCDCDevice structure in the psPrivateCDCSerData field.
//
//*****************************************************************************
#define USB_CDCSER_WORKSPACE_SIZE (sizeof(tCDCSerInstance))
#endif
//*****************************************************************************
//
// The following defines are used when working with composite devices.
//
//*****************************************************************************
//*****************************************************************************
//
//! The size of the memory that should be allocated to create a configuration
//! descriptor for a single instance of the USB Serial CDC Device.
//! This does not include the configuration descriptor which is automatically
//! ignored by the composite device class.
//
// For reference this is sizeof(g_pIADSerDescriptor) +
// sizeof(g_pCDCSerCommInterface) + sizeof(g_pCDCSerDataInterface)
//
//*****************************************************************************
#define COMPOSITE_DCDC_SIZE (8 + 35 + 23)
//*****************************************************************************
//
// CDC-specific events These events are provided to the application in the
// \e ulMsg parameter of the tUSBCallback function.
//
//*****************************************************************************
//
//! The host requests that the device send a BREAK condition on its
//! serial communication channel. The BREAK should remain active until
//! a USBD_CDC_EVENT_CLEAR_BREAK event is received.
//
#define USBD_CDC_EVENT_SEND_BREAK (USBD_CDC_EVENT_BASE + 0)
//
//! The host requests that the device stop sending a BREAK condition on its
//! serial communication channel.
//
#define USBD_CDC_EVENT_CLEAR_BREAK (USBD_CDC_EVENT_BASE + 1)
//
//! The host requests that the device set the RS232 signaling lines to
//! a particular state. The ulMsgValue parameter contains the RTS and
//! DTR control line states as defined in table 51 of the USB CDC class
//! definition and is a combination of the following values:
//!
//! (RTS) USB_CDC_DEACTIVATE_CARRIER or USB_CDC_ACTIVATE_CARRIER
//! (DTR) USB_CDC_DTE_NOT_PRESENT or USB_CDC_DTE_PRESENT
//
#define USBD_CDC_EVENT_SET_CONTROL_LINE_STATE (USBD_CDC_EVENT_BASE + 2)
//
//! The host requests that the device set the RS232 communication
//! parameters. The pvMsgData parameter points to a tLineCoding structure
//! defining the required number of bits per character, parity mode,
//! number of stop bits and the baud rate.
//
#define USBD_CDC_EVENT_SET_LINE_CODING (USBD_CDC_EVENT_BASE + 3)
//
//! The host is querying the current RS232 communication parameters. The
//! pvMsgData parameter points to a tLineCoding structure that the
//! application must fill with the current settings prior to returning
//! from the callback.
//
#define USBD_CDC_EVENT_GET_LINE_CODING (USBD_CDC_EVENT_BASE + 4)
//*****************************************************************************
//
//! The structure used by the application to define operating parameters for
//! the CDC device.
//
//*****************************************************************************
typedef struct
{
//
//! The vendor ID that this device is to present in the device descriptor.
//
unsigned short usVID;
//
//! The product ID that this device is to present in the device descriptor.
//
unsigned short usPID;
//
//! The maximum power consumption of the device, expressed in milliamps.
//
unsigned short usMaxPowermA;
//
//! Indicates whether the device is self- or bus-powered and whether or not
//! it supports remote wakeup. Valid values are USB_CONF_ATTR_SELF_PWR or
//! USB_CONF_ATTR_BUS_PWR, optionally ORed with USB_CONF_ATTR_RWAKE.
//
unsigned char ucPwrAttributes;
//
//! A pointer to the callback function which will be called to notify
//! the application of all asynchronous control events related to the
//! operation of the device.
//
tUSBCallback pfnControlCallback;
//
//! A client-supplied pointer which will be sent as the first
//! parameter in all calls made to the control channel callback,
//! pfnControlCallback.
//
void *pvControlCBData;
//
//! A pointer to the callback function which will be called to notify
//! the application of events related to the device's data receive channel.
//
tUSBCallback pfnRxCallback;
//
//! A client-supplied pointer which will be sent as the first
//! parameter in all calls made to the receive channel callback,
//! pfnRxCallback.
//
void *pvRxCBData;
//
//! A pointer to the callback function which will be called to notify
//! the application of events related to the device's data transmit
//! channel.
//
tUSBCallback pfnTxCallback;
//
//! A client-supplied pointer which will be sent as the first
//! parameter in all calls made to the transmit channel callback,
//! pfnTxCallback.
//
void *pvTxCBData;
//
//! A pointer to the string descriptor array for this device. This array
//! must contain the following string descriptor pointers in this order.
//! Language descriptor, Manufacturer name string (language 1), Product
//! name string (language 1), Serial number string (language 1),
//! Control interface description string (language 1), Configuration
//! description string (language 1).
//!
//! If supporting more than 1 language, the strings for indices 1 through 5
//! must be repeated for each of the other languages defined in the
//! language descriptor.
//
const unsigned char * const *ppStringDescriptors;
//
//! The number of descriptors provided in the ppStringDescriptors
//! array. This must be 1 + (5 * number of supported languages).
//
unsigned long ulNumStringDescriptors;
//
//! A pointer to the private instance data for this device. This memory
//! must remain accessible for as long as the CDC device is in use and must
//! not be modified by any code outside the CDC class driver.
//
tCDCSerInstance *psPrivateCDCSerData;
}
tUSBDCDCDevice;
extern tDeviceInfo g_sCDCSerDeviceInfo;
//*****************************************************************************
//
// API Function Prototypes
//
//*****************************************************************************
extern void * USBDCDCCompositeInit(unsigned long ulIndex,
const tUSBDCDCDevice *psCDCDevice);
extern void *USBDCDCInit(unsigned long ulIndex,
const tUSBDCDCDevice *psCDCDevice);
extern void USBDCDCTerm(void *pvInstance);
extern void *USBDCDCSetControlCBData(void *pvInstance, void *pvCBData);
extern void *USBDCDCSetRxCBData(void *pvInstance, void *pvCBData);
extern void *USBDCDCSetTxCBData(void *pvInstance, void *pvCBData);
extern unsigned long USBDCDCPacketWrite(void *pvInstance,
unsigned char *pcData,
unsigned long ulLength,
tBoolean bLast);
extern unsigned long USBDCDCPacketRead(void *pvInstance,
unsigned char *pcData,
unsigned long ulLength,
tBoolean bLast);
extern unsigned long USBDCDCTxPacketAvailable(void *pvInstance);
extern unsigned long USBDCDCRxPacketAvailable(void *pvInstance);
extern void USBDCDCSerialStateChange(void *pvInstance,
unsigned short usState);
extern void USBDCDCPowerStatusSet(void *pvInstance, unsigned char ucPower);
extern tBoolean USBDCDCRemoteWakeupRequest(void *pvInstance);
//*****************************************************************************
//
// Close the Doxygen group.
//! @}
//
//*****************************************************************************
//*****************************************************************************
//
// Mark the end of the C bindings section for C++ compilers.
//
//*****************************************************************************
#ifdef __cplusplus
}
#endif
#endif // __USBDCDC_H__
|