Changing i2c(8) utility in FreeBSD to work on Raspberry Pi

As we already know standard i2c(8) utility does not work in FreeBSD on the Raspberry Pi.
I have corrected source code of the i2c(8) utility to work on Raspberry Pi.

The patch to the original source code and the updated source code are available here: https://github.com/vzaigrin/newi2c

To get source code of the original i2c(8) utility we need:

After that we can to apply patch to the original source code of i2c utility:

newi2c1

Then we can compile and install it:

newi2c2

We can also just to compile the updated source code:
cc -o i2c newi2c.c
cp i2c /usr/sbin
chown root:wheel /usr/bin/i2c
chmod 555 /usr/sbin/i2c

Let’s try to work with the new i2c(8).
I have connected to my Raspberry Pi the DS1307 Real Time Clock breakout board.
Starting from 0x08H offset it has 56 bytes available as RAM.
So we can read and write to it without changing the time set on it.

newi2c3

When we want to write data and enter from the keyboard 0 we does not write zero, we write the value of symbol '0'. That is 30 in HEX.

Also when we enter on the keyboard abcd we write values 61 62 63 64.
ASCII table is available here: http://en.wikipedia.org/wiki/ASCII

For ‘zeroing’ registers we need to write zero to its.
Zero we can get from the /dev/zero device.

Advertisements

One thought on “Changing i2c(8) utility in FreeBSD to work on Raspberry Pi

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s