Roadrunner technical documentation Buy

How to use the I2C ports

This article illustrates how to use the I2C ports on Acme Systems Road Runner SOM based on Microchip SAMA5D27 MPU

The I2C bus lines are located on the following pins:

Signal Per A Per B Per C Per D Per E Per F
TWD0 SDA PD21 PB31 PC27 PC29
TWCK0 SCL PD22 PC0 PC28 PC30
TWD1 SDA PD4 PD19 PC6
TWCK1 SCL PD5 PD20 PC7

Kernel configuration

Device Drivers  --->
  I2C support  ---> 
    <*>   I2C device interface
          I2C Hardware Bus support  ---> 
          <*> Atmel AT91 I2C Two-Wire interface (TWI) 

Device tree

i2c0: i2c@f8028000 {
    dmas = <0>, <0>;
    pinctrl-names = "default";
    pinctrl-0 = <&pinctrl_i2c0_default>;
    i2c-sda-hold-time-ns = <350>;
    status = "okay";
};

i2c1: i2c@fc028000 {
    dmas = <0>, <0>;
    pinctrl-names = "default";
    pinctrl-0 = <&pinctrl_i2c1_default>;
    status = "okay";
};

pinctrl_i2c0_default: i2c0_default {
    pinmux = <PIN_PD21__TWD0>,
         <PIN_PD22__TWCK0>;
    bias-disable;
};

pinctrl_i2c1_default: i2c1_default {
    pinmux = <PIN_PD4__TWD1>,
         <PIN_PD5__TWCK1>;
    bias-disable;
};

Using I2C from user space

i2c-tools

The faster way to do the first experiments with this board is by installing and using the i2c-tools.

i2c-tools is a package contains a heterogeneous set of I2C tools for Linux such as:

  • a bus probing tool
  • a chip dumper
  • a register-level access helpers
  • an EEPROM decoding scripts
  • ...and more

To install i2c-tools on the FOX Board just type:

apt-get update
apt-get install i2c-tools

Using i2cdetect

i2cdetect is an userspace program to scan an I2C bus for devices. It outputs a table with the list of detected devices on the specified bus.

Example of use:

i2cdetect -y 0

     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f                             
00:          -- -- -- -- -- -- -- -- -- -- -- -- --                             
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --                             
20: 20 -- -- -- -- -- -- -- -- -- -- -- -- -- -- --                             
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --                             
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --                             
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --                             
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --                             
70: -- -- -- -- -- -- -- --                                                     

In this case a device has been detected on address 20 hex.

i2cset and i2cset

i2cset is a small helper program to set registers visible through the I2C bus.

The follow simple command writes the byte value 255 to the I2C device at address 20 hex on the i2c bus 0 (/dev/i2c-0).

i2cset -y 0 0x20 255

If for example you are using a DAISY-22 module with a PCF8574 I2C I/O expander this command will set all the GPIO lines to 1.

i2cget i2cget is a small helper program to read registers visible through the I2C bus.

The follow simple command read a byte from an I2C device at address 20 hex on the i2c bus 0 (/dev/i2c-0).

i2cget -y 0 0x20 0x01

Links

Related products

RoadRunner D2

Info Doc Buy

  • CPU Microchip SAMA5D27
  • Cortex A5 @ 500 MHz
  • Very low power consumption:
    396mW in full speed mode
    198mW at Linux prompt
    17mW in standby mode
    10mW in suspend to RAM mode
  • Armhf architecture
  • DDR3L RAM 256 MB
  • QuadSPI 0/16/64/128MB
  • Size: 40x30 mm
  • Plug-in module
  • 200 pins 0.4 mm pitch
  • TFT parallel interface
  • Boot from internal Quad SPI or external uSD/eMMC
  • Linux Kernel 5.15 LTS
  • Debian, Buildroot and Yocto
  • Open source drivers
H10

Info Doc Buy

  • Single Board Computer based on RoadRunner Linux SOM (Included)
  • Classic "Credit Card" form factor
  • Two USB Host 2.0 ports (one configurable as USB client on the USB-C connector)
  • One 10/100 Mbit/s Lan port
  • Two AcmeSensor ports
  • Double placements for 2.54mm pitch 20x2 pinstrips (not soldered) for GPIOS, SPI, I2C, Serial etc ports
  • Credit Card footprint

Info Buy

  • All the circuitries you need to test the RoadRunner SOM
  • USB host, USB device, Ethernet port, MicroSD socket
  • Test points for power consumption measurements
  • All the Roadrunner signals exposed on 2.54mm pitch pins
  • On-board supercap for RTC and backup memory circuit

Home page Roadrunner technical documentation Buy