diff options
Diffstat (limited to 'keyboard/hhkb')
27 files changed, 2179 insertions, 47 deletions
diff --git a/keyboard/hhkb/Makefile b/keyboard/hhkb/Makefile index 5cf02d194e..dc5c06a948 100644 --- a/keyboard/hhkb/Makefile +++ b/keyboard/hhkb/Makefile @@ -121,11 +121,6 @@ NKRO_ENABLE = yes # USB Nkey Rollover #HHKB_JP = yes # HHKB JP support -ifdef HHKB_JP - OPT_DEFS += -DHHKB_JP -endif - - # # Keymap file # @@ -140,6 +135,11 @@ else endif +ifneq (, $(or $(findstring keymap_jp.c, $(SRC)), $(findstring yes, $(HHKB_JP)))) + OPT_DEFS += -DHHKB_JP +endif + + # Search Path VPATH += $(TARGET_DIR) VPATH += $(TOP_DIR) diff --git a/keyboard/hhkb/Makefile.jp b/keyboard/hhkb/Makefile.jp new file mode 100644 index 0000000000..e04dbb2424 --- /dev/null +++ b/keyboard/hhkb/Makefile.jp @@ -0,0 +1,2 @@ +HHKB_JP = yes +include Makefile diff --git a/keyboard/hhkb/Makefile.nodebug b/keyboard/hhkb/Makefile.rn42 index 578ba70c45..b1eacd070f 100644 --- a/keyboard/hhkb/Makefile.nodebug +++ b/keyboard/hhkb/Makefile.rn42 @@ -39,7 +39,7 @@ #---------------------------------------------------------------------------- # Target file name (without extension). -TARGET = hhkb_lufa +TARGET = hhkb_rn42 # Directory common source filess exist TOP_DIR = ../.. @@ -53,19 +53,10 @@ SRC += keymap_common.c \ matrix.c \ led.c -ifdef KEYMAP - SRC := keymap_$(KEYMAP).c $(SRC) -else - SRC := keymap_hasu.c $(SRC) -endif - -CONFIG_H = config.h +CONFIG_H = config_rn42.h # MCU name -# PJRC Teensy++ 2.0 -#MCU = at90usb1286 -# TMK Alt Controller or PJRC Teensy 2.0 MCU = atmega32u4 # Processor frequency. @@ -117,19 +108,41 @@ 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 +CONSOLE_ENABLE = yes # Console for debug COMMAND_ENABLE = yes # Commands for debug and configuration -NKRO_ENABLE = yes # USB Nkey Rollover -KEYMAP_SECTION_ENABLE = yes # fixed address keymap for keymap editor +#NKRO_ENABLE = yes # USB Nkey Rollover +#KEYMAP_SECTION_ENABLE = yes # fixed address keymap for keymap editor +#HHKB_JP = yes # HHKB JP support + + +# +# Keymap file +# +ifdef KEYMAP + SRC := keymap_$(KEYMAP).c $(SRC) +else + ifdef HHKB_JP + SRC := keymap_jp.c $(SRC) + else + SRC := keymap_hhkb.c $(SRC) + endif +endif + + +ifneq (, $(or $(findstring keymap_jp.c, $(SRC)), $(findstring yes, $(HHKB_JP)))) + OPT_DEFS += -DHHKB_JP +endif # Search Path VPATH += $(TARGET_DIR) VPATH += $(TOP_DIR) +include rn42.mk +include $(TOP_DIR)/protocol.mk include $(TOP_DIR)/protocol/lufa.mk include $(TOP_DIR)/common.mk include $(TOP_DIR)/rules.mk @@ -138,4 +151,5 @@ debug-on: EXTRAFLAGS += -DDEBUG -DDEBUG_ACTION debug-on: all debug-off: EXTRAFLAGS += -DNO_DEBUG -DNO_PRINT +debug-off: OPT_DEFS := $(filter-out -DCONSOLE_ENABLE,$(OPT_DEFS)) debug-off: all diff --git a/keyboard/hhkb/README.md b/keyboard/hhkb/README.md index d4a2cd0223..fcd72e1941 100644 --- a/keyboard/hhkb/README.md +++ b/keyboard/hhkb/README.md @@ -10,11 +10,17 @@ See [this thread][AltController] in geekhack.org. [AltController]: http://geekhack.org/index.php?topic=12047.0 +## Update +* Bluetooth module RN-42 is supported.(2015/01) +* V-USB and iWRAP are no longer supported now, but still it'll works with a little fix. See not_supported directory.(2015/01) + + ##Features * Customizable keymap * More keymap layers(more Fn keys) * Mouse keys * USB NKRO +* Bluetooth(RN-42) See README of [tmk_keyboard] for more. @@ -43,12 +49,16 @@ See [doc/HHKB.txt](doc/HHKB.txt) and files under [doc/](doc/) for internal of HH See [this document](../../doc/build.md) first. ### Configuration -Set `MCU`, `BOOTLOADER_SIZE` and other build options in `Makefile` and `config.h`. If your target is **HHKB JP** you need to set `HHKB_JP` build option in `Makefile`. +If your target is **HHKB JP** you need to set `HHKB_JP` build option in `Makefile` or use `Makefile.jp` instead of `Makefile`. + +If you use other than **TMK Alt Controller Board** set proper `MCU`, `BOOTLOADER_SIZE` and other build options in `Makefile` and `config.h`. At least PJRC Teensy requires changing `BOOTLOADER_SIZE` to 512. ### Build Several version of keymap are available in advance but you are recommended to define your favorite layout yourself. Just `make` with `KEYMAP` option like: - $ make KEYMAP=[hasu|hhkb|spacefn|<name>] + $ make -f Makefile.<jp|pjrc|rn42> KEYMAP=(hasu|hhkb|spacefn|<name>) + +You can omit `-f` option when you use `Makefile`. `Makefile` is used for **Pro2 and Pro**, `Makefile.jp` fits for **JP** model and `Makefile.rn42` supports Bluetooth module **RN-42**. `Makefile.pjrc` uses **PJRC** as output protocol instead of **LUFA**. ### Program @@ -56,11 +66,11 @@ First, push reset button on board to start bootloader. This command programs the controller with [dfu-programmer] if the tool is installed and configured properly. - $ make dfu + $ make -f Makefile.<variant> KEYMAP=<name> dfu Or you can also use [FLIP] command to program. Also the tool should be installed and configured properly. FLIP GUI application is also available. - $ make flip + $ make -f Makefile.<variant> KEYMAP=<name> flip Use [Teensy Loader] if your controller is Teensy/Teensy++. diff --git a/keyboard/hhkb/config_rn42.h b/keyboard/hhkb/config_rn42.h new file mode 100644 index 0000000000..21e73f1c53 --- /dev/null +++ b/keyboard/hhkb/config_rn42.h @@ -0,0 +1,112 @@ +/* +Copyright 2011 Jun Wako <wakojun@gmail.com> + +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/>. +*/ + +#ifndef CONFIG_H +#define CONFIG_H + + +#define VENDOR_ID 0xFEED +#define PRODUCT_ID 0x4242 +#define DEVICE_VER 0x0104 +#define MANUFACTURER t.m.k. +#define PRODUCT HHKB mod +#define DESCRIPTION t.m.k. keyboard firmware for HHKB mod + + +/* matrix size */ +#ifdef HHKB_JP +# define MATRIX_ROWS 16 +#else +# define MATRIX_ROWS 8 +#endif +#define MATRIX_COLS 8 + + +/* key combination for command */ +#define IS_COMMAND() (keyboard_report->mods == (MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_RSHIFT))) + + +/* period of tapping(ms) */ +#define TAPPING_TERM 300 +/* tap count needed for toggling a feature */ +#define TAPPING_TOGGLE 5 +/* Oneshot timeout(ms) */ +#define ONESHOT_TIMEOUT 300 + +/* Boot Magic salt key: Space */ +#define BOOTMAGIC_KEY_SALT KC_FN6 + +/* power control of key switch board */ +#define HHKB_POWER_SAVING + +/* + * Hardware Serial(UART) + * Baud rate are calculated with round off(+0.5). + */ +#ifdef __AVR_ATmega32U4__ + /* iom32u4.h has no definition of UCSR1D. copy from iom32u2.h */ + #define UCSR1D _SFR_MEM8(0xCB) + #define RTSEN 0 + #define CTSEN 1 + + #define SERIAL_UART_BAUD 115200 + #define SERIAL_UART_DATA UDR1 + #define SERIAL_UART_UBRR ((F_CPU/(16.0*SERIAL_UART_BAUD)-1+0.5)) + #define SERIAL_UART_RXD_VECT USART1_RX_vect + #define SERIAL_UART_TXD_READY (UCSR1A&(1<<UDRE1)) + #define SERIAL_UART_INIT() do { \ + UBRR1L = (uint8_t) SERIAL_UART_UBRR; /* baud rate */ \ + UBRR1H = ((uint16_t)SERIAL_UART_UBRR>>8); /* baud rate */ \ + UCSR1B |= (1<<RXCIE1) | (1<<RXEN1); /* RX interrupt, RX: enable */ \ + UCSR1B |= (0<<TXCIE1) | (1<<TXEN1); /* TX interrupt, TX: enable */ \ + UCSR1C |= (0<<UPM11) | (0<<UPM10); /* parity: none(00), even(01), odd(11) */ \ + UCSR1D |= (0<<RTSEN) | (0<<CTSEN); /* RTS, CTS(no flow control by hardware) */ \ + DDRD |= (1<<5); PORTD &= ~(1<<5); /* RTS for flow control by firmware */ \ + sei(); \ + } while(0) + #define SERIAL_UART_RTS_LO() do { PORTD &= ~(1<<5); } while (0) + #define SERIAL_UART_RTS_HI() do { PORTD |= (1<<5); } while (0) +#else + #error "USART configuration is needed." +#endif + + +/* for debug */ +#define SUART_OUT_PORT PORTD +#define SUART_OUT_BIT 0 +#define SUART_IN_PIN PIND +#define SUART_IN_BIT 1 + + +/* + * Feature disable options + * These options are also useful to firmware size reduction. + */ +/* disable debug print */ +//#define NO_DEBUG + +/* disable print */ +//#define NO_PRINT + +/* disable action features */ +//#define NO_ACTION_LAYER +//#define NO_ACTION_TAPPING +//#define NO_ACTION_ONESHOT +//#define NO_ACTION_MACRO +//#define NO_ACTION_FUNCTION + +#endif 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 diff --git a/keyboard/hhkb/keymap_hasu.c b/keyboard/hhkb/keymap_hasu.c index 8379c84f52..433f9cb270 100644 --- a/keyboard/hhkb/keymap_hasu.c +++ b/keyboard/hhkb/keymap_hasu.c @@ -27,7 +27,7 @@ const uint8_t keymaps[][MATRIX_ROWS][MATRIX_COLS] PROGMEM = { TAB, Q, W, E, R, T, Y, U, I, O, P, LBRC,RBRC,BSPC, \ LCTL,A, S, D, F, G, H, J, K, L, FN3, QUOT,FN6, \ FN7, Z, X, C, V, B, N, M, COMM,DOT, FN2, RSFT,FN1, \ - LGUI,LALT, FN4, FN5, FN5), + LGUI,LALT, FN4, FN5, RGUI), /* Layer 1: HHKB mode[HHKB Fn] * ,-----------------------------------------------------------. @@ -47,7 +47,7 @@ const uint8_t keymaps[][MATRIX_ROWS][MATRIX_COLS] PROGMEM = { CAPS,NO, NO, NO, NO, NO, NO, NO, PSCR,SLCK,PAUS, UP, NO, BSPC, \ LCTL,VOLD,VOLU,MUTE,NO, NO, PAST,PSLS,HOME,PGUP,LEFT,RGHT,ENT, \ LSFT,NO, NO, NO, NO, NO, PPLS,PMNS,END, PGDN,DOWN,RSFT,TRNS, \ - LGUI,LALT, SPC, RALT,RGUI), + LGUI,LALT, TRNS, RALT,RGUI), /* Layer 2: Vi mode[Slash] * ,-----------------------------------------------------------. @@ -66,7 +66,7 @@ const uint8_t keymaps[][MATRIX_ROWS][MATRIX_COLS] PROGMEM = { KEYMAP(GRV, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, INS, DEL, \ TAB, HOME,PGDN,UP, PGUP,END, HOME,PGDN,PGUP,END, NO, NO, NO, BSPC, \ LCTL,NO, LEFT,DOWN,RGHT,NO, LEFT,DOWN,UP, RGHT,NO, NO, ENT, \ - LSFT,NO, NO, NO, NO, NO, HOME,PGDN,PGUP,END, TRNS,RSFT,NO, \ + LSFT,NO, NO, NO, NO, NO, HOME,PGDN,PGUP,END, FN2, RSFT,TRNS, \ LGUI,LALT, SPC, RALT,RGUI), /* Layer 3: Mouse mode(IJKL)[Semicolon] @@ -81,16 +81,16 @@ const uint8_t keymaps[][MATRIX_ROWS][MATRIX_COLS] PROGMEM = { * `-----------------------------------------------------------' * |Gui |Alt | Mb1 |Fn |Fn | * `--------------------------------------------' - * Mc: Mouse Cursor / Mb: Mouse Button / Mw: Mouse Wheel8 + * Mc: Mouse Cursor / Mb: Mouse Button / Mw: Mouse Wheel */ [3] = \ KEYMAP(GRV, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, INS, DEL, \ - FN8, NO, NO, NO, NO, NO, WH_L,WH_D,MS_U,WH_U,WH_R,WBAK,WFWD,FN8, \ - LCTL,ACL0,ACL1,ACL2,ACL2,NO, NO, MS_L,MS_D,MS_R,TRNS,NO, ENT, \ - LSFT,NO, NO, NO, NO, BTN3,BTN2,BTN1,BTN4,BTN5,NO, RSFT,NO, \ + FN8, NO, NO, NO, NO, NO, NO, WH_D,MS_U,WH_U,RGHT,FN9, FN10,FN8, \ + LCTL,ACL0,ACL1,ACL2,ACL2,NO, NO, MS_L,MS_D,MS_R,FN3, NO, ENT, \ + LSFT,NO, NO, NO, NO, BTN3,BTN2,BTN1,FN9, FN10,NO, RSFT,TRNS, \ LGUI,LALT, BTN1, TRNS,TRNS), - /* Layer 5: Mouse mode(IJKL)[Space] + /* Layer 4: Mouse mode(IJKL)[Space] * ,-----------------------------------------------------------. * |Esc| F1| F2| F3| F4| F5| F6| F7| F8| F9|F10|F11|F12|Ins|Del| * |-----------------------------------------------------------| @@ -102,13 +102,13 @@ const uint8_t keymaps[][MATRIX_ROWS][MATRIX_COLS] PROGMEM = { * `-----------------------------------------------------------' * |Gui |Alt | Mb1 |Fn |Fn | * `--------------------------------------------' - * Mc: Mouse Cursor / Mb: Mouse Button / Mw: Mouse Wheel8 + * Mc: Mouse Cursor / Mb: Mouse Button / Mw: Mouse Wheel */ [4] = \ KEYMAP(GRV, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, INS, DEL, \ - FN8, NO, NO, NO, NO, NO, WH_L,WH_D,MS_U,WH_U,WH_R,WBAK,WFWD,FN8, \ + FN8, NO, NO, NO, NO, NO, NO, WH_D,MS_U,WH_U,RGHT,FN9, FN10,FN8, \ LCTL,VOLD,VOLU,MUTE,NO, NO, NO, MS_L,MS_D,MS_R,BTN1,NO, ENT, \ - LSFT,NO, NO, NO, NO, BTN3,BTN2,BTN1,BTN4,BTN5,NO, RSFT,NO, \ + LSFT,NO, NO, NO, NO, BTN3,BTN2,BTN1,FN9, FN10,NO, RSFT,TRNS, \ LGUI,LALT, TRNS, TRNS,TRNS), #if 0 @@ -127,9 +127,9 @@ const uint8_t keymaps[][MATRIX_ROWS][MATRIX_COLS] PROGMEM = { * Mc: Mouse Cursor / Mb: Mouse Button / Mw: Mouse Wheel */ KEYMAP(GRV, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, INS, DEL, \ - TAB, NO, NO, NO, NO, NO, WH_L,WH_D,WH_U,WH_R,NO, NO, NO, BSPC, \ + TAB, NO, NO, NO, NO, NO, NO, WH_D,WH_U,RGHT,NO, NO, NO, BSPC, \ LCTL,NO, ACL0,ACL1,ACL2,NO, MS_L,MS_D,MS_U,MS_R,TRNS,QUOT,ENT, \ - LSFT,NO, NO, NO, NO, BTN3,BTN2,BTN1,BTN4,BTN5,SLSH,RSFT,NO, \ + LSFT,NO, NO, NO, NO, BTN3,BTN2,BTN1,FN9, FN10,SLSH,RSFT,NO, \ LGUI,LALT, BTN1, RALT,TRNS), /* Layer4: Mouse mode(HJKL)[Space] @@ -147,9 +147,9 @@ const uint8_t keymaps[][MATRIX_ROWS][MATRIX_COLS] PROGMEM = { * Mc: Mouse Cursor / Mb: Mouse Button / Mw: Mouse Wheel */ KEYMAP(GRV, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, INS, DEL, \ - FN8, NO, NO, NO, NO, NO, WH_L,WH_D,WH_U,WH_R,NO, WBAK,WFWD,FN8, \ + FN8, NO, NO, NO, NO, NO, NO, WH_D,WH_U,RGHT,NO, FN9, FN10,FN8, \ LCTL,NO, ACL0,ACL1,ACL2,NO, MS_L,MS_D,MS_U,MS_R,BTN1,NO, ENT, \ - LSFT,NO, NO, NO, NO, BTN3,BTN2,BTN1,BTN4,BTN5,NO, RSFT,NO, \ + LSFT,NO, NO, NO, NO, BTN3,BTN2,BTN1,FN9, FN10,NO, RSFT,NO, \ LGUI,LALT, TRNS, RALT,RGUI), #endif #if 0 @@ -201,10 +201,12 @@ const uint16_t fn_actions[] PROGMEM = { [2] = ACTION_LAYER_TAP_KEY(2, KC_SLASH), // Cursor layer with Slash* [3] = ACTION_LAYER_TAP_KEY(3, KC_SCLN), // Mousekey layer with Semicolon* [4] = ACTION_LAYER_TAP_KEY(4, KC_SPC), // Mousekey layer with Space - [5] = ACTION_LAYER_MOMENTARY(3), // Mousekey layer + [5] = ACTION_LAYER_MOMENTARY(4), // Mousekey layer(IJKL) [6] = ACTION_MODS_TAP_KEY(MOD_RCTL, KC_ENT), // RControl with tap Enter [7] = ACTION_MODS_ONESHOT(MOD_LSFT), // Oneshot Shift [8] = ACTION_MACRO(ALT_TAB), // Application switching + [9] = ACTION_MODS_KEY(MOD_LALT, KC_LEFT), + [10] = ACTION_MODS_KEY(MOD_LALT, KC_RIGHT), // [x] = ACTION_LMOD_TAP_KEY(KC_LCTL, KC_BSPC), // LControl with tap Backspace // [x] = ACTION_LMOD_TAP_KEY(KC_LCTL, KC_ESC), // LControl with tap Esc diff --git a/keyboard/hhkb/matrix.c b/keyboard/hhkb/matrix.c index b0af4baa52..fb96997944 100644 --- a/keyboard/hhkb/matrix.c +++ b/keyboard/hhkb/matrix.c @@ -27,8 +27,15 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. #include "timer.h" #include "matrix.h" #include "hhkb_avr.h" +#include <avr/wdt.h> +#include "suspend.h" +#include "lufa.h" +// matrix power saving +#define MATRIX_POWER_SAVE 10000 +static uint32_t matrix_last_modified = 0; + // matrix state buffer(1:on, 0:off) static matrix_row_t *matrix; static matrix_row_t *matrix_prev; @@ -72,7 +79,8 @@ uint8_t matrix_scan(void) matrix_prev = matrix; matrix = tmp; - KEY_POWER_ON(); + // power on + if (!KEY_POWER_STATE()) KEY_POWER_ON(); for (uint8_t row = 0; row < MATRIX_ROWS; row++) { for (uint8_t col = 0; col < MATRIX_COLS; col++) { KEY_SELECT(row, col); @@ -126,8 +134,16 @@ uint8_t matrix_scan(void) // This takes 25us or more to make sure KEY_STATE returns to idle state. _delay_us(75); } + if (matrix[row] ^ matrix_prev[row]) matrix_last_modified = timer_read32(); + } + // power off + if (KEY_POWER_STATE() && + (USB_DeviceState == DEVICE_STATE_Suspended || + USB_DeviceState == DEVICE_STATE_Unattached ) && + timer_elapsed32(matrix_last_modified) > MATRIX_POWER_SAVE) { + KEY_POWER_OFF(); + suspend_power_down(); } - KEY_POWER_OFF(); return 1; } @@ -165,3 +181,10 @@ void matrix_print(void) xprintf("%02X: %08b\n", row, bitrev(matrix_get_row(row))); } } + +void matrix_power_up(void) { + KEY_POWER_ON(); +} +void matrix_power_down(void) { + KEY_POWER_OFF(); +} diff --git a/keyboard/hhkb/Makefile.iwrap b/keyboard/hhkb/not_supported/Makefile.iwrap index 2d9d82c481..2d9d82c481 100644 --- a/keyboard/hhkb/Makefile.iwrap +++ b/keyboard/hhkb/not_supported/Makefile.iwrap diff --git a/keyboard/hhkb/Makefile.vusb b/keyboard/hhkb/not_supported/Makefile.vusb index 4343b210d9..4343b210d9 100644 --- a/keyboard/hhkb/Makefile.vusb +++ b/keyboard/hhkb/not_supported/Makefile.vusb diff --git a/keyboard/hhkb/config_iwrap.h b/keyboard/hhkb/not_supported/config_iwrap.h index 747c755132..747c755132 100644 --- a/keyboard/hhkb/config_iwrap.h +++ b/keyboard/hhkb/not_supported/config_iwrap.h diff --git a/keyboard/hhkb/config_vusb.h b/keyboard/hhkb/not_supported/config_vusb.h index 44f7acd6cd..44f7acd6cd 100644 --- a/keyboard/hhkb/config_vusb.h +++ b/keyboard/hhkb/not_supported/config_vusb.h diff --git a/keyboard/hhkb/iwrap.txt b/keyboard/hhkb/not_supported/iwrap.txt index 20a2420a0b..20a2420a0b 100644 --- a/keyboard/hhkb/iwrap.txt +++ b/keyboard/hhkb/not_supported/iwrap.txt diff --git a/keyboard/hhkb/usbconfig.h b/keyboard/hhkb/not_supported/usbconfig.h index c3aad34bef..c3aad34bef 100644 --- a/keyboard/hhkb/usbconfig.h +++ b/keyboard/hhkb/not_supported/usbconfig.h diff --git a/keyboard/hhkb/rn42.mk b/keyboard/hhkb/rn42.mk new file mode 100644 index 0000000000..fd6f7db1a8 --- /dev/null +++ b/keyboard/hhkb/rn42.mk @@ -0,0 +1,12 @@ +RN42_DIR = rn42 + +SRC += serial_uart.c \ + rn42/suart.S \ + rn42/rn42.c \ + rn42/rn42_task.c \ + rn42/battery.c \ + rn42/main.c + +OPT_DEFS += -DPROTOCOL_RN42 + +VPATH += $(RN42_DIR) diff --git a/keyboard/hhkb/rn42/MEMO.txt b/keyboard/hhkb/rn42/MEMO.txt new file mode 100644 index 0000000000..0363c2f433 --- /dev/null +++ b/keyboard/hhkb/rn42/MEMO.txt @@ -0,0 +1,255 @@ +Memo of deveopment +================== +just memo, NOT WORTH READING + +Bug: +- Factory Reset PIO4 doesn't work + - the reason is unclear - 12/08 NOT LOOK INTO ANY MORE + - WORKAROUND: use serial pins(3.3V, GND, RX and TX) + - SF,1 and R,1 to set factory defalult + + +Todo: +- LED cover and switch knob and new Slide Switch +- RN42 auto configuration + - configure the module as HID device every time powering up + - this'll reduce work load of assembly + +- move rn42 to protocol directory when it becomes reusable stack + +- sendchar() in lufa.c no buffer + - no buffering. character lost can be caused. +- LUFA sendchar should be buffered and serial_uart.c buffur size is too large(256). + +- BT operations + - disconnect + - new connection + - remove connection + +- sendchar() in lufa.c block loop - DONE 11/29 + - block loop when powered with AC adapter + - FrameNumber is not updated when adapter powered + +Improving: +- ADC resolution + AVR120 + AVR32138 + - Enhancing ADC resolution by oversampling + AVR121 http://www.atmel.com/images/doc8003.pdf + - disable digital input buffer DIDR(7.8.6) + +Design: +- suspend.h - DONE 11/26 + - remove argument from suspend_power_down() for backward compatitibility +- remove MCU dependent power saving code from core/keyboard - DONE 11/23 + - it should be located in project matrix.c +- HHKB matrix.c needs matrix_prev? + - is_modified() is obsolete now. really needs? +- ADC: removing AREF capacitor C10 + - seems to be better while usb powered + - still bad while battery powered + http://electronics.stackexchange.com/questions/105849/avcc-and-capacitor-using-adc +- ADC: smaller resistors for voltage dividor + - 1K + 1K: not improved. - 11/27 + + +LUFA: +USB connection check: state of USB deivce +- USB_DeviceState: + USB_Deivce_State_t { Unattached, Powered, Default, Addressed, Configured*, Suspended* } + Unattached: unpluged + Powered: pluged with power adapter + Default: enumerate process bigin + Addressed: addressed + Configured: enumerated + Suspended: suspended + +- USB_IsInitialized: state of LUFA core setup + becomes true in USB_Init() USBController_AVR8.c + becomes false in USB_Disable() USBController_AVR8.c +- USB_VBUS_GetStatus(): state of VBUS(power/connection) +- USB_Disable() detaches, disables all interrupts, controller, PLL, regulater. + +- When connect to power adapter + - event happened: CW or CSW or C or DDC + - USB state: not configured + +- USB evnets + - USB connect: CSWRWRW + - USB connect but fail to enumeration: CWRWRWRWS + - USB disconnect: D + - Power adapter connect: CW, CSW, C + - Power adapter disconnect: D + + +Power saving: +- Pro2 current consumption + - active: 138.2mA(no device on Hub) + - suspended: 30.9mA(WakeUp enabled DIPSW6) + - suspended: 0mA->46.0mA(WakeUp disabled DIPSW6) +- Pro current consumption + - active: 54.0mA + - suspended: 40.5mA(WakeUp enabled DIPSW6) + - suspended: 0.3mA(WakeUp disabled DIPSW6) + +- RN42 3.3V + - disconnected(Idle): 5mA (config mode) + - connected(Active): + SW,0000: 23-26mA + SW,0010: 27-29mA worse than 0000 for unknown reason + SW,0020: 17-19mA mouse NG + SW,0030: 13-16mA laggy mouse NG + SW,0050: 10-13mA laggy mouse NG + +- matrix power saving + - power saving while externally powered and not while unpluged +- confirm suspend mode lufa.c: matrix_power_*, suspend_wakeup_condition +- 8MHz clock +- When not connected in a few minutes get into deep sleep to save battery life +- CTS is needed for waking up from deep sleep? How deep sleep is activated? +- firmware controlled 3.3V DC converter to switch on/off BT module +- sleep MCU and BT module(keyboard is not used) +- deep sleep MCU and BT module(keyboard is not used for long time) +- deep sleep MCU and turn off BT module(keyboard is not used and not connected) +- Battery ADC; switching, high resistance + - switching gnd end of divider with PF4 + - high resistor 100K/1M? + capacitor 10nF + http://www.eevblog.com/forum/beginners/measuring-battery-voltage-without-consuming-current/ +- During USB suspend change clock source to internal RC from external Xtal(6.8) +- FRZCLK: you can freeze clock for power saving. still WAKEUPI and VBUSTI interrupts are available while freezing.(21.7.3) +- Suspend: Clear Suspend Bit, Freeze clock, disable PLL, MCU sleep(21.13) +- Voltage reference(8.1.1) + - to reduce power consumption while power down mode +- unset ADEN before sleep(24.7) + + + + + + + +Lipo +---- +850mA lasts around 9 hours(07/28) + +Sparkfun Polymer Lithium Ion Battery 850mAh: +https://www.sparkfun.com/products/341 +Lipo Cell spec: +https://www.sparkfun.com/datasheets/Batteries/063048%20Li-polymer.pdf +Protection spec: +http://dlnmh9ip6v2uc.cloudfront.net/datasheets/Prototyping/BatteryProtection.pdf + min typical max + over-charge 4.255 4.280 4.305 + over-charge discover? 4.030 4.080 4.130 + over-discharge 2.827 2.900 2.973 + over-discharge discover 3.022 3.100 3.178 + +ADC voltage monitor: voltage divider 10K+10K(0.5) + ADC=V*0.5/2.56*1024 + + V ADC + ------------------ + 4.20 0x347(839) + 3.10 0x26b(619) + + + + +TROUBLE SHOOT +------------- +07/16 After fix of voltage dividor on GPIO6, had a trouble that it could not send a char to BT module, though could receive. + Found R8 had wrong 1K resistor and changed to 10K, after that it can send to the module again. Not sure how it had sent with the wrong 1K before. + +07/18 On Linux, had an USB related trouble; keyboard or console didn't work for some reason. Changing PID cured this problem. Very annoying, took very long time before resolved it. + +12/07 rn42_rts() read 1 every time. R12 broke in open mode(no coductive), idk why, too much heat with soldering? and PF1 pin was not soldered. + It resolved with resoldering PF1 and new resistor on R12. + + + + +Done: +- low battery alert(solid light) 09/04 +- *** Rev.E BT test *** - DONE + - with MCP73832, new Schottky, tantalum caps - DONE 12/07 + * MCP73832 doesn't leak from Vcc pin when unpluged and battery powered + 34mV vs 2.07V(MCP73831) at Vcc pin + MCP73832 doesn't need revese protection diode D5 + * PMEG2010ER is very low VF while reverse current/voltage is high + VF=0.96 vs 1.98(RB160M-30TR)with Fluke 175 + Anode of D11 is 680mV vs 20mV(RB160M-30TR) + 780mV is still low < 1.4V VBUS plugin detection(21.11) + this doesn't cause false VBUS detect + and 780mV on MCP73832 Vcc pin is also no problem. + D5 can be removed. + - ADC divider switching - DONE 12/07 + * Drain and Source of Q4 Pch was reversed wrongly on Rev.E. + + - reverse current from Lipo charger - DONE 12/07 + * MCP73832 has no recverse current from Vcc pin unlike MCP73831 + + +- Rev.F design - DONE + - current measure point - DONE 12/08 + - change value of cap 68->47 - DONE 12/08 + - PPTC land pattern: no solder jumper, use 0Ohm resistor instead - CANCEL 12/08 + - Q4 Pch FET: wrong Drain and Source - DONE 12/08 + - D5 can be removed. - DONE 12/08 + + + +- BT_INDICATOR LED turns on wrongly when touching line or pin. -- pull-up enabled on PF6/GPIO2 08/30 +- Lipo charger configuration: fast charge time: USB charger spec? -- used 2kohm +- use LED of charger to alarm low battery. LED should be powered directly from Lipo? - cancel; powered from VUSB +- Use RTS in serial_uart.c to resolve missing chars from help message of RN-42 - done +- CTS/RTS lines are needed? just connect in loop back if no flow control is needed. - done +- add IO pin to charger status CHRG; LED control(low) and detect charge status(input HiZ) 07.24 +- LINKED: add trace on PIO2 to PF6 07.24 +- Lipo voltage ADC sensing +- Lipo charger MCP73831: needs capacitor 4.7uF *2 +- USB connection check - 07.01 +- BT on/off check: whether RX line is pulled up? - checking RTS 07.01 +- USB/BT switching BT is on -> BT, BT is off -> USB - 07.01 +- Under voltage lock out UVLO for protection of Lipo - Lipo has discharge protection at 3.100V 07.01 |