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:
-
busNumberThe i2c bus to use
-
rawBooleanWhether 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:
-
modeEnum 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:
-
addressNumberCommunicate 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:
-
lengthNumberSize of read in bytes to make
Returns:
Data read
readReg
-
reg
Read byte from an i2c register
Parameters:
-
regNumberRegister to read from
Returns:
char read from register
readWordReg
-
reg
Read word from an i2c register
Parameters:
-
regNumberRegister to read from
Returns:
char read from register
writeByte
-
data
Write a byte on the bus
Parameters:
-
dataNumberThe 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:
-
lengthNumberSize of buffer to send
Returns:
Result of operation
writeReg
-
reg -
data
Write a byte to an i2c register
Parameters:
-
regNumberRegister to write to
-
dataNumberValue to write to register
Returns:
Result of operation
writeWordReg
-
reg -
data
Write a word to an i2c register
Parameters:
-
regNumberRegister to write to
-
dataNumberValue to write to register
Returns:
Result of operation