Having worked with a rather fussy I2C component. I need to use a restart, rather than a stop.
I've looked at the wire.c library supplied, but whilst the stop param is supplied, it doesn't seem to be used. Any theories behind this?
Code: Select all
uint8_t TwoWire::endTransmission(uint8_t stop)
{
// We already stopped I2C
if(state == STATE_TRANSMITION_STOPPED)
return sucess_code;
// We have to send one byte if user dind't do it...
if(state == STATE_TRANSMITION_INIT)
{
p_driver->start();
if(!p_driver->write(txAddress))
{
sucess_code |= NACK_ON_ADDRESS;
}
}
// We have open connection for reading bytes
// Some devices will have bad inner state if we don't say "NACK"
// at the end.
if((state == STATE_TRANSMITION_READMODE) && (sucess_code == 0) && available_bytes)
{
// Send NACK
p_driver->read(0x00);
}
// Send stop sequence
p_driver->stop();
state = STATE_TRANSMITION_STOPPED;
return sucess_code;
Pete