Module grisp_i2c

I2C driver API.

Description

I2C driver API.

This API is based on the Linux I2C User Space API . For a description of the I2C protocol see https://www.kernel.org/doc/Documentation/i2c/i2c-protocol.

Function Index

msgs/1Communicate with the I2C bus.

Function Details

msgs/1

msgs(Msgs::[Adr::integer() | {sleep, Time::integer()} | {write, Data::binary()} | {write, Data::binary(), Flags::integer()} | {read, Length::integer()} | {read, Length::integer(), Flags::integer()}]) -> LastResponse::any()

Communicate with the I2C bus.

The first entry in the list has to be the address as an integer. The entry {sleep, Time} can be used to add delays between messages. For possible flags see the Linux I2C User Space API .

Sending a read message {read, Length} the I2C_M_RD flag will be set automatcally. The Length is the number of bytes to be read.

Example

A read message like
 1> grisp_i2c:msgs([16#40, {read, 2}]).
will send an I2C message with
 addr  = 16#40
 flags = I2C_M_RD
 len   = 2
using the notation from https://www.kernel.org/doc/Documentation/i2c/i2c-protocol this message will look like:
 S 16#40 Rd [A] [Data] A [Data] NA P
A write message like
 2> grisp_i2c:msgs([16#40, {write, <<16#02>>}]).
will send an I2C message with
 addr  = 16#40
 flags = 16#0000
 len   = 1
 *buf  = 16#02
using the notation from https://www.kernel.org/doc/Documentation/i2c/i2c-protocol this message will look like:
 S 16#40 Wr [A] 16#02 P


Generated by EDoc