AVRTools
A Library for the AVR ATmega328 and ATmega2560 Microcontrollers
|
This namespace bundles a high-level buffered interface to the USART0 hardware. It provides logical cohesion and prevents namespace collisions. More...
Functions | |
void | start (unsigned long baudRate, UsartSerialConfiguration config=kSerial_8N1) |
Initialize USART0 for buffered, asynchronous serial communications using interrupts. More... | |
void | stop () |
Stops buffered serial communications using interrupts on USART0. More... | |
size_t | write (char c) |
Write a single byte to the transmit buffer. More... | |
size_t | write (const char *c) |
Write a null-terminated string to the transmit buffer. More... | |
size_t | write (const char *c, size_t n) |
Write a character array of given size to the transmit buffer. More... | |
size_t | write (const uint8_t *c, size_t n) |
Write a byte array of given size to the transmit buffer. More... | |
void | flush () |
Flush transmit buffer. More... | |
int | peek () |
Examine the next character in the receive buffer without removing it from the buffer. More... | |
int | read () |
Return the next character in the receive buffer, removing it from the buffer. More... | |
bool | available () |
Determine if there is data in the receive buffer.. More... | |
This namespace bundles a high-level buffered interface to the USART0 hardware. It provides logical cohesion and prevents namespace collisions.
bool USART0::available | ( | ) |
Determine if there is data in the receive buffer..
void USART0::flush | ( | ) |
Flush transmit buffer.
This function blocks until the transmit buffer is empty and the last byte has been transmitted by USART0. flush() doesn't actually do anything to make the transmit happen; it simply waits for the transmission to complete.
int USART0::peek | ( | ) |
Examine the next character in the receive buffer without removing it from the buffer.
int USART0::read | ( | ) |
Return the next character in the receive buffer, removing it from the buffer.
void USART0::start | ( | unsigned long | baudRate, |
UsartSerialConfiguration | config = kSerial_8N1 |
||
) |
Initialize USART0 for buffered, asynchronous serial communications using interrupts.
You must call this function before using any of the other USART0 functions.
baudRate
the baud rate for the communications, usually one of the following values: 300, 600, 1200, 2400, 4800, 9600, 14400, 19200, 28800, 38400, 57600, or 115200 (although other values below can be specified).config
sets the configuration in term of data bits, parity, and stop bits. If omitted, the default is 8 data bits, no parity, and 1 stop bit. void USART0::stop | ( | ) |
Stops buffered serial communications using interrupts on USART0.
After calling this function, Arduino pins 0 and 1 are released and available for use as ordinary digital pins.
If you want to use USART0 again for buffered, asynchronous serial communications, you must again call start().
size_t USART0::write | ( | char | c | ) |
Write a single byte to the transmit buffer.
This function attempts to queue the data into the transmit buffer. If there is room in the transmit buffer, the function returns immediately. If not, the function blocks waiting for room to become available in the transmit buffer.
The data is transmitted asynchronously via USART0-related interrupts.
c
the char (byte) to write into the transmit buffersize_t USART0::write | ( | const char * | c | ) |
Write a null-terminated string to the transmit buffer.
This function attempts to queue the data into the transmit buffer. If there is room in the transmit buffer, the function returns immediately. If not, the function blocks waiting for room to become available in the transmit buffer.
The data is transmitted asynchronously via USART0-related interrupts.
c
the null-terminated string to write into the transmit buffer.size_t USART0::write | ( | const char * | c, |
size_t | n | ||
) |
Write a character array of given size to the transmit buffer.
This function attempts to queue the data into the transmit buffer. If there is room in the transmit buffer, the function returns immediately. If not, the function blocks waiting for room to become available in the transmit buffer.
The data is transmitted asynchronously via USART0-related interrupts
c
the character array to write into the transmit buffer.n
the number of elements from the array to write into the transmit buffer.size_t USART0::write | ( | const uint8_t * | c, |
size_t | n | ||
) |
Write a byte array of given size to the transmit buffer.
This function attempts to queue the data into the transmit buffer. If there is room in the transmit buffer, the function returns immediately. If not, the function blocks waiting for room to become available in the transmit buffer.
The data is transmitted asynchronously via USART0-related interrupts
c
the byte array to write into the transmit buffer.n
the number of elements from the array to write into the transmit buffer.