I2C API

It is possible to communicate with devices via I2C.

#create i2c device on i2c address 0x77
i2c = I2C(0x77)
i2c.write_raw8(123)
class kervi.hal.i2c.II2CDeviceDriver
read_S16(register, little_endian=True)

Read a signed 16-bit value from the specified register, with the specified endianness (default little endian, or least significant byte first).

read_S16BE(register)

Read a signed 16-bit value from the specified register, in big endian byte order.

read_S16LE(register)

Read a signed 16-bit value from the specified register, in little endian byte order.

read_S8(register)

Read a signed byte from the specified register.

read_U16(register, little_endian=True)

Read an unsigned 16-bit value from the specified register, with the specified endianness (default little endian, or least significant byte first).

read_U16BE(register)

Read an unsigned 16-bit value from the specified register, in big endian byte order.

read_U16LE(register)

Read an unsigned 16-bit value from the specified register, in little endian byte order.

read_U8(register)

Read an unsigned byte from the specified register.

read_list(register, length)

Read a length number of bytes from the specified register. Results will be returned as a bytearray.

read_raw8()

Read an 8-bit value on the bus (without register).

reverse_byte_order(data)

Reverses the byte order of an int (16-bit) or long (32-bit) value.

write16(register, value)

Write a 16-bit value to the specified register.

write8(register, value)

Write an 8-bit value to the specified register.

write_list(register, data)

Write bytes to the specified register.

write_raw8(value)

Write an 8-bit value on the bus (without register).