RBControl
Library for the RB3201-RBControl board with the ESP32 by RoboticsBrno.
|
Classes | |
struct | uart_tx_data_t |
struct | uart_pat_rb_t |
struct | uart_obj_t |
Functions | |
esp_err_t | uart_set_word_length (uart_port_t uart_num, uart_word_length_t data_bit) |
Set UART data bits. More... | |
esp_err_t | uart_get_word_length (uart_port_t uart_num, uart_word_length_t *data_bit) |
Get UART data bits. More... | |
esp_err_t | uart_set_stop_bits (uart_port_t uart_num, uart_stop_bits_t stop_bits) |
Set UART stop bits. More... | |
esp_err_t | uart_get_stop_bits (uart_port_t uart_num, uart_stop_bits_t *stop_bits) |
Get UART stop bits. More... | |
esp_err_t | uart_set_parity (uart_port_t uart_num, uart_parity_t parity_mode) |
Set UART parity mode. More... | |
esp_err_t | uart_get_parity (uart_port_t uart_num, uart_parity_t *parity_mode) |
Get UART parity mode. More... | |
esp_err_t | uart_set_baudrate (uart_port_t uart_num, uint32_t baudrate) |
Set UART baud rate. More... | |
esp_err_t | uart_get_baudrate (uart_port_t uart_num, uint32_t *baudrate) |
Get UART baud rate. More... | |
esp_err_t | uart_set_line_inverse (uart_port_t uart_num, uint32_t inverse_mask) |
Set UART line inverse mode. More... | |
esp_err_t | uart_set_sw_flow_ctrl (uart_port_t uart_num, bool enable, uint8_t rx_thresh_xon, uint8_t rx_thresh_xoff) |
Set software flow control. More... | |
esp_err_t | uart_set_hw_flow_ctrl (uart_port_t uart_num, uart_hw_flowcontrol_t flow_ctrl, uint8_t rx_thresh) |
Set hardware flow control. More... | |
esp_err_t | uart_get_hw_flow_ctrl (uart_port_t uart_num, uart_hw_flowcontrol_t *flow_ctrl) |
Get hardware flow control mode. More... | |
static esp_err_t IRAM_ATTR | uart_reset_rx_fifo (uart_port_t uart_num) |
esp_err_t IRAM_ATTR | uart_clear_intr_status (uart_port_t uart_num, uint32_t clr_mask) |
Clear UART interrupt status. More... | |
esp_err_t | uart_enable_intr_mask (uart_port_t uart_num, uint32_t enable_mask) |
Set UART interrupt enable. More... | |
esp_err_t | uart_disable_intr_mask (uart_port_t uart_num, uint32_t disable_mask) |
Clear UART interrupt enable bits. More... | |
static void IRAM_ATTR | uart_disable_intr_mask_from_isr (uart_port_t uart_num, uint32_t disable_mask) |
static void IRAM_ATTR | uart_enable_intr_mask_from_isr (uart_port_t uart_num, uint32_t enable_mask) |
static esp_err_t | uart_pattern_link_free (uart_port_t uart_num) |
static esp_err_t IRAM_ATTR | uart_pattern_enqueue (uart_port_t uart_num, int pos) |
static esp_err_t | uart_pattern_dequeue (uart_port_t uart_num) |
static esp_err_t | uart_pattern_queue_update (uart_port_t uart_num, int diff_len) |
int | uart_pattern_pop_pos (uart_port_t uart_num) |
Return the nearest detected pattern position in buffer. The positions of the detected pattern are saved in a queue, this function will dequeue the first pattern position and move the pointer to next pattern position. More... | |
int | uart_pattern_get_pos (uart_port_t uart_num) |
Return the nearest detected pattern position in buffer. The positions of the detected pattern are saved in a queue, This function do nothing to the queue. More... | |
esp_err_t | uart_pattern_queue_reset (uart_port_t uart_num, int queue_length) |
Allocate a new memory with the given length to save record the detected pattern position in rx buffer. More... | |
esp_err_t | uart_enable_pattern_det_intr (uart_port_t uart_num, char pattern_chr, uint8_t chr_num, int chr_tout, int post_idle, int pre_idle) |
UART enable pattern detect function. Designed for applications like 'AT commands'. When the hardware detect a series of one same character, the interrupt will be triggered. More... | |
esp_err_t | uart_disable_pattern_det_intr (uart_port_t uart_num) |
UART disable pattern detect function. Designed for applications like 'AT commands'. When the hardware detects a series of one same character, the interrupt will be triggered. More... | |
esp_err_t | uart_enable_rx_intr (uart_port_t uart_num) |
Enable UART RX interrupt (RX_FULL & RX_TIMEOUT INTERRUPT) More... | |
esp_err_t | uart_disable_rx_intr (uart_port_t uart_num) |
Disable UART RX interrupt (RX_FULL & RX_TIMEOUT INTERRUPT) More... | |
esp_err_t | uart_disable_tx_intr (uart_port_t uart_num) |
Disable UART TX interrupt (TX_FULL & TX_TIMEOUT INTERRUPT) More... | |
esp_err_t | uart_enable_tx_intr (uart_port_t uart_num, int enable, int thresh) |
Enable UART TX interrupt (TX_FULL & TX_TIMEOUT INTERRUPT) More... | |
esp_err_t | uart_isr_register (uart_port_t uart_num, void(*fn)(void *), void *arg, int intr_alloc_flags, uart_isr_handle_t *handle) |
Register UART interrupt handler (ISR). More... | |
esp_err_t | uart_isr_free (uart_port_t uart_num) |
Free UART interrupt handler registered by uart_isr_register. Must be called on the same core as uart_isr_register was called. More... | |
esp_err_t | uart_set_pin (uart_port_t uart_num, int tx_io_num, int rx_io_num, int rts_io_num, int cts_io_num) |
Set UART pin number. More... | |
esp_err_t | uart_set_rts (uart_port_t uart_num, int level) |
Manually set the UART RTS pin level. More... | |
esp_err_t | uart_set_dtr (uart_port_t uart_num, int level) |
Manually set the UART DTR pin level. More... | |
esp_err_t | uart_set_tx_idle_num (uart_port_t uart_num, uint16_t idle_num) |
Set UART idle interval after tx FIFO is empty. More... | |
esp_err_t | uart_param_config (uart_port_t uart_num, const uart_config_t *uart_config) |
Set UART configuration parameters. More... | |
esp_err_t | uart_intr_config (uart_port_t uart_num, const uart_intr_config_t *intr_conf) |
Configure UART interrupts. More... | |
static int | uart_find_pattern_from_last (uint8_t *buf, int length, uint8_t pat_chr, int pat_num) |
static void IRAM_ATTR | uart_rx_intr_handler_default (void *param) |
static int | uart_fill_fifo (uart_port_t uart_num, const char *buffer, uint32_t len) |
int | uart_tx_chars (uart_port_t uart_num, const char *buffer, uint32_t len) |
Send data to the UART port from a given buffer and length. More... | |
static bool | uart_check_buf_full (uart_port_t uart_num) |
int | uart_read_bytes (uart_port_t uart_num, uint8_t *buf, uint32_t length, TickType_t ticks_to_wait) |
UART read bytes from UART buffer. More... | |
esp_err_t | uart_get_buffered_data_len (uart_port_t uart_num, size_t *size) |
UART get RX ring buffer cached data length. More... | |
esp_err_t | uart_flush_input (uart_port_t uart_num) |
Clear input buffer, discard all the data is in the ring-buffer. More... | |
esp_err_t | uart_flush (uart_port_t uart_num) |
Alias of uart_flush_input. UART ring buffer flush. This will discard all data in the UART RX buffer. More... | |
esp_err_t | uart_driver_install (uart_port_t uart_num, int rx_buffer_size, int tx_buffer_size, int queue_size, QueueHandle_t *uart_queue, int intr_alloc_flags) |
Install UART driver. More... | |
esp_err_t | uart_driver_delete (uart_port_t uart_num) |
Uninstall UART driver. More... | |
void | uart_set_select_notif_callback (uart_port_t uart_num, uart_select_notif_callback_t uart_select_notif_callback) |
portMUX_TYPE * | uart_get_selectlock () |
esp_err_t | uart_set_mode (uart_port_t uart_num, uart_mode_t mode) |
UART set communication mode. More... | |
esp_err_t | uart_set_rx_timeout (uart_port_t uart_num, const uint8_t tout_thresh) |
UART set threshold timeout for TOUT feature. More... | |
esp_err_t | uart_get_collision_flag (uart_port_t uart_num, bool *collision_flag) |
Returns collision detection flag for RS485 mode Function returns the collision detection flag into variable pointed by collision_flag. *collision_flag = true, if collision detected else it is equal to false. This function should be executed when actual transmission is completed (after uart_write_bytes()). More... | |
esp_err_t | uart_set_wakeup_threshold (uart_port_t uart_num, int wakeup_threshold) |
Set the number of RX pin signal edges for light sleep wakeup. More... | |
esp_err_t | uart_get_wakeup_threshold (uart_port_t uart_num, int *out_wakeup_threshold) |
Get the number of RX pin signal edges for light sleep wakeup. More... | |
void | uart_set_half_duplex_pin (uart_port_t uart_num, gpio_num_t pin) |
esp_err_t | uart_wait_tx_done (uart_port_t uart_num, TickType_t ticks_to_wait) |
Wait until UART TX FIFO is empty. More... | |
int | uart_write_bytes (uart_port_t uart_num, const char *src, size_t size) |
Send data to the UART port from a given buffer and length,. More... | |
int | uart_write_bytes_with_break (uart_port_t uart_num, const char *src, size_t size, int brk_len) |
Send data to the UART port from a given buffer and length,. More... | |
Variables | |
static const char * | UART_TAG = "uart" |
static uart_obj_t * | p_uart_obj [UART_NUM_MAX] = {0} |
static DRAM_ATTR uart_dev_t *const | UART [UART_NUM_MAX] = {&UART0, &UART1, &UART2} |
static portMUX_TYPE | uart_spinlock [UART_NUM_MAX] = {portMUX_INITIALIZER_UNLOCKED, portMUX_INITIALIZER_UNLOCKED, portMUX_INITIALIZER_UNLOCKED} |
static portMUX_TYPE | uart_selectlock = portMUX_INITIALIZER_UNLOCKED |
|
static |
esp_err_t rb::half_duplex::uart_clear_intr_status | ( | uart_port_t | uart_num, |
uint32_t | clr_mask | ||
) |
Clear UART interrupt status.
uart_num | UART_NUM_0, UART_NUM_1 or UART_NUM_2 |
clr_mask | Bit mask of the interrupt status to be cleared. The bit mask should be composed from the fields of register UART_INT_CLR_REG. |
esp_err_t rb::half_duplex::uart_disable_intr_mask | ( | uart_port_t | uart_num, |
uint32_t | disable_mask | ||
) |
Clear UART interrupt enable bits.
uart_num | UART_NUM_0, UART_NUM_1 or UART_NUM_2 |
disable_mask | Bit mask of the disable bits. The bit mask should be composed from the fields of register UART_INT_ENA_REG. |
|
static |
esp_err_t rb::half_duplex::uart_disable_pattern_det_intr | ( | uart_port_t | uart_num | ) |
UART disable pattern detect function. Designed for applications like 'AT commands'. When the hardware detects a series of one same character, the interrupt will be triggered.
uart_num | UART port number. |
esp_err_t rb::half_duplex::uart_disable_rx_intr | ( | uart_port_t | uart_num | ) |
Disable UART RX interrupt (RX_FULL & RX_TIMEOUT INTERRUPT)
uart_num | UART_NUM_0, UART_NUM_1 or UART_NUM_2 |
esp_err_t rb::half_duplex::uart_disable_tx_intr | ( | uart_port_t | uart_num | ) |
Disable UART TX interrupt (TX_FULL & TX_TIMEOUT INTERRUPT)
uart_num | UART_NUM_0, UART_NUM_1 or UART_NUM_2 |
esp_err_t rb::half_duplex::uart_driver_delete | ( | uart_port_t | uart_num | ) |
Uninstall UART driver.
uart_num | UART_NUM_0, UART_NUM_1 or UART_NUM_2 |
esp_err_t rb::half_duplex::uart_driver_install | ( | uart_port_t | uart_num, |
int | rx_buffer_size, | ||
int | tx_buffer_size, | ||
int | queue_size, | ||
QueueHandle_t * | uart_queue, | ||
int | intr_alloc_flags | ||
) |
Install UART driver.
UART ISR handler will be attached to the same CPU core that this function is running on.
uart_num | UART_NUM_0, UART_NUM_1 or UART_NUM_2 |
rx_buffer_size | UART RX ring buffer size. |
tx_buffer_size | UART TX ring buffer size. If set to zero, driver will not use TX buffer, TX function will block task until all data have been sent out. |
queue_size | UART event queue size/depth. |
uart_queue | UART event queue handle (out param). On success, a new queue handle is written here to provide access to UART events. If set to NULL, driver will not use an event queue. |
intr_alloc_flags | Flags used to allocate the interrupt. One or multiple (ORred) ESP_INTR_FLAG_* values. See esp_intr_alloc.h for more info. Do not set ESP_INTR_FLAG_IRAM here (the driver's ISR handler is not located in IRAM) |
esp_err_t rb::half_duplex::uart_enable_intr_mask | ( | uart_port_t | uart_num, |
uint32_t | enable_mask | ||
) |
Set UART interrupt enable.
uart_num | UART_NUM_0, UART_NUM_1 or UART_NUM_2 |
enable_mask | Bit mask of the enable bits. The bit mask should be composed from the fields of register UART_INT_ENA_REG. |
|
static |
esp_err_t rb::half_duplex::uart_enable_pattern_det_intr | ( | uart_port_t | uart_num, |
char | pattern_chr, | ||
uint8_t | chr_num, | ||
int | chr_tout, | ||
int | post_idle, | ||
int | pre_idle | ||
) |
UART enable pattern detect function. Designed for applications like 'AT commands'. When the hardware detect a series of one same character, the interrupt will be triggered.
uart_num | UART port number. |
pattern_chr | character of the pattern |
chr_num | number of the character, 8bit value. |
chr_tout | timeout of the interval between each pattern characters, 24bit value, unit is APB (80Mhz) clock cycle. When the duration is less than this value, it will not take this data as at_cmd char |
post_idle | idle time after the last pattern character, 24bit value, unit is APB (80Mhz) clock cycle. When the duration is less than this value, it will not take the previous data as the last at_cmd char |
pre_idle | idle time before the first pattern character, 24bit value, unit is APB (80Mhz) clock cycle. When the duration is less than this value, it will not take this data as the first at_cmd char |
esp_err_t rb::half_duplex::uart_enable_rx_intr | ( | uart_port_t | uart_num | ) |
Enable UART RX interrupt (RX_FULL & RX_TIMEOUT INTERRUPT)
uart_num | UART_NUM_0, UART_NUM_1 or UART_NUM_2 |
esp_err_t rb::half_duplex::uart_enable_tx_intr | ( | uart_port_t | uart_num, |
int | enable, | ||
int | thresh | ||
) |
Enable UART TX interrupt (TX_FULL & TX_TIMEOUT INTERRUPT)
uart_num | UART_NUM_0, UART_NUM_1 or UART_NUM_2 |
enable | 1: enable; 0: disable |
thresh | Threshold of TX interrupt, 0 ~ UART_FIFO_LEN |
|
static |
|
static |
esp_err_t rb::half_duplex::uart_flush | ( | uart_port_t | uart_num | ) |
Alias of uart_flush_input. UART ring buffer flush. This will discard all data in the UART RX buffer.
uart_num | UART_NUM_0, UART_NUM_1 or UART_NUM_2 |
esp_err_t rb::half_duplex::uart_flush_input | ( | uart_port_t | uart_num | ) |
Clear input buffer, discard all the data is in the ring-buffer.
uart_num | UART_NUM_0, UART_NUM_1 or UART_NUM_2 |
esp_err_t rb::half_duplex::uart_get_baudrate | ( | uart_port_t | uart_num, |
uint32_t * | baudrate | ||
) |
Get UART baud rate.
uart_num | UART_NUM_0, UART_NUM_1 or UART_NUM_2 |
baudrate | Pointer to accept value of UART baud rate |
esp_err_t rb::half_duplex::uart_get_buffered_data_len | ( | uart_port_t | uart_num, |
size_t * | size | ||
) |
UART get RX ring buffer cached data length.
uart_num | UART port number. |
size | Pointer of size_t to accept cached data length |
esp_err_t rb::half_duplex::uart_get_collision_flag | ( | uart_port_t | uart_num, |
bool * | collision_flag | ||
) |
Returns collision detection flag for RS485 mode Function returns the collision detection flag into variable pointed by collision_flag. *collision_flag = true, if collision detected else it is equal to false. This function should be executed when actual transmission is completed (after uart_write_bytes()).
uart_num | Uart number to configure |
collision_flag | Pointer to variable of type bool to return collision flag. |
esp_err_t rb::half_duplex::uart_get_hw_flow_ctrl | ( | uart_port_t | uart_num, |
uart_hw_flowcontrol_t * | flow_ctrl | ||
) |
Get hardware flow control mode.
uart_num | UART_NUM_0, UART_NUM_1 or UART_NUM_2 |
flow_ctrl | Option for different flow control mode. |
esp_err_t rb::half_duplex::uart_get_parity | ( | uart_port_t | uart_num, |
uart_parity_t * | parity_mode | ||
) |
Get UART parity mode.
uart_num | UART_NUM_0, UART_NUM_1 or UART_NUM_2 |
parity_mode | Pointer to accept value of UART parity mode. |
portMUX_TYPE* rb::half_duplex::uart_get_selectlock | ( | ) |
esp_err_t rb::half_duplex::uart_get_stop_bits | ( | uart_port_t | uart_num, |
uart_stop_bits_t * | stop_bits | ||
) |
Get UART stop bits.
uart_num | UART_NUM_0, UART_NUM_1 or UART_NUM_2 |
stop_bits | Pointer to accept value of UART stop bits. |
esp_err_t rb::half_duplex::uart_get_wakeup_threshold | ( | uart_port_t | uart_num, |
int * | out_wakeup_threshold | ||
) |
Get the number of RX pin signal edges for light sleep wakeup.
See description of uart_set_wakeup_threshold for the explanation of UART wakeup feature.
uart_num | UART number | |
[out] | out_wakeup_threshold | output, set to the current value of wakeup threshold for the given UART. |
esp_err_t rb::half_duplex::uart_get_word_length | ( | uart_port_t | uart_num, |
uart_word_length_t * | data_bit | ||
) |
Get UART data bits.
uart_num | UART_NUM_0, UART_NUM_1 or UART_NUM_2 |
data_bit | Pointer to accept value of UART data bits. |
esp_err_t rb::half_duplex::uart_intr_config | ( | uart_port_t | uart_num, |
const uart_intr_config_t * | intr_conf | ||
) |
Configure UART interrupts.
uart_num | UART_NUM_0, UART_NUM_1 or UART_NUM_2 |
intr_conf | UART interrupt settings |
esp_err_t rb::half_duplex::uart_isr_free | ( | uart_port_t | uart_num | ) |
Free UART interrupt handler registered by uart_isr_register. Must be called on the same core as uart_isr_register was called.
uart_num | UART_NUM_0, UART_NUM_1 or UART_NUM_2 |
esp_err_t rb::half_duplex::uart_isr_register | ( | uart_port_t | uart_num, |
void(*)(void *) | fn, | ||
void * | arg, | ||
int | intr_alloc_flags, | ||
uart_isr_handle_t * | handle | ||
) |
Register UART interrupt handler (ISR).
uart_num | UART_NUM_0, UART_NUM_1 or UART_NUM_2 |
fn | Interrupt handler function. |
arg | parameter for handler function |
intr_alloc_flags | Flags used to allocate the interrupt. One or multiple (ORred) ESP_INTR_FLAG_* values. See esp_intr_alloc.h for more info. |
handle | Pointer to return handle. If non-NULL, a handle for the interrupt will be returned here. |
esp_err_t rb::half_duplex::uart_param_config | ( | uart_port_t | uart_num, |
const uart_config_t * | uart_config | ||
) |
Set UART configuration parameters.
uart_num | UART_NUM_0, UART_NUM_1 or UART_NUM_2 |
uart_config | UART parameter settings |
|
static |
|
static |
int rb::half_duplex::uart_pattern_get_pos | ( | uart_port_t | uart_num | ) |
Return the nearest detected pattern position in buffer. The positions of the detected pattern are saved in a queue, This function do nothing to the queue.
The following APIs will modify the pattern position info: uart_flush_input, uart_read_bytes, uart_driver_delete, uart_pop_pattern_pos It is the application's responsibility to ensure atomic access to the pattern queue and the rx data buffer when using pattern detect feature.
uart_num | UART port number |
|
static |
int rb::half_duplex::uart_pattern_pop_pos | ( | uart_port_t | uart_num | ) |
Return the nearest detected pattern position in buffer. The positions of the detected pattern are saved in a queue, this function will dequeue the first pattern position and move the pointer to next pattern position.
The following APIs will modify the pattern position info: uart_flush_input, uart_read_bytes, uart_driver_delete, uart_pop_pattern_pos It is the application's responsibility to ensure atomic access to the pattern queue and the rx data buffer when using pattern detect feature.
uart_num | UART port number |
esp_err_t rb::half_duplex::uart_pattern_queue_reset | ( | uart_port_t | uart_num, |
int | queue_length | ||
) |
Allocate a new memory with the given length to save record the detected pattern position in rx buffer.
uart_num | UART port number |
queue_length | Max queue length for the detected pattern. If the queue length is not large enough, some pattern positions might be lost. Set this value to the maximum number of patterns that could be saved in data buffer at the same time. |
|
static |
int rb::half_duplex::uart_read_bytes | ( | uart_port_t | uart_num, |
uint8_t * | buf, | ||
uint32_t | length, | ||
TickType_t | ticks_to_wait | ||
) |
UART read bytes from UART buffer.
uart_num | UART_NUM_0, UART_NUM_1 or UART_NUM_2 |
buf | pointer to the buffer. |
length | data length |
ticks_to_wait | sTimeout, count in RTOS ticks |
|
static |
|
static |
esp_err_t rb::half_duplex::uart_set_baudrate | ( | uart_port_t | uart_num, |
uint32_t | baudrate | ||
) |
Set UART baud rate.
uart_num | UART_NUM_0, UART_NUM_1 or UART_NUM_2 |
baudrate | UART baud rate. |
esp_err_t rb::half_duplex::uart_set_dtr | ( | uart_port_t | uart_num, |
int | level | ||
) |
Manually set the UART DTR pin level.
uart_num | UART_NUM_0, UART_NUM_1 or UART_NUM_2 |
level | 1: DTR output low; 0: DTR output high |
void rb::half_duplex::uart_set_half_duplex_pin | ( | uart_port_t | uart_num, |
gpio_num_t | pin | ||
) |
esp_err_t rb::half_duplex::uart_set_hw_flow_ctrl | ( | uart_port_t | uart_num, |
uart_hw_flowcontrol_t | flow_ctrl, | ||
uint8_t | rx_thresh | ||
) |
Set hardware flow control.
uart_num | UART_NUM_0, UART_NUM_1 or UART_NUM_2 |
flow_ctrl | Hardware flow control mode |
rx_thresh | Threshold of Hardware RX flow control (0 ~ UART_FIFO_LEN). Only when UART_HW_FLOWCTRL_RTS is set, will the rx_thresh value be set. |
esp_err_t rb::half_duplex::uart_set_line_inverse | ( | uart_port_t | uart_num, |
uint32_t | inverse_mask | ||
) |
Set UART line inverse mode.
uart_num | UART_NUM_0, UART_NUM_1 or UART_NUM_2 |
inverse_mask | Choose the wires that need to be inverted. Inverse_mask should be chosen from UART_INVERSE_RXD / UART_INVERSE_TXD / UART_INVERSE_RTS / UART_INVERSE_CTS, combined with OR operation. |
esp_err_t rb::half_duplex::uart_set_mode | ( | uart_port_t | uart_num, |
uart_mode_t | mode | ||
) |
UART set communication mode.
uart_num | Uart number to configure |
mode | UART UART mode to set |
esp_err_t rb::half_duplex::uart_set_parity | ( | uart_port_t | uart_num, |
uart_parity_t | parity_mode | ||
) |
Set UART parity mode.
uart_num | UART_NUM_0, UART_NUM_1 or UART_NUM_2 |
parity_mode | the enum of uart parity configuration |
esp_err_t rb::half_duplex::uart_set_pin | ( | uart_port_t | uart_num, |
int | tx_io_num, | ||
int | rx_io_num, | ||
int | rts_io_num, | ||
int | cts_io_num | ||
) |
Set UART pin number.
uart_num | UART_NUM_0, UART_NUM_1 or UART_NUM_2 |
tx_io_num | UART TX pin GPIO number. |
rx_io_num | UART RX pin GPIO number. |
rts_io_num | UART RTS pin GPIO number. |
cts_io_num | UART CTS pin GPIO number. |
esp_err_t rb::half_duplex::uart_set_rts | ( | uart_port_t | uart_num, |
int | level | ||
) |
Manually set the UART RTS pin level.
uart_num | UART_NUM_0, UART_NUM_1 or UART_NUM_2 |
level | 1: RTS output low (active); 0: RTS output high (block) |
esp_err_t rb::half_duplex::uart_set_rx_timeout | ( | uart_port_t | uart_num, |
const uint8_t | tout_thresh | ||
) |
UART set threshold timeout for TOUT feature.
uart_num | Uart number to configure |
tout_thresh | This parameter defines timeout threshold in uart symbol periods. The maximum value of threshold is 126. tout_thresh = 1, defines TOUT interrupt timeout equal to transmission time of one symbol (~11 bit) on current baudrate. If the time is expired the UART_RXFIFO_TOUT_INT interrupt is triggered. If tout_thresh == 0, the TOUT feature is disabled. |
void rb::half_duplex::uart_set_select_notif_callback | ( | uart_port_t | uart_num, |
uart_select_notif_callback_t | uart_select_notif_callback | ||
) |
esp_err_t rb::half_duplex::uart_set_stop_bits | ( | uart_port_t | uart_num, |
uart_stop_bits_t | stop_bits | ||
) |
Set UART stop bits.
uart_num | UART_NUM_0, UART_NUM_1 or UART_NUM_2 |
stop_bits | UART stop bits |
esp_err_t rb::half_duplex::uart_set_sw_flow_ctrl | ( | uart_port_t | uart_num, |
bool | enable, | ||
uint8_t | rx_thresh_xon, | ||
uint8_t | rx_thresh_xoff | ||
) |
Set software flow control.
uart_num | UART_NUM_0, UART_NUM_1 or UART_NUM_2 |
enable | switch on or off |
rx_thresh_xon | low water mark |
rx_thresh_xoff | high water mark |
esp_err_t rb::half_duplex::uart_set_tx_idle_num | ( | uart_port_t | uart_num, |
uint16_t | idle_num | ||
) |
Set UART idle interval after tx FIFO is empty.
uart_num | UART_NUM_0, UART_NUM_1 or UART_NUM_2 |
idle_num | idle interval after tx FIFO is empty(unit: the time it takes to send one bit under current baudrate) |
esp_err_t rb::half_duplex::uart_set_wakeup_threshold | ( | uart_port_t | uart_num, |
int | wakeup_threshold | ||
) |
Set the number of RX pin signal edges for light sleep wakeup.
UART can be used to wake up the system from light sleep. This feature works by counting the number of positive edges on RX pin and comparing the count to the threshold. When the count exceeds the threshold, system is woken up from light sleep. This function allows setting the threshold value.
Stop bit and parity bits (if enabled) also contribute to the number of edges. For example, letter 'a' with ASCII code 97 is encoded as 0100001101 on the wire (with 8n1 configuration), start and stop bits included. This sequence has 3 positive edges (transitions from 0 to 1). Therefore, to wake up the system when 'a' is sent, set wakeup_threshold=3.
The character that triggers wakeup is not received by UART (i.e. it can not be obtained from UART FIFO). Depending on the baud rate, a few characters after that will also not be received. Note that when the chip enters and exits light sleep mode, APB frequency will be changing. To make sure that UART has correct baud rate all the time, select REF_TICK as UART clock source, by setting use_ref_tick field in uart_config_t to true.
uart_num | UART number |
wakeup_threshold | number of RX edges for light sleep wakeup, value is 3 .. 0x3ff. |
esp_err_t rb::half_duplex::uart_set_word_length | ( | uart_port_t | uart_num, |
uart_word_length_t | data_bit | ||
) |
Set UART data bits.
uart_num | UART_NUM_0, UART_NUM_1 or UART_NUM_2 |
data_bit | UART data bits |
int rb::half_duplex::uart_tx_chars | ( | uart_port_t | uart_num, |
const char * | buffer, | ||
uint32_t | len | ||
) |
Send data to the UART port from a given buffer and length.
This function will not wait for enough space in TX FIFO. It will just fill the available TX FIFO and return when the FIFO is full.
uart_num | UART_NUM_0, UART_NUM_1 or UART_NUM_2 |
buffer | data buffer address |
len | data length to send |
esp_err_t rb::half_duplex::uart_wait_tx_done | ( | uart_port_t | uart_num, |
TickType_t | ticks_to_wait | ||
) |
Wait until UART TX FIFO is empty.
uart_num | UART_NUM_0, UART_NUM_1 or UART_NUM_2 |
ticks_to_wait | Timeout, count in RTOS ticks |
int rb::half_duplex::uart_write_bytes | ( | uart_port_t | uart_num, |
const char * | src, | ||
size_t | size | ||
) |
Send data to the UART port from a given buffer and length,.
If the UART driver's parameter 'tx_buffer_size' is set to zero: This function will not return until all the data have been sent out, or at least pushed into TX FIFO.
Otherwise, if the 'tx_buffer_size' > 0, this function will return after copying all the data to tx ring buffer, UART ISR will then move data from the ring buffer to TX FIFO gradually.
uart_num | UART_NUM_0, UART_NUM_1 or UART_NUM_2 |
src | data buffer address |
size | data length to send |
int rb::half_duplex::uart_write_bytes_with_break | ( | uart_port_t | uart_num, |
const char * | src, | ||
size_t | size, | ||
int | brk_len | ||
) |
Send data to the UART port from a given buffer and length,.
If the UART driver's parameter 'tx_buffer_size' is set to zero: This function will not return until all the data and the break signal have been sent out. After all data is sent out, send a break signal.
Otherwise, if the 'tx_buffer_size' > 0, this function will return after copying all the data to tx ring buffer, UART ISR will then move data from the ring buffer to TX FIFO gradually. After all data sent out, send a break signal.
uart_num | UART_NUM_0, UART_NUM_1 or UART_NUM_2 |
src | data buffer address |
size | data length to send |
brk_len | break signal duration(unit: the time it takes to send one bit at current baudrate) |
|
static |
|
static |
|
static |
|
static |
|
static |