I realized quickly that the MultiAVR library is only the core Arduino library. What is missing are the non-core ones, like the I²C library (AKA TWI or “Wire”). Expecting a serious re-write, I was pleasantly surprised to see that I had to make exactly one change:
*** /usr/share/arduino/libraries/Wire/utility/twi.c 2011-01-10 14:28:07.000000000 +0900
--- /home/harald/workspace/BlinkSanguino/utility/twi.c 2011-09-24 22:38:53.283676108 +0900
***************
*** 69,74 ****
--- 69,77 ----
// as per note from atmega8 manual pg167
sbi(PORTC, 4);
sbi(PORTC, 5);
+ #elif defined(__AVR_ATmega644P__) || defined(__AVR_ATmega1284P__)
+ sbi(PORTC, 0);
+ sbi(PORTC, 1);
#else
// activate internal pull-ups for twi
// as per note from atmega128 manual pg204
and that was it.
In one day I was able to talk to:
- the LCD (16×2 characters)
- an PCF8574A (8 bit I/O)
- an PCF8583 (RTC)
- an MCP23017 (16 bit I/O)
The last one has a strange behaviour: Port A and B seem to be swapped.
