usbcdc.h 35 KB

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