Skip to content

PPaques/i2c

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

I2C - Ruby I2C library

About

Interface to Linux I2C (a.k.a. TWI) implementations. Right now targeted at the Raspberry Pi, but should work with any linux i2c-dev I2C-hardware.

Structure

The library is split into two parts:

- A backend for accessing the I2C bus (right now only through the i2c-dev 
  in Linux, other impementations are possible).
- Drivers for I2C enabled ICs.

Installation

To use the i2c-dev backend it is necessary to load the “i2c-dev” linux kernel module. This is not done automatically even if the module for the underlying I2C-hardware is. To automatically load the i2c-dev driver on startup add it to /etc/modules. Also the device file (usually /dev/i2c-0) must be user accessible. A working (at least on a RaspberryPi running Raspbian) udev rule file is available (rules/88-i2c.rules) and can be installed to /etc/udev/rules.d/.

Backends

The backends are instantiated through the #I2C::create method. depending on the format of the passed bus descriptor the correct backend is invoked.

Right now there is only a i2c-dev backend available

i2c-dev Backend

Backend for the Linux I2C implementation. Accepts device file names as bus descriptors. E.g.

I2C.create(“/dev/i2c-0”) returns an instance of I2C::Dev attached to the first I2c bus on the system.

Drivers

MCP23017

16 bit IO-Expander MCP23017 from Microchip. Provides a wiringpi-ruby compatible API and may therefore be used as a drop-in replacement for IO tasks on a Raspberry Pi. Datasheet: ww1.microchip.com/downloads/en/DeviceDoc/21952b.pdf

MCP23008

8 bit IO-Expander MCP23008 from Microchip. Basically a small version of the MCP23017. Datasheet: ww1.microchip.com/downloads/en/DeviceDoc/21919e.pdf

Acknowledgements

The low-level IO (mainly in i2c-dev.rb) was extracted from Ruby-I2C (rubyforge.org/projects/i2c/) by Jonas Bähr <jonas.baehr@fs.ei.tum.de>

Copyright / Licence

This code may be used under the terms of the GNU General Public Licence, Version 2.

Copyright © 2012 Christoph Anderegg <christoph@christoph-anderegg.ch> Copyright © 2008 Jonas Bähr <jonas.baehr@fs.ei.tum.de>

About

Ruby I2C library

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Ruby 100.0%