From 34746d3783af1ae601487c88f0a7e44f81842618 Mon Sep 17 00:00:00 2001 From: Oxore Date: Thu, 9 Mar 2023 01:42:59 +0300 Subject: Impl UART buffering (still not tested) --- app/platform/stm32f0-gcc/retarget.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'app/platform/stm32f0-gcc/retarget.cpp') diff --git a/app/platform/stm32f0-gcc/retarget.cpp b/app/platform/stm32f0-gcc/retarget.cpp index 8b8160f..a6706d3 100644 --- a/app/platform/stm32f0-gcc/retarget.cpp +++ b/app/platform/stm32f0-gcc/retarget.cpp @@ -31,11 +31,11 @@ struct File static constexpr size_t kFilesCount = 5; static File files[5] { - { FileType::kUART, O_NONBLOCK, reinterpret_cast(USART1), }, - { FileType::kUART, O_NONBLOCK, reinterpret_cast(USART1), }, - { FileType::kUARTDirect, 0, reinterpret_cast(USART1), }, - { FileType::kUART, O_NONBLOCK, reinterpret_cast(USART3), }, - { FileType::kUART, O_NONBLOCK, reinterpret_cast(USART4), }, + { FileType::kUART, O_NONBLOCK, reinterpret_cast(&g_uart1), }, // STDIN_FILENO + { FileType::kUART, O_NONBLOCK, reinterpret_cast(&g_uart1), }, // STDOUT_FILENO + { FileType::kUARTDirect, 0, reinterpret_cast(&g_uart1), }, // STDERR_FILENO + { FileType::kUART, O_NONBLOCK, reinterpret_cast(&g_uart3), }, // WIFI_FILENO + { FileType::kUART, O_NONBLOCK, reinterpret_cast(&g_uart4), }, // GPS_FILENO }; int errno{}; @@ -91,10 +91,10 @@ extern "C" ssize_t read(int fd, void *buf, size_t nbytes) size_t ret{}; switch (file->type) { case FileType::kUART: - ret = UARTRead(reinterpret_cast(file->extra), buf, nbytes); + ret = UARTRead(reinterpret_cast(file->extra), buf, nbytes); break; case FileType::kUARTDirect: - ret = UARTReadDirect(reinterpret_cast(file->extra), buf, nbytes); + ret = UARTReadDirect(reinterpret_cast(file->extra), buf, nbytes); break; } return ret; @@ -110,10 +110,10 @@ extern "C" ssize_t write(int fd, const void *buf, size_t nbytes) size_t ret{}; switch (file->type) { case FileType::kUART: - ret = UARTWrite(reinterpret_cast(file->extra), buf, nbytes); + ret = UARTWrite(reinterpret_cast(file->extra), buf, nbytes); break; case FileType::kUARTDirect: - ret = UARTWriteDirect(reinterpret_cast(file->extra), buf, nbytes); + ret = UARTWriteDirect(reinterpret_cast(file->extra), buf, nbytes); break; } return ret; -- cgit v1.2.3