modm API documentation
modm::platform::BufferedUart< Hal, Buffers > Struct Template Reference

#include <modm/platform/uart/uart.hpp>

Inheritance diagram for modm::platform::BufferedUart< Hal, Buffers >:
modm::platform::UartBase modm::Uart modm::PeripheralDriver

Public Types

enum  Interrupt : uint32_t { Interrupt::ParityError = USART_CR1_PEIE, Interrupt::TxEmpty = USART_CR1_TXEIE, Interrupt::TxComplete = USART_CR1_TCIE, Interrupt::RxNotEmpty = USART_CR1_RXNEIE }
 
enum  InterruptFlag : uint32_t {
  InterruptFlag::TxEmpty = USART_SR_TXE, InterruptFlag::TxComplete = USART_SR_TC, InterruptFlag::RxNotEmpty = USART_SR_RXNE, InterruptFlag::OverrunError = USART_SR_ORE,
  InterruptFlag::FramingError = USART_SR_FE, InterruptFlag::ParityError = USART_SR_PE
}
 
enum  LastBitClockPulse : uint32_t { DoNotOutput = 0b0, Output = USART_CR2_LBCL }
 
enum  Parity : uint32_t { Disabled = 0, Even = USART_CR1_PCE, Odd = USART_CR1_PCE | USART_CR1_PS }
 
enum  SpiClock : uint32_t { Disabled = 0b0, Enabled = USART_CR2_CLKEN }
 
enum  SpiDataMode : uint32_t { Mode0 = 0b00, Mode1 = USART_CR2_CPHA, Mode2 = USART_CR2_CPOL, Mode3 = USART_CR2_CPOL | USART_CR2_CPHA }
 
enum  WordLength : uint32_t { Bit8 = 0, Bit9 = USART_CR1_M }
 

Public Member Functions

 MODM_FLAGS32 (Interrupt)
 
 MODM_FLAGS32 (InterruptFlag)
 

Static Public Member Functions

template<class... Signals>
static void connect (Gpio::InputType InputTypeRx=Gpio::InputType::PullUp, Gpio::OutputType OutputTypeTx=Gpio::OutputType::PushPull)
 
template<class SystemClock , baudrate_t baudrate, percent_t tolerance = pct(1)>
static void initialize (Hal::Parity parity=Hal::Parity::Disabled, Hal::WordLength length=Hal::WordLength::Bit8)
 
static void writeBlocking (uint8_t data)
 
static void writeBlocking (const uint8_t *data, std::size_t length)
 
static void flushWriteBuffer ()
 
static bool write (uint8_t data)
 
static std::size_t write (const uint8_t *data, std::size_t length)
 
static bool isWriteFinished ()
 
static std::size_t transmitBufferSize ()
 
static std::size_t discardTransmitBuffer ()
 
static bool read (uint8_t &data)
 
static std::size_t read (uint8_t *buffer, std::size_t)
 
static std::size_t receiveBufferSize ()
 
static std::size_t discardReceiveBuffer ()
 
static bool hasError ()
 
static void clearError ()
 
static void acknowledgeInterruptFlag ()
 
template<uint64_t available, uint64_t requested, percent_t tolerance>
static void assertBaudrateInTolerance ()
 
template<double available, double requested, percent_t tolerance>
static void assertDurationInTolerance ()
 
static void configurePurpose ()
 configures a peripheral for a specific purpose
 
template<class... Signals>
static void connect ()
 
static bool getInterruptFlag ()
 Read an interrupt flag.
 
static void getParameter ()
 returns a parameter
 
template<class SystemClock , baudrate_t baudrate, percent_t tolerance = 10_pct>
static void initialize ()
 
static void setParameter ()
 sets a parameter
 

Static Public Attributes

static constexpr size_t RxBufferSize = 0
 
static constexpr size_t TxBufferSize = 0
 

Detailed Description

template<class Hal, typename... Buffers>
struct modm::platform::BufferedUart< Hal, Buffers >

Universal asynchronous receiver transmitter (with modular buffers)

Author
Kevin Laeufer
Niklas Hauser
Dima Barsky

Member Enumeration Documentation

enum modm::platform::UartBase::Interrupt : uint32_t
inheritedstrong
Enum ValuesDocumentation
ParityError 

Call interrupt when a parity error occurred.

TxEmpty 

Call interrupt when transmit register is empty (i.e. the byte has been transfered to the shift out register.

TxComplete 

Called when the byte was completely transmitted.

RxNotEmpty 

Call interrupt when char received (RXNE) or overrun occurred (ORE)

enum modm::platform::UartBase::InterruptFlag : uint32_t
inheritedstrong
Enum ValuesDocumentation
TxEmpty 

Set if the transmit data register is empty.

TxComplete 

Set if the transmission is complete.

RxNotEmpty 

Set if the receive data register is not empty.

OverrunError 

Set if receive register was not cleared.

FramingError 

Set if a de-synchronization, excessive noise or a break character is detected.

ParityError 

Set if a parity error was detected.

Member Function Documentation

static void modm::PeripheralDriver::acknowledgeInterruptFlag ( )
inheritedstatic

Acknowledge an interrupt flag.

We use acknowledge here, since it describes the intention rather than the actual implementation.

template<uint64_t available, uint64_t requested, percent_t tolerance>
static void modm::PeripheralDriver::assertBaudrateInTolerance ( )
inheritedinlinestatic

Since baudrates are usually generated by prescaling a system clock, only several distinct values can be generated. This method checks if the user requested baudrate is within error tolerance of the system achievable baudrate.

template<class... Signals>
static void modm::Uart::connect ( )
inheritedstatic

Connect GPIOs to the peripheral and configure them.

This configures the Tx and Rx signals as output and input and connects them.

Template Parameters
SignalsOne Tx and one Rx signal are required and can be passed out-of-order.
template<class SystemClock , baudrate_t baudrate, percent_t tolerance = 10_pct>
static void modm::Uart::initialize ( )
inheritedstatic

Initializes the hardware and sets the baudrate.

Template Parameters
SystemClockthe currently active system clock
baudratedesired baud rate in Hz
tolerancethe allowed absolute tolerance for the resulting baudrate
template<class Hal , typename... Buffers>
template<class SystemClock , baudrate_t baudrate, percent_t tolerance = pct(1)>
static void modm::platform::BufferedUart< Hal, Buffers >::initialize ( Hal::Parity  parity = Hal::Parity::Disabled,
Hal::WordLength  length = Hal::WordLength::Bit8 
)
inlinestatic
Warning
Remember to set word length correctly when using the parity bit!

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