-// void matrix_power_up(void) {
-// #if (DIODE_DIRECTION == COL2ROW)
-// for (int8_t r = MATRIX_ROWS - 1; r >= 0; --r) {
-// /* DDRxn */
-// _SFR_IO8((row_pins[r] >> 4) + 1) |= _BV(row_pins[r] & 0xF);
-// toggle_row(r);
-// }
-// for (int8_t c = MATRIX_COLS - 1; c >= 0; --c) {
-// /* PORTxn */
-// _SFR_IO8((col_pins[c] >> 4) + 2) |= _BV(col_pins[c] & 0xF);
-// }
-// #else
-// for (int8_t c = MATRIX_COLS - 1; c >= 0; --c) {
-// /* DDRxn */
-// _SFR_IO8((col_pins[c] >> 4) + 1) |= _BV(col_pins[c] & 0xF);
-// toggle_col(c);
-// }
-// for (int8_t r = MATRIX_ROWS - 1; r >= 0; --r) {
-// /* PORTxn */
-// _SFR_IO8((row_pins[r] >> 4) + 2) |= _BV(row_pins[r] & 0xF);
-// }
-// #endif
-// }
-
-void matrix_init(void) {
-
- // To use PORTF disable JTAG with writing JTD bit twice within four cycles.
- #if (defined(__AVR_AT90USB1286__) || defined(__AVR_AT90USB1287__) || defined(__AVR_ATmega32U4__))
- MCUCR |= _BV(JTD);
- MCUCR |= _BV(JTD);
- #endif
-
- // initialize row and col
-#if (DIODE_DIRECTION == COL2ROW)
- unselect_rows();
- init_cols();
-#else // ROW2COL
- unselect_cols();
- init_rows();
-#endif
-
- // initialize matrix state: all keys off
- for (uint8_t i=0; i < MATRIX_ROWS; i++) {
- matrix[i] = 0;
- matrix_raw[i] = 0;
- matrix_debouncing[i] = 0;
- }
-
- matrix_init_quantum();
-}
-
-uint8_t matrix_scan(void)
-{
-
-#if (DIODE_DIRECTION == COL2ROW)
-
- // Set row, read cols
- for (uint8_t current_row = 0; current_row < MATRIX_ROWS; current_row++) {
- read_cols_on_row(matrix, current_row);
- }
-
- // select_row(i);
- // wait_us(30); // without this wait read unstable value.
- // matrix_row_t current_row = read_cols();
- // if (matrix_debouncing[i] != current_row) {
- // matrix_debouncing[i] = current_row;
- // if (debouncing) {
- // debug("bounce!: "); debug_hex(debouncing); debug("\n");
- // }
- // debouncing = DEBOUNCING_DELAY;
- // }
- // unselect_row(i);
- // }
-
- // if (debouncing) {
- // if (--debouncing) {
- // wait_ms(1);
- // } else {
- // for (uint8_t i = 0; i < MATRIX_ROWS; i++) {
- // matrix[i] = matrix_debouncing[i];
- // }
- // }
- // }
-
-#else // ROW2COL
-
- // Set col, read rows
- for (uint8_t current_col = 0; current_col < MATRIX_COLS; current_col++) {
- read_rows_on_col(matrix, current_col);
- }
-
-
- // for (uint8_t i = 0; i < MATRIX_COLS; i++) {
- // select_col(i);
- // wait_us(30); // without this wait read unstable value.
- // matrix_col_t current_col = read_rows();
- // if (matrix_transposed_debouncing[i] != current_col) {
- // matrix_transposed_debouncing[i] = current_col;
- // if (debouncing) {
- // debug("bounce!: "); debug_hex(debouncing); debug("\n");
- // }
- // debouncing = DEBOUNCING_DELAY;
- // }
- // unselect_col(i);
- // }
-
- // if (debouncing) {
- // if (--debouncing) {
- // wait_ms(1);
- // } else {
- // for (uint8_t i = 0; i < MATRIX_COLS; i++) {
- // matrix_transposed[i] = matrix_transposed_debouncing[i];
- // }
- // }
- // }
-
- // // Untranspose matrix
- // for (uint8_t y = 0; y < MATRIX_ROWS; y++) {
- // matrix_row_t row = 0;
- // for (uint8_t x = 0; x < MATRIX_COLS; x++) {
- // row |= ((matrix_transposed[x] & (1<<y)) >> y) << x;
- // }
- // matrix[y] = row;
- // }
-
-#endif
-
- matrix_scan_quantum();
-// matrix_print();
- return 1;
-}
-