HardwareSerial.h
Go to the documentation of this file.
46 using StreamDataReceivedDelegate = Delegate<void(Stream& source, char arrivedChar, uint16_t availableCharsCount)>;
55 XX(5N1) XX(6N1) XX(7N1) XX(8N1) XX(5N2) XX(6N2) XX(7N2) XX(8N2) XX(5E1) XX(6E1) XX(7E1) XX(8E1) \
175 bool begin(uint32_t baud, SerialFormat format, SerialMode mode, uint8_t txPin, uint8_t rxPin = SERIAL_PIN_DEFAULT);
bool begin(uint32_t baud, SerialFormat format)
Initialise and set its configuration.
Definition: HardwareSerial.h:146
int peek() override
Read a character from serial port without removing from input buffer.
Definition: HardwareSerial.h:295
void systemDebugOutput(bool enabled)
Configure serial port for system debug output and redirect output from debugf.
bool onDataReceived(StreamDataReceivedDelegate dataReceivedDelegate)
Set handler for received data.
Definition: HardwareSerial.h:350
void clear(SerialMode mode=SERIAL_FULL)
Clear the serial port transmit/receive buffers.
Definition: HardwareSerial.h:304
void commandProcessing(bool)
Configure serial port for command processing.
Definition: HardwareSerial.h:342
bool isTxEnabled()
Checks if the current UART can transmit(print) information.
Definition: HardwareSerial.h:381
int available() override
Get quantity characters available from serial input.
Definition: HardwareSerial.h:255
bool isFinished() override
Check if all data has been read.
Definition: HardwareSerial.h:286
bool begin(uint32_t baud, SerialFormat format, SerialMode mode, uint8_t txPin, uint8_t rxPin=SERIAL_PIN_DEFAULT)
Initialise, set its configuration and mode.
smg_uart_t * getUart()
Returns a pointer to the internal uart object. Use with care.
Definition: HardwareSerial.h:436
void setTx(uint8_t tx_pin)
Toggle between use of GPIO1 and GPIO2 as TX on UART 0.
Definition: HardwareSerial.h:235
HardwareSerial(int uartPort)
Create instance of a hardware serial port object.
Definition: HardwareSerial.h:113
void swap(uint8_t tx_pin)
Toggle between use of GPIO13/GPIO15 or GPIO3/GPIO(1/2) as RX and TX.
Definition: HardwareSerial.h:222
uint32_t setBaudRate(uint32_t baudrate)
Attempt to set the requested baud rate.
Definition: HardwareSerial.h:409
void swap()
Toggle between use of GPIO13/GPIO15 or GPIO3/GPIO(1/2) as RX and TX.
Definition: HardwareSerial.h:213
int read() override
Read a character from serial port.
Definition: HardwareSerial.h:264
int indexOf(char c) override
Returns the location of the searched character.
Definition: HardwareSerial.h:427
bool isRxEnabled()
Checks if the current UART can receive information.
Definition: HardwareSerial.h:390
uint16_t readMemoryBlock(char *buf, int max_len) override
Read a block of characters from serial port.
Definition: HardwareSerial.h:276
bool begin(uint32_t baud=9600)
Initialise the serial port.
Definition: HardwareSerial.h:132
bool begin(uint32_t baud, SerialFormat format, SerialMode mode)
Initialise, set its configuration and mode.
Definition: HardwareSerial.h:161
void setTxWait(bool wait)
Governs write behaviour when UART transmit buffers are full.
Definition: HardwareSerial.h:202
bool onTransmitComplete(TransmitCompleteDelegate transmitCompleteDelegate)
Set handler for received data.
Definition: HardwareSerial.h:360
void setUartCallback(smg_uart_callback_t callback, void *param=nullptr)
Set callback ISR for received data.
Definition: HardwareSerial.h:372
void flush() override
Flush all pending data to the serial port.
Definition: HardwareSerial.h:312
size_t write(const uint8_t *buffer, size_t size) override
write multiple characters to serial port
Definition: HardwareSerial.h:324
uint32_t baudRate()
Get the current baud rate.
Definition: HardwareSerial.h:399
void pins(uint8_t tx, uint8_t rx)
Sets the transmission and receiving PINS.
Definition: HardwareSerial.h:247
XX(x)
XX(tag, comment)
@ TxOnly
@ RxOnly
@ Full
smg_uart_mode_t
values for mode argument of uart_init
Definition: Components/arch_driver/src/include/driver/uart.h:165
int smg_uart_peek_char(smg_uart_t *uart)
see what the next character in the rx buffer is
bool smg_uart_tx_enabled(smg_uart_t *uart)
Definition: Components/arch_driver/src/include/driver/uart.h:360
static void smg_uart_set_options(smg_uart_t *uart, uart_options_t options)
Set option flags.
Definition: Components/arch_driver/src/include/driver/uart.h:332
bool smg_uart_set_tx(smg_uart_t *uart, int tx_pin)
uint32_t smg_uart_set_baudrate(smg_uart_t *uart, uint32_t baud_rate)
set UART baud rate
void smg_uart_flush(smg_uart_t *uart, smg_uart_mode_t mode=UART_FULL)
discard any buffered data and reset hardware FIFOs
#define UART_NO
No UART specified.
Definition: Components/arch_driver/src/include/driver/uart.h:53
void smg_uart_wait_tx_empty(smg_uart_t *uart)
void(* smg_uart_callback_t)(smg_uart_t *uart, uint32_t status)
callback invoked directly from ISR
Definition: Components/arch_driver/src/include/driver/uart.h:197
uint32_t smg_uart_get_baudrate(smg_uart_t *uart)
get the actual baud rate in use
bool smg_uart_set_pins(smg_uart_t *uart, int tx_pin, int rx_pin)
int smg_uart_rx_find(smg_uart_t *uart, char c)
static int smg_uart_read_char(smg_uart_t *uart)
read a received character
Definition: Components/arch_driver/src/include/driver/uart.h:425
size_t smg_uart_rx_available(smg_uart_t *uart)
determine available data which can be read
void smg_uart_set_callback(smg_uart_t *uart, smg_uart_callback_t callback, void *param)
Set callback handler for serial port.
bool smg_uart_rx_enabled(smg_uart_t *uart)
Definition: Components/arch_driver/src/include/driver/uart.h:365
void smg_uart_swap(smg_uart_t *uart, int tx_pin)
size_t smg_uart_write(smg_uart_t *uart, const void *buffer, size_t size)
write a block of data
uint8_t uart_options_t
Definition: Components/arch_driver/src/include/driver/uart.h:171
@ UART_TX_ONLY
Transmit only.
Definition: Components/arch_driver/src/include/driver/uart.h:168
@ UART_FULL
Both receive and transmit - will revert to TX only if RX not supported.
Definition: Components/arch_driver/src/include/driver/uart.h:166
@ UART_RX_ONLY
Receive only.
Definition: Components/arch_driver/src/include/driver/uart.h:167
@ UART_OPT_TXWAIT
If buffers are full then uart_write() will wait for free space.
Definition: Components/arch_driver/src/include/driver/uart.h:177
Definition: Components/arch_driver/src/include/driver/uart.h:237
1.9.1