summaryrefslogtreecommitdiffstats
path: root/keyboards
diff options
context:
space:
mode:
Diffstat (limited to 'keyboards')
-rw-r--r--keyboards/ergodox_ez/config.h2
-rw-r--r--keyboards/ergodox_ez/ergodox_ez.c36
-rw-r--r--keyboards/ergodox_ez/ergodox_ez.h2
-rw-r--r--keyboards/ergodox_ez/matrix.c20
4 files changed, 29 insertions, 31 deletions
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 <http://www.gnu.org/licenses/>.
//#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<<LEFT_LED_3_SHIFT)
- );
+ & ~(ergodox_left_led_3<<LEFT_LED_3_SHIFT),
+ 0);
if (mcp23018_status) goto out;
mcp23018_status = i2c_write(0b11111111
& ~(ergodox_left_led_2<<LEFT_LED_2_SHIFT)
- & ~(ergodox_left_led_1<<LEFT_LED_1_SHIFT)
- );
+ & ~(ergodox_left_led_1<<LEFT_LED_1_SHIFT),
+ 0);
if (mcp23018_status) goto out;
out:
- i2c_stop();
+ i2c_stop(0);
return mcp23018_status;
}
#endif
diff --git a/keyboards/ergodox_ez/ergodox_ez.h b/keyboards/ergodox_ez/ergodox_ez.h
index 3ffc32553c..9086db2fbd 100644
--- a/keyboards/ergodox_ez/ergodox_ez.h
+++ b/keyboards/ergodox_ez/ergodox_ez.h
@@ -23,7 +23,7 @@
#define OLATA 0x14 // output latch register
#define OLATB 0x15
-extern uint8_t mcp23018_status;
+extern i2c_status_t mcp23018_status;
void init_ergodox(void);
void ergodox_blink_all_leds(void);
diff --git a/keyboards/ergodox_ez/matrix.c b/keyboards/ergodox_ez/matrix.c
index 8b117166fb..d8b708a163 100644
--- a/keyboards/ergodox_ez/matrix.c
+++ b/keyboards/ergodox_ez/matrix.c
@@ -295,13 +295,13 @@ static matrix_row_t read_cols(uint8_t row)
return 0;
} else {
uint8_t data = 0;
- 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_read_nack();
- data = ~data;
+ mcp23018_status = i2c_start(I2C_ADDR_WRITE, 0); if (mcp23018_status) goto out;
+ mcp23018_status = i2c_write(GPIOB, 0); if (mcp23018_status) goto out;
+ mcp23018_status = i2c_start(I2C_ADDR_READ, 0); if (mcp23018_status) goto out;
+ mcp23018_status = i2c_read_nack(0); if (mcp23018_status < 0) goto out;
+ data = ~((uint8_t)mcp23018_status);
out:
- i2c_stop();
+ i2c_stop(0);
return data;
}
} else {
@@ -350,11 +350,11 @@ static void select_row(uint8_t row)
} else {
// set active row low : 0
// set other rows hi-Z : 1
- mcp23018_status = i2c_start(I2C_ADDR_WRITE); if (mcp23018_status) goto out;
- mcp23018_status = i2c_write(GPIOA); if (mcp23018_status) goto out;
- mcp23018_status = i2c_write(0xFF & ~(1<<row)); if (mcp23018_status) goto out;
+ mcp23018_status = i2c_start(I2C_ADDR_WRITE, 0); if (mcp23018_status) goto out;
+ mcp23018_status = i2c_write(GPIOA, 0); if (mcp23018_status) goto out;
+ mcp23018_status = i2c_write(0xFF & ~(1<<row), 0); if (mcp23018_status) goto out;
out:
- i2c_stop();
+ i2c_stop(0);
}
} else {
// select on teensy