AVRTools
A Library for the AVR ATmega328 and ATmega2560 Microcontrollers
|
This file provides functions that provide a minimalist interface to USART0 available on the Arduino Uno (ATmega328) and Arduino Mega (ATmega2560). More...
Go to the source code of this file.
Functions | |
void | initUSART0 (unsigned long baudRate) |
Initialize USART0 for serial receive and transmit. More... | |
void | transmitUSART0 (unsigned char data) |
Transmit a single byte on USART0. More... | |
void | transmitUSART0 (const char *data) |
Transmit a null-terminated string on USART0. More... | |
unsigned char | receiveUSART0 () |
Receive a byte on USART0. More... | |
void | releaseUSART0 () |
Release USART0, making pins 0 and 1 again available for non-USART use. More... | |
This file provides functions that provide a minimalist interface to USART0 available on the Arduino Uno (ATmega328) and Arduino Mega (ATmega2560).
These functions are minimalist in the following sense:
To use these functions, include USART0Minimal.h in your source code and link against USART0Minimal.cpp.
For a more advanced USART0 interface, consider using either the USART0 or Serial0 interfaces. Both of these are available by including USART0.h instead of USART0Minimal.h.
void initUSART0 | ( | unsigned long | baudRate | ) |
Initialize USART0 for serial receive and transmit.
USART0 is tied to pins 0 (RX) and 1 (TX) on both Arduino Uno (ATmega328 pins PD0, PD1) and Arduino Mega (ATmega2560 pins PE0, PE1).
Communications are configured for 8 data bits, no parity, and 1 stop bit.
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). unsigned char receiveUSART0 | ( | ) |
Receive a byte on USART0.
You must first initialize USART0 by calling initUSART0().
This function blocks until the USART receives a byte.
void releaseUSART0 | ( | ) |
Release USART0, making pins 0 and 1 again available for non-USART use.
After calling this function, you cannot read or write to the USART unless you first call initUSART0().
void transmitUSART0 | ( | unsigned char | data | ) |
Transmit a single byte on USART0.
You must first initialize USART0 by calling initUSART0().
This function blocks until the USART becomes available and the byte can be transmitted.
data
the byte to be transmitted. void transmitUSART0 | ( | const char * | data | ) |
Transmit a null-terminated string on USART0.
You must first initialize USART0 by calling initUSART0().
This function blocks until the USART becomes available and all the bytes can be transmitted.
data
the null-terminated string to be transmitted.