AVRTools
A Library for the AVR ATmega328 and ATmega2560 Microcontrollers
|
This file provides functions that provide a minimalist interface to USART1 available on the Arduino Mega (ATmega2560). More...
Go to the source code of this file.
Functions | |
void | initUSART1 (unsigned long baudRate) |
Initialize USART1 for serial receive and transmit. More... | |
void | transmitUSART1 (unsigned char data) |
Transmit a single byte on USART1. More... | |
void | transmitUSART1 (const char *data) |
Transmit a null-terminated string on USART1. More... | |
unsigned char | receiveUSART1 () |
Receive a byte on USART1. More... | |
void | releaseUSART1 () |
Release USART1, making pins 0 and 1 again available for non-USART use. More... | |
This file provides functions that provide a minimalist interface to USART1 available on the Arduino Mega (ATmega2560).
These functions are minimalist in the following sense:
To use these functions, include USART1Minimal.h in your source code and link against USART1Minimal.cpp.
For a more advanced USART1 interface, consider using either the USART1 or Serial1 interfaces. Both of these are available by including USART1.h instead of USART1Minimal.h.
void initUSART1 | ( | unsigned long | baudRate | ) |
Initialize USART1 for serial receive and transmit.
USART1 is tied to pins 18 (TX) and 19 (RX) on Arduino Mega (ATmega2560 pins PD3, PD2).
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 receiveUSART1 | ( | ) |
Receive a byte on USART1.
You must first initialize USART1 by calling initUSART1().
This function blocks until the USART receives a byte.
void releaseUSART1 | ( | ) |
Release USART1, 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 initUSART1().
void transmitUSART1 | ( | unsigned char | data | ) |
Transmit a single byte on USART1.
You must first initialize USART1 by calling initUSART1().
This function blocks until the USART becomes available and the byte can be transmitted.
data
the byte to be transmitted.void transmitUSART1 | ( | const char * | data | ) |
Transmit a null-terminated string on USART1.
You must first initialize USART1 by calling initUSART1().
This function blocks until the USART becomes available and all the bytes can be transmitted.
data
the null-terminated string to be transmitted.