' source in /Program Files/Coridium/BASIClib
FUNCTION I2COUT (DATApin, CLKpin, addr, OUTcnt, BYREF OUTlist as string)
I2COUT will send OUTcnt bytes from OUTlist bytes as i2c
serial data on CLKpin and DATApin to the i2c device at
addr. If OUTcnt is 0, then the string will be sent
until a 0, CR or LF character is found in OUTlist. If the i2c
device does not respond 0 is returned by I2COUT, otherwise 1.
I2COUT returns a 1 if an I2C device responds, else 0.
The data rate is 280Kb. See the #defines to
change this rate.
shortMessage(20) as STRING
' test the EEPROM 24LC02 on pins
0 == SDA and 1 == SCL
' address into EEPROM
shortMessage(1)= 11 ' data
present = I2COUT (0, 1,
0xA0, 8, shortMessage)
if present = 0 then print "NO i2c device ***"
Differences from other BASICs
- PBASIC output formatting not supported
- PBASIC regADDR and secondADDR are done in the OutputList
- no equivalent in Visual BASIC