Pages: [1]   Go Down
Author Topic: getting I2C working  (Read 885 times)
0 Members and 1 Guest are viewing this topic.
Bangalore
Offline Offline
Newbie
*
Karma: 0
Posts: 6
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi im working with an Arduino due and a c3038 camera. I found this discussion and have gone through the code.
http://arduino.cc/forum/index.php?topic=8100.0
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?
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 1
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
David.
Logged

Pages: [1]   Go Up
Jump to: