diff options
| author | tmk <nobody@nowhere> | 2013-03-11 15:35:55 +0900 |
|---|---|---|
| committer | tmk <nobody@nowhere> | 2013-03-11 15:35:55 +0900 |
| commit | 48433a5e9988647a737234c11dd9db4080fd4a4e (patch) | |
| tree | 4af03a20658cb7e6cd43f9c65dfa002f1b544332 | |
| parent | 5d6b848a157a2e94859949961297d40da6a77527 (diff) | |
| parent | ef8439bddb2d7fe5fd95faf2b6bebd8235acf160 (diff) | |
| download | qmk_firmware-48433a5e9988647a737234c11dd9db4080fd4a4e.tar.gz qmk_firmware-48433a5e9988647a737234c11dd9db4080fd4a4e.zip | |
Merge branch 'eeprom_config'
| -rw-r--r-- | common.mk | 6 | ||||
| -rw-r--r-- | common/bootloader.c | 116 | ||||
| -rw-r--r-- | common/bootmagic.c | 67 | ||||
| -rw-r--r-- | common/bootmagic.h | 75 | ||||
| -rw-r--r-- | common/command.c | 43 | ||||
| -rw-r--r-- | common/eeconfig.c | 38 | ||||
| -rw-r--r-- | common/eeconfig.h | 85 | ||||
| -rw-r--r-- | common/keyboard.c | 39 | ||||
| -rw-r--r-- | common/keymap.c | 86 | ||||
| -rw-r--r-- | common/keymap.h | 21 | ||||
| -rw-r--r-- | common/report.h | 2 | ||||
| -rw-r--r-- | converter/pc98_usb/config.h | 3 | ||||
| -rw-r--r-- | converter/sun_usb/config.h | 14 | ||||
| -rw-r--r-- | keyboard/gh60/Makefile.lufa | 21 | ||||
| -rw-r--r-- | keyboard/gh60/Makefile.pjrc | 22 | ||||
| -rw-r--r-- | keyboard/gh60/config.h | 19 | ||||
| -rw-r--r-- | keyboard/gh60/keymap.c | 6 | ||||
| -rw-r--r-- | keyboard/gh60/matrix.c | 2 | ||||
| -rw-r--r-- | keyboard/hhkb/Makefile.lufa | 7 | ||||
| -rw-r--r-- | keyboard/hhkb/config.h | 13 | ||||
| -rw-r--r-- | keyboard/hhkb/config_iwrap.h | 13 | ||||
| -rw-r--r-- | protocol/iwrap.mk | 2 | ||||
| -rw-r--r-- | protocol/iwrap/main.c | 14 | ||||
| -rw-r--r-- | protocol/lufa.mk | 4 | ||||
| -rw-r--r-- | protocol/pjrc.mk | 5 | ||||
| -rw-r--r-- | protocol/vusb.mk | 2 |
26 files changed, 563 insertions, 162 deletions
| @@ -14,6 +14,12 @@ SRC += $(COMMON_DIR)/host.c \ | |||
| 14 | 14 | ||
| 15 | 15 | ||
| 16 | # Option modules | 16 | # Option modules |
| 17 | ifdef BOOTMAGIC_ENABLE | ||
| 18 | SRC += $(COMMON_DIR)/bootmagic.c | ||
| 19 | SRC += $(COMMON_DIR)/eeconfig.c | ||
| 20 | OPT_DEFS += -DBOOTMAGIC_ENABLE | ||
| 21 | endif | ||
| 22 | |||
| 17 | ifdef MOUSEKEY_ENABLE | 23 | ifdef MOUSEKEY_ENABLE |
| 18 | SRC += $(COMMON_DIR)/mousekey.c | 24 | SRC += $(COMMON_DIR)/mousekey.c |
| 19 | OPT_DEFS += -DMOUSEKEY_ENABLE | 25 | OPT_DEFS += -DMOUSEKEY_ENABLE |
diff --git a/common/bootloader.c b/common/bootloader.c index 6e04efbbd..43a7e47ce 100644 --- a/common/bootloader.c +++ b/common/bootloader.c | |||
| @@ -1,45 +1,106 @@ | |||
| 1 | #include <stdint.h> | ||
| 2 | #include <stdbool.h> | ||
| 1 | #include <avr/io.h> | 3 | #include <avr/io.h> |
| 2 | #include <avr/interrupt.h> | 4 | #include <avr/interrupt.h> |
| 5 | #include <avr/wdt.h> | ||
| 3 | #include <util/delay.h> | 6 | #include <util/delay.h> |
| 4 | #include "bootloader.h" | 7 | #include "bootloader.h" |
| 5 | 8 | ||
| 6 | /* Start Bootloader from Application | 9 | #ifdef PROTOCOL_LUFA |
| 7 | * See | 10 | #include <LUFA/Drivers/USB/USB.h> |
| 8 | * http://www.pjrc.com/teensy/jump_to_bootloader.html | 11 | #endif |
| 9 | * http://www.fourwalledcubicle.com/files/LUFA/Doc/120219/html/_page__software_bootloader_start.html | 12 | |
| 13 | |||
| 14 | /* Boot Section Size in *BYTEs* | ||
| 15 | * Teensy halfKay 512 | ||
| 16 | * Teensy++ halfKay 1024 | ||
| 17 | * Atmel DFU loader 4096 | ||
| 18 | * LUFA bootloader 4096 | ||
| 19 | * USBaspLoader 2048 | ||
| 10 | */ | 20 | */ |
| 21 | #ifndef BOOTLOADER_SIZE | ||
| 22 | #warning To use bootloader_jump() you need to define BOOTLOADER_SIZE in config.h. | ||
| 23 | #define BOOTLOADER_SIZE 4096 | ||
| 24 | #endif | ||
| 11 | 25 | ||
| 12 | // TODO: support usbasp | 26 | #define FLASH_SIZE (FLASHEND + 1L) |
| 13 | /* Boot Section Size in bytes | 27 | #define BOOTLOADER_START (FLASH_SIZE - BOOTLOADER_SIZE) |
| 14 | * Teensy halfKay 512 | 28 | |
| 15 | * Atmel DFU loader 4096 | 29 | |
| 16 | * LUFA bootloader 4096 | 30 | /* |
| 31 | * Entering the Bootloader via Software | ||
| 32 | * http://www.fourwalledcubicle.com/files/LUFA/Doc/120730/html/_page__software_bootloader_start.html | ||
| 17 | */ | 33 | */ |
| 18 | #ifndef BOOT_SIZE | 34 | #define BOOTLOADER_RESET_KEY 0xB007B007 |
| 19 | #define BOOT_SIZE 512 | 35 | uint32_t reset_key __attribute__ ((section (".noinit"))); |
| 36 | |||
| 37 | /* initialize MCU status by watchdog reset */ | ||
| 38 | void bootloader_jump(void) { | ||
| 39 | #ifdef PROTOCOL_LUFA | ||
| 40 | USB_Disable(); | ||
| 41 | cli(); | ||
| 42 | _delay_ms(2000); | ||
| 43 | #endif | ||
| 44 | |||
| 45 | #ifdef PROTOCOL_PJRC | ||
| 46 | cli(); | ||
| 47 | UDCON = 1; | ||
| 48 | USBCON = (1<<FRZCLK); | ||
| 49 | UCSR1B = 0; | ||
| 50 | _delay_ms(5); | ||
| 20 | #endif | 51 | #endif |
| 21 | 52 | ||
| 22 | #define FLASH_SIZE (FLASHEND + 1) | 53 | // watchdog reset |
| 23 | #define BOOTLOADER_START (FLASHEND - BOOT_SIZE) | 54 | reset_key = BOOTLOADER_RESET_KEY; |
| 55 | wdt_enable(WDTO_250MS); | ||
| 56 | for (;;); | ||
| 57 | } | ||
| 24 | 58 | ||
| 59 | |||
| 60 | /* this runs before main() */ | ||
| 61 | void bootloader_jump_after_watchdog_reset(void) __attribute__ ((used, naked, section (".init3"))); | ||
| 62 | void bootloader_jump_after_watchdog_reset(void) | ||
| 63 | { | ||
| 64 | if ((MCUSR & (1<<WDRF)) && reset_key == BOOTLOADER_RESET_KEY) { | ||
| 65 | reset_key = 0; | ||
| 66 | |||
| 67 | // My custom USBasploader requires this to come up. | ||
| 68 | MCUSR = 0; | ||
| 69 | |||
| 70 | // Seems like Teensy halfkay loader requires clearing WDRF and disabling watchdog. | ||
| 71 | MCUSR &= ~(1<<WDRF); | ||
| 72 | wdt_disable(); | ||
| 73 | |||
| 74 | ((void (*)(void))BOOTLOADER_START)(); | ||
| 75 | } | ||
| 76 | } | ||
| 77 | |||
| 78 | |||
| 79 | #if 0 | ||
| 80 | /* Jumping To The Bootloader | ||
| 81 | * http://www.pjrc.com/teensy/jump_to_bootloader.html | ||
| 82 | * | ||
| 83 | * This method doen't work when using LUFA. idk why. | ||
| 84 | * - needs to initialize more regisers or interrupt setting? | ||
| 85 | */ | ||
| 25 | void bootloader_jump(void) { | 86 | void bootloader_jump(void) { |
| 87 | #ifdef PROTOCOL_LUFA | ||
| 88 | USB_Disable(); | ||
| 26 | cli(); | 89 | cli(); |
| 90 | _delay_ms(2000); | ||
| 91 | #endif | ||
| 27 | 92 | ||
| 28 | // | 93 | #ifdef PROTOCOL_PJRC |
| 29 | //Teensy | 94 | cli(); |
| 30 | // | ||
| 31 | #if defined(__AVR_AT90USB162__) || defined(__AVR_ATmega32U4__) || defined(__AVR_AT90USB646__) || defined(__AVR_AT90USB1286__) | ||
| 32 | // disable watchdog, if enabled | ||
| 33 | // disable all peripherals | ||
| 34 | UDCON = 1; | 95 | UDCON = 1; |
| 35 | USBCON = (1<<FRZCLK); // disable USB | 96 | USBCON = (1<<FRZCLK); |
| 36 | UCSR1B = 0; | 97 | UCSR1B = 0; |
| 37 | _delay_ms(5); | 98 | _delay_ms(5); |
| 38 | #else | ||
| 39 | // This makes custom USBasploader come up. | ||
| 40 | MCUSR = 0; | ||
| 41 | #endif | 99 | #endif |
| 42 | 100 | ||
| 101 | /* | ||
| 102 | * Initialize | ||
| 103 | */ | ||
| 43 | #if defined(__AVR_AT90USB162__) | 104 | #if defined(__AVR_AT90USB162__) |
| 44 | EIMSK = 0; PCICR = 0; SPCR = 0; ACSR = 0; EECR = 0; | 105 | EIMSK = 0; PCICR = 0; SPCR = 0; ACSR = 0; EECR = 0; |
| 45 | TIMSK0 = 0; TIMSK1 = 0; UCSR1B = 0; | 106 | TIMSK0 = 0; TIMSK1 = 0; UCSR1B = 0; |
| @@ -62,10 +123,9 @@ void bootloader_jump(void) { | |||
| 62 | PORTA = 0; PORTB = 0; PORTC = 0; PORTD = 0; PORTE = 0; PORTF = 0; | 123 | PORTA = 0; PORTB = 0; PORTC = 0; PORTD = 0; PORTE = 0; PORTF = 0; |
| 63 | #endif | 124 | #endif |
| 64 | 125 | ||
| 65 | 126 | /* | |
| 66 | // | 127 | * USBaspLoader |
| 67 | //USBasp | 128 | */ |
| 68 | // | ||
| 69 | #if defined(__AVR_ATmega168__) || defined(__AVR_ATmega168P__) || defined(__AVR_ATmega328P__) | 129 | #if defined(__AVR_ATmega168__) || defined(__AVR_ATmega168P__) || defined(__AVR_ATmega328P__) |
| 70 | // This makes custom USBasploader come up. | 130 | // This makes custom USBasploader come up. |
| 71 | MCUSR = 0; | 131 | MCUSR = 0; |
| @@ -81,7 +141,7 @@ void bootloader_jump(void) { | |||
| 81 | ADCSRA = 0; TWCR = 0; UCSR0B = 0; | 141 | ADCSRA = 0; TWCR = 0; UCSR0B = 0; |
| 82 | #endif | 142 | #endif |
| 83 | 143 | ||
| 84 | |||
| 85 | // start Bootloader | 144 | // start Bootloader |
| 86 | ((void (*)(void))BOOTLOADER_START)(); | 145 | ((void (*)(void))BOOTLOADER_START)(); |
| 87 | } | 146 | } |
| 147 | #endif | ||
diff --git a/common/bootmagic.c b/common/bootmagic.c new file mode 100644 index 000000000..388099e2e --- /dev/null +++ b/common/bootmagic.c | |||
| @@ -0,0 +1,67 @@ | |||
| 1 | #include <stdint.h> | ||
| 2 | #include <stdbool.h> | ||
| 3 | #include <util/delay.h> | ||
| 4 | #include "matrix.h" | ||
| 5 | #include "keymap.h" | ||
| 6 | #include "eeconfig.h" | ||
| 7 | #include "bootloader.h" | ||
| 8 | #include "bootmagic.h" | ||
| 9 | |||
| 10 | |||
| 11 | void bootmagic(void) | ||
| 12 | { | ||
| 13 | if (!BOOTMAGIC_IS_ENABLED()) { return; } | ||
| 14 | |||
| 15 | /* do scans in case of bounce */ | ||
| 16 | uint8_t scan = 100; | ||
| 17 | while (scan--) { matrix_scan(); _delay_ms(1); } | ||
| 18 | |||
| 19 | if (bootmagic_scan_keycode(BOOTMAGIC_BOOTLOADER_KEY)) { | ||
| 20 | bootloader_jump(); | ||
| 21 | } | ||
| 22 | |||
| 23 | if (bootmagic_scan_keycode(BOOTMAGIC_DEBUG_ENABLE_KEY)) { | ||
| 24 | eeconfig_write_debug(eeconfig_read_debug() ^ EECONFIG_DEBUG_ENABLE); | ||
| 25 | } | ||
| 26 | |||
| 27 | if (bootmagic_scan_keycode(BOOTMAGIC_EEPROM_CLEAR_KEY)) { | ||
| 28 | eeconfig_init(); | ||
| 29 | } | ||
| 30 | |||
| 31 | if (bootmagic_scan_keycode(BOOTMAGIC_SWAP_CONTROL_CPASLOCK)) { | ||
| 32 | eeconfig_write_keyconf(eeconfig_read_keyconf() ^ EECONFIG_KEYCONF_SWAP_CONTROL_CAPSLOCK); | ||
| 33 | } | ||
| 34 | if (bootmagic_scan_keycode(BOOTMAGIC_CAPSLOCK_TO_CONTROL)) { | ||
| 35 | eeconfig_write_keyconf(eeconfig_read_keyconf() ^ EECONFIG_KEYCONF_CAPSLOCK_TO_CONTROL); | ||
| 36 | } | ||
| 37 | if (bootmagic_scan_keycode(BOOTMAGIC_SWAP_LALT_LGUI)) { | ||
| 38 | eeconfig_write_keyconf(eeconfig_read_keyconf() ^ EECONFIG_KEYCONF_SWAP_LALT_LGUI); | ||
| 39 | } | ||
| 40 | if (bootmagic_scan_keycode(BOOTMAGIC_SWAP_RALT_RGUI)) { | ||
| 41 | eeconfig_write_keyconf(eeconfig_read_keyconf() ^ EECONFIG_KEYCONF_SWAP_RALT_RGUI); | ||
| 42 | } | ||
| 43 | if (bootmagic_scan_keycode(BOOTMAGIC_NO_GUI)) { | ||
| 44 | eeconfig_write_keyconf(eeconfig_read_keyconf() ^ EECONFIG_KEYCONF_NO_GUI); | ||
| 45 | } | ||
| 46 | if (bootmagic_scan_keycode(BOOTMAGIC_SWAP_GRAVE_ESC)) { | ||
| 47 | eeconfig_write_keyconf(eeconfig_read_keyconf() ^ EECONFIG_KEYCONF_SWAP_GRAVE_ESC); | ||
| 48 | } | ||
| 49 | if (bootmagic_scan_keycode(BOOTMAGIC_SWAP_BACKSLASH_BACKSPACE)) { | ||
| 50 | eeconfig_write_keyconf(eeconfig_read_keyconf() ^ EECONFIG_KEYCONF_SWAP_BACKSLASH_BACKSPACE); | ||
| 51 | } | ||
| 52 | } | ||
| 53 | |||
| 54 | bool bootmagic_scan_keycode(uint8_t keycode) | ||
| 55 | { | ||
| 56 | for (uint8_t r = 0; r < MATRIX_ROWS; r++) { | ||
| 57 | matrix_row_t matrix_row = matrix_get_row(r); | ||
| 58 | for (uint8_t c = 0; c < MATRIX_COLS; c++) { | ||
| 59 | if (matrix_row & ((matrix_row_t)1<<c)) { | ||
| 60 | if (keycode == keymap_key_to_keycode(0, (key_t){ .row = r, .col = c })) { | ||
| 61 | return true; | ||
| 62 | } | ||
| 63 | } | ||
| 64 | } | ||
| 65 | } | ||
| 66 | return false; | ||
| 67 | } | ||
diff --git a/common/bootmagic.h b/common/bootmagic.h new file mode 100644 index 000000000..5791b221f --- /dev/null +++ b/common/bootmagic.h | |||
| @@ -0,0 +1,75 @@ | |||
| 1 | #ifndef BOOTMAGIC_H | ||
| 2 | #define BOOTMAGIC_H | ||
| 3 | |||
| 4 | |||
| 5 | #ifndef BOOTMAGIC_IS_ENABLED | ||
| 6 | #define BOOTMAGIC_IS_ENABLED() true | ||
| 7 | #endif | ||
| 8 | |||
| 9 | /* kick up bootloader */ | ||
| 10 | #ifndef BOOTMAGIC_BOOTLOADER_KEY | ||
| 11 | #define BOOTMAGIC_BOOTLOADER_KEY KC_B | ||
| 12 | #endif | ||
| 13 | /* debug enable */ | ||
| 14 | #ifndef BOOTMAGIC_DEBUG_ENABLE_KEY | ||
| 15 | #define BOOTMAGIC_DEBUG_ENABLE_KEY KC_D | ||
| 16 | #endif | ||
| 17 | /* eeprom clear */ | ||
| 18 | #ifndef BOOTMAGIC_EEPROM_CLEAR_KEY | ||
| 19 | #define BOOTMAGIC_EEPROM_CLEAR_KEY KC_BSPACE | ||
| 20 | #endif | ||
| 21 | |||
| 22 | /* | ||
| 23 | * key configure | ||
| 24 | */ | ||
| 25 | /* swap control and capslock */ | ||
| 26 | #ifndef BOOTMAGIC_SWAP_CONTROL_CPASLOCK | ||
| 27 | #define BOOTMAGIC_SWAP_CONTROL_CPASLOCK KC_LCTRL | ||
| 28 | #endif | ||
| 29 | /* capslock to control */ | ||
| 30 | #ifndef BOOTMAGIC_CAPSLOCK_TO_CONTROL | ||
| 31 | #define BOOTMAGIC_CAPSLOCK_TO_CONTROL KC_CAPSLOCK | ||
| 32 | #endif | ||
| 33 | /* swap alt and gui */ | ||
| 34 | #ifndef BOOTMAGIC_SWAP_LALT_LGUI | ||
| 35 | #define BOOTMAGIC_SWAP_LALT_LGUI KC_LALT | ||
| 36 | #endif | ||
| 37 | /* swap alt and gui */ | ||
| 38 | #ifndef BOOTMAGIC_SWAP_RALT_RGUI | ||
| 39 | #define BOOTMAGIC_SWAP_RALT_RGUI KC_RALT | ||
| 40 | #endif | ||
| 41 | /* no gui */ | ||
| 42 | #ifndef BOOTMAGIC_NO_GUI | ||
| 43 | #define BOOTMAGIC_NO_GUI KC_LGUI | ||
| 44 | #endif | ||
| 45 | /* swap esc and grave */ | ||
| 46 | #ifndef BOOTMAGIC_SWAP_GRAVE_ESC | ||
| 47 | #define BOOTMAGIC_SWAP_GRAVE_ESC KC_GRAVE | ||
| 48 | #endif | ||
| 49 | /* swap backslash and backspace */ | ||
| 50 | #ifndef BOOTMAGIC_SWAP_BACKSLASH_BACKSPACE | ||
| 51 | #define BOOTMAGIC_SWAP_BACKSLASH_BACKSPACE KC_BSLASH | ||
| 52 | #endif | ||
| 53 | |||
| 54 | |||
| 55 | /* | ||
| 56 | * change default layer | ||
| 57 | */ | ||
| 58 | #ifndef BOOTMAGIC_DEFAULT_LAYER_0_KEY | ||
| 59 | #define BOOTMAGIC_DEFAULT_LAYER_0_KEY KC_0 | ||
| 60 | #endif | ||
| 61 | #ifndef BOOTMAGIC_DEFAULT_LAYER_1_KEY | ||
| 62 | #define BOOTMAGIC_DEFAULT_LAYER_1_KEY KC_1 | ||
| 63 | #endif | ||
| 64 | #ifndef BOOTMAGIC_DEFAULT_LAYER_2_KEY | ||
| 65 | #define BOOTMAGIC_DEFAULT_LAYER_2_KEY KC_2 | ||
| 66 | #endif | ||
| 67 | #ifndef BOOTMAGIC_DEFAULT_LAYER_3_KEY | ||
| 68 | #define BOOTMAGIC_DEFAULT_LAYER_3_KEY KC_3 | ||
| 69 | #endif | ||
| 70 | |||
| 71 | |||
| 72 | void bootmagic(void); | ||
| 73 | bool bootmagic_scan_keycode(uint8_t keycode); | ||
| 74 | |||
| 75 | #endif | ||
diff --git a/common/command.c b/common/command.c index 202d531fd..372ca291e 100644 --- a/common/command.c +++ b/common/command.c | |||
| @@ -27,20 +27,21 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
| 27 | #include "keyboard.h" | 27 | #include "keyboard.h" |
| 28 | #include "bootloader.h" | 28 | #include "bootloader.h" |
| 29 | #include "layer_switch.h" | 29 | #include "layer_switch.h" |
| 30 | #include "eeconfig.h" | ||
| 30 | #include "command.h" | 31 | #include "command.h" |
| 31 | 32 | ||
| 32 | #ifdef MOUSEKEY_ENABLE | 33 | #ifdef MOUSEKEY_ENABLE |
| 33 | #include "mousekey.h" | 34 | #include "mousekey.h" |
| 34 | #endif | 35 | #endif |
| 35 | 36 | ||
| 36 | #ifdef HOST_PJRC | 37 | #ifdef PROTOCOL_PJRC |
| 37 | # include "usb_keyboard.h" | 38 | # include "usb_keyboard.h" |
| 38 | # ifdef EXTRAKEY_ENABLE | 39 | # ifdef EXTRAKEY_ENABLE |
| 39 | # include "usb_extra.h" | 40 | # include "usb_extra.h" |
| 40 | # endif | 41 | # endif |
| 41 | #endif | 42 | #endif |
| 42 | 43 | ||
| 43 | #ifdef HOST_VUSB | 44 | #ifdef PROTOCOL_VUSB |
| 44 | # include "usbdrv.h" | 45 | # include "usbdrv.h" |
| 45 | #endif | 46 | #endif |
| 46 | 47 | ||
| @@ -108,6 +109,7 @@ static void command_common_help(void) | |||
| 108 | print("v: print device version & info\n"); | 109 | print("v: print device version & info\n"); |
| 109 | print("t: print timer count\n"); | 110 | print("t: print timer count\n"); |
| 110 | print("s: print status\n"); | 111 | print("s: print status\n"); |
| 112 | print("e: print eeprom boot config\n"); | ||
| 111 | #ifdef NKRO_ENABLE | 113 | #ifdef NKRO_ENABLE |
| 112 | print("n: toggle NKRO\n"); | 114 | print("n: toggle NKRO\n"); |
| 113 | #endif | 115 | #endif |
| @@ -121,10 +123,41 @@ static void command_common_help(void) | |||
| 121 | print("Paus: jump to bootloader\n"); | 123 | print("Paus: jump to bootloader\n"); |
| 122 | } | 124 | } |
| 123 | 125 | ||
| 126 | #ifdef BOOTMAGIC_ENABLE | ||
| 127 | static void print_eeprom_config(void) | ||
| 128 | { | ||
| 129 | uint8_t eebyte; | ||
| 130 | |||
| 131 | eebyte = eeconfig_read_debug(); | ||
| 132 | print("debug: "); print_hex8(eebyte); print("\n"); | ||
| 133 | |||
| 134 | eebyte = eeconfig_read_defalt_layer(); | ||
| 135 | print("defalt_layer: "); print_hex8(eebyte); print("\n"); | ||
| 136 | |||
| 137 | eebyte = eeconfig_read_keyconf(); | ||
| 138 | print("keyconf: "); print_hex8(eebyte); print("\n"); | ||
| 139 | |||
| 140 | keyconf kc = (keyconf){ .raw = eebyte }; | ||
| 141 | print("keyconf.swap_control_capslock: "); print_hex8(kc.swap_control_capslock); print("\n"); | ||
| 142 | print("keyconf.capslock_to_control: "); print_hex8(kc.capslock_to_control); print("\n"); | ||
| 143 | print("keyconf.swap_lalt_lgui: "); print_hex8(kc.swap_lalt_lgui); print("\n"); | ||
| 144 | print("keyconf.swap_ralt_rgui: "); print_hex8(kc.swap_ralt_rgui); print("\n"); | ||
| 145 | print("keyconf.no_gui: "); print_hex8(kc.no_gui); print("\n"); | ||
| 146 | print("keyconf.swap_grave_esc: "); print_hex8(kc.swap_grave_esc); print("\n"); | ||
| 147 | print("keyconf.swap_backslash_backspace: "); print_hex8(kc.swap_backslash_backspace); print("\n"); | ||
| 148 | } | ||
| 149 | #endif | ||
| 150 | |||
| 124 | static bool command_common(uint8_t code) | 151 | static bool command_common(uint8_t code) |
| 125 | { | 152 | { |
| 126 | static host_driver_t *host_driver = 0; | 153 | static host_driver_t *host_driver = 0; |
| 127 | switch (code) { | 154 | switch (code) { |
| 155 | #ifdef BOOTMAGIC_ENABLE | ||
| 156 | case KC_E: | ||
| 157 | print("eeprom config\n"); | ||
| 158 | print_eeprom_config(); | ||
| 159 | break; | ||
| 160 | #endif | ||
| 128 | case KC_CAPSLOCK: | 161 | case KC_CAPSLOCK: |
| 129 | if (host_get_driver()) { | 162 | if (host_get_driver()) { |
| 130 | host_driver = host_get_driver(); | 163 | host_driver = host_get_driver(); |
| @@ -218,7 +251,7 @@ static bool command_common(uint8_t code) | |||
| 218 | case KC_S: | 251 | case KC_S: |
| 219 | print("\n\n----- Status -----\n"); | 252 | print("\n\n----- Status -----\n"); |
| 220 | print_val_hex8(host_keyboard_leds()); | 253 | print_val_hex8(host_keyboard_leds()); |
| 221 | #ifdef HOST_PJRC | 254 | #ifdef PROTOCOL_PJRC |
| 222 | print_val_hex8(UDCON); | 255 | print_val_hex8(UDCON); |
| 223 | print_val_hex8(UDIEN); | 256 | print_val_hex8(UDIEN); |
| 224 | print_val_hex8(UDINT); | 257 | print_val_hex8(UDINT); |
| @@ -228,7 +261,7 @@ static bool command_common(uint8_t code) | |||
| 228 | print_val_hex8(usb_keyboard_idle_count); | 261 | print_val_hex8(usb_keyboard_idle_count); |
| 229 | #endif | 262 | #endif |
| 230 | 263 | ||
| 231 | #ifdef HOST_VUSB | 264 | #ifdef PROTOCOL_PJRC |
| 232 | # if USB_COUNT_SOF | 265 | # if USB_COUNT_SOF |
| 233 | print_val_hex8(usbSofCount); | 266 | print_val_hex8(usbSofCount); |
| 234 | # endif | 267 | # endif |
| @@ -247,7 +280,7 @@ static bool command_common(uint8_t code) | |||
| 247 | #ifdef EXTRAKEY_ENABLE | 280 | #ifdef EXTRAKEY_ENABLE |
| 248 | case KC_PSCREEN: | 281 | case KC_PSCREEN: |
| 249 | // TODO: Power key should take this feature? otherwise any key during suspend. | 282 | // TODO: Power key should take this feature? otherwise any key during suspend. |
| 250 | #ifdef HOST_PJRC | 283 | #ifdef PROTOCOL_PJRC |
| 251 | if (suspend && remote_wakeup) { | 284 | if (suspend && remote_wakeup) { |
| 252 | usb_remote_wakeup(); | 285 | usb_remote_wakeup(); |
| 253 | } else { | 286 | } else { |
diff --git a/common/eeconfig.c b/common/eeconfig.c new file mode 100644 index 000000000..cea3810ee --- /dev/null +++ b/common/eeconfig.c | |||
| @@ -0,0 +1,38 @@ | |||
| 1 | #include <stdint.h> | ||
| 2 | #include <stdbool.h> | ||
| 3 | #include <avr/eeprom.h> | ||
| 4 | #include "eeconfig.h" | ||
| 5 | |||
| 6 | |||
| 7 | void eeconfig_init(void) | ||
| 8 | { | ||
| 9 | eeprom_write_word(EECONFIG_MAGIC, EECONFIG_MAGIC_NUMBER); | ||
| 10 | eeprom_write_byte(EECONFIG_DEBUG, 0); | ||
| 11 | eeprom_write_byte(EECONFIG_DEFAULT_LAYER, 0); | ||
| 12 | eeprom_write_byte(EECONFIG_KEYCONF, 0); | ||
| 13 | eeprom_write_byte(EECONFIG_MOUSEKEY_ACCEL, 0); | ||
| 14 | } | ||
| 15 | |||
| 16 | void eeconfig_enable(void) | ||
| 17 | { | ||
| 18 | eeprom_write_word(EECONFIG_MAGIC, EECONFIG_MAGIC_NUMBER); | ||
| 19 | } | ||
| 20 | |||
| 21 | void eeconfig_disable(void) | ||
| 22 | { | ||
| 23 | eeprom_write_word(EECONFIG_MAGIC, 0xFFFF); | ||
| 24 | } | ||
| 25 | |||
| 26 | bool eeconfig_is_enabled(void) | ||
| 27 | { | ||
| 28 | return EECONFIG_IS_ENABLED() && (eeprom_read_word(EECONFIG_MAGIC) == EECONFIG_MAGIC_NUMBER); | ||
| 29 | } | ||
| 30 | |||
| 31 | uint8_t eeconfig_read_debug(void) { return eeprom_read_byte(EECONFIG_DEBUG); } | ||
| 32 | void eeconfig_write_debug(uint8_t val) { eeprom_write_byte(EECONFIG_DEBUG, val); } | ||
| 33 | |||
| 34 | uint8_t eeconfig_read_defalt_layer(void) { return eeprom_read_byte(EECONFIG_DEFAULT_LAYER); } | ||
| 35 | void eeconfig_write_defalt_layer(uint8_t val) { eeprom_write_byte(EECONFIG_DEFAULT_LAYER, val); } | ||
| 36 | |||
| 37 | uint8_t eeconfig_read_keyconf(void) { return eeprom_read_byte(EECONFIG_KEYCONF); } | ||
| 38 | void eeconfig_write_keyconf(uint8_t val) { eeprom_write_byte(EECONFIG_KEYCONF, val); } | ||
diff --git a/common/eeconfig.h b/common/eeconfig.h new file mode 100644 index 000000000..3e195478b --- /dev/null +++ b/common/eeconfig.h | |||
| @@ -0,0 +1,85 @@ | |||
| 1 | /* | ||
| 2 | Copyright 2013 Jun Wako <wakojun@gmail.com> | ||
| 3 | |||
| 4 | This program is free software: you can redistribute it and/or modify | ||
| 5 | it under the terms of the GNU General Public License as published by | ||
| 6 | the Free Software Foundation, either version 2 of the License, or | ||
| 7 | (at your option) any later version. | ||
| 8 | |||
| 9 | This program is distributed in the hope that it will be useful, | ||
| 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 12 | GNU General Public License for more details. | ||
| 13 | |||
| 14 | You should have received a copy of the GNU General Public License | ||
| 15 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 16 | */ | ||
| 17 | |||
| 18 | #ifndef EECONFIG_H | ||
| 19 | #define EECONFIG_H | ||
| 20 | |||
| 21 | #include <stdint.h> | ||
| 22 | |||
| 23 | #ifndef EECONFIG_IS_ENABLED | ||
| 24 | #define EECONFIG_IS_ENABLED() true | ||
| 25 | #endif | ||
| 26 | |||
| 27 | #define EECONFIG_MAGIC_NUMBER (uint16_t)0xFEED | ||
| 28 | |||
| 29 | /* eeprom parameteter address */ | ||
| 30 | #define EECONFIG_MAGIC (uint16_t *)0 | ||
| 31 | #define EECONFIG_DEBUG (uint8_t *)2 | ||
| 32 | #define EECONFIG_DEFAULT_LAYER (uint8_t *)3 | ||
| 33 | #define EECONFIG_KEYCONF (uint8_t *)4 | ||
| 34 | #define EECONFIG_MOUSEKEY_ACCEL (uint8_t *)5 | ||
| 35 | |||
| 36 | |||
| 37 | /* debug bit */ | ||
| 38 | #define EECONFIG_DEBUG_ENABLE (1<<0) | ||
| 39 | #define EECONFIG_DEBUG_MATRIX (1<<1) | ||
| 40 | #define EECONFIG_DEBUG_KEYBOARD (1<<2) | ||
| 41 | #define EECONFIG_DEBUG_MOUSE (1<<3) | ||
| 42 | |||
| 43 | /* keyconf bit */ | ||
| 44 | #define EECONFIG_KEYCONF_SWAP_CONTROL_CAPSLOCK (1<<0) | ||
| 45 | #define EECONFIG_KEYCONF_CAPSLOCK_TO_CONTROL (1<<1) | ||
| 46 | #define EECONFIG_KEYCONF_SWAP_LALT_LGUI (1<<2) | ||
| 47 | #define EECONFIG_KEYCONF_SWAP_RALT_RGUI (1<<3) | ||
| 48 | #define EECONFIG_KEYCONF_NO_GUI (1<<4) | ||
| 49 | #define EECONFIG_KEYCONF_SWAP_GRAVE_ESC (1<<5) | ||
| 50 | #define EECONFIG_KEYCONF_SWAP_BACKSLASH_BACKSPACE (1<<6) | ||
| 51 | |||
| 52 | |||
| 53 | /* XXX: Not portable. Bit field order depends on implementation */ | ||
| 54 | typedef union { | ||
| 55 | uint8_t raw; | ||
| 56 | struct { | ||
| 57 | bool swap_control_capslock:1; | ||
| 58 | bool capslock_to_control:1; | ||
| 59 | bool swap_lalt_lgui:1; | ||
| 60 | bool swap_ralt_rgui:1; | ||
| 61 | bool no_gui:1; | ||
| 62 | bool swap_grave_esc:1; | ||
| 63 | bool swap_backslash_backspace:1; | ||
| 64 | bool reserved:1; | ||
| 65 | }; | ||
| 66 | } keyconf; | ||
| 67 | |||
| 68 | bool eeconfig_is_enabled(void); | ||
| 69 | |||
| 70 | void eeconfig_init(void); | ||
| 71 | |||
| 72 | void eeconfig_enable(void); | ||
| 73 | |||
| 74 | void eeconfig_disable(void); | ||
| 75 | |||
| 76 | uint8_t eeconfig_read_debug(void); | ||
| 77 | void eeconfig_write_debug(uint8_t val); | ||
| 78 | |||
| 79 | uint8_t eeconfig_read_defalt_layer(void); | ||
| 80 | void eeconfig_write_defalt_layer(uint8_t val); | ||
| 81 | |||
| 82 | uint8_t eeconfig_read_keyconf(void); | ||
| 83 | void eeconfig_write_keyconf(uint8_t val); | ||
| 84 | |||
| 85 | #endif | ||
diff --git a/common/keyboard.c b/common/keyboard.c index 91f321d9c..401fdb4e1 100644 --- a/common/keyboard.c +++ b/common/keyboard.c | |||
| @@ -28,10 +28,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
| 28 | #include "command.h" | 28 | #include "command.h" |
| 29 | #include "util.h" | 29 | #include "util.h" |
| 30 | #include "sendchar.h" | 30 | #include "sendchar.h" |
| 31 | #include "bootloader.h" | 31 | #include "bootmagic.h" |
| 32 | #ifdef MOUSEKEY_ENABLE | 32 | #include "eeconfig.h" |
| 33 | #include "mousekey.h" | 33 | #include "mousekey.h" |
| 34 | #endif | ||
| 35 | 34 | ||
| 36 | 35 | ||
| 37 | #ifdef MATRIX_HAS_GHOST | 36 | #ifdef MATRIX_HAS_GHOST |
| @@ -59,27 +58,25 @@ void keyboard_init(void) | |||
| 59 | 58 | ||
| 60 | timer_init(); | 59 | timer_init(); |
| 61 | matrix_init(); | 60 | matrix_init(); |
| 62 | |||
| 63 | /* matrix scan for boot magic keys */ | ||
| 64 | #ifdef DEBOUNCE | ||
| 65 | uint8_t scan = DEBOUNCE * 2; | ||
| 66 | while (scan--) { matrix_scan(); _delay_ms(1); } | ||
| 67 | #else | ||
| 68 | matrix_scan(); | ||
| 69 | #endif | ||
| 70 | |||
| 71 | /* boot magic keys */ | ||
| 72 | #ifdef IS_BOOTMAGIC_BOOTLOADER | ||
| 73 | /* kick up bootloader */ | ||
| 74 | if (IS_BOOTMAGIC_BOOTLOADER()) bootloader_jump(); | ||
| 75 | #endif | ||
| 76 | #ifdef IS_BOOTMAGIC_DEBUG | ||
| 77 | if (IS_BOOTMAGIC_DEBUG()) debug_enable = true; | ||
| 78 | #endif | ||
| 79 | |||
| 80 | #ifdef PS2_MOUSE_ENABLE | 61 | #ifdef PS2_MOUSE_ENABLE |
| 81 | ps2_mouse_init(); | 62 | ps2_mouse_init(); |
| 82 | #endif | 63 | #endif |
| 64 | |||
| 65 | #ifdef BOOTMAGIC_ENABLE | ||
| 66 | bootmagic(); | ||
| 67 | |||
| 68 | if (eeconfig_is_enabled()) { | ||
| 69 | uint8_t config; | ||
| 70 | config = eeconfig_read_debug(); | ||
| 71 | // ignored if debug is enabled by program before. | ||
| 72 | if (!debug_enable) debug_enable = (config & EECONFIG_DEBUG_ENABLE); | ||
| 73 | if (!debug_matrix) debug_matrix = (config & EECONFIG_DEBUG_MATRIX); | ||
| 74 | if (!debug_keyboard) debug_keyboard = (config & EECONFIG_DEBUG_KEYBOARD); | ||
| 75 | if (!debug_mouse) debug_mouse = (config & EECONFIG_DEBUG_MOUSE); | ||
| 76 | } else { | ||
| 77 | eeconfig_init(); | ||
| 78 | } | ||
| 79 | #endif | ||
| 83 | } | 80 | } |
| 84 | 81 | ||
| 85 | /* | 82 | /* |
diff --git a/common/keymap.c b/common/keymap.c index aa8d944a7..ace3f49b6 100644 --- a/common/keymap.c +++ b/common/keymap.c | |||
| @@ -26,7 +26,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
| 26 | 26 | ||
| 27 | static action_t keycode_to_action(uint8_t keycode); | 27 | static action_t keycode_to_action(uint8_t keycode); |
| 28 | 28 | ||
| 29 | #ifdef USE_KEYMAP_V2 | 29 | |
| 30 | /* converts key to action */ | 30 | /* converts key to action */ |
| 31 | action_t action_for_key(uint8_t layer, key_t key) | 31 | action_t action_for_key(uint8_t layer, key_t key) |
| 32 | { | 32 | { |
| @@ -38,42 +38,20 @@ action_t action_for_key(uint8_t layer, key_t key) | |||
| 38 | return keycode_to_action(keycode); | 38 | return keycode_to_action(keycode); |
| 39 | } | 39 | } |
| 40 | } | 40 | } |
| 41 | #else | ||
| 42 | /* | ||
| 43 | * legacy keymap support | ||
| 44 | */ | ||
| 45 | /* translation for legacy keymap */ | ||
| 46 | action_t action_for_key(uint8_t layer, key_t key) | ||
| 47 | { | ||
| 48 | /* convert from legacy keycode to action */ | ||
| 49 | /* layer 16-31 indicate 'overlay' but not supported in legacy keymap */ | ||
| 50 | uint8_t keycode = keymap_get_keycode((layer & OVERLAY_MASK), key.row, key.col); | ||
| 51 | action_t action; | ||
| 52 | switch (keycode) { | ||
| 53 | case KC_FN0 ... KC_FN31: | ||
| 54 | { | ||
| 55 | uint8_t layer = keymap_fn_layer(FN_INDEX(keycode)); | ||
| 56 | uint8_t key = keymap_fn_keycode(FN_INDEX(keycode)); | ||
| 57 | if (key) { | ||
| 58 | action.code = ACTION_KEYMAP_TAP_KEY(layer, key); | ||
| 59 | } else { | ||
| 60 | action.code = ACTION_KEYMAP_MOMENTARY(layer); | ||
| 61 | } | ||
| 62 | } | ||
| 63 | return action; | ||
| 64 | default: | ||
| 65 | return keycode_to_action(keycode); | ||
| 66 | } | ||
| 67 | } | ||
| 68 | #endif | ||
| 69 | 41 | ||
| 70 | 42 | ||
| 43 | /* Macro */ | ||
| 71 | __attribute__ ((weak)) | 44 | __attribute__ ((weak)) |
| 72 | const prog_macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt) { return MACRO_NONE; } | 45 | const prog_macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt) |
| 46 | { | ||
| 47 | return MACRO_NONE; | ||
| 48 | } | ||
| 73 | 49 | ||
| 50 | /* Function */ | ||
| 74 | __attribute__ ((weak)) | 51 | __attribute__ ((weak)) |
| 75 | void action_function(keyrecord_t *record, uint8_t id, uint8_t opt) {} | 52 | void action_function(keyrecord_t *record, uint8_t id, uint8_t opt) |
| 76 | 53 | { | |
| 54 | } | ||
| 77 | 55 | ||
| 78 | 56 | ||
| 79 | 57 | ||
| @@ -83,14 +61,9 @@ static action_t keycode_to_action(uint8_t keycode) | |||
| 83 | action_t action; | 61 | action_t action; |
| 84 | switch (keycode) { | 62 | switch (keycode) { |
| 85 | case KC_A ... KC_EXSEL: | 63 | case KC_A ... KC_EXSEL: |
| 64 | case KC_LCTRL ... KC_RGUI: | ||
| 86 | action.code = ACTION_KEY(keycode); | 65 | action.code = ACTION_KEY(keycode); |
| 87 | break; | 66 | break; |
| 88 | case KC_LCTRL ... KC_LGUI: | ||
| 89 | action.code = ACTION_LMOD(keycode); | ||
| 90 | break; | ||
| 91 | case KC_RCTRL ... KC_RGUI: | ||
| 92 | action.code = ACTION_RMOD(keycode); | ||
| 93 | break; | ||
| 94 | case KC_SYSTEM_POWER ... KC_SYSTEM_WAKE: | 67 | case KC_SYSTEM_POWER ... KC_SYSTEM_WAKE: |
| 95 | action.code = ACTION_USAGE_SYSTEM(KEYCODE2SYSTEM(keycode)); | 68 | action.code = ACTION_USAGE_SYSTEM(KEYCODE2SYSTEM(keycode)); |
| 96 | break; | 69 | break; |
| @@ -109,3 +82,40 @@ static action_t keycode_to_action(uint8_t keycode) | |||
| 109 | } | 82 | } |
| 110 | return action; | 83 | return action; |
| 111 | } | 84 | } |
| 85 | |||
| 86 | |||
| 87 | |||
| 88 | #ifdef USE_LEGACY_KEYMAP | ||
| 89 | /* | ||
| 90 | * Legacy keymap support | ||
| 91 | * Consider using new keymap API instead. | ||
| 92 | */ | ||
| 93 | __attribute__ ((weak)) | ||
| 94 | uint8_t keymap_key_to_keycode(uint8_t layer, key_t key) | ||
| 95 | { | ||
| 96 | return keymap_get_keycode(layer, key.row, key.col); | ||
| 97 | } | ||
| 98 | |||
| 99 | |||
| 100 | /* Legacy keymap support */ | ||
| 101 | __attribute__ ((weak)) | ||
| 102 | action_t keymap_fn_to_action(uint8_t keycode) | ||
| 103 | { | ||
| 104 | action_t action = { .code = ACTION_NO }; | ||
| 105 | switch (keycode) { | ||
| 106 | case KC_FN0 ... KC_FN31: | ||
| 107 | { | ||
| 108 | uint8_t layer = keymap_fn_layer(FN_INDEX(keycode)); | ||
| 109 | uint8_t key = keymap_fn_keycode(FN_INDEX(keycode)); | ||
| 110 | if (key) { | ||
| 111 | action.code = ACTION_KEYMAP_TAP_KEY(layer, key); | ||
| 112 | } else { | ||
| 113 | action.code = ACTION_KEYMAP_MOMENTARY(layer); | ||
| 114 | } | ||
| 115 | } | ||
| 116 | return action; | ||
| 117 | default: | ||
| 118 | return action; | ||
| 119 | } | ||
| 120 | } | ||
| 121 | #endif | ||
diff --git a/common/keymap.h b/common/keymap.h index 0c483483f..7efd91f70 100644 --- a/common/keymap.h +++ b/common/keymap.h | |||
| @@ -23,24 +23,29 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
| 23 | #include "action.h" | 23 | #include "action.h" |
| 24 | 24 | ||
| 25 | 25 | ||
| 26 | #ifdef USE_KEYMAP_V2 | 26 | /* translates key to keycode */ |
| 27 | /* translates key to keycode | ||
| 28 | * layer: 0-15 for base layers | ||
| 29 | * 16-31 for overlays | ||
| 30 | */ | ||
| 31 | uint8_t keymap_key_to_keycode(uint8_t layer, key_t key); | 27 | uint8_t keymap_key_to_keycode(uint8_t layer, key_t key); |
| 28 | |||
| 32 | /* translates Fn keycode to action */ | 29 | /* translates Fn keycode to action */ |
| 33 | action_t keymap_fn_to_action(uint8_t keycode); | 30 | action_t keymap_fn_to_action(uint8_t keycode); |
| 34 | #else | 31 | |
| 35 | #warning "You are using LEGACY KEYAMP. Consider using NEW KEYMAP." | 32 | |
| 33 | |||
| 34 | #ifdef USE_LEGACY_KEYMAP | ||
| 36 | /* | 35 | /* |
| 37 | * legacy keymap support | 36 | * Legacy keymap |
| 37 | * Consider using new keymap API above instead. | ||
| 38 | */ | 38 | */ |
| 39 | /* keycode of key */ | 39 | /* keycode of key */ |
| 40 | __attribute__ ((deprecated)) | ||
| 40 | uint8_t keymap_get_keycode(uint8_t layer, uint8_t row, uint8_t col); | 41 | uint8_t keymap_get_keycode(uint8_t layer, uint8_t row, uint8_t col); |
| 42 | |||
| 41 | /* layer to move during press Fn key */ | 43 | /* layer to move during press Fn key */ |
| 44 | __attribute__ ((deprecated)) | ||
| 42 | uint8_t keymap_fn_layer(uint8_t fn_bits); | 45 | uint8_t keymap_fn_layer(uint8_t fn_bits); |
| 46 | |||
| 43 | /* keycode to send when release Fn key without using */ | 47 | /* keycode to send when release Fn key without using */ |
| 48 | __attribute__ ((deprecated)) | ||
| 44 | uint8_t keymap_fn_keycode(uint8_t fn_bits); | 49 | uint8_t keymap_fn_keycode(uint8_t fn_bits); |
| 45 | #endif | 50 | #endif |
| 46 | 51 | ||
diff --git a/common/report.h b/common/report.h index 0995189b3..480102768 100644 --- a/common/report.h +++ b/common/report.h | |||
| @@ -71,7 +71,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
| 71 | 71 | ||
| 72 | 72 | ||
| 73 | /* key report size(NKRO or boot mode) */ | 73 | /* key report size(NKRO or boot mode) */ |
| 74 | #if defined(HOST_PJRC) | 74 | #if defined(PROTOCOL_PJRC) |
| 75 | # include "usb.h" | 75 | # include "usb.h" |
| 76 | # if defined(KBD2_REPORT_KEYS) && KBD2_REPORT_KEYS > KBD_REPORT_KEYS | 76 | # if defined(KBD2_REPORT_KEYS) && KBD2_REPORT_KEYS > KBD_REPORT_KEYS |
| 77 | # define REPORT_KEYS KBD2_REPORT_KEYS | 77 | # define REPORT_KEYS KBD2_REPORT_KEYS |
diff --git a/converter/pc98_usb/config.h b/converter/pc98_usb/config.h index 4f91c07ce..b8d676e4c 100644 --- a/converter/pc98_usb/config.h +++ b/converter/pc98_usb/config.h | |||
| @@ -30,9 +30,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
| 30 | #define MATRIX_ROWS 16 | 30 | #define MATRIX_ROWS 16 |
| 31 | #define MATRIX_COLS 8 | 31 | #define MATRIX_COLS 8 |
| 32 | 32 | ||
| 33 | /* To use new keymap framework */ | ||
| 34 | #define USE_KEYMAP_V2 | ||
| 35 | |||
| 36 | /* key combination for command */ | 33 | /* key combination for command */ |
| 37 | #define IS_COMMAND() ( \ | 34 | #define IS_COMMAND() ( \ |
| 38 | host_get_first_key() == KC_CANCEL \ | 35 | host_get_first_key() == KC_CANCEL \ |
diff --git a/converter/sun_usb/config.h b/converter/sun_usb/config.h index 65ce9daf6..32303cd32 100644 --- a/converter/sun_usb/config.h +++ b/converter/sun_usb/config.h | |||
| @@ -25,12 +25,10 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
| 25 | #define PRODUCT Sun keyboard converter | 25 | #define PRODUCT Sun keyboard converter |
| 26 | #define DESCRIPTION converts Sun keyboard protocol into USB | 26 | #define DESCRIPTION converts Sun keyboard protocol into USB |
| 27 | 27 | ||
| 28 | |||
| 29 | /* matrix size */ | 28 | /* matrix size */ |
| 30 | #define MATRIX_ROWS 16 | 29 | #define MATRIX_ROWS 16 |
| 31 | #define MATRIX_COLS 8 | 30 | #define MATRIX_COLS 8 |
| 32 | 31 | ||
| 33 | |||
| 34 | /* key combination for command */ | 32 | /* key combination for command */ |
| 35 | #define IS_COMMAND() ( \ | 33 | #define IS_COMMAND() ( \ |
| 36 | keyboard_report->mods == (MOD_BIT(KC_LALT) | MOD_BIT(KC_RALT)) || \ | 34 | keyboard_report->mods == (MOD_BIT(KC_LALT) | MOD_BIT(KC_RALT)) || \ |
| @@ -38,6 +36,18 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
| 38 | keyboard_report->mods == (MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_RSHIFT)) \ | 36 | keyboard_report->mods == (MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_RSHIFT)) \ |
| 39 | ) | 37 | ) |
| 40 | 38 | ||
| 39 | /* legacy keymap support */ | ||
| 40 | #define USE_LEGACY_KEYMAP | ||
| 41 | |||
| 42 | /* Boot Section Size in *BYTEs* | ||
| 43 | * Teensy halfKay 512 | ||
| 44 | * Teensy++ halfKay 1024 | ||
| 45 | * Atmel DFU loader 4096 | ||
| 46 | * LUFA bootloader 4096 | ||
| 47 | * USBaspLoader 2048 | ||
| 48 | */ | ||
| 49 | #define BOOTLOADER_SIZE 4096 | ||
| 50 | |||
| 41 | 51 | ||
| 42 | /* Serial(USART) configuration | 52 | /* Serial(USART) configuration |
| 43 | * asynchronous, negative logic, 1200baud, no flow control | 53 | * asynchronous, negative logic, 1200baud, no flow control |
diff --git a/keyboard/gh60/Makefile.lufa b/keyboard/gh60/Makefile.lufa index 7a8303296..a5ff609a7 100644 --- a/keyboard/gh60/Makefile.lufa +++ b/keyboard/gh60/Makefile.lufa | |||
| @@ -47,8 +47,7 @@ TOP_DIR = ../.. | |||
| 47 | # Directory keyboard dependent files exist | 47 | # Directory keyboard dependent files exist |
| 48 | TARGET_DIR = . | 48 | TARGET_DIR = . |
| 49 | 49 | ||
| 50 | 50 | # project specific files | |
| 51 | # List C source files here. (C dependencies are automatically generated.) | ||
| 52 | SRC += keymap.c \ | 51 | SRC += keymap.c \ |
| 53 | matrix.c \ | 52 | matrix.c \ |
| 54 | led.c | 53 | led.c |
| @@ -93,23 +92,23 @@ ARCH = AVR8 | |||
| 93 | # CPU clock adjust registers or the clock division fuses), this will be equal to F_CPU. | 92 | # CPU clock adjust registers or the clock division fuses), this will be equal to F_CPU. |
| 94 | F_USB = $(F_CPU) | 93 | F_USB = $(F_CPU) |
| 95 | 94 | ||
| 95 | # Interrupt driven control endpoint task(+60) | ||
| 96 | #OPT_DEFS += -DINTERRUPT_CONTROL_ENDPOINT | ||
| 97 | |||
| 96 | 98 | ||
| 97 | # Build Options | 99 | # Build Options |
| 98 | # comment out to disable the options. | 100 | # comment out to disable the options. |
| 99 | # | 101 | # |
| 100 | MOUSEKEY_ENABLE = yes # Mouse keys | 102 | BOOTMAGIC_ENABLE = yes # Virtual DIP switch configuration(+1000) |
| 101 | EXTRAKEY_ENABLE = yes # Audio control and System control | 103 | MOUSEKEY_ENABLE = yes # Mouse keys(+4700) |
| 102 | CONSOLE_ENABLE = yes # Console for debug | 104 | EXTRAKEY_ENABLE = yes # Audio control and System control(+450) |
| 105 | CONSOLE_ENABLE = yes # Console for debug(+400) | ||
| 103 | #NKRO_ENABLE = yes # USB Nkey Rollover - not yet supported in LUFA | 106 | #NKRO_ENABLE = yes # USB Nkey Rollover - not yet supported in LUFA |
| 104 | #PS2_MOUSE_ENABLE = yes # PS/2 mouse(TrackPoint) support | 107 | #PS2_MOUSE_ENABLE = yes # PS/2 mouse(TrackPoint) support |
| 105 | 108 | ||
| 106 | 109 | ||
| 107 | # Boot Section Size in bytes | 110 | # Optimize size but this may cause error "relocation truncated to fit" |
| 108 | # Teensy halfKay 512 | 111 | EXTRALDFLAGS = -Wl,--relax |
| 109 | # Atmel DFU loader 4096 | ||
| 110 | # LUFA bootloader 4096 | ||
| 111 | OPT_DEFS += -DBOOT_SIZE=4096 | ||
| 112 | |||
| 113 | 112 | ||
| 114 | # Search Path | 113 | # Search Path |
| 115 | VPATH += $(TARGET_DIR) | 114 | VPATH += $(TARGET_DIR) |
diff --git a/keyboard/gh60/Makefile.pjrc b/keyboard/gh60/Makefile.pjrc index af6ef63ec..f03ca9416 100644 --- a/keyboard/gh60/Makefile.pjrc +++ b/keyboard/gh60/Makefile.pjrc | |||
| @@ -47,7 +47,7 @@ TOP_DIR = ../.. | |||
| 47 | # Directory keyboard dependent files exist | 47 | # Directory keyboard dependent files exist |
| 48 | TARGET_DIR = . | 48 | TARGET_DIR = . |
| 49 | 49 | ||
| 50 | # keyboard dependent files | 50 | # project specific files |
| 51 | SRC = keymap.c \ | 51 | SRC = keymap.c \ |
| 52 | matrix.c \ | 52 | matrix.c \ |
| 53 | led.c | 53 | led.c |
| @@ -57,10 +57,8 @@ CONFIG_H = config.h | |||
| 57 | 57 | ||
| 58 | # MCU name, you MUST set this to match the board you are using | 58 | # MCU name, you MUST set this to match the board you are using |
| 59 | # type "make clean" after changing this, so all files will be rebuilt | 59 | # type "make clean" after changing this, so all files will be rebuilt |
| 60 | #MCU = at90usb162 # Teensy 1.0 | 60 | MCU = atmega32u4 |
| 61 | MCU = atmega32u4 # Teensy 2.0 | 61 | #MCU = at90usb1286 |
| 62 | #MCU = at90usb646 # Teensy++ 1.0 | ||
| 63 | #MCU = at90usb1286 # Teensy++ 2.0 | ||
| 64 | 62 | ||
| 65 | 63 | ||
| 66 | # Processor frequency. | 64 | # Processor frequency. |
| @@ -70,15 +68,21 @@ MCU = atmega32u4 # Teensy 2.0 | |||
| 70 | # examples use this variable to calculate timings. Do not add a "UL" here. | 68 | # examples use this variable to calculate timings. Do not add a "UL" here. |
| 71 | F_CPU = 16000000 | 69 | F_CPU = 16000000 |
| 72 | 70 | ||
| 71 | # Boot Section Size in bytes | ||
| 72 | # Teensy halfKay 512 | ||
| 73 | # Atmel DFU loader 4096 | ||
| 74 | # LUFA bootloader 4096 | ||
| 75 | OPT_DEFS += -DBOOT_SIZE=4096 | ||
| 73 | 76 | ||
| 74 | # Build Options | 77 | # Build Options |
| 75 | # comment out to disable the options. | 78 | # comment out to disable the options. |
| 76 | # | 79 | # |
| 77 | MOUSEKEY_ENABLE = yes # Mouse keys | 80 | BOOTMAGIC_ENABLE = yes # Virtual DIP switch configuration(+1000) |
| 78 | #PS2_MOUSE_ENABLE = yes # PS/2 mouse(TrackPoint) support | 81 | MOUSEKEY_ENABLE = yes # Mouse keys(+5000) |
| 79 | EXTRAKEY_ENABLE = yes # Audio control and System control | 82 | EXTRAKEY_ENABLE = yes # Audio control and System control(+600) |
| 80 | NKRO_ENABLE = yes # USB Nkey Rollover | 83 | NKRO_ENABLE = yes # USB Nkey Rollover(+500) |
| 81 | CONSOLE_ENABLE = yes # Console for debug | 84 | CONSOLE_ENABLE = yes # Console for debug |
| 85 | #PS2_MOUSE_ENABLE = yes # PS/2 mouse(TrackPoint) support | ||
| 82 | 86 | ||
| 83 | 87 | ||
| 84 | # Search Path | 88 | # Search Path |
diff --git a/keyboard/gh60/config.h b/keyboard/gh60/config.h index ef0c9a173..cd98395eb 100644 --- a/keyboard/gh60/config.h +++ b/keyboard/gh60/config.h | |||
| @@ -25,12 +25,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
| 25 | #define DEVICE_VER 0x0001 | 25 | #define DEVICE_VER 0x0001 |
| 26 | #define MANUFACTURER geekhack | 26 | #define MANUFACTURER geekhack |
| 27 | #define PRODUCT GH60 | 27 | #define PRODUCT GH60 |
| 28 | |||
| 29 | |||
| 30 | /* message strings */ | ||
| 31 | #define DESCRIPTION t.m.k. keyboard firmware for GH60 | 28 | #define DESCRIPTION t.m.k. keyboard firmware for GH60 |
| 32 | 29 | ||
| 33 | |||
| 34 | /* matrix size */ | 30 | /* matrix size */ |
| 35 | #define MATRIX_ROWS 5 | 31 | #define MATRIX_ROWS 5 |
| 36 | #define MATRIX_COLS 14 | 32 | #define MATRIX_COLS 14 |
| @@ -41,14 +37,20 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
| 41 | /* Set 0 if need no debouncing */ | 37 | /* Set 0 if need no debouncing */ |
| 42 | #define DEBOUNCE 5 | 38 | #define DEBOUNCE 5 |
| 43 | 39 | ||
| 44 | /* To use new keymap framework */ | ||
| 45 | #define USE_KEYMAP_V2 | ||
| 46 | |||
| 47 | /* key combination for command */ | 40 | /* key combination for command */ |
| 48 | #define IS_COMMAND() ( \ | 41 | #define IS_COMMAND() ( \ |
| 49 | keyboard_report->mods == (MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_RSHIFT)) \ | 42 | keyboard_report->mods == (MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_RSHIFT)) \ |
| 50 | ) | 43 | ) |
| 51 | 44 | ||
| 45 | /* Boot Section Size in *BYTEs* | ||
| 46 | * Teensy halfKay 512 | ||
| 47 | * Teensy++ halfKay 1024 | ||
| 48 | * Atmel DFU loader 4096 | ||
| 49 | * LUFA bootloader 4096 | ||
| 50 | * USBaspLoader 2048 | ||
| 51 | */ | ||
| 52 | #define BOOTLOADER_SIZE 4096 | ||
| 53 | |||
| 52 | /* | 54 | /* |
| 53 | * Boot magic keys | 55 | * Boot magic keys |
| 54 | * call some function by pressing key when pluging cable or powering on. | 56 | * call some function by pressing key when pluging cable or powering on. |
| @@ -56,10 +58,13 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
| 56 | /* key position on matrix(ROW:COL) */ | 58 | /* key position on matrix(ROW:COL) */ |
| 57 | #define KEY_FN 0x4A | 59 | #define KEY_FN 0x4A |
| 58 | #define KEY_D 0x23 | 60 | #define KEY_D 0x23 |
| 61 | #define KEY_ESC 0x00 | ||
| 59 | #define KEY_IS_ON(key) matrix_is_on((key)>>4, (key)&0xF) | 62 | #define KEY_IS_ON(key) matrix_is_on((key)>>4, (key)&0xF) |
| 60 | /* kick up bootloader */ | 63 | /* kick up bootloader */ |
| 61 | #define IS_BOOTMAGIC_BOOTLOADER() KEY_IS_ON(KEY_FN) | 64 | #define IS_BOOTMAGIC_BOOTLOADER() KEY_IS_ON(KEY_FN) |
| 62 | /* debug on */ | 65 | /* debug on */ |
| 63 | #define IS_BOOTMAGIC_DEBUG() KEY_IS_ON(KEY_D) | 66 | #define IS_BOOTMAGIC_DEBUG() KEY_IS_ON(KEY_D) |
| 67 | /* eeprom clear */ | ||
| 68 | #define IS_BOOTMAGIC_EEPROM_CLEAR() KEY_IS_ON(KEY_ESC) | ||
| 64 | 69 | ||
| 65 | #endif | 70 | #endif |
diff --git a/keyboard/gh60/keymap.c b/keyboard/gh60/keymap.c index 1f5344d4c..d6af16961 100644 --- a/keyboard/gh60/keymap.c +++ b/keyboard/gh60/keymap.c | |||
| @@ -231,7 +231,8 @@ uint8_t keymap_key_to_keycode(uint8_t layer, key_t key) | |||
| 231 | if (layer < OVERLAYS_SIZE) { | 231 | if (layer < OVERLAYS_SIZE) { |
| 232 | return pgm_read_byte(&overlays[(layer)][(key.row)][(key.col)]); | 232 | return pgm_read_byte(&overlays[(layer)][(key.row)][(key.col)]); |
| 233 | } else { | 233 | } else { |
| 234 | debug("key_to_keycode: overlay "); debug_dec(layer); debug(" is invalid.\n"); | 234 | // XXX: this may cuaes bootlaoder_jump incositent fail. |
| 235 | //debug("key_to_keycode: overlay "); debug_dec(layer); debug(" is invalid.\n"); | ||
| 235 | return KC_TRANSPARENT; | 236 | return KC_TRANSPARENT; |
| 236 | } | 237 | } |
| 237 | } | 238 | } |
| @@ -240,8 +241,9 @@ uint8_t keymap_key_to_keycode(uint8_t layer, key_t key) | |||
| 240 | if (layer < KEYMAPS_SIZE) { | 241 | if (layer < KEYMAPS_SIZE) { |
| 241 | return pgm_read_byte(&keymaps[(layer)][(key.row)][(key.col)]); | 242 | return pgm_read_byte(&keymaps[(layer)][(key.row)][(key.col)]); |
| 242 | } else { | 243 | } else { |
| 244 | // XXX: this may cuaes bootlaoder_jump incositent fail. | ||
| 245 | //debug("key_to_keycode: base "); debug_dec(layer); debug(" is invalid.\n"); | ||
| 243 | // fall back to layer 0 | 246 | // fall back to layer 0 |
| 244 | debug("key_to_keycode: base "); debug_dec(layer); debug(" is invalid.\n"); | ||
| 245 | return pgm_read_byte(&keymaps[0][(key.row)][(key.col)]); | 247 | return pgm_read_byte(&keymaps[0][(key.row)][(key.col)]); |
| 246 | } | 248 | } |
| 247 | } | 249 | } |
diff --git a/keyboard/gh60/matrix.c b/keyboard/gh60/matrix.c index 85e58fe36..09a051aa6 100644 --- a/keyboard/gh60/matrix.c +++ b/keyboard/gh60/matrix.c | |||
| @@ -120,7 +120,7 @@ bool matrix_has_ghost(void) | |||
| 120 | inline | 120 | inline |
| 121 | bool matrix_is_on(uint8_t row, uint8_t col) | 121 | bool matrix_is_on(uint8_t row, uint8_t col) |
| 122 | { | 122 | { |
| 123 | return (matrix[row] & (1<<col)); | 123 | return (matrix[row] & ((matrix_row_t)1<<col)); |
| 124 | } | 124 | } |
| 125 | 125 | ||
| 126 | inline | 126 | inline |
diff --git a/keyboard/hhkb/Makefile.lufa b/keyboard/hhkb/Makefile.lufa index afd413d01..e8b2414d3 100644 --- a/keyboard/hhkb/Makefile.lufa +++ b/keyboard/hhkb/Makefile.lufa | |||
| @@ -107,13 +107,6 @@ CONSOLE_ENABLE = yes # Console for debug | |||
| 107 | #PS2_MOUSE_ENABLE = yes # PS/2 mouse(TrackPoint) support | 107 | #PS2_MOUSE_ENABLE = yes # PS/2 mouse(TrackPoint) support |
| 108 | 108 | ||
| 109 | 109 | ||
| 110 | # Boot Section Size in bytes | ||
| 111 | # Teensy halfKay 512 | ||
| 112 | # Atmel DFU loader 4096 | ||
| 113 | # LUFA bootloader 4096 | ||
| 114 | #OPT_DEFS += -DBOOT_SIZE=4096 | ||
| 115 | |||
| 116 | |||
| 117 | # Search Path | 110 | # Search Path |
| 118 | VPATH += $(TARGET_DIR) | 111 | VPATH += $(TARGET_DIR) |
| 119 | VPATH += $(TOP_DIR) | 112 | VPATH += $(TOP_DIR) |
diff --git a/keyboard/hhkb/config.h b/keyboard/hhkb/config.h index 72e4d26e9..ef2958981 100644 --- a/keyboard/hhkb/config.h +++ b/keyboard/hhkb/config.h | |||
| @@ -27,18 +27,23 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
| 27 | #define DEVICE_VER 0x0103 | 27 | #define DEVICE_VER 0x0103 |
| 28 | #define MANUFACTURER t.m.k. | 28 | #define MANUFACTURER t.m.k. |
| 29 | #define PRODUCT HHKB mod | 29 | #define PRODUCT HHKB mod |
| 30 | #define DESCRIPTION t.m.k. keyboard firmware for HHKB mod | ||
| 30 | 31 | ||
| 31 | 32 | ||
| 32 | #define DESCRIPTION t.m.k. keyboard firmware for HHKB mod | 33 | /* Boot Section Size in *BYTEs* |
| 34 | * Teensy halfKay 512 | ||
| 35 | * Teensy++ halfKay 1024 | ||
| 36 | * Atmel DFU loader 4096 | ||
| 37 | * LUFA bootloader 4096 | ||
| 38 | * USBaspLoader 2048 | ||
| 39 | */ | ||
| 40 | #define BOOTLOADER_SIZE 1024 | ||
| 33 | 41 | ||
| 34 | 42 | ||
| 35 | /* matrix size */ | 43 | /* matrix size */ |
| 36 | #define MATRIX_ROWS 8 | 44 | #define MATRIX_ROWS 8 |
| 37 | #define MATRIX_COLS 8 | 45 | #define MATRIX_COLS 8 |
| 38 | 46 | ||
| 39 | /* To use new keymap framework */ | ||
| 40 | #define USE_KEYMAP_V2 | ||
| 41 | |||
| 42 | /* | 47 | /* |
| 43 | * Boot magic keys | 48 | * Boot magic keys |
| 44 | * call some function by pressing key when pluging cable or powering on. | 49 | * call some function by pressing key when pluging cable or powering on. |
diff --git a/keyboard/hhkb/config_iwrap.h b/keyboard/hhkb/config_iwrap.h index d50b704d7..7a4ec3711 100644 --- a/keyboard/hhkb/config_iwrap.h +++ b/keyboard/hhkb/config_iwrap.h | |||
| @@ -27,13 +27,20 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
| 27 | #define DESCRIPTION t.m.k. keyboard firmware for HHKB mod | 27 | #define DESCRIPTION t.m.k. keyboard firmware for HHKB mod |
| 28 | 28 | ||
| 29 | 29 | ||
| 30 | /* Boot Section Size in *BYTEs* | ||
| 31 | * Teensy halfKay 512 | ||
| 32 | * Teensy++ halfKay 1024 | ||
| 33 | * Atmel DFU loader 4096 | ||
| 34 | * LUFA bootloader 4096 | ||
| 35 | * USBaspLoader 2048 | ||
| 36 | */ | ||
| 37 | #define BOOTLOADER_SIZE 2048 | ||
| 38 | |||
| 39 | |||
| 30 | /* matrix size */ | 40 | /* matrix size */ |
| 31 | #define MATRIX_ROWS 8 | 41 | #define MATRIX_ROWS 8 |
| 32 | #define MATRIX_COLS 8 | 42 | #define MATRIX_COLS 8 |
| 33 | 43 | ||
| 34 | /* To use new keymap framework */ | ||
| 35 | #define USE_KEYMAP_V2 | ||
| 36 | |||
| 37 | /* key combination for command */ | 44 | /* key combination for command */ |
| 38 | #define IS_COMMAND() (keyboard_report->mods == (MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_RSHIFT))) | 45 | #define IS_COMMAND() (keyboard_report->mods == (MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_RSHIFT))) |
| 39 | 46 | ||
diff --git a/protocol/iwrap.mk b/protocol/iwrap.mk index 9c83075a4..96aa4140c 100644 --- a/protocol/iwrap.mk +++ b/protocol/iwrap.mk | |||
| @@ -1,6 +1,6 @@ | |||
| 1 | IWRAP_DIR = protocol/iwrap | 1 | IWRAP_DIR = protocol/iwrap |
| 2 | 2 | ||
| 3 | OPT_DEFS += -DHOST_IWRAP | 3 | OPT_DEFS += -DPROTOCOL_IWRAP |
| 4 | 4 | ||
| 5 | SRC += $(IWRAP_DIR)/iwrap.c \ | 5 | SRC += $(IWRAP_DIR)/iwrap.c \ |
| 6 | $(IWRAP_DIR)/suart.S \ | 6 | $(IWRAP_DIR)/suart.S \ |
diff --git a/protocol/iwrap/main.c b/protocol/iwrap/main.c index 05a67337f..ac83280f1 100644 --- a/protocol/iwrap/main.c +++ b/protocol/iwrap/main.c | |||
| @@ -26,7 +26,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
| 26 | #include "matrix.h" | 26 | #include "matrix.h" |
| 27 | #include "host.h" | 27 | #include "host.h" |
| 28 | #include "iwrap.h" | 28 | #include "iwrap.h" |
| 29 | #ifdef HOST_VUSB | 29 | #ifdef PROTOCOL_VUSB |
| 30 | # include "vusb.h" | 30 | # include "vusb.h" |
| 31 | # include "usbdrv.h" | 31 | # include "usbdrv.h" |
| 32 | #endif | 32 | #endif |
| @@ -78,7 +78,7 @@ static void pullup_pins(void) | |||
| 78 | */ | 78 | */ |
| 79 | 79 | ||
| 80 | 80 | ||
| 81 | #ifdef HOST_VUSB | 81 | #ifdef PROTOCOL_VUSB |
| 82 | static void disable_vusb(void) | 82 | static void disable_vusb(void) |
| 83 | { | 83 | { |
| 84 | // disable interrupt & disconnect to prevent host from enumerating | 84 | // disable interrupt & disconnect to prevent host from enumerating |
| @@ -131,7 +131,7 @@ int main(void) | |||
| 131 | //pullup_pins(); | 131 | //pullup_pins(); |
| 132 | //set_prr(); | 132 | //set_prr(); |
| 133 | 133 | ||
| 134 | #ifdef HOST_VUSB | 134 | #ifdef PROTOCOL_VUSB |
| 135 | disable_vusb(); | 135 | disable_vusb(); |
| 136 | #endif | 136 | #endif |
| 137 | uart_init(115200); | 137 | uart_init(115200); |
| @@ -159,12 +159,12 @@ int main(void) | |||
| 159 | 159 | ||
| 160 | last_timer = timer_read(); | 160 | last_timer = timer_read(); |
| 161 | while (true) { | 161 | while (true) { |
| 162 | #ifdef HOST_VUSB | 162 | #ifdef PROTOCOL_VUSB |
| 163 | if (host_get_driver() == vusb_driver()) | 163 | if (host_get_driver() == vusb_driver()) |
| 164 | usbPoll(); | 164 | usbPoll(); |
| 165 | #endif | 165 | #endif |
| 166 | keyboard_task(); | 166 | keyboard_task(); |
| 167 | #ifdef HOST_VUSB | 167 | #ifdef PROTOCOL_VUSB |
| 168 | if (host_get_driver() == vusb_driver()) | 168 | if (host_get_driver() == vusb_driver()) |
| 169 | vusb_transfer_keyboard(); | 169 | vusb_transfer_keyboard(); |
| 170 | #endif | 170 | #endif |
| @@ -258,7 +258,7 @@ static uint8_t console_command(uint8_t c) | |||
| 258 | print("r: reset. software reset by watchdog\n"); | 258 | print("r: reset. software reset by watchdog\n"); |
| 259 | print("i: insomniac. prevent KB from sleeping\n"); | 259 | print("i: insomniac. prevent KB from sleeping\n"); |
| 260 | print("c: iwrap_call. CALL for BT connection.\n"); | 260 | print("c: iwrap_call. CALL for BT connection.\n"); |
| 261 | #ifdef HOST_VUSB | 261 | #ifdef PROTOCOL_VUSB |
| 262 | print("u: USB mode. switch to USB.\n"); | 262 | print("u: USB mode. switch to USB.\n"); |
| 263 | print("w: BT mode. switch to Bluetooth.\n"); | 263 | print("w: BT mode. switch to Bluetooth.\n"); |
| 264 | #endif | 264 | #endif |
| @@ -281,7 +281,7 @@ static uint8_t console_command(uint8_t c) | |||
| 281 | print("iwrap_call()\n"); | 281 | print("iwrap_call()\n"); |
| 282 | iwrap_call(); | 282 | iwrap_call(); |
| 283 | return 1; | 283 | return 1; |
| 284 | #ifdef HOST_VUSB | 284 | #ifdef PROTOCOL_VUSB |
| 285 | case 'u': | 285 | case 'u': |
| 286 | print("USB mode\n"); | 286 | print("USB mode\n"); |
| 287 | init_vusb(); | 287 | init_vusb(); |
diff --git a/protocol/lufa.mk b/protocol/lufa.mk index 443b85344..8ea071afb 100644 --- a/protocol/lufa.mk +++ b/protocol/lufa.mk | |||
| @@ -39,4 +39,6 @@ LUFA_OPTS += -D USE_STATIC_OPTIONS="(USB_DEVICE_OPT_FULLSPEED | USB_OPT_REG_ENAB | |||
| 39 | OPT_DEFS += -DF_USB=$(F_USB)UL | 39 | OPT_DEFS += -DF_USB=$(F_USB)UL |
| 40 | OPT_DEFS += -DARCH=ARCH_$(ARCH) | 40 | OPT_DEFS += -DARCH=ARCH_$(ARCH) |
| 41 | OPT_DEFS += $(LUFA_OPTS) | 41 | OPT_DEFS += $(LUFA_OPTS) |
| 42 | OPT_DEFS += -DHOST_LUFA | 42 | |
| 43 | # This indicates using LUFA stack | ||
| 44 | OPT_DEFS += -DPROTOCOL_LUFA | ||
diff --git a/protocol/pjrc.mk b/protocol/pjrc.mk index cccdf6204..27f908b1c 100644 --- a/protocol/pjrc.mk +++ b/protocol/pjrc.mk | |||
| @@ -1,7 +1,5 @@ | |||
| 1 | PJRC_DIR = protocol/pjrc | 1 | PJRC_DIR = protocol/pjrc |
| 2 | 2 | ||
| 3 | OPT_DEFS += -DHOST_PJRC | ||
| 4 | |||
| 5 | SRC += $(PJRC_DIR)/main.c \ | 3 | SRC += $(PJRC_DIR)/main.c \ |
| 6 | $(PJRC_DIR)/pjrc.c \ | 4 | $(PJRC_DIR)/pjrc.c \ |
| 7 | $(PJRC_DIR)/usb_keyboard.c \ | 5 | $(PJRC_DIR)/usb_keyboard.c \ |
| @@ -19,3 +17,6 @@ endif | |||
| 19 | 17 | ||
| 20 | # Search Path | 18 | # Search Path |
| 21 | VPATH += $(TOP_DIR)/$(PJRC_DIR) | 19 | VPATH += $(TOP_DIR)/$(PJRC_DIR) |
| 20 | |||
| 21 | # This indicates using LUFA stack | ||
| 22 | OPT_DEFS += -DPROTOCOL_PJRC | ||
diff --git a/protocol/vusb.mk b/protocol/vusb.mk index 4c5058115..77b1c6337 100644 --- a/protocol/vusb.mk +++ b/protocol/vusb.mk | |||
| @@ -1,6 +1,6 @@ | |||
| 1 | VUSB_DIR = protocol/vusb | 1 | VUSB_DIR = protocol/vusb |
| 2 | 2 | ||
| 3 | OPT_DEFS += -DHOST_VUSB | 3 | OPT_DEFS += -DPROTOCOL_VUSB |
| 4 | 4 | ||
| 5 | SRC += $(VUSB_DIR)/main.c \ | 5 | SRC += $(VUSB_DIR)/main.c \ |
| 6 | $(VUSB_DIR)/vusb.c \ | 6 | $(VUSB_DIR)/vusb.c \ |
