mirror of
https://github.com/espressif/esp-idf.git
synced 2025-08-01 03:34:32 +02:00
vfs: implement fsync for UART VFS
This commit is contained in:
@@ -26,6 +26,7 @@
|
|||||||
#include "driver/uart.h"
|
#include "driver/uart.h"
|
||||||
#include "sdkconfig.h"
|
#include "sdkconfig.h"
|
||||||
#include "driver/uart_select.h"
|
#include "driver/uart_select.h"
|
||||||
|
#include "rom/uart.h"
|
||||||
|
|
||||||
// TODO: make the number of UARTs chip dependent
|
// TODO: make the number of UARTs chip dependent
|
||||||
#define UART_NUM 3
|
#define UART_NUM 3
|
||||||
@@ -304,6 +305,15 @@ static int uart_access(const char *path, int amode)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int uart_fsync(int fd)
|
||||||
|
{
|
||||||
|
assert(fd >= 0 && fd < 3);
|
||||||
|
_lock_acquire_recursive(&s_uart_write_locks[fd]);
|
||||||
|
uart_tx_wait_idle((uint8_t) fd);
|
||||||
|
_lock_release_recursive(&s_uart_write_locks[fd]);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
static void select_notif_callback(uart_port_t uart_num, uart_select_notif_t uart_select_notif, BaseType_t *task_woken)
|
static void select_notif_callback(uart_port_t uart_num, uart_select_notif_t uart_select_notif, BaseType_t *task_woken)
|
||||||
{
|
{
|
||||||
switch (uart_select_notif) {
|
switch (uart_select_notif) {
|
||||||
@@ -883,6 +893,7 @@ void esp_vfs_dev_uart_register()
|
|||||||
.close = &uart_close,
|
.close = &uart_close,
|
||||||
.read = &uart_read,
|
.read = &uart_read,
|
||||||
.fcntl = &uart_fcntl,
|
.fcntl = &uart_fcntl,
|
||||||
|
.fsync = &uart_fsync,
|
||||||
.access = &uart_access,
|
.access = &uart_access,
|
||||||
.start_select = &uart_start_select,
|
.start_select = &uart_start_select,
|
||||||
.end_select = &uart_end_select,
|
.end_select = &uart_end_select,
|
||||||
|
Reference in New Issue
Block a user