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)
Value:
XX(5N1) XX(6N1) XX(7N1) XX(8N1) XX(5N2) XX(6N2) XX(7N2) XX(8N2) XX(5E1) XX(6E1) XX(7E1) XX(8E1) \
XX(5E2) XX(6E2) XX(7E2) XX(8E2) XX(5O1) XX(6O1) XX(7O1) XX(8O1) XX(5O2) XX(6O2) XX(7O2) XX(8O2)

◆ 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
sourceReference to serial stream
arrivedCharChar received
availableCharsCountQuantity 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

Delegate callback type for serial data transmit completion.

Note
Invoked when the last byte has left the hardware FIFO

Enumeration Type Documentation

◆ SerialFormat

enum SerialFormat
strong
Enumerator
XX 

◆ SerialMode

enum SerialMode
strong

values equivalent to uart_mode_t

Enumerator
Full 
RxOnly 
TxOnly 

◆ SerialStatus

enum SerialStatus
strong

Notification and error status bits.

Enumerator
XX 

Variable Documentation

◆ Serial

Global instance of serial port UART0.

Note
Use Serial.function to access serial functions
Example:
Serial.begin(115200);
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

constexpr SerialMode SERIAL_FULL {SerialMode::Full}
staticconstexpr

◆ SERIAL_RX_ONLY

constexpr SerialMode SERIAL_RX_ONLY {SerialMode::RxOnly}
staticconstexpr

◆ SERIAL_TX_ONLY

constexpr SerialMode SERIAL_TX_ONLY {SerialMode::TxOnly}
staticconstexpr
bool begin(uint32_t baud=9600)
Initialise the serial port.
Definition: HardwareSerial.h:132
#define XX(x)
Definition: HardwareSerial.h:101
HardwareSerial Serial
Global instance of serial port UART0.