// #include "http://www.byvac.com//mBlib/flb/Library/2016/lib_i2c.bas"
This is mainly implemented for the MX170 as currently the MX370 has I2C functions as part of the ByPic but this may change. ** Only channel 1 is implemented
SCL1 is RB8 **
SDA1 is RB9 **
SDA2 is RB2
SCL2 is RB3
// SCL1 is RG2
// SDA1 is RG3
I2c must be opened before use, this opens it at the requested frequency, normally 100000 or 400000
This will send a start condition followed by a byte that is the address of the slave I2C device you want to communicate with. The address is the 8 bit address and for writing should be an even number but for reading should be an off number.
Puts a byte on to the I2C bus, the device must have been addressed first using i2c_start() with an even address.
This closes the I2C bus for that data exchange
This is the restart command, stop and start can be used instead.
i2c_rstart(address) // Not available on MX340
This will get a byte from the I2C bus, this device actually does the clocking and so the slave needs some additional information. Last is set to 0 if there are more bytes to get, set to 1 if this is the last byte required from the slave. Prior to using theis the start function must be used with an odd address.
x = i2c_getc(last)
A utility that will return the first address (between start and end) of any device that may happen to be on the bus.
i2c_find(start,end) ** This does not work on the MX370 devices
Example: print i2c_find(0x30,0xf0) // searches for addresses between 0x30 and 0xf0