CI130X SDK API手册  2.2.0
本手册用于描述CI130X SDK各个组件和驱动API
ci130x_iic.h
浏览该文件的文档.
1 
11 #ifndef __CI130X_IIC_H_
12 #define __CI130X_IIC_H_
13 
14 #include <stdbool.h>
15 #include "ci130x_system.h"
16 #include "ci130x_scu.h"
17 #include "ci130x_core_eclic.h"
18 #include "ci130x_core_misc.h"
19 
20 #ifdef __cplusplus
21  extern "C"{
22 #endif
23 
34 typedef enum
35 {
37  IIC_NULL = 0,
38 }iic_base_t;
39 
43 typedef enum
44 {
45  LONG_TIME_OUT = 0X5FFFFF,
46  SHORT_TIME_OUT = 0XFFFF,
48 
52 typedef enum
53 {
58 
62 typedef enum
63 {
68 
72 typedef enum
73 {
75  IIC_M_READ = 1,
77 
78 typedef bool (*master_send_cb_t)(char* data, IIC_SendStateType state, IIC_AckType previous_ack);
79 typedef bool (*master_recv_cb_t)(char data, bool stop);
80 typedef bool (*slave_send_cb_t)(char* data, IIC_SendStateType state, IIC_AckType previous_ack);
81 typedef bool (*slave_recv_cb_t)(char data, bool stop);
82 
86 typedef struct
87 {
88  char *buf;
89  int size;
91  union{
92  int read_size;
93  int write_size;
94  };
96 
97 
98 /****************************************** 常用接口 **********************************************************/
99 void iic_polling_init(iic_base_t base, uint32_t speed, uint32_t slaveaddr, IIC_TimeOut timeout);
100 int32_t iic_master_polling_send(iic_base_t base, uint16_t addr, const char *buf, int32_t count, uint8_t *last_ack_flag);
101 int32_t iic_master_polling_recv(iic_base_t base, uint16_t addr, char *buf, int32_t count);
102 int32_t iic_master_multi_transmission(iic_base_t base, uint16_t addr, multi_transmission_msg *msg, int msg_count);
103 /*************************************************************************************************************/
104 /****************************************** 其他接口 **********************************************************/
105 int32_t iic_slave_polling_send(iic_base_t base, const char *buf, int32_t count, uint8_t *last_ack_flag);
106 int32_t iic_slave_polling_recv(iic_base_t base, char *buf, int32_t count);
107 void iic_interrupt_init(iic_base_t base, uint32_t speed, uint32_t slaveaddr, IIC_TimeOut timeout);
108 int32_t iic_master_interrupt_send(iic_base_t base, uint16_t addr, master_send_cb_t master_send_cb);
109 int32_t iic_master_interrupt_recv(iic_base_t base, uint16_t addr, master_recv_cb_t master_recv_cb);
110 int32_t iic_slave_interrupt_send(iic_base_t base, slave_send_cb_t slave_send_cb);
111 int32_t iic_slave_interrupt_recv(iic_base_t base, slave_recv_cb_t slave_recv_cb);
112 /*************************************************************************************************************/
113 void IIC_IRQHandler(iic_base_t base);
114 /*************************************************************************************************************/
115 
116 /****************************************** 兼容旧驱动接口 ***************************************************/
117 int32_t i2c_master_only_send(char slave_ic_address, const char *buf, int32_t count);
118 int32_t i2c_master_send_recv(char slave_ic_address, char *buf, int32_t send_len, int32_t rev_len);
119 int32_t i2c_master_only_recv(char slave_ic_address, char *buf, int32_t rev_len);
120 /*************************************************************************************************************/
121 
126 #ifdef __cplusplus
127 }
128 #endif
129 
130 #endif /*__CI130X_IIC_H_*/
131 /***************** (C) COPYRIGHT Chipintelli Technology Co., Ltd. *****END OF FILE****/
iic_multi_transmission_type
IIC 方向选择
Definition: ci130x_iic.h:72
三代芯片scu底层驱动接口头文件
Definition: ci130x_iic.h:36
内核相关其他驱动
bool(* slave_send_cb_t)(char *data, IIC_SendStateType state, IIC_AckType previous_ack)
Definition: ci130x_iic.h:80
#define HAL_IIC0_BASE
Definition: ci130x_system.h:484
iic_base_t
IIC控制器定义
Definition: ci130x_iic.h:34
int32_t i2c_master_only_recv(char slave_ic_address, char *buf, int32_t rev_len)
I2C 只接收数据
Definition: ci130x_iic.c:1367
int32_t iic_slave_polling_recv(iic_base_t base, char *buf, int32_t count)
iic slave 模式查询方式接收
Definition: ci130x_iic.c:886
int32_t iic_slave_polling_send(iic_base_t base, const char *buf, int32_t count, uint8_t *last_ack_flag)
iic slave 查询方式发送
Definition: ci130x_iic.c:769
int32_t i2c_master_send_recv(char slave_ic_address, char *buf, int32_t send_len, int32_t rev_len)
I2C 先发送数据,再接收数据
Definition: ci130x_iic.c:1336
Definition: ci130x_iic.h:64
Definition: ci130x_iic.h:75
Definition: ci130x_iic.h:74
char * buf
Definition: ci130x_iic.h:88
void IIC_IRQHandler(iic_base_t base)
iic中断统一处理函数
Definition: ci130x_iic.c:1052
Definition: ci130x_iic.h:55
Definition: ci130x_iic.h:66
IIC 传输结构体
Definition: ci130x_iic.h:86
Definition: ci130x_iic.h:37
int32_t iic_master_interrupt_send(iic_base_t base, uint16_t addr, master_send_cb_t master_send_cb)
iic master 模式中断发送注册并启动
Definition: ci130x_iic.c:640
chip级定义
Definition: ci130x_iic.h:56
IIC_SendStateType
IIC 发送状态选择
Definition: ci130x_iic.h:62
Definition: ci130x_iic.h:65
iic_multi_transmission_type flag
Definition: ci130x_iic.h:90
Definition: ci130x_iic.h:54
int32_t i2c_master_only_send(char slave_ic_address, const char *buf, int32_t count)
I2C 只发送数据
Definition: ci130x_iic.c:1311
Definition: ci130x_iic.h:46
bool(* slave_recv_cb_t)(char data, bool stop)
Definition: ci130x_iic.h:81
int32_t iic_master_polling_recv(iic_base_t base, uint16_t addr, char *buf, int32_t count)
iic master 查询接收
Definition: ci130x_iic.c:679
int32_t iic_slave_interrupt_recv(iic_base_t base, slave_recv_cb_t slave_recv_cb)
iic slave 中断方式接收注册(被动启动)
Definition: ci130x_iic.c:962
bool(* master_send_cb_t)(char *data, IIC_SendStateType state, IIC_AckType previous_ack)
Definition: ci130x_iic.h:78
void iic_polling_init(iic_base_t base, uint32_t speed, uint32_t slaveaddr, IIC_TimeOut timeout)
iic以查询方式初始化
Definition: ci130x_iic.c:435
int32_t iic_slave_interrupt_send(iic_base_t base, slave_send_cb_t slave_send_cb)
iic slave 中断方式发送注册(被动启动)
Definition: ci130x_iic.c:865
int32_t iic_master_interrupt_recv(iic_base_t base, uint16_t addr, master_recv_cb_t master_recv_cb)
iic master 中断方式接收注册并启动
Definition: ci130x_iic.c:730
IIC_TimeOut
IIC超时选择
Definition: ci130x_iic.h:43
IIC_AckType
IIC ACK状态选择
Definition: ci130x_iic.h:52
int32_t iic_master_multi_transmission(iic_base_t base, uint16_t addr, multi_transmission_msg *msg, int msg_count)
iic 传输多个消息
Definition: ci130x_iic.c:984
内核中断控制器驱动
bool(* master_recv_cb_t)(char data, bool stop)
Definition: ci130x_iic.h:79
int size
Definition: ci130x_iic.h:89
Definition: ci130x_iic.h:45
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 查询方式发送数据
Definition: ci130x_iic.c:589
void iic_interrupt_init(iic_base_t base, uint32_t speed, uint32_t slaveaddr, IIC_TimeOut timeout)
iic以中断方式初始化
Definition: ci130x_iic.c:510