<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
		<id>http://www.ethernut.de/nutwiki/index.php?action=history&amp;feed=atom&amp;title=Uart.c</id>
		<title>Uart.c - Revision history</title>
		<link rel="self" type="application/atom+xml" href="http://www.ethernut.de/nutwiki/index.php?action=history&amp;feed=atom&amp;title=Uart.c"/>
		<link rel="alternate" type="text/html" href="http://www.ethernut.de/nutwiki/index.php?title=Uart.c&amp;action=history"/>
		<updated>2026-04-25T00:40:04Z</updated>
		<subtitle>Revision history for this page on the wiki</subtitle>
		<generator>MediaWiki 1.26.2</generator>

	<entry>
		<id>http://www.ethernut.de/nutwiki/index.php?title=Uart.c&amp;diff=284&amp;oldid=prev</id>
		<title>Harald: 1 revision imported</title>
		<link rel="alternate" type="text/html" href="http://www.ethernut.de/nutwiki/index.php?title=Uart.c&amp;diff=284&amp;oldid=prev"/>
				<updated>2016-10-27T16:03:02Z</updated>
		
		<summary type="html">&lt;p&gt;1 revision imported&lt;/p&gt;
&lt;table class='diff diff-contentalign-left'&gt;
				&lt;tr style='vertical-align: top;' lang='en'&gt;
				&lt;td colspan='1' style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan='1' style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;Revision as of 16:03, 27 October 2016&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan='2' style='text-align: center;' lang='en'&gt;&lt;div class=&quot;mw-diff-empty&quot;&gt;(No difference)&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;</summary>
		<author><name>Harald</name></author>	</entry>

	<entry>
		<id>http://www.ethernut.de/nutwiki/index.php?title=Uart.c&amp;diff=283&amp;oldid=prev</id>
		<title>Harald at 18:08, 2 October 2007</title>
		<link rel="alternate" type="text/html" href="http://www.ethernut.de/nutwiki/index.php?title=Uart.c&amp;diff=283&amp;oldid=prev"/>
				<updated>2007-10-02T18:08:47Z</updated>
		
		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;Dieses Beispiel zeigt die Nutzung der seriellen Schnittstelle. Bei dieses Diesem Beispiel werden Fließkommeberechnungen vorgenommen. Deswgen muss nutlibcrtf gelinkt werden.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
#include &amp;lt;cfg/crt.h&amp;gt;    /* Floating point configuration. */&lt;br /&gt;
&lt;br /&gt;
#include &amp;lt;string.h&amp;gt;&lt;br /&gt;
#include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;
#include &amp;lt;io.h&amp;gt;&lt;br /&gt;
&lt;br /&gt;
#include &amp;lt;dev/board.h&amp;gt;&lt;br /&gt;
#include &amp;lt;sys/timer.h&amp;gt;&lt;br /&gt;
&lt;br /&gt;
static char *banner = &amp;quot;\nNut/OS UART Sample\n&amp;quot;;&lt;br /&gt;
static prog_char presskey_P[] = &amp;quot;Press any key...&amp;quot;;&lt;br /&gt;
static prog_char pgm_ptr[] = &amp;quot;\nHello stranger!\n&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
static char inbuf[128];&lt;br /&gt;
&lt;br /&gt;
/*&lt;br /&gt;
 * UART sample.&lt;br /&gt;
 *&lt;br /&gt;
 * Some functions do not work with ICCAVR.&lt;br /&gt;
 */&lt;br /&gt;
int main(void)&lt;br /&gt;
{&lt;br /&gt;
    int got;&lt;br /&gt;
    int i;&lt;br /&gt;
    char *cp;&lt;br /&gt;
    u_long baud = 115200;&lt;br /&gt;
    FILE *uart;&lt;br /&gt;
#ifdef STDIO_FLOATING_POINT&lt;br /&gt;
    float dval = 0.0;&lt;br /&gt;
#endif&lt;br /&gt;
&lt;br /&gt;
    /*&lt;br /&gt;
     * Each device must be registered. We do this by referencing the &lt;br /&gt;
     * device structure of the driver. The advantage is, that only &lt;br /&gt;
     * those device drivers are included in our flash code, which we &lt;br /&gt;
     * really need.&lt;br /&gt;
     *&lt;br /&gt;
     * The uart0 device is the first one on the ATmega chip. So it &lt;br /&gt;
     * has no configurable base address or interrupt and we set both &lt;br /&gt;
     * parameters to zero.&lt;br /&gt;
     */&lt;br /&gt;
    NutRegisterDevice(&amp;amp;DEV_UART, 0, 0);&lt;br /&gt;
&lt;br /&gt;
    /*&lt;br /&gt;
     * Now, as the device is registered, we can open it. The fopen()&lt;br /&gt;
     * function returns a pointer to a FILE structure, which we use &lt;br /&gt;
     * for subsequent reading and writing.&lt;br /&gt;
     */&lt;br /&gt;
    uart = fopen(DEV_UART_NAME, &amp;quot;r+&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
    /*&lt;br /&gt;
     * Before doing the first read or write, we set the baudrate.&lt;br /&gt;
     * This low level function doesn't know about FILE structures&lt;br /&gt;
     * and we use _fileno() to get the low level file descriptor&lt;br /&gt;
     * of the stream.&lt;br /&gt;
     *&lt;br /&gt;
     * The short sleep allows the UART to settle after the baudrate&lt;br /&gt;
     * change.&lt;br /&gt;
     */&lt;br /&gt;
    _ioctl(_fileno(uart), UART_SETSPEED, &amp;amp;baud);&lt;br /&gt;
&lt;br /&gt;
    /*&lt;br /&gt;
     * Stream devices can use low level read and write functions. &lt;br /&gt;
     * Writing program space data is supported too.&lt;br /&gt;
     */&lt;br /&gt;
    _write(_fileno(uart), banner, strlen(banner));&lt;br /&gt;
    {&lt;br /&gt;
        _write_P(_fileno(uart), presskey_P, sizeof(presskey_P));&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    /*&lt;br /&gt;
     * Stream devices do buffered I/O. That means, nothing will be &lt;br /&gt;
     * passed to the hardware device until either the output buffer &lt;br /&gt;
     * is full or we do a flush. With stream I/O we typically use&lt;br /&gt;
     * fflush(), but low level writing a null pointer will also flush &lt;br /&gt;
     * the output buffer.&lt;br /&gt;
     */&lt;br /&gt;
    _write(_fileno(uart), 0, 0);&lt;br /&gt;
&lt;br /&gt;
    /*&lt;br /&gt;
     * The low level function read() will grab all available bytes &lt;br /&gt;
     * from the input buffer. If the buffer is empty, the call will&lt;br /&gt;
     * block until something is available for reading.&lt;br /&gt;
     */&lt;br /&gt;
    got = _read(_fileno(uart), inbuf, sizeof(inbuf));&lt;br /&gt;
    _write(_fileno(uart), inbuf, got);&lt;br /&gt;
&lt;br /&gt;
    /*&lt;br /&gt;
     * Nut/OS never expects a thread to return. So we enter an &lt;br /&gt;
     * endless loop here.&lt;br /&gt;
     */&lt;br /&gt;
    for (i = 0;; i++) {&lt;br /&gt;
        /*&lt;br /&gt;
         * A bit more advanced input routine is able to read a string &lt;br /&gt;
         * up to and including the first newline character or until a&lt;br /&gt;
         * specified maximum number of characters, whichever comes first.&lt;br /&gt;
         */&lt;br /&gt;
        fputs(&amp;quot;\nEnter your name: &amp;quot;, uart);&lt;br /&gt;
        fflush(uart);&lt;br /&gt;
        fgets(inbuf, sizeof(inbuf), uart);&lt;br /&gt;
&lt;br /&gt;
        /*&lt;br /&gt;
         * Chop off trailing linefeed.&lt;br /&gt;
         */&lt;br /&gt;
        cp = strchr(inbuf, '\n');&lt;br /&gt;
        if (cp)&lt;br /&gt;
            *cp = 0;&lt;br /&gt;
&lt;br /&gt;
        /*&lt;br /&gt;
         * Streams support formatted output as well as printing strings &lt;br /&gt;
         * from program space.&lt;br /&gt;
         */&lt;br /&gt;
        if (inbuf[0])&lt;br /&gt;
            fprintf(uart, &amp;quot;\nHello %s!\n&amp;quot;, inbuf);&lt;br /&gt;
        else {&lt;br /&gt;
            fputs_P(pgm_ptr, uart);&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
        /*&lt;br /&gt;
         * Just to demonstrate formatted floating point output.&lt;br /&gt;
         * In order to use this, we need to link the application&lt;br /&gt;
         * with nutcrtf instead of nutcrt for pure integer.&lt;br /&gt;
         */&lt;br /&gt;
#ifdef STDIO_FLOATING_POINT&lt;br /&gt;
        dval += 1.0125;&lt;br /&gt;
        fprintf(uart, &amp;quot;FP %f\n&amp;quot;, dval);&lt;br /&gt;
#endif&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
uart.c [[Copyright]] by egnite Software GmbH&lt;/div&gt;</summary>
		<author><name>Harald</name></author>	</entry>

	</feed>