usbcdc.h 36 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790
  1. //*****************************************************************************
  2. //
  3. // usbhid.h - Definitions used by Communication Device Class devices.
  4. //
  5. // Copyright (c) 2007-2010 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. // This is part of AM1808 StarterWare USB Library and reused from revision 6288
  22. // of the Stellaris USB Library.
  23. //
  24. //*****************************************************************************
  25. //*****************************************************************************
  26. //
  27. // Note: This header contains definitions related to the USB Communication
  28. // Device Class specification. The header is complete for ACM model
  29. // devices but request and notification definitions specific to other
  30. // modem types, ISDN, ATM and Ethernet are currently incomplete or
  31. // omitted.
  32. //
  33. //*****************************************************************************
  34. #ifndef __USBCDC_H__
  35. #define __USBCDC_H__
  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. //! \addtogroup cdc_device_class_api
  49. //! @{
  50. //
  51. //*****************************************************************************
  52. //*****************************************************************************
  53. //
  54. // Generic macros to read a byte, word or long from a character pointer.
  55. //
  56. //*****************************************************************************
  57. #define BYTE(pucData) (*(unsigned char *)(pucData))
  58. #define SHORT(pucData) (*(unsigned short *)(pucData))
  59. #define INT(pucData) (*(unsigned int *)(pucData))
  60. //*****************************************************************************
  61. //
  62. // USB CDC subclass codes. Used in interface descriptor, bInterfaceClass
  63. //
  64. //*****************************************************************************
  65. #define USB_CDC_SUBCLASS_DIRECT_LINE_MODEL 0x01
  66. #define USB_CDC_SUBCLASS_ABSTRACT_MODEL 0x02
  67. #define USB_CDC_SUBCLASS_TELEPHONE_MODEL 0x03
  68. #define USB_CDC_SUBCLASS_MULTI_CHANNEL_MODEL 0x04
  69. #define USB_CDC_SUBCLASS_CAPI_MODEL 0x05
  70. #define USB_CDC_SUBCLASS_ETHERNET_MODEL 0x06
  71. #define USB_CDC_SUBCLASS_ATM_MODEL 0x07
  72. //*****************************************************************************
  73. //
  74. // USB CDC control interface protocols. Used in control interface descriptor,
  75. // bInterfaceProtocol
  76. //
  77. //*****************************************************************************
  78. #define USB_CDC_PROTOCOL_NONE 0x00
  79. #define USB_CDC_PROTOCOL_V25TER 0x01
  80. #define USB_CDC_PROTOCOL_VENDOR 0xFF
  81. //*****************************************************************************
  82. //
  83. // USB CDC data interface protocols. Used in data interface descriptor,
  84. // bInterfaceProtocol
  85. //
  86. //*****************************************************************************
  87. // USB_CDC_PROTOCOL_NONE 0x00
  88. #define USB_CDC_PROTOCOL_I420 0x30
  89. #define USB_CDC_PROTOCOL_TRANSPARENT 0x32
  90. #define USB_CDC_PROTOCOL_Q921M 0x50
  91. #define USB_CDC_PROTOCOL_Q921 0x51
  92. #define USB_CDC_PROTOCOL_Q921TM 0x52
  93. #define USB_CDC_PROTOCOL_V42BIS 0x90
  94. #define USB_CDC_PROTOCOL_Q921EURO 0x91
  95. #define USB_CDC_PROTOCOL_V120 0x92
  96. #define USB_CDC_PROTOCOL_CAPI20 0x93
  97. #define USB_CDC_PROTOCOL_HOST_DRIVER 0xFD
  98. #define USB_CDC_PROTOCOL_CDC_SPEC 0xFE
  99. // USB_CDC_PROTOCOL_VENDOR 0xFF
  100. //*****************************************************************************
  101. //
  102. // Functional descriptor definitions
  103. //
  104. //*****************************************************************************
  105. //*****************************************************************************
  106. //
  107. // Functional descriptor types
  108. //
  109. //*****************************************************************************
  110. #define USB_CDC_CS_INTERFACE 0x24
  111. #define USB_CDC_CS_ENDPOINT 0x25
  112. //*****************************************************************************
  113. //
  114. // Functional descriptor subtypes
  115. //
  116. //*****************************************************************************
  117. #define USB_CDC_FD_SUBTYPE_HEADER 0x00
  118. #define USB_CDC_FD_SUBTYPE_CALL_MGMT 0x01
  119. #define USB_CDC_FD_SUBTYPE_ABSTRACT_CTL_MGMT 0x02
  120. #define USB_CDC_FD_SUBTYPE_DIRECT_LINE_MGMT 0x03
  121. #define USB_CDC_FD_SUBTYPE_TELEPHONE_RINGER 0x04
  122. #define USB_CDC_FD_SUBTYPE_LINE_STATE_CAPS 0x05
  123. #define USB_CDC_FD_SUBTYPE_UNION 0x06
  124. #define USB_CDC_FD_SUBTYPE_COUNTRY 0x07
  125. #define USB_CDC_FD_SUBTYPE_TELEPHONE_MODES 0x08
  126. #define USB_CDC_FD_SUBTYPE_USB_TERMINAL 0x09
  127. #define USB_CDC_FD_SUBTYPE_NETWORK_TERMINAL 0x0A
  128. #define USB_CDC_FD_SUBTYPE_PROTOCOL_UNIT 0x0B
  129. #define USB_CDC_FD_SUBTYPE_EXTENSION_UNIT 0x0C
  130. #define USB_CDC_FD_SUBTYPE_MULTI_CHANNEL_MGMT 0x0D
  131. #define USB_CDC_FD_SUBTYPE_CAPI_MGMT 0x0E
  132. #define USB_CDC_FD_SUBTYPE_ETHERNET 0x0F
  133. #define USB_CDC_FD_SUBTYPE_ATM 0x10
  134. //*****************************************************************************
  135. //
  136. // USB_CDC_FD_SUBTYPE_CALL_MGMT, Header functional descriptor, bmCapabilities
  137. //
  138. //*****************************************************************************
  139. #define USB_CDC_CALL_MGMT_VIA_DATA 0x02
  140. #define USB_CDC_CALL_MGMT_HANDLED 0x01
  141. //*****************************************************************************
  142. //
  143. // USB_CDC_FD_SUBTYPE_ABSTRACT_CTL_MGMT, Abstract Control Management functional
  144. // descriptor, bmCapabilities
  145. //
  146. //*****************************************************************************
  147. #define USB_CDC_ACM_SUPPORTS_NETWORK_CONNECTION 0x08
  148. #define USB_CDC_ACM_SUPPORTS_SEND_BREAK 0x04
  149. #define USB_CDC_ACM_SUPPORTS_LINE_PARAMS 0x02
  150. #define USB_CDC_ACM_SUPPORTS_COMM_FEATURE 0x01
  151. //*****************************************************************************
  152. //
  153. // USB_CDC_FD_SUBTYPE_DIRECT_LINE_MGMT, Direct Line Management functional
  154. // descriptor, bmCapabilities
  155. //
  156. //*****************************************************************************
  157. #define USB_CDC_DLM_NEEDS_EXTRA_PULSE_SETUP 0x04
  158. #define USB_CDC_DLM_SUPPORTS_AUX 0x02
  159. #define USB_CDC_DLM_SUPPORTS_PULSE 0x01
  160. //*****************************************************************************
  161. //
  162. // USB_CDC_FD_SUBTYPE_TELEPHONE_MODES, Telephone Operational Modes functional
  163. // descriptor, bmCapabilities
  164. //
  165. //*****************************************************************************
  166. #define USB_CDC_TELEPHONE_SUPPORTS_COMPUTER 0x04
  167. #define USB_CDC_TELEPHONE_SUPPORTS_STANDALONE 0x02
  168. #define USB_CDC_TELEPHONE_SUPPORTS_SIMPLE 0x01
  169. //*****************************************************************************
  170. //
  171. // USB_CDC_FD_SUBTYPE_LINE_STATE_CAPS, Telephone Call and Line State Reporting
  172. // Capabilities descriptor
  173. //
  174. //*****************************************************************************
  175. #define USB_CDC_LINE_STATE_CHANGES_NOTIFIED 0x20
  176. #define USB_CDC_LINE_STATE_REPORTS_DTMF 0x10
  177. #define USB_CDC_LINE_STATE_REPORTS_DIST_RING 0x08
  178. #define USB_CDC_LINE_STATE_REPORTS_CALLERID 0x04
  179. #define USB_CDC_LINE_STATE_REPORTS_BUSY 0x02
  180. #define USB_CDC_LINE_STATE_REPORTS_INT_DIALTONE 0x01
  181. //*****************************************************************************
  182. //
  183. // USB_CDC_FD_SUBTYPE_USB_TERMINAL, USB Terminal functional descriptor,
  184. // bmOptions
  185. //
  186. //*****************************************************************************
  187. #define USB_CDC_TERMINAL_NO_WRAPPER_USED 0x00
  188. #define USB_CDC_TERMINAL_WRAPPER_USED 0x01
  189. //*****************************************************************************
  190. //
  191. // USB_CDC_FD_SUBTYPE_MULTI_CHANNEL_MGMT, Multi-Channel Management functional
  192. // descriptor, bmCapabilities
  193. //
  194. //*****************************************************************************
  195. #define USB_CDC_MCM_SUPPORTS_SET_UNIT_PARAM 0x04
  196. #define USB_CDC_MCM_SUPPORTS_CLEAR_UNIT_PARAM 0x02
  197. #define USB_CDC_MCM_UNIT_PARAMS_NON_VOLATILE 0x01
  198. //*****************************************************************************
  199. //
  200. // USB_CDC_FD_SUBTYPE_CAPI_MGMT, CAPI Control Management functional descriptor,
  201. // bmCapabilities
  202. //
  203. //*****************************************************************************
  204. #define USB_CDC_CAPI_INTELLIGENT 0x01
  205. #define USB_CDC_CAPI_SIMPLE 0x00
  206. //*****************************************************************************
  207. //
  208. // USB_CDC_FD_SUBTYPE_ETHERNET, Ethernet Networking functional descriptor,
  209. // bmEthernetStatistics
  210. //
  211. //*****************************************************************************
  212. #define USB_CDC_ETHERNET_XMIT_OK 0x01000000
  213. #define USB_CDC_ETHERNET_RCV_OK 0x02000000
  214. #define USB_CDC_ETHERNET_XMIT_ERROR 0x04000000
  215. #define USB_CDC_ETHERNET_RCV_ERROR 0x08000000
  216. #define USB_CDC_ETHERNET_RCV_NO_BUFFER 0x10000000
  217. #define USB_CDC_ETHERNET_DIRECTED_BYTES_XMIT 0x20000000
  218. #define USB_CDC_ETHERNET_DIRECTED_FRAMES_XMIT 0x40000000
  219. #define USB_CDC_ETHERNET_MULTICAST_BYTES_XMIT 0x80000000
  220. #define USB_CDC_ETHERNET_MULTICAST_FRAMES_XMIT 0x00010000
  221. #define USB_CDC_ETHERNET_BROADCAST_BYTES_XMIT 0x00020000
  222. #define USB_CDC_ETHERNET_BROADCAST_FRAMES_XMIT 0x00040000
  223. #define USB_CDC_ETHERNET_DIRECTED_BYTES_RCV 0x00080000
  224. #define USB_CDC_ETHERNET_DIRECTED_FRAMES_RCV 0x00100000
  225. #define USB_CDC_ETHERNET_MULTICAST_BYTES_RCV 0x00200000
  226. #define USB_CDC_ETHERNET_MULTICAST_FRAMES_RCV 0x00400000
  227. #define USB_CDC_ETHERNET_BROADCAST_BYTES_RCV 0x00800000
  228. #define USB_CDC_ETHERNET_BROADCAST_FRAMES_RCV 0x00000100
  229. #define USB_CDC_ETHERNET_RCV_CRC_ERROR 0x00000200
  230. #define USB_CDC_ETHERNET_TRANSMIT_QUEUE_LENGTH 0x00000400
  231. #define USB_CDC_ETHERNET_RCV_ERROR_ALIGNMENT 0x00000800
  232. #define USB_CDC_ETHERNET_XMIT_ONE_COLLISION 0x00001000
  233. #define USB_CDC_ETHERNET_XMIT_MORE_COLLISIONS 0x00002000
  234. #define USB_CDC_ETHERNET_XMIT_DEFERRED 0x00004000
  235. #define USB_CDC_ETHERNET_XMIT_MAX_COLLISIONS 0x00008000
  236. #define USB_CDC_ETHERNET_RCV_OVERRUN 0x00000001
  237. #define USB_CDC_ETHERNET_XMIT_UNDERRUN 0x00000002
  238. #define USB_CDC_ETHERNET_XMIT_HEARTBEAT_FAILURE 0x00000004
  239. #define USB_CDC_ETHERNET_XMIT_TIMES_CRS_LOST 0x00000008
  240. #define USB_CDC_ETHERNET_XMIT_LATE_COLLISIONS 0x00000010
  241. //*****************************************************************************
  242. //
  243. // USB_CDC_FD_SUBTYPE_ATM, ATM Networking functional descriptor,
  244. // bmDataCapabilities
  245. //
  246. //*****************************************************************************
  247. #define USB_CDC_ATM_TYPE_3 0x08
  248. #define USB_CDC_ATM_TYPE_2 0x04
  249. #define USB_CDC_ATM_TYPE_1 0x02
  250. //*****************************************************************************
  251. //
  252. // bmATMDeviceStatistics
  253. //
  254. //*****************************************************************************
  255. #define USB_CDC_ATM_VC_US_CELLS_SENT 0x10
  256. #define USB_CDC_ATM_VC_US_CELLS_RECEIVED 0x08
  257. #define USB_CDC_ATM_DS_CELLS_HEC_ERR_CORRECTED 0x04
  258. #define USB_CDC_ATM_US_CELLS_SENT 0x02
  259. #define USB_CDC_ATM_US_CELLS_RECEIVED 0x01
  260. //*****************************************************************************
  261. //
  262. // Management Element Requests (provided in tUSBRequest.ucRequest)
  263. //
  264. //*****************************************************************************
  265. #define USB_CDC_SEND_ENCAPSULATED_COMMAND 0x00
  266. #define USB_CDC_GET_ENCAPSULATED_RESPONSE 0x01
  267. #define USB_CDC_SET_COMM_FEATURE 0x02
  268. #define USB_CDC_GET_COMM_FEATURE 0x03
  269. #define USB_CDC_CLEAR_COMM_FEATURE 0x04
  270. #define USB_CDC_SET_AUX_LINE_STATE 0x10
  271. #define USB_CDC_SET_HOOK_STATE 0x11
  272. #define USB_CDC_PULSE_SETUP 0x12
  273. #define USB_CDC_SEND_PULSE 0x13
  274. #define USB_CDC_SET_PULSE_TIME 0x14
  275. #define USB_CDC_RING_AUX_JACK 0x15
  276. #define USB_CDC_SET_LINE_CODING 0x20
  277. #define USB_CDC_GET_LINE_CODING 0x21
  278. #define USB_CDC_SET_CONTROL_LINE_STATE 0x22
  279. #define USB_CDC_SEND_BREAK 0x23
  280. #define USB_CDC_SET_RINGER_PARMS 0x30
  281. #define USB_CDC_GET_RINGER_PARMS 0x31
  282. #define USB_CDC_SET_OPERATION_PARMS 0x32
  283. #define USB_CDC_GET_OPERATION_PARMS 0x33
  284. #define USB_CDC_SET_LINE_PARMS 0x34
  285. #define USB_CDC_GET_LINE_PARMS 0x35
  286. #define USB_CDC_DIAL_DIGITS 0x36
  287. #define USB_CDC_SET_UNIT_PARAMETER 0x37
  288. #define USB_CDC_GET_UNIT_PARAMETER 0x38
  289. #define USB_CDC_CLEAR_UNIT_PARAMETER 0x39
  290. #define USB_CDC_GET_PROFILE 0x3A
  291. #define USB_CDC_SET_ETHERNET_MULTICAST_FILTERS 0x40
  292. #define USB_CDC_SET_ETHERNET_POWER_MANAGEMENT_PATTERN_FILTER 0x41
  293. #define USB_CDC_GET_ETHERNET_POWER_MANAGEMENT_PATTERN_FILTER 0x42
  294. #define USB_CDC_SET_ETHERNET_PACKET_FILTER 0x43
  295. #define USB_CDC_GET_ETHERNET_STATISTIC 0x44
  296. #define USB_CDC_SET_ATM_DATA_FORMAT 0x50
  297. #define USB_CDC_GET_ATM_DEVICE_STATISTICS 0x51
  298. #define USB_CDC_SET_ATM_DEFAULT_VC 0x52
  299. #define USB_CDC_GET_ATM_VC_STATISTICS 0x53
  300. //*****************************************************************************
  301. //
  302. // In cases where a request defined above results in the return of a fixed size
  303. // data block, the following group of labels define the size of that block. In
  304. // each of these cases, an access macro is also provided to write the response
  305. // data into an appropriately-sized array of unsigned characters.
  306. //
  307. //*****************************************************************************
  308. #define USB_CDC_SIZE_COMM_FEATURE 2
  309. #define USB_CDC_SIZE_LINE_CODING 7
  310. #define USB_CDC_SIZE_RINGER_PARMS 4
  311. #define USB_CDC_SIZE_OPERATION_PARMS 2
  312. #define USB_CDC_SIZE_UNIT_PARAMETER 2
  313. #define USB_CDC_SIZE_PROFILE 64
  314. #define USB_CDC_SIZE_ETHERNET_POWER_MANAGEMENT_PATTERN_FILTER 2
  315. #define USB_CDC_SIZE_ETHERNET_STATISTIC 4
  316. #define USB_CDC_SIZE_ATM_DEVICE_STATISTICS 4
  317. #define USB_CDC_SIZE_ATM_VC_STATISTICS 4
  318. #define USB_CDC_SIZE_LINE_PARMS 10
  319. //*****************************************************************************
  320. //
  321. // NB: USB_CDC_SIZE_LINE_PARAMS assumes only a single call. For multiple
  322. // calls, add 4 bytes per additional call.
  323. //
  324. //*****************************************************************************
  325. //*****************************************************************************
  326. //
  327. // USB_CDC_GET_COMM_FEATURE & USB_CDC_SET_COMM_FEATURE
  328. //
  329. //*****************************************************************************
  330. //*****************************************************************************
  331. //
  332. // wValue (Feature Selector)
  333. //
  334. //*****************************************************************************
  335. #define USB_CDC_ABSTRACT_STATE 0x0001
  336. #define USB_CDC_COUNTRY_SETTING 0x0002
  337. //*****************************************************************************
  338. //
  339. // Data when feature selector is USB_DCD_ABSTRACT_STATE
  340. //
  341. //*****************************************************************************
  342. #define USB_CDC_ABSTRACT_CALL_DATA_MULTIPLEXED 0x0002
  343. #define USB_CDC_ABSTRACT_ENDPOINTS_IDLE 0x0001
  344. //*****************************************************************************
  345. //
  346. // Macros to populate the response data buffer (whose size in bytes is defined
  347. // by USB_CDC_SIZE_COMM_FEATURE).
  348. //
  349. //*****************************************************************************
  350. #define SetResponseCommFeature(pcBuf, usData) \
  351. do \
  352. { \
  353. (*(unsigned short *)(pcBuf)) = (usData); \
  354. } \
  355. while(0)
  356. //*****************************************************************************
  357. //
  358. // USB_CDC_SET_AUX_LINE_STATE, wValue
  359. //
  360. //*****************************************************************************
  361. #define USB_CDC_AUX_DISCONNECT 0x0000
  362. #define USB_CDC_AUX_CONNECT 0x0001
  363. //*****************************************************************************
  364. //
  365. // USB_CDC_SET_HOOK_STATE, wValue
  366. //
  367. //*****************************************************************************
  368. #define USB_CDC_ON_HOOK 0x0000
  369. #define USB_CDC_OFF_HOOK 0x0001
  370. #define USB_CDC_SNOOPING 0x0002
  371. //*****************************************************************************
  372. //
  373. // USB_CDC_GET_LINE_CODING
  374. //
  375. //*****************************************************************************
  376. #define USB_CDC_STOP_BITS_1 0x00
  377. #define USB_CDC_STOP_BITS_1_5 0x01
  378. #define USB_CDC_STOP_BITS_2 0x02
  379. #define USB_CDC_PARITY_NONE 0x00
  380. #define USB_CDC_PARITY_ODD 0x01
  381. #define USB_CDC_PARITY_EVEN 0x02
  382. #define USB_CDC_PARITY_MARK 0x03
  383. #define USB_CDC_PARITY_SPACE 0x04
  384. //*****************************************************************************
  385. //
  386. // Macro to populate the response data buffer (whose size in bytes is defined
  387. // by USB_CDC_SIZE_LINE_CODING).
  388. //
  389. //*****************************************************************************
  390. #define SetResponseLineCoding(pcBuf, ucRate, ucStop, ucParity, ucDatabits) \
  391. do \
  392. { \
  393. (*(unsigned int *)(pcBuf)) = (ucRate); \
  394. (*((unsigned char *)(pcBuf) + 4)) = (ucStop); \
  395. (*((unsigned char *)(pcBuf) + 5)) = (ucParity); \
  396. (*((unsigned char *)(pcBuf) + 6)) = (ucDatabits); \
  397. } \
  398. while(0)
  399. //*****************************************************************************
  400. //
  401. // USB_CDC_SET_CONTROL_LINE_STATE, wValue
  402. //
  403. //*****************************************************************************
  404. #define USB_CDC_DEACTIVATE_CARRIER 0x00
  405. #define USB_CDC_ACTIVATE_CARRIER 0x02
  406. #define USB_CDC_DTE_NOT_PRESENT 0x00
  407. #define USB_CDC_DTE_PRESENT 0x01
  408. //*****************************************************************************
  409. //
  410. // USB_CDC_SET_RINGER_PARMS, USB_CDC_GET_RINGER_PARMS and
  411. // USB_CDC_GET_LINE_PARMS (ulRingerBmp)
  412. //
  413. //*****************************************************************************
  414. #define USB_CDC_RINGER_EXISTS 0x80000000
  415. #define USB_CDC_RINGER_DOES_NOT_EXIST 0x00000000
  416. //*****************************************************************************
  417. //
  418. // Macro to populate the response data buffer to USB_CDC_GET_RINGER_PARMS.
  419. // Parameter buf points to a buffer of size USB_CDC_SIZE_RINGER_PARMS bytes.
  420. //
  421. //*****************************************************************************
  422. #define SetResponseRingerParms(pcBuf, ucPattern, ucVolume, ulExists) \
  423. do \
  424. { \
  425. *(unsigned int *)(pcBuf) = ((ucPattern) + \
  426. ((ucVolume & 0xFF) << 8) + \
  427. (ulExists & USB_CDC_RINGER_EXISTS)); \
  428. } \
  429. while(0)
  430. //*****************************************************************************
  431. //
  432. // Macros to extract fields from the USB_CDC_SET_RINGER_PARMS data
  433. //
  434. //*****************************************************************************
  435. #define GetRingerVolume(pcData) (BYTE((pcData)+1))
  436. #define GetRingerPattern(pcData) (BYTE(pcData))
  437. #define GetRingerExists(pcData) ((INT(pcData)) & USB_CDC_RINGER_EXISTS)
  438. //*****************************************************************************
  439. //
  440. // USB_CDC_SET_OPERATION_PARMS, wValue
  441. //
  442. //*****************************************************************************
  443. #define USB_CDC_SIMPLE_MODE 0x0000
  444. #define USB_CDC_STANDALONE_MODE 0x0001
  445. #define USB_CDC_HOST_CENTRIC_MODE 0x0002
  446. //*****************************************************************************
  447. //
  448. // Macro to populate the response data buffer to USB_CDC_GET_OPERATION_PARMS.
  449. // Parameter buf points to a buffer of size USB_CDC_SIZE_OPERATION_PARMS
  450. // bytes.
  451. //
  452. //*****************************************************************************
  453. #define SetResponseOperationParms(pBbuf, usData) \
  454. do \
  455. { \
  456. WORD(pcBuf) = (usData); \
  457. } \
  458. while(0)
  459. //*****************************************************************************
  460. //
  461. // USB_CDC_SET_LINE_PARMS, wParam - Line State Change
  462. //
  463. //*****************************************************************************
  464. #define USB_CDC_DROP_ACTIVE_CALL 0x0000
  465. #define USB_CDC_START_NEW_CALL 0x0001
  466. #define USB_CDC_APPLY_RINGING 0x0002
  467. #define USB_CDC_REMOVE_RINGING 0x0003
  468. #define USB_CDC_SWITCH_CALL 0x0004
  469. //*****************************************************************************
  470. //
  471. // Line state bitmap in USB_CDC_GET_LINE_PARMS response
  472. //
  473. //*****************************************************************************
  474. #define USB_CDC_LINE_IS_ACTIVE 0x80000000
  475. #define USB_CDC_LINE_IS_IDLE 0x00000000
  476. #define USB_CDC_LINE_NO_ACTIVE_CALL 0x000000FF
  477. #define USB_CDC_CALL_ACTIVE 0x80000000
  478. //*****************************************************************************
  479. //
  480. // Call state value definitions
  481. //
  482. //*****************************************************************************
  483. #define USB_CDC_CALL_IDLE 0x00000000
  484. #define USB_CDC_CALL_TYPICAL_DIALTONE 0x00000001
  485. #define USB_CDC_CALL_INTERRUPTED_DIALTONE 0x00000002
  486. #define USB_CDC_CALL_DIALING 0x00000003
  487. #define USB_CDC_CALL_RINGBACK 0x00000004
  488. #define USB_CDC_CALL_CONNECTED 0x00000005
  489. #define USB_CDC_CALL_INCOMING 0x00000006
  490. //*****************************************************************************
  491. //
  492. // Call state change value definitions
  493. //
  494. //*****************************************************************************
  495. #define USB_CDC_CALL_STATE_IDLE 0x01
  496. #define USB_CDC_CALL_STATE_DIALING 0x02
  497. #define USB_CDC_CALL_STATE_RINGBACK 0x03
  498. #define USB_CDC_CALL_STATE_CONNECTED 0x04
  499. #define USB_CDC_CALL_STATE_INCOMING 0x05
  500. //*****************************************************************************
  501. //
  502. // Extra byte of data describing the connection type for
  503. // USB_CDC_CALL_STATE_CONNECTED.
  504. //
  505. //*****************************************************************************
  506. #define USB_CDC_VOICE 0x00
  507. #define USB_CDC_ANSWERING_MACHINE 0x01
  508. #define USB_CDC_FAX 0x02
  509. #define USB_CDC_MODEM 0x03
  510. #define USB_CDC_UNKNOWN 0xFF
  511. //*****************************************************************************
  512. //
  513. // Macro to extract call index from request in cases where wParam is
  514. // USB_CDC_SWITCH_CALL.
  515. //
  516. //*****************************************************************************
  517. #define GetCallIndex(pcData) (BYTE(pcData))
  518. //*****************************************************************************
  519. //
  520. // Macro to populate the CallState entries in response to request
  521. // USB_CDC_GET_LINE_PARMS. The ucIndex parameter is a zero based index
  522. // indicating which call entry in the pcBuf response buffer to fill in. Note
  523. // that pcBuf points to the first byte of the buffer (the wLength field).
  524. //
  525. //*****************************************************************************
  526. #define SetResponseCallState(pcBuf, ucIndex, ulActive, ucStateChange, \
  527. ucState) \
  528. do \
  529. { \
  530. (INT((unsigned char *)(pcBuf) + (10 + (4 * (ucIndex))))) = \
  531. (((ulActive) & USB_CDC_CALL_IS_ACTIVE) + \
  532. (((ucStateChange) & 0xFF) << 8) + \
  533. ((ucState) & 0xFF)); \
  534. } \
  535. while(0)
  536. //*****************************************************************************
  537. //
  538. // Macro to populate the response data buffer (whose size in bytes is defined
  539. // by USB_CDC_SIZE_LINE_PARMS). Note that this macro only populates fields for
  540. // a single call. If multiple calls are being managed, additional 4 byte
  541. // fields must be appended to provide call state for each call after the first.
  542. // This may be done using the SetResponseCallState macro with the appropriate
  543. // call index supplied.
  544. //
  545. //*****************************************************************************
  546. #define SetResponseLineParms(pcBuf, usLength, \
  547. ucRingPattern, ucRingVolume, ulRingExists, \
  548. ulLineActive, ucLineCallIndex, \
  549. ulCallActive, ucCallStateChange, ucCallState) \
  550. do \
  551. { \
  552. (WORD(pcBuf)) = (usLength); \
  553. SetResponseRingerParams(((unsigned char *)(pcBuf) + 2), \
  554. (ucRingPattern), (ucRingVolume), \
  555. (ulRingExists)); \
  556. (INT((unsigned char *)(pcBuf) + 6)) = \
  557. (((ulLineActive) & USB_CDC_LINE_IS_ACTIVE) + \
  558. ((ucLineCallIndex) & 0xFF)) ; \
  559. SetResponseCallState((pcBuf), 0, (ulCallActive), \
  560. (ucCallStateChange), (ucCallState)); \
  561. } \
  562. while(0)
  563. //*****************************************************************************
  564. //
  565. // Notification Element definitions
  566. //
  567. //*****************************************************************************
  568. #define USB_CDC_NOTIFY_NETWORK_CONNECTION 0x00
  569. #define USB_CDC_NOTIFY_RESPONSE_AVAILABLE 0x01
  570. #define USB_CDC_NOTIFY_AUX_JACK_HOOK_STATE 0x08
  571. #define USB_CDC_NOTIFY_RING_DETECT 0x09
  572. #define USB_CDC_NOTIFY_SERIAL_STATE 0x20
  573. #define USB_CDC_NOTIFY_CALL_STATE_CHANGE 0x28
  574. #define USB_CDC_NOTIFY_LINE_STATE_CHANGE 0x29
  575. #define USB_CDC_NOTIFY_CONNECTION_SPEED_CHANGE 0x2A
  576. //*****************************************************************************
  577. //
  578. // USB_CDC_NOTIFY_NETWORK_CONNECTION, wValue
  579. //
  580. //*****************************************************************************
  581. #define USB_CDC_NETWORK_DISCONNECTED 0x0000
  582. #define USB_CDC_NETWORK_CONNECTED 0x0001
  583. //*****************************************************************************
  584. //
  585. // USB_CDC_NOTIFY_AUX_JACK_HOOK_STATE, wValue
  586. //
  587. //*****************************************************************************
  588. #define USB_CDC_AUX_JACK_ON_HOOK 0x0000
  589. #define USB_CDC_AUX_JACK_OFF_HOOK 0x0001
  590. //*****************************************************************************
  591. //
  592. // USB_CDC_NOTIFY_SERIAL_STATE, Data
  593. //
  594. //*****************************************************************************
  595. //*****************************************************************************
  596. //
  597. // Number of bytes of data returned alongside this notification.
  598. //
  599. //*****************************************************************************
  600. #define USB_CDC_NOTIFY_SERIAL_STATE_SIZE 2
  601. #define USB_CDC_SERIAL_STATE_OVERRUN 0x0040
  602. #define USB_CDC_SERIAL_STATE_PARITY 0x0020
  603. #define USB_CDC_SERIAL_STATE_FRAMING 0x0010
  604. #define USB_CDC_SERIAL_STATE_RING_SIGNAL 0x0008
  605. #define USB_CDC_SERIAL_STATE_BREAK 0x0004
  606. #define USB_CDC_SERIAL_STATE_TXCARRIER 0x0002
  607. #define USB_CDC_SERIAL_STATE_RXCARRIER 0x0001
  608. //*****************************************************************************
  609. //
  610. // USB_CDC_NOTIFY_CALL_STATE_CHANGE, wValue
  611. //
  612. // Call state values are defined above in the group beginning
  613. // USB_CDC_CALL_STATE_IDLE. Note that the data returned alongside this
  614. // notification are heavily dependent upon the call state being reported so no
  615. // specific lengths or access macros are provided here.
  616. //
  617. // Macro to construct the correct wValue for this notification given a state
  618. // and call index.
  619. //
  620. //*****************************************************************************
  621. #define SetNotifyCallStatewValue(psResult, ucCallState, ucIndex) \
  622. do \
  623. { \
  624. (WORD(psResult)) = (((ucCallState) & 0xFF) + \
  625. (((ucIndex) & 0xFF) << 8)); \
  626. } \
  627. while(0)
  628. //*****************************************************************************
  629. //
  630. // USB_CDC_NOTIFY_LINE_STATE_CHANGE, wValue
  631. //
  632. // Note that the data returned alongside this notification are heavily
  633. // dependent upon the call state being reported so no specific lengths or
  634. // access macros are provided here.
  635. //
  636. //*****************************************************************************
  637. #define USB_CDC_LINE_STATE_IDLE 0x0000
  638. #define USB_CDC_LINE_STATE_HOLD 0x0001
  639. #define USB_CDC_LINE_STATE_OFF_HOOK 0x0002
  640. #define USB_CDC_LINE_STATE_ON_HOOK 0x0003
  641. //*****************************************************************************
  642. //
  643. // USB_CDC_NOTIFY_CONNECTION_SPEED_CHANGE, Data
  644. //
  645. // Macro to populate the 8 byte data structure returned alongside this
  646. // notification.
  647. //
  648. //*****************************************************************************
  649. #define SetNotifyConnectionSpeedChange(pcBuf, ulUSBitRate, ulDSBitRate) \
  650. do \
  651. { \
  652. INT(pcBuf) = ulUSBitRate; \
  653. INT((unsigned char *)(pcBuf) + 4) = ulDSBitRate; \
  654. } \
  655. while(0)
  656. //*****************************************************************************
  657. //
  658. // Packed structure definitions for request/response data blocks
  659. //
  660. //*****************************************************************************
  661. //*****************************************************************************
  662. //
  663. // All structures defined in this section of the header require byte packing of
  664. // fields. This is usually accomplished using the USBLIB_PACKED macro but, for IAR
  665. // Embedded Workbench, this requires a pragma.
  666. //
  667. //*****************************************************************************
  668. #if defined(ewarm) || defined(__IAR_SYSTEMS_ICC__)
  669. #pragma pack(1)
  670. #endif
  671. //*****************************************************************************
  672. //
  673. //! USB_CDC_GET/SET_LINE_CODING request-specific data.
  674. //
  675. //*****************************************************************************
  676. typedef struct
  677. {
  678. //
  679. //! The data terminal rate in bits per second.
  680. //
  681. unsigned int ulRate;
  682. //
  683. //! The number of stop bits. Valid values are USB_CDC_STOP_BITS_1,
  684. //! USB_CDC_STOP_BITS_1_5 or USB_CDC_STOP_BITS_2
  685. //
  686. unsigned char ucStop;
  687. //
  688. //! The parity setting. Valid values are USB_CDC_PARITY_NONE,
  689. //! USB_CDC_PARITY_ODD, USB_CDC_PARITY_EVEN, USB_CDC_PARITY_MARK and
  690. //! USB_CDC_PARITY_SPACE.
  691. //
  692. unsigned char ucParity;
  693. //
  694. //! The number of data bits per character. Valid values are 5, 6, 7 and 8
  695. //! in this implementation.
  696. //
  697. unsigned char ucDatabits;
  698. }
  699. USBLIB_PACKED tLineCoding;
  700. //*****************************************************************************
  701. //
  702. // Return to default packing when using the IAR Embedded Workbench compiler.
  703. //
  704. //*****************************************************************************
  705. #if defined(ewarm) || defined(__IAR_SYSTEMS_ICC__)
  706. #pragma pack()
  707. #endif
  708. //*****************************************************************************
  709. //
  710. // Close the Doxygen group.
  711. //! @}
  712. //
  713. //*****************************************************************************
  714. //*****************************************************************************
  715. //
  716. // Mark the end of the C bindings section for C++ compilers.
  717. //
  718. //*****************************************************************************
  719. #ifdef __cplusplus
  720. }
  721. #endif
  722. #endif // __USBCDC_H__