The I2C kernel device drivers provide access to the BCM2835 I2C interface.
In common with many other device drivers it makes 'files' available in the /dev/ folder of your system that you can write to and read from using ioctl commands.
The module HiPi::Device::I2C supports communication with i2c devices using the kernel device driver.
Note that you may also communicate with i2c devices using the userspace bcm2835 library wrapped in HiPi::BCM2835::I2C
You can have the device drivers loaded at system startup as described in the Loading Device Drivers Topic.
You can also load the device drivers dynamically with:
modprobe i2c_bcm2708 modprobe i2c_dev
The advantage of loading at startup is that the I2C device driver is configured to allow none root users to access the device files. These configuration settings also apply when using modprobe but your process would need root permissions to run modprobe.
In recent versions of Raspbian Wheezy the I2C device driver creates device files where the group is 'i2c' and this group has read write permissions. You can manage who has access to the i2c devices by adding and removing users to and from the i2c group.
The Raspberry Pi GPIO provides access to either 1 or 2 I2C devices depending on your board revision. Recent boards provide access to 2 peripherals using the device files:
/dev/i2c-1 is the default device available on the GPIO PAD1 pins. A pair of GPIO PAD5 pins can be configured to provide access to /dev/i2c-0.
On earlier revision 1 boards /dev/i2c-0 is the default device available on the GPIO PAD1 pins.
The HiPi Control GUI applicationWill allow you to manage the i2c group and device driver options.
The I2C driver accepts an option - baudrate - which defines the default communication speed for the i2c bus. The default setting is 100000. I have found that several devices do not work at this speed. This is because they employ a method called clock stretching that is not supported on current Raspberry Pi hardware or software. This issue can be overcome by making the speed of the bus slower. I have found that a baudrate of 32000 allows the problem devices I have come across to work.
To change the baudrate you could specify it as an option to modprobe:
modprobe i2c_bcm2708 baudrate=32000
To apply a setting as a default to be used every time the spidev driver is loaded we need to create a file in /etc/modprobe.d/ that contains the line:
options i2c_bcm2708 baudrate=32000
The HiPi Control GUI application will set or remove this option setting for you and allow you to manage the i2c group.