summaryrefslogtreecommitdiff
path: root/keyboard/hhkb/hhkb_avr.h
diff options
context:
space:
mode:
authorJack Humbert <jack.humb@gmail.com>2015-03-16 12:01:35 -0400
committerJack Humbert <jack.humb@gmail.com>2015-03-16 12:01:35 -0400
commit9307a0a3e415d33d0858283f67fcba4c59a042ff (patch)
tree45252e53439dde1122945646f4fa340cf0a8923e /keyboard/hhkb/hhkb_avr.h
parentbe86aefdbda560d6810f9594169fee4385c1422d (diff)
parentc35c4283b9c2c65d62fe8dc5e4b7ca49a8f5af33 (diff)
downloadqmk_firmware-9307a0a3e415d33d0858283f67fcba4c59a042ff.tar.gz
qmk_firmware-9307a0a3e415d33d0858283f67fcba4c59a042ff.zip
Merge pull request #6 from tmk/master
pulling from tmk
Diffstat (limited to 'keyboard/hhkb/hhkb_avr.h')
-rw-r--r--keyboard/hhkb/hhkb_avr.h28
1 files changed, 23 insertions, 5 deletions
diff --git a/keyboard/hhkb/hhkb_avr.h b/keyboard/hhkb/hhkb_avr.h
index b7bd507b5d..7ea6322c73 100644
--- a/keyboard/hhkb/hhkb_avr.h
+++ b/keyboard/hhkb/hhkb_avr.h
@@ -41,17 +41,32 @@ static inline void KEY_UNABLE(void) { (PORTB |= (1<<6)); }
static inline bool KEY_STATE(void) { return (PIND & (1<<7)); }
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 = 0x00;
+ PORTB = 0x40; // unable
+ /* key: input with pull-up */
DDRD &= ~0x80;
- PORTD |= 0x80;
- /* keyswitch board power on */
- DDRD |= (1<<4);
- PORTD |= (1<<4);
+ PORTD |= 0x80;
#ifdef HHKB_JP
/* row extention for HHKB JP */
DDRC |= (1<<6|1<<7);
@@ -59,6 +74,8 @@ static inline void KEY_INIT(void)
#endif
KEY_UNABLE();
KEY_PREV_OFF();
+
+ KEY_POWER_OFF();
}
static inline void KEY_SELECT(uint8_t ROW, uint8_t COL)
{
@@ -98,6 +115,7 @@ static inline void KEY_SELECT(uint8_t ROW, uint8_t COL)
#define KEY_PREV_OFF() (PORTE &= ~(1<<7))
#define KEY_POWER_ON()
#define KEY_POWER_OFF()
+#define KEY_POWER_STATE() true
#else