tmp
doxygen.7AND9C
usbcdc.h
Go to the documentation of this file.
1
//*****************************************************************************
2
//
3
// usbhid.h - Definitions used by Communication Device Class devices.
4
//
5
// Copyright (c) 2007-2017 Texas Instruments Incorporated. All rights reserved.
6
// Software License Agreement
7
//
8
// Texas Instruments (TI) is supplying this software for use solely and
9
// exclusively on TI's microcontroller products. The software is owned by
10
// TI and/or its suppliers, and is protected under applicable copyright
11
// laws. You may not combine this software with "viral" open-source
12
// software in order to form a larger program.
13
//
14
// THIS SOFTWARE IS PROVIDED "AS IS" AND WITH ALL FAULTS.
15
// NO WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT
16
// NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
17
// A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. TI SHALL NOT, UNDER ANY
18
// CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR CONSEQUENTIAL
19
// DAMAGES, FOR ANY REASON WHATSOEVER.
20
//
21
//*****************************************************************************
22
23
//*****************************************************************************
24
//
25
// Note: This header contains definitions related to the USB Communication
26
// Device Class specification. The header is complete for ACM model
27
// devices but request and notification definitions specific to other
28
// modem types, ISDN, ATM and Ethernet are currently incomplete or
29
// omitted.
30
//
31
//*****************************************************************************
32
33
#ifndef __USBCDC_H__
34
#define __USBCDC_H__
35
36
//*****************************************************************************
37
//
38
// If building with a C++ compiler, make all of the definitions in this header
39
// have a C binding.
40
//
41
//*****************************************************************************
42
#ifdef __cplusplus
43
extern
"C"
44
{
45
#endif
46
47
//*****************************************************************************
48
//
51
//
52
//*****************************************************************************
53
54
//*****************************************************************************
55
//
56
// Generic macros to read an 8-bit, 16-bit or 32-bit value from a character
57
// pointer.
58
//
59
//*****************************************************************************
60
#define BYTE(pui8Data) (*(uint8_t *)(pui8Data))
61
#define SHORT(pui8Data) (*(uint16_t *)(pui8Data))
62
#define LONG(pui8Data) (*(uint32_t *)(pui8Data))
63
64
//*****************************************************************************
65
//
66
// USB CDC subclass codes. Used in interface descriptor, bInterfaceClass
67
//
68
//*****************************************************************************
69
#define USB_CDC_SUBCLASS_DIRECT_LINE_MODEL \
70
0x01
71
#define USB_CDC_SUBCLASS_ABSTRACT_MODEL \
72
0x02
73
#define USB_CDC_SUBCLASS_TELEPHONE_MODEL \
74
0x03
75
#define USB_CDC_SUBCLASS_MULTI_CHANNEL_MODEL \
76
0x04
77
#define USB_CDC_SUBCLASS_CAPI_MODEL \
78
0x05
79
#define USB_CDC_SUBCLASS_ETHERNET_MODEL \
80
0x06
81
#define USB_CDC_SUBCLASS_ATM_MODEL \
82
0x07
83
84
//*****************************************************************************
85
//
86
// USB CDC control interface protocols. Used in control interface descriptor,
87
// bInterfaceProtocol
88
//
89
//*****************************************************************************
90
#define USB_CDC_PROTOCOL_NONE 0x00
91
#define USB_CDC_PROTOCOL_V25TER 0x01
92
#define USB_CDC_PROTOCOL_VENDOR 0xFF
93
94
//*****************************************************************************
95
//
96
// USB CDC data interface protocols. Used in data interface descriptor,
97
// bInterfaceProtocol
98
//
99
//*****************************************************************************
100
#define USB_CDC_PROTOCOL_NONE 0x00
101
#define USB_CDC_PROTOCOL_I420 0x30
102
#define USB_CDC_PROTOCOL_TRANSPARENT \
103
0x32
104
#define USB_CDC_PROTOCOL_Q921M 0x50
105
#define USB_CDC_PROTOCOL_Q921 0x51
106
#define USB_CDC_PROTOCOL_Q921TM 0x52
107
#define USB_CDC_PROTOCOL_V42BIS 0x90
108
#define USB_CDC_PROTOCOL_Q921EURO \
109
0x91
110
#define USB_CDC_PROTOCOL_V120 0x92
111
#define USB_CDC_PROTOCOL_CAPI20 0x93
112
#define USB_CDC_PROTOCOL_HOST_DRIVER \
113
0xFD
114
#define USB_CDC_PROTOCOL_CDC_SPEC \
115
0xFE
116
#define USB_CDC_PROTOCOL_VENDOR 0xFF
117
118
//*****************************************************************************
119
//
120
// Functional descriptor definitions
121
//
122
//*****************************************************************************
123
124
//*****************************************************************************
125
//
126
// Functional descriptor types
127
//
128
//*****************************************************************************
129
#define USB_CDC_CS_INTERFACE 0x24
130
#define USB_CDC_CS_ENDPOINT 0x25
131
132
//*****************************************************************************
133
//
134
// Functional descriptor subtypes
135
//
136
//*****************************************************************************
137
#define USB_CDC_FD_SUBTYPE_HEADER \
138
0x00
139
#define USB_CDC_FD_SUBTYPE_CALL_MGMT \
140
0x01
141
#define USB_CDC_FD_SUBTYPE_ABSTRACT_CTL_MGMT \
142
0x02
143
#define USB_CDC_FD_SUBTYPE_DIRECT_LINE_MGMT \
144
0x03
145
#define USB_CDC_FD_SUBTYPE_TELEPHONE_RINGER \
146
0x04
147
#define USB_CDC_FD_SUBTYPE_LINE_STATE_CAPS \
148
0x05
149
#define USB_CDC_FD_SUBTYPE_UNION \
150
0x06
151
#define USB_CDC_FD_SUBTYPE_COUNTRY \
152
0x07
153
#define USB_CDC_FD_SUBTYPE_TELEPHONE_MODES \
154
0x08
155
#define USB_CDC_FD_SUBTYPE_USB_TERMINAL \
156
0x09
157
#define USB_CDC_FD_SUBTYPE_NETWORK_TERMINAL \
158
0x0A
159
#define USB_CDC_FD_SUBTYPE_PROTOCOL_UNIT \
160
0x0B
161
#define USB_CDC_FD_SUBTYPE_EXTENSION_UNIT \
162
0x0C
163
#define USB_CDC_FD_SUBTYPE_MULTI_CHANNEL_MGMT \
164
0x0D
165
#define USB_CDC_FD_SUBTYPE_CAPI_MGMT \
166
0x0E
167
#define USB_CDC_FD_SUBTYPE_ETHERNET \
168
0x0F
169
#define USB_CDC_FD_SUBTYPE_ATM 0x10
170
171
//*****************************************************************************
172
//
173
// USB_CDC_FD_SUBTYPE_CALL_MGMT, Header functional descriptor, bmCapabilities
174
//
175
//*****************************************************************************
176
#define USB_CDC_CALL_MGMT_VIA_DATA \
177
0x02
178
#define USB_CDC_CALL_MGMT_HANDLED \
179
0x01
180
181
//*****************************************************************************
182
//
183
// USB_CDC_FD_SUBTYPE_ABSTRACT_CTL_MGMT, Abstract Control Management functional
184
// descriptor, bmCapabilities
185
//
186
//*****************************************************************************
187
#define USB_CDC_ACM_SUPPORTS_NETWORK_CONNECTION \
188
0x08
189
#define USB_CDC_ACM_SUPPORTS_SEND_BREAK \
190
0x04
191
#define USB_CDC_ACM_SUPPORTS_LINE_PARAMS \
192
0x02
193
#define USB_CDC_ACM_SUPPORTS_COMM_FEATURE \
194
0x01
195
196
//*****************************************************************************
197
//
198
// USB_CDC_FD_SUBTYPE_DIRECT_LINE_MGMT, Direct Line Management functional
199
// descriptor, bmCapabilities
200
//
201
//*****************************************************************************
202
#define USB_CDC_DLM_NEEDS_EXTRA_PULSE_SETUP \
203
0x04
204
#define USB_CDC_DLM_SUPPORTS_AUX \
205
0x02
206
#define USB_CDC_DLM_SUPPORTS_PULSE \
207
0x01
208
209
//*****************************************************************************
210
//
211
// USB_CDC_FD_SUBTYPE_TELEPHONE_MODES, Telephone Operational Modes functional
212
// descriptor, bmCapabilities
213
//
214
//*****************************************************************************
215
#define USB_CDC_TELEPHONE_SUPPORTS_COMPUTER \
216
0x04
217
#define USB_CDC_TELEPHONE_SUPPORTS_STANDALONE \
218
0x02
219
#define USB_CDC_TELEPHONE_SUPPORTS_SIMPLE \
220
0x01
221
222
//*****************************************************************************
223
//
224
// USB_CDC_FD_SUBTYPE_LINE_STATE_CAPS, Telephone Call and Line State Reporting
225
// Capabilities descriptor
226
//
227
//*****************************************************************************
228
#define USB_CDC_LINE_STATE_CHANGES_NOTIFIED \
229
0x20
230
#define USB_CDC_LINE_STATE_REPORTS_DTMF \
231
0x10
232
#define USB_CDC_LINE_STATE_REPORTS_DIST_RING \
233
0x08
234
#define USB_CDC_LINE_STATE_REPORTS_CALLERID \
235
0x04
236
#define USB_CDC_LINE_STATE_REPORTS_BUSY \
237
0x02
238
#define USB_CDC_LINE_STATE_REPORTS_INT_DIALTONE \
239
0x01
240
241
//*****************************************************************************
242
//
243
// USB_CDC_FD_SUBTYPE_USB_TERMINAL, USB Terminal functional descriptor,
244
// bmOptions
245
//
246
//*****************************************************************************
247
#define USB_CDC_TERMINAL_NO_WRAPPER_USED \
248
0x00
249
#define USB_CDC_TERMINAL_WRAPPER_USED \
250
0x01
251
252
//*****************************************************************************
253
//
254
// USB_CDC_FD_SUBTYPE_MULTI_CHANNEL_MGMT, Multi-Channel Management functional
255
// descriptor, bmCapabilities
256
//
257
//*****************************************************************************
258
#define USB_CDC_MCM_SUPPORTS_SET_UNIT_PARAM \
259
0x04
260
#define USB_CDC_MCM_SUPPORTS_CLEAR_UNIT_PARAM \
261
0x02
262
#define USB_CDC_MCM_UNIT_PARAMS_NON_VOLATILE \
263
0x01
264
265
//*****************************************************************************
266
//
267
// USB_CDC_FD_SUBTYPE_CAPI_MGMT, CAPI Control Management functional descriptor,
268
// bmCapabilities
269
//
270
//*****************************************************************************
271
#define USB_CDC_CAPI_INTELLIGENT \
272
0x01
273
#define USB_CDC_CAPI_SIMPLE 0x00
274
275
//*****************************************************************************
276
//
277
// USB_CDC_FD_SUBTYPE_ETHERNET, Ethernet Networking functional descriptor,
278
// bmEthernetStatistics
279
//
280
//*****************************************************************************
281
#define USB_CDC_ETHERNET_XMIT_OK \
282
0x01000000
283
#define USB_CDC_ETHERNET_RCV_OK 0x02000000
284
#define USB_CDC_ETHERNET_XMIT_ERROR \
285
0x04000000
286
#define USB_CDC_ETHERNET_RCV_ERROR \
287
0x08000000
288
#define USB_CDC_ETHERNET_RCV_NO_BUFFER \
289
0x10000000
290
#define USB_CDC_ETHERNET_DIRECTED_BYTES_XMIT \
291
0x20000000
292
#define USB_CDC_ETHERNET_DIRECTED_FRAMES_XMIT \
293
0x40000000
294
#define USB_CDC_ETHERNET_MULTICAST_BYTES_XMIT \
295
0x80000000
296
#define USB_CDC_ETHERNET_MULTICAST_FRAMES_XMIT \
297
0x00010000
298
#define USB_CDC_ETHERNET_BROADCAST_BYTES_XMIT \
299
0x00020000
300
#define USB_CDC_ETHERNET_BROADCAST_FRAMES_XMIT \
301
0x00040000
302
#define USB_CDC_ETHERNET_DIRECTED_BYTES_RCV \
303
0x00080000
304
#define USB_CDC_ETHERNET_DIRECTED_FRAMES_RCV \
305
0x00100000
306
#define USB_CDC_ETHERNET_MULTICAST_BYTES_RCV \
307
0x00200000
308
#define USB_CDC_ETHERNET_MULTICAST_FRAMES_RCV \
309
0x00400000
310
#define USB_CDC_ETHERNET_BROADCAST_BYTES_RCV \
311
0x00800000
312
#define USB_CDC_ETHERNET_BROADCAST_FRAMES_RCV \
313
0x00000100
314
#define USB_CDC_ETHERNET_RCV_CRC_ERROR \
315
0x00000200
316
#define USB_CDC_ETHERNET_TRANSMIT_QUEUE_LENGTH \
317
0x00000400
318
#define USB_CDC_ETHERNET_RCV_ERROR_ALIGNMENT \
319
0x00000800
320
#define USB_CDC_ETHERNET_XMIT_ONE_COLLISION \
321
0x00001000
322
#define USB_CDC_ETHERNET_XMIT_MORE_COLLISIONS \
323
0x00002000
324
#define USB_CDC_ETHERNET_XMIT_DEFERRED \
325
0x00004000
326
#define USB_CDC_ETHERNET_XMIT_MAX_COLLISIONS \
327
0x00008000
328
#define USB_CDC_ETHERNET_RCV_OVERRUN \
329
0x00000001
330
#define USB_CDC_ETHERNET_XMIT_UNDERRUN \
331
0x00000002
332
#define USB_CDC_ETHERNET_XMIT_HEARTBEAT_FAILURE \
333
0x00000004
334
#define USB_CDC_ETHERNET_XMIT_TIMES_CRS_LOST \
335
0x00000010
336
337
//*****************************************************************************
338
//
339
// USB_CDC_FD_SUBTYPE_ATM, ATM Networking functional descriptor,
340
// bmDataCapabilities
341
//
342
//*****************************************************************************
343
#define USB_CDC_ATM_TYPE_3 0x08
344
#define USB_CDC_ATM_TYPE_2 0x04
345
#define USB_CDC_ATM_TYPE_1 0x02
346
347
//*****************************************************************************
348
//
349
// bmATMDeviceStatistics
350
//
351
//*****************************************************************************
352
#define USB_CDC_ATM_VC_US_CELLS_SENT \
353
0x10
354
#define USB_CDC_ATM_VC_US_CELLS_RECEIVED \
355
0x08
356
#define USB_CDC_ATM_DS_CELLS_HEC_ERR_CORRECTED \
357
0x04
358
#define USB_CDC_ATM_US_CELLS_SENT \
359
0x02
360
#define USB_CDC_ATM_US_CELLS_RECEIVED \
361
0x01
362
363
//*****************************************************************************
364
//
365
// Management Element Requests (provided in tUSBRequest.bRequest)
366
//
367
//*****************************************************************************
368
#define USB_CDC_SEND_ENCAPSULATED_COMMAND \
369
0x00
370
#define USB_CDC_GET_ENCAPSULATED_RESPONSE \
371
0x01
372
#define USB_CDC_SET_COMM_FEATURE \
373
0x02
374
#define USB_CDC_GET_COMM_FEATURE \
375
0x03
376
#define USB_CDC_CLEAR_COMM_FEATURE \
377
0x04
378
#define USB_CDC_SET_AUX_LINE_STATE \
379
0x10
380
#define USB_CDC_SET_HOOK_STATE 0x11
381
#define USB_CDC_PULSE_SETUP 0x12
382
#define USB_CDC_SEND_PULSE 0x13
383
#define USB_CDC_SET_PULSE_TIME 0x14
384
#define USB_CDC_RING_AUX_JACK 0x15
385
#define USB_CDC_SET_LINE_CODING 0x20
386
#define USB_CDC_GET_LINE_CODING 0x21
387
#define USB_CDC_SET_CONTROL_LINE_STATE \
388
0x22
389
#define USB_CDC_SEND_BREAK 0x23
390
#define USB_CDC_SET_RINGER_PARMS \
391
0x30
392
#define USB_CDC_GET_RINGER_PARMS \
393
0x31
394
#define USB_CDC_SET_OPERATION_PARMS \
395
0x32
396
#define USB_CDC_GET_OPERATION_PARMS \
397
0x33
398
#define USB_CDC_SET_LINE_PARMS 0x34
399
#define USB_CDC_GET_LINE_PARMS 0x35
400
#define USB_CDC_DIAL_DIGITS 0x36
401
#define USB_CDC_SET_UNIT_PARAMETER \
402
0x37
403
#define USB_CDC_GET_UNIT_PARAMETER \
404
0x38
405
#define USB_CDC_CLEAR_UNIT_PARAMETER \
406
0x39
407
#define USB_CDC_GET_PROFILE 0x3A
408
#define USB_CDC_SET_ETHERNET_MULTICAST_FILTERS \
409
0x40
410
#define USB_CDC_SET_ETHERNET_POWER_MANAGEMENT_PATTERN_FILTER \
411
0x41
412
#define USB_CDC_GET_ETHERNET_POWER_MANAGEMENT_PATTERN_FILTER \
413
0x42
414
#define USB_CDC_SET_ETHERNET_PACKET_FILTER \
415
0x43
416
#define USB_CDC_GET_ETHERNET_STATISTIC \
417
0x44
418
#define USB_CDC_SET_ATM_DATA_FORMAT \
419
0x50
420
#define USB_CDC_GET_ATM_DEVICE_STATISTICS \
421
0x51
422
#define USB_CDC_SET_ATM_DEFAULT_VC \
423
0x52
424
#define USB_CDC_GET_ATM_VC_STATISTICS \
425
0x53
426
427
//*****************************************************************************
428
//
429
// In cases where a request defined above results in the return of a fixed size
430
// data block, the following group of labels define the size of that block. In
431
// each of these cases, an access macro is also provided to write the response
432
// data into an appropriately-sized array of 8-bit characters.
433
//
434
//*****************************************************************************
435
#define USB_CDC_SIZE_COMM_FEATURE \
436
2
437
#define USB_CDC_SIZE_LINE_CODING \
438
7
439
#define USB_CDC_SIZE_RINGER_PARMS \
440
4
441
#define USB_CDC_SIZE_OPERATION_PARMS \
442
2
443
#define USB_CDC_SIZE_UNIT_PARAMETER \
444
2
445
#define USB_CDC_SIZE_PROFILE 64
446
#define USB_CDC_SIZE_ETHERNET_POWER_MANAGEMENT_PATTERN_FILTER \
447
2
448
#define USB_CDC_SIZE_ETHERNET_STATISTIC \
449
4
450
#define USB_CDC_SIZE_ATM_DEVICE_STATISTICS \
451
4
452
#define USB_CDC_SIZE_ATM_VC_STATISTICS \
453
4
454
#define USB_CDC_SIZE_LINE_PARMS \
455
10
456
457
//*****************************************************************************
458
//
459
// NB: USB_CDC_SIZE_LINE_PARAMS assumes only a single call. For multiple
460
// calls, add 4 bytes per additional call.
461
//
462
//*****************************************************************************
463
464
//*****************************************************************************
465
//
466
// USB_CDC_GET_COMM_FEATURE & USB_CDC_SET_COMM_FEATURE
467
//
468
//*****************************************************************************
469
470
//*****************************************************************************
471
//
472
// wValue (Feature Selector)
473
//
474
//*****************************************************************************
475
#define USB_CDC_ABSTRACT_STATE 0x0001
476
#define USB_CDC_COUNTRY_SETTING 0x0002
477
478
//*****************************************************************************
479
//
480
// Data when feature selector is USB_DCD_ABSTRACT_STATE
481
//
482
//*****************************************************************************
483
#define USB_CDC_ABSTRACT_CALL_DATA_MULTIPLEXED \
484
0x0002
485
#define USB_CDC_ABSTRACT_ENDPOINTS_IDLE \
486
0x0001
487
488
//*****************************************************************************
489
//
490
// Macros to populate the response data buffer (whose size in bytes is defined
491
// by USB_CDC_SIZE_COMM_FEATURE).
492
//
493
//*****************************************************************************
494
#define SetResponseCommFeature(pi8Buf, ui16Data) \
495
do \
496
{ \
497
(*(uint16_t *)(pi8Buf)) = ui16Data; \
498
} \
499
while(0)
500
501
//*****************************************************************************
502
//
503
// USB_CDC_SET_AUX_LINE_STATE, wValue
504
//
505
//*****************************************************************************
506
#define USB_CDC_AUX_DISCONNECT 0x0000
507
#define USB_CDC_AUX_CONNECT 0x0001
508
509
//*****************************************************************************
510
//
511
// USB_CDC_SET_HOOK_STATE, wValue
512
//
513
//*****************************************************************************
514
#define USB_CDC_ON_HOOK 0x0000
515
#define USB_CDC_OFF_HOOK 0x0001
516
#define USB_CDC_SNOOPING 0x0002
517
518
//*****************************************************************************
519
//
520
// USB_CDC_GET_LINE_CODING
521
//
522
//*****************************************************************************
523
#define USB_CDC_STOP_BITS_1 0x00
524
#define USB_CDC_STOP_BITS_1_5 0x01
525
#define USB_CDC_STOP_BITS_2 0x02
526
527
#define USB_CDC_PARITY_NONE 0x00
528
#define USB_CDC_PARITY_ODD 0x01
529
#define USB_CDC_PARITY_EVEN 0x02
530
#define USB_CDC_PARITY_MARK 0x03
531
#define USB_CDC_PARITY_SPACE 0x04
532
533
//*****************************************************************************
534
//
535
// Macro to populate the response data buffer (whose size in bytes is defined
536
// by USB_CDC_SIZE_LINE_CODING).
537
//
538
//*****************************************************************************
539
#define SetResponseLineCoding(pi8Buf, ui8Rate, ui8Stop, ui8Parity, \
540
ui8Databits) \
541
do \
542
{ \
543
(*(uint32_t *)(pi8Buf)) = ui8Rate; \
544
(*((uint8_t *)(pi8Buf) + 4)) = ui8Stop; \
545
(*((uint8_t *)(pi8Buf) + 5)) = ui8Parity; \
546
(*((uint8_t *)(pi8Buf) + 6)) = ui8Databits; \
547
} \
548
while(0)
549
550
//*****************************************************************************
551
//
552
// USB_CDC_SET_CONTROL_LINE_STATE, wValue
553
//
554
//*****************************************************************************
555
#define USB_CDC_DEACTIVATE_CARRIER \
556
0x00
557
#define USB_CDC_ACTIVATE_CARRIER \
558
0x02
559
#define USB_CDC_DTE_NOT_PRESENT 0x00
560
#define USB_CDC_DTE_PRESENT 0x01
561
562
//*****************************************************************************
563
//
564
// USB_CDC_SET_RINGER_PARMS, USB_CDC_GET_RINGER_PARMS and
565
// USB_CDC_GET_LINE_PARMS (ui32RingerBmp)
566
//
567
//*****************************************************************************
568
#define USB_CDC_RINGER_EXISTS 0x80000000
569
#define USB_CDC_RINGER_DOES_NOT_EXIST \
570
0x00000000
571
572
//*****************************************************************************
573
//
574
// Macro to populate the response data buffer to USB_CDC_GET_RINGER_PARMS.
575
// Parameter buf points to a buffer of size USB_CDC_SIZE_RINGER_PARMS bytes.
576
//
577
//*****************************************************************************
578
#define SetResponseRingerParms(pi8Buf, ui8Pattern, ui8Volume, ui32Exists) \
579
do \
580
{ \
581
*(uint32_t *)(pi8Buf) = ((ui8Pattern) + \
582
((ui8Volume & 0xFF) << 8) + \
583
(ui32Exists & USB_CDC_RINGER_EXISTS)); \
584
} \
585
while(0)
586
587
//*****************************************************************************
588
//
589
// Macros to extract fields from the USB_CDC_SET_RINGER_PARMS data
590
//
591
//*****************************************************************************
592
#define GetRingerVolume(pi8Data) \
593
(BYTE((pi8Data) + 1))
594
#define GetRingerPattern(pi8Data) \
595
(BYTE(pi8Data))
596
#define GetRingerExists(pi8Data) \
597
((LONG(pi8Data)) & USB_CDC_RINGER_EXISTS)
598
599
//*****************************************************************************
600
//
601
// USB_CDC_SET_OPERATION_PARMS, wValue
602
//
603
//*****************************************************************************
604
#define USB_CDC_SIMPLE_MODE 0x0000
605
#define USB_CDC_STANDALONE_MODE 0x0001
606
#define USB_CDC_HOST_CENTRIC_MODE \
607
0x0002
608
609
//*****************************************************************************
610
//
611
// Macro to populate the response data buffer to USB_CDC_GET_OPERATION_PARMS.
612
// Parameter buf points to a buffer of size USB_CDC_SIZE_OPERATION_PARMS
613
// bytes.
614
//
615
//*****************************************************************************
616
#define SetResponseOperationParms(pi8Bbuf, ui16Data) \
617
do \
618
{ \
619
WORD(pi8Buf) = ui16Data; \
620
} \
621
while(0)
622
623
//*****************************************************************************
624
//
625
// USB_CDC_SET_LINE_PARMS, wParam - Line State Change
626
//
627
//*****************************************************************************
628
#define USB_CDC_DROP_ACTIVE_CALL \
629
0x0000
630
#define USB_CDC_START_NEW_CALL 0x0001
631
#define USB_CDC_APPLY_RINGING 0x0002
632
#define USB_CDC_REMOVE_RINGING 0x0003
633
#define USB_CDC_SWITCH_CALL 0x0004
634
635
//*****************************************************************************
636
//
637
// Line state bitmap in USB_CDC_GET_LINE_PARMS response
638
//
639
//*****************************************************************************
640
#define USB_CDC_LINE_IS_ACTIVE 0x80000000
641
#define USB_CDC_LINE_IS_IDLE 0x00000000
642
#define USB_CDC_LINE_NO_ACTIVE_CALL \
643
0x000000FF
644
645
#define USB_CDC_CALL_ACTIVE 0x80000000
646
647
//*****************************************************************************
648
//
649
// Call state value definitions
650
//
651
//*****************************************************************************
652
#define USB_CDC_CALL_IDLE 0x00000000
653
#define USB_CDC_CALL_TYPICAL_DIALTONE \
654
0x00000001
655
#define USB_CDC_CALL_INTERRUPTED_DIALTONE \
656
0x00000002
657
#define USB_CDC_CALL_DIALING 0x00000003
658
#define USB_CDC_CALL_RINGBACK 0x00000004
659
#define USB_CDC_CALL_CONNECTED 0x00000005
660
#define USB_CDC_CALL_INCOMING 0x00000006
661
662
//*****************************************************************************
663
//
664
// Call state change value definitions
665
//
666
//*****************************************************************************
667
#define USB_CDC_CALL_STATE_IDLE 0x01
668
#define USB_CDC_CALL_STATE_DIALING \
669
0x02
670
#define USB_CDC_CALL_STATE_RINGBACK \
671
0x03
672
#define USB_CDC_CALL_STATE_CONNECTED \
673
0x04
674
#define USB_CDC_CALL_STATE_INCOMING \
675
0x05
676
677
//*****************************************************************************
678
//
679
// Extra byte of data describing the connection type for
680
// USB_CDC_CALL_STATE_CONNECTED.
681
//
682
//*****************************************************************************
683
#define USB_CDC_VOICE 0x00
684
#define USB_CDC_ANSWERING_MACHINE \
685
0x01
686
#define USB_CDC_FAX 0x02
687
#define USB_CDC_MODEM 0x03
688
#define USB_CDC_UNKNOWN 0xFF
689
690
//*****************************************************************************
691
//
692
// Macro to extract call index from request in cases where wParam is
693
// USB_CDC_SWITCH_CALL.
694
//
695
//*****************************************************************************
696
#define GetCallIndex(pi8Data) (BYTE(pi8Data))
697
698
//*****************************************************************************
699
//
700
// Macro to populate the CallState entries in response to request
701
// USB_CDC_GET_LINE_PARMS. The ui8Index parameter is a zero based index
702
// indicating which call entry in the pi8Buf response buffer to fill in. Note
703
// that pi8Buf points to the first byte of the buffer (the wLength field).
704
//
705
//*****************************************************************************
706
#define SetResponseCallState(pi8Buf, ui8Index, ui32Active, ui8StateChange, \
707
ui8State) \
708
do \
709
{ \
710
(LONG((uint8_t *)(pi8Buf) + (10 + (4 * (ui8Index))))) = \
711
(((ui32Active) & USB_CDC_CALL_IS_ACTIVE) + \
712
(((ui8StateChange) & 0xFF) << 8) + \
713
((ui8State) & 0xFF)); \
714
} \
715
while(0)
716
717
//*****************************************************************************
718
//
719
// Macro to populate the response data buffer (whose size in bytes is defined
720
// by USB_CDC_SIZE_LINE_PARMS). Note that this macro only populates fields for
721
// a single call. If multiple calls are being managed, additional 4 byte
722
// fields must be appended to provide call state for each call after the first.
723
// This may be done using the SetResponseCallState macro with the appropriate
724
// call index supplied.
725
//
726
//*****************************************************************************
727
#define SetResponseLineParms(pi8Buf, ui16Length, \
728
ui8RingPattern, ui8RingVolume, ui32RingExists, \
729
ui32LineActive, ui8LineCallIndex, \
730
ui32CallActive, ui8CallStateChange, \
731
ui8CallState) \
732
do \
733
{ \
734
(WORD(pi8Buf)) = ui16Length; \
735
SetResponseRingerParams(((uint8_t *)(pi8Buf) + 2), \
736
ui8RingPattern, ui8RingVolume, \
737
ui32RingExists); \
738
(LONG((uint8_t *)(pi8Buf) + 6)) = \
739
(((ui32LineActive) & USB_CDC_LINE_IS_ACTIVE) + \
740
((ui8LineCallIndex) & 0xFF)) ; \
741
SetResponseCallState(pi8Buf, 0, ui32CallActive, \
742
ui8CallStateChange, ui8CallState); \
743
} \
744
while(0)
745
746
//*****************************************************************************
747
//
748
// Notification Element definitions
749
//
750
//*****************************************************************************
751
#define USB_CDC_NOTIFY_NETWORK_CONNECTION \
752
0x00
753
#define USB_CDC_NOTIFY_RESPONSE_AVAILABLE \
754
0x01
755
#define USB_CDC_NOTIFY_AUX_JACK_HOOK_STATE \
756
0x08
757
#define USB_CDC_NOTIFY_RING_DETECT \
758
0x09
759
#define USB_CDC_NOTIFY_SERIAL_STATE \
760
0x20
761
#define USB_CDC_NOTIFY_CALL_STATE_CHANGE \
762
0x28
763
#define USB_CDC_NOTIFY_LINE_STATE_CHANGE \
764
0x29
765
#define USB_CDC_NOTIFY_CONNECTION_SPEED_CHANGE \
766
0x2A
767
768
//*****************************************************************************
769
//
770
// USB_CDC_NOTIFY_NETWORK_CONNECTION, wValue
771
//
772
//*****************************************************************************
773
#define USB_CDC_NETWORK_DISCONNECTED \
774
0x0000
775
#define USB_CDC_NETWORK_CONNECTED \
776
0x0001
777
778
//*****************************************************************************
779
//
780
// USB_CDC_NOTIFY_AUX_JACK_HOOK_STATE, wValue
781
//
782
//*****************************************************************************
783
#define USB_CDC_AUX_JACK_ON_HOOK \
784
0x0000
785
#define USB_CDC_AUX_JACK_OFF_HOOK \
786
0x0001
787
788
//*****************************************************************************
789
//
790
// USB_CDC_NOTIFY_SERIAL_STATE, Data
791
//
792
//*****************************************************************************
793
794
//*****************************************************************************
795
//
796
// Number of bytes of data returned alongside this notification.
797
//
798
//*****************************************************************************
799
#define USB_CDC_NOTIFY_SERIAL_STATE_SIZE \
800
2
801
802
#define USB_CDC_SERIAL_STATE_OVERRUN \
803
0x0040
804
#define USB_CDC_SERIAL_STATE_PARITY \
805
0x0020
806
#define USB_CDC_SERIAL_STATE_FRAMING \
807
0x0010
808
#define USB_CDC_SERIAL_STATE_RING_SIGNAL \
809
0x0008
810
#define USB_CDC_SERIAL_STATE_BREAK \
811
0x0004
812
#define USB_CDC_SERIAL_STATE_TXCARRIER \
813
0x0002
814
#define USB_CDC_SERIAL_STATE_RXCARRIER \
815
0x0001
816
817
//*****************************************************************************
818
//
819
// USB_CDC_NOTIFY_CALL_STATE_CHANGE, wValue
820
//
821
// Call state values are defined above in the group beginning
822
// USB_CDC_CALL_STATE_IDLE. Note that the data returned alongside this
823
// notification are heavily dependent upon the call state being reported so no
824
// specific lengths or access macros are provided here.
825
//
826
// Macro to construct the correct wValue for this notification given a state
827
// and call index.
828
//
829
//*****************************************************************************
830
#define SetNotifyCallStatewValue(pi16Result, ui8CallState, ui8Index) \
831
do \
832
{ \
833
(WORD(pi16Result)) = (((ui8CallState) & 0xFF) + \
834
(((ui8Index) & 0xFF) << 8)); \
835
} \
836
while(0)
837
838
//*****************************************************************************
839
//
840
// USB_CDC_NOTIFY_LINE_STATE_CHANGE, wValue
841
//
842
// Note that the data returned alongside this notification are heavily
843
// dependent upon the call state being reported so no specific lengths or
844
// access macros are provided here.
845
//
846
//*****************************************************************************
847
#define USB_CDC_LINE_STATE_IDLE 0x0000
848
#define USB_CDC_LINE_STATE_HOLD 0x0001
849
#define USB_CDC_LINE_STATE_OFF_HOOK \
850
0x0002
851
#define USB_CDC_LINE_STATE_ON_HOOK \
852
0x0003
853
854
//*****************************************************************************
855
//
856
// USB_CDC_NOTIFY_CONNECTION_SPEED_CHANGE, Data
857
//
858
// Macro to populate the 8 byte data structure returned alongside this
859
// notification.
860
//
861
//*****************************************************************************
862
#define SetNotifyConnectionSpeedChange(pi8Buf, ui32USBitRate, ui32DSBitRate) \
863
do \
864
{ \
865
LONG(pi8Buf) = ui32USBitRate; \
866
LONG((uint8_t *)(pi8Buf) + 4) = ui32DSBitRate; \
867
} \
868
while(0)
869
870
//*****************************************************************************
871
//
872
// Packed structure definitions for request/response data blocks
873
//
874
//*****************************************************************************
875
876
//*****************************************************************************
877
//
878
// All structures defined in this section of the header require byte packing of
879
// fields. This is usually accomplished using the PACKED macro but, for IAR
880
// Embedded Workbench, this requires a pragma.
881
//
882
//*****************************************************************************
883
#ifdef __ICCARM__
884
#pragma pack(1)
885
#endif
886
887
//*****************************************************************************
888
//
890
//
891
//*****************************************************************************
892
typedef
struct
893
{
894
//
896
//
897
uint32_t
ui32Rate
;
898
899
//
902
//
903
uint8_t
ui8Stop
;
904
905
//
909
//
910
uint8_t
ui8Parity
;
911
912
//
915
//
916
uint8_t
ui8Databits
;
917
}
918
PACKED
tLineCoding;
919
920
//*****************************************************************************
921
//
922
// Return to default packing when using the IAR Embedded Workbench compiler.
923
//
924
//*****************************************************************************
925
#ifdef __ICCARM__
926
#pragma pack()
927
#endif
928
929
//*****************************************************************************
930
//
931
// Close the Doxygen group.
933
//
934
//*****************************************************************************
935
936
//*****************************************************************************
937
//
938
// Mark the end of the C bindings section for C++ compilers.
939
//
940
//*****************************************************************************
941
#ifdef __cplusplus
942
}
943
#endif
944
945
#endif // __USBCDC_H__
PACKED::ui8Stop
uint8_t ui8Stop
Definition:
usbcdc.h:903
PACKED::ui8Databits
uint8_t ui8Databits
Definition:
usbcdc.h:916
PACKED::ui32Rate
uint32_t ui32Rate
The data terminal rate in bits per second.
Definition:
usbcdc.h:897
PACKED::ui8Parity
uint8_t ui8Parity
Definition:
usbcdc.h:910
PACKED
USB_CDC_GET/SET_LINE_CODING request-specific data.
Definition:
usbaudio.h:288
Copyright 2017, Texas Instruments Incorporated