summaryrefslogtreecommitdiff
path: root/keyboards/gboards/georgi
diff options
context:
space:
mode:
Diffstat (limited to 'keyboards/gboards/georgi')
-rw-r--r--keyboards/gboards/georgi/georgi.c26
-rw-r--r--keyboards/gboards/georgi/georgi.h5
-rw-r--r--keyboards/gboards/georgi/matrix.c17
3 files changed, 15 insertions, 33 deletions
diff --git a/keyboards/gboards/georgi/georgi.c b/keyboards/gboards/georgi/georgi.c
index dd95b593f1..745e8ab35d 100644
--- a/keyboards/gboards/georgi/georgi.c
+++ b/keyboards/gboards/georgi/georgi.c
@@ -45,23 +45,17 @@ uint8_t init_mcp23018(void) {
// - unused : input : 1
// - input : input : 1
// - driving : output : 0
- mcp23018_status = i2c_start(I2C_ADDR_WRITE, ERGODOX_EZ_I2C_TIMEOUT); if (mcp23018_status) goto out;
- mcp23018_status = i2c_write(IODIRA, ERGODOX_EZ_I2C_TIMEOUT); if (mcp23018_status) goto out;
- mcp23018_status = i2c_write(0b10000000, ERGODOX_EZ_I2C_TIMEOUT); if (mcp23018_status) goto out;
- mcp23018_status = i2c_write(0b11111111, ERGODOX_EZ_I2C_TIMEOUT); if (mcp23018_status) goto out;
- i2c_stop();
-
- // set pull-up
- // - unused : on : 1
- // - input : on : 1
- // - driving : off : 0
- mcp23018_status = i2c_start(I2C_ADDR_WRITE, ERGODOX_EZ_I2C_TIMEOUT); if (mcp23018_status) goto out;
- mcp23018_status = i2c_write(GPPUA, ERGODOX_EZ_I2C_TIMEOUT); if (mcp23018_status) goto out;
- mcp23018_status = i2c_write(0b10000000, ERGODOX_EZ_I2C_TIMEOUT); if (mcp23018_status) goto out;
- mcp23018_status = i2c_write(0b11111111, ERGODOX_EZ_I2C_TIMEOUT); if (mcp23018_status) goto out;
+ uint8_t data[] = {0b10000000, 0b11111111};
+ mcp23018_status = i2c_writeReg(I2C_ADDR, IODIRA, data, 2, ERGODOX_EZ_I2C_TIMEOUT);
+
+ if (!mcp23018_status) {
+ // set pull-up
+ // - unused : on : 1
+ // - input : on : 1
+ // - driving : off : 0
+ mcp23018_status = i2c_writeReg(I2C_ADDR, GPPUA, data, 2, ERGODOX_EZ_I2C_TIMEOUT);
+ }
-out:
- i2c_stop();
// SREG=sreg_prev;
//uprintf("Init %x\n", mcp23018_status);
return mcp23018_status;
diff --git a/keyboards/gboards/georgi/georgi.h b/keyboards/gboards/georgi/georgi.h
index e23fc264f4..6ab47ced74 100644
--- a/keyboards/gboards/georgi/georgi.h
+++ b/keyboards/gboards/georgi/georgi.h
@@ -11,10 +11,7 @@ extern i2c_status_t mcp23018_status;
#define ERGODOX_EZ_I2C_TIMEOUT 1000
// I2C aliases and register addresses (see "mcp23018.md")
-//#define I2C_ADDR 0b0100000
-#define I2C_ADDR 0x20
-#define I2C_ADDR_WRITE ( (I2C_ADDR<<1) | I2C_WRITE )
-#define I2C_ADDR_READ ( (I2C_ADDR<<1) | I2C_READ )
+#define I2C_ADDR (0x20<<1)
#define IODIRA 0x00 // i/o direction register
#define IODIRB 0x01
#define GPPUA 0x0C // GPIO pull-up resistor register
diff --git a/keyboards/gboards/georgi/matrix.c b/keyboards/gboards/georgi/matrix.c
index b66b1a194c..d1151ae80e 100644
--- a/keyboards/gboards/georgi/matrix.c
+++ b/keyboards/gboards/georgi/matrix.c
@@ -254,14 +254,7 @@ static matrix_row_t read_cols(uint8_t row)
return 0;
} else {
uint8_t data = 0;
- mcp23018_status = i2c_start(I2C_ADDR_WRITE, ERGODOX_EZ_I2C_TIMEOUT); if (mcp23018_status) goto out;
- mcp23018_status = i2c_write(GPIOB, ERGODOX_EZ_I2C_TIMEOUT); if (mcp23018_status) goto out;
- mcp23018_status = i2c_start(I2C_ADDR_READ, ERGODOX_EZ_I2C_TIMEOUT); if (mcp23018_status) goto out;
- mcp23018_status = i2c_read_nack(ERGODOX_EZ_I2C_TIMEOUT); if (mcp23018_status < 0) goto out;
- data = ~((uint8_t)mcp23018_status);
- mcp23018_status = I2C_STATUS_SUCCESS;
- out:
- i2c_stop();
+ mcp23018_status = i2c_readReg(I2C_ADDR, GPIOB, &data, 1, ERGODOX_EZ_I2C_TIMEOUT);
#ifdef DEBUG_MATRIX
if (data != 0x00) xprintf("I2C: %d\n", data);
@@ -304,11 +297,9 @@ static void select_row(uint8_t row)
// select on mcp23018
if (mcp23018_status) { // do nothing on error
} else { // set active row low : 0 // set other rows hi-Z : 1
- mcp23018_status = i2c_start(I2C_ADDR_WRITE, ERGODOX_EZ_I2C_TIMEOUT); if (mcp23018_status) goto out;
- mcp23018_status = i2c_write(GPIOA, ERGODOX_EZ_I2C_TIMEOUT); if (mcp23018_status) goto out;
- mcp23018_status = i2c_write(0xFF & ~(1<<row), ERGODOX_EZ_I2C_TIMEOUT); if (mcp23018_status) goto out;
- out:
- i2c_stop();
+ uint8_t data = 0xFF & ~(1<<row);
+ mcp23018_status = i2c_writeReg(I2C_ADDR, GPIOA, &data, 1, ERGODOX_EZ_I2C_TIMEOUT);
+
}
} else {
// Output low(DDR:1, PORT:0) to select