diff options
author | Oxore <oxore@protonmail.com> | 2023-03-09 01:42:59 +0300 |
---|---|---|
committer | Oxore <oxore@protonmail.com> | 2023-03-09 01:42:59 +0300 |
commit | 34746d3783af1ae601487c88f0a7e44f81842618 (patch) | |
tree | 508a849e81e1f7a83e1df053719579e4452b4e35 /app/platform/stm32f0-gcc/retarget.cpp | |
parent | 8370de05bb807f02c0077ba59c68053b283671e2 (diff) |
Impl UART buffering (still not tested)
Diffstat (limited to 'app/platform/stm32f0-gcc/retarget.cpp')
-rw-r--r-- | app/platform/stm32f0-gcc/retarget.cpp | 18 |
1 files changed, 9 insertions, 9 deletions
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<void *>(USART1), }, - { FileType::kUART, O_NONBLOCK, reinterpret_cast<void *>(USART1), }, - { FileType::kUARTDirect, 0, reinterpret_cast<void *>(USART1), }, - { FileType::kUART, O_NONBLOCK, reinterpret_cast<void *>(USART3), }, - { FileType::kUART, O_NONBLOCK, reinterpret_cast<void *>(USART4), }, + { FileType::kUART, O_NONBLOCK, reinterpret_cast<void *>(&g_uart1), }, // STDIN_FILENO + { FileType::kUART, O_NONBLOCK, reinterpret_cast<void *>(&g_uart1), }, // STDOUT_FILENO + { FileType::kUARTDirect, 0, reinterpret_cast<void *>(&g_uart1), }, // STDERR_FILENO + { FileType::kUART, O_NONBLOCK, reinterpret_cast<void *>(&g_uart3), }, // WIFI_FILENO + { FileType::kUART, O_NONBLOCK, reinterpret_cast<void *>(&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<USART_TypeDef*>(file->extra), buf, nbytes); + ret = UARTRead(reinterpret_cast<UART*>(file->extra), buf, nbytes); break; case FileType::kUARTDirect: - ret = UARTReadDirect(reinterpret_cast<USART_TypeDef*>(file->extra), buf, nbytes); + ret = UARTReadDirect(reinterpret_cast<UART*>(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<USART_TypeDef*>(file->extra), buf, nbytes); + ret = UARTWrite(reinterpret_cast<UART*>(file->extra), buf, nbytes); break; case FileType::kUARTDirect: - ret = UARTWriteDirect(reinterpret_cast<USART_TypeDef*>(file->extra), buf, nbytes); + ret = UARTWriteDirect(reinterpret_cast<UART*>(file->extra), buf, nbytes); break; } return ret; |