modm API documentation
modm::platform::UartHal4 Class Reference

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

Inheritance diagram for modm::platform::UartHal4:
modm::platform::UartBase

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

static void enable ()
 
static void disable ()
 Disables the hw module (by disabling its clock line)
 
static void enableOperation ()
 Set the UE (USART enable) bit.
 
static void disableOperation ()
 Clear the UE (USART enable) bit.
 
template<class SystemClock , baudrate_t baudrate, percent_t tolerance>
static void initialize (Parity parity, WordLength length)
 
static void write (uint16_t data)
 Write a single byte to the transmit register. More...
 
static void read (uint8_t &data)
 
static void read (uint16_t &data)
 
static void setTransmitterEnable (bool enable)
 
static void setReceiverEnable (bool enable)
 
static bool isReceiveRegisterNotEmpty ()
 Returns true if data has been received.
 
static bool isTransmitRegisterEmpty ()
 Returns true if data can be written.
 
static bool isTransmissionComplete ()
 Returns true if the transmission of a frame containing data is complete.
 
static void enableInterruptVector (bool enable, uint32_t priority)
 
static void enableInterrupt (Interrupt_t interrupt)
 
static void disableInterrupt (Interrupt_t interrupt)
 
static void setInterruptPriority (uint32_t priority)
 
static InterruptFlag_t getInterruptFlags ()
 
static void acknowledgeInterruptFlags (InterruptFlag_t flags)
 

Static Public Attributes

static constexpr bool isExtended = false
 
static const Peripheral UartPeripheral = Peripheral::Uart4
 
static modm::inplace_function< bool (bool)> InterruptCallback
 

Detailed Description

Universal asynchronous receiver transmitter (UartHal4)

Not available on the low- and medium density devices.

Very basic implementation that exposes more hardware features than the regular Usart classes.

Author
Kevin Laeufer

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::platform::UartHal4::enable ( )
inlinestatic

Enables the clock, resets the hardware

Warning
Call enableOperation() to start the peripheral!
template<class SystemClock , baudrate_t baudrate, percent_t tolerance>
static void modm::platform::UartHal4::initialize ( Parity  parity,
WordLength  length 
)
inlinestatic
Warning
Call enableOperation() after this to start the peripheral!
static void modm::platform::UartHal4::read ( uint8_t &  data)
inlinestatic

Saves the value of the receive register to data

Warning
This method does NOT do any sanity checks!! It is your responsibility to check if the register contains something useful!
static void modm::platform::UartHal4::write ( uint16_t  data)
inlinestatic

Write a single byte to the transmit register.

Warning
This method does NOT do any sanity checks!! It is your responsibility to check if the register is empty!

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