+/* Columns 0 - 15
+ * These columns uses two 74HC237D 3 to 8 bit demultiplexers.
+ * col / pin: PB6 PC6 PC7 PF1 PF0
+ * 0: 0 1 0 0 0
+ * 1: 0 1 0 0 1
+ * 2: 0 1 0 1 0
+ * 3: 0 1 0 1 1
+ * 4: 0 1 1 0 0
+ * 5: 0 1 1 0 1
+ * 6: 0 1 1 1 0
+ * 7: 0 1 1 1 1
+ * 8: 1 0 0 0 0
+ * 9: 1 0 0 0 1
+ * 10: 1 0 0 1 0
+ * 11: 1 0 0 1 1
+ * 12: 1 0 1 0 0
+ * 13: 1 0 1 0 1
+ * 14: 1 0 1 1 0
+ * 15: 1 0 1 1 1
+ *
+ * col: 16
+ * pin: PB5
+ */
+static void unselect_cols(void) {
+ for (uint8_t x = 0; x < 6; x++) {
+ setPinOutput(col_pins[x]);
+ writePinLow(col_pins[x]);
+ }
+}
+
+static void select_col(uint8_t col) {
+ if (col < 16) {
+ uint8_t c = col + 8;
+
+ writePin(B6, c & 0b10000);
+ writePin(C6, c & 0b01000);
+ writePin(C7, c & 0b00100);
+ writePin(F1, c & 0b00010);
+ writePin(F0, c & 0b00001);
+ } else {
+ writePinHigh(B5);
+ }
+}
+
+/* Row pin configuration
+ * row: 0 1 2 3 4 5
+ * pin: D0 D1 D2 D3 D5 B7
+ *
+ * Caps lock uses its own pin E2
+ */
+static void init_pins(void) {
+ unselect_cols();
+ for (uint8_t x = 0; x < MATRIX_ROWS; x++) {
+ setPinInput(row_pins[x]);
+ }
+
+ setPinInputHigh(E2);
+}
+
+static bool read_rows_on_col(matrix_row_t current_matrix[], uint8_t current_col) {