i2c

A collection of i2c related words

I2C

This package provides some more or less
generic I2C related words. They are generic
in a sense that they depend on a low level
hardware driver, that provides some very
basic routines to access the I2C interface.
They are based on the amforth recipe
http://amforth.sourceforge.net/TG/recipes/I2C-Generic.html

They are tested with amforth on an Atmega with
it's hardware I2C module called TWI.

The driver uses the following hardware low level words, that
the user has to provide.

i2c.wait ( -- )
wait for the bus

i2c.start ( -- )
send start condition

i2c.stop ( -- )
send stop condition

i2c.restart ( -- )
send the restart condition

i2c.tx ( c -- )
send 1 byte

i2c.rx ( -- c )
receive 1 byte, send ACK

i2c.rxn ( -- c )
receive 1 byte, send NACK

The following two words are not essential but
are useful for tools and checks.

i2c.status ( -- n )
get i2c status in a system specific way

i2c.ping? ( addr -- f )
detect the presence of a device on the bus, f is true if a device
at addr responds

i2c.frt

above the specific driver words some generic but
still low level words.