aboutsummaryrefslogtreecommitdiff
path: root/keyboards/dc01/left/matrix.c
diff options
context:
space:
mode:
authorNick Brassel <[email protected]>2024-02-28 21:47:37 +1100
committerNick Brassel <[email protected]>2024-02-28 21:47:37 +1100
commit4e369d405af6bba1adce6337b2e1b1ea1788566c (patch)
treeb0f020feff1809e37c9e7795d344929ff0bb290a /keyboards/dc01/left/matrix.c
parent4e04da397ef643f8fcf4afbe1d19f63aee1fc561 (diff)
parentdd1706e468bb18dd7f7ae143de735a5d3be1bfb8 (diff)
downloadqmk_firmware-4e369d405af6bba1adce6337b2e1b1ea1788566c.tar.gz
qmk_firmware-4e369d405af6bba1adce6337b2e1b1ea1788566c.zip
Merge branch 'develop'0.24.0
Diffstat (limited to 'keyboards/dc01/left/matrix.c')
-rw-r--r--keyboards/dc01/left/matrix.c36
1 files changed, 6 insertions, 30 deletions
diff --git a/keyboards/dc01/left/matrix.c b/keyboards/dc01/left/matrix.c
index d384c6a4bc..fd21d4333b 100644
--- a/keyboards/dc01/left/matrix.c
+++ b/keyboards/dc01/left/matrix.c
@@ -387,37 +387,13 @@ static void unselect_cols(void)
// Complete rows from other modules over i2c
i2c_status_t i2c_transaction(uint8_t address, uint32_t mask, uint8_t col_offset) {
- i2c_status_t status = i2c_start(address, 5);
- if (status < 0) {
- goto error;
- }
-
- status = i2c_write(0x01, 50);
- if (status < 0) {
- goto error;
- }
-
- status = i2c_start(address | I2C_READ, 50);
+ uint8_t data[MATRIX_ROWS + 1];
+ i2c_status_t status = i2c_readReg(address, 0x01, data, (MATRIX_ROWS + 1), 5);
- status = i2c_read_ack(50);
- if (status != 0x55) { //synchronization byte
- goto error;
+ for (uint8_t i = 0; i < (MATRIX_ROWS) && status >= 0; i++) { //assemble slave matrix in main matrix
+ matrix[i] &= mask; //mask bits to keep
+ matrix[i] |= ((uint32_t)data[i+1] << (MATRIX_COLS_SCANNED + col_offset)); //add new bits at the end
}
- for (uint8_t i = 0; i < MATRIX_ROWS-1 && status >= 0; i++) { //assemble slave matrix in main matrix
- matrix[i] &= mask; //mask bits to keep
- status = i2c_read_ack(50);
- matrix[i] |= ((uint32_t)status << (MATRIX_COLS_SCANNED + col_offset)); //add new bits at the end
- }
- //last read request must be followed by a NACK
- if (status >= 0) {
- matrix[MATRIX_ROWS - 1] &= mask; //mask bits to keep
- status = i2c_read_nack(50);
- matrix[MATRIX_ROWS - 1] |= ((uint32_t)status << (MATRIX_COLS_SCANNED + col_offset)); //add new bits at the end
- }
-
-error:
- i2c_stop();
-
- return (status < 0) ? status : I2C_STATUS_SUCCESS;
+ return status;
}