jung6717 / arduino

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

TWI does not twi_init() correctly in wire/utility/twi.c for atmega644[p] #238

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
In the arduino/hardware/libraries/Wire/utility directory I had to modify
twi_init() in twi.c 
twi_init does not include a definition for the atmega644[p] and such
incorrectly set's the pull up registers for the wrong ports.
The atmega644[p] TWI are ports PORTC0/PORTC1 not PORTD0/PORTD1 as the
source states.

I added:
  #elif defined(__AVR_ATmega644P__) || defined(__AVR_ATmega644__)
    sbi(PORTC, 0);
    sbi(PORTC, 1);
 to 

void twi_init(void)
{
  // initialize state
  twi_state = TWI_READY;

  #if defined(__AVR_ATmega168__) || defined(__AVR_ATmega8__) ||
defined(__AVR_ATmega328P__)
    // activate internal pull-ups for twi
    // as per note from atmega8 manual pg167
    sbi(PORTC, 4);
    sbi(PORTC, 5);
  #elif defined(__AVR_ATmega644P__) || defined(__AVR_ATmega644__)
    sbi(PORTC, 0);
    sbi(PORTC, 1);
  #else
    // activate internal pull-ups for twi
    // as per note from atmega128 manual pg204
    sbi(PORTD, 0);
    sbi(PORTD, 1);
  #endif

I am running Arduino version 0017.

Original issue reported on code.google.com by sancho...@gmail.com on 2 May 2010 at 6:30

GoogleCodeExporter commented 8 years ago
We only support the processors found on Arduino boards in the core.

Original comment by dmel...@gmail.com on 3 May 2010 at 2:24