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

HPM SDK I2C 主机驱动,适配 LibXR I2C 接口 / HPM SDK based I2C master driver for the LibXR I2C interface. More...

#include <hpm_i2c.hpp>

Inheritance diagram for LibXR::HPMI2C:
[legend]
Collaboration diagram for LibXR::HPMI2C:
[legend]

Data Structures

struct  WaitPolicy
 HPM I2C 忙等超时策略 / HPM I2C busy-wait timeout policy. More...
 

Public Types

enum class  AddressMode : uint8_t { ADDR_7BIT , ADDR_10BIT }
 HPM I2C 主机寻址模式 / HPM I2C master addressing mode. More...
 
enum class  SequenceFrame : uint8_t { FIRST , NEXT , LAST }
 HPM 主机顺序事务分段类型 / HPM master sequential transfer frame type. More...
 
enum class  TransferFlag : uint16_t {
  NONE = 0 , READ = 0x0001U , ADDR_10BIT = 0x0002U , NO_START = 0x0004U ,
  NO_ADDRESS = 0x0008U , NO_READ_ACK = 0x0010U , NO_STOP = 0x0020U , WRITE_CHECK_ACK = 0x0040U
}
 HPM 主机扩展事务标志 / HPM master extended transfer flags. More...
 
enum class  AsyncTransferKind : uint8_t { NONE , READ , WRITE , MEM_READ }
 HPM I2C 后台事务类型 / HPM I2C asynchronous transfer kind. More...
 
- Public Types inherited from LibXR::I2C
enum class  MemAddrLength : uint8_t { BYTE_8 , BYTE_16 }
 

Public Member Functions

 HPMI2C (LibXRHpmI2cType *i2c, clock_name_t clock, bool auto_board_init=true, I2C::Configuration config={100000})
 构造 HPM I2C 主机对象 / Construct an HPM I2C master object.
 
ErrorCode SetAddressMode (AddressMode mode)
 设置 HPM 主机寻址模式并重建控制器 / Set HPM master addressing mode and rebuild the controller.
 
ErrorCode SetWaitPolicy (WaitPolicy policy)
 设置当前实例的忙等超时策略 / Set the busy-wait timeout policy for this instance.
 
WaitPolicy GetWaitPolicy () const
 获取当前实例的忙等超时策略 / Get the current busy-wait timeout policy.
 
AddressMode GetAddressMode () const
 获取当前 HPM 主机寻址模式 / Get current HPM master addressing mode.
 
ErrorCode SequenceWrite (uint16_t slave_addr, ConstRawData write_data, SequenceFrame frame, bool check_ack, WriteOperation &op, bool in_isr=false)
 执行一段 HPM 主机顺序写事务 / Execute one HPM master sequential write frame.
 
ErrorCode SequenceRead (uint16_t slave_addr, RawData read_data, SequenceFrame frame, ReadOperation &op, bool in_isr=false)
 执行一段 HPM 主机顺序读事务 / Execute one HPM master sequential read frame.
 
ErrorCode TransferWithFlags (uint16_t slave_addr, RawData data, uint16_t flags, ReadOperation &op, bool in_isr=false)
 执行一段 HPM 扩展标志主机事务 / Execute one HPM master transfer with extended SDK flags.
 
ErrorCode TransferWithFlags (uint16_t slave_addr, ConstRawData data, uint16_t flags, WriteOperation &op, bool in_isr=false)
 执行一段 HPM 扩展标志主机写事务 / Execute one HPM master write transfer with extended SDK flags.
 
ErrorCode Read (uint16_t slave_addr, RawData read_data, ReadOperation &op, bool in_isr=false) override
 I2C 从设备读取字节 / Read bytes from an I2C slave.
 
ErrorCode Write (uint16_t slave_addr, ConstRawData write_data, WriteOperation &op, bool in_isr=false) override
 I2C 从设备写入字节 / Write bytes to an I2C slave.
 
ErrorCode MemRead (uint16_t slave_addr, uint16_t mem_addr, RawData read_data, ReadOperation &op, MemAddrLength mem_addr_size=MemAddrLength::BYTE_8, bool in_isr=false) override
 I2C 从设备寄存器或存储器地址读取字节 / Read bytes from an I2C slave register or memory address.
 
ErrorCode MemWrite (uint16_t slave_addr, uint16_t mem_addr, ConstRawData write_data, WriteOperation &op, MemAddrLength mem_addr_size=MemAddrLength::BYTE_8, bool in_isr=false) override
 I2C 从设备寄存器或存储器地址写入字节 / Write bytes to an I2C slave register or memory address.
 
ErrorCode SetConfig (Configuration config) override
 应用 I2C 时序配置 / Apply I2C timing configuration.
 
uint32_t GetClockFreq () const
 获取当前缓存的 I2C 源时钟频率 / Get cached I2C source clock frequency.
 
- Public Member Functions inherited from LibXR::I2C
 I2C ()
 默认构造函数。 Default constructor.
 

Static Public Member Functions

static constexpr WaitPolicy DefaultWaitPolicy ()
 返回默认 HPM I2C 忙等超时策略 / Return the default HPM I2C wait policy.
 

Private Member Functions

friend void::libxr_hpm_i2c_process_interrupt (LibXRHpmI2cType *ptr)
 
uint16_t BuildTransferFlags (uint16_t flags) const
 根据目标固定速率解析 HPM I2C 工作模式 / Resolve HPM I2C operating mode from a fixed target clock rate.
 
ErrorCode ValidateSlaveAddress (uint16_t slave_addr) const
 校验当前寻址模式下的从地址 / Validate slave address for the current addressing mode.
 
ErrorCode ValidateTransferArgs (uint16_t slave_addr, RawData data, bool allow_zero_size) const
 校验普通读写事务入口参数 / Validate common read/write entry arguments.
 
ErrorCode ValidateTransferArgs (uint16_t slave_addr, ConstRawData data, bool allow_zero_size) const
 校验普通写事务入口参数 / Validate common write entry arguments.
 
ErrorCode ValidateMemWriteArgs (uint16_t slave_addr, ConstRawData write_data, MemAddrLength mem_addr_size, uint32_t &addr_size) const
 校验寄存器写事务入口参数并解析寄存器地址长度 / Validate memory-write entry arguments and resolve memory-address length.
 
ErrorCode DoSequenceWrite (uint16_t slave_addr, ConstRawData write_data, SequenceFrame frame, bool check_ack)
 执行一段顺序写事务,不做状态分发 / Execute one sequential write frame without LibXR status dispatch.
 
ErrorCode DoSequenceRead (uint16_t slave_addr, RawData read_data, SequenceFrame frame)
 执行一段顺序读事务,不做状态分发 / Execute one sequential read frame without LibXR status dispatch.
 
ErrorCode DoTransferWithFlags (uint16_t slave_addr, RawData data, uint16_t flags)
 执行一段扩展标志事务,不做状态分发 / Execute one flag-based transfer without LibXR status dispatch.
 
hpm_stat_t DoManualTransferWithFlags (uint16_t slave_addr, RawData data, uint16_t flags)
 通过手工 phase 编排执行一笔 blocking 事务 / Execute one blocking transfer through manual phase orchestration.
 
ErrorCode EnsureClockReady ()
 确保 I2C 源时钟已可用 / Ensure the I2C source clock is available.
 
ErrorCode EnsureControllerReady ()
 确保控制器已完成一次可用配置 / Ensure the controller has a usable configuration applied.
 
ErrorCode ApplyConfig (const Configuration &config)
 按当前后端限制下发配置并缓存成功配置 / Apply configuration under current backend limits and cache it on success.
 
void RecoverController ()
 复位并按缓存配置重建 I2C 控制器 / Reset and reinitialize the I2C controller with cached configuration.
 
void TryRecoverBusLines ()
 在 SDA 被拉低且硬件支持时尝试发出 I2C reset clocks / Try to generate I2C reset clocks when SDA is stuck low and the hardware supports it.
 

Static Private Member Functions

static ErrorCode ConvertStatus (hpm_stat_t status)
 将 HPM SDK I2C 状态码转换为 LibXR 错误码 / Convert HPM SDK I2C status to LibXR ErrorCode.
 
static uint16_t GetMaxSlaveAddress (AddressMode mode)
 获取指定寻址模式可接受的最大从地址 / Get the maximum valid slave address for the given mode.
 
static ErrorCode ResolveMemAddressSize (MemAddrLength len, uint32_t &addr_size)
 解析寄存器地址宽度枚举到字节数 / Resolve register-address enum to byte count.
 
static void FillMemAddress (uint16_t mem_addr, MemAddrLength len, uint8_t out[2])
 按 BYTE_8/BYTE_16 格式填充寄存器地址字节 / Fill register address bytes according to BYTE_8/BYTE_16 format.
 
static bool ShouldRecover (hpm_stat_t status)
 判断失败后是否需要重建控制器 / Decide whether the controller should be reinitialized after a failure.
 
template<typename Op >
static ErrorCode FinishOperation (Op &op, bool in_isr, ErrorCode ans)
 完成 LibXR 操作状态更新或回调 / Complete LibXR operation status update or callback dispatch.
 

Private Attributes

LibXRHpmI2cType * i2c_
 I2C 外设实例 / I2C peripheral instance.
 
clock_name_t clock_
 I2C 源时钟名称 / I2C source clock name.
 
uint32_t source_clock_hz_ = 0
 缓存的源时钟频率 / Cached source clock frequency.
 
Configuration current_config_
 最近一次成功总线时序配置 / Most recent successful bus-timing config.
 
WaitPolicy wait_policy_
 当前忙等超时策略 / Current busy-wait timeout policy.
 
AddressMode address_mode_
 当前主机寻址模式 / Current master addressing mode.
 
bool configured_ = false
 是否已有成功配置 / Whether a valid config was applied.
 
bool auto_board_init_
 是否自动调用板级初始化 / Whether board init is automatic.
 

Static Private Attributes

static constexpr uint16_t kMax7BitAddress = 0x7FU
 当前 HPM 后端支持的最大 7-bit 从地址 / Maximum 7-bit slave address supported by the current HPM backend.
 
static constexpr uint16_t kMax10BitAddress = 0x3FFU
 当前 HPM 后端支持的最大 10-bit 从地址 / Maximum 10-bit slave address supported by the current HPM backend.
 

Detailed Description

HPM SDK I2C 主机驱动,适配 LibXR I2C 接口 / HPM SDK based I2C master driver for the LibXR I2C interface.

该类持有一个 HPM I2C 外设实例,并通过 LibXR::I2C 提供普通字节流传输和 寄存器/存储器地址式传输。 This class owns one HPM I2C peripheral instance and exposes byte-stream transfers and register/memory-address transfers through LibXR::I2C.

默认按 7-bit 主机寻址模式启动,也可通过 HPMI2C::SetAddressMode() 切到 HPM SDK 已支持的 10-bit 主机寻址模式;若遇到超时、总线忙或无响应等典型主机故障,驱动会 尝试用最近一次成功配置重建控制器。 The driver starts in 7-bit master addressing mode by default and can switch to the HPM SDK supported 10-bit master addressing mode through HPMI2C::SetAddressMode(). On typical master-side failures such as timeout, bus busy, or no response, the driver attempts to rebuild the controller with the most recent successful configuration.

BLOCK 模式保持同步阻塞式传输;当工程提供旧分支的 hpm_dma_mgr.h helper 时, POLLING / CALLBACK / NONE 可复用 DMA 后台路径覆盖 Write / Read / MemRead。 当前 upstream HPM5301 模板未携带该 helper 时,这些操作降级为同步完成并即时更新 LibXR Operation 状态。MemWrite 始终保持阻塞路径。对 10-bit / 扩展 flags 的 blocking 手工 phase 路径,地址阶段会显式等待 ADDRHIT,失败时按适配层策略强制 cleanup 并按原始 HPM 状态触发恢复链路。 BLOCK mode stays on synchronous blocking transfers. When the project provides the legacy-branch hpm_dma_mgr.h helper, POLLING / CALLBACK / NONE can reuse the DMA backed path for Write / Read / MemRead. Without that helper, as in the current upstream HPM5301 template, these operations complete synchronously and update the LibXR Operation state before returning. MemWrite always stays on the blocking path. For the blocking manual phase path used by 10-bit / extended-flag transfers, the address phase explicitly waits for ADDRHIT; failures force adapter-level cleanup and preserve the original HPM status for recovery handling.

后台 DMA 完成并不直接代表事务成功,驱动会在 DMA 结束后继续确认 I2C CMPL 和后置状态,再通过 UpdateStatus() 或 AsyncBlockWait 报告最终结果。 DMA completion alone is not treated as transfer success. After DMA finishes, the driver still verifies I2C CMPL and post-transfer status before reporting the final result through UpdateStatus() or AsyncBlockWait. 异步完成路径的 dma_donecmpl_donefinal_statusshould_recover 原子状态由内部 AsyncCompletionStateMachine helper 统一更新,IRQ 和 DMA 回调只声明 发生的事件。 The asynchronous completion atomics dma_done, cmpl_done, final_status, and should_recover are updated through the internal AsyncCompletionStateMachine helper, leaving IRQ and DMA callbacks to report events only.

当 DMA 后台事务正在进行时,同步 Read / Write / MemRead / MemWrite、顺序 SequenceRead / SequenceWrite 以及扩展 flags 手动 phase 入口会返回 BUSY; 低层手动 helper 在清 FIFO、改 CTRL/INTEN 或发 START 前返回 HPM SDK 的 status_i2c_bus_busy,再由 ConvertStatus() 映射到 LibXR 错误码。 While a DMA-backed transfer is active, synchronous Read / Write / MemRead / MemWrite, sequential SequenceRead / SequenceWrite, and extended-flag manual phase entry points return BUSY. The low-level manual helper returns the HPM SDK status_i2c_bus_busy before clearing FIFO, changing CTRL/INTEN, or issuing START, and ConvertStatus() maps that status to the LibXR error code.

忙等路径统一经实现文件内部的 WaitUntil() 处理;工程可提供强定义 extern "C" void libxr_hpm_i2c_wait_relax_hook(void),在等待 ADDRHITCMPL 或 FIFO 状态时插入调度让出、低功耗等待或板级短延时。默认实现仅执行一个 nop, 不改变无 RTOS 裸机场景的时序假设。WaitUntil() 缓存首次读取的 clock_get_core_clock_ticks_per_us() 结果,并使用 unsigned elapsed ticks 比较以 避免 deadline 加法回绕;HPM SDK hpm_csr_get_core_cycle() 返回 64-bit CYCLE 值, 事务期间仍假设 core clock 不被动态改频。 Busy-wait paths are centralized through the implementation-local WaitUntil(). A project may provide a strong extern "C" void libxr_hpm_i2c_wait_relax_hook(void) definition to yield to a scheduler, enter a low-power wait, or add a board-level short delay while waiting for ADDRHIT, CMPL, or FIFO status. The default fallback only executes one nop, preserving bare-metal timing assumptions when no hook is supplied. WaitUntil() caches the first clock_get_core_clock_ticks_per_us() result and uses an unsigned elapsed-tick comparison to avoid deadline-addition wrap-around. The HPM SDK hpm_csr_get_core_cycle() API returns a 64-bit CYCLE value; the core clock is still assumed not to be dynamically retuned during I2C transfers. 每个实例可通过 SetWaitPolicy() 调整这些超时值。 Per-instance timeout values can be adjusted with SetWaitPolicy().

默认 ISR wrapper 按 HPM_I2CnIRQn_I2CnHPM_DMA_SRC_I2Cn 等 HPM SDK header 宏构建同一个实例资源表;该表已拆到 hpm_i2c_platform.hpp 内部 helper, 并由该 helper 解析 index、IRQ 和 DMA request source;若项目层后续要自行接管同一 IRQ,需要单独调整 ownership 方案。 The default ISR wrapper adapts to multi-series instances through HPM SDK header macros such as HPM_I2Cn, IRQn_I2Cn, and HPM_DMA_SRC_I2Cn. The shared instance resource table lives in the internal hpm_i2c_platform.hpp helper, which resolves index, IRQ, and DMA request source. If project code needs to own the same IRQ later, the ownership scheme should be revised in a separate change.

编译期支持由 HPMSOC_HAS_HPMSDK_I2C__has_include("hpm_i2c_drv.h") 同时 gate;缺少能力宏或裁剪 SDK 头时仍保留 LibXR API 形状,但所有事务返回 NOT_SUPPORT,避免 driver/hpm glob 构建在无 I2C SoC 上因 SDK 头缺失失败。 Compile-time support is gated by both HPMSOC_HAS_HPMSDK_I2C and __has_include("hpm_i2c_drv.h"). When the capability macro or trimmed SDK header is missing, the LibXR API shape remains available but transfer APIs return NOT_SUPPORT, preventing the driver/hpm glob build from failing on SoCs without I2C.

Definition at line 146 of file hpm_i2c.hpp.

Member Enumeration Documentation

◆ AddressMode

enum class LibXR::HPMI2C::AddressMode : uint8_t
strong

HPM I2C 主机寻址模式 / HPM I2C master addressing mode.

Enumerator
ADDR_7BIT 

7-bit 从地址 / 7-bit slave addressing.

ADDR_10BIT 

10-bit 从地址 / 10-bit slave addressing.

Definition at line 152 of file hpm_i2c.hpp.

153 {
154 ADDR_7BIT,
156 };
@ ADDR_10BIT
10-bit 从地址 / 10-bit slave addressing.
@ ADDR_7BIT
7-bit 从地址 / 7-bit slave addressing.

◆ AsyncTransferKind

enum class LibXR::HPMI2C::AsyncTransferKind : uint8_t
strong

HPM I2C 后台事务类型 / HPM I2C asynchronous transfer kind.

Definition at line 196 of file hpm_i2c.hpp.

197 {
198 NONE,
199 READ,
200 WRITE,
201 MEM_READ
202 };

◆ SequenceFrame

enum class LibXR::HPMI2C::SequenceFrame : uint8_t
strong

HPM 主机顺序事务分段类型 / HPM master sequential transfer frame type.

Enumerator
FIRST 

带 START 和地址阶段 / Includes START and address phase.

NEXT 

中间段,不带 START/STOP / Middle frame without START/STOP.

LAST 

末段,带 STOP / Final frame with STOP.

Definition at line 161 of file hpm_i2c.hpp.

162 {
163 FIRST,
164 NEXT,
165 LAST
166 };
@ FIRST
带 START 和地址阶段 / Includes START and address phase.
@ NEXT
中间段,不带 START/STOP / Middle frame without START/STOP.
@ LAST
末段,带 STOP / Final frame with STOP.

◆ TransferFlag

enum class LibXR::HPMI2C::TransferFlag : uint16_t
strong

HPM 主机扩展事务标志 / HPM master extended transfer flags.

Definition at line 171 of file hpm_i2c.hpp.

172 {
173 NONE = 0,
174#if LIBXR_HPM_I2C_SUPPORTED
175 READ = I2C_RD,
176 ADDR_10BIT = I2C_ADDR_10BIT,
177 NO_START = I2C_NO_START,
178 NO_ADDRESS = I2C_NO_ADDRESS,
179 NO_READ_ACK = I2C_NO_READ_ACK,
180 NO_STOP = I2C_NO_STOP,
181 WRITE_CHECK_ACK = I2C_WRITE_CHECK_ACK
182#else
183 READ = 0x0001U,
184 ADDR_10BIT = 0x0002U,
185 NO_START = 0x0004U,
186 NO_ADDRESS = 0x0008U,
187 NO_READ_ACK = 0x0010U,
188 NO_STOP = 0x0020U,
189 WRITE_CHECK_ACK = 0x0040U
190#endif
191 };

Constructor & Destructor Documentation

◆ HPMI2C()

HPMI2C::HPMI2C ( LibXRHpmI2cType * i2c,
clock_name_t clock,
bool auto_board_init = true,
I2C::Configuration config = {100000} )

构造 HPM I2C 主机对象 / Construct an HPM I2C master object.

Parameters
i2cHPM I2C 外设基地址,不能为空 / HPM I2C peripheral base address. Must not be nullptr.
clockHPM 时钟树名称;当板级 helper 未提供时用于开启并查询外设源时钟 / HPM clock name used to enable and query the peripheral source clock when the optional board helper does not provide one.
auto_board_init若为 true 且存在 board.h,则自动调用板级 I2C 时钟和引脚 初始化 helper / If true and board.h is available, call board I2C clock and pin helper functions automatically.
config初始 I2C 总线配置;当前 HPM 后端只接受 100 kHz、400 kHz、1 MHz 三个固定速率,其他速率由 SetConfig() 返回 NOT_SUPPORT。默认地址模式为 7-bit, 如需 10-bit 可在构造后调用 SetAddressMode() / Initial I2C bus configuration. The current HPM backend accepts only three fixed rates: 100 kHz, 400 kHz, and 1 MHz. Other rates are rejected by SetConfig(). The default address mode is 7-bit; call SetAddressMode() after construction to switch to 10-bit when needed.
Note
构造函数会在外设指针为空、源时钟无法解析或初始配置无效时断言失败 / The constructor asserts when the peripheral pointer is null, the source clock cannot be resolved, or the initial configuration is invalid.

Definition at line 2300 of file hpm_i2c.cpp.

2302 : i2c_(i2c), clock_(clock), current_config_(config), auto_board_init_(auto_board_init)
2303{
2304 (void)i2c_;
2305 (void)clock_;
2306 (void)auto_board_init_;
2307}
bool auto_board_init_
是否自动调用板级初始化 / Whether board init is automatic.
Definition hpm_i2c.hpp:943
clock_name_t clock_
I2C 源时钟名称 / I2C source clock name.
Definition hpm_i2c.hpp:920
LibXRHpmI2cType * i2c_
I2C 外设实例 / I2C peripheral instance.
Definition hpm_i2c.hpp:919
Configuration current_config_
最近一次成功总线时序配置 / Most recent successful bus-timing config.
Definition hpm_i2c.hpp:922

Member Function Documentation

◆ ApplyConfig()

ErrorCode HPMI2C::ApplyConfig ( const Configuration & config)
private

按当前后端限制下发配置并缓存成功配置 / Apply configuration under current backend limits and cache it on success.

Definition at line 2363 of file hpm_i2c.cpp.

2364{
2365 current_config_ = config;
2366 configured_ = false;
2368}
bool configured_
是否已有成功配置 / Whether a valid config was applied.
Definition hpm_i2c.hpp:928
@ NOT_SUPPORT
不支持 | Not supported

◆ BuildTransferFlags()

uint16_t HPMI2C::BuildTransferFlags ( uint16_t flags) const
private

根据目标固定速率解析 HPM I2C 工作模式 / Resolve HPM I2C operating mode from a fixed target clock rate.

转换 HPM 顺序分段枚举到 SDK 枚举 / Convert HPM sequence frame enum to SDK enum.

从当前地址模式补齐 HPM SDK 事务标志 / Merge current address-mode bit into SDK transfer flags.

Definition at line 2321 of file hpm_i2c.cpp.

2321{ return flags; }

◆ ConvertStatus()

ErrorCode HPMI2C::ConvertStatus ( hpm_stat_t status)
staticprivate

将 HPM SDK I2C 状态码转换为 LibXR 错误码 / Convert HPM SDK I2C status to LibXR ErrorCode.

Definition at line 2315 of file hpm_i2c.cpp.

2316{
2317 UNUSED(status);
2319}

◆ DefaultWaitPolicy()

static constexpr WaitPolicy LibXR::HPMI2C::DefaultWaitPolicy ( )
inlinestaticconstexpr

返回默认 HPM I2C 忙等超时策略 / Return the default HPM I2C wait policy.

Returns
默认超时策略 / Default timeout policy.

Definition at line 226 of file hpm_i2c.hpp.

227 {
228 return {500ULL, 1000ULL, 1000ULL, 500000ULL};
229 }

◆ DoManualTransferWithFlags()

hpm_stat_t HPMI2C::DoManualTransferWithFlags ( uint16_t slave_addr,
RawData data,
uint16_t flags )
private

通过手工 phase 编排执行一笔 blocking 事务 / Execute one blocking transfer through manual phase orchestration.

Definition at line 2350 of file hpm_i2c.cpp.

2352{
2353 UNUSED(slave_addr);
2354 UNUSED(data);
2355 UNUSED(flags);
2356 return status_fail;
2357}

◆ DoSequenceRead()

ErrorCode HPMI2C::DoSequenceRead ( uint16_t slave_addr,
RawData read_data,
SequenceFrame frame )
private

执行一段顺序读事务,不做状态分发 / Execute one sequential read frame without LibXR status dispatch.

Definition at line 2333 of file hpm_i2c.cpp.

2335{
2336 UNUSED(slave_addr);
2337 UNUSED(read_data);
2338 UNUSED(frame);
2340}

◆ DoSequenceWrite()

ErrorCode HPMI2C::DoSequenceWrite ( uint16_t slave_addr,
ConstRawData write_data,
SequenceFrame frame,
bool check_ack )
private

执行一段顺序写事务,不做状态分发 / Execute one sequential write frame without LibXR status dispatch.

Definition at line 2323 of file hpm_i2c.cpp.

2325{
2326 UNUSED(slave_addr);
2327 UNUSED(write_data);
2328 UNUSED(frame);
2329 UNUSED(check_ack);
2331}

◆ DoTransferWithFlags()

ErrorCode HPMI2C::DoTransferWithFlags ( uint16_t slave_addr,
RawData data,
uint16_t flags )
private

执行一段扩展标志事务,不做状态分发 / Execute one flag-based transfer without LibXR status dispatch.

Definition at line 2342 of file hpm_i2c.cpp.

2343{
2344 UNUSED(slave_addr);
2345 UNUSED(data);
2346 UNUSED(flags);
2348}

◆ EnsureClockReady()

ErrorCode HPMI2C::EnsureClockReady ( )
private

确保 I2C 源时钟已可用 / Ensure the I2C source clock is available.

Definition at line 2359 of file hpm_i2c.cpp.

2359{ return ErrorCode::NOT_SUPPORT; }

◆ EnsureControllerReady()

ErrorCode HPMI2C::EnsureControllerReady ( )
private

确保控制器已完成一次可用配置 / Ensure the controller has a usable configuration applied.

Definition at line 2361 of file hpm_i2c.cpp.

2361{ return ErrorCode::NOT_SUPPORT; }

◆ FillMemAddress()

void HPMI2C::FillMemAddress ( uint16_t mem_addr,
MemAddrLength len,
uint8_t out[2] )
staticprivate

按 BYTE_8/BYTE_16 格式填充寄存器地址字节 / Fill register address bytes according to BYTE_8/BYTE_16 format.

Definition at line 71 of file hpm_i2c.cpp.

72{
73 FillHpmI2cMemAddress(mem_addr, len, out);
74}

◆ FinishOperation()

template<typename Op >
static ErrorCode LibXR::HPMI2C::FinishOperation ( Op & op,
bool in_isr,
ErrorCode ans )
inlinestaticprivate

完成 LibXR 操作状态更新或回调 / Complete LibXR operation status update or callback dispatch.

Definition at line 910 of file hpm_i2c.hpp.

911 {
912 if (op.type != Op::OperationType::BLOCK)
913 {
914 op.UpdateStatus(in_isr, ans);
915 }
916 return ans;
917 }

◆ GetAddressMode()

AddressMode LibXR::HPMI2C::GetAddressMode ( ) const
inline

获取当前 HPM 主机寻址模式 / Get current HPM master addressing mode.

Returns
当前地址模式 / Current address mode.

Definition at line 293 of file hpm_i2c.hpp.

293{ return address_mode_; }
AddressMode address_mode_
当前主机寻址模式 / Current master addressing mode.
Definition hpm_i2c.hpp:926

◆ GetClockFreq()

uint32_t LibXR::HPMI2C::GetClockFreq ( ) const
inline

获取当前缓存的 I2C 源时钟频率 / Get cached I2C source clock frequency.

Returns
源时钟频率,单位 Hz;成功解析时钟前为 0 / Source clock frequency in Hz, or 0 before successful clock discovery.

Definition at line 497 of file hpm_i2c.hpp.

497{ return source_clock_hz_; }
uint32_t source_clock_hz_
缓存的源时钟频率 / Cached source clock frequency.
Definition hpm_i2c.hpp:921

◆ GetMaxSlaveAddress()

uint16_t HPMI2C::GetMaxSlaveAddress ( AddressMode mode)
staticprivate

获取指定寻址模式可接受的最大从地址 / Get the maximum valid slave address for the given mode.

Definition at line 56 of file hpm_i2c.cpp.

57{
58 return ResolveHpmI2cMaxSlaveAddress(mode);
59}

◆ GetWaitPolicy()

WaitPolicy LibXR::HPMI2C::GetWaitPolicy ( ) const
inline

获取当前实例的忙等超时策略 / Get the current busy-wait timeout policy.

Returns
当前策略 / Current policy.

Definition at line 287 of file hpm_i2c.hpp.

287{ return wait_policy_; }
WaitPolicy wait_policy_
当前忙等超时策略 / Current busy-wait timeout policy.
Definition hpm_i2c.hpp:924

◆ MemRead()

ErrorCode HPMI2C::MemRead ( uint16_t slave_addr,
uint16_t mem_addr,
RawData read_data,
ReadOperation & op,
MemAddrLength mem_addr_size = MemAddrLength::BYTE_8,
bool in_isr = false )
overridevirtual

I2C 从设备寄存器或存储器地址读取字节 / Read bytes from an I2C slave register or memory address.

该接口先发送寄存器/存储器地址,再进入读阶段。BYTE_8 只发送 mem_addr 低 8 位; BYTE_16 按高字节在前、低字节在后的顺序发送。 This API sends the register/memory address before the read phase. BYTE_8 sends only the low 8 bits of mem_addr; BYTE_16 sends the high byte first, then the low byte.

Parameters
slave_addr当前寻址模式下的从设备地址,不包含 R/W 位 / Slave address for the current addressing mode, without the R/W bit.
mem_addr读阶段前发送的寄存器或存储器地址 / Register or memory address sent before reading.
read_data目标缓冲区;size_ 为 0 时不访问总线并返回 OK。非零长度时 addr_ 必须非空,且 size_ 不超过 I2C_SOC_TRANSFER_COUNT_MAX / Destination buffer. A zero-size buffer completes with OK without bus access. For non-zero size, addr_ must be non-null and size_ must not exceed I2C_SOC_TRANSFER_COUNT_MAX.
opLibXR 读操作描述符,见类注释中的操作模式说明 / LibXR read operation descriptor. See class-level operation mode notes.
mem_addr_size寄存器地址宽度:BYTE_8 或 BYTE_16 / Register address width: BYTE_8 or BYTE_16.
in_isr仅用于 CALLBACK/POLLING 完成分发的中断上下文标志 / ISR-context flag forwarded only to CALLBACK/POLLING completion handling.
Returns
成功返回 OK;空缓冲指针返回 PTR_NULL;从地址超出当前寻址模式范围返回 ARG_ERR;寄存器地址长度枚举无效时返回 ARG_ERR; 读载荷长度超限返回 SIZE_ERR;其余返回 HPM SDK 状态转换后的错误码 / Returns OK on success, PTR_NULL for null non-empty buffer, SIZE_ERR for oversized read payload, ARG_ERR for slave addresses beyond the active addressing range or invalid register-address enum, or converted HPM SDK status otherwise.

Implements LibXR::I2C.

Definition at line 2403 of file hpm_i2c.cpp.

2405{
2406 UNUSED(slave_addr);
2407 UNUSED(mem_addr);
2408 UNUSED(read_data);
2409 UNUSED(mem_addr_size);
2410 return FinishOperation(op, in_isr, ErrorCode::NOT_SUPPORT);
2411}
static ErrorCode FinishOperation(Op &op, bool in_isr, ErrorCode ans)
完成 LibXR 操作状态更新或回调 / Complete LibXR operation status update or callback dispatch.
Definition hpm_i2c.hpp:910

◆ MemWrite()

ErrorCode HPMI2C::MemWrite ( uint16_t slave_addr,
uint16_t mem_addr,
ConstRawData write_data,
WriteOperation & op,
MemAddrLength mem_addr_size = MemAddrLength::BYTE_8,
bool in_isr = false )
overridevirtual

I2C 从设备寄存器或存储器地址写入字节 / Write bytes to an I2C slave register or memory address.

该接口先发送寄存器/存储器地址,再发送载荷。BYTE_8 只发送 mem_addr 低 8 位; BYTE_16 按高字节在前、低字节在后的顺序发送。零长度载荷合法,只写地址字节。 This API sends the register/memory address before the payload. BYTE_8 sends only the low 8 bits of mem_addr; BYTE_16 sends the high byte first, then the low byte. A zero-size payload is valid and writes only the address bytes.

Parameters
slave_addr当前寻址模式下的从设备地址,不包含 R/W 位 / Slave address for the current addressing mode, without the R/W bit.
mem_addr载荷前发送的寄存器或存储器地址 / Register or memory address sent before the payload.
write_data源载荷缓冲区;非零长度时 addr_ 必须非空;地址字节加载荷长度 不能超过 I2C_SOC_TRANSFER_COUNT_MAX / Source payload buffer. For non-zero size, addr_ must be non-null. Address bytes plus payload size must not exceed I2C_SOC_TRANSFER_COUNT_MAX.
opLibXR 写操作描述符,见类注释中的操作模式说明 / LibXR write operation descriptor. See class-level operation mode notes.
mem_addr_size寄存器地址宽度:BYTE_8 或 BYTE_16 / Register address width: BYTE_8 or BYTE_16.
in_isr仅用于 CALLBACK/POLLING 完成分发的中断上下文标志 / ISR-context flag forwarded only to CALLBACK/POLLING completion handling.
Returns
成功返回 OK;空载荷指针返回 PTR_NULL;从地址超出当前寻址模式范围返回 ARG_ERR;寄存器地址长度枚举无效时返回 ARG_ERR;地址加载荷长度超限返回 SIZE_ERR;其余返回 HPM SDK 状态转换后的错误码 / Returns OK on success, PTR_NULL for null non-empty payload, SIZE_ERR when address bytes plus payload exceed the hardware limit, ARG_ERR for slave addresses beyond the active addressing range or invalid register-address enum, or converted HPM SDK status otherwise.

Implements LibXR::I2C.

Definition at line 2413 of file hpm_i2c.cpp.

2416{
2417 UNUSED(slave_addr);
2418 UNUSED(mem_addr);
2419 UNUSED(write_data);
2420 UNUSED(mem_addr_size);
2421 return FinishOperation(op, in_isr, ErrorCode::NOT_SUPPORT);
2422}

◆ Read()

ErrorCode HPMI2C::Read ( uint16_t slave_addr,
RawData read_data,
ReadOperation & op,
bool in_isr = false )
overridevirtual

I2C 从设备读取字节 / Read bytes from an I2C slave.

Parameters
slave_addr当前寻址模式下的从设备地址,不包含 R/W 位 / Slave address for the current addressing mode, without the R/W bit.
read_data目标缓冲区;size_ 为 0 时不访问总线并返回 OK。非零长度时 addr_ 必须非空,且 size_ 不超过 I2C_SOC_TRANSFER_COUNT_MAX / Destination buffer. A zero-size buffer completes with OK without bus access. For non-zero size, addr_ must be non-null and size_ must not exceed I2C_SOC_TRANSFER_COUNT_MAX.
opLibXR 读操作描述符,见类注释中的操作模式说明 / LibXR read operation descriptor. See class-level operation mode notes.
in_isr仅用于 CALLBACK/POLLING 完成分发的中断上下文标志 / ISR-context flag forwarded only to CALLBACK/POLLING completion handling.
Returns
成功返回 OK;空缓冲指针返回 PTR_NULL;从地址超出当前寻址模式范围返回 ARG_ERR; 长度超限返回 SIZE_ERR;其余返回 HPM SDK 状态转换后的 TIMEOUT、BUSY、 NO_RESPONSE、CHECK_ERR 或 FAILED / Returns OK on success, PTR_NULL for null non-empty buffer, SIZE_ERR for oversized transfer, ARG_ERR for slave addresses beyond the active addressing range, or converted HPM SDK status such as TIMEOUT, BUSY, NO_RESPONSE, CHECK_ERR, or FAILED.

Implements LibXR::I2C.

Definition at line 2387 of file hpm_i2c.cpp.

2389{
2390 UNUSED(slave_addr);
2391 UNUSED(read_data);
2392 return FinishOperation(op, in_isr, ErrorCode::NOT_SUPPORT);
2393}

◆ RecoverController()

void HPMI2C::RecoverController ( )
private

复位并按缓存配置重建 I2C 控制器 / Reset and reinitialize the I2C controller with cached configuration.

Definition at line 2376 of file hpm_i2c.cpp.

2376{}

◆ ResolveMemAddressSize()

ErrorCode HPMI2C::ResolveMemAddressSize ( MemAddrLength len,
uint32_t & addr_size )
staticprivate

解析寄存器地址宽度枚举到字节数 / Resolve register-address enum to byte count.

Definition at line 66 of file hpm_i2c.cpp.

67{
68 return ResolveHpmI2cMemAddressSize(len, addr_size);
69}

◆ SequenceRead()

ErrorCode HPMI2C::SequenceRead ( uint16_t slave_addr,
RawData read_data,
SequenceFrame frame,
ReadOperation & op,
bool in_isr = false )

执行一段 HPM 主机顺序读事务 / Execute one HPM master sequential read frame.

Parameters
slave_addr当前寻址模式下的从设备地址,不包含 R/W 位 / Slave address in the current addressing mode, without the R/W bit.
read_data当前分段要读入的数据缓冲区,长度必须大于 0 / Destination buffer for this frame. Size must be greater than 0.
frame分段类型:FIRST/NEXT/LAST / Frame type: FIRST, NEXT, or LAST.
opLibXR 读操作描述符 / LibXR read operation descriptor.
in_isr仅用于状态分发的中断上下文标志 / ISR-context flag for status dispatch.
Returns
返回本段事务的最终错误码 / Final error code for this frame.

Definition at line 2435 of file hpm_i2c.cpp.

2437{
2438 UNUSED(slave_addr);
2439 UNUSED(read_data);
2440 UNUSED(frame);
2441 return FinishOperation(op, in_isr, ErrorCode::NOT_SUPPORT);
2442}

◆ SequenceWrite()

ErrorCode HPMI2C::SequenceWrite ( uint16_t slave_addr,
ConstRawData write_data,
SequenceFrame frame,
bool check_ack,
WriteOperation & op,
bool in_isr = false )

执行一段 HPM 主机顺序写事务 / Execute one HPM master sequential write frame.

Parameters
slave_addr当前寻址模式下的从设备地址,不包含 R/W 位 / Slave address in the current addressing mode, without the R/W bit.
write_data当前分段要写出的数据,长度必须大于 0 / Payload for this frame. Size must be greater than 0.
frame分段类型:FIRST/NEXT/LAST / Frame type: FIRST, NEXT, or LAST.
check_ack是否逐字节检查从机 ACK / Whether to check slave ACK byte by byte.
opLibXR 写操作描述符 / LibXR write operation descriptor.
in_isr仅用于状态分发的中断上下文标志 / ISR-context flag for status dispatch.
Returns
返回本段事务的最终错误码 / Final error code for this frame.

Definition at line 2424 of file hpm_i2c.cpp.

2427{
2428 UNUSED(slave_addr);
2429 UNUSED(write_data);
2430 UNUSED(frame);
2431 UNUSED(check_ack);
2432 return FinishOperation(op, in_isr, ErrorCode::NOT_SUPPORT);
2433}

◆ SetAddressMode()

ErrorCode HPMI2C::SetAddressMode ( AddressMode mode)

设置 HPM 主机寻址模式并重建控制器 / Set HPM master addressing mode and rebuild the controller.

Parameters
mode目标寻址模式,ADDR_7BIT 或 ADDR_10BIT / Target addressing mode, either ADDR_7BIT or ADDR_10BIT.
Returns
成功返回 OK;外设指针为空返回 PTR_NULL;时钟/配置重建失败时返回相应错误码 / Returns OK on success, PTR_NULL for null peripheral, or the underlying clock / configuration failure otherwise.
Note
LibXR::I2C 的通用 Configuration 目前只描述总线速率,因此 10-bit 控制 以 HPMI2C 扩展接口暴露,而不是塞进基类配置里 / LibXR::I2C::Configuration currently describes only bus speed, so 10-bit control is exposed as an HPMI2C extension instead of being packed into the generic base configuration.

Definition at line 2309 of file hpm_i2c.cpp.

2310{
2311 address_mode_ = mode;
2313}

◆ SetConfig()

ErrorCode HPMI2C::SetConfig ( Configuration config)
overridevirtual

应用 I2C 时序配置 / Apply I2C timing configuration.

Parameters
config目标 I2C 时钟配置 / Desired I2C clock configuration.
Returns
成功返回 OK;外设指针为空返回 PTR_NULL;源时钟无法解析返回 INIT_ERR; 时钟为 0 返回 ARG_ERR;非 100 kHz / 400 kHz / 1 MHz 的速率返回 NOT_SUPPORT; 其余返回 HPM SDK 初始化状态 / Returns OK on success, PTR_NULL for null peripheral pointer, INIT_ERR when source clock cannot be resolved, ARG_ERR for zero clock, NOT_SUPPORT for rates other than 100 kHz / 400 kHz / 1 MHz, or converted HPM SDK initialization status otherwise.

Implements LibXR::I2C.

Definition at line 2380 of file hpm_i2c.cpp.

2381{
2382 current_config_ = config;
2383 configured_ = false;
2385}

◆ SetWaitPolicy()

ErrorCode HPMI2C::SetWaitPolicy ( WaitPolicy policy)

设置当前实例的忙等超时策略 / Set the busy-wait timeout policy for this instance.

Parameters
policy新策略;所有字段必须非零 / New policy. Every field must be nonzero.
Returns
成功返回 OK;字段为 0 返回 ARG_ERR;后台 DMA 事务在途时返回 BUSY / Returns OK on success, ARG_ERR when any field is zero, or BUSY while a DMA-backed transfer is active.

Definition at line 76 of file hpm_i2c.cpp.

77{
78 if (policy.addr_hit_timeout_us == 0U || policy.stop_timeout_us == 0U ||
79 policy.bus_idle_timeout_us == 0U || policy.transfer_timeout_us == 0U)
80 {
81 return ErrorCode::ARG_ERR;
82 }
83
84#if LIBXR_HPM_I2C_HAS_DMA_MGR
85 if (AsyncTransferActive())
86 {
87 return ErrorCode::BUSY;
88 }
89#endif
90
91 wait_policy_ = policy;
92 return ErrorCode::OK;
93}
@ BUSY
忙碌 | Busy
@ OK
操作成功 | Operation successful
@ ARG_ERR
参数错误 | Argument error

◆ ShouldRecover()

bool HPMI2C::ShouldRecover ( hpm_stat_t status)
staticprivate

判断失败后是否需要重建控制器 / Decide whether the controller should be reinitialized after a failure.

Definition at line 2370 of file hpm_i2c.cpp.

2371{
2372 UNUSED(status);
2373 return false;
2374}

◆ TransferWithFlags() [1/2]

ErrorCode HPMI2C::TransferWithFlags ( uint16_t slave_addr,
ConstRawData data,
uint16_t flags,
WriteOperation & op,
bool in_isr = false )

执行一段 HPM 扩展标志主机写事务 / Execute one HPM master write transfer with extended SDK flags.

Parameters
slave_addr当前寻址模式下的从设备地址,不包含 R/W 位 / Slave address in the current addressing mode, without the R/W bit.
data要写出的数据缓冲区 / Data buffer to be transmitted.
flagsHPM 扩展事务标志组合;READ 位若被传入会被忽略 / Combined HPM extended transfer flags. The READ bit is ignored when provided.
opLibXR 写操作描述符 / LibXR write operation descriptor.
in_isr仅用于状态分发的中断上下文标志 / ISR-context flag for status dispatch.
Returns
返回事务最终错误码 / Final transfer error code.

Definition at line 2453 of file hpm_i2c.cpp.

2455{
2456 UNUSED(slave_addr);
2457 UNUSED(data);
2458 UNUSED(flags);
2459 return FinishOperation(op, in_isr, ErrorCode::NOT_SUPPORT);
2460}

◆ TransferWithFlags() [2/2]

ErrorCode HPMI2C::TransferWithFlags ( uint16_t slave_addr,
RawData data,
uint16_t flags,
ReadOperation & op,
bool in_isr = false )

执行一段 HPM 扩展标志主机事务 / Execute one HPM master transfer with extended SDK flags.

Parameters
slave_addr当前寻址模式下的从设备地址,不包含 R/W 位 / Slave address in the current addressing mode, without the R/W bit.
data数据缓冲区;按 flags 指示读或写 / Data buffer used for read or write according to flags.
flagsHPM 扩展事务标志组合 / Combined HPM extended transfer flags.
opLibXR 读写操作描述符 / LibXR read/write operation descriptor.
in_isr仅用于状态分发的中断上下文标志 / ISR-context flag for status dispatch.
Returns
返回事务最终错误码 / Final transfer error code.

Definition at line 2444 of file hpm_i2c.cpp.

2446{
2447 UNUSED(slave_addr);
2448 UNUSED(data);
2449 UNUSED(flags);
2450 return FinishOperation(op, in_isr, ErrorCode::NOT_SUPPORT);
2451}

◆ TryRecoverBusLines()

void HPMI2C::TryRecoverBusLines ( )
private

在 SDA 被拉低且硬件支持时尝试发出 I2C reset clocks / Try to generate I2C reset clocks when SDA is stuck low and the hardware supports it.

Definition at line 2378 of file hpm_i2c.cpp.

2378{}

◆ ValidateSlaveAddress()

ErrorCode HPMI2C::ValidateSlaveAddress ( uint16_t slave_addr) const
private

校验当前寻址模式下的从地址 / Validate slave address for the current addressing mode.

Definition at line 61 of file hpm_i2c.cpp.

62{
63 return ValidateHpmI2cSlaveAddress(address_mode_, slave_addr);
64}

◆ Write()

ErrorCode HPMI2C::Write ( uint16_t slave_addr,
ConstRawData write_data,
WriteOperation & op,
bool in_isr = false )
overridevirtual

I2C 从设备写入字节 / Write bytes to an I2C slave.

Parameters
slave_addr当前寻址模式下的从设备地址,不包含 R/W 位 / Slave address for the current addressing mode, without the R/W bit.
write_data源缓冲区;size_ 为 0 时不访问总线并返回 OK。非零长度时 addr_ 必须非空,且 size_ 不超过 I2C_SOC_TRANSFER_COUNT_MAX / Source buffer. A zero-size buffer completes with OK without bus access. For non-zero size, addr_ must be non-null and size_ must not exceed I2C_SOC_TRANSFER_COUNT_MAX.
opLibXR 写操作描述符,见类注释中的操作模式说明 / LibXR write operation descriptor. See class-level operation mode notes.
in_isr仅用于 CALLBACK/POLLING 完成分发的中断上下文标志 / ISR-context flag forwarded only to CALLBACK/POLLING completion handling.
Returns
成功返回 OK;空缓冲指针返回 PTR_NULL;从地址超出当前寻址模式范围返回 ARG_ERR; 长度超限返回 SIZE_ERR;其余返回 HPM SDK 状态转换后的 TIMEOUT、BUSY、 NO_RESPONSE、CHECK_ERR 或 FAILED / Returns OK on success, PTR_NULL for null non-empty buffer, SIZE_ERR for oversized transfer, ARG_ERR for slave addresses beyond the active addressing range, or converted HPM SDK status such as TIMEOUT, BUSY, NO_RESPONSE, CHECK_ERR, or FAILED.

Implements LibXR::I2C.

Definition at line 2395 of file hpm_i2c.cpp.

2397{
2398 UNUSED(slave_addr);
2399 UNUSED(write_data);
2400 return FinishOperation(op, in_isr, ErrorCode::NOT_SUPPORT);
2401}

Field Documentation

◆ address_mode_

AddressMode LibXR::HPMI2C::address_mode_
private
Initial value:

当前主机寻址模式 / Current master addressing mode.

Definition at line 926 of file hpm_i2c.hpp.

◆ auto_board_init_

bool LibXR::HPMI2C::auto_board_init_
private

是否自动调用板级初始化 / Whether board init is automatic.

Definition at line 943 of file hpm_i2c.hpp.

◆ clock_

clock_name_t LibXR::HPMI2C::clock_
private

I2C 源时钟名称 / I2C source clock name.

Definition at line 920 of file hpm_i2c.hpp.

◆ configured_

bool LibXR::HPMI2C::configured_ = false
private

是否已有成功配置 / Whether a valid config was applied.

Definition at line 928 of file hpm_i2c.hpp.

◆ current_config_

Configuration LibXR::HPMI2C::current_config_
private
Initial value:
{
100000}

最近一次成功总线时序配置 / Most recent successful bus-timing config.

Definition at line 922 of file hpm_i2c.hpp.

922 {
923 100000};

◆ i2c_

LibXRHpmI2cType* LibXR::HPMI2C::i2c_
private

I2C 外设实例 / I2C peripheral instance.

Definition at line 919 of file hpm_i2c.hpp.

◆ kMax10BitAddress

uint16_t LibXR::HPMI2C::kMax10BitAddress = 0x3FFU
staticconstexprprivate

当前 HPM 后端支持的最大 10-bit 从地址 / Maximum 10-bit slave address supported by the current HPM backend.

Definition at line 572 of file hpm_i2c.hpp.

◆ kMax7BitAddress

uint16_t LibXR::HPMI2C::kMax7BitAddress = 0x7FU
staticconstexprprivate

当前 HPM 后端支持的最大 7-bit 从地址 / Maximum 7-bit slave address supported by the current HPM backend.

Definition at line 566 of file hpm_i2c.hpp.

◆ source_clock_hz_

uint32_t LibXR::HPMI2C::source_clock_hz_ = 0
private

缓存的源时钟频率 / Cached source clock frequency.

Definition at line 921 of file hpm_i2c.hpp.

◆ wait_policy_

WaitPolicy LibXR::HPMI2C::wait_policy_
private
Initial value:
=
static constexpr WaitPolicy DefaultWaitPolicy()
返回默认 HPM I2C 忙等超时策略 / Return the default HPM I2C wait policy.
Definition hpm_i2c.hpp:226

当前忙等超时策略 / Current busy-wait timeout policy.

Definition at line 924 of file hpm_i2c.hpp.


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