mirror of
https://github.com/espressif/esp-idf.git
synced 2025-08-08 04:02:27 +00:00
feat(uart): update uart driver for esp32s2beta
This commit is contained in:
@@ -32,7 +32,7 @@
|
||||
#endif
|
||||
|
||||
// TODO: make the number of UARTs chip dependent
|
||||
#define UART_NUM 3
|
||||
#define UART_NUM SOC_UART_NUM
|
||||
|
||||
// Token signifying that no character is available
|
||||
#define NONE -1
|
||||
@@ -51,12 +51,27 @@ static void uart_tx_char_via_driver(int fd, int c);
|
||||
static int uart_rx_char_via_driver(int fd);
|
||||
|
||||
// Pointers to UART peripherals
|
||||
static uart_dev_t* s_uarts[UART_NUM] = {&UART0, &UART1, &UART2};
|
||||
static uart_dev_t* s_uarts[UART_NUM] = {
|
||||
&UART0,
|
||||
&UART1,
|
||||
#if UART_NUM > 2
|
||||
&UART2
|
||||
#endif
|
||||
};
|
||||
|
||||
// One-character buffer used for newline conversion code, per UART
|
||||
static int s_peek_char[UART_NUM] = {
|
||||
NONE,
|
||||
NONE,
|
||||
#if UART_NUM > 2
|
||||
NONE
|
||||
#endif
|
||||
};
|
||||
|
||||
// per-UART locks, lazily initialized
|
||||
static _lock_t s_uart_read_locks[UART_NUM];
|
||||
static _lock_t s_uart_write_locks[UART_NUM];
|
||||
// One-character buffer used for newline conversion code, per UART
|
||||
static int s_peek_char[UART_NUM] = { NONE, NONE, NONE };
|
||||
|
||||
// Per-UART non-blocking flag. Note: default implementation does not honor this
|
||||
// flag, all reads are non-blocking. This option becomes effective if UART
|
||||
// driver is used.
|
||||
@@ -98,15 +113,22 @@ static void uart_end_select();
|
||||
|
||||
// Functions used to write bytes to UART. Default to "basic" functions.
|
||||
static tx_func_t s_uart_tx_func[UART_NUM] = {
|
||||
&uart_tx_char, &uart_tx_char, &uart_tx_char
|
||||
&uart_tx_char,
|
||||
&uart_tx_char,
|
||||
#if UART_NUM > 2
|
||||
&uart_tx_char
|
||||
#endif
|
||||
};
|
||||
|
||||
// Functions used to read bytes from UART. Default to "basic" functions.
|
||||
static rx_func_t s_uart_rx_func[UART_NUM] = {
|
||||
&uart_rx_char, &uart_rx_char, &uart_rx_char
|
||||
&uart_rx_char,
|
||||
&uart_rx_char,
|
||||
#if UART_NUM > 2
|
||||
&uart_rx_char
|
||||
#endif
|
||||
};
|
||||
|
||||
|
||||
static int uart_open(const char * path, int flags, int mode)
|
||||
{
|
||||
// this is fairly primitive, we should check if file is opened read only,
|
||||
|
Reference in New Issue
Block a user