From 682555faac8a67deff5688b956165cd1c39389cb Mon Sep 17 00:00:00 2001 From: Jack Humbert Date: Tue, 15 May 2018 22:30:58 -0400 Subject: [PATCH] i2c fix --- drivers/avr/i2c_master.c | 42 +++++++++++++++++-------------- drivers/avr/is31fl3731.c | 7 ++++-- keyboards/ergodox_ez/ergodox_ez.c | 4 +-- keyboards/ergodox_ez/ergodox_ez.h | 2 +- keyboards/ergodox_ez/matrix.c | 3 +-- keyboards/ergodox_ez/rules.mk | 4 +-- 6 files changed, 33 insertions(+), 29 deletions(-) diff --git a/drivers/avr/i2c_master.c b/drivers/avr/i2c_master.c index f4a4bb7b0b..bcf92153c5 100755 --- a/drivers/avr/i2c_master.c +++ b/drivers/avr/i2c_master.c @@ -13,32 +13,34 @@ void i2c_init(void) { + TWSR = 0; /* no prescaler */ TWBR = (uint8_t)TWBR_val; + //TWBR = 10; } uint8_t i2c_start(uint8_t address) { // reset TWI control register - TWCR = 0; - // transmit START condition + //TWCR = 0; + // transmit START condition TWCR = (1< #include -#include "i2cmaster.h" +#include "i2c_master.h" #include #define CPU_PRESCALE(n) (CLKPR = 0x80, CLKPR = (n)) diff --git a/keyboards/ergodox_ez/matrix.c b/keyboards/ergodox_ez/matrix.c index e101711334..2aad997817 100644 --- a/keyboards/ergodox_ez/matrix.c +++ b/keyboards/ergodox_ez/matrix.c @@ -34,7 +34,6 @@ along with this program. If not, see . #include "util.h" #include "matrix.h" #include QMK_KEYBOARD_H -#include "i2cmaster.h" #ifdef DEBUG_MATRIX_SCAN_RATE #include "timer.h" #endif @@ -297,7 +296,7 @@ static matrix_row_t read_cols(uint8_t row) mcp23018_status = i2c_start(I2C_ADDR_WRITE); if (mcp23018_status) goto out; mcp23018_status = i2c_write(GPIOB); if (mcp23018_status) goto out; mcp23018_status = i2c_start(I2C_ADDR_READ); if (mcp23018_status) goto out; - data = i2c_readNak(); + data = i2c_read_nack(); data = ~data; out: i2c_stop(); diff --git a/keyboards/ergodox_ez/rules.mk b/keyboards/ergodox_ez/rules.mk index a3b2ba5cab..0e0b3cdefd 100644 --- a/keyboards/ergodox_ez/rules.mk +++ b/keyboards/ergodox_ez/rules.mk @@ -15,8 +15,8 @@ #---------------------------------------------------------------------------- # # project specific files -SRC = twimaster.c \ - matrix.c +SRC = matrix.c \ + i2c_master.c # MCU name MCU = atmega32u4