mirror of
https://github.com/arduino/Arduino.git
synced 2025-02-20 14:54:31 +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))
|
#define sbi(sfr, bit) (_SFR_BYTE(sfr) |= _BV(bit))
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include "pins_arduino.h"
|
||||||
#include "twi.h"
|
#include "twi.h"
|
||||||
|
|
||||||
static volatile uint8_t twi_state;
|
static volatile uint8_t twi_state;
|
||||||
@ -64,17 +65,9 @@ void twi_init(void)
|
|||||||
// initialize state
|
// initialize state
|
||||||
twi_state = TWI_READY;
|
twi_state = TWI_READY;
|
||||||
|
|
||||||
#if defined(__AVR_ATmega168__) || defined(__AVR_ATmega8__) || defined(__AVR_ATmega328P__)
|
// activate internal pullups for twi.
|
||||||
// activate internal pull-ups for twi
|
digitalWrite(SDA, 1);
|
||||||
// as per note from atmega8 manual pg167
|
digitalWrite(SCL, 1);
|
||||||
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
|
|
||||||
|
|
||||||
// initialize twi prescaler and bit rate
|
// initialize twi prescaler and bit rate
|
||||||
cbi(TWSR, TWPS0);
|
cbi(TWSR, TWPS0);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user