Home Documentation Tutorials API GitHub

I2C

The I2C API allows you to communicate over serial I2C interfaces.

Basics

Invoke I2C.open to open a I2C interface with a given I2C bus name. Read and write data to devices using read and write, where addr is the 7-bit address on the I2C bus:

i2c  := I2C.open("i2c-1")
i2c.write(5, Buf().writeI4(0x1234_abcd))
bytes := i2c.read(5, 4)
i2c.close

Once you are finished, call close to free the backing native process.