2023-02-02 22:22:14 +01:00

57 lines
1.1 KiB
C++

/**
* @file
* @brief Implementation of UART using STM32 HAL.
*/
#ifndef STA_CORE_STM32_UART_HPP
#define STA_CORE_STM32_UART_HPP
// Only enable module on STM32 platform w/ HAL UART module enabled
#include <sta/config.hpp>
#ifdef STA_PLATFORM_STM32
# include <sta/stm32/hal.hpp>
# ifdef HAL_UART_MODULE_ENABLED
# define STA_STM32_UART_ENABLED
# endif // HAL_UART_MODULE_ENABLED
#endif // STA_PLATFORM_STM32
#if defined(STA_STM32_UART_ENABLED) || defined(DOXYGEN)
#include <sta/uart.hpp>
/**
* @defgroup sta_core_stm32_uart UART
* @ingroup sta_core_stm32
* @brief STM32 UART module.
*/
namespace sta
{
/**
* @brief Implementation of UART interface using HAL.
*
* @ingroup sta_core_stm32_uart
*/
class STM32UART : public UART
{
public:
/**
* @param handle STM32 HAL handle
*/
STM32UART(UART_HandleTypeDef * handle);
void write(const uint8_t * buffer, size_t size) override;
private:
UART_HandleTypeDef * handle_; /**< STM32 HAL handle */
};
} // namespace sta
#endif // STA_STM32_UART_ENABLED
#endif // STA_CORE_STM32_UART_HPP