I2CIN
Syntax
I2CIN pin, slaveADDR, [opt1, [... opt5,]] [ InputList ] InputList = variable | stringname$ \count | arrayname \count [, InputList]
Description
I2CIN will read a series of bytes from an I2C slave device. pin is any expression defining the SDA pin to use. pin+1 will be designated the SCL pin. slaveADDR will select a device on the I2C bus. Up to 5 optional byte values may be sent out prior to reading the InputList. After that a series of bytes will be read from the slave to fill the InputList. The InputList enclosed in [] can contain variables or strings. When using a string a count must be specified defines the number of bytes to be copied into the string. I2C is a byte oriented bus, so each transaction will either send a byte value (0 to 255) or receive a byte for each element of the InputList. Data is shifted in at 380 Kbits/sec.
Example
DIM A$(10)
I2CIN 1,$30,$10, [A$ \10] ' read 10 bytes
from
slave $30 register $10 connected on pins 1,2
I2CIN 5,$40,$20, [X]
' read a single byte from slave $40 register $20 on pins 5,6
Differences from other BASICs
- PBASIC output formatting not supported
- PBASIC secondADDR specification is seperated by , rather than \
- no equivalent in Visual BASIC