summaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorMechMerlin <30334081+mechmerlin@users.noreply.github.com>2019-04-07 02:30:48 +0200
committerDrashna Jaelre <drashna@live.com>2019-04-07 02:30:48 +0200
commit410984486b0a5c61174c6e4e5a3570f1b09f97dc (patch)
treec3a5773e94e84a1bf818a9e1e295035b710fb41a /drivers
parent2ffa4798a43682a73598c0b43d46abcca7cd6e83 (diff)
downloadqmk_firmware-410984486b0a5c61174c6e4e5a3570f1b09f97dc.tar.gz
qmk_firmware-410984486b0a5c61174c6e4e5a3570f1b09f97dc.tar.xz
i2c_init update to work with atmega32a boards (#5562)
* On i2c_init, enable two wire interface, twi interrupt, and slave address ACK along with pull up resistors. * thanks to some testing by drashna, we know that setting TWI doesn't work for all boards. Putting the new code into an ifdef block
Diffstat (limited to 'drivers')
-rwxr-xr-xdrivers/avr/i2c_master.c12
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 @@
void i2c_init(void) {
TWSR = 0; /* no prescaler */
TWBR = (uint8_t)TWBR_val;
+
+ #ifdef __AVR_ATmega32A__
+ // set pull-up resistors on I2C bus pins
+ PORTC |= 0b11;
+
+ // enable TWI (two-wire interface)
+ TWCR |= (1 << TWEN);
+
+ // enable TWI interrupt and slave address ACK
+ TWCR |= (1 << TWIE);
+ TWCR |= (1 << TWEA);
+ #endif
}
i2c_status_t i2c_start(uint8_t address, uint16_t timeout) {