stm32f103
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
UartDevice Class Reference

Implements device-level abstraction for UART devices. More...

#include <uart_device.h>

Classes

struct  Config
 Configuration for UART device. More...
 

Public Types

enum  Devices {
  kUart1, kUart2, kUart3, kUart4,
  kUart5
}
 UART devices enumeration. More...
 
using Listener = std::function< void(const uint8_t)>
 UART RX Listener type definition. More...
 

Public Member Functions

 UartDevice (const Config &config)
 Constructor for UART device. More...
 
void SetListener (Listener &&listener)
 Sets and enables RX listener for this device. More...
 
void TxByte (const uint8_t byte)
 Transmites one byte. More...
 
void Tx (const char *data,...)
 Transmits a formatted string. More...
 
void Tx (const std::string &s)
 Transmits a string. More...
 

Static Public Member Functions

static ListenerInvokeListener (const uint8_t uart_port)
 Invokes the external listener. More...
 

Detailed Description

Implements device-level abstraction for UART devices.

Member Typedef Documentation

using UartDevice::Listener = std::function<void(const uint8_t)>

UART RX Listener type definition.

Member Enumeration Documentation

UART devices enumeration.

Enumerator
kUart1 
kUart2 
kUart3 
kUart4 
kUart5 

Constructor & Destructor Documentation

UartDevice::UartDevice ( const Config config)
explicit

Constructor for UART device.

Parameters
configUART device configuration. See UartDevice::Config.

Member Function Documentation

static Listener& UartDevice::InvokeListener ( const uint8_t  uart_port)
inlinestatic

Invokes the external listener.

Parameters
uart_portUART Port ID
Returns
External listener corresponding to the UART port
void UartDevice::SetListener ( Listener &&  listener)

Sets and enables RX listener for this device.

Parameters
listenerExternal listener function to trigger.
void UartDevice::Tx ( const char *  data,
  ... 
)

Transmits a formatted string.

Parameters
dataFormatted string
...Variables
void UartDevice::Tx ( const std::string &  s)

Transmits a string.

Parameters
sString to transmit
void UartDevice::TxByte ( const uint8_t  byte)

Transmites one byte.

Parameters
byteCharacter to transmit

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