|
libxr
1.0
Want to be the best embedded framework
|
SWD 探针抽象基类,提供链路控制、传输与 DP/AP 辅助接口。 Abstract SWD probe base class providing link control, transfer, and DP/AP helpers. More...
#include <swd.hpp>
Data Structures | |
| struct | TransferPolicy |
| 传输策略(WAIT 重试与空闲周期插入)。Transfer policy (WAIT retry & idle insertion). More... | |
Public Member Functions | |
| virtual | ~Swd ()=default |
| 虚析构函数。Virtual destructor. | |
| Swd (const Swd &)=delete | |
| Swd & | operator= (const Swd &)=delete |
| void | SetTransferPolicy (const TransferPolicy &policy) |
| 设置传输策略。Set transfer policy. | |
| const TransferPolicy & | GetTransferPolicy () const |
| 获取传输策略。Get transfer policy. | |
| virtual ErrorCode | SetClockHz (uint32_t hz)=0 |
| 设置 SWCLK 频率(可选)。Set SWCLK frequency (optional). | |
| virtual void | Close ()=0 |
| 关闭探针并释放资源。Close probe and release resources. | |
| virtual ErrorCode | LineReset ()=0 |
| 执行 SWD 线复位。Perform SWD line reset. | |
| virtual ErrorCode | EnterSwd ()=0 |
| 进入 SWD 模式(如需从 JTAG 切换)。Enter SWD mode (e.g., switch from JTAG if needed). | |
| virtual ErrorCode | Transfer (const SwdProtocol::Request &req, SwdProtocol::Response &resp)=0 |
| 执行一次 SWD 传输(不含重试)。Perform one SWD transfer (no retry). | |
| ErrorCode | TransferWithRetry (const SwdProtocol::Request &req, SwdProtocol::Response &resp) |
| 带重试的 SWD 传输封装(WAIT 重试 + IdleCycles 插入)。 SWD transfer wrapper with retry (WAIT retry + IdleCycles insertion). | |
| ErrorCode | DpRead (SwdProtocol::DpReadReg reg, uint32_t &val, SwdProtocol::Ack &ack) |
| DP 寄存器读取(无重试)。DP register read (no retry). | |
| ErrorCode | DpWrite (SwdProtocol::DpWriteReg reg, uint32_t val, SwdProtocol::Ack &ack) |
| DP 寄存器写入(无重试)。DP register write (no retry). | |
| ErrorCode | DpReadTxn (SwdProtocol::DpReadReg reg, uint32_t &val, SwdProtocol::Ack &ack) |
| DP 读事务(带重试)。DP read transaction (with retry). | |
| ErrorCode | DpWriteTxn (SwdProtocol::DpWriteReg reg, uint32_t val, SwdProtocol::Ack &ack) |
| DP 写事务(带重试)。DP write transaction (with retry). | |
| ErrorCode | ApReadTxn (uint8_t addr2b, uint32_t &val, SwdProtocol::Ack &ack) |
| AP 读事务(带重试,包含 RDBUFF 回读)。AP read transaction (with retry, with RDBUFF readback). | |
| ErrorCode | ApReadPostedTxn (uint8_t addr2b, uint32_t &posted_val, SwdProtocol::Ack &ack) |
| AP 读事务(带重试,不读 RDBUFF;返回 posted 数据)。 AP read transaction (with retry, no RDBUFF; returns posted data). | |
| ErrorCode | DpReadRdbuffTxn (uint32_t &val, SwdProtocol::Ack &ack) |
| 读取 DP RDBUFF(带重试)。Read DP RDBUFF (with retry). | |
| ErrorCode | ApWriteTxn (uint8_t addr2b, uint32_t val, SwdProtocol::Ack &ack) |
| AP 写事务(带重试)。AP write transaction (with retry). | |
| ErrorCode | ReadIdCode (uint32_t &idcode, SwdProtocol::Ack &ack) |
| 读取 DP IDCODE。Read DP IDCODE. | |
| ErrorCode | WriteAbort (uint32_t flags, SwdProtocol::Ack &ack) |
| 写入 DP ABORT(无重试)。Write DP ABORT (no retry). | |
| ErrorCode | WriteAbortTxn (uint32_t flags, SwdProtocol::Ack &ack) |
| 写入 DP ABORT(带重试)。Write DP ABORT (with retry). | |
| ErrorCode | SetSelectCached (uint32_t select, SwdProtocol::Ack &ack) |
| 写 SELECT(带缓存;命中则跳过写入)。Write SELECT with cache (skip write on hit). | |
| void | InvalidateSelectCache () |
| 失效 SELECT 缓存。Invalidate SELECT cache. | |
| Swd ()=default | |
| 构造函数。Constructor. | |
| virtual void | IdleClocks (uint32_t cycles)=0 |
| 插入空闲时钟周期。Insert idle clock cycles. | |
| virtual ErrorCode | SeqWriteBits (uint32_t cycles, const uint8_t *data_lsb_first)=0 |
| virtual ErrorCode | SeqReadBits (uint32_t cycles, uint8_t *out_lsb_first)=0 |
Private Member Functions | |
| ErrorCode | ClearStickyErrors () |
| 清除 DP sticky 错误(尽力而为)。Clear DP sticky errors (best-effort). | |
Static Private Member Functions | |
| static void | ResetResponse (SwdProtocol::Response &resp) |
| 重置响应结构体为默认值。Reset response to defaults. | |
Private Attributes | |
| TransferPolicy | policy_ {} |
| 传输策略。Transfer policy. | |
| uint32_t | select_cache_ = 0u |
| SELECT 缓存值。SELECT cached value. | |
| bool | select_valid_ = false |
| SELECT 缓存是否有效。SELECT cache valid. | |
SWD 探针抽象基类,提供链路控制、传输与 DP/AP 辅助接口。 Abstract SWD probe base class providing link control, transfer, and DP/AP helpers.
|
inline |
AP 读事务(带重试,不读 RDBUFF;返回 posted 数据)。 AP read transaction (with retry, no RDBUFF; returns posted data).
| addr2b | AP 寄存器地址(A2/A3,两位)。AP register address (A2/A3, 2-bit). |
| posted_val | 输出:posted 数据。Output: posted value. |
| ack | 输出:ACK。Output: ACK. |
Definition at line 306 of file swd.hpp.
|
inline |
AP 读事务(带重试,包含 RDBUFF 回读)。AP read transaction (with retry, with RDBUFF readback).
注意:AP 读为 posted;该辅助函数执行:Note: AP reads are posted; this helper performs: 1) AP READ(获得 posted 数据)。AP READ (gets posted data). 2) 读取 DP RDBUFF 获取本次 AP READ 的实际数据。DP RDBUFF read to obtain the actual data for this AP read.
| addr2b | AP 寄存器地址(A2/A3,两位)。AP register address (A2/A3, 2-bit). |
| val | 输出:实际读取的数据。Output: actual read value. |
| ack | 输出:ACK。Output: ACK. |
Definition at line 274 of file swd.hpp.
|
inline |
AP 写事务(带重试)。AP write transaction (with retry).
| addr2b | AP 寄存器地址(A2/A3,两位)。AP register address (A2/A3, 2-bit). |
| val | 写入数据。Write value. |
| ack | 输出:ACK。Output: ACK. |
Definition at line 343 of file swd.hpp.
|
inlineprivate |
清除 DP sticky 错误(尽力而为)。Clear DP sticky errors (best-effort).
Definition at line 464 of file swd.hpp.
|
pure virtual |
关闭探针并释放资源。Close probe and release resources.
Implemented in LibXR::Debug::SwdGeneralGPIO< SwclkGpioType, SwdioGpioType >.
|
inline |
DP 寄存器读取(无重试)。DP register read (no retry).
| reg | DP 读寄存器。DP read register. |
| val | 输出:读到的数据。Output: read value. |
| ack | 输出:ACK。Output: ACK. |
Definition at line 169 of file swd.hpp.
|
inline |
|
inline |
DP 读事务(带重试)。DP read transaction (with retry).
| reg | DP 读寄存器。DP read register. |
| val | 输出:读到的数据。Output: read value. |
| ack | 输出:ACK。Output: ACK. |
Definition at line 218 of file swd.hpp.
|
inline |
DP 寄存器写入(无重试)。DP register write (no retry).
| reg | DP 写寄存器。DP write register. |
| val | 写入数据。Write value. |
| ack | 输出:ACK。Output: ACK. |
Definition at line 197 of file swd.hpp.
|
inline |
DP 写事务(带重试)。DP write transaction (with retry).
| reg | DP 写寄存器。DP write register. |
| val | 写入数据。Write value. |
| ack | 输出:ACK。Output: ACK. |
Definition at line 245 of file swd.hpp.
|
pure virtual |
进入 SWD 模式(如需从 JTAG 切换)。Enter SWD mode (e.g., switch from JTAG if needed).
Implemented in LibXR::Debug::SwdGeneralGPIO< SwclkGpioType, SwdioGpioType >.
|
inlinenodiscard |
|
pure virtual |
插入空闲时钟周期。Insert idle clock cycles.
| cycles | 周期数。Number of cycles. |
Implemented in LibXR::Debug::SwdGeneralGPIO< SwclkGpioType, SwdioGpioType >.
|
inline |
失效 SELECT 缓存。Invalidate SELECT cache.
Definition at line 422 of file swd.hpp.
|
pure virtual |
执行 SWD 线复位。Perform SWD line reset.
Implemented in LibXR::Debug::SwdGeneralGPIO< SwclkGpioType, SwdioGpioType >.
|
inline |
读取 DP IDCODE。Read DP IDCODE.
| idcode | 输出:IDCODE。Output: IDCODE. |
| ack | 输出:ACK。Output: ACK. |
Definition at line 364 of file swd.hpp.
|
inlinestaticprivate |
|
pure virtual |
设置 SWCLK 频率(可选)。Set SWCLK frequency (optional).
| hz | 目标频率(Hz)。Target frequency in Hz. |
Implemented in LibXR::Debug::SwdGeneralGPIO< SwclkGpioType, SwdioGpioType >.
|
inline |
写 SELECT(带缓存;命中则跳过写入)。Write SELECT with cache (skip write on hit).
| select | SELECT 值。SELECT value. |
| ack | 输出:ACK。Output: ACK. |
Definition at line 402 of file swd.hpp.
|
inline |
|
pure virtual |
执行一次 SWD 传输(不含重试)。Perform one SWD transfer (no retry).
| req | 请求包。Request. |
| resp | 响应包。Response. |
Implemented in LibXR::Debug::SwdGeneralGPIO< SwclkGpioType, SwdioGpioType >.
|
inline |
带重试的 SWD 传输封装(WAIT 重试 + IdleCycles 插入)。 SWD transfer wrapper with retry (WAIT retry + IdleCycles insertion).
规则:Rules:
| req | 请求包。Request. |
| resp | 响应包。Response. |
Definition at line 110 of file swd.hpp.
|
inline |
|
inline |
写入 DP ABORT(带重试)。Write DP ABORT (with retry).
| flags | ABORT 标志位。ABORT flags. |
| ack | 输出:ACK。Output: ACK. |
|
private |
|
private |
|
private |