summaryrefslogtreecommitdiff
path: root/keyboard
diff options
context:
space:
mode:
authortmk <nobody@nowhere>2014-10-02 09:58:47 +0900
committertmk <nobody@nowhere>2014-10-02 09:58:47 +0900
commit6c06b9031fd09479d552f9750a3b1cfe259678fd (patch)
tree1519d8c40ca11fb7f76b6e503c1294a0f943d373 /keyboard
parentbfd2d969b48eb2f381137383c6262b60e03cf5b1 (diff)
downloadqmk_firmware-6c06b9031fd09479d552f9750a3b1cfe259678fd.tar.gz
qmk_firmware-6c06b9031fd09479d552f9750a3b1cfe259678fd.zip
Add power control of key switch board
Diffstat (limited to 'keyboard')
-rw-r--r--keyboard/hhkb_rn42/config.h2
-rw-r--r--keyboard/hhkb_rn42/hhkb_avr.h26
2 files changed, 23 insertions, 5 deletions
diff --git a/keyboard/hhkb_rn42/config.h b/keyboard/hhkb_rn42/config.h
index a46c7a8bf0..21e73f1c53 100644
--- a/keyboard/hhkb_rn42/config.h
+++ b/keyboard/hhkb_rn42/config.h
@@ -50,6 +50,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
/* Boot Magic salt key: Space */
#define BOOTMAGIC_KEY_SALT KC_FN6
+/* power control of key switch board */
+#define HHKB_POWER_SAVING
/*
* Hardware Serial(UART)
diff --git a/keyboard/hhkb_rn42/hhkb_avr.h b/keyboard/hhkb_rn42/hhkb_avr.h
index b7bd507b5d..313effedfe 100644
--- a/keyboard/hhkb_rn42/hhkb_avr.h
+++ b/keyboard/hhkb_rn42/hhkb_avr.h
@@ -41,17 +41,31 @@ 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) {
+ _delay_ms(10); // TODO: sleep to save power
+ 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(1); // 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
+}
+#else
static inline void KEY_POWER_ON(void) {}
static inline void KEY_POWER_OFF(void) {}
+#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 +73,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)
{