summaryrefslogtreecommitdiff
path: root/keyboards/gboards
diff options
context:
space:
mode:
Diffstat (limited to 'keyboards/gboards')
-rw-r--r--keyboards/gboards/ergotaco/ergotaco.c28
-rw-r--r--keyboards/gboards/ergotaco/ergotaco.h5
-rw-r--r--keyboards/gboards/ergotaco/matrix.c18
-rw-r--r--keyboards/gboards/georgi/georgi.c26
-rw-r--r--keyboards/gboards/georgi/georgi.h5
-rw-r--r--keyboards/gboards/georgi/matrix.c17
-rw-r--r--keyboards/gboards/gergo/gergo.c24
-rw-r--r--keyboards/gboards/gergo/gergo.h5
-rw-r--r--keyboards/gboards/gergo/keymaps/default/config.h2
-rw-r--r--keyboards/gboards/gergo/keymaps/germ/config.h2
-rw-r--r--keyboards/gboards/gergo/matrix.c20
-rw-r--r--keyboards/gboards/gergoplex/gergoplex.c34
-rw-r--r--keyboards/gboards/gergoplex/gergoplex.h4
-rw-r--r--keyboards/gboards/gergoplex/matrix.c28
14 files changed, 65 insertions, 153 deletions
diff --git a/keyboards/gboards/ergotaco/ergotaco.c b/keyboards/gboards/ergotaco/ergotaco.c
index daeba1e0a6..694e07f031 100644
--- a/keyboards/gboards/ergotaco/ergotaco.c
+++ b/keyboards/gboards/ergotaco/ergotaco.c
@@ -49,23 +49,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(0b00000000, 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(0b00000000, ERGODOX_EZ_I2C_TIMEOUT); if (mcp23018_status) goto out;
- mcp23018_status = i2c_write(0b11111111, ERGODOX_EZ_I2C_TIMEOUT); if (mcp23018_status) goto out;
-
-out:
- i2c_stop();
+ uint8_t data[] = {0b00000000, 0b00111111};
+ mcp23018_status = i2c_writeReg(I2C_ADDR, IODIRA, data, sizeof(data), 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, sizeof(data), ERGODOX_EZ_I2C_TIMEOUT);
+ }
+
// SREG=sreg_prev;
//uprintf("Init %x\n", mcp23018_status);
return mcp23018_status;
diff --git a/keyboards/gboards/ergotaco/ergotaco.h b/keyboards/gboards/ergotaco/ergotaco.h
index e23fc264f4..6ab47ced74 100644
--- a/keyboards/gboards/ergotaco/ergotaco.h
+++ b/keyboards/gboards/ergotaco/ergotaco.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/ergotaco/matrix.c b/keyboards/gboards/ergotaco/matrix.c
index 63d4c4f5f3..3c49f2802e 100644
--- a/keyboards/gboards/ergotaco/matrix.c
+++ b/keyboards/gboards/ergotaco/matrix.c
@@ -234,15 +234,8 @@ 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) >> 2) & 0x01 ;
- mcp23018_status = I2C_STATUS_SUCCESS;
- out:
- i2c_stop();
-
+ mcp23018_status = i2c_readReg(I2C_ADDR, GPIOB, &data, 1, ERGODOX_EZ_I2C_TIMEOUT);
+ data = (~((uint8_t)data) >> 2) & 0x01 ;
#ifdef DEBUG_MATRIX
if (data != 0x00) xprintf("I2C: %d\n", data);
#endif
@@ -274,11 +267,8 @@ static void select_row(uint8_t row)
if (mcp23018_status) { // do nothing on error
// Read using bitmask
} 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(~(1<<row), ERGODOX_EZ_I2C_TIMEOUT); if (mcp23018_status) goto out;
- out:
- i2c_stop();
+ uint8_t data = ~(1<<row);
+ mcp23018_status = i2c_writeReg(I2C_ADDR, GPIOA, &data, 1, ERGODOX_EZ_I2C_TIMEOUT);
}
} else {
// Output low(DDR:1, PORT:0) to select
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
diff --git a/keyboards/gboards/gergo/gergo.c b/keyboards/gboards/gergo/gergo.c
index da2a3007a8..41d383d408 100644
--- a/keyboards/gboards/gergo/gergo.c
+++ b/keyboards/gboards/gergo/gergo.c
@@ -43,23 +43,17 @@ uint8_t init_mcp23018(void) {
// - unused : input : 1
// - input : input : 1
// - driving : output : 0
- mcp23018_status = i2c_start(I2C_ADDR_WRITE, I2C_TIMEOUT); if (mcp23018_status) goto out;
- mcp23018_status = i2c_write(IODIRA, I2C_TIMEOUT); if (mcp23018_status) goto out;
- mcp23018_status = i2c_write(0b10000000, I2C_TIMEOUT); if (mcp23018_status) goto out;
- mcp23018_status = i2c_write(0b11111111, I2C_TIMEOUT); if (mcp23018_status) goto out;
- i2c_stop();
+ uint8_t data[] = {0b10000000, 0b11111111};
+ mcp23018_status = i2c_writeReg(I2C_ADDR, IODIRA, data, sizeof(data), I2C_TIMEOUT);
- // set pull-up
- // - unused : on : 1
- // - input : on : 1
- // - driving : off : 0
- mcp23018_status = i2c_start(I2C_ADDR_WRITE, I2C_TIMEOUT); if (mcp23018_status) goto out;
- mcp23018_status = i2c_write(GPPUA, I2C_TIMEOUT); if (mcp23018_status) goto out;
- mcp23018_status = i2c_write(0b10000000, I2C_TIMEOUT); if (mcp23018_status) goto out;
- mcp23018_status = i2c_write(0b11111111, I2C_TIMEOUT); if (mcp23018_status) goto out;
+ if (!mcp23018_status) {
+ // set pull-up
+ // - unused : on : 1
+ // - input : on : 1
+ // - driving : off : 0
+ mcp23018_status = i2c_writeReg(I2C_ADDR, GPPUA, data, sizeof(data), I2C_TIMEOUT);
+ }
-out:
- i2c_stop();
// SREG=sreg_prev;
//uprintf("Init %x\n", mcp23018_status);
return mcp23018_status;
diff --git a/keyboards/gboards/gergo/gergo.h b/keyboards/gboards/gergo/gergo.h
index ea6368e2f1..f6dc1498f0 100644
--- a/keyboards/gboards/gergo/gergo.h
+++ b/keyboards/gboards/gergo/gergo.h
@@ -11,10 +11,7 @@ extern i2c_status_t mcp23018_status;
#define 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/gergo/keymaps/default/config.h b/keyboards/gboards/gergo/keymaps/default/config.h
deleted file mode 100644
index 3f59c932d3..0000000000
--- a/keyboards/gboards/gergo/keymaps/default/config.h
+++ /dev/null
@@ -1,2 +0,0 @@
-#pragma once
-
diff --git a/keyboards/gboards/gergo/keymaps/germ/config.h b/keyboards/gboards/gergo/keymaps/germ/config.h
deleted file mode 100644
index 3f59c932d3..0000000000
--- a/keyboards/gboards/gergo/keymaps/germ/config.h
+++ /dev/null
@@ -1,2 +0,0 @@
-#pragma once
-
diff --git a/keyboards/gboards/gergo/matrix.c b/keyboards/gboards/gergo/matrix.c
index 8a6b38bf73..b4885361fb 100644
--- a/keyboards/gboards/gergo/matrix.c
+++ b/keyboards/gboards/gergo/matrix.c
@@ -297,19 +297,12 @@ static matrix_row_t read_cols(uint8_t row) {
return 0;
} else {
uint8_t data = 0;
- mcp23018_status = i2c_start(I2C_ADDR_WRITE, I2C_TIMEOUT); if (mcp23018_status) goto out;
- mcp23018_status = i2c_write(GPIOB, I2C_TIMEOUT); if (mcp23018_status) goto out;
- mcp23018_status = i2c_start(I2C_ADDR_READ, I2C_TIMEOUT); if (mcp23018_status) goto out;
- mcp23018_status = i2c_read_nack(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, I2C_TIMEOUT);
#ifdef DEBUG_MATRIX
- if (data != 0x00) xprintf("I2C: %d\n", data);
+ if (~data != 0x00) xprintf("I2C: %d\n", ~data);
#endif
- return data;
+ return ~data;
}
} else {
/* read from teensy
@@ -350,11 +343,8 @@ 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, I2C_TIMEOUT); if (mcp23018_status) goto out;
- mcp23018_status = i2c_write(GPIOA, I2C_TIMEOUT); if (mcp23018_status) goto out;
- mcp23018_status = i2c_write(0xFF & ~(1<<row), 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, I2C_TIMEOUT);
}
} else {
// Output low(DDR:1, PORT:0) to select
diff --git a/keyboards/gboards/gergoplex/gergoplex.c b/keyboards/gboards/gergoplex/gergoplex.c
index 1e44583895..b621201c16 100644
--- a/keyboards/gboards/gergoplex/gergoplex.c
+++ b/keyboards/gboards/gergoplex/gergoplex.c
@@ -39,30 +39,16 @@ uint8_t init_mcp23018(void) {
// - unused : input : 1
// - input : input : 1
// - driving : output : 0
- mcp23018_status = i2c_start(I2C_ADDR_WRITE, I2C_TIMEOUT);
- if (mcp23018_status) goto out;
- mcp23018_status = i2c_write(IODIRA, I2C_TIMEOUT);
- if (mcp23018_status) goto out;
- mcp23018_status = i2c_write(0b11000001, I2C_TIMEOUT);
- if (mcp23018_status) goto out;
- mcp23018_status = i2c_write(0b11111111, 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, I2C_TIMEOUT);
- if (mcp23018_status) goto out;
- mcp23018_status = i2c_write(GPPUA, I2C_TIMEOUT);
- if (mcp23018_status) goto out;
- mcp23018_status = i2c_write(0b11000001, I2C_TIMEOUT);
- if (mcp23018_status) goto out;
- mcp23018_status = i2c_write(0b11111111, I2C_TIMEOUT);
- if (mcp23018_status) goto out;
+ uint8_t data[] = {0b11000001, 0b11111111};
+ mcp23018_status = i2c_writeReg(I2C_ADDR, IODIRA, data, sizeof(data), 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, sizeof(data), I2C_TIMEOUT);
+ }
-out:
- i2c_stop();
return mcp23018_status;
}
diff --git a/keyboards/gboards/gergoplex/gergoplex.h b/keyboards/gboards/gergoplex/gergoplex.h
index 549228104a..217cb8dff1 100644
--- a/keyboards/gboards/gergoplex/gergoplex.h
+++ b/keyboards/gboards/gergoplex/gergoplex.h
@@ -25,9 +25,7 @@ extern i2c_status_t mcp23018_status;
#define XXX KC_NO
// I2C aliases and register addresses (see "mcp23018.md")
-#define I2C_ADDR 0x20 // 0b0100000
-#define I2C_ADDR_WRITE ((I2C_ADDR << 1) | I2C_WRITE)
-#define I2C_ADDR_READ ((I2C_ADDR << 1) | I2C_READ)
+#define I2C_ADDR (0x20 << 1) // 0b0100000
#define IODIRA 0x00 // i/o direction register
#define IODIRB 0x01
#define GPPUA 0x0C // GPIO pull-up resistor register
diff --git a/keyboards/gboards/gergoplex/matrix.c b/keyboards/gboards/gergoplex/matrix.c
index c9f5528b74..9437b24377 100644
--- a/keyboards/gboards/gergoplex/matrix.c
+++ b/keyboards/gboards/gergoplex/matrix.c
@@ -177,20 +177,12 @@ static matrix_row_t read_cols(uint8_t row) {
if (mcp23018_status) { // if there was an error
return 0;
} else {
- uint8_t data = 0;
- mcp23018_status = i2c_start(I2C_ADDR_READ, I2C_TIMEOUT);
- if (mcp23018_status) goto out;
- mcp23018_status = i2c_read_nack(I2C_TIMEOUT);
- if (mcp23018_status < 0) goto out;
- data = ~((uint8_t)mcp23018_status);
- mcp23018_status = I2C_STATUS_SUCCESS;
- out:
- i2c_stop();
-
+ uint8_t data = 0;
+ mcp23018_status = i2c_receive(I2C_ADDR, &data, 1, I2C_TIMEOUT);
#ifdef DEBUG_MATRIX
- if (data != 0x00) xprintf("I2C: %d\n", data);
+ if (~data != 0x00) xprintf("I2C: %d\n", ~data);
#endif
- return data;
+ return ~data;
}
} else {
return ~((((PINF & COL4) >> 1) | ((PINF & (COL1 | COL2 | COL3)) >> 3)) & 0xF);
@@ -213,14 +205,10 @@ 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, I2C_TIMEOUT);
- if (mcp23018_status) goto out;
- mcp23018_status = i2c_write(GPIOA, I2C_TIMEOUT);
- if (mcp23018_status) goto out;
- mcp23018_status = i2c_write(0xFF & ~(1 << (row + 1)), I2C_TIMEOUT);
- if (mcp23018_status) goto out;
- out:
- i2c_stop();
+ uint8_t data;
+ data = 0xFF & ~(1 << (row + 1));
+ mcp23018_status = i2c_writeReg(I2C_ADDR, GPIOA, &data, 1, I2C_TIMEOUT);
+
}
} else {
setPinOutput(row_pins[row - MATRIX_ROWS_PER_SIDE]);