Skip to content

tonyrog/i2c

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

72 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

i2c

i2c is an erlang application for controlling the i2c (Inter-Integrated Circuit) linux interface.

Dependencies

To build rfZone you will need a working installation of Erlang R15B (or later).
Information on building and installing Erlang/OTP can be found here (more info).

rfZone is built using rebar that can be found here, with building instructions here.

Download

Clone the repository in a suitable location:

$ git clone git://github.com/tonyrog/i2c.git

Configuration

Raspberry pi

Comment out (enable) the i2c blacklist entry in /etc/modprove.d/raspo-blacklist.conf, it should read:

# blacklist i2c-bcm2708

Install the i2c tools:

sudo apt-get install i2c-tools

Load the driver:

sudo modprobe i2c-dev

Test the driver - example, list the i2c supported functions:

sudo i2cdetect -F 0

Run

Run

i2c is started in a standard erlang fashion:

$ erl
(node@host) 1> application:start(i2c).

Experiment without hardware

modprobe i2c-stub

API

The following interface functions exist:

  • opent
  • close
  • set_retries
  • set_timeout
  • set_slave
  • set_slave_force
  • set_tenbit
  • set_pec
  • get_funcs
  • rdwr
  • smbus

For details see the source code documentation or the source code.

Documentation

i2c is (partly) documented using edoc. To generate the documentation do:

$ cd i2c
$ rebar doc

The result is a collection of html-documents under i2c/doc.