Skip to content

Commit 7128952

Browse files
committed
Use SDA and SCL constants, not hardcoded registers for TWI pullups.
http://code.google.com/p/arduino/issues/detail?id=601
1 parent 7d8d208 commit 7128952

File tree

1 file changed

+5
-12
lines changed
  • libraries/Wire/utility

1 file changed

+5
-12
lines changed

libraries/Wire/utility/twi.c

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
#define sbi(sfr, bit) (_SFR_BYTE(sfr) |= _BV(bit))
3333
#endif
3434

35+
#include "pins_arduino.h"
3536
#include "twi.h"
3637

3738
static volatile uint8_t twi_state;
@@ -63,18 +64,10 @@ void twi_init(void)
6364
{
6465
// initialize state
6566
twi_state = TWI_READY;
66-
67-
#if defined(__AVR_ATmega168__) || defined(__AVR_ATmega8__) || defined(__AVR_ATmega328P__)
68-
// activate internal pull-ups for twi
69-
// as per note from atmega8 manual pg167
70-
sbi(PORTC, 4);
71-
sbi(PORTC, 5);
72-
#else
73-
// activate internal pull-ups for twi
74-
// as per note from atmega128 manual pg204
75-
sbi(PORTD, 0);
76-
sbi(PORTD, 1);
77-
#endif
67+
68+
// activate internal pullups for twi.
69+
digitalWrite(SDA, 1);
70+
digitalWrite(SCL, 1);
7871

7972
// initialize twi prescaler and bit rate
8073
cbi(TWSR, TWPS0);

0 commit comments

Comments
 (0)