aboutsummaryrefslogtreecommitdiff
path: root/keyboards/splitkb/elora/rev1/matrix.c
diff options
context:
space:
mode:
authorleah-splitkb <103112489+leah-splitkb@users.noreply.github.com>2025-03-02 22:33:03 +0100
committerGitHub <noreply@github.com>2025-03-02 14:33:03 -0700
commitcb6e1c1af54790e778062ba7203aa23370c263b0 (patch)
tree5fb1b3c42c293af6c03741f96e52a5e9370351fa /keyboards/splitkb/elora/rev1/matrix.c
parent563eb6fdc9224a772d19e2d5714e903fa7c021c6 (diff)
Add splitkb.com's Elora (#22557)
* Add splitkb's Elora * WIP * Make requested changes * fix missing call to keyboard init user for elora * sync vial_qmk with qmk * Add fixes * Add encoder quadrature and update files * Update Readme * Implement changes * Remove encoder driver from keyboard.json * make requested changed * Implement changes and remove myriad_task as it wasn't actually doing anything. * Remove myriad.h from matrix.c * Simplify OLED code debug * Update RGB keycodes (qmk#24484) * remove rules.mk (qmk#23281) * Add matrix state sync --------- Co-authored-by: NapOli1084 <10320176+NapOli1084@users.noreply.github.com> Co-authored-by: harveysch <126267034+harvey-splitkb@users.noreply.github.com> Co-authored-by: harvey <harvey@splitkb.com> Co-authored-by: VeyPatch <126267034+VeyPatch@users.noreply.github.com>
Diffstat (limited to 'keyboards/splitkb/elora/rev1/matrix.c')
-rw-r--r--keyboards/splitkb/elora/rev1/matrix.c57
1 files changed, 57 insertions, 0 deletions
diff --git a/keyboards/splitkb/elora/rev1/matrix.c b/keyboards/splitkb/elora/rev1/matrix.c
new file mode 100644
index 0000000000..625eafcd85
--- /dev/null
+++ b/keyboards/splitkb/elora/rev1/matrix.c
@@ -0,0 +1,57 @@
+// Copyright 2024 splitkb.com (support@splitkb.com)
+// SPDX-License-Identifier: GPL-2.0-or-later
+
+#include "matrix.h"
+#include "spi_master.h"
+
+// The matrix is hooked up to a chain of 74xx165 shift registers.
+// Pin F0 acts as Chip Select (active-low)
+// The signal goes to a NOT gate, whose output is wired to
+// a) the latch pin of the shift registers
+// b) the "enable" pin of a tri-state buffer,
+// attached between the shift registers and MISO
+// F0 has an external pull-up.
+// SCK works as usual.
+//
+// Note that the matrix contains a variety of data.
+// In addition to the keys, it also reads the rotary encoders
+// and whether the board is the left/right half.
+
+void matrix_init_custom(void) {
+ // Note: `spi_init` has already been called
+ // in `keyboard_pre_init_kb()`, so nothing to do here
+}
+
+bool matrix_scan_custom(matrix_row_t current_matrix[]) {
+ // Enough to hold the shift registers
+ uint16_t length = 5;
+ uint8_t data[length];
+
+ // Matrix SPI config
+ // 1) Pin
+ // 2) Mode: Register shifts on rising clock, and clock idles low
+ // pol = 0 & pha = 0 => mode 0
+ // 3) LSB first: Register outputs H first, and we want H as MSB,
+ // as this result in a neat A-H order in the layout macro.
+ // 4) Divisor: 2 is the fastest possible, at Fclk / 2.
+ // range is 2-128
+ spi_start(GP13, false, 0, 128);
+ spi_receive(data, length);
+ spi_stop();
+
+ bool matrix_has_changed = false;
+ for (uint8_t i = 0; i < length; i++) {
+ // Bitwise NOT because we use pull-ups,
+ // and switches short the pin to ground,
+ // but the matrix uses 1 to indicate a pressed switch
+ uint8_t word = ~data[i];
+ matrix_has_changed |= current_matrix[i] ^ word;
+ current_matrix[i] = word;
+ }
+#ifdef MYRIAD_ENABLE
+ bool myriad_hook_matrix(matrix_row_t current_matrix[]);
+ return matrix_has_changed || myriad_hook_matrix(current_matrix);
+#else
+ return matrix_has_changed;
+#endif
+} \ No newline at end of file