Hardware Reference
In-Depth Information
The i2c-tools package includes the following utilities:
i2cdetect : Detects peripherals on the I2C line
i2cdump : Dumps values from an I2C peripheral
i2cset : Sets I2C registers and values
i2cget : Gets I2C registers and values
Each of these utilities has a man page available for additional information. We'll be
using some of these commands in this chapter and in later parts of this topic.
I2C API
In this section, we'll look at the bare-metal C language API for the I2C bus transactions.
An application using this API is provided in Chapter 2 of Experimenting with Raspberry Pi
(Apress, 2014).
Kernel Module Support
Access to the I2C bus is provided through the use of kernel modules. If lsmod indicates
that the drivers are not loaded, you can load them at the command line:
$ sudo modprobe i2c-dev
$ sudo modprobe i2c-bcm2708
Once these modules are loaded, i2cdetect should be able to see bus-level support.
On Revision 2.0 and later Raspberry Pis, the i2c-0 bus is for internal use. The user bus is
shown as i2c-1 . On early Pis this is reversed.
$ i2cdetect -l
i2c-0 unknown bcm2708_i2c.0 N/A
i2c-1 unknown bcm2708_i2c.1 N/A
After the driver support is available, the device nodes should appear under /dev :
$ ls -l /dev/i2c
crw−rw−−−T 1 root root 89, 0 Feb 18 23:53 /dev/i2c−0
crw−rw−−−T 1 root root 89, 1 Feb 18 23:53 /dev/i2c−1
 
Search WWH ::




Custom Search