uart.h 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771
  1. #ifndef _DEV_UART_H
  2. #define _DEV_UART_H
  3. /*
  4. * Copyright (C) 2001-2004 by egnite Software GmbH
  5. *
  6. * All rights reserved.
  7. *
  8. * Redistribution and use in source and binary forms, with or without
  9. * modification, are permitted provided that the following conditions
  10. * are met:
  11. *
  12. * 1. Redistributions of source code must retain the above copyright
  13. * notice, this list of conditions and the following disclaimer.
  14. * 2. Redistributions in binary form must reproduce the above copyright
  15. * notice, this list of conditions and the following disclaimer in the
  16. * documentation and/or other materials provided with the distribution.
  17. * 3. Neither the name of the copyright holders nor the names of
  18. * contributors may be used to endorse or promote products derived
  19. * from this software without specific prior written permission.
  20. *
  21. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  22. * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  23. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
  24. * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
  25. * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  26. * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
  27. * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
  28. * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
  29. * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  30. * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  31. * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  32. * SUCH DAMAGE.
  33. *
  34. * For additional information see http://www.ethernut.de/
  35. */
  36. /*
  37. * $Id: uart.h 5526 2014-01-07 18:17:36Z u_bonnes $
  38. */
  39. #include <sys/device.h>
  40. /*!
  41. * \file dev/uart.h
  42. * \brief UART I/O control functions.
  43. * \verbatim
  44. * $Id: uart.h 5526 2014-01-07 18:17:36Z u_bonnes $
  45. * \endverbatim
  46. */
  47. /*!
  48. * \addtogroup xgUARTIOCTL
  49. *
  50. * \brief UART _ioctl() commands.
  51. *
  52. * These commands are used to control and retrieve hardware specific
  53. * configurations. The definitions are kept independent from the
  54. * underlying hardware, but not all commands may be fully implemented
  55. * in each UART driver.
  56. *
  57. * The \ref _ioctl() function expects three parameters:
  58. * - A device descriptor.
  59. * - A command code, any of the UART_... commands listed below.
  60. * - A pointer to a configuration parameter, in most cases an uint32_t.
  61. */
  62. /*@{*/
  63. /*! \brief UART _ioctl() command code to set the line speed.
  64. *
  65. * The configuration parameter must be a pointer to a uint32_t variable,
  66. * which contains the bit rate per second (baud rate). The command sets
  67. * both, input and output speed.
  68. *
  69. * Which speeds are available depends on the target platform and the
  70. * current peripheral clock frequency. If available, the initial speed
  71. * will be 115200, but may be re-configured via UART_INIT_BAUDRATE.
  72. *
  73. * See also \ref UART_GETSPEED.
  74. */
  75. #define UART_SETSPEED 0x0101
  76. /*! \brief UART _ioctl() command code to query the line speed.
  77. *
  78. * The configuration parameter must be a pointer to a uint32_t variable,
  79. * which receives the current bit rate per second.
  80. *
  81. * See also \ref UART_SETSPEED.
  82. */
  83. #define UART_GETSPEED 0x0102
  84. /*! \brief UART _ioctl() command code to set the number of data bits.
  85. *
  86. * The configuration parameter must be a pointer to a uint8_t variable,
  87. * which contains the number of data bits.
  88. *
  89. * Typically the number of data bits is initially set to 8. Most
  90. * platforms aloow to change this to 7 bits, some may support 5, 6 or
  91. * 9 bits.
  92. *
  93. * See also \ref UART_GETDATABITS.
  94. */
  95. #define UART_SETDATABITS 0x0103
  96. /*! \brief UART _ioctl() command code to query the number of data bits.
  97. *
  98. * The configuration parameter must be a pointer to a uint32_t variable,
  99. * which receives the current number of data bits.
  100. *
  101. * See also \ref UART_SETDATABITS.
  102. */
  103. #define UART_GETDATABITS 0x0104
  104. /*! \brief UART _ioctl() command code to set the parity mode.
  105. *
  106. * The configuration parameter must be a pointer to a uint32_t variable,
  107. * which contains the requested parity mode, 0 (none), 1 (odd) or
  108. * 2 (even).
  109. *
  110. * On most platforms the initial parity mode is set to 0.
  111. *
  112. * See also \ref UART_GETPARITY.
  113. */
  114. #define UART_SETPARITY 0x0105
  115. /*! \brief UART _ioctl() command code to query the parity mode.
  116. *
  117. * The configuration parameter must be a pointer to a uint32_t variable,
  118. * which receives the current parity mode, 0 (none), 1 (odd) or 2 (even).
  119. *
  120. * See also \ref UART_SETPARITY.
  121. */
  122. #define UART_GETPARITY 0x0106
  123. /*! \brief UART _ioctl() command code to set the number of stop bits.
  124. *
  125. * The configuration parameter must be a pointer to a uint32_t variable,
  126. * which contains the number of stop bits.
  127. *
  128. * Most platforms support 1 or 2 stop bits, initially set to 1.
  129. *
  130. * See also \ref UART_GETSTOPBITS.
  131. */
  132. #define UART_SETSTOPBITS 0x0107
  133. /*! \brief UART _ioctl() command code to query the number of stop bits.
  134. *
  135. * The configuration parameter must be a pointer to a uint32_t variable,
  136. * which receives the current number of stop bits.
  137. *
  138. * See also \ref UART_SETSTOPBITS.
  139. */
  140. #define UART_GETSTOPBITS 0x0108
  141. /*! \brief UART _ioctl() command code to set the status.
  142. *
  143. * The configuration parameter must be a pointer to a uint32_t variable,
  144. * which contains the \ref xaUARTStatus "UART status" to be set.
  145. *
  146. * See also \ref UART_GETSTATUS.
  147. */
  148. #define UART_SETSTATUS 0x0109
  149. /*! \brief UART _ioctl() command code to query the status.
  150. *
  151. * The configuration parameter must be a pointer to a uint32_t variable,
  152. * which receives the current \ref xaUARTStatus "UART status".
  153. *
  154. * See also \ref UART_SETSTATUS.
  155. */
  156. #define UART_GETSTATUS 0x010a
  157. /*! \brief UART _ioctl() command code to set the read timeout.
  158. *
  159. * The configuration parameter must be a pointer to a uint32_t variable,
  160. * which contains the read timeout in milliseconds.
  161. *
  162. * See also \ref UART_GETREADTIMEOUT.
  163. */
  164. #define UART_SETREADTIMEOUT 0x010b
  165. /*! \brief UART _ioctl() command code to query the read timeout.
  166. *
  167. * The configuration parameter must be a pointer to a uint32_t variable,
  168. * which receives the current read timeout in milliseconds.
  169. *
  170. * See also \ref UART_SETREADTIMEOUT.
  171. */
  172. #define UART_GETREADTIMEOUT 0x010c
  173. /*! \brief UART _ioctl() command code to set the write timeout.
  174. *
  175. * The configuration parameter must be a pointer to a uint32_t variable,
  176. * which contains the write timeout in milliseconds.
  177. *
  178. * See also \ref UART_GETWRITETIMEOUT.
  179. */
  180. #define UART_SETWRITETIMEOUT 0x010d
  181. /*! \brief UART _ioctl() command code to query the write timeout.
  182. *
  183. * The configuration parameter must be a pointer to a uint32_t variable,
  184. * which receives the current write timeout in milliseconds.
  185. *
  186. * See also \ref UART_SETWRITETIMEOUT.
  187. */
  188. #define UART_GETWRITETIMEOUT 0x010e
  189. /*! \brief UART _ioctl() command code to set the local echo mode.
  190. *
  191. * The configuration parameter must be a pointer to a uint32_t variable,
  192. * which contains the requested echo mode, either 0 (off) or 1 (on).
  193. *
  194. * See also \ref UART_GETLOCALECHO.
  195. */
  196. #define UART_SETLOCALECHO 0x010f
  197. /*! \brief UART _ioctl() command code to query the local echo mode.
  198. *
  199. * The configuration parameter must be a pointer to a uint32_t variable,
  200. * which receives the current echo mode, either 0 (off) or 1 (on).
  201. *
  202. * See also \ref UART_SETLOCALECHO.
  203. */
  204. #define UART_GETLOCALECHO 0x0110
  205. /*! \brief UART _ioctl() command code to set the flow control mode.
  206. *
  207. * The configuration parameter must be a pointer to a uint32_t variable,
  208. * which contains the requested \ref xaUARTHS "flow control mode".
  209. *
  210. * See also \ref UART_GETFLOWCONTROL.
  211. */
  212. #define UART_SETFLOWCONTROL 0x0111
  213. /*! \brief UART _ioctl() command code to query the flow control mode.
  214. *
  215. * The configuration parameter must be a pointer to a uint32_t variable,
  216. * which receives the current \ref xaUARTHS "flow control mode".
  217. *
  218. * See also \ref UART_SETFLOWCONTROL.
  219. */
  220. #define UART_GETFLOWCONTROL 0x0112
  221. /*! \brief UART _ioctl() command code to set the cooking mode.
  222. *
  223. * The configuration parameter must be a pointer to a uint32_t variable,
  224. * which contains the requested cooking mode, either 0 (raw) or 1 (EOL
  225. * translation).
  226. *
  227. * See also \ref UART_GETCOOKEDMODE.
  228. */
  229. #define UART_SETCOOKEDMODE 0x0113
  230. /*! \brief UART _ioctl() command code to query the cooking mode.
  231. *
  232. * The configuration parameter must be a pointer to a uint32_t variable,
  233. * which receives the current cooking mode, either 0 (raw) or 1 (EOL
  234. * translation).
  235. *
  236. * See also \ref UART_SETCOOKEDMODE.
  237. */
  238. #define UART_GETCOOKEDMODE 0x0114
  239. /*! \brief UART _ioctl() command code to set the buffering mode.
  240. *
  241. * The configuration parameter must be a pointer to a uint32_t variable,
  242. * which contains the requested buffering mode.
  243. *
  244. * See also \ref UART_GETBUFFERMODE.
  245. */
  246. #define UART_SETBUFFERMODE 0x0115
  247. /*! \brief UART _ioctl() command code to query the buffering mode.
  248. *
  249. * The configuration parameter must be a pointer to a uint32_t variable,
  250. * which receives the current buffering mode.
  251. *
  252. * See also \ref UART_SETBUFFERMODE.
  253. */
  254. #define UART_GETBUFFERMODE 0x0116
  255. /*! \brief UART _ioctl() command code to set the network interface mode.
  256. *
  257. * The configuration parameter must be a pointer to the \ref NUTDEVICE
  258. * structure of the network device to enable HDLC mode, or a NULL pointer
  259. * to disable it.
  260. *
  261. * See also \ref HDLC_GETIFNET.
  262. */
  263. #define HDLC_SETIFNET 0x0117
  264. /*! \brief UART _ioctl() command code to query the network interface mode.
  265. *
  266. * The configuration parameter must be a pointer to a pointer variable,
  267. * which receives a \ref NUTDEVICE pointer to the current network device
  268. * if HDLC is enabled, or NULL if disabled.
  269. *
  270. * See also \ref HDLC_SETIFNET.
  271. */
  272. #define HDLC_GETIFNET 0x0118
  273. /*! \brief UART _ioctl() command code to set the clock mode.
  274. *
  275. * The configuration parameter must be a pointer to a uint32_t variable,
  276. * which contains the requested \ref xaUARTClock "clock mode".
  277. *
  278. * See also \ref UART_GETCLOCKMODE.
  279. */
  280. #define UART_SETCLOCKMODE 0x0119
  281. /*! \brief UART _ioctl() command code to query the clock mode.
  282. *
  283. * The configuration parameter must be a pointer to a uint32_t variable,
  284. * which receives the current \ref xaUARTClock "clock mode".
  285. *
  286. * See also \ref UART_SETCLOCKMODE.
  287. */
  288. #define UART_GETCLOCKMODE 0x011a
  289. /*! \brief UART _ioctl() command code to set the transmit buffer size.
  290. *
  291. * The configuration parameter must be a pointer to a uint32_t variable,
  292. * which contains the requested size of the transmit buffer in bytes.
  293. *
  294. * See also \ref UART_GETTXBUFSIZ.
  295. */
  296. #define UART_SETTXBUFSIZ 0x011b
  297. /*! \brief UART _ioctl() command code to query the transmit buffer size.
  298. *
  299. * The configuration parameter must be a pointer to a uint32_t variable,
  300. * which receives the current size of the transmit buffer in bytes.
  301. *
  302. * See also \ref UART_SETTXBUFSIZ.
  303. */
  304. #define UART_GETTXBUFSIZ 0x011c
  305. /*! \brief UART _ioctl() command code to set the receive buffer size.
  306. *
  307. * The configuration parameter must be a pointer to a uint32_t variable,
  308. * which contains the requested size of the receive buffer in bytes.
  309. *
  310. * See also \ref UART_GETRXBUFSIZ.
  311. */
  312. #define UART_SETRXBUFSIZ 0x011d
  313. /*! \brief UART _ioctl() command code to query the receive buffer size.
  314. *
  315. * The configuration parameter must be a pointer to a uint32_t variable,
  316. * which receives the current size of the receive buffer in bytes.
  317. *
  318. * See also \ref UART_SETRXBUFSIZ.
  319. */
  320. #define UART_GETRXBUFSIZ 0x011e
  321. /*! \brief UART _ioctl() command code to set the transmit buffer low watermark.
  322. *
  323. * The configuration parameter must be a pointer to a uint32_t variable,
  324. * which contains the requested low watermark of the transmit buffer.
  325. *
  326. * See also \ref UART_GETTXBUFLWMARK.
  327. */
  328. #define UART_SETTXBUFLWMARK 0x0120
  329. /*! \brief UART _ioctl() command code to query the transmit buffer low watermark.
  330. *
  331. * The configuration parameter must be a pointer to a uint32_t variable,
  332. * which receives the current low watermark of the transmit buffer.
  333. *
  334. * See also \ref UART_SETTXBUFLWMARK.
  335. */
  336. #define UART_GETTXBUFLWMARK 0x0121
  337. /*! \brief UART _ioctl() command code to set the transmit buffer high watermark.
  338. *
  339. * The configuration parameter must be a pointer to a uint32_t variable,
  340. * which contains the requested high watermark of the transmit buffer.
  341. *
  342. * See also \ref UART_GETTXBUFHWMARK.
  343. */
  344. #define UART_SETTXBUFHWMARK 0x0122
  345. /*! \brief UART _ioctl() command code to query the transmit buffer high watermark.
  346. *
  347. * The configuration parameter must be a pointer to a uint32_t variable,
  348. * which receives the current high watermark of the transmit buffer.
  349. *
  350. * See also \ref UART_SETTXBUFHWMARK.
  351. */
  352. #define UART_GETTXBUFHWMARK 0x0123
  353. /*! \brief UART _ioctl() command code to set the receive buffer low watermark.
  354. *
  355. * The configuration parameter must be a pointer to a uint32_t variable,
  356. * which contains the requested low watermark of the receive buffer.
  357. *
  358. * See also \ref UART_GETRXBUFLWMARK.
  359. */
  360. #define UART_SETRXBUFLWMARK 0x0124
  361. /*! \brief UART _ioctl() command code to query the receive buffer low watermark.
  362. *
  363. * The configuration parameter must be a pointer to a uint32_t variable,
  364. * which receives the current low watermark of the receive buffer.
  365. *
  366. * See also \ref UART_SETRXBUFLWMARK.
  367. */
  368. #define UART_GETRXBUFLWMARK 0x0125
  369. /*! \brief UART _ioctl() command code to set the receive buffer high watermark.
  370. *
  371. * The configuration parameter must be a pointer to a uint32_t variable,
  372. * which contains the requested high watermark of the receive buffer.
  373. *
  374. * See also \ref UART_GETRXBUFHWMARK.
  375. */
  376. #define UART_SETRXBUFHWMARK 0x0126
  377. /*! \brief UART _ioctl() command code to query the receive buffer high watermark.
  378. *
  379. * The configuration parameter must be a pointer to a uint32_t variable,
  380. * which receives the current high watermark of the receive buffer.
  381. *
  382. * See also \ref UART_SETRXBUFHWMARK.
  383. */
  384. #define UART_GETRXBUFHWMARK 0x0127
  385. /*! \brief UART _ioctl() command code to set the block read mode.
  386. *
  387. * The configuration parameter must be a pointer to a uint32_t variable,
  388. * which contains the requested block read mode, either 0 (disabled)
  389. * or 1 (enabled).
  390. *
  391. * See also \ref UART_GETBLOCKREAD.
  392. */
  393. #define UART_SETBLOCKREAD 0x0128
  394. /*! \brief UART _ioctl() command code to query the the block read mode.
  395. *
  396. * The configuration parameter must be a pointer to a uint32_t variable,
  397. * which receives the current read block mode, either 0 (disabled)
  398. * or 1 (enabled).
  399. *
  400. * See also \ref UART_SETBLOCKREAD.
  401. */
  402. #define UART_GETBLOCKREAD 0x0129
  403. /*! \brief UART _ioctl() command code to set the block write mode
  404. *
  405. * The configuration parameter must be a pointer to a uint32_t variable,
  406. * which contains the requested block write mode, either 0 (disabled)
  407. * or 1 (enabled).
  408. *
  409. * See also \ref UART_GETBLOCKWRITE.
  410. */
  411. #define UART_SETBLOCKWRITE 0x012a
  412. /*! \brief UART _ioctl() command code to query the the block write mode.
  413. *
  414. * The configuration parameter must be a pointer to a uint32_t variable,
  415. * which receives the current write block mode, either 0 (disabled)
  416. * or 1 (enabled).
  417. *
  418. * See also \ref UART_SETBLOCKWRITE.
  419. */
  420. #define UART_GETBLOCKWRITE 0x012b
  421. /*! \brief UART _ioctl() command code to set physical device to the raw mode.
  422. *
  423. * The configuration parameter must be a pointer to a uint32_t variable,
  424. * which contains the requested raw mode, either 0 (disabled) or 1 (enabled).
  425. *
  426. * In raw mode data encapsulation is not allowed to be done. This allows other
  427. * processing to be done on physical device after a network device has been
  428. * attached.
  429. *
  430. * See also \ref UART_GETRAWMODE.
  431. */
  432. #define UART_SETRAWMODE 0x012c
  433. /*! \brief UART _ioctl() command code to query the raw mode.
  434. *
  435. * The configuration parameter must be a pointer to a uint32_t variable,
  436. * which receives the current raw mode, either 0 (disabled) or 1 (enabled).
  437. *
  438. * See also \ref UART_SETRAWMODE.
  439. */
  440. #define UART_GETRAWMODE 0x012d
  441. /*! \brief AHDLC _ioctl() command code to set the ACCM (Control Character Mask).
  442. *
  443. * The configuration parameter must be a pointer to a uint32_t variable,
  444. * which contains the requested character mask.
  445. *
  446. * During the LCP stage of PPP negotiation both peers inform each other which
  447. * of the control characters (0-31) will not require escaping when being
  448. * transmitted. This allows the PPP layer to tell the HDLC layer about this
  449. * so that data may be transmitted quicker (no escapes).
  450. *
  451. * See also \ref HDLC_GETTXACCM.
  452. */
  453. #define HDLC_SETTXACCM 0x012e
  454. /*! \brief AHDLC _ioctl() command code to get the ACCM (Control Character Mask).
  455. *
  456. * The configuration parameter must be a pointer to a uint32_t variable,
  457. * which receives the current character mask.
  458. *
  459. * See also \ref HDLC_SETTXACCM.
  460. */
  461. #define HDLC_GETTXACCM 0x012f
  462. /*! \brief UART _ioctl() command code to set physical device to half duplex mode.
  463. *
  464. * The configuration parameter must be a pointer to a uint32_t variable,
  465. * which contains the requested half duplex mode, either 0 (disabled) or
  466. * 1 (enabled).
  467. *
  468. * See also \ref UART_GETHDPXMODE.
  469. */
  470. #define UART_SETHDPXMODE 0x0130
  471. /*! \brief UART _ioctl() command code to query the halfduplex mode.
  472. *
  473. * The configuration parameter must be a pointer to a uint32_t variable,
  474. * which receives the current half duplex mode, either 0 (disabled) or
  475. * 1 (enabled).
  476. *
  477. * See also \ref UART_SETHDPXMODE.
  478. */
  479. #define UART_GETHDPXMODE 0x0131
  480. /*! \brief UART _ioctl() command code to set physical device to half duplex mode.
  481. *
  482. * If devive supports, Rx is connected internally to TX, TX is set to multidrive and
  483. * TX is pulled up. Ioctl may succeed even when pull-up is not realized.
  484. *
  485. * The configuration parameter must be a pointer to a uint32_t variable,
  486. * which contains the requested half duplex mode, either 0 (disabled) or
  487. * 1 (enabled).
  488. *
  489. * See also \ref UART_GETHDPXMODE.
  490. */
  491. #define UART_SETOWIMODE 0x0132
  492. /*! \brief UART _ioctl() command code to query the OWI halfduplex mode.
  493. *
  494. * The configuration parameter must be a pointer to a uint32_t variable,
  495. * which receives the current half duplex mode, either 0 (disabled) or
  496. * 1 (enabled).
  497. *
  498. * See also \ref UART_SETOWIMODE.
  499. */
  500. #define UART_GETOWIMODE 0x0133
  501. /*!
  502. * \addtogroup xgUARTStatus
  503. * \brief UART device status flags,
  504. *
  505. * \anchor xaUARTStatus
  506. * A combination of these status flags is used by the _ioctl() commands
  507. * \ref UART_SETSTATUS and \ref UART_GETSTATUS.
  508. */
  509. /*@{*/
  510. /*! \brief Framing error.
  511. *
  512. * \ref UART_SETSTATUS will clear this error.
  513. */
  514. #define UART_FRAMINGERROR 0x00000001UL
  515. /*! \brief Overrun error.
  516. *
  517. * \ref UART_SETSTATUS will clear this error.
  518. */
  519. #define UART_OVERRUNERROR 0x00000002UL
  520. /*! \brief Parity error.
  521. *
  522. * \ref UART_SETSTATUS will clear this error.
  523. */
  524. #define UART_PARITYERROR 0x00000004UL
  525. /*! \brief UART errors.
  526. *
  527. * \ref UART_SETSTATUS will clear all errors.
  528. */
  529. #define UART_ERRORS (UART_FRAMINGERROR | UART_OVERRUNERROR | UART_PARITYERROR)
  530. /*! \brief Receiver buffer empty.
  531. */
  532. #define UART_RXBUFFEREMPTY 0x00000040UL
  533. /*! \brief Transmitter buffer empty.
  534. *
  535. * \ref UART_SETSTATUS will immediately clear the buffer. It will not
  536. * wait until the remaining characters have been transmitted.
  537. */
  538. #define UART_TXBUFFEREMPTY 0x00000080UL
  539. /*! \brief RTS handshake output enabled.
  540. */
  541. #define UART_RTSENABLED 0x00000100UL
  542. /*! \brief RTS handshake output disabled.
  543. */
  544. #define UART_RTSDISABLED 0x00000200UL
  545. /*! \brief CTS handshake input enabled.
  546. */
  547. #define UART_CTSENABLED 0x00000400UL
  548. /*! \brief CTS handshake input disabled.
  549. */
  550. #define UART_CTSDISABLED 0x00000800UL
  551. /*! \brief DTR handshake output enabled.
  552. */
  553. #define UART_DTRENABLED 0x00001000UL
  554. /*! \brief DTR handshake output disabled.
  555. */
  556. #define UART_DTRDISABLED 0x00002000UL
  557. /*! \brief Receiver enabled.
  558. */
  559. #define UART_RXENABLED 0x00010000UL
  560. /*! \brief Receiver disabled.
  561. */
  562. #define UART_RXDISABLED 0x00020000UL
  563. /*! \brief Transmitter enabled.
  564. */
  565. #define UART_TXENABLED 0x00040000UL
  566. /*! \brief Transmitter disabled.
  567. */
  568. #define UART_TXDISABLED 0x00080000UL
  569. /*! \brief Receive address frames only.
  570. *
  571. * Used in multidrop communication. May only work if 9 databits have
  572. * been configured.
  573. */
  574. #define UART_RXADDRFRAME 0x00100000UL
  575. /*! \brief Receive all frames.
  576. *
  577. * Used in multidrop communication.
  578. */
  579. #define UART_RXNORMFRAME 0x00200000UL
  580. /*! \brief Transmit as address frame.
  581. *
  582. * Used in multidrop communication. May only work if 9 databits have
  583. * been configured.
  584. */
  585. #define UART_TXADDRFRAME 0x00400000UL
  586. /*! \brief Transmit as normal frame.
  587. *
  588. * Used in multidrop communication.
  589. */
  590. #define UART_TXNORMFRAME 0x00800000UL
  591. /*@}*/
  592. /*!
  593. * \addtogroup xgUARTHS
  594. * \brief UART handshake modes.
  595. *
  596. * \anchor xaUARTHS
  597. * Any of these values may be used by the _ioctl() commands
  598. * \ref UART_SETFLOWCONTROL and \ref UART_GETFLOWCONTROL.
  599. */
  600. /*@{*/
  601. /*! \brief RTS / CTS hardware handshake.
  602. *
  603. * Nut/OS uses DTE definitions, where RTS is output and CTS is input.
  604. */
  605. #define UART_HS_RTSCTS 0x0003
  606. /*! \brief Full modem hardware handshake.
  607. *
  608. * Not supported yet by the standard drivers.
  609. */
  610. #define UART_HS_MODEM 0x001F
  611. /*! \brief XON / XOFF software handshake.
  612. *
  613. * It is recommended to set a proper read timeout with software handshake.
  614. * In this case a timeout may occur, if the communication peer lost our
  615. * last XON character. The application may then use ioctl() to disable the
  616. * receiver and do the read again. This will send out another XON.
  617. */
  618. #define UART_HS_SOFT 0x0020
  619. /*! \brief Half duplex mode.
  620. */
  621. #define UART_HS_HALFDUPLEX 0x0400
  622. /*@}*/
  623. /*!
  624. * \addtogroup xgUARTClock
  625. * \brief UART device clock modes.
  626. *
  627. * \anchor xaUARTClock
  628. * Any of these values may be used by the _ioctl() commands
  629. * \ref UART_SETCLOCKMODE and \ref UART_GETCLOCKMODE. Most drivers
  630. * require to set the bit rate after modifying the clock mode. In order
  631. * to avoid unknown clock output frequencies in master mode, set the
  632. * clock mode to \ref UART_SYNCSLAVE first, than use \ref UART_SETSPEED
  633. * to select the bit rate and finally switch to \ref UART_SYNCMASTER or
  634. * \ref UART_NSYNCMASTER.
  635. */
  636. /*@{*/
  637. #define UART_SYNC 0x01
  638. #define UART_MASTER 0x02
  639. #define UART_NCLOCK 0x04
  640. #define UART_HIGHSPEED 0x20
  641. /*! \brief Normal asynchronous mode.
  642. */
  643. #define UART_ASYNC 0x00
  644. /*! \brief Synchronous slave mode.
  645. *
  646. * Transmit data changes on rising edge and receive data is sampled on
  647. * the falling edge of the clock input.
  648. */
  649. #define UART_SYNCSLAVE UART_SYNC
  650. /*! \brief Synchronous master mode.
  651. *
  652. * Transmit data changes on rising edge and receive data is sampled on
  653. * the falling edge of the clock output.
  654. */
  655. #define UART_SYNCMASTER (UART_SYNC | UART_MASTER)
  656. /*! \brief Synchronous slave mode, clock negated.
  657. *
  658. * Similar to \ref UART_SYNCSLAVE, but transmit data changes on falling
  659. * edge and receive data is sampled on the rising edge of the clock input.
  660. */
  661. #define UART_NSYNCSLAVE (UART_SYNC | UART_NCLOCK)
  662. /*! \brief Synchronous master mode, clock negated
  663. *
  664. * Similar to \ref UART_SYNCMASTER, but transmit data changes on falling
  665. * edge and receive data is sampled on the rising edge of the clock output.
  666. */
  667. #define UART_NSYNCMASTER (UART_SYNC | UART_NCLOCK | UART_MASTER)
  668. /*! \brief Asynchronous high speed mode.
  669. *
  670. * More deviation sensitive than normal mode, but supports higher speed.
  671. */
  672. #define UART_ASYNC_HS UART_HIGHSPEED
  673. /*@}*/
  674. /*@}*/
  675. #endif