diff options
Diffstat (limited to 'keyboards/dc01')
| -rw-r--r-- | keyboards/dc01/left/config.h | 2 | ||||
| -rw-r--r-- | keyboards/dc01/left/matrix.c | 41 |
2 files changed, 15 insertions, 28 deletions
diff --git a/keyboards/dc01/left/config.h b/keyboards/dc01/left/config.h index 68484d835..e3d49404e 100644 --- a/keyboards/dc01/left/config.h +++ b/keyboards/dc01/left/config.h | |||
| @@ -46,6 +46,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
| 46 | #define MATRIX_COL_PINS { F4, F1, F0, F7, F6, F5 } | 46 | #define MATRIX_COL_PINS { F4, F1, F0, F7, F6, F5 } |
| 47 | #define UNUSED_PINS | 47 | #define UNUSED_PINS |
| 48 | 48 | ||
| 49 | #define F_SCL 300000UL | ||
| 50 | |||
| 49 | /* COL2ROW, ROW2COL, or CUSTOM_MATRIX */ | 51 | /* COL2ROW, ROW2COL, or CUSTOM_MATRIX */ |
| 50 | #define DIODE_DIRECTION COL2ROW | 52 | #define DIODE_DIRECTION COL2ROW |
| 51 | 53 | ||
diff --git a/keyboards/dc01/left/matrix.c b/keyboards/dc01/left/matrix.c index 792376635..806583580 100644 --- a/keyboards/dc01/left/matrix.c +++ b/keyboards/dc01/left/matrix.c | |||
| @@ -43,7 +43,7 @@ static uint8_t error_count_arrow = 0; | |||
| 43 | /* Set 0 if debouncing isn't needed */ | 43 | /* Set 0 if debouncing isn't needed */ |
| 44 | 44 | ||
| 45 | #ifndef DEBOUNCING_DELAY | 45 | #ifndef DEBOUNCING_DELAY |
| 46 | # define DEBOUNCING_DELAY 5 | 46 | # define DEBOUNCING_DELAY 5 |
| 47 | #endif | 47 | #endif |
| 48 | 48 | ||
| 49 | #if (DEBOUNCING_DELAY > 0) | 49 | #if (DEBOUNCING_DELAY > 0) |
| @@ -135,10 +135,7 @@ uint8_t matrix_cols(void) { | |||
| 135 | return MATRIX_COLS; | 135 | return MATRIX_COLS; |
| 136 | } | 136 | } |
| 137 | 137 | ||
| 138 | |||
| 139 | i2c_status_t i2c_transaction(uint8_t address, uint32_t mask, uint8_t col_offset); | 138 | i2c_status_t i2c_transaction(uint8_t address, uint32_t mask, uint8_t col_offset); |
| 140 | //uint8_t i2c_transaction_numpad(void); | ||
| 141 | //uint8_t i2c_transaction_arrow(void); | ||
| 142 | 139 | ||
| 143 | //this replases tmk code | 140 | //this replases tmk code |
| 144 | void matrix_setup(void){ | 141 | void matrix_setup(void){ |
| @@ -220,7 +217,7 @@ uint8_t matrix_scan(void) | |||
| 220 | matrix[i] &= 0x3F; //mask bits to keep | 217 | matrix[i] &= 0x3F; //mask bits to keep |
| 221 | } | 218 | } |
| 222 | } | 219 | } |
| 223 | }else{ //no error | 220 | }else{ //no error |
| 224 | error_count_right = 0; | 221 | error_count_right = 0; |
| 225 | } | 222 | } |
| 226 | 223 | ||
| @@ -440,40 +437,28 @@ static void unselect_cols(void) | |||
| 440 | // Complete rows from other modules over i2c | 437 | // Complete rows from other modules over i2c |
| 441 | i2c_status_t i2c_transaction(uint8_t address, uint32_t mask, uint8_t col_offset) { | 438 | i2c_status_t i2c_transaction(uint8_t address, uint32_t mask, uint8_t col_offset) { |
| 442 | i2c_status_t err = i2c_start((address << 1) | I2C_WRITE, 10); | 439 | i2c_status_t err = i2c_start((address << 1) | I2C_WRITE, 10); |
| 443 | if (err) return err; | 440 | i2c_write(0x01, 10); //request data in address 1 |
| 444 | i2c_write(0x01, 10); | ||
| 445 | if (err) return err; | ||
| 446 | 441 | ||
| 447 | i2c_start((address << 1) | I2C_READ, 10); | 442 | i2c_start((address << 1) | I2C_READ, 5); |
| 448 | if (err) return err; | ||
| 449 | 443 | ||
| 450 | err = i2c_read_ack(10); | 444 | err = i2c_read_ack(10); |
| 451 | if (err == 0x55) { //synchronization byte | 445 | if (err == 0x55) { //synchronization byte |
| 452 | 446 | ||
| 453 | for (uint8_t i = 0; i < MATRIX_ROWS-1 ; i++) { //assemble slave matrix in main matrix | 447 | for (uint8_t i = 0; i < MATRIX_ROWS-1 ; i++) { //assemble slave matrix in main matrix |
| 454 | matrix[i] &= mask; //mask bits to keep | 448 | matrix[i] &= mask; //mask bits to keep |
| 455 | err = i2c_read_ack(10); | 449 | err = i2c_read_ack(10); |
| 456 | if (err >= 0) { | 450 | matrix[i] |= ((uint32_t)err << (MATRIX_COLS_SCANNED + col_offset)); //add new bits at the end |
| 457 | matrix[i] |= ((uint32_t)err << (MATRIX_COLS_SCANNED + col_offset)); //add new bits at the end | 451 | } |
| 458 | } else { | 452 | //last read request must be followed by a NACK |
| 459 | return err; | 453 | matrix[MATRIX_ROWS - 1] &= mask; //mask bits to keep |
| 460 | } | 454 | err = i2c_read_nack(10); |
| 461 | } | ||
| 462 | //last read request must be followed by a NACK | ||
| 463 | matrix[MATRIX_ROWS - 1] &= mask; //mask bits to keep | ||
| 464 | err = i2c_read_nack(10); | ||
| 465 | if (err >= 0) { | ||
| 466 | matrix[MATRIX_ROWS - 1] |= ((uint32_t)err << (MATRIX_COLS_SCANNED + col_offset)); //add new bits at the end | 455 | matrix[MATRIX_ROWS - 1] |= ((uint32_t)err << (MATRIX_COLS_SCANNED + col_offset)); //add new bits at the end |
| 467 | } else { | 456 | |
| 468 | return err; | ||
| 469 | } | ||
| 470 | } else { | 457 | } else { |
| 471 | i2c_stop(10); | 458 | i2c_stop(10); |
| 472 | return 1; | 459 | return 1; |
| 473 | } | 460 | } |
| 474 | 461 | ||
| 475 | i2c_stop(10); | 462 | i2c_stop(10); |
| 476 | if (err) return err; | ||
| 477 | |||
| 478 | return 0; | 463 | return 0; |
| 479 | } \ No newline at end of file | 464 | } \ No newline at end of file |
