Components/arch_driver/src/include/driver/uart.h
Go to the documentation of this file.
28 * For uart_write_xxx functions, if there is no space in the tx FIFO it will return a short count. It will not wait.
30 * Code is now C++ only; reference to this header has been removed from esp_systemapi.h uart structure should be
100 static inline constexpr uint8_t SMG_UART_FORMAT(smg_uart_bits_t databits, smg_uart_stop_bits_t stopbits,
103 return (databits << UART_NB_BIT_SHIFT) | (stopbits << UART_NB_STOP_BIT_SHIFT) | (parity << UART_PARITY_SHIFT);
169 };
265 smg_uart_t* smg_uart_init(uint8_t uart_nr, uint32_t baudrate, smg_uart_format_t format, smg_uart_mode_t mode,
bool smg_uart_realloc_buffer(SerialBuffer *&buffer, size_t new_size)
smg_uart_notify_code_t
Indicates notification, parameters refer to uart_notify_info_t structure.
Definition: Components/arch_driver/src/include/driver/uart.h:205
smg_uart_mode_t
values for mode argument of uart_init
Definition: Components/arch_driver/src/include/driver/uart.h:165
static constexpr uint8_t SMG_UART_FORMAT(smg_uart_bits_t databits, smg_uart_stop_bits_t stopbits, smg_uart_parity_t parity)
Definition: Components/arch_driver/src/include/driver/uart.h:100
int smg_uart_peek_char(smg_uart_t *uart)
see what the next character in the rx buffer is
smg_uart_t * smg_uart_get_uart(uint8_t uart_nr)
Get the uart structure for the given number.
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)
void smg_uart_set_format(smg_uart_t *uart, smg_uart_format_t format)
Set the UART data format.
uint32_t smg_uart_set_baudrate_reg(int uart_nr, uint32_t baud_rate)
set UART baud rate, given the UART number
void smg_uart_uninit(smg_uart_t *uart)
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
static size_t smg_uart_write_char(smg_uart_t *uart, char c)
queue a single character for output
Definition: Components/arch_driver/src/include/driver/uart.h:408
void smg_uart_set_debug(int uart_nr)
static uart_options_t smg_uart_get_options(smg_uart_t *uart)
Definition: Components/arch_driver/src/include/driver/uart.h:351
void smg_uart_stop_isr(smg_uart_t *uart)
disable interrupts for a UART
Definition: Components/arch_driver/src/include/driver/uart.h:492
void(*)(smg_uart_t *uart, smg_uart_notify_code_t code) smg_uart_notify_callback_t
Port notification callback function type.
Definition: Components/arch_driver/src/include/driver/uart.h:226
size_t smg_uart_tx_buffer_size(smg_uart_t *uart)
smg_uart_stop_bits_t
Number of UART stop bits.
Definition: Components/arch_driver/src/include/driver/uart.h:84
smg_uart_format_settings_t
Definition: Components/arch_driver/src/include/driver/uart.h:91
void smg_uart_wait_tx_empty(smg_uart_t *uart)
smg_uart_option_bits_t
bit values for options argument of uart_init
Definition: Components/arch_driver/src/include/driver/uart.h:176
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
size_t smg_uart_resize_rx_buffer(smg_uart_t *uart, size_t new_size)
uint8_t smg_uart_disable_interrupts()
disable interrupts and return current interrupt state
uint32_t smg_uart_get_baudrate(smg_uart_t *uart)
get the actual baud rate in use
bool smg_uart_intr_config(smg_uart_t *uart, const smg_uart_intr_config_t *config)
Configure interrupt thresholds.
smg_uart_parity_t
UART parity setting.
Definition: Components/arch_driver/src/include/driver/uart.h:75
size_t smg_uart_rx_buffer_size(smg_uart_t *uart)
void smg_uart_restore_interrupts()
re-enable interrupts after calling uart_disable_interrupts()
smg_uart_bits_t
Number of UART data bits.
Definition: Components/arch_driver/src/include/driver/uart.h:61
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)
size_t smg_uart_resize_tx_buffer(smg_uart_t *uart, size_t new_size)
int smg_uart_get_debug()
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
int smg_uart_get_nr(smg_uart_t *uart)
Definition: Components/arch_driver/src/include/driver/uart.h:301
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
int smg_uart_peek_last_char(smg_uart_t *uart)
fetch last character read out of FIFO
void smg_uart_swap(smg_uart_t *uart, int tx_pin)
smg_uart_t * smg_uart_init(uint8_t uart_nr, uint32_t baudrate, smg_uart_format_t format, smg_uart_mode_t mode, uint8_t tx_pin, size_t rx_size, size_t tx_size=0)
void smg_uart_set_break(smg_uart_t *uart, bool state)
Set or clear a break condition on the TX line.
void * smg_uart_get_callback_param(smg_uart_t *uart)
Get the callback parameter specified by uart_set_callback()
Definition: Components/arch_driver/src/include/driver/uart.h:323
bool smg_uart_set_notify(unsigned uart_nr, smg_uart_notify_callback_t callback)
Set the notification callback function.
smg_uart_format_t
Options for config argument of uart_init.
Definition: Components/arch_driver/src/include/driver/uart.h:123
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
smg_uart_t * smg_uart_init_ex(const smg_uart_config_t &cfg)
@ UART_STATUS_FRM_ERR
Definition: Components/arch_driver/src/include/driver/uart.h:158
@ UART_STATUS_PARITY_ERR
Definition: Components/arch_driver/src/include/driver/uart.h:159
@ UART_STATUS_BRK_DET
Definition: Components/arch_driver/src/include/driver/uart.h:154
@ UART_STATUS_TXFIFO_EMPTY
Definition: Components/arch_driver/src/include/driver/uart.h:160
@ UART_STATUS_RXFIFO_OVF
Definition: Components/arch_driver/src/include/driver/uart.h:157
@ UART_STATUS_DSR_CHG
Definition: Components/arch_driver/src/include/driver/uart.h:156
@ UART_STATUS_CTS_CHG
Definition: Components/arch_driver/src/include/driver/uart.h:155
@ UART_STATUS_RXFIFO_FULL
Definition: Components/arch_driver/src/include/driver/uart.h:161
@ UART_STATUS_RXFIFO_TOUT
Definition: Components/arch_driver/src/include/driver/uart.h:153
@ UART_STATUS_TX_DONE
All data transmitted (ESP32 only)
Definition: Components/arch_driver/src/include/driver/uart.h:152
@ UART_NOTIFY_BEFORE_READ
Called before data is read from rx buffer.
Definition: Components/arch_driver/src/include/driver/uart.h:216
@ UART_NOTIFY_WAIT_TX
Called to ensure all buffered data is output.
Definition: Components/arch_driver/src/include/driver/uart.h:219
@ UART_NOTIFY_AFTER_WRITE
Called after data has been written into tx buffer.
Definition: Components/arch_driver/src/include/driver/uart.h:213
@ UART_NOTIFY_AFTER_OPEN
Called when uart has been initialised successfully.
Definition: Components/arch_driver/src/include/driver/uart.h:207
@ UART_NOTIFY_BEFORE_CLOSE
Called immediately before uart is closed and destroyed.
Definition: Components/arch_driver/src/include/driver/uart.h:210
@ 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_NB_STOP_BIT_2
Definition: Components/arch_driver/src/include/driver/uart.h:88
@ UART_NB_STOP_BIT_1
Definition: Components/arch_driver/src/include/driver/uart.h:86
@ UART_NB_STOP_BIT_15
Definition: Components/arch_driver/src/include/driver/uart.h:87
@ UART_NB_STOP_BIT_0
Definition: Components/arch_driver/src/include/driver/uart.h:85
@ UART_NB_STOP_BIT_MASK
Definition: Components/arch_driver/src/include/driver/uart.h:96
@ UART_NB_STOP_BIT_SHIFT
Definition: Components/arch_driver/src/include/driver/uart.h:97
@ 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
@ UART_OPT_CALLBACK_RAW
ISR invokes user callback function with no pre-processing.
Definition: Components/arch_driver/src/include/driver/uart.h:178
Format format
Definition: Components/arch_driver/src/include/driver/uart.h:252
size_t rx_size
Definition: Components/arch_driver/src/include/driver/uart.h:260
uint32_t baudrate
Requested baudrate; actual baudrate may differ.
Definition: Components/arch_driver/src/include/driver/uart.h:258
uint8_t uart_nr
Definition: Components/arch_driver/src/include/driver/uart.h:253
size_t tx_size
Definition: Components/arch_driver/src/include/driver/uart.h:261
uint8_t tx_pin
Specify 2 for alternate pin, otherwise defaults to pin 1.
Definition: Components/arch_driver/src/include/driver/uart.h:254
smg_uart_mode_t mode
Whether to enable receive, transmit or both.
Definition: Components/arch_driver/src/include/driver/uart.h:256
smg_uart_format_t format
UART CONF0 register bits.
Definition: Components/arch_driver/src/include/driver/uart.h:259
uint8_t rx_pin
Definition: Components/arch_driver/src/include/driver/uart.h:255
uart_options_t options
Definition: Components/arch_driver/src/include/driver/uart.h:257
UART interrupt configuration parameters for smg_uart_intr_config function.
Definition: Components/arch_driver/src/include/driver/uart.h:284
uint8_t rx_timeout_thresh
Definition: Components/arch_driver/src/include/driver/uart.h:285
uint8_t txfifo_empty_intr_thresh
Definition: Components/arch_driver/src/include/driver/uart.h:286
uint8_t rxfifo_full_thresh
Ignored if additional buffers are allocated.
Definition: Components/arch_driver/src/include/driver/uart.h:287
uint32_t intr_enable
State of interrupt bits.
Definition: Components/arch_driver/src/include/driver/uart.h:290
uint8_t reserved
Definition: Components/arch_driver/src/include/driver/uart.h:288
uint32_t intr_mask
Mask of smg_uart_status_t indicating which interrupt bits to change.
Definition: Components/arch_driver/src/include/driver/uart.h:289
Definition: Components/arch_driver/src/include/driver/uart.h:237
void * param
User-supplied callback parameter.
Definition: Components/arch_driver/src/include/driver/uart.h:249
uint16_t status
All status flags reported to callback since last uart_get_status() call.
Definition: Components/arch_driver/src/include/driver/uart.h:245
struct SerialBuffer * rx_buffer
Optional receive buffer.
Definition: Components/arch_driver/src/include/driver/uart.h:246
struct SerialBuffer * tx_buffer
Optional transmit buffer.
Definition: Components/arch_driver/src/include/driver/uart.h:247
uint8_t rx_headroom
Callback when rx_buffer free space <= headroom.
Definition: Components/arch_driver/src/include/driver/uart.h:244
uint32_t baud_rate
Definition: Components/arch_driver/src/include/driver/uart.h:239
smg_uart_mode_t mode
Definition: Components/arch_driver/src/include/driver/uart.h:240
smg_uart_callback_t callback
Optional User callback routine.
Definition: Components/arch_driver/src/include/driver/uart.h:248
Structure for easier decomposing of format value.
Definition: Components/arch_driver/src/include/driver/uart.h:111
smg_uart_bits_t bits
Definition: Components/arch_driver/src/include/driver/uart.h:114
smg_uart_stop_bits_t stop_bits
Definition: Components/arch_driver/src/include/driver/uart.h:115
uint8_t val
Definition: Components/arch_driver/src/include/driver/uart.h:117
smg_uart_parity_t parity
Definition: Components/arch_driver/src/include/driver/uart.h:113
1.9.1