diff options
Diffstat (limited to 'converter/usb_usb')
-rw-r--r-- | converter/usb_usb/Makefile | 20 | ||||
-rw-r--r-- | converter/usb_usb/keymap.c | 30 | ||||
-rw-r--r-- | converter/usb_usb/led.c | 24 | ||||
-rw-r--r-- | converter/usb_usb/main.cpp | 86 |
4 files changed, 65 insertions, 95 deletions
diff --git a/converter/usb_usb/Makefile b/converter/usb_usb/Makefile index d6867bb002..0f25232b25 100644 --- a/converter/usb_usb/Makefile +++ b/converter/usb_usb/Makefile @@ -27,7 +27,7 @@ # make flip-ee = Download the eeprom file to the device, using Atmel FLIP # (must have Atmel FLIP installed). # -# make debug = Start either simulavr or avarice as specified for debugging, +# make debug = Start either simulavr or avarice as specified for debugging, # with avr-gdb or avr-insight as the front end for debugging. # # make filename.s = Just compile filename.c into the assembler code only. @@ -41,7 +41,7 @@ # Target file name (without extension). TARGET = usb_usb -TOP_DIR = ../.. +TMK_DIR = ../../tmk_core # Directory keyboard dependent files exist TARGET_DIR = . @@ -93,6 +93,7 @@ OPT_DEFS += -DINTERRUPT_CONTROL_ENDPOINT MOUSEKEY_ENABLE = yes # Mouse keys EXTRAKEY_ENABLE = yes # Media control and System control CONSOLE_ENABLE = yes # Console for debug +#COMMAND_ENABLE = yes # Commands for debug and configuration #NKRO_ENABLE = yes # USB Nkey Rollover # Boot Section Size in bytes @@ -101,12 +102,15 @@ CONSOLE_ENABLE = yes # Console for debug # LUFA bootloader 4096 OPT_DEFS += -DBOOTLOADER_SIZE=4096 +#LDFLAGS += -Wl,--relax +#OPT_DEFS += -DNO_ACTION_TAPPING +#OPT_DEFS += -DNO_ACTION_LAYER +#OPT_DEFS += -DNO_ACTION_MACRO SRC = \ keymap_common.c \ matrix.c \ - led.c \ main.cpp ifdef KEYMAP @@ -121,7 +125,7 @@ CONFIG_H = config.h # Search Path VPATH += $(TARGET_DIR) -VPATH += $(TOP_DIR) +VPATH += $(TMK_DIR) @@ -130,7 +134,7 @@ PROGRAM_CMD = avrdude -p$(MCU) -cavr109 -b57600 -Uflash:w:$(TARGET).hex -P$(DEV) -include $(TOP_DIR)/protocol/usb_hid.mk -include $(TOP_DIR)/protocol/lufa.mk -include $(TOP_DIR)/common.mk -include $(TOP_DIR)/rules.mk +include $(TMK_DIR)/protocol/usb_hid.mk +include $(TMK_DIR)/protocol/lufa.mk +include $(TMK_DIR)/common.mk +include $(TMK_DIR)/rules.mk diff --git a/converter/usb_usb/keymap.c b/converter/usb_usb/keymap.c index c14a8aa553..5397de519f 100644 --- a/converter/usb_usb/keymap.c +++ b/converter/usb_usb/keymap.c @@ -19,7 +19,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { - /* 0: default + /* 0: plain Qwerty without layer switching * ,---. ,---------------. ,---------------. ,---------------. ,-----------. ,-----------. * |Esc| |F1 |F2 |F3 |F4 | |F5 |F6 |F7 |F8 | |F9 |F10|F11|F12| |PrS|ScL|Pau| |Pwr|Slp|Wak| * `---' `---------------' `---------------' `---------------' `-----------' `-----------' @@ -37,28 +37,6 @@ const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { */ KEYMAP( ESC, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, PSCR,SLCK,PAUS, - ESC, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, MINS,EQL, BSPC, INS, HOME,PGUP, NLCK,PSLS,PAST,PMNS, - TAB, Q, W, E, R, T, Y, U, I, O, P, LBRC,RBRC,BSLS, DEL, END, PGDN, P7, P8, P9, - CAPS,A, S, D, F, G, H, J, K, L, SCLN,QUOT, ENT, P4, P5, P6, PPLS, - LSFT,Z, X, C, V, B, N, M, COMM,DOT, SLSH, RSFT, UP, P1, P2, P3, - LCTL,LGUI,LALT, SPC, RALT,RGUI,APP, GRV, LEFT,DOWN,RGHT, P0, PDOT,PENT - ), - - /* 1: plain Qwerty without layer switching - * ,-----------------------------------------------------------. - * | `| 1| 2| 3| 4| 5| 6| 7| 8| 9| 0| -| =|Backspa| - * |-----------------------------------------------------------| - * |Tab | Q| W| E| R| T| Y| U| I| O| P| [| ]| \| - * |-----------------------------------------------------------| - * |CapsLo| A| S| D| F| G| H| J| K| L| ;| '|Return | - * |-----------------------------------------------------------| - * |Shift | Z| X| C| V| B| N| M| ,| ,| /|Shift | - * |-----------------------------------------------------------| - * |Ctrl |Gui |Alt | Space |Alt |Gui |Menu|Ctrl| - * `-----------------------------------------------------------' - */ - KEYMAP( - ESC, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, PSCR,SLCK,PAUS, GRV, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, MINS,EQL, BSPC, INS, HOME,PGUP, NLCK,PSLS,PAST,PMNS, TAB, Q, W, E, R, T, Y, U, I, O, P, LBRC,RBRC,BSLS, DEL, END, PGDN, P7, P8, P9, CAPS,A, S, D, F, G, H, J, K, L, SCLN,QUOT, ENT, P4, P5, P6, PPLS, @@ -66,7 +44,7 @@ const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { LCTL,LGUI,LALT, SPC, RALT,RGUI,APP, RCTL, LEFT,DOWN,RGHT, P0, PDOT,PENT ), - /* 2: Colemak http://colemak.com + /* 1: Colemak http://colemak.com * ,-----------------------------------------------------------. * | `| 1| 2| 3| 4| 5| 6| 7| 8| 9| 0| -| =|Backspa| * |-----------------------------------------------------------| @@ -88,7 +66,7 @@ const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { LCTL,LGUI,LALT, SPC, RALT,RGUI,APP, RCTL, LEFT,DOWN,RGHT, P0, PDOT,PENT ), - /* 3: Dvorak http://en.wikipedia.org/wiki/Dvorak_Simplified_Keyboard + /* 2: Dvorak http://en.wikipedia.org/wiki/Dvorak_Simplified_Keyboard * ,-----------------------------------------------------------. * | `| 1| 2| 3| 4| 5| 6| 7| 8| 9| 0| [| ]|Backspa| * |-----------------------------------------------------------| @@ -110,7 +88,7 @@ const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { LCTL,LGUI,LALT, SPC, RALT,RGUI,APP, RCTL, LEFT,DOWN,RGHT, P0, PDOT,PENT ), - /* 4: Workman http://viralintrospection.wordpress.com/2010/09/06/a-different-philosophy-in-designing-keyboard-layouts/ + /* 3: Workman http://viralintrospection.wordpress.com/2010/09/06/a-different-philosophy-in-designing-keyboard-layouts/ * ,-----------------------------------------------------------. * | `| 1| 2| 3| 4| 5| 6| 7| 8| 9| 0| -| =|Backspa| * |-----------------------------------------------------------| diff --git a/converter/usb_usb/led.c b/converter/usb_usb/led.c deleted file mode 100644 index fc0eeb0ff7..0000000000 --- a/converter/usb_usb/led.c +++ /dev/null @@ -1,24 +0,0 @@ -/* -Copyright 2012 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/>. -*/ - -#include "stdint.h" -#include "led.h" - - -void led_set(uint8_t usb_led) -{ -} diff --git a/converter/usb_usb/main.cpp b/converter/usb_usb/main.cpp index 30fd3348a3..652c805734 100644 --- a/converter/usb_usb/main.cpp +++ b/converter/usb_usb/main.cpp @@ -5,10 +5,10 @@ // USB HID host #include "Usb.h" +#include "usbhub.h" #include "hid.h" #include "hidboot.h" #include "parser.h" -#include "usbhub.h" // LUFA #include "lufa.h" @@ -17,22 +17,31 @@ #include "sendchar.h" #include "debug.h" #include "keyboard.h" +#include "led.h" + + +/* LED ping configuration */ +#define TMK_LED +//#define LEONARDO_LED +#if defined(TMK_LED) +// For TMK converter and Teensy +#define LED_TX_INIT (DDRD |= (1<<6)) +#define LED_TX_ON (PORTD |= (1<<6)) +#define LED_TX_OFF (PORTD &= ~(1<<6)) +#define LED_TX_TOGGLE (PORTD ^= (1<<6)) +#elif defined(LEONARDO_LED) +// For Leonardo(TX LED) +#define LED_TX_INIT (DDRD |= (1<<5)) +#define LED_TX_ON (PORTD &= ~(1<<5)) +#define LED_TX_OFF (PORTD |= (1<<5)) +#define LED_TX_TOGGLE (PORTD ^= (1<<5)) +#else +#define LED_TX_INIT +#define LED_TX_ON +#define LED_TX_OFF +#define LED_TX_TOGGLE +#endif -#include "leonardo_led.h" - - -static USB usb_host; -static HIDBoot<HID_PROTOCOL_KEYBOARD> kbd(&usb_host); -static KBDReportParser kbd_parser; -static USBHub hub1(&usb_host); // one hub is enough for HHKB pro2 -/* may be needed for other device with more hub -static USBHub hub2(&usb_host); -static USBHub hub3(&usb_host); -static USBHub hub4(&usb_host); -static USBHub hub5(&usb_host); -static USBHub hub6(&usb_host); -static USBHub hub7(&usb_host); -*/ static void LUFA_setup(void) { @@ -53,18 +62,24 @@ static void LUFA_setup(void) print_set_sendchar(sendchar); } -static void HID_setup() + + +/* + * USB Host Shield HID keyboard + */ +USB usb_host; +USBHub hub1(&usb_host); +HIDBoot<HID_PROTOCOL_KEYBOARD> kbd(&usb_host); +KBDReportParser kbd_parser; + + +void led_set(uint8_t usb_led) { - if (usb_host.Init() == -1) { - debug("HID init: failed\n"); - LED_TX_OFF; - } - - _delay_ms(200); - - kbd.SetReportParser(0, (HIDReportParser*)&kbd_parser); + kbd.SetReport(0, 0, 2, 0, 1, &usb_led); } + + int main(void) { // LED for debug @@ -72,35 +87,32 @@ int main(void) LED_TX_ON; debug_enable = true; -/* - debug_matrix = true; debug_keyboard = true; - debug_mouse = true; -*/ host_set_driver(&lufa_driver); keyboard_init(); LUFA_setup(); + + // USB Host Shield setup + usb_host.Init(); + kbd.SetReportParser(0, (HIDReportParser*)&kbd_parser); + + /* NOTE: Don't insert time consuming job here. + * It'll cause unclear initialization failure when DFU reset(worm start). + */ sei(); -uint8_t ret; // wait for startup of sendchar routine while (USB_DeviceState != DEVICE_STATE_Configured) ; if (debug_enable) { _delay_ms(1000); } - debug("init: start\n"); - HID_setup(); - debug("init: done\n"); uint16_t timer; -// to see loop pulse with oscillo scope -DDRF = (1<<7); for (;;) { -PORTF ^= (1<<7); keyboard_task(); timer = timer_read(); @@ -115,6 +127,6 @@ if (timer > 100) { USB_USBTask(); #endif } - + return 0; } |