mirror of
https://github.com/espressif/ESP8266_RTOS_SDK.git
synced 2025-05-22 01:27:11 +08:00
feat(vfs): Modify for esp8266
This commit is contained in:
@ -33,6 +33,7 @@
|
||||
#include "rom/ets_sys.h"
|
||||
|
||||
#include "driver/uart.h"
|
||||
#include "driver/uart_select.h"
|
||||
|
||||
#define portYIELD_FROM_ISR() taskYIELD()
|
||||
|
||||
@ -88,6 +89,7 @@ typedef struct {
|
||||
uint32_t tx_len_tot; /*!< Total length of current item in ring buffer*/
|
||||
uint32_t tx_len_cur;
|
||||
bool wait_tx_done_flg;
|
||||
uart_select_notif_callback_t uart_select_notif_callback; /*!< Notification about select() events */
|
||||
} uart_obj_t;
|
||||
|
||||
static uart_obj_t *p_uart_obj[UART_NUM_MAX] = {0};
|
||||
@ -502,6 +504,7 @@ static void uart_rx_intr_handler_default(void *param)
|
||||
BaseType_t task_woken = 0;
|
||||
|
||||
while (uart_intr_status != 0x0) {
|
||||
uart_select_notif_t notify = UART_SELECT_ERROR_NOTIF;
|
||||
|
||||
buf_idx = 0;
|
||||
uart_event.type = UART_EVENT_MAX;
|
||||
@ -628,6 +631,8 @@ static void uart_rx_intr_handler_default(void *param)
|
||||
p_uart->rx_buffered_len += p_uart->rx_stash_len;
|
||||
}
|
||||
|
||||
notify = UART_SELECT_READ_NOTIF;
|
||||
|
||||
if (task_woken == pdTRUE) {
|
||||
portYIELD_FROM_ISR();
|
||||
}
|
||||
@ -640,17 +645,32 @@ static void uart_rx_intr_handler_default(void *param)
|
||||
uart_reset_rx_fifo(uart_num);
|
||||
uart_reg->int_clr.rxfifo_ovf = 1;
|
||||
uart_event.type = UART_FIFO_OVF;
|
||||
notify = UART_SELECT_ERROR_NOTIF;
|
||||
} else if (uart_intr_status & UART_FRM_ERR_INT_ST_M) {
|
||||
uart_reg->int_clr.frm_err = 1;
|
||||
uart_event.type = UART_FRAME_ERR;
|
||||
notify = UART_SELECT_ERROR_NOTIF;
|
||||
} else if (uart_intr_status & UART_PARITY_ERR_INT_ST_M) {
|
||||
uart_reg->int_clr.parity_err = 1;
|
||||
uart_event.type = UART_PARITY_ERR;
|
||||
notify = UART_SELECT_ERROR_NOTIF;
|
||||
} else {
|
||||
uart_reg->int_clr.val = uart_intr_status; // simply clear all other intr status
|
||||
uart_event.type = UART_EVENT_MAX;
|
||||
notify = UART_SELECT_ERROR_NOTIF;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_USING_ESP_VFS
|
||||
if (uart_event.type != UART_EVENT_MAX && p_uart->uart_select_notif_callback) {
|
||||
p_uart->uart_select_notif_callback(uart_num, notify, &task_woken);
|
||||
if (task_woken == pdTRUE) {
|
||||
portYIELD_FROM_ISR();
|
||||
}
|
||||
}
|
||||
#else
|
||||
(void)notify;
|
||||
#endif
|
||||
|
||||
if (uart_event.type != UART_EVENT_MAX && p_uart->xQueueUart) {
|
||||
if (pdFALSE == xQueueSendFromISR(p_uart->xQueueUart, (void *)&uart_event, &task_woken)) {
|
||||
ESP_EARLY_LOGV(UART_TAG, "UART event queue full");
|
||||
@ -950,6 +970,8 @@ esp_err_t uart_driver_install(uart_port_t uart_num, int rx_buffer_size, int tx_b
|
||||
p_uart_obj[uart_num]->tx_ring_buf = NULL;
|
||||
p_uart_obj[uart_num]->tx_buf_size = 0;
|
||||
}
|
||||
|
||||
p_uart_obj[uart_num]->uart_select_notif_callback = NULL;
|
||||
} else {
|
||||
ESP_LOGE(UART_TAG, "UART driver already installed");
|
||||
return ESP_FAIL;
|
||||
@ -1039,6 +1061,13 @@ esp_err_t uart_driver_delete(uart_port_t uart_num)
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
void uart_set_select_notif_callback(uart_port_t uart_num, uart_select_notif_callback_t uart_select_notif_callback)
|
||||
{
|
||||
if (uart_num < UART_NUM_MAX && p_uart_obj[uart_num]) {
|
||||
p_uart_obj[uart_num]->uart_select_notif_callback = (uart_select_notif_callback_t) uart_select_notif_callback;
|
||||
}
|
||||
}
|
||||
|
||||
esp_err_t uart_set_rx_timeout(uart_port_t uart_num, const uint8_t tout_thresh)
|
||||
{
|
||||
UART_CHECK((uart_num < UART_NUM_MAX), "uart_num error", ESP_ERR_INVALID_ARG);
|
||||
|
@ -40,7 +40,7 @@ void uart_set_select_notif_callback(uart_port_t uart_num, uart_select_notif_call
|
||||
/**
|
||||
* @brief Get mutex guarding select() notifications
|
||||
*/
|
||||
portMUX_TYPE *uart_get_selectlock();
|
||||
void *uart_get_selectlock();
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
Reference in New Issue
Block a user