Go Down

Topic: getting I2C working (Read 1 time) previous topic - next topic


Hi im working with an Arduino due and a c3038 camera. I found this discussion and have gone through the code.
As it happens the i2c write page does not work on the ide since it is written for avr libraries. I've been looking for some help to re-write some of this code so that it is compatible with Due, but I've been unable to find the macros to be replaced for the "_BV", TWSR TWBR etc.

Am i simply missing an include file? or are there separate macros defined for the above?


To allow slave mode to accept a read then repeat start with a 16 bit write . I altered Wire.cpp In arduino-1.5.2 approximately at line 309.
I changed "if (TWI_STATUS_TXCOMP(sr) && TWI_STATUS_EOSACC(sr))" to "if(TWI_STATUS_EOSACC(sr))".  The repeat start does not indicate
a TXCOMP so onReceive never triggers.

Now Wire.onReceive() gets triggered on receipt of register address, and Wire.onRequest() gets triggered to have me write my two bytes.
This should also work with 16 bit register addresses so emulating a EEPROM should be possible.
I have not extensively tested for any side effects.

Go Up