serial.h.html 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215
  1. <?xml version='1.0' encoding='iso-8859-1'?>
  2. <!doctype html public '-//W3C//DTD XHTML 1.0 Strict//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd'>
  3. <html xmlns='http://www.w3c.org/1999/xhtml' lang='en-us'>
  4. <head>
  5. <title>
  6. serial.h
  7. </title>
  8. <meta http-equiv='content-type' content='text/html;iso-8859-1'/>
  9. <meta name='generator' content='motley-tools 1.9.4 13:40:33 Feb 18 2015'/>
  10. <meta name='author' content='cmaier@cmassoc.net'/>
  11. <meta name='robots' content='noindex,nofollow'/>
  12. <link href='toolkit.css' rel='stylesheet' type='text/css'/>
  13. </head>
  14. <body>
  15. <div class='headerlink'>
  16. [<a href='sdram.h.html' title=' sdram.h '>PREV</a>]
  17. [<a href='toolkit.html' title=' Index '>HOME</a>]
  18. [<a href='SHA256.h.html' title=' SHA256.h '>NEXT</a>]
  19. </div>
  20. <pre>
  21. /*====================================================================*
  22. *
  23. * Copyright (c) 2013 Qualcomm Atheros, Inc.
  24. *
  25. * All rights reserved.
  26. *
  27. * Redistribution and use in source and binary forms, with or
  28. * without modification, are permitted (subject to the limitations
  29. * in the disclaimer below) provided that the following conditions
  30. * are met:
  31. *
  32. * * Redistributions of source code must retain the above copyright
  33. * notice, this list of conditions and the following disclaimer.
  34. *
  35. * * Redistributions in binary form must reproduce the above
  36. * copyright notice, this list of conditions and the following
  37. * disclaimer in the documentation and/or other materials
  38. * provided with the distribution.
  39. *
  40. * * Neither the name of Qualcomm Atheros nor the names of
  41. * its contributors may be used to endorse or promote products
  42. * derived from this software without specific prior written
  43. * permission.
  44. *
  45. * NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE
  46. * GRANTED BY THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE
  47. * COPYRIGHT HOLDERS AND CONTRIBUTORS &quot;AS IS&quot; AND ANY EXPRESS OR
  48. * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  49. * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  50. * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
  51. * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  52. * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
  53. * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  54. * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  55. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
  56. * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
  57. * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  58. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  59. *
  60. *--------------------------------------------------------------------*/
  61. /*====================================================================*
  62. *
  63. * serial.h - Atheros Serial Line Definitions and declarations;
  64. *
  65. *. Qualcomm Atheros HomePlug AV Powerline Toolkit
  66. *: Copyright (c) 2009-2013 by Qualcomm Atheros Inc. ALL RIGHTS RESERVED;
  67. *; For demonstration and evaluation only; Not for production use.
  68. *
  69. * Contributor(s):
  70. * Charles Maier &lt;cmaier@qca.qualcomm.com&gt;
  71. *
  72. *--------------------------------------------------------------------*/
  73. #ifndef SERIAL_HEADER
  74. #define SERIAL_HEADER
  75. /*====================================================================*
  76. * system header files;
  77. *--------------------------------------------------------------------*/
  78. #include &lt;ctype.h&gt;
  79. #ifndef WIN32
  80. #include &lt;termios.h&gt;
  81. #endif
  82. /*====================================================================*
  83. * custom header files;
  84. *--------------------------------------------------------------------*/
  85. #include &quot;../tools/types.h&quot;
  86. /*====================================================================*
  87. *
  88. *--------------------------------------------------------------------*/
  89. #if defined (WIN32)
  90. # define DEVICE &quot;com1:&quot;
  91. # define PAUSE(x) Sleep (x)
  92. #else
  93. # define DEVICE &quot;/dev/ttyUSB0&quot;
  94. # define PAUSE(x) usleep ((x)*1000)
  95. #endif
  96. /*====================================================================*
  97. *
  98. *--------------------------------------------------------------------*/
  99. #define UART_MODE 0
  100. #define UART_BAUDRATE 115200
  101. #define UART_DATABITS 8
  102. #define UART_STOPBITS 1
  103. #define UART_PARITY 0
  104. #define UART_FLOWCTRL 0
  105. #define UART_BUFFERSIZE 4096
  106. #define UART_BLOCKSIZE 512
  107. #define UART_PORT &quot;PLCUART&quot;
  108. /*====================================================================*
  109. * Atheros Serial Line Command flags;
  110. *--------------------------------------------------------------------*/
  111. #define UART_SILENCE (1 &lt;&lt; 0)
  112. #define UART_VERBOSE (1 &lt;&lt; 1)
  113. #define UART_DEFAULT (1 &lt;&lt; 2)
  114. #define UART_COMMAND (1 &lt;&lt; 3)
  115. #define UART_WAKE (1 &lt;&lt; 4)
  116. #define UART_RESPOND (1 &lt;&lt; 5)
  117. #define UART_ATRV (1 &lt;&lt; 6)
  118. #define UART_ATRPM (1 &lt;&lt; 7)
  119. #define UART_ATSK1 (1 &lt;&lt; 8)
  120. #define UART_ATSK2 (1 &lt;&lt; 9)
  121. #define UART_ATZ (1 &lt;&lt; 10)
  122. #define UART_ATDST1 (1 &lt;&lt; 11)
  123. #define UART_ATDST2 (1 &lt;&lt; 12)
  124. #define UART_ATNI (1 &lt;&lt; 13)
  125. #define UART_ATFD (1 &lt;&lt; 14)
  126. #define UART_ATPS (1 &lt;&lt; 15)
  127. #define UART_ATO (1 &lt;&lt; 16)
  128. #define UART_ATHSC (1 &lt;&lt; 17)
  129. #define UART_ATRP (1 &lt;&lt; 18)
  130. #define UART_ATWPF1 (1 &lt;&lt; 19)
  131. #define UART_ATWPF2 (1 &lt;&lt; 20)
  132. #define UART_ATWNV (1 &lt;&lt; 21)
  133. #define UART_ATBSZ1 (1 &lt;&lt; 22)
  134. #define UART_ATBSZ2 (1 &lt;&lt; 23)
  135. #define UART_ATTO (1 &lt;&lt; 24)
  136. #define UART_ATBR (1 &lt;&lt; 25)
  137. #define UART_ATM (1 &lt;&lt; 26)
  138. /*====================================================================*
  139. *
  140. * struct command;
  141. *
  142. * structure containing serial command buffer and two pointers; the
  143. * buffer is used for both transmit and receive and shared by most
  144. * function below;
  145. *
  146. *--------------------------------------------------------------------*/
  147. typedef struct command
  148. {
  149. char buffer [UART_BUFFERSIZE];
  150. unsigned length;
  151. unsigned offset;
  152. }
  153. COMMAND;
  154. /*====================================================================*
  155. *
  156. *--------------------------------------------------------------------*/
  157. #ifndef WIN32
  158. signed baudrate (unsigned rate, speed_t * speed);
  159. #endif
  160. void openport (struct _file_ * port, flag_t mode);
  161. void closeport (struct _file_ * port);
  162. /*====================================================================*
  163. * serial command line buffer functions;
  164. *--------------------------------------------------------------------*/
  165. void clearcommand ();
  166. void sendcommand (struct _file_ * port, flag_t flags);
  167. void readcommand (struct _file_ * port, flag_t flags);
  168. void insert (char c);
  169. size_t readframe (signed fd, void * memory, size_t extent);
  170. void decode (void const * memory, size_t extent);
  171. void encode (void * memory, size_t extent);
  172. void string (char * string);
  173. uint64_t hextoint (unsigned bytes);
  174. void mustbe (char c);;
  175. /*====================================================================*
  176. *
  177. *--------------------------------------------------------------------*/
  178. #endif
  179. </pre>
  180. <div class='footerlink'>
  181. [<a href='sdram.h.html' title=' sdram.h '>PREV</a>]
  182. [<a href='toolkit.html' title=' Index '>HOME</a>]
  183. [<a href='SHA256.h.html' title=' SHA256.h '>NEXT</a>]
  184. </div>
  185. </body>
  186. </html>