Serial Port
|
Class for avr hardware USART ports. More...
#include <SerialPort.h>
Public Member Functions | |
SerialPort () | |
int | available (void) |
void | begin (uint32_t baud, uint8_t options=SP_8_BIT_CHAR) |
void | clearRxError () |
void | end () |
void | flush () |
void | flushRx () |
void | flushTx () |
uint8_t | getRxError () |
int | peek (void) |
int | read () |
size_t | read (uint8_t *b, size_t n) |
size_t | write (const char *s) |
size_t | write (uint8_t b) |
size_t | write (const __FlashStringHelper *s) |
size_t | write (const uint8_t *b, size_t n) |
size_t | write_P (PGM_P b, size_t n) |
size_t | writeln (const char *s) |
size_t | writeln () |
size_t | writeln (const __FlashStringHelper *s) |
Class for avr hardware USART ports.
Definition at line 300 of file SerialPort.h.
SerialPort< PortNumber, RxBufSize, TxBufSize >::SerialPort | ( | ) | [inline] |
Constructor
Definition at line 304 of file SerialPort.h.
int SerialPort< PortNumber, RxBufSize, TxBufSize >::available | ( | void | ) | [inline] |
Definition at line 320 of file SerialPort.h.
void SerialPort< PortNumber, RxBufSize, TxBufSize >::begin | ( | uint32_t | baud, |
uint8_t | options = SP_8_BIT_CHAR |
||
) | [inline] |
Sets the data rate in bits per second (baud) for serial data transmission.
[in] | baud | Rate in bits per second (baud). |
[in] | options | constructed by a bitwise-inclusive OR of values from the following list. Choose one value for stop bit, parity, and character size. |
The default is SP_8_BIT_CHAR which results in one stop bit, no parity, and 8-bit characters.
Definition at line 349 of file SerialPort.h.
void SerialPort< PortNumber, RxBufSize, TxBufSize >::clearRxError | ( | ) | [inline] |
Clear RX error bits.
Definition at line 382 of file SerialPort.h.
void SerialPort< PortNumber, RxBufSize, TxBufSize >::end | ( | ) | [inline] |
Disables serial communication, allowing the RX and TX pins to be used for general input and output. To re-enable serial communication, call SerialPort::begin().
Definition at line 398 of file SerialPort.h.
void SerialPort< PortNumber, RxBufSize, TxBufSize >::flush | ( | ) | [inline] |
For Arduino 1.0 and greater call flushTx().
Definition at line 412 of file SerialPort.h.
void SerialPort< PortNumber, RxBufSize, TxBufSize >::flushRx | ( | ) | [inline] |
Discard any buffered incoming serial data.
Definition at line 417 of file SerialPort.h.
void SerialPort< PortNumber, RxBufSize, TxBufSize >::flushTx | ( | ) | [inline] |
Waits for the transmission of outgoing serial data to complete.
Definition at line 429 of file SerialPort.h.
uint8_t SerialPort< PortNumber, RxBufSize, TxBufSize >::getRxError | ( | ) | [inline] |
Definition at line 390 of file SerialPort.h.
int SerialPort< PortNumber, RxBufSize, TxBufSize >::peek | ( | void | ) | [inline] |
Definition at line 439 of file SerialPort.h.
int SerialPort< PortNumber, RxBufSize, TxBufSize >::read | ( | ) | [inline] |
Read incoming serial data.
Definition at line 450 of file SerialPort.h.
size_t SerialPort< PortNumber, RxBufSize, TxBufSize >::read | ( | uint8_t * | b, |
size_t | n | ||
) | [inline] |
Read incoming serial data. Stop when RX buffer is empty or n bytes have been read.
[in] | b | The location to receive the data. |
[in] | n | Maximum number of bytes to read. |
Definition at line 472 of file SerialPort.h.
size_t SerialPort< PortNumber, RxBufSize, TxBufSize >::write | ( | const __FlashStringHelper * | s | ) | [inline] |
Write a flash string to the serial port.
[in] | s | The string to be written. |
Definition at line 568 of file SerialPort.h.
size_t SerialPort< PortNumber, RxBufSize, TxBufSize >::write | ( | const char * | s | ) | [inline] |
Write a string to the serial port.
[in] | s | The string to be written. |
Definition at line 620 of file SerialPort.h.
size_t SerialPort< PortNumber, RxBufSize, TxBufSize >::write | ( | const uint8_t * | b, |
size_t | n | ||
) | [inline] |
Write binary data to the serial port.
[in] | b | Location of the bytes to be written. |
[in] | n | The number of bytes to write. |
Definition at line 594 of file SerialPort.h.
size_t SerialPort< PortNumber, RxBufSize, TxBufSize >::write | ( | uint8_t | b | ) | [inline] |
Write binary data to the serial port.
[in] | b | The byte to be written. |
Definition at line 498 of file SerialPort.h.
size_t SerialPort< PortNumber, RxBufSize, TxBufSize >::write_P | ( | PGM_P | b, |
size_t | n | ||
) | [inline] |
Write binary data from flash memory to the serial port.
[in] | b | Location of the bytes to be written. |
[in] | n | The number of bytes to write. |
Definition at line 542 of file SerialPort.h.
size_t SerialPort< PortNumber, RxBufSize, TxBufSize >::writeln | ( | const __FlashStringHelper * | s | ) | [inline] |
Write a flash string to the serial port followed by CR/LF.
[in] | s | The string to be written. |
Definition at line 581 of file SerialPort.h.
size_t SerialPort< PortNumber, RxBufSize, TxBufSize >::writeln | ( | const char * | s | ) | [inline] |
Write a string to the serial port followed by CR/LF.
[in] | s | The string to be written. |
Definition at line 529 of file SerialPort.h.
size_t SerialPort< PortNumber, RxBufSize, TxBufSize >::writeln | ( | ) | [inline] |