天嵌二次封装库使用手册  V2.1.2
lib_i2c.h
浏览该文件的文档.
1 
7 #ifndef LINUX_LIBV2_SOURCE_I2C_LIB_I2C_H_
8 #define LINUX_LIBV2_SOURCE_I2C_LIB_I2C_H_
9 
10 // Copyright 2024
11 
12 #include <stdio.h>
13 #include <fcntl.h>
14 #include <stdlib.h>
15 #include <string.h>
16 #include <linux/i2c-dev.h>
17 #include <errno.h>
18 #include <linux/i2c.h>
19 #include <sys/types.h>
20 #include <sys/stat.h>
21 #include <sys/ioctl.h>
22 #include <unistd.h>
23 
24 #ifdef __cplusplus
25 #define I2C_API extern "C"
26 #else
27 #define I2C_API
28 #endif
29 
38  I2C_API int i2c_read(int fd, unsigned short addr, unsigned char *reg, unsigned char *rbuf, int len);
49  I2C_API int i2c_write(int fd, unsigned char addr, unsigned char *tbuf, int len);
50 
51 #endif
I2C_API int i2c_read(int fd, unsigned short addr, unsigned char *reg, unsigned char *rbuf, int len)
读取从设备中指定寄存器的内容。
#define I2C_API
Definition: lib_i2c.h:27
I2C_API int i2c_write(int fd, unsigned char addr, unsigned char *tbuf, int len)
向从设备中指定寄存器写数据