Other Parts Discussed in Thread: HALCOGEN
I've been struggling to get the i2c device to actually create a restart condition using interrupts exclusively. My application is such that a busy-wait would be problematic.
Here is my code using a busy wait to generate a repeated start:
((Tms570I2cHandle_t*)master)->i2c->MDR &= ~(I2C_STP_BIT);
i2cSetSlaveAdd(((Tms570I2cHandle_t*)master)->i2c, device_address);
i2cSetDirection(((Tms570I2cHandle_t*)master)->i2c, I2C_TRANSMITTER);
i2cSetMode(((Tms570I2cHandle_t*)master)->i2c, I2C_MASTER);
i2cSetCount(((Tms570I2cHandle_t*)master)->i2c, num_sub_address_bytes);
i2cSetStart(((Tms570I2cHandle_t*)master)->i2c);
//Send subaddress
i2cSend(((Tms570I2cHandle_t*)master)->i2c, num_sub_address_bytes, (uint8_t*)(&sub_address) + (4-num_sub_address_bytes));
//wait for tx ready, indicating that we've sent the subaddress successfully
while(!i2cIsTxReady(((Tms570I2cHandle_t*)master)->i2c));
i2cSetSlaveAdd(((Tms570I2cHandle_t*)master)->i2c, device_address);
i2cSetDirection(((Tms570I2cHandle_t*)master)->i2c, I2C_RECEIVER);
i2cSetCount(((Tms570I2cHandle_t*)master)->i2c, transfer_size);
i2cSetMode(((Tms570I2cHandle_t*)master)->i2c, I2C_MASTER);
i2cSetStop(((Tms570I2cHandle_t*)master)->i2c);
i2cSetStart(((Tms570I2cHandle_t*)master)->i2c);
i2cReceive(((Tms570I2cHandle_t*)master)->i2c, transfer_size, data);
I would like to be able to remove the busy-wait after the i2cSend, and instead wait for a txrdy interrupt. I've modified the halcogen code so that it should generate the tx notification after every byte, but it does not seem to help. I don't seem to be actually getting a tx notification when the send is done. I've noticed that the i2csend notification is broken, since it sends the notification *before* the last byte has been shifted out, which is not useful in this case. I want to know when the device can be put into a receive mode.
I've looked into the ARDY bit, but I don't fully understand what exactly it indicates, as the documentation is fairly vague. How does ARDY work? What interrupt will let me know when I can start receiving after sending the subaddress?
Thank you.