I2c Class
An I2c object represents an i2c master and can talk multiple i2c slaves by selecting the correct address
Item Index
Methods
I2c
-
bus
-
raw
Instantiates an i2c bus. Multiple instances of the same bus can exist and the bus is not guaranteed to be on the correct address before read/write.
Parameters:
-
bus
NumberThe i2c bus to use
-
raw
BooleanWhether to disable pinmapper for your board
Returns:
frequency
-
mode
Sets the i2c Frequency for communication. Your board may not support the set frequency. Anyone can change this at any time and this will affect every slave on the bus
Parameters:
-
mode
Enum I2cModeFrequency to set the bus to
Returns:
Result of operation
address
-
address
Set the slave to talk to, typically called before every read/write operation
Parameters:
-
address
NumberCommunicate to the i2c slave on this address
Returns:
Result of operation
readByte
()
Number
Read exactly one byte from the bus
Returns:
char read from the bus
read
-
length
Read length bytes from the bus
Parameters:
-
length
NumberSize of read in bytes to make
Returns:
Data read
readReg
-
reg
Read byte from an i2c register
Parameters:
-
reg
NumberRegister to read from
Returns:
char read from register
readWordReg
-
reg
Read word from an i2c register
Parameters:
-
reg
NumberRegister to read from
Returns:
char read from register
writeByte
-
data
Write a byte on the bus
Parameters:
-
data
NumberThe byte to send on the bus
Returns:
Result of operation
write
-
length
Write length bytes to the bus, the first byte in the Buffer is the command/register to write
Parameters:
-
length
NumberSize of buffer to send
Returns:
Result of operation
writeReg
-
reg
-
data
Write a byte to an i2c register
Parameters:
-
reg
NumberRegister to write to
-
data
NumberValue to write to register
Returns:
Result of operation
writeWordReg
-
reg
-
data
Write a word to an i2c register
Parameters:
-
reg
NumberRegister to write to
-
data
NumberValue to write to register
Returns:
Result of operation