]> git.friedersdorff.com Git - max/tmk_keyboard.git/blob - keyboard/kl27z_onekey/kl27z_onekey.c
core: Clean up code of Locking key support
[max/tmk_keyboard.git] / keyboard / kl27z_onekey / kl27z_onekey.c
1 /*
2 Copyright 2012 Jun Wako <wakojun@gmail.com>
3
4 This program is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation, either version 2 of the License, or
7 (at your option) any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with this program.  If not, see <http://www.gnu.org/licenses/>.
16 */
17
18 #include "ch.h"
19 #include "hal.h"
20
21 /*
22  * scan matrix
23  */
24 #include "print.h"
25 #include "debug.h"
26 #include "util.h"
27 #include "wait.h"
28 #include "matrix.h"
29 #include "led.h"
30 #include "keymap.h"
31
32
33 inline
34 uint8_t matrix_rows(void)
35 {
36     return MATRIX_ROWS;
37 }
38
39 inline
40 uint8_t matrix_cols(void)
41 {
42     return MATRIX_COLS;
43 }
44
45 void matrix_init(void)
46 {
47     // internal pull-up
48     palSetPadMode(GPIOA, 4, PAL_MODE_INPUT_PULLUP);
49
50     // LED blink
51     palSetPadMode(GPIOD, 7, PAL_MODE_OUTPUT_PUSHPULL);
52     palSetPad(GPIOD, 7);
53     chThdSleepMilliseconds(200);
54     palClearPad(GPIOD, 7);
55     chThdSleepMilliseconds(200);
56     palSetPad(GPIOD, 7);
57     chThdSleepMilliseconds(200);
58     palClearPad(GPIOD, 7);
59 }
60
61 uint8_t matrix_scan(void)
62 {
63     return 1;
64 }
65
66 inline
67 bool matrix_is_on(uint8_t row, uint8_t col)
68 {
69     return !palReadPad(GPIOA, 4);
70 }
71
72 inline
73 matrix_row_t matrix_get_row(uint8_t row)
74 {
75     return !palReadPad(GPIOA, 4);
76 }
77
78 void matrix_print(void)
79 {
80 }
81
82 void led_set(uint8_t usb_led) {
83     if (usb_led & (1<<USB_LED_CAPS_LOCK)) {
84         // output high
85         palSetPadMode(GPIOD, 7, PAL_MODE_OUTPUT_PUSHPULL);
86         palSetPad(GPIOD, 7);
87     } else {
88         // Hi-Z
89         palSetPadMode(GPIOD, 7, PAL_MODE_INPUT);
90     }
91 }
92
93
94 //
95 // Keymap
96 //
97 const uint8_t keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
98     {{KC_A}},
99 };
100
101 const action_t fn_actions[] = {
102 };