Add power control of keyswitch board and tweak scan wait
This commit is contained in:
parent
d965822857
commit
0e37dd2ec5
@ -71,7 +71,7 @@ MCU = atmega32u4
|
||||
# does not *change* the processor frequency - it should merely be updated to
|
||||
# reflect the processor speed set externally so that the code can use accurate
|
||||
# software delays.
|
||||
F_CPU = 8000000
|
||||
F_CPU = 16000000
|
||||
|
||||
|
||||
#
|
||||
@ -109,7 +109,7 @@ OPT_DEFS += -DBOOTLOADER_SIZE=4096
|
||||
# Build Options
|
||||
# comment out to disable the options.
|
||||
#
|
||||
BOOTMAGIC_ENABLE = yes # Virtual DIP switch configuration
|
||||
#BOOTMAGIC_ENABLE = yes # Virtual DIP switch configuration
|
||||
MOUSEKEY_ENABLE = yes # Mouse keys
|
||||
EXTRAKEY_ENABLE = yes # Audio control and System control
|
||||
CONSOLE_ENABLE = yes # Console for debug
|
||||
|
48
keyboard/hhkb/doc/Power.txt
Normal file
48
keyboard/hhkb/doc/Power.txt
Normal file
@ -0,0 +1,48 @@
|
||||
HHKB Power consumption
|
||||
----------------------
|
||||
|
||||
**Power consumption
|
||||
board clock/prescaler keyswitch power ctrl current
|
||||
--------------------------------------------------------------------------
|
||||
tmk 16MHz no no 26.4mA
|
||||
tmk 16MHz pro1 no 45.1mA
|
||||
tmk 16MHz/2 no no 18.1mA
|
||||
tmk 16MHz/2 pro1 no 37.3mA
|
||||
tmk 8MHz no no 18.9mA
|
||||
tmk 8MHz pro2 no(w/o FET) 32.1mA
|
||||
tmk 8MHz pro2 no(w FET) 32.1mA withou POWER_ON/FF
|
||||
tmk 8MHz pro2 no(w FET) 32.6mA with POWR_ON/OFF
|
||||
tmk 8MHz pro2 15ms(w FET) 21.3mA with POWR_ON/OFF, enumerated but error -32
|
||||
tmk 8MHz pro2 60ms(w FET) 13.3mA with POWR_ON/OFF, not enumerated
|
||||
|
||||
gh60 16MHz 25.8mA
|
||||
gh60 16MHz USB suspend w LED breathing 17.6-29.1mA
|
||||
gh60 16MHz USB suspend w/o LED 0.2mA(0.231-0.276mA)
|
||||
Poker 5.6mA
|
||||
Poker USB suspend 0.3mA(0.301mA)
|
||||
gh60 16MHz stock firmware by komar 26.8mA
|
||||
|
||||
|
||||
HHKB pro2 Over All 139.4mA
|
||||
HHKB pro2 Controller 115.1mA
|
||||
HHKB pro1 Controller 25.9mA
|
||||
|
||||
|
||||
keyswitch power consumption:
|
||||
pro1: 45.1-26.4=18.7mA
|
||||
37.3-18.1=19.2mA
|
||||
pro2: 32.1-18.9=13.2mA
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
**Low Freq Crystal or Prescaler?
|
||||
No advantage of Low Freq Crystal against Prescaled.
|
||||
|
||||
Clock routing
|
||||
X'tal --+---->Prescaler-------> System Clock
|
||||
|
|
||||
+---------------------> USB PLL
|
||||
|
||||
Design Decision: Install 16MHz crystal on board with using clock rescaler.
|
@ -79,11 +79,15 @@ static matrix_row_t _matrix1[MATRIX_ROWS];
|
||||
// col: PB3-5,6
|
||||
// key: PD7(pull-uped)
|
||||
// prev: PB7
|
||||
// power: PD4(L:off/H:on)
|
||||
#define KEY_INIT() do { \
|
||||
DDRB = 0xFF; \
|
||||
PORTB = 0x00; \
|
||||
DDRD &= ~0x80; \
|
||||
PORTD |= 0x80; \
|
||||
/* keyswitch board power on */ \
|
||||
DDRD |= (1<<4); \
|
||||
PORTD |= (1<<4); \
|
||||
KEY_UNABLE(); \
|
||||
KEY_PREV_OFF(); \
|
||||
} while (0)
|
||||
@ -97,6 +101,20 @@ static matrix_row_t _matrix1[MATRIX_ROWS];
|
||||
#define KEY_PREV_OFF() (PORTB &= ~(1<<7))
|
||||
#define KEY_POWER_ON()
|
||||
#define KEY_POWER_OFF()
|
||||
/*
|
||||
#define KEY_POWER_ON() do { \
|
||||
KEY_INIT(); \
|
||||
PORTD |= (1<<4); \
|
||||
_delay_ms(1); \
|
||||
} while (0)
|
||||
#define KEY_POWER_OFF() do { \
|
||||
PORTD &= ~(1<<4); \
|
||||
DDRB &= ~0xFF; \
|
||||
PORTB &= ~0xFF; \
|
||||
DDRB &= ~0x80; \
|
||||
PORTB &= ~0x80; \
|
||||
} while (0)
|
||||
*/
|
||||
|
||||
|
||||
#elif defined(__AVR_ATmega328P__)
|
||||
@ -195,16 +213,21 @@ uint8_t matrix_scan(void)
|
||||
uint8_t last = TIMER_RAW;
|
||||
|
||||
KEY_ENABLE();
|
||||
|
||||
// Wait for KEY_STATE outputs its value.
|
||||
// 1us was ok on one HHKB, but not worked on another.
|
||||
// no wait doesn't work on Teensy++ with pro(1us works)
|
||||
// no wait does work on tmk PCB(8MHz) with pro2
|
||||
// 1us wait does work on both of above
|
||||
// 1us wait doesn't work on tmk(16MHz)
|
||||
// 5us wait does work on tmk(16MHz)
|
||||
// 5us wait does work on tmk(16MHz/2)
|
||||
// 5us wait does work on tmk(8MHz)
|
||||
// 10us wait does work on Teensy++ with pro
|
||||
// 10us wait does work on 328p+iwrap with pro
|
||||
// 10us wait doesn't work on tmk PCB(8MHz) with pro2(very lagged scan)
|
||||
_delay_us(1);
|
||||
// _delay_us(10);
|
||||
_delay_us(5);
|
||||
|
||||
if (KEY_STATE()) {
|
||||
matrix[row] &= ~(1<<col);
|
||||
} else {
|
||||
|
Loading…
Reference in New Issue
Block a user