OpenMPTL - STM32 (common)
C++ Microprocessor Template Library
Classes | Public Types | Static Public Member Functions | Static Public Attributes | List of all members
mptl::usart_stm32_common< _usart_no, system_clock_type > Class Template Reference

#include <usart.hpp>

Classes

struct  clock_phase
 
struct  clock_polarity
 
struct  flow_control
 
struct  parity
 

Public Types

using USARTx = USART< usart_no >
 
using irq = irq::usart< usart_no >
 
using resources = rcc_usart_clock_resources< usart_no >
 
using enable_rx = regval< typename USARTx::CR1::RE, 1 >
 
using enable_tx = regval< typename USARTx::CR1::TE, 1 >
 
template<unsigned value>
using baud_rate = typename baud_rate_impl< value >::type
 
template<unsigned value>
using word_length = typename word_length_impl< value >::type
 
template<unsigned a, unsigned b = 0>
using stop_bits = typename stop_bits_impl< a, b >::type
 
using clock_enable = regval< typename USARTx::CR2::CLKEN, 1 >
 
using last_bit_clock_pulse = regval< typename USARTx::CR2::LBCL, 1 >
 

Static Public Member Functions

static USARTx::BRR::value_type baud_to_brr (unsigned baud_rate)
 
template<typename... Tp>
static void configure (void)
 Configure USART register using Tp type traits. More...
 
static void set_baudrate (unsigned value)
 Set the BRR register to the value corresponding to the baud_rate provided. More...
 
static void send (typename USARTx::DR::value_type data)
 
static USARTx::DR::value_type receive (void)
 
static void enable (void)
 
static void disable (void)
 
static void enable_interrupt (bool rxne, bool txe=false, bool pe=false, bool tc=false, bool idle=false)
 
static void disable_interrupt (bool rxne, bool txe=false, bool pe=false, bool tc=false, bool idle=false)
 
static void enable_tx_interrupt (void)
 
static void disable_tx_interrupt (void)
 

Static Public Attributes

static constexpr unsigned usart_no = _usart_no
 

Member Typedef Documentation

◆ baud_rate

template<unsigned _usart_no, typename system_clock_type >
template<unsigned value>
using mptl::usart_stm32_common< _usart_no, system_clock_type >::baud_rate = typename baud_rate_impl<value>::type

◆ clock_enable

template<unsigned _usart_no, typename system_clock_type >
using mptl::usart_stm32_common< _usart_no, system_clock_type >::clock_enable = regval< typename USARTx::CR2::CLKEN, 1 >

◆ enable_rx

template<unsigned _usart_no, typename system_clock_type >
using mptl::usart_stm32_common< _usart_no, system_clock_type >::enable_rx = regval< typename USARTx::CR1::RE, 1 >

◆ enable_tx

template<unsigned _usart_no, typename system_clock_type >
using mptl::usart_stm32_common< _usart_no, system_clock_type >::enable_tx = regval< typename USARTx::CR1::TE, 1 >

◆ irq

template<unsigned _usart_no, typename system_clock_type >
using mptl::usart_stm32_common< _usart_no, system_clock_type >::irq = irq::usart<usart_no>

◆ last_bit_clock_pulse

template<unsigned _usart_no, typename system_clock_type >
using mptl::usart_stm32_common< _usart_no, system_clock_type >::last_bit_clock_pulse = regval< typename USARTx::CR2::LBCL, 1 >

◆ resources

template<unsigned _usart_no, typename system_clock_type >
using mptl::usart_stm32_common< _usart_no, system_clock_type >::resources = rcc_usart_clock_resources<usart_no>

◆ stop_bits

template<unsigned _usart_no, typename system_clock_type >
template<unsigned a, unsigned b = 0>
using mptl::usart_stm32_common< _usart_no, system_clock_type >::stop_bits = typename stop_bits_impl<a,b>::type

◆ USARTx

template<unsigned _usart_no, typename system_clock_type >
using mptl::usart_stm32_common< _usart_no, system_clock_type >::USARTx = USART<usart_no>

◆ word_length

template<unsigned _usart_no, typename system_clock_type >
template<unsigned value>
using mptl::usart_stm32_common< _usart_no, system_clock_type >::word_length = typename word_length_impl<value>::type

Member Function Documentation

◆ baud_to_brr()

template<unsigned _usart_no, typename system_clock_type >
static USARTx::BRR::value_type mptl::usart_stm32_common< _usart_no, system_clock_type >::baud_to_brr ( unsigned  baud_rate)
inlinestatic

◆ configure()

template<unsigned _usart_no, typename system_clock_type >
template<typename... Tp>
static void mptl::usart_stm32_common< _usart_no, system_clock_type >::configure ( void  )
inlinestatic

NOTE: make sure no communication is ongoing when calling this function.

◆ disable()

template<unsigned _usart_no, typename system_clock_type >
static void mptl::usart_stm32_common< _usart_no, system_clock_type >::disable ( void  )
inlinestatic

◆ disable_interrupt()

template<unsigned _usart_no, typename system_clock_type >
static void mptl::usart_stm32_common< _usart_no, system_clock_type >::disable_interrupt ( bool  rxne,
bool  txe = false,
bool  pe = false,
bool  tc = false,
bool  idle = false 
)
inlinestatic
Parameters
rxneread data register not empty interrupt
txetransmitter data register empty interrupt
peparity error interrupt
tctransmission complete interrupt
idleidle interrupt

◆ disable_tx_interrupt()

template<unsigned _usart_no, typename system_clock_type >
static void mptl::usart_stm32_common< _usart_no, system_clock_type >::disable_tx_interrupt ( void  )
inlinestatic

◆ enable()

template<unsigned _usart_no, typename system_clock_type >
static void mptl::usart_stm32_common< _usart_no, system_clock_type >::enable ( void  )
inlinestatic

◆ enable_interrupt()

template<unsigned _usart_no, typename system_clock_type >
static void mptl::usart_stm32_common< _usart_no, system_clock_type >::enable_interrupt ( bool  rxne,
bool  txe = false,
bool  pe = false,
bool  tc = false,
bool  idle = false 
)
inlinestatic
Parameters
rxneread data register not empty interrupt
txetransmitter data register empty interrupt
peparity error interrupt
tctransmission complete interrupt
idleidle interrupt

◆ enable_tx_interrupt()

template<unsigned _usart_no, typename system_clock_type >
static void mptl::usart_stm32_common< _usart_no, system_clock_type >::enable_tx_interrupt ( void  )
inlinestatic

◆ receive()

template<unsigned _usart_no, typename system_clock_type >
static USARTx::DR::value_type mptl::usart_stm32_common< _usart_no, system_clock_type >::receive ( void  )
inlinestatic

◆ send()

template<unsigned _usart_no, typename system_clock_type >
static void mptl::usart_stm32_common< _usart_no, system_clock_type >::send ( typename USARTx::DR::value_type  data)
inlinestatic

◆ set_baudrate()

template<unsigned _usart_no, typename system_clock_type >
static void mptl::usart_stm32_common< _usart_no, system_clock_type >::set_baudrate ( unsigned  value)
inlinestatic

NOTE: make sure no communication is ongoing when calling this function.

Member Data Documentation

◆ usart_no

template<unsigned _usart_no, typename system_clock_type >
constexpr unsigned mptl::usart_stm32_common< _usart_no, system_clock_type >::usart_no = _usart_no
static

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