diff options
author | QMK Bot <hello@qmk.fm> | 2021-09-07 15:35:32 +0000 |
---|---|---|
committer | QMK Bot <hello@qmk.fm> | 2021-09-07 15:35:32 +0000 |
commit | af19461a02b8a5f89d26c448b10984aa0ac19f42 (patch) | |
tree | be484d88bf4d4621355c4fd5f8d30bbd4117e1d1 /keyboards/sx60/matrix.c | |
parent | c669c4376972446f52340584976d935ea9bf23ca (diff) | |
parent | 04c0704b280c4847c43b164335e9741b19219131 (diff) |
Merge remote-tracking branch 'origin/master' into develop
Diffstat (limited to 'keyboards/sx60/matrix.c')
-rw-r--r-- | keyboards/sx60/matrix.c | 21 |
1 files changed, 7 insertions, 14 deletions
diff --git a/keyboards/sx60/matrix.c b/keyboards/sx60/matrix.c index 6fa0dd1456..b7dc25425d 100644 --- a/keyboards/sx60/matrix.c +++ b/keyboards/sx60/matrix.c @@ -243,15 +243,11 @@ static bool read_cols_on_row(matrix_row_t current_matrix[], uint8_t current_row) /* if there was an error */ return 0; } else { - uint16_t data = 0; - 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_start(I2C_ADDR_READ); if (mcp23018_status) goto out; - data = i2c_readNak(); - data = ~data; - out: - i2c_stop(); - current_matrix[current_row] |= (data << 8); + uint8_t data = 0; + mcp23018_status = i2c_readReg(I2C_ADDR, GPIOA, &data, 1, I2C_TIMEOUT); + if (!mcp23018_status) { + current_matrix[current_row] |= (~((uint16_t)data) << 8); + } } /* For each col... */ @@ -278,11 +274,8 @@ static void select_row(uint8_t row) /* set active row low : 0 set active row output : 1 set other rows hi-Z : 1 */ - 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_write(0xFF & ~(1<<abs(row-4))); if (mcp23018_status) goto out; - out: - i2c_stop(); + uint8_t port = 0xFF & ~(1<<abs(row-4)); + mcp23018_status = i2c_writeReg(I2C_ADDR, GPIOB, &port, 1, I2C_TIMEOUT); } uint8_t pin = row_pins[row]; |