mirror of
https://github.com/arduino/Arduino.git
synced 2024-11-29 10:24:12 +01:00
Use SDA and SCL constants, not hardcoded registers for TWI pullups.
http://code.google.com/p/arduino/issues/detail?id=601
This commit is contained in:
parent
7d8d20894c
commit
71289521bf
@ -32,6 +32,7 @@
|
||||
#define sbi(sfr, bit) (_SFR_BYTE(sfr) |= _BV(bit))
|
||||
#endif
|
||||
|
||||
#include "pins_arduino.h"
|
||||
#include "twi.h"
|
||||
|
||||
static volatile uint8_t twi_state;
|
||||
@ -63,18 +64,10 @@ 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);
|
||||
#else
|
||||
// activate internal pull-ups for twi
|
||||
// as per note from atmega128 manual pg204
|
||||
sbi(PORTD, 0);
|
||||
sbi(PORTD, 1);
|
||||
#endif
|
||||
|
||||
// activate internal pullups for twi.
|
||||
digitalWrite(SDA, 1);
|
||||
digitalWrite(SCL, 1);
|
||||
|
||||
// initialize twi prescaler and bit rate
|
||||
cbi(TWSR, TWPS0);
|
||||
|
Loading…
Reference in New Issue
Block a user