From e27ae40884f17bfa27e4fdac1dd8c446caa12441 Mon Sep 17 00:00:00 2001 From: Moritz Martinius Date: Sun, 15 Dec 2024 12:46:53 +0100 Subject: [PATCH] Clean up usart class a bit --- Core/Inc/usart.hpp | 5 ++++- Core/Src/usart.cpp | 11 +---------- 2 files changed, 5 insertions(+), 11 deletions(-) diff --git a/Core/Inc/usart.hpp b/Core/Inc/usart.hpp index c83b47d..508a582 100644 --- a/Core/Inc/usart.hpp +++ b/Core/Inc/usart.hpp @@ -9,6 +9,10 @@ #include "stm32f4xx_hal_uart.h" namespace driver::usart { + +constexpr const uint8_t TX_BUFSIZE{20}; +constexpr const uint8_t TX_TIMEOUT_MS{200}; + class Usart { public: explicit Usart(USART_TypeDef* usart, uint32_t baudRate, uint32_t wordLength, uint32_t stopBits, @@ -23,6 +27,5 @@ class Usart { UART_HandleTypeDef mHandle{}; void tx(std::string_view range); - void flush(); }; } // namespace driver::usart \ No newline at end of file diff --git a/Core/Src/usart.cpp b/Core/Src/usart.cpp index 93eaf9b..cb507ee 100644 --- a/Core/Src/usart.cpp +++ b/Core/Src/usart.cpp @@ -1,18 +1,13 @@ #include "usart.hpp" -#include #include -#include #include #include "stm32f4xx_hal_uart.h" -#include "usart.h" namespace driver::usart { -constexpr const uint8_t TX_BUFSIZE{20}; - Usart::Usart(USART_TypeDef* usart, uint32_t baudRate, uint32_t wordLength, uint32_t stopBits, uint32_t parity, uint32_t mode, uint32_t hwFlowCtl, uint32_t overSampling) : mHandle{.Instance = usart, @@ -37,14 +32,10 @@ void Usart::println(const std::string_view str) { tx("\r\n"); } -void Usart::flush() { - -}; - void Usart::tx(const std::string_view range) { for (uint32_t pt{0}; pt <= range.size(); pt += TX_BUFSIZE) { HAL_UART_Transmit(&mHandle, reinterpret_cast(range.begin() + pt), - TX_BUFSIZE, 200); + TX_BUFSIZE, TX_TIMEOUT_MS); } };