libxr  1.0
Want to be the best embedded framework
Loading...
Searching...
No Matches
LibXR::ESPTxDoubleBuffer Class Reference

ESP 发送路径双缓冲辅助器。 More...

#include <esp_tx_double_buffer.hpp>

Collaboration diagram for LibXR::ESPTxDoubleBuffer:
[legend]

Public Member Functions

 ESPTxDoubleBuffer ()=default
 默认构造辅助器。
 
void Init (RawData storage)
 绑定外部双缓冲 backing storage 并重置状态。
 
void Reset ()
 重置当前 active/pending 发送状态。
 
uint8_t * ActiveBuffer () const
 获取当前 active payload 缓冲区指针。
 
uint8_t * PendingBuffer () const
 获取当前 pending payload 缓冲区指针。
 
size_t BufferSize () const
 获取单个半缓冲区大小。
 
bool HasActive () const
 判断是否存在有效 active 请求。
 
bool HasPending () const
 判断是否存在有效 pending 请求。
 
size_t ActiveLength () const
 获取当前 active payload 长度。
 
size_t ActiveOffset () const
 获取当前 active payload 已推进的偏移量。
 
void SetActiveOffset (size_t offset)
 更新当前 active payload 已推进的偏移量。
 
WriteInfoBlockActiveInfo ()
 获取 active 请求元数据引用。
 
const WriteInfoBlockActiveInfo () const
 获取 active 请求元数据常量引用。
 
WriteInfoBlockPendingInfo ()
 获取 pending 请求元数据引用。
 
const WriteInfoBlockPendingInfo () const
 获取 pending 请求元数据常量引用。
 
void LoadActive (size_t size, const WriteInfoBlock &info)
 装载一个 active 请求的长度与元数据。
 
void LoadPending (size_t size, const WriteInfoBlock &info)
 装载一个 pending 请求的长度与元数据。
 
bool PromotePending ()
 将 pending 请求提升为 active 请求。
 
void ClearActive ()
 清除当前 active 请求状态。
 
void ClearPending ()
 清除当前 pending 请求状态。
 

Private Attributes

DoubleBuffer bytes_ {}
 payload 双缓冲对象。 Payload double-buffer object.
 
size_t active_length_ = 0U
 active payload 长度。 Active payload length.
 
size_t pending_length_ = 0U
 pending payload 长度。 Pending payload length.
 
size_t active_offset_ = 0U
 active payload 已推进偏移。 Active progressed offset.
 
WriteInfoBlock active_info_ = {}
 active 请求元数据。 Active request metadata.
 
WriteInfoBlock pending_info_ = {}
 pending 请求元数据。 Pending request metadata.
 
bool active_valid_
 active 请求是否有效。 Whether an active request is valid.
 
Flag::Atomic pending_valid_ {}
 pending 请求是否有效。 Whether a pending request is valid.
 

Detailed Description

ESP 发送路径双缓冲辅助器。

Double-buffer helper for ESP transmit paths.

该辅助器复用 DoubleBuffer 管理 payload 缓冲区,并额外维护 active/pending 两个发送请求的长度、偏移和 WriteInfoBlock 元数据。 It reuses DoubleBuffer for payload storage and additionally tracks active/pending request length, offset, and WriteInfoBlock metadata.

Definition at line 23 of file esp_tx_double_buffer.hpp.

Constructor & Destructor Documentation

◆ ESPTxDoubleBuffer()

LibXR::ESPTxDoubleBuffer::ESPTxDoubleBuffer ( )
default

默认构造辅助器。

Construct one helper in the uninitialized state.

Member Function Documentation

◆ ActiveBuffer()

uint8_t * LibXR::ESPTxDoubleBuffer::ActiveBuffer ( ) const
inline

获取当前 active payload 缓冲区指针。

Return the current active payload buffer pointer.

Definition at line 63 of file esp_tx_double_buffer.hpp.

63{ return bytes_.ActiveBuffer(); }
uint8_t * ActiveBuffer() const
获取当前正在使用的缓冲区指针 Returns the currently active buffer
DoubleBuffer bytes_
payload 双缓冲对象。 Payload double-buffer object.

◆ ActiveInfo() [1/2]

WriteInfoBlock & LibXR::ESPTxDoubleBuffer::ActiveInfo ( )
inline

获取 active 请求元数据引用。

Return the active request metadata reference.

Definition at line 114 of file esp_tx_double_buffer.hpp.

114{ return active_info_; }
WriteInfoBlock active_info_
active 请求元数据。 Active request metadata.

◆ ActiveInfo() [2/2]

const WriteInfoBlock & LibXR::ESPTxDoubleBuffer::ActiveInfo ( ) const
inline

获取 active 请求元数据常量引用。

Return the const active request metadata reference.

Definition at line 120 of file esp_tx_double_buffer.hpp.

120{ return active_info_; }

◆ ActiveLength()

size_t LibXR::ESPTxDoubleBuffer::ActiveLength ( ) const
inline

获取当前 active payload 长度。

Return the current active payload length.

Definition at line 93 of file esp_tx_double_buffer.hpp.

93{ return active_length_; }
size_t active_length_
active payload 长度。 Active payload length.

◆ ActiveOffset()

size_t LibXR::ESPTxDoubleBuffer::ActiveOffset ( ) const
inline

获取当前 active payload 已推进的偏移量。

Return the current progressed offset of the active payload.

Definition at line 99 of file esp_tx_double_buffer.hpp.

99{ return active_offset_; }
size_t active_offset_
active payload 已推进偏移。 Active progressed offset.

◆ BufferSize()

size_t LibXR::ESPTxDoubleBuffer::BufferSize ( ) const
inline

获取单个半缓冲区大小。

Return the size of one half-buffer.

Definition at line 75 of file esp_tx_double_buffer.hpp.

75{ return bytes_.Size(); }
size_t Size() const
获取每个缓冲区的大小(单位:字节) Gets the size of each buffer in bytes

◆ ClearActive()

void LibXR::ESPTxDoubleBuffer::ClearActive ( )
inline

清除当前 active 请求状态。

Clear the current active request state.

Definition at line 198 of file esp_tx_double_buffer.hpp.

199 {
200 active_length_ = 0U;
201 active_offset_ = 0U;
202 active_info_ = {};
203 active_valid_ = false;
204 }
bool active_valid_
active 请求是否有效。 Whether an active request is valid.

◆ ClearPending()

void LibXR::ESPTxDoubleBuffer::ClearPending ( )
inline

清除当前 pending 请求状态。

Clear the current pending request state.

Definition at line 210 of file esp_tx_double_buffer.hpp.

211 {
213 pending_length_ = 0U;
214 pending_info_ = {};
215 }
WriteInfoBlock pending_info_
pending 请求元数据。 Pending request metadata.
Flag::Atomic pending_valid_
pending 请求是否有效。 Whether a pending request is valid.
size_t pending_length_
pending payload 长度。 Pending payload length.
void Clear() noexcept
清除标志 / Clear the flag
Definition flag.hpp:47

◆ HasActive()

bool LibXR::ESPTxDoubleBuffer::HasActive ( ) const
inline

判断是否存在有效 active 请求。

Check whether a valid active request exists.

Definition at line 81 of file esp_tx_double_buffer.hpp.

81{ return active_valid_; }

◆ HasPending()

bool LibXR::ESPTxDoubleBuffer::HasPending ( ) const
inline

判断是否存在有效 pending 请求。

Check whether a valid pending request exists.

Definition at line 87 of file esp_tx_double_buffer.hpp.

87{ return pending_valid_.IsSet(); }
bool IsSet() const noexcept
判断是否已置位 / Check whether the flag is set
Definition flag.hpp:55

◆ Init()

void LibXR::ESPTxDoubleBuffer::Init ( RawData storage)
inline

绑定外部双缓冲 backing storage 并重置状态。

Bind external double-buffer backing storage and reset state.

backing storage 的合法性约束由 DoubleBuffer::Init() 统一负责。 The backing-storage contract is enforced solely by DoubleBuffer::Init().

Parameters
storage外部双缓冲 backing storage。
storageExternal double-buffer backing storage.

Definition at line 42 of file esp_tx_double_buffer.hpp.

43 {
44 bytes_.Init(storage);
45 Reset();
46 }
void Init(const LibXR::RawData &raw_data)
绑定连续 backing storage 并重置双缓冲状态 Binds continuous backing storage and resets double-buffer state
void Reset()
重置当前 active/pending 发送状态。

◆ LoadActive()

void LibXR::ESPTxDoubleBuffer::LoadActive ( size_t size,
const WriteInfoBlock & info )
inline

装载一个 active 请求的长度与元数据。

Load the length and metadata of one active request.

Parameters
sizeactive payload 长度。
sizeActive payload length.
infoactive 请求元数据。
infoActive request metadata.

Definition at line 143 of file esp_tx_double_buffer.hpp.

144 {
145 active_length_ = size;
146 active_offset_ = 0U;
147 active_info_ = info;
148 active_valid_ = true;
149 }

◆ LoadPending()

void LibXR::ESPTxDoubleBuffer::LoadPending ( size_t size,
const WriteInfoBlock & info )
inline

装载一个 pending 请求的长度与元数据。

Load the length and metadata of one pending request.

Parameters
sizepending payload 长度。
sizePending payload length.
infopending 请求元数据。
infoPending request metadata.

Definition at line 160 of file esp_tx_double_buffer.hpp.

161 {
162 pending_length_ = size;
163 pending_info_ = info;
165 }
void Set() noexcept
置位标志 / Set the flag
Definition flag.hpp:42

◆ PendingBuffer()

uint8_t * LibXR::ESPTxDoubleBuffer::PendingBuffer ( ) const
inline

获取当前 pending payload 缓冲区指针。

Return the current pending payload buffer pointer.

Definition at line 69 of file esp_tx_double_buffer.hpp.

69{ return bytes_.PendingBuffer(); }
uint8_t * PendingBuffer() const
获取备用缓冲区的指针 Returns the pending (inactive) buffer

◆ PendingInfo() [1/2]

WriteInfoBlock & LibXR::ESPTxDoubleBuffer::PendingInfo ( )
inline

获取 pending 请求元数据引用。

Return the pending request metadata reference.

Definition at line 126 of file esp_tx_double_buffer.hpp.

126{ return pending_info_; }

◆ PendingInfo() [2/2]

const WriteInfoBlock & LibXR::ESPTxDoubleBuffer::PendingInfo ( ) const
inline

获取 pending 请求元数据常量引用。

Return the const pending request metadata reference.

Definition at line 132 of file esp_tx_double_buffer.hpp.

132{ return pending_info_; }

◆ PromotePending()

bool LibXR::ESPTxDoubleBuffer::PromotePending ( )
inline

将 pending 请求提升为 active 请求。

Promote the pending request into the active slot.

若当前没有有效 pending 请求,则返回 false。 Returns false when no valid pending request is present.

Returns
提升成功返回 true,否则返回 false。
True on successful promotion, otherwise false.

Definition at line 177 of file esp_tx_double_buffer.hpp.

178 {
180 {
181 return false;
182 }
183
186 active_offset_ = 0U;
188 active_valid_ = true;
189 pending_length_ = 0U;
190 pending_info_ = {};
191 return true;
192 }
void FlipActiveBlock()
翻转当前活动缓冲区编号 Flips the current active block index
bool TestAndClear() noexcept
测试并清除:清除并返回旧状态 / Test-and-clear: clear and return previous state
Definition flag.hpp:77

◆ Reset()

void LibXR::ESPTxDoubleBuffer::Reset ( )
inline

重置当前 active/pending 发送状态。

Reset the current active/pending transmit state.

Definition at line 52 of file esp_tx_double_buffer.hpp.

53 {
54 bytes_.Reset();
57 }
void Reset()
重置 active/pending 状态,但保留已绑定的 backing storage Resets active/pending state while keeping bound backing ...
void ClearActive()
清除当前 active 请求状态。
void ClearPending()
清除当前 pending 请求状态。

◆ SetActiveOffset()

void LibXR::ESPTxDoubleBuffer::SetActiveOffset ( size_t offset)
inline

更新当前 active payload 已推进的偏移量。

Update the progressed offset of the active payload.

Parameters
offset新的 active 偏移量。
offsetNew active offset.

Definition at line 108 of file esp_tx_double_buffer.hpp.

108{ active_offset_ = offset; }

Field Documentation

◆ active_info_

WriteInfoBlock LibXR::ESPTxDoubleBuffer::active_info_ = {}
private

active 请求元数据。 Active request metadata.

Definition at line 222 of file esp_tx_double_buffer.hpp.

222{};

◆ active_length_

size_t LibXR::ESPTxDoubleBuffer::active_length_ = 0U
private

active payload 长度。 Active payload length.

Definition at line 219 of file esp_tx_double_buffer.hpp.

◆ active_offset_

size_t LibXR::ESPTxDoubleBuffer::active_offset_ = 0U
private

active payload 已推进偏移。 Active progressed offset.

Definition at line 221 of file esp_tx_double_buffer.hpp.

◆ active_valid_

bool LibXR::ESPTxDoubleBuffer::active_valid_
private
Initial value:
=
false

active 请求是否有效。 Whether an active request is valid.

Definition at line 224 of file esp_tx_double_buffer.hpp.

◆ bytes_

DoubleBuffer LibXR::ESPTxDoubleBuffer::bytes_ {}
private

payload 双缓冲对象。 Payload double-buffer object.

Definition at line 218 of file esp_tx_double_buffer.hpp.

218{};

◆ pending_info_

WriteInfoBlock LibXR::ESPTxDoubleBuffer::pending_info_ = {}
private

pending 请求元数据。 Pending request metadata.

Definition at line 223 of file esp_tx_double_buffer.hpp.

223{};

◆ pending_length_

size_t LibXR::ESPTxDoubleBuffer::pending_length_ = 0U
private

pending payload 长度。 Pending payload length.

Definition at line 220 of file esp_tx_double_buffer.hpp.

◆ pending_valid_

Flag::Atomic LibXR::ESPTxDoubleBuffer::pending_valid_ {}
private

pending 请求是否有效。 Whether a pending request is valid.

Definition at line 227 of file esp_tx_double_buffer.hpp.

227{};

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