Corium 1.1.0
High-Performance Zero-Heap C++20 MPSC Application Runtime
Loading...
Searching...
No Matches
corium::embedded::DmaUartRxBuffer< BufferSize > Class Template Reference

Statically-allocated circular DMA UART RX buffer. More...

#include <DmaUartAdapter.hpp>

+ Inheritance diagram for corium::embedded::DmaUartRxBuffer< BufferSize >:
+ Collaboration diagram for corium::embedded::DmaUartRxBuffer< BufferSize >:

Public Member Functions

const uint8_t * dmaBuffer () const noexcept
 Const pointer to raw memory buffer.
 
uint8_t * dmaBuffer () noexcept
 Direct pointer to raw memory buffer for DMA peripheral configuration (e.g. HAL_UART_Receive_DMA).
 
constexpr DmaUartRxBuffer ()=default
 
template<typename Callback >
void processAvailableBytes (std::size_t currentDmaWriteIndex, Callback &&onPacket)
 Update tail position based on hardware DMA counter and extract available bytes. Typically invoked from UART Idle Line ISR or DMA Half/Full Transfer ISR.
 
void reset () noexcept
 Reset circular tail index.
 
std::size_t tail () const noexcept
 Current tail index in the circular buffer.
 

Static Public Member Functions

static constexpr std::size_t capacity () noexcept
 Capacity of circular DMA buffer in bytes.
 

Detailed Description

template<std::size_t BufferSize = 512>
class corium::embedded::DmaUartRxBuffer< BufferSize >

Statically-allocated circular DMA UART RX buffer.

Template Parameters
BufferSizeCircular buffer capacity in bytes (must be power of two).

Constructor & Destructor Documentation

◆ DmaUartRxBuffer()

template<std::size_t BufferSize = 512>
constexpr corium::embedded::DmaUartRxBuffer< BufferSize >::DmaUartRxBuffer ( )
constexprdefault

Member Function Documentation

◆ capacity()

template<std::size_t BufferSize = 512>
static constexpr std::size_t corium::embedded::DmaUartRxBuffer< BufferSize >::capacity ( )
inlinestaticconstexprnoexcept

Capacity of circular DMA buffer in bytes.

◆ dmaBuffer() [1/2]

template<std::size_t BufferSize = 512>
const uint8_t * corium::embedded::DmaUartRxBuffer< BufferSize >::dmaBuffer ( ) const
inlinenoexcept

Const pointer to raw memory buffer.

◆ dmaBuffer() [2/2]

template<std::size_t BufferSize = 512>
uint8_t * corium::embedded::DmaUartRxBuffer< BufferSize >::dmaBuffer ( )
inlinenoexcept

Direct pointer to raw memory buffer for DMA peripheral configuration (e.g. HAL_UART_Receive_DMA).

◆ processAvailableBytes()

template<std::size_t BufferSize = 512>
template<typename Callback >
void corium::embedded::DmaUartRxBuffer< BufferSize >::processAvailableBytes ( std::size_t  currentDmaWriteIndex,
Callback &&  onPacket 
)
inline

Update tail position based on hardware DMA counter and extract available bytes. Typically invoked from UART Idle Line ISR or DMA Half/Full Transfer ISR.

Parameters
currentDmaWriteIndexCurrent hardware DMA write index (e.g. BufferSize - __HAL_DMA_GET_COUNTER(hdma)).
onPacketExtracted byte span callback: void(std::span<const uint8_t> data).

◆ reset()

template<std::size_t BufferSize = 512>
void corium::embedded::DmaUartRxBuffer< BufferSize >::reset ( )
inlinenoexcept

Reset circular tail index.

◆ tail()

template<std::size_t BufferSize = 512>
std::size_t corium::embedded::DmaUartRxBuffer< BufferSize >::tail ( ) const
inlinenoexcept

Current tail index in the circular buffer.


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