Linux从用户空间 i2c,用户空间操作i2c(User space operation I2C).doc

用户空间操作i2c(User space operation I2C)

用户空间操作i2c(User space operation I2C)

Catalog

The first chapter user space using i2c_dev.................. 1.

1.1 prepare................................................ 1...

1.2 IOCTL control............................................. 1.

1.3 i2c_dev use routines.................................... 4.

1.3.1 (read) (/write).................................... 4.

1.3.2 I2C_RDWR.................................... 5...

A.1 i2c_dev in the user space interface.............................. 6.

The first chapter use i2c_dev user space

The I2C adapter is registered, users can also use their space. In the Linux kernel code file

The /include/linux/i2c-dev.c for each adapter to generate a master device number device node 89, to achieve the file

The operation of the user interface, I2C space can be accessed through the I2C device adapter node. The adapter number starting from 0, and

The adapter device node device number is the same.

The I2C adapter device node is /dev/i2c-x, where x is the number of representative figures, adapter. As the adapter series

The number is dynamically allocated (and related registration), we would like to know which one can see what the corresponding adapter number.

The contents of the file under the /sys/class/i2c-dev/ directory.

1.1 preparation.

In order to user space program operation I2C adapter, must contain the following sentences in the program:

#include

#include

The two header defines the structure and the need to use macros.

You can then open the device node. But on which one? Because the number is not fixed adapter. We run the following command in the end:

[root@zlg cat /sys/class/i2c-dev/i2c-0/name /]#

PNX4008-I2C0

[root@zlg cat /sys/class/i2c-dev/i2c-1/name /]#

PNX4008-I2C1

[root@zlg cat /sys/class/i2c-dev/i2c-2/name /]#

USB-I2C

If we want to open the second adapter, just its number is 1, the corresponding device node is /dev/i2c-1. You can open it in the following way:

Int fd;

If ((FD = open (/dev/i2c-1, O

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值