I have a couple of questions to this PCF8574 driver I found in the web:
Code: Select all
int ReadPort(char PCF8574Port, byte PCF8574ID, char input)
{
byte cnt = 0x02;
byte I2CMsg[];
byte inbuf[];
byte Address = PCF8574ID;
byte nByteReady = 0;
int result = -1;
int loop;
ArrayBuild(I2CMsg, Address);
Wait(8);
while (loop == STAT_COMM_PENDING)
{
loop = I2CStatus(PCF8574Port, nByteReady);
}
if (I2CBytes(PCF8574Port, I2CMsg, cnt, inbuf))
{
result = inbuf[1];
}
return result;
}
- why is cnt =2 ? (I just have to read 1 Byte!)
- why is result to be found in inbuf[1] and not in [0] ?
- what is inbuf[0] for?