![]() |
CI130X SDK API手册
2.2.0
本手册用于描述CI130X SDK各个组件和驱动API
|
CI130X芯片iic驱动 更多...
结构体 | |
struct | multi_transmission_msg |
IIC 传输结构体 更多... | |
union | multi_transmission_msg.__unnamed__ |
类型定义 | |
typedef bool(* | master_send_cb_t) (char *data, IIC_SendStateType state, IIC_AckType previous_ack) |
typedef bool(* | master_recv_cb_t) (char data, bool stop) |
typedef bool(* | slave_send_cb_t) (char *data, IIC_SendStateType state, IIC_AckType previous_ack) |
typedef bool(* | slave_recv_cb_t) (char data, bool stop) |
枚举 | |
enum | iic_base_t { IIC0 = HAL_IIC0_BASE, IIC_NULL = 0 } |
IIC控制器定义 更多... | |
enum | IIC_TimeOut { LONG_TIME_OUT = 0X5FFFFF, SHORT_TIME_OUT = 0XFFFF } |
IIC超时选择 更多... | |
enum | IIC_AckType { IIC_ACKTYPE_ERR = -1, IIC_ACKTYPE_ACK = 0, IIC_ACKTYPE_NACK = 1 } |
IIC ACK状态选择 更多... | |
enum | IIC_SendStateType { IIC_SENDSTATE_OK = 0, IIC_SENDSTATE_STOP = 1, IIC_SENDSTATE_NOTIFY = 2 } |
IIC 发送状态选择 更多... | |
enum | iic_multi_transmission_type { IIC_M_WRITE = 0, IIC_M_READ = 1 } |
IIC 方向选择 更多... | |
函数 | |
void | iic_polling_init (iic_base_t base, uint32_t speed, uint32_t slaveaddr, IIC_TimeOut timeout) |
iic以查询方式初始化 更多... | |
int32_t | iic_master_polling_send (iic_base_t base, uint16_t addr, const char *buf, int32_t count, uint8_t *last_ack_flag) |
iic master 查询方式发送数据 更多... | |
int32_t | iic_master_polling_recv (iic_base_t base, uint16_t addr, char *buf, int32_t count) |
iic master 查询接收 更多... | |
int32_t | iic_master_multi_transmission (iic_base_t base, uint16_t addr, multi_transmission_msg *msg, int msg_count) |
iic 传输多个消息 更多... | |
int32_t | iic_slave_polling_send (iic_base_t base, const char *buf, int32_t count, uint8_t *last_ack_flag) |
iic slave 查询方式发送 更多... | |
int32_t | iic_slave_polling_recv (iic_base_t base, char *buf, int32_t count) |
iic slave 模式查询方式接收 更多... | |
void | iic_interrupt_init (iic_base_t base, uint32_t speed, uint32_t slaveaddr, IIC_TimeOut timeout) |
iic以中断方式初始化 更多... | |
int32_t | iic_master_interrupt_send (iic_base_t base, uint16_t addr, master_send_cb_t master_send_cb) |
iic master 模式中断发送注册并启动 更多... | |
int32_t | iic_master_interrupt_recv (iic_base_t base, uint16_t addr, master_recv_cb_t master_recv_cb) |
iic master 中断方式接收注册并启动 更多... | |
int32_t | iic_slave_interrupt_send (iic_base_t base, slave_send_cb_t slave_send_cb) |
iic slave 中断方式发送注册(被动启动) 更多... | |
int32_t | iic_slave_interrupt_recv (iic_base_t base, slave_recv_cb_t slave_recv_cb) |
iic slave 中断方式接收注册(被动启动) 更多... | |
void | IIC_IRQHandler (iic_base_t base) |
iic中断统一处理函数 更多... | |
int32_t | i2c_master_only_send (char slave_ic_address, const char *buf, int32_t count) |
I2C 只发送数据 更多... | |
int32_t | i2c_master_send_recv (char slave_ic_address, char *buf, int32_t send_len, int32_t rev_len) |
I2C 先发送数据,再接收数据 更多... | |
int32_t | i2c_master_only_recv (char slave_ic_address, char *buf, int32_t rev_len) |
I2C 只接收数据 更多... | |
CI130X芯片iic驱动
struct multi_transmission_msg |
IIC 传输结构体
成员变量 | ||
---|---|---|
union multi_transmission_msg | __unnamed__ | |
char * | buf |
数据缓存 |
iic_multi_transmission_type | flag |
传输模式 |
int | size |
数据长度 |
typedef bool(* master_recv_cb_t) (char data, bool stop) |
typedef bool(* master_send_cb_t) (char *data, IIC_SendStateType state, IIC_AckType previous_ack) |
typedef bool(* slave_recv_cb_t) (char data, bool stop) |
typedef bool(* slave_send_cb_t) (char *data, IIC_SendStateType state, IIC_AckType previous_ack) |
int32_t i2c_master_only_recv | ( | char | slave_ic_address, |
char * | buf, | ||
int32_t | rev_len | ||
) |
I2C 只接收数据
slave_ic_address | I2C传输数据的7位SLAVE设备地址 |
buf | 接收数据缓存指针 |
rev_len | 接收数据字节个数 |
int32_t i2c_master_only_send | ( | char | slave_ic_address, |
const char * | buf, | ||
int32_t | count | ||
) |
I2C 只发送数据
client | : I2C传输数据的7位SLAVE设备地址 |
buf | : 发送数据缓存指针 |
count | : 发送数据字节个数 |
int32_t i2c_master_send_recv | ( | char | slave_ic_address, |
char * | buf, | ||
int32_t | send_len, | ||
int32_t | rev_len | ||
) |
I2C 先发送数据,再接收数据
slave_ic_address | : I2C传输数据的7位SLAVE设备地址 |
buf | 发送/接收数据缓存指针 |
send_len | 发送数据字节个数 |
rev_len | 接收数据字节个数 |
void iic_interrupt_init | ( | iic_base_t | base, |
uint32_t | speed, | ||
uint32_t | slaveaddr, | ||
IIC_TimeOut | timeout | ||
) |
iic以中断方式初始化
base | iic号 |
speed | 时钟速度 |
slaveaddr | 配置为0则为master模式,否则为slave模式,并使用这个只作为addr |
timeout | 超时时间 |
void IIC_IRQHandler | ( | iic_base_t | base | ) |
iic中断统一处理函数
base | iic号 |
int32_t iic_master_interrupt_recv | ( | iic_base_t | base, |
uint16_t | addr, | ||
master_recv_cb_t | master_recv_cb | ||
) |
iic master 中断方式接收注册并启动
base | iic号 |
addr | 目标slave地址 |
master_recv_cb | 接收数据的回调函数,需要用户实现在该函数会将每个接收到的字节下发并获取是否继续发送的信息 |
int32_t iic_master_interrupt_send | ( | iic_base_t | base, |
uint16_t | addr, | ||
master_send_cb_t | master_send_cb | ||
) |
iic master 模式中断发送注册并启动
base | iic号 |
addr | 目标slave地址 |
master_send_cb | 发送回调函数,用户需要实现该函数,待开始发送时中断里会调用该还是获取发送数据以及通知发送状态 |
int32_t iic_master_multi_transmission | ( | iic_base_t | base, |
uint16_t | addr, | ||
multi_transmission_msg * | msg, | ||
int | msg_count | ||
) |
iic 传输多个消息
base | iic号 |
addr | SLAVE的7位设备地址 |
msg | 消息指针 |
msg_count | 消息数量 |
int32_t iic_master_polling_recv | ( | iic_base_t | base, |
uint16_t | addr, | ||
char * | buf, | ||
int32_t | count | ||
) |
iic master 查询接收
base | iic号 |
addr | 目标slave地址 |
buf | 数据存储buff |
count | 打算接收的数据个数 |
int32_t iic_master_polling_send | ( | iic_base_t | base, |
uint16_t | addr, | ||
const char * | buf, | ||
int32_t | count, | ||
uint8_t * | last_ack_flag | ||
) |
iic master 查询方式发送数据
base | iic号 |
addr | 目标slave地址 |
buf | 待发送的数据buff |
count | 需要发送的数据个数 |
last_ack_flag | 用来返回数据发送完毕后最好一次收到ack or nack |
void iic_polling_init | ( | iic_base_t | base, |
uint32_t | speed, | ||
uint32_t | slaveaddr, | ||
IIC_TimeOut | timeout | ||
) |
iic以查询方式初始化
base | iic号 |
speed | 时钟速度 |
slaveaddr | 配置为0则为master模式,否则为slave模式,并使用这个只作为addr |
timeout | 超时时间 |
int32_t iic_slave_interrupt_recv | ( | iic_base_t | base, |
slave_recv_cb_t | slave_recv_cb | ||
) |
iic slave 中断方式接收注册(被动启动)
base | iic号 |
slave_recv_cb | 数据接收回调函数,需要用户实现,该函数会将接收的数据传入并获取是否继续接收的状态 |
int32_t iic_slave_interrupt_send | ( | iic_base_t | base, |
slave_send_cb_t | slave_send_cb | ||
) |
iic slave 中断方式发送注册(被动启动)
base | iic号 |
slave_send_cb | 中断发送回调函数,需要用户编写,在该函数会请求待发送的数据并通知发送中的ack以及中断状态 |
int32_t iic_slave_polling_recv | ( | iic_base_t | base, |
char * | buf, | ||
int32_t | count | ||
) |
iic slave 模式查询方式接收
base | iic号 |
buf | 待接收数据buff |
count | 打算接收的数据个数 |
int32_t iic_slave_polling_send | ( | iic_base_t | base, |
const char * | buf, | ||
int32_t | count, | ||
uint8_t * | last_ack_flag | ||
) |
iic slave 查询方式发送
base | iic号 |
buf | 待发送的数据buff |
count | 待发送的数据数 |
last_ack_flag | 最后一次发送收到的ack |