mirror of
https://git.intern.spaceteamaachen.de/ALPAKA/sta-core.git
synced 2025-06-12 01:25:59 +00:00
44 lines
844 B
C++
44 lines
844 B
C++
#include <sta/hal/uart.hpp>
|
|
#ifdef STA_HAL_UART_ENABLE
|
|
|
|
#include <sta/assert.hpp>
|
|
|
|
|
|
namespace sta
|
|
{
|
|
HalUART::HalUART(UART_HandleTypeDef * handle)
|
|
: handle_{handle}
|
|
{
|
|
STA_ASSERT(handle != nullptr);
|
|
}
|
|
|
|
|
|
void HalUART::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_HAL_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
|
|
{
|
|
HalUART gHalDebugSerial(&STA_HAL_UART_DEBUG_SERIAL);
|
|
|
|
// Used by <sta/debug.hpp>
|
|
UART * const DebugSerial = &gHalDebugSerial;
|
|
} // namespace sta
|
|
|
|
#endif // STA_HAL_UART_DEBUG_SERIAL
|
|
|
|
|
|
#endif // STA_HAL_UART_ENABLE
|