ahmetsemihparlak / arduino

Automatically exported from code.google.com/p/arduino
0 stars 0 forks source link

Add support for "general call" to the Wire library #120

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
I'd like to see a small enhancement to the Wire library to allow I2C-
connected Arduinos to respond to the "general call" address.

It's sometimes useful to transmit data to multiple Arduinos at once.  At 
present I have to hack around this missing functionality by directly 
setting the TWGCE bit in the TWAR register.

Maybe Wire.begin could have an additional boolean argument to specify 
whether to respond to general calls?  This should default to false, so 
that existing code is unaffected.

Original issue reported on code.google.com by kevin.i.orourke on 20 Sep 2009 at 3:07

GoogleCodeExporter commented 9 years ago
Could you post the modifications you made to make the general call work? I'm 
very much 
interested in this feature since I have multiple arduino's communicating with 
eachother over I2C

Original comment by daan.ger...@gmail.com on 10 Mar 2010 at 11:49

GoogleCodeExporter commented 9 years ago
It's a one-liner in my setup function:
void setup()
{
...
  // Initialise I2C
  Wire.begin(MY_ADDR); // as slave
  bitSet(TWAR, TWGCE); // ugly hack to enable general call
  Wire.onReceive(receiveEvent);
...
}

I just added the line commented "ugly hack..." :)

Original comment by kevin.i.orourke on 10 Mar 2010 at 5:28

GoogleCodeExporter commented 9 years ago
Great! works like a charm :). I second the idea of having a boolean parameter 
to 
indicate general call handling.

Original comment by daan.ger...@gmail.com on 10 Mar 2010 at 6:40