5#ifdef HAL_I2C_MODULE_ENABLED
44stm32_i2c_id_t STM32_I2C_GetID(I2C_TypeDef *hi2c);
53 id_(STM32_I2C_GetID(
hi2c->Instance)),
65 return ErrorCode::BUSY;
70 if (read_data.
size_ > dma_enable_min_size_)
76 read_buff_ = read_data;
78 if (op.
type == ReadOperation::OperationType::BLOCK)
80 return op.
data.sem_info.sem->
Wait(op.
data.sem_info.timeout);
92 if (op.
type == ReadOperation::OperationType::BLOCK)
94 return op.
data.sem_info.sem->
Wait(op.
data.sem_info.timeout);
105 return ErrorCode::BUSY;
112 if (write_data.
size_ > dma_enable_min_size_)
119 if (op.
type == WriteOperation::OperationType::BLOCK)
121 return op.
data.sem_info.sem->
Wait(op.
data.sem_info.timeout);
123 return ErrorCode::OK;
133 if (op.
type == WriteOperation::OperationType::BLOCK)
135 return op.
data.sem_info.sem->
Wait(op.
data.sem_info.timeout);
148 return ErrorCode::BUSY;
153 if (read_data.
size_ > dma_enable_min_size_)
160 read_buff_ = read_data;
162 if (op.
type == ReadOperation::OperationType::BLOCK)
164 return op.
data.sem_info.sem->
Wait(op.
data.sem_info.timeout);
166 return ErrorCode::OK;
180 if (op.
type == ReadOperation::OperationType::BLOCK)
182 return op.
data.sem_info.sem->
Wait(op.
data.sem_info.timeout);
195 return ErrorCode::BUSY;
202 if (write_data.
size_ > dma_enable_min_size_)
211 if (op.
type == WriteOperation::OperationType::BLOCK)
213 return op.
data.sem_info.sem->
Wait(op.
data.sem_info.timeout);
215 return ErrorCode::OK;
229 if (op.
type == WriteOperation::OperationType::BLOCK)
231 return op.
data.sem_info.sem->
Wait(op.
data.sem_info.timeout);
237 template <
typename,
typename =
void>
242 template <
typename T>
248 template <
typename T>
249 typename std::enable_if<!HasClockSpeed<T>::value>::type SetClockSpeed(
254 template <
typename T>
255 typename std::enable_if<HasClockSpeed<T>::value>::type SetClockSpeed(
269 return ErrorCode::NOT_SUPPORT;
274 return ErrorCode::INIT_ERR;
276 return ErrorCode::OK;
291 static STM32I2C *map[STM32_I2C_NUMBER];
常量原始数据封装类。 A class for encapsulating constant raw data.
size_t size_
数据大小(字节)。 The size of the data (in bytes).
const void * addr_
数据存储地址(常量)。 The storage address of the data (constant).
I2C(Inter-Integrated Circuit)接口类。 I2C (Inter-Integrated Circuit) interface class.
I2C()
默认构造函数。 Default constructor.
void UpdateStatus(bool in_isr, Args &&...args)
Updates operation status based on type.
void MarkAsRunning()
标记操作为运行状态。 Marks the operation as running.
union LibXR::Operation::@4 data
原始数据封装类。 A class for encapsulating raw data.
size_t size_
数据大小(字节)。 The size of the data (in bytes).
void * addr_
数据存储地址。 The storage address of the data.
ErrorCode MemWrite(uint16_t slave_addr, uint16_t mem_addr, ConstRawData write_data, WriteOperation &op, MemAddrLength mem_addr_size) override
向 I2C 设备指定寄存器写入数据。 Writes data to a specific register of an I2C device.
ErrorCode SetConfig(Configuration config) override
配置 I2C 设备参数。 Configures the I2C device settings.
ErrorCode MemRead(uint16_t slave_addr, uint16_t mem_addr, RawData read_data, ReadOperation &op, MemAddrLength mem_addr_size) override
从 I2C 设备指定寄存器读取数据。 Reads data from a specific register of an I2C device.
ErrorCode Write(uint16_t slave_addr, ConstRawData write_data, WriteOperation &op) override
向 I2C 设备写入数据。 Writes data to an I2C device.
ErrorCode Read(uint16_t slave_addr, RawData read_data, ReadOperation &op) override
读取 I2C 设备的数据。 Reads data from an I2C device.
ErrorCode Wait(uint32_t timeout=UINT32_MAX)
等待(减少)信号量 Waits (decrements) the semaphore
LibXR Color Control Library / LibXR终端颜色控制库
constexpr auto min(T1 a, T2 b) -> typename std::common_type< T1, T2 >::type
计算两个数的最小值
I2C 设备的配置信息结构体。 Configuration structure for an I2C device.