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_CONFIG_MAP(XX)
 
#define XX(x)   Cfg##x = UART_##x,
 
#define XX(x)   static constexpr SerialConfig SERIAL_##x{SerialConfig::Cfg##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  SerialConfig { SerialConfig::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...
 
enum  AtState { eAtOK = 0, eAtRunning, eAtError }
 
using AtReceiveCallback = Delegate< bool(AtClient &atClient, Stream &source)>
 If the callback returns true then this means that we have finished successfully processing the command. More...
 
using AtCompleteCallback = Delegate< bool(AtClient &atClient, String &reply)>
 If the callback returns true then this means that we have finished successfully processing the command. More...
 
#define AT_REPLY_OK   "OK"
 Asynchronous AT command client. More...
 
#define AT_TIMEOUT   2000
 

Detailed Description

Hardware serial UARTs.

Macro Definition Documentation

◆ AT_REPLY_OK

#define AT_REPLY_OK   "OK"

Asynchronous AT command client.

◆ AT_TIMEOUT

#define AT_TIMEOUT   2000

◆ 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)
#define XX(x)
Definition: HardwareSerial.h:101

◆ 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")
#define XX(x)
Definition: HardwareSerial.h:101

◆ 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 (   x)    Cfg##x = UART_##x,

◆ XX [2/4]

#define XX (   x)    static constexpr SerialConfig SERIAL_##x{SerialConfig::Cfg##x};

◆ XX [3/4]

#define XX (   tag,
  comment 
)    tag,

◆ XX [4/4]

#define XX (   tag,
  comment 
)    static constexpr SerialStatus eSERS_##tag{SerialStatus::tag};

Typedef Documentation

◆ AtCompleteCallback

using AtCompleteCallback = Delegate<bool(AtClient& atClient, String& reply)>

If the callback returns true then this means that we have finished successfully processing the command.

◆ AtReceiveCallback

using AtReceiveCallback = Delegate<bool(AtClient& atClient, Stream& source)>

If the callback returns true then this means that we have finished successfully processing the command.

◆ 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

◆ AtState

enum AtState
Enumerator
eAtOK 
eAtRunning 
eAtError 

◆ SerialConfig

enum SerialConfig
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}
static

◆ SERIAL_RX_ONLY

constexpr SerialMode SERIAL_RX_ONLY {SerialMode::RxOnly}
static

◆ SERIAL_TX_ONLY

constexpr SerialMode SERIAL_TX_ONLY {SerialMode::TxOnly}
static