Difference between revisions of "Interfacing with I2C Devices"

From eLinux.org
Jump to: navigation, search
m (Formatting, capitalization)
Line 9: Line 9:
 
The TI BeagleBoard has 3 I²C buses available, which control a variety of on-board peripherals, including the DVI display driver and power sequencing.  As bus 2 is by far the easiest to connect to due to its presence on the 0.1" spaced expansion header, it is assumed the user will be controlling that bus for the purposes of this example.  However, by default bus 2 is disabled due to a lack of pull-up resistors on the board, so external pull-ups must be added and the kernel recompiled to enable i2c2.   
 
The TI BeagleBoard has 3 I²C buses available, which control a variety of on-board peripherals, including the DVI display driver and power sequencing.  As bus 2 is by far the easiest to connect to due to its presence on the 0.1" spaced expansion header, it is assumed the user will be controlling that bus for the purposes of this example.  However, by default bus 2 is disabled due to a lack of pull-up resistors on the board, so external pull-ups must be added and the kernel recompiled to enable i2c2.   
  
See [[BeagleBoard#Linux_kernel]] and [[BeagleBoardLinuxKernel]] for details on how to recompile your linux kernel.  To enable i2c2 specifically during that process, enable the setting during the "make menuconfig" step.   
+
See [[BeagleBoard#Linux_kernel]] and [[BeagleBoardLinuxKernel]] for details on how to recompile your Linux kernel.  To enable i2c2 specifically during that process, enable the setting during the "make menuconfig" step.   
  
  
Line 28: Line 28:
 
= External Links =
 
= External Links =
  
[http://en.wikipedia.org/wiki/I%C2%B2C Wikipedia I²C Page]
+
* [http://en.wikipedia.org/wiki/I%C2%B2C Wikipedia I²C Page]
[http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=blob;f=Documentation/i2c/dev-interface Linux Kernel I2C Documentation]
+
* [http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=blob;f=Documentation/i2c/dev-interface Linux Kernel I2C Documentation]
  
 
[[Category:Robotics]]
 
[[Category:Robotics]]

Revision as of 12:18, 27 April 2010

This page is meant to provide some basic information about how to interface with I²C devices through the /dev/i2c interface. The I²C bus is commonly used to connect relatively low-speed sensors and other peripherals to equipment varying in complexity from a simple microcontroller to a full-on motherboard. I²C is extremely popular due to its ease-of-use and ability to control multiple peripherals while utilizing only two pins on the host controller. Although I2C has a variety of modes, this page will deal purely with communication between a Linux-based master and a slave peripheral for the time being.

Code

Note: Examples shown on this page were developed based on a Texas Instruments BeagleBoard and some changes will be required depending on the system being utilized.

Beagleboard I2C2 Enable

The TI BeagleBoard has 3 I²C buses available, which control a variety of on-board peripherals, including the DVI display driver and power sequencing. As bus 2 is by far the easiest to connect to due to its presence on the 0.1" spaced expansion header, it is assumed the user will be controlling that bus for the purposes of this example. However, by default bus 2 is disabled due to a lack of pull-up resistors on the board, so external pull-ups must be added and the kernel recompiled to enable i2c2.

See BeagleBoard#Linux_kernel and BeagleBoardLinuxKernel for details on how to recompile your Linux kernel. To enable i2c2 specifically during that process, enable the setting during the "make menuconfig" step.


B

SDA_23

SCL_24

Tested Devices

External Links