aboutsummaryrefslogtreecommitdiff
path: root/keyboards/spiderisland/split78/matrix.c
diff options
context:
space:
mode:
Diffstat (limited to 'keyboards/spiderisland/split78/matrix.c')
-rw-r--r--keyboards/spiderisland/split78/matrix.c16
1 files changed, 14 insertions, 2 deletions
diff --git a/keyboards/spiderisland/split78/matrix.c b/keyboards/spiderisland/split78/matrix.c
index b5c7028fd..71e154e5b 100644
--- a/keyboards/spiderisland/split78/matrix.c
+++ b/keyboards/spiderisland/split78/matrix.c
@@ -105,9 +105,17 @@ void matrix_init_custom(void) {
105 105
106} 106}
107 107
108static i2c_status_t mcp23018_status = I2C_STATUS_SUCCESS;
109
108bool matrix_scan_custom(matrix_row_t current_matrix[]) { 110bool matrix_scan_custom(matrix_row_t current_matrix[]) {
109 bool matrix_has_changed = false; 111 bool matrix_has_changed = false;
110 112
113#if defined(RIGHT_HALF)
114 if (mcp23018_status != I2C_STATUS_SUCCESS) {
115 mcp23018_status = mcp23018_init();
116 }
117#endif
118
111 for (uint8_t row = 0; row < MATRIX_ROWS; row++) { 119 for (uint8_t row = 0; row < MATRIX_ROWS; row++) {
112 // Store last value of row prior to reading 120 // Store last value of row prior to reading
113 matrix_row_t last_row_value = current_matrix[row]; 121 matrix_row_t last_row_value = current_matrix[row];
@@ -124,7 +132,9 @@ bool matrix_scan_custom(matrix_row_t current_matrix[]) {
124 // as 0x75 would be no keys pressed 132 // as 0x75 would be no keys pressed
125 uint8_t data = 0x7F; 133 uint8_t data = 0x7F;
126 // Receive the columns from right half 134 // Receive the columns from right half
127 i2c_receive(TWI_ADDR_WRITE, &data, 1, I2C_TIMEOUT); 135 if (mcp23018_status == I2C_STATUS_SUCCESS) {
136 mcp23018_status = i2c_receive(TWI_ADDR_WRITE, &data, 1, I2C_TIMEOUT);
137 }
128#endif 138#endif
129 139
130 cols |= ((~(PINA | 0x80)) & 0x7F); 140 cols |= ((~(PINA | 0x80)) & 0x7F);
@@ -146,7 +156,9 @@ void matrix_set_row_status(uint8_t row) {
146 //Set the remote row on port A 156 //Set the remote row on port A
147 txdata[0] = (GPIOA); 157 txdata[0] = (GPIOA);
148 txdata[1] = ( 0xFF & ~(1<<row) ); 158 txdata[1] = ( 0xFF & ~(1<<row) );
149 i2c_transmit(TWI_ADDR_WRITE, (uint8_t *)txdata, 2, I2C_TIMEOUT); 159 if (mcp23018_status == I2C_STATUS_SUCCESS) {
160 mcp23018_status = i2c_transmit(TWI_ADDR_WRITE, (uint8_t *)txdata, 2, I2C_TIMEOUT);
161 }
150#endif 162#endif
151 163
152 //Set the local row on port B 164 //Set the local row on port B