/** * @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 #ifdef STA_PLATFORM_STM32 # include # 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 /** * @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 * @param settings UART settings * @param mutex Mutex for thread safety */ STM32UART(UART_HandleTypeDef * handle, UARTSettings & settings, Mutex * mutex); void transfer(uint8_t value) override; void transfer16(uint16_t value) override; void transfer(const uint8_t * buffer, size_t size) override; void receive(uint8_t * buffer, size_t size) override; void fill(uint8_t value, size_t count) override; private: UART_HandleTypeDef * handle_; /**< STM32 HAL handle */ }; } // namespace sta #endif // STA_STM32_UART_ENABLED #endif // STA_CORE_STM32_UART_HPP