sta-core/include/sta/hal/uart.hpp
2022-05-02 13:37:44 +02:00

44 lines
824 B
C++

/**
* @brief Implementation of UART using HAL.
*
* Configuration:
* STA_HAL_UART_ENABLE: Enable module
* STA_HAL_UART_DEBUG_SERIAL: Create global `sta::DebugSerial` object using this UART instance
*/
#ifndef STA_HAL_UART_HPP
#define STA_HAL_UART_HPP
#include <sta/config.hpp>
#ifdef STA_HAL_UART_ENABLE
#include <sta/hal.hpp>
#include <sta/intf/uart.hpp>
namespace sta
{
/**
* @brief Implementation of `UART` interface using HAL.
*/
class HalUART : public UART
{
public:
/**
* @param handle UART handle
*/
HalUART(UART_HandleTypeDef * handle);
using UART::print;
void write(const uint8_t * buffer, size_t size) override;
private:
UART_HandleTypeDef * handle_; /**< UART handle */
};
} // namespace sta
#endif // STA_HAL_UART_ENABLE
#endif // STA_HAL_UART_HPP