embello

Embedded software from JeeLabs

Embello Home Page
Hardware Documentation
Forth Library Documentation

I2C communication driver

This describes the portable bit-banged version of the I2C driver.

Each I2C transaction consists of the following steps:

API

: i2c-init ( -- )  \ initialise bit-banged I2C
: i2c-addr ( u -- )  \ start a new I2C transaction
: i2c-xfer ( u -- nak )  \ prepare for the reply
: >i2c ( u -- )  \ send one byte out to the I2C bus
: i2c> ( -- u )  \ read one byte back from the I2C bus
: i2c. ( -- )  \ scan and report all I2C devices on the bus

Constants

The SCL and SDA constants should be defined before including this driver, if you want to use I2C on other pins than the default PB6 and PB7, respectively.