aboutsummaryrefslogtreecommitdiff
path: root/keyboards/3w6
diff options
context:
space:
mode:
authorDrashna Jaelre <drashna@live.com>2021-09-07 18:53:55 -0700
committerGitHub <noreply@github.com>2021-09-08 02:53:55 +0100
commit0b8d6df39037e58b6b699332d2bbbc448889c6b2 (patch)
tree1723c566c0bd5888a2fbc7a006a1e9bf0318b4bc /keyboards/3w6
parent60c5bd7b5e0e75f48d9731118b92a3add3342efd (diff)
downloadqmk_firmware-0b8d6df39037e58b6b699332d2bbbc448889c6b2.tar.gz
qmk_firmware-0b8d6df39037e58b6b699332d2bbbc448889c6b2.zip
[Keyboard] Fix issues with 3w6 rev2 matrix (#14346)
Diffstat (limited to 'keyboards/3w6')
-rw-r--r--keyboards/3w6/rev2/matrix.c21
1 files changed, 10 insertions, 11 deletions
diff --git a/keyboards/3w6/rev2/matrix.c b/keyboards/3w6/rev2/matrix.c
index 4df161b89..0fc0322b6 100644
--- a/keyboards/3w6/rev2/matrix.c
+++ b/keyboards/3w6/rev2/matrix.c
@@ -187,23 +187,20 @@ static matrix_row_t read_cols(uint8_t row) {
187 } else { 187 } else {
188 uint8_t data = 0; 188 uint8_t data = 0;
189 uint8_t port0 = 0; 189 uint8_t port0 = 0;
190 tca9555_status = i2c_readReg(I2C_ADDR, IREGP0, port0, 1, I2C_TIMEOUT); 190 tca9555_status = i2c_readReg(I2C_ADDR, IREGP0, &port0, 1, I2C_TIMEOUT);
191 if (tca9555_status) { // if there was an error 191 if (tca9555_status) { // if there was an error
192 // do nothing 192 // do nothing
193 return 0; 193 return 0;
194 } else { 194 } else {
195 uint8_t port0 = ports[0];
196 uint8_t port1 = ports[1];
197
198 // We read all the pins on GPIOA. 195 // We read all the pins on GPIOA.
199 // The initial state was all ones and any depressed key at a given column for the currently selected row will have its bit flipped to zero. 196 // The initial state was all ones and any depressed key at a given column for the currently selected row will have its bit flipped to zero.
200 // The return value is a row as represented in the generic matrix code were the rightmost bits represent the lower columns and zeroes represent non-depressed keys while ones represent depressed keys. 197 // The return value is a row as represented in the generic matrix code were the rightmost bits represent the lower columns and zeroes represent non-depressed keys while ones represent depressed keys.
201 // the pins connected to eact columns are sequential, but in reverse order, and counting from zero down (col 5 -> GPIO04, col6 -> GPIO03 and so on). 198 // the pins connected to eact columns are sequential, but in reverse order, and counting from zero down (col 5 -> GPIO04, col6 -> GPIO03 and so on).
202 data |= ( port0 & 0x01 ) << 4; 199 data |= (port0 & 0x01) << 4;
203 data |= ( port0 & 0x02 ) << 2; 200 data |= (port0 & 0x02) << 2;
204 data |= ( port0 & 0x04 ); 201 data |= (port0 & 0x04);
205 data |= ( port0 & 0x08 ) >> 2; 202 data |= (port0 & 0x08) >> 2;
206 data |= ( port0 & 0x10 ) >> 4; 203 data |= (port0 & 0x10) >> 4;
207 204
208 tca9555_status = I2C_STATUS_SUCCESS; 205 tca9555_status = I2C_STATUS_SUCCESS;
209 return data; 206 return data;
@@ -244,11 +241,13 @@ static void select_row(uint8_t row) {
244 case 4: port1 &= ~(1 << 0); break; 241 case 4: port1 &= ~(1 << 0); break;
245 case 5: port1 &= ~(1 << 1); break; 242 case 5: port1 &= ~(1 << 1); break;
246 case 6: port1 &= ~(1 << 2); break; 243 case 6: port1 &= ~(1 << 2); break;
247 case 7: port0 &= ~(1 << 5); break; 244 case 7:
245 port1 &= ~(1 << 3);
246 break;
248 default: break; 247 default: break;
249 } 248 }
250 249
251 tca9555_status = i2c_writeReg(I2C_ADDR, OREGP1, port1, 2, I2C_TIMEOUT); 250 tca9555_status = i2c_writeReg(I2C_ADDR, OREGP1, &port1, 2, I2C_TIMEOUT);
252 // Select the desired row by writing a byte for the entire GPIOB bus where only the bit representing the row we want to select is a zero (write instruction) and every other bit is a one. 251 // Select the desired row by writing a byte for the entire GPIOB bus where only the bit representing the row we want to select is a zero (write instruction) and every other bit is a one.
253 // Note that the row - MATRIX_ROWS_PER_SIDE reflects the fact that being on the right hand, the columns are numbered from MATRIX_ROWS_PER_SIDE to MATRIX_ROWS, but the pins we want to write to are indexed from zero up on the GPIOB bus. 252 // Note that the row - MATRIX_ROWS_PER_SIDE reflects the fact that being on the right hand, the columns are numbered from MATRIX_ROWS_PER_SIDE to MATRIX_ROWS, but the pins we want to write to are indexed from zero up on the GPIOB bus.
254 } 253 }