EDIT: Please ignore this response as it is INCORRECT.
Please modify as below.
status = CyU3PI2cTransmitBytes (&preamble, buffer, 0, 0);
The preamble data contains the address and the first byte of data to be followed. So, the byteCount parameter of the CyU3PI2cTransmitBytes should be set to 0. Since you have set this to '1', there is an additional byte of data after the preamble being sent.
I've modified the code following your suggestion.
preamble.length = 2; preamble.buffer = IAP2_I2C_WRITE_ADDRESS_RST_HIGH; preamble.buffer = ACCESSORY_CERTIFICATE_SERIAL_NUMBER; //0x4E preamble.ctrlMask = 0x0000; status = CyU3PI2cTransmitBytes (&preamble, buffer, 0, 0);
However, there would be no i2c waveform out if the 3rd parameter of CyU3PI2cTransmitBytes is 0.
And I verified it with my logic analyzer.
Does the API not accept byteCount to be 0?
- Apologies. You are right. The CyU3PI2cTransmitBytes() API would return immediately if the byteCount parameter is set to 0 and there would be no I2C transfer.
- Modify the preamble buffer to contain the device address (IAP2_I2C_WRITE_ADDRESS_RST_HIGH) and include a data buffer that is passed as a parameter to the CyU3PI2cTransmitBytes. Fill the data buffer with the ACCESSORY_CERTIFICATE_SERIAL_NUMBER and pass it to the CyU3PI2cTransmitBytes() API.
- When CyU3PI2cTransmitBytes()byteCount parameter is set to 0, there will be no I2c transfer.