mirror of
https://github.com/espressif/ESP8266_RTOS_SDK.git
synced 2025-08-05 22:11:04 +08:00
feat(vfs): Modify for esp8266
This commit is contained in:
@ -1,7 +1,9 @@
|
||||
set(COMPONENT_SRCS "vfs.c"
|
||||
"vfs_uart.c")
|
||||
set(COMPONENT_ADD_INCLUDEDIRS "include")
|
||||
if(CONFIG_USING_ESP_VFS)
|
||||
set(COMPONENT_SRCS "vfs.c"
|
||||
"vfs_uart.c")
|
||||
set(COMPONENT_ADD_INCLUDEDIRS "include")
|
||||
|
||||
set(COMPONENT_REQUIRES)
|
||||
set(COMPONENT_REQUIRES)
|
||||
|
||||
register_component()
|
||||
register_component()
|
||||
endif()
|
||||
|
@ -1,8 +1,16 @@
|
||||
menu "Virtual file system"
|
||||
|
||||
config USING_ESP_VFS
|
||||
bool "Using espressif VFS"
|
||||
default y
|
||||
help
|
||||
Enable this option, espressif VFS can be used. Users can use APIs like "open", "read", "write"
|
||||
and so on to operate I/O device which is registered.
|
||||
|
||||
config SUPPRESS_SELECT_DEBUG_OUTPUT
|
||||
bool "Suppress select() related debug outputs"
|
||||
default y
|
||||
depends on USING_ESP_VFS
|
||||
help
|
||||
Select() related functions might produce an unconveniently lot of
|
||||
debug outputs when one sets the default log level to DEBUG or higher.
|
||||
@ -12,6 +20,7 @@ config SUPPRESS_SELECT_DEBUG_OUTPUT
|
||||
config SUPPORT_TERMIOS
|
||||
bool "Add support for termios.h"
|
||||
default y
|
||||
depends on USING_ESP_VFS
|
||||
help
|
||||
Disabling this option can save memory when the support for termios.h is not required.
|
||||
|
||||
|
@ -3,3 +3,8 @@
|
||||
#
|
||||
# (Uses default behaviour of compiling all source files in directory, adding 'include' to include path.)
|
||||
|
||||
ifndef CONFIG_USING_ESP_VFS
|
||||
COMPONENT_ADD_INCLUDEDIRS :=
|
||||
COMPONENT_SRCDIRS :=
|
||||
endif
|
||||
|
||||
|
@ -22,13 +22,23 @@
|
||||
#include "esp_vfs.h"
|
||||
#include "esp_vfs_dev.h"
|
||||
#include "esp_attr.h"
|
||||
#include "soc/uart_struct.h"
|
||||
#include "esp8266/uart_struct.h"
|
||||
#include "driver/uart_select.h"
|
||||
#include "driver/uart.h"
|
||||
#include "sdkconfig.h"
|
||||
#include "driver/uart_select.h"
|
||||
|
||||
#ifdef portENTER_CRITICAL
|
||||
#undef portENTER_CRITICAL
|
||||
#define portENTER_CRITICAL(_lock) vPortEnterCritical()
|
||||
#endif
|
||||
|
||||
#ifdef portEXIT_CRITICAL
|
||||
#undef portEXIT_CRITICAL
|
||||
#define portEXIT_CRITICAL(_lock) vPortExitCritical()
|
||||
#endif
|
||||
|
||||
// TODO: make the number of UARTs chip dependent
|
||||
#define UART_NUM 3
|
||||
#define UART_NUM 2
|
||||
|
||||
// Token signifying that no character is available
|
||||
#define NONE -1
|
||||
@ -47,12 +57,12 @@ 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};
|
||||
// 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 };
|
||||
static int s_peek_char[UART_NUM] = { 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.
|
||||
@ -94,12 +104,12 @@ 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
|
||||
};
|
||||
|
||||
// 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
|
||||
};
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user