theCore C++ embedded framework
ecl::usart_cfg< dev > Struct Template Reference

Base template class for the usart configuration. More...

#include </home/travis/build/forGGe/theCore/platform/stm32/export/aux/usart_bus.hpp>

Detailed Description

template<usart_device dev>
struct ecl::usart_cfg< dev >

Base template class for the usart configuration.

User must create template specialization for required USART device. Usart configuration class must contain following constexpr fields:

  • uint32_t baudrate - Configures the USART communication baud rate
  • uint16_t word_len - Specifies the number of data bits transmitted or received. This member can be a value of USART_Word_Length (see STM32 SPL).
  • uint16_t stop_bit - Specifies the number of stop bits transmitted. This member can be a value of USART_Stop_Bits (see STM32 SPL).
  • uint16_t parity - Specifies the parity mode. This member can be a value of USART_Parity (see STM32 SPL).
  • uint16_t mode - Specifies wether the Receive or Transmit mode is enabled or disabled. This member can be a value of USART_Modes (see STM32 SPL).
  • uint16_t hw_flow - Specifies wether the hardware flow control mode is enabled or disabled. This member can be a value of USART_Hardware_Flow_Control (see STM32 SPL).
USART configuration example.
In order to use this configuration class one must create configuration class in the ecl namespace before any acccess to usart_bus instance.
template<>
struct usart_cfg< usart_device::dev3 >
{
static auto constexpr baudrate = 115200;
static auto constexpr word_len = USART_WordLength_8b;
static auto constexpr stop_bit = USART_StopBits_1;
static auto constexpr parity = USART_Parity_No;
static auto constexpr mode = USART_Mode_Rx | USART_Mode_Tx;
static auto constexpr hw_flow = USART_HardwareFlowControl_None;
};
Warning
To avoid potential problems with multiple configurations for single USART bus, make sure that full specialization is placed in the header included (directly or indirectly) by all dependent modules.. Thus, redefinition of the config class for given USART will result in compilation errors. Good practice is to place all USART configuration class in the single target-related header.

The documentation for this struct was generated from the following file: