ace.h 13 KB

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