NEW: Learning electronics? Ask your questions on the new Electronics Questions & Answers site hosted by CircuitLab.
Microcontroller Programming » What's a stream (ala UART)?
February 29, 2012 by jeffspc88mx |
I understand
but why would I want to use
?? What's the stream anyway? Do I have to use it? Or can I just call uart_write? |
---|---|
March 01, 2012 by hevans (NerdKits Staff) |
You can certainly just use uart_write if you are writing out simple strings. The function uart_putchar is there to allow us to use our own uart functions as a stream in C. You are not meant to use it directly. A stream is a special structure in C that several of the built in io functions use to write to. It is basically an abstraction that lets us treat things you can write characters to in the same way. The most useful thing in our case is that by setting it up as a stream you can then use the printf family of functions to write to the uart, and you can take advantage of format strings. Humberto |
Please log in to post a reply.
Did you know that two resistors can be used to make a voltage divider? Learn more...
|