ace.h 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456
  1. #ifndef _DEV_ACE_H
  2. #define _DEV_ACE_H
  3. /*
  4. * Copyright (C) 2001-2003 by Cyber Integration, LLC. All rights reserved.
  5. *
  6. * Redistribution and use in source and binary forms, with or without
  7. * modification, are permitted provided that the following conditions
  8. * are met:
  9. *
  10. * 1. Redistributions of source code must retain the above copyright
  11. * notice, this list of conditions and the following disclaimer.
  12. * 2. Redistributions in binary form must reproduce the above copyright
  13. * notice, this list of conditions and the following disclaimer in the
  14. * documentation and/or other materials provided with the distribution.
  15. * 3. Neither the name of the copyright holders nor the names of
  16. * contributors may be used to endorse or promote products derived
  17. * from this software without specific prior written permission.
  18. *
  19. * THIS SOFTWARE IS PROVIDED BY CYBER INTEGRATION, LLC AND CONTRIBUTORS
  20. * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  21. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
  22. * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL CYBER
  23. * INTEGRATION, LLC OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  24. * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
  25. * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
  26. * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
  27. * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  28. * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  29. * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  30. * SUCH DAMAGE.
  31. *
  32. *
  33. */
  34. /*
  35. * $Log$
  36. * Revision 1.4 2008/08/11 06:59:59 haraldkipp
  37. * BSD types replaced by stdint types (feature request #1282721).
  38. *
  39. * Revision 1.3 2007/08/29 07:43:53 haraldkipp
  40. * Documentation updated and corrected.
  41. *
  42. * Revision 1.2 2006/05/25 09:09:57 haraldkipp
  43. * API documentation updated and corrected.
  44. *
  45. * Revision 1.1 2005/11/24 11:24:06 haraldkipp
  46. * Initial check-in.
  47. * Many thanks to William Basser for this code and also to Przemyslaw Rudy
  48. * for several enhancements.
  49. *
  50. */
  51. #include <sys/device.h>
  52. /*!
  53. * \file dev/ace.h
  54. * \brief ACE I/O function prototypes.
  55. */
  56. /*!
  57. * \addtogroup xgAceDriver
  58. *
  59. * \brief ACE _ioctl() commands.
  60. *
  61. * These commands are used to control and retrieve hardware specific
  62. * configurations. The definitions are kept independent from the
  63. * underlying hardware, but not all commands may be fully implemented
  64. * in each ACE driver.
  65. *
  66. * The _ioctl() function expects three parameters:
  67. * - A device descriptor.
  68. * - A command code, any of the ACE_... commands listed below.
  69. * - A pointer to a configuration parameter, in most cases an unsigned long.
  70. */
  71. /*@{*/
  72. /*! \brief ACE _ioctl() command code to set the line speed.
  73. *
  74. * The configuration parameter specifies the input and output bit rate
  75. * per second.
  76. */
  77. #define ACE_SETSPEED 0x0101
  78. /*! \brief ACE _ioctl() command code to query the line speed.
  79. *
  80. * The configuration parameter is set to the input and output bit rate
  81. * per second.
  82. */
  83. #define ACE_GETSPEED 0x0102
  84. /*! \brief ACE _ioctl() command code to set the number of data bits.
  85. *
  86. * The configuration parameter specifies the number of data bits, 5, 6,
  87. * 7, 8 or 9.
  88. */
  89. #define ACE_SETDATABITS 0x0103
  90. /*! \brief ACE _ioctl() command code to query the number of data bits.
  91. *
  92. * The configuration parameter is set to the number of data bits, 5, 6,
  93. * 7, 8 or 9.
  94. */
  95. #define ACE_GETDATABITS 0x0104
  96. /*! \brief ACE _ioctl() command code to set the parity mode.
  97. *
  98. * The configuration parameter specifies the type of the parity bit,
  99. * 0 (none), 1 (odd), 2 (even), 3 (mark) or 4 (space).
  100. */
  101. #define ACE_SETPARITY 0x0105
  102. /*! \brief ACE _ioctl() command code to query the parity mode.
  103. *
  104. * The configuration parameter is set to the type of the parity bit,
  105. * 0 (none), 1 (odd), 2 (even), 3 (mark) or 4 (space).
  106. */
  107. #define ACE_GETPARITY 0x0106
  108. /*! \brief ACE _ioctl() command code to set the number of stop bits.
  109. *
  110. * The configuration parameter specifies the number of stop bits, 1 or 2.
  111. */
  112. #define ACE_SETSTOPBITS 0x0107
  113. /*! \brief ACE _ioctl() command code to query the number of stop bits.
  114. *
  115. * The configuration parameter is set to the number of stop bits, 1 or 2.
  116. */
  117. #define ACE_GETSTOPBITS 0x0108
  118. /*! \brief ACE _ioctl() command code to set the status.
  119. *
  120. * The configuration parameter specifies the status to set.
  121. */
  122. #define ACE_SETSTATUS 0x0109
  123. /*! \brief ACE _ioctl() command code to query the status.
  124. *
  125. * The configuration parameter is set to the current status.
  126. */
  127. #define ACE_GETSTATUS 0x010a
  128. /*! \brief ACE _ioctl() command code to set the read timeout.
  129. *
  130. * The configuration parameter specifies the read timeout in
  131. * milliseconds.
  132. */
  133. #define ACE_SETREADTIMEOUT 0x010b
  134. /*! \brief ACE _ioctl() command code to query the read timeout.
  135. *
  136. * The configuration parameter is set to the read timeout in
  137. * milliseconds.
  138. */
  139. #define ACE_GETREADTIMEOUT 0x010c
  140. /*! \brief ACE _ioctl() command code to set the write timeout.
  141. *
  142. * The configuration parameter specifies the write timeout in
  143. * milliseconds.
  144. */
  145. #define ACE_SETWRITETIMEOUT 0x010d
  146. /*! \brief ACE _ioctl() command code to query the write timeout.
  147. *
  148. * The configuration parameter is set to the write timeout in
  149. * milliseconds.
  150. */
  151. #define ACE_GETWRITETIMEOUT 0x010e
  152. /*! \brief ACE _ioctl() command code to set the local echo mode.
  153. *
  154. * The configuration parameter specifies the local echo mode,
  155. * 0 (off) or 1 (on).
  156. */
  157. #define ACE_SETLOCALECHO 0x010f
  158. /*! \brief ACE _ioctl() command code to query the local echo mode.
  159. *
  160. * The configuration parameter is set to the local echo mode,
  161. * 0 (off) or 1 (on).
  162. */
  163. #define ACE_GETLOCALECHO 0x0110
  164. /*! \brief ACE _ioctl() command code to set the flow control mode.
  165. *
  166. * The configuration parameter specifies the flow control mode.
  167. */
  168. #define ACE_SETFLOWCONTROL 0x0111
  169. /*! \brief ACE _ioctl() command code to query the flow control mode.
  170. *
  171. * The configuration parameter is set to the flow control mode.
  172. */
  173. #define ACE_GETFLOWCONTROL 0x0112
  174. /*! \brief ACE _ioctl() command code to set the cooking mode.
  175. *
  176. * The configuration parameter specifies the character cooking mode,
  177. * 0 (raw) or 1 (EOL translation).
  178. */
  179. #define ACE_SETCOOKEDMODE 0x0113
  180. /*! \brief ACE _ioctl() command code to query the cooking mode.
  181. *
  182. * The configuration parameter is set to the character cooking mode,
  183. * 0 (raw) or 1 (EOL translation).
  184. */
  185. #define ACE_GETCOOKEDMODE 0x0114
  186. /*! \brief ACE _ioctl() command code to set the buffering mode.
  187. *
  188. * The configuration parameter specifies the buffering mode.
  189. */
  190. #define ACE_SETBUFFERMODE 0x0115
  191. /*! \brief ACE _ioctl() command code to query the buffering mode.
  192. *
  193. * The configuration parameter is set to the buffering mode.
  194. */
  195. #define ACE_GETBUFFERMODE 0x0116
  196. /*! \brief ACE _ioctl() command code to set the transmit buffer size.
  197. *
  198. * The configuration parameter specifies the number of bytes.
  199. */
  200. #define ACE_SETTXBUFSIZ 0x011b
  201. /*! \brief ACE _ioctl() command code to query the transmit buffer size.
  202. *
  203. * The configuration parameter specifies the number of bytes.
  204. */
  205. #define ACE_GETTXBUFSIZ 0x011c
  206. /*! \brief ACE _ioctl() command code to set the receive buffer size.
  207. *
  208. * The configuration parameter specifies the number of bytes.
  209. */
  210. #define ACE_SETRXBUFSIZ 0x011d
  211. /*! \brief ACE _ioctl() command code to query the receive buffer size.
  212. *
  213. * The configuration parameter specifies the number of bytes.
  214. */
  215. #define ACE_GETRXBUFSIZ 0x011e
  216. /*! \brief ACE _ioctl() command code to set the transmit buffer low watermark.
  217. *
  218. * The configuration parameter specifies the number of bytes.
  219. */
  220. #define ACE_SETTXBUFLWMARK 0x0120
  221. /*! \brief ACE _ioctl() command code to query the transmit buffer low watermark.
  222. *
  223. * The configuration parameter specifies the number of bytes.
  224. */
  225. #define ACE_GETTXBUFLWMARK 0x0121
  226. /*! \brief ACE _ioctl() command code to set the transmit buffer high watermark.
  227. *
  228. * The configuration parameter specifies the number of bytes.
  229. */
  230. #define ACE_SETTXBUFHWMARK 0x0122
  231. /*! \brief ACE _ioctl() command code to query the transmit buffer high watermark.
  232. *
  233. * The configuration parameter specifies the number of bytes.
  234. */
  235. #define ACE_GETTXBUFHWMARK 0x0123
  236. /*! \brief ACE _ioctl() command code to set the receive buffer low watermark.
  237. *
  238. * The configuration parameter specifies the number of bytes.
  239. */
  240. #define ACE_SETRXBUFLWMARK 0x0124
  241. /*! \brief ACE _ioctl() command code to query the receive buffer low watermark.
  242. *
  243. * The configuration parameter specifies the number of bytes.
  244. */
  245. #define ACE_GETRXBUFLWMARK 0x0125
  246. /*! \brief ACE _ioctl() command code to set the receive buffer high watermark.
  247. *
  248. * The configuration parameter specifies the number of bytes.
  249. */
  250. #define ACE_SETRXBUFHWMARK 0x0126
  251. /*! \brief ACE _ioctl() command code to query the receive buffer high watermark.
  252. *
  253. * The configuration parameter specifies the number of bytes.
  254. */
  255. #define ACE_GETRXBUFHWMARK 0x0127
  256. /*! \brief ACE _ioctl() command code to set the block read mode
  257. *
  258. * The configuration parameter specifies the block read mode
  259. */
  260. #define ACE_SETBLOCKREAD 0x0128
  261. /*! \brief ACE _ioctl() command code to query the receive buffer high watermark.
  262. *
  263. * The configuration parameter specifies the block read mode
  264. */
  265. #define ACE_GETBLOCKREAD 0x0129
  266. /*! \brief ACE _ioctl() command code to set the fifo mode and receive fifo trigger level.
  267. *
  268. * The configuration parameter specifies the receive fifo trigger level (x,1,4,8,14), x - disables fifo
  269. */
  270. #define ACE_SETFIFO 0x012a
  271. /*! \brief ACE _ioctl() command code to query the fifo mode and receive fifo trigger level.
  272. *
  273. * The configuration parameter specifies the receive fifo trigger level (x,1,4,8,14), x - fifo is disabled
  274. */
  275. #define ACE_GETFIFO 0x012b
  276. /*!
  277. * \addtogroup xgACEStatus
  278. * \brief ACE device status flags,
  279. *
  280. * A combination of these status flags is used by the _ioctl() commands
  281. * \ref ACE_SETSTATUS and \ref ACE_GETSTATUS.
  282. */
  283. /*@{*/
  284. /*! \brief Framing error.
  285. *
  286. * \ref ACE_SETSTATUS will clear this error.
  287. */
  288. #define ACE_FRAMINGERROR 0x00000001UL
  289. /*! \brief Overrun error.
  290. *
  291. * \ref ACE_SETSTATUS will clear this error.
  292. */
  293. #define ACE_OVERRUNERROR 0x00000002UL
  294. /*! \brief Parity error.
  295. *
  296. * \ref ACE_SETSTATUS will clear this error.
  297. */
  298. #define ACE_PARITYERROR 0x00000004UL
  299. /*! \brief ACE errors.
  300. *
  301. * \ref ACE_SETSTATUS will clear all errors.
  302. */
  303. #define ACE_ERRORS (ACE_FRAMINGERROR | ACE_OVERRUNERROR | ACE_PARITYERROR)
  304. /*! \brief Receiver buffer empty.
  305. */
  306. #define ACE_RXBUFFEREMPTY 0x00000040UL
  307. /*! \brief Transmitter buffer empty.
  308. *
  309. * \ref ACE_SETSTATUS will immediately clear the buffer. It will not
  310. * wait until the remaining characters have been transmitted.
  311. */
  312. #define ACE_TXBUFFEREMPTY 0x00000080UL
  313. /*! \brief RTS handshake output enabled.
  314. */
  315. #define ACE_RTSENABLED 0x00000100UL
  316. /*! \brief RTS handshake output disabled.
  317. */
  318. #define ACE_RTSDISABLED 0x00000200UL
  319. /*! \brief CTS handshake input enabled.
  320. */
  321. #define ACE_CTSENABLED 0x00000400UL
  322. /*! \brief CTS handshake input disabled.
  323. */
  324. #define ACE_CTSDISABLED 0x00000800UL
  325. /*! \brief DTR handshake output enabled.
  326. */
  327. #define ACE_DTRENABLED 0x00001000UL
  328. /*! \brief DTR handshake output disabled.
  329. */
  330. #define ACE_DTRDISABLED 0x00002000UL
  331. /*! \brief Receiver enabled.
  332. */
  333. #define ACE_RXENABLED 0x00010000UL
  334. /*! \brief Receiver enabled.
  335. */
  336. #define ACE_RXDISABLED 0x00020000UL
  337. /*! \brief Transmitter enabled.
  338. */
  339. #define ACE_TXENABLED 0x00040000UL
  340. /*! \brief Transmitter enabled.
  341. */
  342. #define ACE_TXDISABLED 0x00080000UL
  343. /*@}*/
  344. /*!
  345. * \addtogroup xgACEHS
  346. * \brief ACE handshake modes.
  347. *
  348. * Any of these values may be used by the _ioctl() commands
  349. * \ref ACE_SETFLOWCONTROL and \ref ACE_GETFLOWCONTROL.
  350. */
  351. /*@{*/
  352. /*! \brief RTS / CTS hardware handshake.
  353. *
  354. * Nut/OS uses DTE definitions, where RTS is output and CTS is input.
  355. */
  356. #define ACE_HS_RTSCTS 0x0003
  357. /*! \brief Full modem hardware handshake.
  358. *
  359. * Not supported yet by the standard drivers.
  360. */
  361. #define ACE_HS_MODEM 0x001F
  362. /*! \brief XON / XOFF software handshake.
  363. *
  364. * It is recommended to set a proper read timeout with software handshake.
  365. * In this case a timeout may occur, if the communication peer lost our
  366. * last XON character. The application may then use ioctl() to disable the
  367. * receiver and do the read again. This will send out another XON.
  368. */
  369. #define ACE_HS_SOFT 0x0020
  370. /*@}*/
  371. /*@}*/
  372. extern int AceInit(NUTDEVICE * dev);
  373. extern int AceIOCtl(NUTDEVICE * dev, int req, void *conf);
  374. extern int AceInput(NUTDEVICE * dev);
  375. extern int AceOutput(NUTDEVICE * dev);
  376. extern int AceFlush(NUTDEVICE * dev);
  377. extern int AceGetRaw(uint8_t * cp);
  378. extern int AcePutRaw(uint8_t ch);
  379. extern int AceRead(NUTFILE * fp, void *buffer, int size);
  380. extern int AceWrite(NUTFILE * fp, const void *buffer, int len);
  381. extern int AceWrite_P(NUTFILE * fp, PGM_P buffer, int len);
  382. extern NUTFILE *AceOpen(NUTDEVICE * dev, const char *name, int mode, int acc);
  383. extern long AceSize(NUTFILE * fp);
  384. extern int AceClose(NUTFILE * fp);
  385. #endif