diff options
| -rwxr-xr-x | drivers/avr/i2c_master.c | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/drivers/avr/i2c_master.c b/drivers/avr/i2c_master.c index 0db949db4..ba6d0d158 100755 --- a/drivers/avr/i2c_master.c +++ b/drivers/avr/i2c_master.c | |||
| @@ -18,6 +18,18 @@ | |||
| 18 | void i2c_init(void) { | 18 | void i2c_init(void) { |
| 19 | TWSR = 0; /* no prescaler */ | 19 | TWSR = 0; /* no prescaler */ |
| 20 | TWBR = (uint8_t)TWBR_val; | 20 | TWBR = (uint8_t)TWBR_val; |
| 21 | |||
| 22 | #ifdef __AVR_ATmega32A__ | ||
| 23 | // set pull-up resistors on I2C bus pins | ||
| 24 | PORTC |= 0b11; | ||
| 25 | |||
| 26 | // enable TWI (two-wire interface) | ||
| 27 | TWCR |= (1 << TWEN); | ||
| 28 | |||
| 29 | // enable TWI interrupt and slave address ACK | ||
| 30 | TWCR |= (1 << TWIE); | ||
| 31 | TWCR |= (1 << TWEA); | ||
| 32 | #endif | ||
| 21 | } | 33 | } |
| 22 | 34 | ||
| 23 | i2c_status_t i2c_start(uint8_t address, uint16_t timeout) { | 35 | i2c_status_t i2c_start(uint8_t address, uint16_t timeout) { |
