Add HAL UART implementation

This commit is contained in:
Henrik Stickann
2022-04-09 21:49:20 +02:00
parent 03ca528d91
commit 221b455e43
2 changed files with 85 additions and 0 deletions

32
src/hal/uart.cpp Normal file
View File

@@ -0,0 +1,32 @@
#include <sta/hal/uart.hpp>
#ifdef STA_HAL_UART_ENABLE
namespace sta
{
HalUART::HalUART(UART_HandleTypeDef * handle)
: handle_{handle}
{}
void HalUART::write(const uint8_t * buffer, size_t size)
{
HAL_UART_Transmit(handle_, const_cast<uint8_t *>(buffer), size, HAL_MAX_DELAY);
}
} // namespace sta
#ifdef STA_HAL_UART_DEBUG
#include <usart.h>
namespace sta
{
HalUART DebugSerial(&STA_HAL_UART_DEBUG);
} // namespace sta
#endif // STA_HAL_UART_DEBUG
#endif // STA_HAL_UART_ENABLE