summaryrefslogtreecommitdiff
path: root/keyboards
diff options
context:
space:
mode:
authorjels <66403163+Jels02@users.noreply.github.com>2022-07-02 22:18:56 +1000
committerGitHub <noreply@github.com>2022-07-02 22:18:56 +1000
commitac333016eb5aeb555357751c8d05d62abe944daa (patch)
treef80437a38ac999e3e0b14aa40ea860df552a8075 /keyboards
parenta80943579c88255fff9de57978b8e577d184785c (diff)
Add ATmega32u2 Support to HHKB (#17298)
Diffstat (limited to 'keyboards')
-rw-r--r--keyboards/hhkb/ansi/32u2/rules.mk5
-rw-r--r--keyboards/hhkb/ansi/hhkb_avr.h54
-rw-r--r--keyboards/hhkb/ansi/rules.mk4
3 files changed, 61 insertions, 2 deletions
diff --git a/keyboards/hhkb/ansi/32u2/rules.mk b/keyboards/hhkb/ansi/32u2/rules.mk
new file mode 100644
index 0000000000..0c0b4c37c2
--- /dev/null
+++ b/keyboards/hhkb/ansi/32u2/rules.mk
@@ -0,0 +1,5 @@
+# MCU name
+MCU = atmega32u2
+
+CONSOLE_ENABLE = no # Console for debug
+COMMAND_ENABLE = no # Commands for debug and configuration
diff --git a/keyboards/hhkb/ansi/hhkb_avr.h b/keyboards/hhkb/ansi/hhkb_avr.h
index f9446deef7..a805445e9b 100644
--- a/keyboards/hhkb/ansi/hhkb_avr.h
+++ b/keyboards/hhkb/ansi/hhkb_avr.h
@@ -78,6 +78,60 @@ static inline void KEY_SELECT(uint8_t ROW, uint8_t COL)
}
+#elif defined(__AVR_ATmega32U2__)
+/*
+ * For TMK HHKB alt controller(ATMega32U4)
+ *
+ * row: PB0-2
+ * col: PB3-5,6
+ * key: PD3(pull-uped)
+ * prev: PB7
+ * power: PD4(L:off/H:on)
+ * row-ext: PC6,7 for HHKB JP(active low)
+ */
+static inline void KEY_ENABLE(void) { (PORTB &= ~(1<<6)); }
+static inline void KEY_UNABLE(void) { (PORTB |= (1<<6)); }
+static inline bool KEY_STATE(void) { return (PIND & (1<<3)); }
+static inline void KEY_PREV_ON(void) { (PORTB |= (1<<7)); }
+static inline void KEY_PREV_OFF(void) { (PORTB &= ~(1<<7)); }
+#ifdef HHKB_POWER_SAVING
+static inline void KEY_POWER_ON(void) {
+ DDRB = 0xFF; PORTB = 0x40; // change pins output
+ DDRD |= (1<<4); PORTD |= (1<<4); // MOS FET switch on
+ /* Without this wait you will miss or get false key events. */
+ _delay_ms(5); // wait for powering up
+}
+static inline void KEY_POWER_OFF(void) {
+ /* input with pull-up consumes less than without it when pin is open. */
+ DDRB = 0x00; PORTB = 0xFF; // change pins input with pull-up
+ DDRD |= (1<<4); PORTD &= ~(1<<4); // MOS FET switch off
+}
+static inline bool KEY_POWER_STATE(void) { return PORTD & (1<<4); }
+#else
+static inline void KEY_POWER_ON(void) {}
+static inline void KEY_POWER_OFF(void) {}
+static inline bool KEY_POWER_STATE(void) { return true; }
+#endif
+static inline void KEY_INIT(void)
+{
+ /* row,col,prev: output */
+ DDRB = 0xFF;
+ PORTB = 0x40; // unable
+ /* key: input with pull-up */
+ DDRD &= ~0x80;
+ PORTD |= 0x80;
+
+ KEY_UNABLE();
+ KEY_PREV_OFF();
+
+ KEY_POWER_OFF();
+}
+static inline void KEY_SELECT(uint8_t ROW, uint8_t COL)
+{
+ PORTB = (PORTB & 0xC0) | (((COL) & 0x07)<<3) | ((ROW) & 0x07);
+
+}
+
#elif defined(__AVR_AT90USB1286__)
/*
diff --git a/keyboards/hhkb/ansi/rules.mk b/keyboards/hhkb/ansi/rules.mk
index 0b110d6561..40a34662bc 100644
--- a/keyboards/hhkb/ansi/rules.mk
+++ b/keyboards/hhkb/ansi/rules.mk
@@ -14,9 +14,9 @@ CONSOLE_ENABLE = yes # Console for debug
COMMAND_ENABLE = yes # Commands for debug and configuration
CUSTOM_MATRIX = yes # Custom matrix file for the HHKB
NKRO_ENABLE = no # Enable N-Key Rollover
-# BACKLIGHT_ENABLE = yes # Enable keyboard backlight functionality
+BACKLIGHT_ENABLE = no # Enable keyboard backlight functionality
-# HHKB_RN42_ENABLE = yes # Enable support for hasu's BT alt controller -- code borrowed from tmk source tree.
+HHKB_RN42_ENABLE = no # Enable support for hasu's BT alt controller -- code borrowed from tmk source tree.
# Either uncomment the HHKB_RN42_ENABLE line above, or run make enabling the
# feature. Be sure to clean any existing build before trying to enable rn42