summaryrefslogtreecommitdiffstats
path: root/keyboards/hhkb/yang/yang.c
diff options
context:
space:
mode:
authorQMK Bot <hello@qmk.fm>2022-07-02 11:01:36 +0000
committerQMK Bot <hello@qmk.fm>2022-07-02 11:01:36 +0000
commit92c0b29be94acb5450fcd6e6e8673248b1b18052 (patch)
tree8fc12d3ee484cc6e0ea9b1ae11c45cb533a541e4 /keyboards/hhkb/yang/yang.c
parente3cad4045ad35f4441105123ecdd91a31649f8db (diff)
parentf439fe605543c6646d523a65b77533fea4b08ab8 (diff)
Merge remote-tracking branch 'origin/master' into develop
Diffstat (limited to 'keyboards/hhkb/yang/yang.c')
-rw-r--r--keyboards/hhkb/yang/yang.c118
1 files changed, 118 insertions, 0 deletions
diff --git a/keyboards/hhkb/yang/yang.c b/keyboards/hhkb/yang/yang.c
new file mode 100644
index 0000000000..7ae0d76390
--- /dev/null
+++ b/keyboards/hhkb/yang/yang.c
@@ -0,0 +1,118 @@
+/* Copyright 2021 Kan-Ru Chen <kanru@kanru.info>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "yang.h"
+
+extern uint8_t power_save_level;
+
+void hhkb_led_on(uint8_t led) {
+ switch (led) {
+ case 1:
+ writePinHigh(F4);
+ break;
+ case 2:
+ writePinHigh(F2);
+ break;
+ case 3:
+ writePinHigh(F0);
+ break;
+ }
+}
+
+void hhkb_led_off(uint8_t led) {
+ switch (led) {
+ case 1:
+ writePinLow(F4);
+ break;
+ case 2:
+ writePinLow(F2);
+ break;
+ case 3:
+ writePinLow(F0);
+ break;
+ }
+}
+
+void keyboard_pre_init_kb(void) {
+ // BT power up
+ setPinOutput(D5);
+ writePinLow(D5);
+
+ // Row selectors
+ setPinOutput(B0);
+ setPinOutput(B1);
+ setPinOutput(B2);
+
+ // Col selectors
+ setPinOutput(B3);
+ setPinOutput(B4);
+ setPinOutput(B5);
+
+ // Key strobe
+ setPinOutput(B6);
+ writePinHigh(B6);
+
+ // Key: input with pull-up
+ setPinInputHigh(D7);
+
+ // Unused pins on Pro2 ANSI
+ // Input with pull up to save power
+ setPinInputHigh(C6);
+ setPinInputHigh(C7);
+
+ // LED pin configuration
+ setPinOutput(F0);
+ setPinOutput(F1);
+ setPinOutput(F4);
+ writePinLow(F0);
+ writePinLow(F1);
+ writePinLow(F4);
+
+ // Turn on switch PCB
+ setPinOutput(D6);
+ writePinLow(D6);
+
+ keyboard_pre_init_user();
+}
+
+void suspend_power_down_kb(void) {
+ if (power_save_level > 2) {
+ // Disable UART TX to avoid current leakage
+ UCSR1B &= ~_BV(TXEN1);
+ // Power down BLE module
+ writePinHigh(D5);
+ }
+
+ suspend_power_down_user();
+}
+
+void suspend_wakeup_init_kb(void) {
+ // Power up BLE module
+ writePinLow(D5);
+ // Enable UART TX
+ UCSR1B |= _BV(TXEN1);
+
+ suspend_wakeup_init_user();
+}
+
+layer_state_t layer_state_set_kb(layer_state_t state) {
+ state = layer_state_set_user(state);
+
+ writePin(F1, IS_LAYER_ON_STATE(state, 1));
+ writePin(F0, IS_LAYER_ON_STATE(state, 2));
+
+ return state;
+}