Skip to content

Commit cd57f1b

Browse files
committed
feat(eppp): Add support for UART flow control
Closes #870
1 parent 497ee2d commit cd57f1b

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

components/eppp_link/eppp_uart.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,12 +80,12 @@ static esp_err_t init_uart(struct eppp_uart *h, struct eppp_config_uart_s *confi
8080
uart_config.data_bits = UART_DATA_8_BITS;
8181
uart_config.parity = UART_PARITY_DISABLE;
8282
uart_config.stop_bits = UART_STOP_BITS_1;
83-
uart_config.flow_ctrl = UART_HW_FLOWCTRL_DISABLE;
83+
uart_config.flow_ctrl = config->flow_control;
8484
uart_config.source_clk = UART_SCLK_DEFAULT;
8585

8686
ESP_RETURN_ON_ERROR(uart_driver_install(h->uart_port, config->rx_buffer_size, 0, config->queue_size, &h->uart_event_queue, 0), TAG, "Failed to install UART");
8787
ESP_RETURN_ON_ERROR(uart_param_config(h->uart_port, &uart_config), TAG, "Failed to set params");
88-
ESP_RETURN_ON_ERROR(uart_set_pin(h->uart_port, config->tx_io, config->rx_io, UART_PIN_NO_CHANGE, UART_PIN_NO_CHANGE), TAG, "Failed to set UART pins");
88+
ESP_RETURN_ON_ERROR(uart_set_pin(h->uart_port, config->tx_io, config->rx_io, config->rts_io, config->cts_io), TAG, "Failed to set UART pins");
8989
ESP_RETURN_ON_ERROR(uart_set_rx_timeout(h->uart_port, 1), TAG, "Failed to set UART Rx timeout");
9090
return ESP_OK;
9191
}
@@ -269,6 +269,7 @@ eppp_transport_handle_t eppp_uart_init(struct eppp_config_uart_s *config)
269269
ESP_GOTO_ON_ERROR(init_uart(h, config), err, TAG, "Failed to init UART");
270270
return &h->parent;
271271
err:
272+
free(h);
272273
return NULL;
273274
}
274275

components/eppp_link/include/eppp_link.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ extern "C" {
3434
.rx_io = 26, \
3535
.queue_size = 16, \
3636
.rx_buffer_size = 1024, \
37+
.rts_io = -1, \
38+
.cts_io = -1, \
39+
.flow_control = 0, \
3740
}, \
3841

3942
#define EPPP_DEFAULT_SDIO_CONFIG() \
@@ -135,6 +138,9 @@ typedef struct eppp_config_t {
135138
int rx_io;
136139
int queue_size;
137140
int rx_buffer_size;
141+
int rts_io;
142+
int cts_io;
143+
int flow_control;
138144
} uart;
139145

140146
struct eppp_config_sdio_s {

0 commit comments

Comments
 (0)