USB2SerialMux/firmware/uart/manual_uart.html

473 lines
29 KiB
HTML
Raw Permalink Normal View History

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.9.1"/>
<title>AVR-GCC Libraries: UART Library &lt;uart.h&gt;</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
<tbody>
<tr style="height: 56px;">
<td style="padding-left: 0.5em;">
<div id="projectname">AVR-GCC Libraries
</div>
</td>
</tr>
</tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.9.1 -->
<div id="navrow1" class="tabs">
<ul class="tablist">
<li><a href="index.html"><span>Main&#160;Page</span></a></li>
<li><a href="modules.html"><span>Modules</span></a></li>
<li><a href="files.html"><span>Files</span></a></li>
</ul>
</div>
</div><!-- top -->
<div class="header">
<div class="summary">
<a href="#define-members">Macros</a> &#124;
<a href="#func-members">Functions</a> </div>
<div class="headertitle">
<div class="title">UART Library &lt;uart.h&gt;</div> </div>
</div><!--header-->
<div class="contents">
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
<p>Interrupt UART library using the built-in UART with transmit and receive circular buffers. </p>
<div class="fragment"><div class="line"><span class="preprocessor">#include &lt;<a class="code" href="uart_8h.html">uart.h</a>&gt;</span> </div>
</div><!-- fragment --><p>This library can be used to transmit and receive data through the built in UART.</p>
<p>An interrupt is generated when the UART has finished transmitting or receiving a byte. The interrupt handling routines use circular buffers for buffering received and transmitted data.</p>
<p>The UART_RX_BUFFER_SIZE and UART_TX_BUFFER_SIZE constants define the size of the circular buffers in bytes. Note that these constants must be a power of 2. You may need to adapt these constants to your target and your application by adding CDEFS += -DUART_RX_BUFFER_SIZE=nn -DUART_TX_BUFFER_SIZE=nn to your Makefile.</p>
<dl class="section note"><dt>Note</dt><dd>Based on Atmel Application Note AVR306 </dd></dl>
<dl class="section author"><dt>Author</dt><dd>Peter Fleury <a href="#" onclick="location.href='mai'+'lto:'+'pfl'+'eu'+'ry@'+'gm'+'x.c'+'h'; return false;">pfleu<span style="display: none;">.nosp@m.</span>ry@g<span style="display: none;">.nosp@m.</span>mx.ch</a> <a href="http://tinyurl.com/peterfleury">http://tinyurl.com/peterfleury</a> </dd></dl>
<dl class="section copyright"><dt>Copyright</dt><dd>(C) 2015 Peter Fleury, GNU General Public License Version 3 </dd></dl>
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="define-members"></a>
Macros</h2></td></tr>
<tr class="memitem:ga367ff7b5de225ed936a63239ad4adb0b"><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__pfleury__uart.html#ga367ff7b5de225ed936a63239ad4adb0b">UART_BAUD_SELECT</a>(baudRate, xtalCpu)&#160;&#160;&#160;(((xtalCpu) + 8UL * (baudRate)) / (16UL * (baudRate)) -1UL)</td></tr>
<tr class="memdesc:ga367ff7b5de225ed936a63239ad4adb0b"><td class="mdescLeft">&#160;</td><td class="mdescRight">UART Baudrate Expression. <a href="#ga367ff7b5de225ed936a63239ad4adb0b">More...</a><br /></td></tr>
<tr class="separator:ga367ff7b5de225ed936a63239ad4adb0b"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga1a02d45130520cb651ab313e69039382"><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__pfleury__uart.html#ga1a02d45130520cb651ab313e69039382">UART_BAUD_SELECT_DOUBLE_SPEED</a>(baudRate, xtalCpu)&#160;&#160;&#160;( ((((xtalCpu) + 4UL * (baudRate)) / (8UL * (baudRate)) -1UL)) | 0x8000)</td></tr>
<tr class="memdesc:ga1a02d45130520cb651ab313e69039382"><td class="mdescLeft">&#160;</td><td class="mdescRight">UART Baudrate Expression for ATmega double speed mode. <a href="#ga1a02d45130520cb651ab313e69039382">More...</a><br /></td></tr>
<tr class="separator:ga1a02d45130520cb651ab313e69039382"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga5bdd6772c246436bb14377095de79b31"><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__pfleury__uart.html#ga5bdd6772c246436bb14377095de79b31">UART_RX_BUFFER_SIZE</a>&#160;&#160;&#160;32</td></tr>
<tr class="memdesc:ga5bdd6772c246436bb14377095de79b31"><td class="mdescLeft">&#160;</td><td class="mdescRight">Size of the circular receive buffer, must be power of 2. <a href="#ga5bdd6772c246436bb14377095de79b31">More...</a><br /></td></tr>
<tr class="separator:ga5bdd6772c246436bb14377095de79b31"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga05f5d709605c6317c97e4974bec3402a"><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__pfleury__uart.html#ga05f5d709605c6317c97e4974bec3402a">UART_TX_BUFFER_SIZE</a>&#160;&#160;&#160;32</td></tr>
<tr class="memdesc:ga05f5d709605c6317c97e4974bec3402a"><td class="mdescLeft">&#160;</td><td class="mdescRight">Size of the circular transmit buffer, must be power of 2. <a href="#ga05f5d709605c6317c97e4974bec3402a">More...</a><br /></td></tr>
<tr class="separator:ga05f5d709605c6317c97e4974bec3402a"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gabcdb1041d763560cd8f8e722370dfd37"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="gabcdb1041d763560cd8f8e722370dfd37"></a>
#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__pfleury__uart.html#gabcdb1041d763560cd8f8e722370dfd37">UART_FRAME_ERROR</a>&#160;&#160;&#160;0x1000</td></tr>
<tr class="memdesc:gabcdb1041d763560cd8f8e722370dfd37"><td class="mdescLeft">&#160;</td><td class="mdescRight">Framing Error by UART. <br /></td></tr>
<tr class="separator:gabcdb1041d763560cd8f8e722370dfd37"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga3183177e3613d8785d8cc8516931beb6"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="ga3183177e3613d8785d8cc8516931beb6"></a>
#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__pfleury__uart.html#ga3183177e3613d8785d8cc8516931beb6">UART_OVERRUN_ERROR</a>&#160;&#160;&#160;0x0800</td></tr>
<tr class="memdesc:ga3183177e3613d8785d8cc8516931beb6"><td class="mdescLeft">&#160;</td><td class="mdescRight">Overrun condition by UART. <br /></td></tr>
<tr class="separator:ga3183177e3613d8785d8cc8516931beb6"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga946e3d317937e003d2057bf19e96dd1d"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="ga946e3d317937e003d2057bf19e96dd1d"></a>
#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__pfleury__uart.html#ga946e3d317937e003d2057bf19e96dd1d">UART_PARITY_ERROR</a>&#160;&#160;&#160;0x0400</td></tr>
<tr class="memdesc:ga946e3d317937e003d2057bf19e96dd1d"><td class="mdescLeft">&#160;</td><td class="mdescRight">Parity Error by UART. <br /></td></tr>
<tr class="separator:ga946e3d317937e003d2057bf19e96dd1d"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga94758f3dad6864703b7417d3e40f11df"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="ga94758f3dad6864703b7417d3e40f11df"></a>
#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__pfleury__uart.html#ga94758f3dad6864703b7417d3e40f11df">UART_BUFFER_OVERFLOW</a>&#160;&#160;&#160;0x0200</td></tr>
<tr class="memdesc:ga94758f3dad6864703b7417d3e40f11df"><td class="mdescLeft">&#160;</td><td class="mdescRight">receive ringbuffer overflow <br /></td></tr>
<tr class="separator:ga94758f3dad6864703b7417d3e40f11df"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga77ba544d423ff42d400220a05303f268"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="ga77ba544d423ff42d400220a05303f268"></a>
#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__pfleury__uart.html#ga77ba544d423ff42d400220a05303f268">UART_NO_DATA</a>&#160;&#160;&#160;0x0100</td></tr>
<tr class="memdesc:ga77ba544d423ff42d400220a05303f268"><td class="mdescLeft">&#160;</td><td class="mdescRight">no receive data available <br /></td></tr>
<tr class="separator:ga77ba544d423ff42d400220a05303f268"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gae9e143569df2285379bc55f9f5595bf9"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="gae9e143569df2285379bc55f9f5595bf9"></a>
#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__pfleury__uart.html#gae9e143569df2285379bc55f9f5595bf9">uart_puts_P</a>(__s)&#160;&#160;&#160;<a class="el" href="group__pfleury__uart.html#ga6d78b6744db6232f52b4616402036c2f">uart_puts_p</a>(PSTR(__s))</td></tr>
<tr class="memdesc:gae9e143569df2285379bc55f9f5595bf9"><td class="mdescLeft">&#160;</td><td class="mdescRight">Macro to automatically put a string constant into program memory. <br /></td></tr>
<tr class="separator:gae9e143569df2285379bc55f9f5595bf9"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gaabd7a5b0c15611ee9ecb2873cc9ee87a"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="gaabd7a5b0c15611ee9ecb2873cc9ee87a"></a>
#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__pfleury__uart.html#gaabd7a5b0c15611ee9ecb2873cc9ee87a">uart1_puts_P</a>(__s)&#160;&#160;&#160;<a class="el" href="group__pfleury__uart.html#ga1e8074d0a2d5922601c5db2f9777ba79">uart1_puts_p</a>(PSTR(__s))</td></tr>
<tr class="memdesc:gaabd7a5b0c15611ee9ecb2873cc9ee87a"><td class="mdescLeft">&#160;</td><td class="mdescRight">Macro to automatically put a string constant into program memory. <br /></td></tr>
<tr class="separator:gaabd7a5b0c15611ee9ecb2873cc9ee87a"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="func-members"></a>
Functions</h2></td></tr>
<tr class="memitem:gac19a76bb7d446125734a67f9f4b68991"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__pfleury__uart.html#gac19a76bb7d446125734a67f9f4b68991">uart_init</a> (unsigned int baudrate)</td></tr>
<tr class="memdesc:gac19a76bb7d446125734a67f9f4b68991"><td class="mdescLeft">&#160;</td><td class="mdescRight">Initialize UART and set baudrate. <a href="#gac19a76bb7d446125734a67f9f4b68991">More...</a><br /></td></tr>
<tr class="separator:gac19a76bb7d446125734a67f9f4b68991"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gaefaab30a8338ec46a6be35b99b1b4f09"><td class="memItemLeft" align="right" valign="top">unsigned int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__pfleury__uart.html#gaefaab30a8338ec46a6be35b99b1b4f09">uart_getc</a> (void)</td></tr>
<tr class="memdesc:gaefaab30a8338ec46a6be35b99b1b4f09"><td class="mdescLeft">&#160;</td><td class="mdescRight">Get received byte from ringbuffer. <a href="#gaefaab30a8338ec46a6be35b99b1b4f09">More...</a><br /></td></tr>
<tr class="separator:gaefaab30a8338ec46a6be35b99b1b4f09"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gad975221bc08b901e4c7ad69f9c9a97e2"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__pfleury__uart.html#gad975221bc08b901e4c7ad69f9c9a97e2">uart_putc</a> (unsigned char data)</td></tr>
<tr class="memdesc:gad975221bc08b901e4c7ad69f9c9a97e2"><td class="mdescLeft">&#160;</td><td class="mdescRight">Put byte to ringbuffer for transmitting via UART. <a href="#gad975221bc08b901e4c7ad69f9c9a97e2">More...</a><br /></td></tr>
<tr class="separator:gad975221bc08b901e4c7ad69f9c9a97e2"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gae52facc0a56086a365bb0018160d8d71"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__pfleury__uart.html#gae52facc0a56086a365bb0018160d8d71">uart_puts</a> (const char *s)</td></tr>
<tr class="memdesc:gae52facc0a56086a365bb0018160d8d71"><td class="mdescLeft">&#160;</td><td class="mdescRight">Put string to ringbuffer for transmitting via UART. <a href="#gae52facc0a56086a365bb0018160d8d71">More...</a><br /></td></tr>
<tr class="separator:gae52facc0a56086a365bb0018160d8d71"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga6d78b6744db6232f52b4616402036c2f"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__pfleury__uart.html#ga6d78b6744db6232f52b4616402036c2f">uart_puts_p</a> (const char *s)</td></tr>
<tr class="memdesc:ga6d78b6744db6232f52b4616402036c2f"><td class="mdescLeft">&#160;</td><td class="mdescRight">Put string from program memory to ringbuffer for transmitting via UART. <a href="#ga6d78b6744db6232f52b4616402036c2f">More...</a><br /></td></tr>
<tr class="separator:ga6d78b6744db6232f52b4616402036c2f"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga4db697cb5469fd70e794fa7df73a6d6a"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__pfleury__uart.html#ga4db697cb5469fd70e794fa7df73a6d6a">uart1_init</a> (unsigned int baudrate)</td></tr>
<tr class="memdesc:ga4db697cb5469fd70e794fa7df73a6d6a"><td class="mdescLeft">&#160;</td><td class="mdescRight">Initialize USART1 (only available on selected ATmegas) <a href="#ga4db697cb5469fd70e794fa7df73a6d6a">More...</a><br /></td></tr>
<tr class="separator:ga4db697cb5469fd70e794fa7df73a6d6a"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gaeb1405c641e5bc9b7224018f5e8d90de"><td class="memItemLeft" align="right" valign="top">unsigned int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__pfleury__uart.html#gaeb1405c641e5bc9b7224018f5e8d90de">uart1_getc</a> (void)</td></tr>
<tr class="memdesc:gaeb1405c641e5bc9b7224018f5e8d90de"><td class="mdescLeft">&#160;</td><td class="mdescRight">Get received byte of USART1 from ringbuffer. (only available on selected ATmega) <a href="#gaeb1405c641e5bc9b7224018f5e8d90de">More...</a><br /></td></tr>
<tr class="separator:gaeb1405c641e5bc9b7224018f5e8d90de"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gab465f689d197fadfbacc374fc9411154"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__pfleury__uart.html#gab465f689d197fadfbacc374fc9411154">uart1_putc</a> (unsigned char data)</td></tr>
<tr class="memdesc:gab465f689d197fadfbacc374fc9411154"><td class="mdescLeft">&#160;</td><td class="mdescRight">Put byte to ringbuffer for transmitting via USART1 (only available on selected ATmega) <a href="#gab465f689d197fadfbacc374fc9411154">More...</a><br /></td></tr>
<tr class="separator:gab465f689d197fadfbacc374fc9411154"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga5568f8f3913b218fd4d0346af78831b2"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__pfleury__uart.html#ga5568f8f3913b218fd4d0346af78831b2">uart1_puts</a> (const char *s)</td></tr>
<tr class="memdesc:ga5568f8f3913b218fd4d0346af78831b2"><td class="mdescLeft">&#160;</td><td class="mdescRight">Put string to ringbuffer for transmitting via USART1 (only available on selected ATmega) <a href="#ga5568f8f3913b218fd4d0346af78831b2">More...</a><br /></td></tr>
<tr class="separator:ga5568f8f3913b218fd4d0346af78831b2"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga1e8074d0a2d5922601c5db2f9777ba79"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__pfleury__uart.html#ga1e8074d0a2d5922601c5db2f9777ba79">uart1_puts_p</a> (const char *s)</td></tr>
<tr class="memdesc:ga1e8074d0a2d5922601c5db2f9777ba79"><td class="mdescLeft">&#160;</td><td class="mdescRight">Put string from program memory to ringbuffer for transmitting via USART1 (only available on selected ATmega) <a href="#ga1e8074d0a2d5922601c5db2f9777ba79">More...</a><br /></td></tr>
<tr class="separator:ga1e8074d0a2d5922601c5db2f9777ba79"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<h2 class="groupheader">Macro Definition Documentation</h2>
<a class="anchor" id="ga367ff7b5de225ed936a63239ad4adb0b"></a>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">#define UART_BAUD_SELECT</td>
<td>(</td>
<td class="paramtype">&#160;</td>
<td class="paramname">baudRate, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">&#160;</td>
<td class="paramname">xtalCpu&#160;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td>&#160;&#160;&#160;(((xtalCpu) + 8UL * (baudRate)) / (16UL * (baudRate)) -1UL)</td>
</tr>
</table>
</div><div class="memdoc">
<p>UART Baudrate Expression. </p>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramname">xtalCpu</td><td>system clock in Mhz, e.g. 4000000UL for 4Mhz </td></tr>
<tr><td class="paramname">baudRate</td><td>baudrate in bps, e.g. 1200, 2400, 9600 </td></tr>
</table>
</dd>
</dl>
</div>
</div>
<a class="anchor" id="ga1a02d45130520cb651ab313e69039382"></a>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">#define UART_BAUD_SELECT_DOUBLE_SPEED</td>
<td>(</td>
<td class="paramtype">&#160;</td>
<td class="paramname">baudRate, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">&#160;</td>
<td class="paramname">xtalCpu&#160;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td>&#160;&#160;&#160;( ((((xtalCpu) + 4UL * (baudRate)) / (8UL * (baudRate)) -1UL)) | 0x8000)</td>
</tr>
</table>
</div><div class="memdoc">
<p>UART Baudrate Expression for ATmega double speed mode. </p>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramname">xtalCpu</td><td>system clock in Mhz, e.g. 4000000UL for 4Mhz </td></tr>
<tr><td class="paramname">baudRate</td><td>baudrate in bps, e.g. 1200, 2400, 9600 </td></tr>
</table>
</dd>
</dl>
</div>
</div>
<a class="anchor" id="ga5bdd6772c246436bb14377095de79b31"></a>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">#define UART_RX_BUFFER_SIZE&#160;&#160;&#160;32</td>
</tr>
</table>
</div><div class="memdoc">
<p>Size of the circular receive buffer, must be power of 2. </p>
<p>You may need to adapt this constant to your target and your application by adding CDEFS += -DUART_RX_BUFFER_SIZE=nn to your Makefile. </p>
</div>
</div>
<a class="anchor" id="ga05f5d709605c6317c97e4974bec3402a"></a>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">#define UART_TX_BUFFER_SIZE&#160;&#160;&#160;32</td>
</tr>
</table>
</div><div class="memdoc">
<p>Size of the circular transmit buffer, must be power of 2. </p>
<p>You may need to adapt this constant to your target and your application by adding CDEFS += -DUART_TX_BUFFER_SIZE=nn to your Makefile. </p>
</div>
</div>
<h2 class="groupheader">Function Documentation</h2>
<a class="anchor" id="gac19a76bb7d446125734a67f9f4b68991"></a>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void uart_init </td>
<td>(</td>
<td class="paramtype">unsigned int&#160;</td>
<td class="paramname"><em>baudrate</em></td><td>)</td>
<td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Initialize UART and set baudrate. </p>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramname">baudrate</td><td>Specify baudrate using macro <a class="el" href="group__pfleury__uart.html#ga367ff7b5de225ed936a63239ad4adb0b" title="UART Baudrate Expression. ">UART_BAUD_SELECT()</a> </td></tr>
</table>
</dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>none </dd></dl>
</div>
</div>
<a class="anchor" id="gaefaab30a8338ec46a6be35b99b1b4f09"></a>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">unsigned int uart_getc </td>
<td>(</td>
<td class="paramtype">void&#160;</td>
<td class="paramname"></td><td>)</td>
<td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Get received byte from ringbuffer. </p>
<p>Returns in the lower byte the received character and in the higher byte the last receive error. UART_NO_DATA is returned when no data is available.</p>
<dl class="section return"><dt>Returns</dt><dd>lower byte: received byte from ringbuffer </dd>
<dd>
higher byte: last receive status<ul>
<li><b>0</b> successfully received data from UART</li>
<li><b>UART_NO_DATA</b> <br />
no receive data available</li>
<li><b>UART_BUFFER_OVERFLOW</b> <br />
Receive ringbuffer overflow. We are not reading the receive buffer fast enough, one or more received character have been dropped</li>
<li><b>UART_OVERRUN_ERROR</b> <br />
Overrun condition by UART. A character already present in the UART UDR register was not read by the interrupt handler before the next character arrived, one or more received characters have been dropped.</li>
<li><b>UART_FRAME_ERROR</b> <br />
Framing Error by UART </li>
</ul>
</dd></dl>
</div>
</div>
<a class="anchor" id="gad975221bc08b901e4c7ad69f9c9a97e2"></a>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void uart_putc </td>
<td>(</td>
<td class="paramtype">unsigned char&#160;</td>
<td class="paramname"><em>data</em></td><td>)</td>
<td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Put byte to ringbuffer for transmitting via UART. </p>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramname">data</td><td>byte to be transmitted </td></tr>
</table>
</dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>none </dd></dl>
</div>
</div>
<a class="anchor" id="gae52facc0a56086a365bb0018160d8d71"></a>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void uart_puts </td>
<td>(</td>
<td class="paramtype">const char *&#160;</td>
<td class="paramname"><em>s</em></td><td>)</td>
<td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Put string to ringbuffer for transmitting via UART. </p>
<p>The string is buffered by the uart library in a circular buffer and one character at a time is transmitted to the UART using interrupts. Blocks if it can not write the whole string into the circular buffer.</p>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramname">s</td><td>string to be transmitted </td></tr>
</table>
</dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>none </dd></dl>
</div>
</div>
<a class="anchor" id="ga6d78b6744db6232f52b4616402036c2f"></a>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void uart_puts_p </td>
<td>(</td>
<td class="paramtype">const char *&#160;</td>
<td class="paramname"><em>s</em></td><td>)</td>
<td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Put string from program memory to ringbuffer for transmitting via UART. </p>
<p>The string is buffered by the uart library in a circular buffer and one character at a time is transmitted to the UART using interrupts. Blocks if it can not write the whole string into the circular buffer.</p>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramname">s</td><td>program memory string to be transmitted </td></tr>
</table>
</dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>none </dd></dl>
<dl class="section see"><dt>See also</dt><dd><a class="el" href="group__pfleury__uart.html#gae9e143569df2285379bc55f9f5595bf9" title="Macro to automatically put a string constant into program memory. ">uart_puts_P</a> </dd></dl>
</div>
</div>
<a class="anchor" id="ga4db697cb5469fd70e794fa7df73a6d6a"></a>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void uart1_init </td>
<td>(</td>
<td class="paramtype">unsigned int&#160;</td>
<td class="paramname"><em>baudrate</em></td><td>)</td>
<td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Initialize USART1 (only available on selected ATmegas) </p>
<dl class="section see"><dt>See also</dt><dd><a class="el" href="group__pfleury__uart.html#gac19a76bb7d446125734a67f9f4b68991" title="Initialize UART and set baudrate. ">uart_init</a> </dd></dl>
</div>
</div>
<a class="anchor" id="gaeb1405c641e5bc9b7224018f5e8d90de"></a>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">unsigned int uart1_getc </td>
<td>(</td>
<td class="paramtype">void&#160;</td>
<td class="paramname"></td><td>)</td>
<td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Get received byte of USART1 from ringbuffer. (only available on selected ATmega) </p>
<dl class="section see"><dt>See also</dt><dd><a class="el" href="group__pfleury__uart.html#gaefaab30a8338ec46a6be35b99b1b4f09" title="Get received byte from ringbuffer. ">uart_getc</a> </dd></dl>
</div>
</div>
<a class="anchor" id="gab465f689d197fadfbacc374fc9411154"></a>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void uart1_putc </td>
<td>(</td>
<td class="paramtype">unsigned char&#160;</td>
<td class="paramname"><em>data</em></td><td>)</td>
<td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Put byte to ringbuffer for transmitting via USART1 (only available on selected ATmega) </p>
<dl class="section see"><dt>See also</dt><dd><a class="el" href="group__pfleury__uart.html#gad975221bc08b901e4c7ad69f9c9a97e2" title="Put byte to ringbuffer for transmitting via UART. ">uart_putc</a> </dd></dl>
</div>
</div>
<a class="anchor" id="ga5568f8f3913b218fd4d0346af78831b2"></a>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void uart1_puts </td>
<td>(</td>
<td class="paramtype">const char *&#160;</td>
<td class="paramname"><em>s</em></td><td>)</td>
<td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Put string to ringbuffer for transmitting via USART1 (only available on selected ATmega) </p>
<dl class="section see"><dt>See also</dt><dd><a class="el" href="group__pfleury__uart.html#gae52facc0a56086a365bb0018160d8d71" title="Put string to ringbuffer for transmitting via UART. ">uart_puts</a> </dd></dl>
</div>
</div>
<a class="anchor" id="ga1e8074d0a2d5922601c5db2f9777ba79"></a>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void uart1_puts_p </td>
<td>(</td>
<td class="paramtype">const char *&#160;</td>
<td class="paramname"><em>s</em></td><td>)</td>
<td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Put string from program memory to ringbuffer for transmitting via USART1 (only available on selected ATmega) </p>
<dl class="section see"><dt>See also</dt><dd><a class="el" href="group__pfleury__uart.html#ga6d78b6744db6232f52b4616402036c2f" title="Put string from program memory to ringbuffer for transmitting via UART. ">uart_puts_p</a> </dd></dl>
</div>
</div>
</div><!-- contents -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated on Sat Jan 31 2015 18:52:30 for AVR-GCC Libraries by &#160;<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/>
</a> 1.8.9.1
</small></address>
</body>
</html>