尊敬的 TI:
我尝试通过 i2c 发送数据、但未发现错误。 请帮帮我。
void writecommand (uint8_t *命令、uint8_t 命令)
{
// I2C 命令写入。
uint8_t 校验和;
uint8_t txBuffer[9];
// uint8_t rxBuffer[0];
cmdlen++;
usleep(2000);
// I2C 启动
i2cTransaction.writeBuf = txBuffer;
// i2cTransaction.readBuf = rxBuffer;
i2cTransaction.writeCount = 9;
// i2cTransaction.ReadCount = 0;
校验和= 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
校验和+= PN532_HOSTTOPN532;
uint8_t i = 0;
(i=0;<cmdlen-1; i++) {
txBuffer[6]= cmd[i];
校验和+= cmd[i];
}
txBuffer[7]=~校验和;
txBuffer[8]= PN532_POSTACMBLE;
I2C_transfer (i2c、&i2cTransaction);
// I2C 停止
I2C_Close (i2c);
}