From 6380f8319057d33bb6d07c66789867e49c634504 Mon Sep 17 00:00:00 2001 From: Jack Humbert Date: Fri, 22 Jun 2018 21:26:30 -0400 Subject: refactor, non-working --- keyboards/ergodox_ez/config.h | 2 -- keyboards/ergodox_ez/ergodox_ez.c | 36 ++++++++++++++++++------------------ keyboards/ergodox_ez/ergodox_ez.h | 2 +- keyboards/ergodox_ez/matrix.c | 20 ++++++++++---------- 4 files changed, 29 insertions(+), 31 deletions(-) (limited to 'keyboards') diff --git a/keyboards/ergodox_ez/config.h b/keyboards/ergodox_ez/config.h index ec1620030c..1285cbe1c9 100644 --- a/keyboards/ergodox_ez/config.h +++ b/keyboards/ergodox_ez/config.h @@ -138,6 +138,4 @@ along with this program. If not, see . //#define NO_ACTION_FUNCTION //#define DEBUG_MATRIX_SCAN_RATE -#define I2C_TIMEOUT 1000 - #endif diff --git a/keyboards/ergodox_ez/ergodox_ez.c b/keyboards/ergodox_ez/ergodox_ez.c index 3a2d1273fa..65671b38fe 100644 --- a/keyboards/ergodox_ez/ergodox_ez.c +++ b/keyboards/ergodox_ez/ergodox_ez.c @@ -24,7 +24,7 @@ extern inline void ergodox_led_all_set(uint8_t n); bool i2c_initialized = 0; -uint8_t mcp23018_status = 0x20; +i2c_status_t mcp23018_status = 0x20; void matrix_init_kb(void) { // keyboard LEDs (see "PWM on ports OC1(A|B|C)" in "teensy-2-0.md") @@ -125,23 +125,23 @@ uint8_t init_mcp23018(void) { // - unused : input : 1 // - input : input : 1 // - driving : output : 0 - mcp23018_status = i2c_start(I2C_ADDR_WRITE); if (mcp23018_status) goto out; - mcp23018_status = i2c_write(IODIRA); if (mcp23018_status) goto out; - mcp23018_status = i2c_write(0b00000000); if (mcp23018_status) goto out; - mcp23018_status = i2c_write(0b00111111); if (mcp23018_status) goto out; - i2c_stop(); + mcp23018_status = i2c_start(I2C_ADDR_WRITE, 0); if (mcp23018_status) goto out; + mcp23018_status = i2c_write(IODIRA, 0); if (mcp23018_status) goto out; + mcp23018_status = i2c_write(0b00000000, 0); if (mcp23018_status) goto out; + mcp23018_status = i2c_write(0b00111111, 0); if (mcp23018_status) goto out; + i2c_stop(0); // set pull-up // - unused : on : 1 // - input : on : 1 // - driving : off : 0 - mcp23018_status = i2c_start(I2C_ADDR_WRITE); if (mcp23018_status) goto out; - mcp23018_status = i2c_write(GPPUA); if (mcp23018_status) goto out; - mcp23018_status = i2c_write(0b00000000); if (mcp23018_status) goto out; - mcp23018_status = i2c_write(0b00111111); if (mcp23018_status) goto out; + mcp23018_status = i2c_start(I2C_ADDR_WRITE, 0); if (mcp23018_status) goto out; + mcp23018_status = i2c_write(GPPUA, 0); if (mcp23018_status) goto out; + mcp23018_status = i2c_write(0b00000000, 0); if (mcp23018_status) goto out; + mcp23018_status = i2c_write(0b00111111, 0); if (mcp23018_status) goto out; out: - i2c_stop(); + i2c_stop(0); #ifdef LEFT_LEDS if (!mcp23018_status) mcp23018_status = ergodox_left_leds_update(); @@ -165,22 +165,22 @@ uint8_t ergodox_left_leds_update(void) { // - unused : hi-Z : 1 // - input : hi-Z : 1 // - driving : hi-Z : 1 - mcp23018_status = i2c_start(I2C_ADDR_WRITE); + mcp23018_status = i2c_start(I2C_ADDR_WRITE, 0); if (mcp23018_status) goto out; - mcp23018_status = i2c_write(OLATA); + mcp23018_status = i2c_write(OLATA, 0); if (mcp23018_status) goto out; mcp23018_status = i2c_write(0b11111111 - & ~(ergodox_left_led_3<