HI Ti,
i try to send a data through i2c but didn"t find a error. please help me.
void writecommand(uint8_t *cmd, uint8_t cmdlen)
{
// I2C command write.
uint8_t checksum;
uint8_t txBuffer[9];
// uint8_t rxBuffer[0];
cmdlen++;
usleep(2000);
// I2C START
i2cTransaction.writeBuf = txBuffer;
// i2cTransaction.readBuf = rxBuffer;
i2cTransaction.writeCount = 9;
// i2cTransaction.readCount = 0;
checksum = PN532_PREAMBLE + PN532_PREAMBLE + PN532_STARTCODE2;
i2cTransaction.slaveAddress = PN532_I2C_ADDRESS;
txBuffer[0] = PN532_PREAMBLE; // 0x00
txBuffer[1] = PN532_PREAMBLE; // 0x00
txBuffer[2] = PN532_STARTCODE2;// 0xFF
txBuffer[3] = cmdlen;
txBuffer[4] = ~cmdlen + 1;
txBuffer[5] = PN532_HOSTTOPN532;// 0xD4
checksum += PN532_HOSTTOPN532;
uint8_t i = 0;
for (i=0; i<cmdlen-1; i++) {
txBuffer[6]=cmd[i];
checksum += cmd[i];
}
txBuffer[7]=~checksum;
txBuffer[8]=PN532_POSTAMBLE;
I2C_transfer(i2c, &i2cTransaction);
// I2C STOP
I2C_close(i2c);
}