aboutsummaryrefslogtreecommitdiff
path: root/quantum/matrix.h
diff options
context:
space:
mode:
Diffstat (limited to 'quantum/matrix.h')
-rw-r--r--quantum/matrix.h79
1 files changed, 79 insertions, 0 deletions
diff --git a/quantum/matrix.h b/quantum/matrix.h
new file mode 100644
index 000000000..ce57010a4
--- /dev/null
+++ b/quantum/matrix.h
@@ -0,0 +1,79 @@
1/*
2Copyright 2011 Jun Wako <wakojun@gmail.com>
3
4This program is free software: you can redistribute it and/or modify
5it under the terms of the GNU General Public License as published by
6the Free Software Foundation, either version 2 of the License, or
7(at your option) any later version.
8
9This program is distributed in the hope that it will be useful,
10but WITHOUT ANY WARRANTY; without even the implied warranty of
11MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12GNU General Public License for more details.
13
14You should have received a copy of the GNU General Public License
15along with this program. If not, see <http://www.gnu.org/licenses/>.
16*/
17
18#pragma once
19
20#include <stdint.h>
21#include <stdbool.h>
22
23#if (MATRIX_COLS <= 8)
24typedef uint8_t matrix_row_t;
25#elif (MATRIX_COLS <= 16)
26typedef uint16_t matrix_row_t;
27#elif (MATRIX_COLS <= 32)
28typedef uint32_t matrix_row_t;
29#else
30# error "MATRIX_COLS: invalid value"
31#endif
32
33#define MATRIX_ROW_SHIFTER ((matrix_row_t)1)
34
35#ifdef __cplusplus
36extern "C" {
37#endif
38
39/* number of matrix rows */
40uint8_t matrix_rows(void);
41/* number of matrix columns */
42uint8_t matrix_cols(void);
43/* should be called at early stage of startup before matrix_init.(optional) */
44void matrix_setup(void);
45/* intialize matrix for scaning. */
46void matrix_init(void);
47/* scan all key states on matrix */
48uint8_t matrix_scan(void);
49/* whether modified from previous scan. used after matrix_scan. */
50bool matrix_is_modified(void) __attribute__((deprecated));
51/* whether a switch is on */
52bool matrix_is_on(uint8_t row, uint8_t col);
53/* matrix state on row */
54matrix_row_t matrix_get_row(uint8_t row);
55/* print matrix for debug */
56void matrix_print(void);
57/* delay between changing matrix pin state and reading values */
58void matrix_output_select_delay(void);
59void matrix_output_unselect_delay(void);
60/* only for backwards compatibility. delay between changing matrix pin state and reading values */
61void matrix_io_delay(void);
62
63/* power control */
64void matrix_power_up(void);
65void matrix_power_down(void);
66
67/* executes code for Quantum */
68void matrix_init_quantum(void);
69void matrix_scan_quantum(void);
70
71void matrix_init_kb(void);
72void matrix_scan_kb(void);
73
74void matrix_init_user(void);
75void matrix_scan_user(void);
76
77#ifdef __cplusplus
78}
79#endif