theCore C++ embedded framework
Collaboration diagram for UART driver:

Data Structures

struct  ecl::usart_cfg< dev >
 Base template class for the usart configuration. More...
 
class  ecl::usart_bus< dev >
 STM32 USART bus. More...
 

Enumerations

enum  ecl::usart_device {
  ecl::usart_device::dev1, ecl::usart_device::dev2, ecl::usart_device::dev3, ecl::usart_device::dev4,
  ecl::usart_device::dev5, ecl::usart_device::dev6, ecl::usart_device::dev7, ecl::usart_device::dev8
}
 Represents distinct peripheral devices. More...
 

Functions

static ecl::err ecl::usart_bus< dev >::init ()
 Lazy initialization. More...
 
static void ecl::usart_bus< dev >::set_rx (uint8_t *rx, size_t size)
 Sets rx buffer with given size. More...
 
static void ecl::usart_bus< dev >::set_tx (size_t size, uint8_t fill_byte=0xff)
 Sets tx buffer made-up from sequence of similar bytes. More...
 
static void ecl::usart_bus< dev >::set_tx (const uint8_t *tx, size_t size)
 Sets tx buffer with given size. More...
 
static void ecl::usart_bus< dev >::set_handler (const handler_fn &handler)
 Sets event handler. More...
 
static void ecl::usart_bus< dev >::reset_buffers ()
 Reset xfer buffers. More...
 
static void ecl::usart_bus< dev >::reset_handler ()
 Resets previously set handler. More...
 
static ecl::err ecl::usart_bus< dev >::do_xfer ()
 Executes xfer, using buffers previously set. More...
 
static ecl::err ecl::usart_bus< dev >::do_rx ()
 Executes rx transfer, using rx buffer previously set. More...
 
static ecl::err ecl::usart_bus< dev >::do_tx ()
 Executes tx transfer, using tx buffer previously set. More...
 
static ecl::err ecl::usart_bus< dev >::cancel_xfer ()
 Cancels xfer. More...
 
static ecl::err ecl::usart_bus< dev >::cancel_rx ()
 Cancels xfer on rx. More...
 
static ecl::err ecl::usart_bus< dev >::cancel_tx ()
 Cancels xfer on tx. More...
 
static ecl::err ecl::usart_bus< dev >::enable_listen_mode ()
 Enables listen mode. More...
 
static ecl::err ecl::usart_bus< dev >::disable_listen_mode ()
 Disables listen mode. More...
 

Detailed Description

Enumeration Type Documentation

◆ usart_device

enum ecl::usart_device
strong

Represents distinct peripheral devices.

Enumerator
dev1 
dev2 
dev3 
dev4 
dev5 
dev6 
dev7 
dev8 

Function Documentation

◆ init()

template<usart_device dev>
ecl::err ecl::usart_bus< dev >::init ( )
static

Lazy initialization.

Returns
Status of operation.
Here is the call graph for this function:

◆ set_rx()

template<usart_device dev>
void ecl::usart_bus< dev >::set_rx ( uint8_t *  rx,
size_t  size 
)
static

Sets rx buffer with given size.

Parameters
[in,out]rxBuffer to write data to. Optional.
[in]sizeSize

◆ set_tx() [1/2]

template<usart_device dev>
void ecl::usart_bus< dev >::set_tx ( size_t  size,
uint8_t  fill_byte = 0xff 
)
static

Sets tx buffer made-up from sequence of similar bytes.

Parameters
[in]sizeSize of sequence
[in]fill_byteByte to fill a sequence. Optional.

◆ set_tx() [2/2]

template<usart_device dev>
void ecl::usart_bus< dev >::set_tx ( const uint8_t *  tx,
size_t  size 
)
static

Sets tx buffer with given size.

Parameters
[in]txBuffer to transmit. Optional.
[in]sizeBuffer size.

◆ set_handler()

template<usart_device dev>
void ecl::usart_bus< dev >::set_handler ( const handler_fn handler)
static

Sets event handler.

Handler will be used by the bus, until reset_handler() will be called.

Parameters
[in]handlerHandler itself.

◆ reset_buffers()

template<usart_device dev>
void ecl::usart_bus< dev >::reset_buffers ( )
static

Reset xfer buffers.

Buffers that were set by

See also
set_tx() and
set_rx() will be no longer used after this call.

◆ reset_handler()

template<usart_device dev>
void ecl::usart_bus< dev >::reset_handler ( )
static

Resets previously set handler.

◆ do_xfer()

template<usart_device dev>
ecl::err ecl::usart_bus< dev >::do_xfer ( )
static

Executes xfer, using buffers previously set.

When it will be done, handler will be invoked.

Returns
Status of operation.

◆ do_rx()

template<usart_device dev>
ecl::err ecl::usart_bus< dev >::do_rx ( )
static

Executes rx transfer, using rx buffer previously set.

When it will be done, handler will be invoked.

Returns
Status of operation.

◆ do_tx()

template<usart_device dev>
ecl::err ecl::usart_bus< dev >::do_tx ( )
static

Executes tx transfer, using tx buffer previously set.

When it will be done, handler will be invoked.

Returns
Status of operation.

◆ cancel_xfer()

template<usart_device dev>
ecl::err ecl::usart_bus< dev >::cancel_xfer ( )
static

Cancels xfer.

After this call no xfer will occur.

Returns
Status of operation.

◆ cancel_rx()

template<usart_device dev>
ecl::err ecl::usart_bus< dev >::cancel_rx ( )
static

Cancels xfer on rx.

After this call no rx transfer will occur.

Returns
Status of opetation.
Here is the call graph for this function:

◆ cancel_tx()

template<usart_device dev>
ecl::err ecl::usart_bus< dev >::cancel_tx ( )
static

Cancels xfer on tx.

After this call no tx transfer will occur.

Returns
Status of opetation.
Here is the call graph for this function:

◆ enable_listen_mode()

template<usart_device dev>
ecl::err ecl::usart_bus< dev >::enable_listen_mode ( )
static

Enables listen mode.

In listen mode, UART bus uses different semantics of the transfer complete event. transfer complete will be generated with every byte received. bus_handler will be called with total argument that equal to current count of bytes written to the buffer.

Note
Can be called from ISR.

◆ disable_listen_mode()

template<usart_device dev>
ecl::err ecl::usart_bus< dev >::disable_listen_mode ( )
static

Disables listen mode.

Note
Can be called from ISR. Changes buffer usage and transfer compelte event semantics back to normal.