mirror of
https://git.intern.spaceteamaachen.de/ALPAKA/sta-core.git
synced 2025-06-10 00:36:00 +00:00
44 lines
868 B
C++
44 lines
868 B
C++
#include <sta/stm32/uart.hpp>
|
|
#ifdef STA_STM32_UART_ENABLE
|
|
|
|
#include <sta/assert.hpp>
|
|
|
|
|
|
namespace sta
|
|
{
|
|
STM32UART::STM32UART(UART_HandleTypeDef * handle)
|
|
: handle_{handle}
|
|
{
|
|
STA_ASSERT(handle != nullptr);
|
|
}
|
|
|
|
|
|
void STM32UART::write(const uint8_t * buffer, size_t size)
|
|
{
|
|
STA_ASSERT(buffer != nullptr);
|
|
|
|
HAL_UART_Transmit(handle_, const_cast<uint8_t *>(buffer), size, HAL_MAX_DELAY);
|
|
}
|
|
} // namespace sta
|
|
|
|
|
|
#ifdef STA_STM32_UART_DEBUG_SERIAL
|
|
|
|
// Get extern declaration for DebugSerial because const namespace level variables have internal linkage by default
|
|
#include <sta/debug_serial.hpp>
|
|
|
|
#include <usart.h>
|
|
|
|
namespace sta
|
|
{
|
|
STM32UART gStm32DebugSerial(&STA_STM32_UART_DEBUG_SERIAL);
|
|
|
|
// Used by <sta/debug.hpp>
|
|
PrintableUART DebugSerial(&gStm32DebugSerial);
|
|
} // namespace sta
|
|
|
|
#endif // STA_STM32_UART_DEBUG_SERIAL
|
|
|
|
|
|
#endif // STA_STM32_UART_ENABLE
|