Hardware serial
Hardware serial UARTs. More...
Classes | |
class | HardwareSerial |
Hardware serial class. More... | |
Macros | |
#define | UART_ID_0 0 |
ID of UART 0. More... | |
#define | UART_ID_1 1 |
ID of UART 1. More... | |
#define | NUMBER_UARTS UART_COUNT |
Quantity of UARTs available. More... | |
#define | SERIAL_PIN_DEFAULT UART_PIN_DEFAULT |
#define | SERIAL_CONFIG_MAP(XX) |
#define | XX(x) Fmt##x = UART_##x, |
#define | XX(x) static constexpr SerialFormat SERIAL_##x{SerialFormat::Fmt##x}; |
#define | XX(tag, comment) tag, |
#define | XX(tag, comment) static constexpr SerialStatus eSERS_##tag{SerialStatus::tag}; |
#define | DEFAULT_RX_BUFFER_SIZE 256 |
#define | DEFAULT_TX_BUFFER_SIZE 0 |
#define | SERIAL_STATUS_MAP(XX) |
Typedefs | |
using | StreamDataReceivedDelegate = Delegate< void(Stream &source, char arrivedChar, uint16_t availableCharsCount)> |
Delegate callback type for serial data reception. More... | |
using | TransmitCompleteDelegate = Delegate< void(HardwareSerial &serial)> |
Delegate callback type for serial data transmit completion. More... | |
Enumerations | |
enum | SerialFormat { SerialFormat::XX } |
enum | SerialMode { SerialMode::Full = UART_FULL, SerialMode::RxOnly = UART_RX_ONLY, SerialMode::TxOnly = UART_TX_ONLY } |
values equivalent to uart_mode_t More... | |
enum | SerialStatus { SerialStatus::XX } |
Notification and error status bits. More... | |
Variables | |
static constexpr SerialMode | SERIAL_FULL {SerialMode::Full} |
static constexpr SerialMode | SERIAL_RX_ONLY {SerialMode::RxOnly} |
static constexpr SerialMode | SERIAL_TX_ONLY {SerialMode::TxOnly} |
HardwareSerial | Serial |
Global instance of serial port UART0. More... | |
Detailed Description
Hardware serial UARTs.
Macro Definition Documentation
◆ DEFAULT_RX_BUFFER_SIZE
#define DEFAULT_RX_BUFFER_SIZE 256 |
◆ DEFAULT_TX_BUFFER_SIZE
#define DEFAULT_TX_BUFFER_SIZE 0 |
◆ NUMBER_UARTS
#define NUMBER_UARTS UART_COUNT |
Quantity of UARTs available.
◆ SERIAL_CONFIG_MAP
#define SERIAL_CONFIG_MAP | ( | XX | ) |
◆ SERIAL_PIN_DEFAULT
#define SERIAL_PIN_DEFAULT UART_PIN_DEFAULT |
◆ SERIAL_STATUS_MAP
#define SERIAL_STATUS_MAP | ( | XX | ) |
Value:
XX(BreakDetected, "Break condition detected on receive line") \
XX(Overflow, "Receive buffer overflowed") \
XX(FramingError, "Receive framing error") \
XX(ParityError, "Parity check failed on received data")
◆ UART_ID_0
#define UART_ID_0 0 |
ID of UART 0.
◆ UART_ID_1
#define UART_ID_1 1 |
ID of UART 1.
◆ XX [1/4]
#define XX | ( | tag, | |
comment | |||
) | tag, |
◆ XX [2/4]
#define XX | ( | tag, | |
comment | |||
) | static constexpr SerialStatus eSERS_##tag{SerialStatus::tag}; |
◆ XX [3/4]
#define XX | ( | x | ) | Fmt##x = UART_##x, |
◆ XX [4/4]
#define XX | ( | x | ) | static constexpr SerialFormat SERIAL_##x{SerialFormat::Fmt##x}; |
Typedef Documentation
◆ StreamDataReceivedDelegate
using StreamDataReceivedDelegate = Delegate<void(Stream& source, char arrivedChar, uint16_t availableCharsCount)> |
Delegate callback type for serial data reception.
- Parameters
-
source Reference to serial stream arrivedChar Char received availableCharsCount Quantity of chars available stream in receive buffer
- Note
- Delegate constructor usage: (&YourClass::method, this)
This delegate is invoked when the serial receive buffer is full, or it times out. The arrivedChar indicates the last character received, which might be a '
' line ending character, for example.
If no receive buffer has been allocated, or it's not big enough to contain the full message, then this value will be incorrect as data is stored in the hardware FIFO until read out.
◆ TransmitCompleteDelegate
using TransmitCompleteDelegate = Delegate<void(HardwareSerial& serial)> |
Enumeration Type Documentation
◆ SerialFormat
|
strong |
◆ SerialMode
|
strong |
◆ SerialStatus
|
strong |
Variable Documentation
◆ Serial
HardwareSerial Serial |
Global instance of serial port UART0.
- Note
- Use Serial.function to access serial functions
- Example:
- Serial uses UART0, which is mapped to pins GPIO1 (TX) and GPIO3 (RX).
- Serial may be swapped to GPIO15 (TX) and GPIO13 (RX) by calling Serial.swap() after Serial.begin.
- Calling swap again maps UART0 back to GPIO1 and GPIO3.
◆ SERIAL_FULL
|
staticconstexpr |
◆ SERIAL_RX_ONLY
|
staticconstexpr |
◆ SERIAL_TX_ONLY
|
staticconstexpr |
bool begin(uint32_t baud=9600)
Initialise the serial port.
Definition: HardwareSerial.h:132