diff options
Diffstat (limited to 'tmk_core')
33 files changed, 179 insertions, 1176 deletions
diff --git a/tmk_core/avr.mk b/tmk_core/avr.mk index 1846a9b4b..ecd2fd39a 100644 --- a/tmk_core/avr.mk +++ b/tmk_core/avr.mk | |||
| @@ -240,7 +240,7 @@ avrdude-split-right: $(BUILD_DIR)/$(TARGET).hex check-size cpfirmware | |||
| 240 | $(call EXEC_AVRDUDE,eeprom-righthand.eep) | 240 | $(call EXEC_AVRDUDE,eeprom-righthand.eep) |
| 241 | 241 | ||
| 242 | define EXEC_USBASP | 242 | define EXEC_USBASP |
| 243 | avrdude -p $(MCU) -c usbasp -U flash:w:$(BUILD_DIR)/$(TARGET).hex | 243 | avrdude -p $(AVRDUDE_MCU) -c usbasp -U flash:w:$(BUILD_DIR)/$(TARGET).hex |
| 244 | endef | 244 | endef |
| 245 | 245 | ||
| 246 | usbasp: $(BUILD_DIR)/$(TARGET).hex check-size cpfirmware | 246 | usbasp: $(BUILD_DIR)/$(TARGET).hex check-size cpfirmware |
| @@ -321,7 +321,7 @@ extcoff: $(BUILD_DIR)/$(TARGET).elf | |||
| 321 | bootloader: | 321 | bootloader: |
| 322 | make -C lib/lufa/Bootloaders/DFU/ clean | 322 | make -C lib/lufa/Bootloaders/DFU/ clean |
| 323 | $(TMK_DIR)/make_dfu_header.sh $(ALL_CONFIGS) | 323 | $(TMK_DIR)/make_dfu_header.sh $(ALL_CONFIGS) |
| 324 | $(eval MAX_SIZE=$(shell n=`$(CC) -E -mmcu=$(MCU) $(CFLAGS) $(OPT_DEFS) tmk_core/common/avr/bootloader_size.c 2> /dev/null | sed -ne '/^#/n;/^AVR_SIZE:/,$${s/^AVR_SIZE: //;p;}'` && echo $$(($$n)) || echo 0)) | 324 | $(eval MAX_SIZE=$(shell n=`$(CC) -E -mmcu=$(MCU) $(CFLAGS) $(OPT_DEFS) tmk_core/common/avr/bootloader_size.c 2> /dev/null | sed -ne 's/\r//;/^#/n;/^AVR_SIZE:/,$${s/^AVR_SIZE: //;p;}'` && echo $$(($$n)) || echo 0)) |
| 325 | $(eval PROGRAM_SIZE_KB=$(shell n=`expr $(MAX_SIZE) / 1024` && echo $$(($$n)) || echo 0)) | 325 | $(eval PROGRAM_SIZE_KB=$(shell n=`expr $(MAX_SIZE) / 1024` && echo $$(($$n)) || echo 0)) |
| 326 | $(eval BOOT_SECTION_SIZE_KB=$(shell n=`expr $(BOOTLOADER_SIZE) / 1024` && echo $$(($$n)) || echo 0)) | 326 | $(eval BOOT_SECTION_SIZE_KB=$(shell n=`expr $(BOOTLOADER_SIZE) / 1024` && echo $$(($$n)) || echo 0)) |
| 327 | $(eval FLASH_SIZE_KB=$(shell n=`expr $(PROGRAM_SIZE_KB) + $(BOOT_SECTION_SIZE_KB)` && echo $$(($$n)) || echo 0)) | 327 | $(eval FLASH_SIZE_KB=$(shell n=`expr $(PROGRAM_SIZE_KB) + $(BOOT_SECTION_SIZE_KB)` && echo $$(($$n)) || echo 0)) |
diff --git a/tmk_core/common.mk b/tmk_core/common.mk index d43950299..8f355da12 100644 --- a/tmk_core/common.mk +++ b/tmk_core/common.mk | |||
| @@ -187,18 +187,6 @@ ifeq ($(strip $(NO_USB_STARTUP_CHECK)), yes) | |||
| 187 | TMK_COMMON_DEFS += -DNO_USB_STARTUP_CHECK | 187 | TMK_COMMON_DEFS += -DNO_USB_STARTUP_CHECK |
| 188 | endif | 188 | endif |
| 189 | 189 | ||
| 190 | ifeq ($(strip $(KEYMAP_SECTION_ENABLE)), yes) | ||
| 191 | TMK_COMMON_DEFS += -DKEYMAP_SECTION_ENABLE | ||
| 192 | |||
| 193 | ifeq ($(strip $(MCU)),atmega32u2) | ||
| 194 | TMK_COMMON_LDFLAGS = -Wl,-L$(TMK_DIR),-Tldscript_keymap_avr35.x | ||
| 195 | else ifeq ($(strip $(MCU)),atmega32u4) | ||
| 196 | TMK_COMMON_LDFLAGS = -Wl,-L$(TMK_DIR),-Tldscript_keymap_avr5.x | ||
| 197 | else | ||
| 198 | TMK_COMMON_LDFLAGS = $(error no ldscript for keymap section) | ||
| 199 | endif | ||
| 200 | endif | ||
| 201 | |||
| 202 | ifeq ($(strip $(SHARED_EP_ENABLE)), yes) | 190 | ifeq ($(strip $(SHARED_EP_ENABLE)), yes) |
| 203 | TMK_COMMON_DEFS += -DSHARED_EP_ENABLE | 191 | TMK_COMMON_DEFS += -DSHARED_EP_ENABLE |
| 204 | endif | 192 | endif |
diff --git a/tmk_core/common/action.c b/tmk_core/common/action.c index bd6aeba4f..d6062703e 100644 --- a/tmk_core/common/action.c +++ b/tmk_core/common/action.c | |||
| @@ -47,6 +47,10 @@ int retro_tapping_counter = 0; | |||
| 47 | # include <fauxclicky.h> | 47 | # include <fauxclicky.h> |
| 48 | #endif | 48 | #endif |
| 49 | 49 | ||
| 50 | #ifdef IGNORE_MOD_TAP_INTERRUPT_PER_KEY | ||
| 51 | __attribute__ ((weak)) bool get_ignore_mod_tap_interrupt(uint16_t keycode) { return false; } | ||
| 52 | #endif | ||
| 53 | |||
| 50 | #ifndef TAP_CODE_DELAY | 54 | #ifndef TAP_CODE_DELAY |
| 51 | # define TAP_CODE_DELAY 0 | 55 | # define TAP_CODE_DELAY 0 |
| 52 | #endif | 56 | #endif |
| @@ -308,8 +312,12 @@ void process_action(keyrecord_t *record, action_t action) { | |||
| 308 | default: | 312 | default: |
| 309 | if (event.pressed) { | 313 | if (event.pressed) { |
| 310 | if (tap_count > 0) { | 314 | if (tap_count > 0) { |
| 311 | # ifndef IGNORE_MOD_TAP_INTERRUPT | 315 | # if !defined(IGNORE_MOD_TAP_INTERRUPT) || defined(IGNORE_MOD_TAP_INTERRUPT_PER_KEY) |
| 312 | if (record->tap.interrupted) { | 316 | if ( |
| 317 | # ifdef IGNORE_MOD_TAP_INTERRUPT_PER_KEY | ||
| 318 | !get_ignore_mod_tap_interrupt(get_event_keycode(record->event)) && | ||
| 319 | # endif | ||
| 320 | record->tap.interrupted) { | ||
| 313 | dprint("mods_tap: tap: cancel: add_mods\n"); | 321 | dprint("mods_tap: tap: cancel: add_mods\n"); |
| 314 | // ad hoc: set 0 to cancel tap | 322 | // ad hoc: set 0 to cancel tap |
| 315 | record->tap.count = 0; | 323 | record->tap.count = 0; |
| @@ -552,7 +560,7 @@ void process_action(keyrecord_t *record, action_t action) { | |||
| 552 | action_macro_play(action_get_macro(record, action.func.id, action.func.opt)); | 560 | action_macro_play(action_get_macro(record, action.func.id, action.func.opt)); |
| 553 | break; | 561 | break; |
| 554 | #endif | 562 | #endif |
| 555 | #if defined(BACKLIGHT_ENABLE) | defined(LED_MATRIX_ENABLE) | 563 | #if defined(BACKLIGHT_ENABLE) || defined(LED_MATRIX_ENABLE) |
| 556 | case ACT_BACKLIGHT: | 564 | case ACT_BACKLIGHT: |
| 557 | if (!event.pressed) { | 565 | if (!event.pressed) { |
| 558 | switch (action.backlight.opt) { | 566 | switch (action.backlight.opt) { |
diff --git a/tmk_core/common/action_tapping.c b/tmk_core/common/action_tapping.c index e0f524ad7..c0f1f694b 100644 --- a/tmk_core/common/action_tapping.c +++ b/tmk_core/common/action_tapping.c | |||
| @@ -27,6 +27,10 @@ __attribute__((weak)) uint16_t get_tapping_term(uint16_t keycode) { return TAPPI | |||
| 27 | # define WITHIN_TAPPING_TERM(e) (TIMER_DIFF_16(e.time, tapping_key.event.time) < TAPPING_TERM) | 27 | # define WITHIN_TAPPING_TERM(e) (TIMER_DIFF_16(e.time, tapping_key.event.time) < TAPPING_TERM) |
| 28 | # endif | 28 | # endif |
| 29 | 29 | ||
| 30 | # ifdef TAPPING_FORCE_HOLD_PER_KEY | ||
| 31 | __attribute__((weak)) bool get_tapping_force_hold(uint16_t keycode, keyrecord_t *record) { return false; } | ||
| 32 | # endif | ||
| 33 | |||
| 30 | static keyrecord_t tapping_key = {}; | 34 | static keyrecord_t tapping_key = {}; |
| 31 | static keyrecord_t waiting_buffer[WAITING_BUFFER_SIZE] = {}; | 35 | static keyrecord_t waiting_buffer[WAITING_BUFFER_SIZE] = {}; |
| 32 | static uint8_t waiting_buffer_head = 0; | 36 | static uint8_t waiting_buffer_head = 0; |
| @@ -111,7 +115,7 @@ bool process_tapping(keyrecord_t *keyp) { | |||
| 111 | * This can register the key before settlement of tapping, | 115 | * This can register the key before settlement of tapping, |
| 112 | * useful for long TAPPING_TERM but may prevent fast typing. | 116 | * useful for long TAPPING_TERM but may prevent fast typing. |
| 113 | */ | 117 | */ |
| 114 | # if defined(TAPPING_TERM_PER_KEY) || (!defined(PER_KEY_TAPPING_TERM) && TAPPING_TERM >= 500) || defined(PERMISSIVE_HOLD) | 118 | # if defined(TAPPING_TERM_PER_KEY) || (TAPPING_TERM >= 500) || defined(PERMISSIVE_HOLD) |
| 115 | # ifdef TAPPING_TERM_PER_KEY | 119 | # ifdef TAPPING_TERM_PER_KEY |
| 116 | else if ((get_tapping_term(get_event_keycode(tapping_key.event)) >= 500) && IS_RELEASED(event) && waiting_buffer_typed(event)) | 120 | else if ((get_tapping_term(get_event_keycode(tapping_key.event)) >= 500) && IS_RELEASED(event) && waiting_buffer_typed(event)) |
| 117 | # else | 121 | # else |
| @@ -232,8 +236,13 @@ bool process_tapping(keyrecord_t *keyp) { | |||
| 232 | if (WITHIN_TAPPING_TERM(event)) { | 236 | if (WITHIN_TAPPING_TERM(event)) { |
| 233 | if (event.pressed) { | 237 | if (event.pressed) { |
| 234 | if (IS_TAPPING_KEY(event.key)) { | 238 | if (IS_TAPPING_KEY(event.key)) { |
| 235 | # ifndef TAPPING_FORCE_HOLD | 239 | //# ifndef TAPPING_FORCE_HOLD |
| 236 | if (!tapping_key.tap.interrupted && tapping_key.tap.count > 0) { | 240 | # if !defined(TAPPING_FORCE_HOLD) || defined(TAPPING_FORCE_HOLD_PER_KEY) |
| 241 | if ( | ||
| 242 | # ifdef TAPPING_FORCE_HOLD_PER_KEY | ||
| 243 | !get_tapping_force_hold(get_event_keycode(tapping_key.event), keyp) && | ||
| 244 | # endif | ||
| 245 | !tapping_key.tap.interrupted && tapping_key.tap.count > 0) { | ||
| 237 | // sequential tap. | 246 | // sequential tap. |
| 238 | keyp->tap = tapping_key.tap; | 247 | keyp->tap = tapping_key.tap; |
| 239 | if (keyp->tap.count < 15) keyp->tap.count += 1; | 248 | if (keyp->tap.count < 15) keyp->tap.count += 1; |
diff --git a/tmk_core/common/chibios/chibios_config.h b/tmk_core/common/chibios/chibios_config.h new file mode 100644 index 000000000..272529608 --- /dev/null +++ b/tmk_core/common/chibios/chibios_config.h | |||
| @@ -0,0 +1,24 @@ | |||
| 1 | /* Copyright 2019 | ||
| 2 | * | ||
| 3 | * This program is free software: you can redistribute it and/or modify | ||
| 4 | * it under the terms of the GNU General Public License as published by | ||
| 5 | * the Free Software Foundation, either version 2 of the License, or | ||
| 6 | * (at your option) any later version. | ||
| 7 | * | ||
| 8 | * This program is distributed in the hope that it will be useful, | ||
| 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 11 | * GNU General Public License for more details. | ||
| 12 | * | ||
| 13 | * You should have received a copy of the GNU General Public License | ||
| 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 15 | */ | ||
| 16 | #pragma once | ||
| 17 | |||
| 18 | #if defined(STM32F1XX) | ||
| 19 | # define USE_GPIOV1 | ||
| 20 | #endif | ||
| 21 | |||
| 22 | #if defined(STM32F1XX) || defined(STM32F2XX) || defined(STM32F4XX) || defined(STM32L1XX) | ||
| 23 | # define USE_I2CV1 | ||
| 24 | #endif | ||
diff --git a/tmk_core/common/command.c b/tmk_core/common/command.c index 82cd80609..0d6661d60 100644 --- a/tmk_core/common/command.c +++ b/tmk_core/common/command.c | |||
| @@ -192,9 +192,6 @@ static void print_version(void) { | |||
| 192 | #ifdef NKRO_ENABLE | 192 | #ifdef NKRO_ENABLE |
| 193 | " NKRO" | 193 | " NKRO" |
| 194 | #endif | 194 | #endif |
| 195 | #ifdef KEYMAP_SECTION_ENABLE | ||
| 196 | " KEYMAP_SECTION" | ||
| 197 | #endif | ||
| 198 | 195 | ||
| 199 | " " STR(BOOTLOADER_SIZE) "\n"); | 196 | " " STR(BOOTLOADER_SIZE) "\n"); |
| 200 | 197 | ||
diff --git a/tmk_core/common/eeconfig.h b/tmk_core/common/eeconfig.h index 308f865e1..6fbe78903 100644 --- a/tmk_core/common/eeconfig.h +++ b/tmk_core/common/eeconfig.h | |||
| @@ -48,6 +48,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
| 48 | #define EECONFIG_RGB_MATRIX_SPEED (uint8_t *)32 | 48 | #define EECONFIG_RGB_MATRIX_SPEED (uint8_t *)32 |
| 49 | // TODO: Combine these into a single word and single block of EEPROM | 49 | // TODO: Combine these into a single word and single block of EEPROM |
| 50 | #define EECONFIG_KEYMAP_UPPER_BYTE (uint8_t *)33 | 50 | #define EECONFIG_KEYMAP_UPPER_BYTE (uint8_t *)33 |
| 51 | // Size of EEPROM being used, other code can refer to this for available EEPROM | ||
| 52 | #define EECONFIG_SIZE 34 | ||
| 51 | /* debug bit */ | 53 | /* debug bit */ |
| 52 | #define EECONFIG_DEBUG_ENABLE (1 << 0) | 54 | #define EECONFIG_DEBUG_ENABLE (1 << 0) |
| 53 | #define EECONFIG_DEBUG_MATRIX (1 << 1) | 55 | #define EECONFIG_DEBUG_MATRIX (1 << 1) |
diff --git a/tmk_core/common/keyboard.c b/tmk_core/common/keyboard.c index 63ace9793..cb4e7637f 100644 --- a/tmk_core/common/keyboard.c +++ b/tmk_core/common/keyboard.c | |||
| @@ -83,6 +83,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
| 83 | #ifdef VELOCIKEY_ENABLE | 83 | #ifdef VELOCIKEY_ENABLE |
| 84 | # include "velocikey.h" | 84 | # include "velocikey.h" |
| 85 | #endif | 85 | #endif |
| 86 | #ifdef VIA_ENABLE | ||
| 87 | # include "via.h" | ||
| 88 | #endif | ||
| 86 | 89 | ||
| 87 | // Only enable this if console is enabled to print to | 90 | // Only enable this if console is enabled to print to |
| 88 | #if defined(DEBUG_MATRIX_SCAN_RATE) && defined(CONSOLE_ENABLE) | 91 | #if defined(DEBUG_MATRIX_SCAN_RATE) && defined(CONSOLE_ENABLE) |
| @@ -217,6 +220,9 @@ __attribute__((weak)) bool is_keyboard_master(void) { return true; } | |||
| 217 | void keyboard_init(void) { | 220 | void keyboard_init(void) { |
| 218 | timer_init(); | 221 | timer_init(); |
| 219 | matrix_init(); | 222 | matrix_init(); |
| 223 | #ifdef VIA_ENABLE | ||
| 224 | via_init(); | ||
| 225 | #endif | ||
| 220 | #ifdef QWIIC_ENABLE | 226 | #ifdef QWIIC_ENABLE |
| 221 | qwiic_init(); | 227 | qwiic_init(); |
| 222 | #endif | 228 | #endif |
| @@ -254,6 +260,7 @@ void keyboard_init(void) { | |||
| 254 | #endif | 260 | #endif |
| 255 | #if defined(NKRO_ENABLE) && defined(FORCE_NKRO) | 261 | #if defined(NKRO_ENABLE) && defined(FORCE_NKRO) |
| 256 | keymap_config.nkro = 1; | 262 | keymap_config.nkro = 1; |
| 263 | eeconfig_update_keymap(keymap_config.raw); | ||
| 257 | #endif | 264 | #endif |
| 258 | keyboard_post_init_kb(); /* Always keep this last */ | 265 | keyboard_post_init_kb(); /* Always keep this last */ |
| 259 | } | 266 | } |
| @@ -296,13 +303,14 @@ void keyboard_task(void) { | |||
| 296 | } | 303 | } |
| 297 | #endif | 304 | #endif |
| 298 | if (debug_matrix) matrix_print(); | 305 | if (debug_matrix) matrix_print(); |
| 299 | for (uint8_t c = 0; c < MATRIX_COLS; c++) { | 306 | matrix_row_t col_mask = 1; |
| 300 | if (matrix_change & ((matrix_row_t)1 << c)) { | 307 | for (uint8_t c = 0; c < MATRIX_COLS; c++, col_mask <<= 1) { |
| 308 | if (matrix_change & col_mask) { | ||
| 301 | action_exec((keyevent_t){ | 309 | action_exec((keyevent_t){ |
| 302 | .key = (keypos_t){.row = r, .col = c}, .pressed = (matrix_row & ((matrix_row_t)1 << c)), .time = (timer_read() | 1) /* time should not be 0 */ | 310 | .key = (keypos_t){.row = r, .col = c}, .pressed = (matrix_row & col_mask), .time = (timer_read() | 1) /* time should not be 0 */ |
| 303 | }); | 311 | }); |
| 304 | // record a processed key | 312 | // record a processed key |
| 305 | matrix_prev[r] ^= ((matrix_row_t)1 << c); | 313 | matrix_prev[r] ^= col_mask; |
| 306 | #ifdef QMK_KEYS_PER_SCAN | 314 | #ifdef QMK_KEYS_PER_SCAN |
| 307 | // only jump out if we have processed "enough" keys. | 315 | // only jump out if we have processed "enough" keys. |
| 308 | if (++keys_processed >= QMK_KEYS_PER_SCAN) | 316 | if (++keys_processed >= QMK_KEYS_PER_SCAN) |
| @@ -327,6 +335,16 @@ MATRIX_LOOP_END: | |||
| 327 | matrix_scan_perf_task(); | 335 | matrix_scan_perf_task(); |
| 328 | #endif | 336 | #endif |
| 329 | 337 | ||
| 338 | #if defined(RGBLIGHT_ANIMATIONS) && defined(RGBLIGHT_ENABLE) | ||
| 339 | rgblight_task(); | ||
| 340 | #endif | ||
| 341 | |||
| 342 | #if defined(BACKLIGHT_ENABLE) | ||
| 343 | # if defined(BACKLIGHT_PIN) || defined(BACKLIGHT_PINS) | ||
| 344 | backlight_task(); | ||
| 345 | # endif | ||
| 346 | #endif | ||
| 347 | |||
| 330 | #ifdef QWIIC_ENABLE | 348 | #ifdef QWIIC_ENABLE |
| 331 | qwiic_task(); | 349 | qwiic_task(); |
| 332 | #endif | 350 | #endif |
diff --git a/tmk_core/common/keycode.h b/tmk_core/common/keycode.h index fd5d60680..e1059fadf 100644 --- a/tmk_core/common/keycode.h +++ b/tmk_core/common/keycode.h | |||
| @@ -175,7 +175,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
| 175 | #define KC_MPLY KC_MEDIA_PLAY_PAUSE | 175 | #define KC_MPLY KC_MEDIA_PLAY_PAUSE |
| 176 | #define KC_MSEL KC_MEDIA_SELECT | 176 | #define KC_MSEL KC_MEDIA_SELECT |
| 177 | #define KC_EJCT KC_MEDIA_EJECT | 177 | #define KC_EJCT KC_MEDIA_EJECT |
| 178 | #define KC_MAIL KC_MAIL | ||
| 179 | #define KC_CALC KC_CALCULATOR | 178 | #define KC_CALC KC_CALCULATOR |
| 180 | #define KC_MYCM KC_MY_COMPUTER | 179 | #define KC_MYCM KC_MY_COMPUTER |
| 181 | #define KC_WSCH KC_WWW_SEARCH | 180 | #define KC_WSCH KC_WWW_SEARCH |
diff --git a/tmk_core/common/matrix.h b/tmk_core/common/matrix.h index 7624d5137..a2fedf5ff 100644 --- a/tmk_core/common/matrix.h +++ b/tmk_core/common/matrix.h | |||
| @@ -40,6 +40,8 @@ typedef uint32_t matrix_col_t; | |||
| 40 | # error "MATRIX_ROWS: invalid value" | 40 | # error "MATRIX_ROWS: invalid value" |
| 41 | #endif | 41 | #endif |
| 42 | 42 | ||
| 43 | #define MATRIX_ROW_SHIFTER ((matrix_row_t)1) | ||
| 44 | |||
| 43 | #define MATRIX_IS_ON(row, col) (matrix_get_row(row) && (1 << col)) | 45 | #define MATRIX_IS_ON(row, col) (matrix_get_row(row) && (1 << col)) |
| 44 | 46 | ||
| 45 | #ifdef __cplusplus | 47 | #ifdef __cplusplus |
| @@ -79,11 +81,6 @@ void matrix_scan_kb(void); | |||
| 79 | void matrix_init_user(void); | 81 | void matrix_init_user(void); |
| 80 | void matrix_scan_user(void); | 82 | void matrix_scan_user(void); |
| 81 | 83 | ||
| 82 | #ifdef I2C_SPLIT | ||
| 83 | void slave_matrix_init(void); | ||
| 84 | uint8_t slave_matrix_scan(void); | ||
| 85 | #endif | ||
| 86 | |||
| 87 | #ifdef __cplusplus | 84 | #ifdef __cplusplus |
| 88 | } | 85 | } |
| 89 | #endif | 86 | #endif |
diff --git a/tmk_core/common/mbed/bootloader.c b/tmk_core/common/mbed/bootloader.c deleted file mode 100644 index 88945eb05..000000000 --- a/tmk_core/common/mbed/bootloader.c +++ /dev/null | |||
| @@ -1,3 +0,0 @@ | |||
| 1 | #include "bootloader.h" | ||
| 2 | |||
| 3 | void bootloader_jump(void) {} | ||
diff --git a/tmk_core/common/mbed/suspend.c b/tmk_core/common/mbed/suspend.c deleted file mode 100644 index 3d0554f87..000000000 --- a/tmk_core/common/mbed/suspend.c +++ /dev/null | |||
| @@ -1,5 +0,0 @@ | |||
| 1 | #include <stdbool.h> | ||
| 2 | |||
| 3 | void suspend_power_down(void) {} | ||
| 4 | bool suspend_wakeup_condition(void) { return true; } | ||
| 5 | void suspend_wakeup_init(void) {} | ||
diff --git a/tmk_core/common/mbed/timer.c b/tmk_core/common/mbed/timer.c deleted file mode 100644 index 7e4070af2..000000000 --- a/tmk_core/common/mbed/timer.c +++ /dev/null | |||
| @@ -1,23 +0,0 @@ | |||
| 1 | #include "cmsis.h" | ||
| 2 | #include "timer.h" | ||
| 3 | |||
| 4 | /* Mill second tick count */ | ||
| 5 | volatile uint32_t timer_count = 0; | ||
| 6 | |||
| 7 | /* Timer interrupt handler */ | ||
| 8 | void SysTick_Handler(void) { timer_count++; } | ||
| 9 | |||
| 10 | void timer_init(void) { | ||
| 11 | timer_count = 0; | ||
| 12 | SysTick_Config(SystemCoreClock / 1000); /* 1ms tick */ | ||
| 13 | } | ||
| 14 | |||
| 15 | void timer_clear(void) { timer_count = 0; } | ||
| 16 | |||
| 17 | uint16_t timer_read(void) { return (uint16_t)(timer_count & 0xFFFF); } | ||
| 18 | |||
| 19 | uint32_t timer_read32(void) { return timer_count; } | ||
| 20 | |||
| 21 | uint16_t timer_elapsed(uint16_t last) { return TIMER_DIFF_16(timer_read(), last); } | ||
| 22 | |||
| 23 | uint32_t timer_elapsed32(uint32_t last) { return TIMER_DIFF_32(timer_read32(), last); } | ||
diff --git a/tmk_core/common/mbed/xprintf.cpp b/tmk_core/common/mbed/xprintf.cpp deleted file mode 100644 index 184b7fa7a..000000000 --- a/tmk_core/common/mbed/xprintf.cpp +++ /dev/null | |||
| @@ -1,50 +0,0 @@ | |||
| 1 | #include <cstdarg> | ||
| 2 | //#include <stdarg.h> | ||
| 3 | #include "mbed.h" | ||
| 4 | #include "mbed/xprintf.h" | ||
| 5 | |||
| 6 | #define STRING_STACK_LIMIT 120 | ||
| 7 | |||
| 8 | // TODO | ||
| 9 | int __xprintf(const char* format, ...) { return 0; } | ||
| 10 | |||
| 11 | #if 0 | ||
| 12 | /* mbed Serial */ | ||
| 13 | Serial ser(UART_TX, UART_RX); | ||
| 14 | |||
| 15 | /* TODO: Need small implementation for embedded */ | ||
| 16 | int xprintf(const char* format, ...) | ||
| 17 | { | ||
| 18 | /* copy from mbed/common/RawSerial.cpp */ | ||
| 19 | std::va_list arg; | ||
| 20 | va_start(arg, format); | ||
| 21 | int len = vsnprintf(NULL, 0, format, arg); | ||
| 22 | if (len < STRING_STACK_LIMIT) { | ||
| 23 | char temp[STRING_STACK_LIMIT]; | ||
| 24 | vsprintf(temp, format, arg); | ||
| 25 | ser.puts(temp); | ||
| 26 | } else { | ||
| 27 | char *temp = new char[len + 1]; | ||
| 28 | vsprintf(temp, format, arg); | ||
| 29 | ser.puts(temp); | ||
| 30 | delete[] temp; | ||
| 31 | } | ||
| 32 | va_end(arg); | ||
| 33 | return len; | ||
| 34 | |||
| 35 | /* Fail: __builtin_va_arg_pack? | ||
| 36 | * https://gcc.gnu.org/onlinedocs/gcc-4.3.5/gcc/Constructing-Calls.html#Constructing-Calls | ||
| 37 | void *arg = __builtin_apply_args(); | ||
| 38 | void *ret = __builtin_apply((void*)(&(ser.printf)), arg, 100); | ||
| 39 | __builtin_return(ret) | ||
| 40 | */ | ||
| 41 | /* Fail: varargs can not be passed to printf | ||
| 42 | //int r = ser.printf("test %i\r\n", 123); | ||
| 43 | va_list arg; | ||
| 44 | va_start(arg, format); | ||
| 45 | int r = ser.printf(format, arg); | ||
| 46 | va_end(arg); | ||
| 47 | return r; | ||
| 48 | */ | ||
| 49 | } | ||
| 50 | #endif | ||
diff --git a/tmk_core/common/mbed/xprintf.h b/tmk_core/common/mbed/xprintf.h deleted file mode 100644 index e27822d3a..000000000 --- a/tmk_core/common/mbed/xprintf.h +++ /dev/null | |||
| @@ -1,16 +0,0 @@ | |||
| 1 | #ifndef XPRINTF_H | ||
| 2 | #define XPRINTF_H | ||
| 3 | |||
| 4 | //#define xprintf(format, ...) __xprintf(format, ##__VA_ARGS__) | ||
| 5 | |||
| 6 | #ifdef __cplusplus | ||
| 7 | extern "C" { | ||
| 8 | #endif | ||
| 9 | |||
| 10 | int __xprintf(const char *format, ...); | ||
| 11 | |||
| 12 | #ifdef __cplusplus | ||
| 13 | } | ||
| 14 | #endif | ||
| 15 | |||
| 16 | #endif | ||
diff --git a/tmk_core/common/print.h b/tmk_core/common/print.h index 20189838f..04ca55810 100644 --- a/tmk_core/common/print.h +++ b/tmk_core/common/print.h | |||
| @@ -128,38 +128,7 @@ extern "C" | |||
| 128 | 128 | ||
| 129 | # endif /* USER_PRINT / NORMAL PRINT */ | 129 | # endif /* USER_PRINT / NORMAL PRINT */ |
| 130 | 130 | ||
| 131 | # elif defined(__arm__) /* __arm__ */ | 131 | # endif /* __AVR__ / PROTOCOL_CHIBIOS / PROTOCOL_ARM_ATSAM */ |
| 132 | |||
| 133 | # include "mbed/xprintf.h" | ||
| 134 | |||
| 135 | # ifdef USER_PRINT /* USER_PRINT */ | ||
| 136 | |||
| 137 | // Remove normal print defines | ||
| 138 | # define print(s) | ||
| 139 | # define println(s) | ||
| 140 | # define xprintf(fmt, ...) | ||
| 141 | |||
| 142 | // Create user print defines | ||
| 143 | # define uprintf(fmt, ...) __xprintf(fmt, ##__VA_ARGS__) | ||
| 144 | # define uprint(s) xprintf(s) | ||
| 145 | # define uprintln(s) xprintf(s "\r\n") | ||
| 146 | |||
| 147 | # else /* NORMAL PRINT */ | ||
| 148 | |||
| 149 | // Create user & normal print defines | ||
| 150 | # define xprintf(fmt, ...) __xprintf(fmt, ##__VA_ARGS__) | ||
| 151 | # define print(s) xprintf(s) | ||
| 152 | # define println(s) xprintf(s "\r\n") | ||
| 153 | # define uprint(s) print(s) | ||
| 154 | # define uprintln(s) println(s) | ||
| 155 | # define uprintf(fmt, ...) xprintf(fmt, ##__VA_ARGS__) | ||
| 156 | |||
| 157 | # endif /* USER_PRINT / NORMAL PRINT */ | ||
| 158 | |||
| 159 | /* TODO: to select output destinations: UART/USBSerial */ | ||
| 160 | # define print_set_sendchar(func) | ||
| 161 | |||
| 162 | # endif /* __AVR__ / PROTOCOL_CHIBIOS / PROTOCOL_ARM_ATSAM / __arm__ */ | ||
| 163 | 132 | ||
| 164 | // User print disables the normal print messages in the body of QMK/TMK code and | 133 | // User print disables the normal print messages in the body of QMK/TMK code and |
| 165 | // is meant as a lightweight alternative to NOPRINT. Use it when you only want to do | 134 | // is meant as a lightweight alternative to NOPRINT. Use it when you only want to do |
diff --git a/tmk_core/common/wait.h b/tmk_core/common/wait.h index cb1f386a6..c82cd2d65 100644 --- a/tmk_core/common/wait.h +++ b/tmk_core/common/wait.h | |||
| @@ -33,8 +33,6 @@ extern "C" { | |||
| 33 | # include "clks.h" | 33 | # include "clks.h" |
| 34 | # define wait_ms(ms) CLK_delay_ms(ms) | 34 | # define wait_ms(ms) CLK_delay_ms(ms) |
| 35 | # define wait_us(us) CLK_delay_us(us) | 35 | # define wait_us(us) CLK_delay_us(us) |
| 36 | #elif defined(__arm__) | ||
| 37 | # include "wait_api.h" | ||
| 38 | #else // Unit tests | 36 | #else // Unit tests |
| 39 | void wait_ms(uint32_t ms); | 37 | void wait_ms(uint32_t ms); |
| 40 | # define wait_us(us) wait_ms(us / 1000) | 38 | # define wait_us(us) wait_ms(us / 1000) |
diff --git a/tmk_core/ldscript_keymap_avr35.x b/tmk_core/ldscript_keymap_avr35.x deleted file mode 100644 index 6665020af..000000000 --- a/tmk_core/ldscript_keymap_avr35.x +++ /dev/null | |||
| @@ -1,268 +0,0 @@ | |||
| 1 | /* | ||
| 2 | * linker script for configurable keymap | ||
| 3 | * | ||
| 4 | * This adds keymap section which places keymap at fixed address and | ||
| 5 | * is based on binutils-avr ldscripts(/usr/lib/ldscripts/avr5.x). | ||
| 6 | */ | ||
| 7 | OUTPUT_FORMAT("elf32-avr","elf32-avr","elf32-avr") | ||
| 8 | OUTPUT_ARCH(avr:35) | ||
| 9 | MEMORY | ||
| 10 | { | ||
| 11 | /* With keymap section | ||
| 12 | * | ||
| 13 | * Flash Map of ATMega32U4(32KB) | ||
| 14 | * +------------+ 0x0000 | ||
| 15 | * | .vectors | | ||
| 16 | * | .progmem | | ||
| 17 | * | .init0-9 | > text region | ||
| 18 | * | .text | | ||
| 19 | * | .fini9-0 | | ||
| 20 | * | | | ||
| 21 | * |------------| _etext | ||
| 22 | * | .data | | ||
| 23 | * | .bss | > data region | ||
| 24 | * | .noinit | | ||
| 25 | * | | | ||
| 26 | * |------------| 0x6800 | ||
| 27 | * | .keymap | > keymap region(2KB) | ||
| 28 | * |------------| 0x7000 | ||
| 29 | * | bootloader | 4KB | ||
| 30 | * +------------+ 0x7FFF | ||
| 31 | */ | ||
| 32 | text (rx) : ORIGIN = 0, LENGTH = 64K | ||
| 33 | keymap (rw!x) : ORIGIN = 0x6800, LENGTH = 2K | ||
| 34 | data (rw!x) : ORIGIN = 0x800060, LENGTH = 0xffa0 | ||
| 35 | eeprom (rw!x) : ORIGIN = 0x810000, LENGTH = 64K | ||
| 36 | fuse (rw!x) : ORIGIN = 0x820000, LENGTH = 1K | ||
| 37 | lock (rw!x) : ORIGIN = 0x830000, LENGTH = 1K | ||
| 38 | signature (rw!x) : ORIGIN = 0x840000, LENGTH = 1K | ||
| 39 | } | ||
| 40 | SECTIONS | ||
| 41 | { | ||
| 42 | /* Read-only sections, merged into text segment: */ | ||
| 43 | .hash : { *(.hash) } | ||
| 44 | .dynsym : { *(.dynsym) } | ||
| 45 | .dynstr : { *(.dynstr) } | ||
| 46 | .gnu.version : { *(.gnu.version) } | ||
| 47 | .gnu.version_d : { *(.gnu.version_d) } | ||
| 48 | .gnu.version_r : { *(.gnu.version_r) } | ||
| 49 | .rel.init : { *(.rel.init) } | ||
| 50 | .rela.init : { *(.rela.init) } | ||
| 51 | .rel.text : | ||
| 52 | { | ||
| 53 | *(.rel.text) | ||
| 54 | *(.rel.text.*) | ||
| 55 | *(.rel.gnu.linkonce.t*) | ||
| 56 | } | ||
| 57 | .rela.text : | ||
| 58 | { | ||
| 59 | *(.rela.text) | ||
| 60 | *(.rela.text.*) | ||
| 61 | *(.rela.gnu.linkonce.t*) | ||
| 62 | } | ||
| 63 | .rel.fini : { *(.rel.fini) } | ||
| 64 | .rela.fini : { *(.rela.fini) } | ||
| 65 | .rel.rodata : | ||
| 66 | { | ||
| 67 | *(.rel.rodata) | ||
| 68 | *(.rel.rodata.*) | ||
| 69 | *(.rel.gnu.linkonce.r*) | ||
| 70 | } | ||
| 71 | .rela.rodata : | ||
| 72 | { | ||
| 73 | *(.rela.rodata) | ||
| 74 | *(.rela.rodata.*) | ||
| 75 | *(.rela.gnu.linkonce.r*) | ||
| 76 | } | ||
| 77 | .rel.data : | ||
| 78 | { | ||
| 79 | *(.rel.data) | ||
| 80 | *(.rel.data.*) | ||
| 81 | *(.rel.gnu.linkonce.d*) | ||
| 82 | } | ||
| 83 | .rela.data : | ||
| 84 | { | ||
| 85 | *(.rela.data) | ||
| 86 | *(.rela.data.*) | ||
| 87 | *(.rela.gnu.linkonce.d*) | ||
| 88 | } | ||
| 89 | .rel.ctors : { *(.rel.ctors) } | ||
| 90 | .rela.ctors : { *(.rela.ctors) } | ||
| 91 | .rel.dtors : { *(.rel.dtors) } | ||
| 92 | .rela.dtors : { *(.rela.dtors) } | ||
| 93 | .rel.got : { *(.rel.got) } | ||
| 94 | .rela.got : { *(.rela.got) } | ||
| 95 | .rel.bss : { *(.rel.bss) } | ||
| 96 | .rela.bss : { *(.rela.bss) } | ||
| 97 | .rel.plt : { *(.rel.plt) } | ||
| 98 | .rela.plt : { *(.rela.plt) } | ||
| 99 | /* Internal text space or external memory. */ | ||
| 100 | .text : | ||
| 101 | { | ||
| 102 | *(.vectors) | ||
| 103 | KEEP(*(.vectors)) | ||
| 104 | /* For data that needs to reside in the lower 64k of progmem. */ | ||
| 105 | *(.progmem.gcc*) | ||
| 106 | *(.progmem*) | ||
| 107 | . = ALIGN(2); | ||
| 108 | __trampolines_start = . ; | ||
| 109 | /* The jump trampolines for the 16-bit limited relocs will reside here. */ | ||
| 110 | *(.trampolines) | ||
| 111 | *(.trampolines*) | ||
| 112 | __trampolines_end = . ; | ||
| 113 | /* For future tablejump instruction arrays for 3 byte pc devices. | ||
| 114 | We don't relax jump/call instructions within these sections. */ | ||
| 115 | *(.jumptables) | ||
| 116 | *(.jumptables*) | ||
| 117 | /* For code that needs to reside in the lower 128k progmem. */ | ||
| 118 | *(.lowtext) | ||
| 119 | *(.lowtext*) | ||
| 120 | __ctors_start = . ; | ||
| 121 | *(.ctors) | ||
| 122 | __ctors_end = . ; | ||
| 123 | __dtors_start = . ; | ||
| 124 | *(.dtors) | ||
| 125 | __dtors_end = . ; | ||
| 126 | KEEP(SORT(*)(.ctors)) | ||
| 127 | KEEP(SORT(*)(.dtors)) | ||
| 128 | /* From this point on, we don't bother about wether the insns are | ||
| 129 | below or above the 16 bits boundary. */ | ||
| 130 | *(.init0) /* Start here after reset. */ | ||
| 131 | KEEP (*(.init0)) | ||
| 132 | *(.init1) | ||
| 133 | KEEP (*(.init1)) | ||
| 134 | *(.init2) /* Clear __zero_reg__, set up stack pointer. */ | ||
| 135 | KEEP (*(.init2)) | ||
| 136 | *(.init3) | ||
| 137 | KEEP (*(.init3)) | ||
| 138 | *(.init4) /* Initialize data and BSS. */ | ||
| 139 | KEEP (*(.init4)) | ||
| 140 | *(.init5) | ||
| 141 | KEEP (*(.init5)) | ||
| 142 | *(.init6) /* C++ constructors. */ | ||
| 143 | KEEP (*(.init6)) | ||
| 144 | *(.init7) | ||
| 145 | KEEP (*(.init7)) | ||
| 146 | *(.init8) | ||
| 147 | KEEP (*(.init8)) | ||
| 148 | *(.init9) /* Call main(). */ | ||
| 149 | KEEP (*(.init9)) | ||
| 150 | *(.text) | ||
| 151 | . = ALIGN(2); | ||
| 152 | *(.text.*) | ||
| 153 | . = ALIGN(2); | ||
| 154 | *(.fini9) /* _exit() starts here. */ | ||
| 155 | KEEP (*(.fini9)) | ||
| 156 | *(.fini8) | ||
| 157 | KEEP (*(.fini8)) | ||
| 158 | *(.fini7) | ||
| 159 | KEEP (*(.fini7)) | ||
| 160 | *(.fini6) /* C++ destructors. */ | ||
| 161 | KEEP (*(.fini6)) | ||
| 162 | *(.fini5) | ||
| 163 | KEEP (*(.fini5)) | ||
| 164 | *(.fini4) | ||
| 165 | KEEP (*(.fini4)) | ||
| 166 | *(.fini3) | ||
| 167 | KEEP (*(.fini3)) | ||
| 168 | *(.fini2) | ||
| 169 | KEEP (*(.fini2)) | ||
| 170 | *(.fini1) | ||
| 171 | KEEP (*(.fini1)) | ||
| 172 | *(.fini0) /* Infinite loop after program termination. */ | ||
| 173 | KEEP (*(.fini0)) | ||
| 174 | _etext = . ; | ||
| 175 | } > text | ||
| 176 | .data : AT (ADDR (.text) + SIZEOF (.text)) | ||
| 177 | { | ||
| 178 | PROVIDE (__data_start = .) ; | ||
| 179 | *(.data) | ||
| 180 | *(.data*) | ||
| 181 | *(.rodata) /* We need to include .rodata here if gcc is used */ | ||
| 182 | *(.rodata*) /* with -fdata-sections. */ | ||
| 183 | *(.gnu.linkonce.d*) | ||
| 184 | . = ALIGN(2); | ||
| 185 | _edata = . ; | ||
| 186 | PROVIDE (__data_end = .) ; | ||
| 187 | } > data | ||
| 188 | .bss : AT (ADDR (.bss)) | ||
| 189 | { | ||
| 190 | PROVIDE (__bss_start = .) ; | ||
| 191 | *(.bss) | ||
| 192 | *(.bss*) | ||
| 193 | *(COMMON) | ||
| 194 | PROVIDE (__bss_end = .) ; | ||
| 195 | } > data | ||
| 196 | __data_load_start = LOADADDR(.data); | ||
| 197 | __data_load_end = __data_load_start + SIZEOF(.data); | ||
| 198 | /* Global data not cleared after reset. */ | ||
| 199 | .noinit : | ||
| 200 | { | ||
| 201 | PROVIDE (__noinit_start = .) ; | ||
| 202 | *(.noinit*) | ||
| 203 | PROVIDE (__noinit_end = .) ; | ||
| 204 | _end = . ; | ||
| 205 | PROVIDE (__heap_start = .) ; | ||
| 206 | } > data | ||
| 207 | /* keymap region is located at end of flash | ||
| 208 | * .fn_actions Fn actions definitions | ||
| 209 | * .keymaps Mapping layers | ||
| 210 | */ | ||
| 211 | .keymap : | ||
| 212 | { | ||
| 213 | PROVIDE(__keymap_start = .) ; | ||
| 214 | *(.keymap.fn_actions) /* 32*actions = 64bytes */ | ||
| 215 | . = ALIGN(0x40); | ||
| 216 | *(.keymap.keymaps) /* rest of .keymap section */ | ||
| 217 | *(.keymap*) | ||
| 218 | /* . = ALIGN(0x800); */ /* keymap section takes 2KB- */ | ||
| 219 | } > keymap = 0x00 /* zero fill */ | ||
| 220 | .eeprom : | ||
| 221 | { | ||
| 222 | *(.eeprom*) | ||
| 223 | __eeprom_end = . ; | ||
| 224 | } > eeprom | ||
| 225 | .fuse : | ||
| 226 | { | ||
| 227 | KEEP(*(.fuse)) | ||
| 228 | KEEP(*(.lfuse)) | ||
| 229 | KEEP(*(.hfuse)) | ||
| 230 | KEEP(*(.efuse)) | ||
| 231 | } > fuse | ||
| 232 | .lock : | ||
| 233 | { | ||
| 234 | KEEP(*(.lock*)) | ||
| 235 | } > lock | ||
| 236 | .signature : | ||
| 237 | { | ||
| 238 | KEEP(*(.signature*)) | ||
| 239 | } > signature | ||
| 240 | /* Stabs debugging sections. */ | ||
| 241 | .stab 0 : { *(.stab) } | ||
| 242 | .stabstr 0 : { *(.stabstr) } | ||
| 243 | .stab.excl 0 : { *(.stab.excl) } | ||
| 244 | .stab.exclstr 0 : { *(.stab.exclstr) } | ||
| 245 | .stab.index 0 : { *(.stab.index) } | ||
| 246 | .stab.indexstr 0 : { *(.stab.indexstr) } | ||
| 247 | .comment 0 : { *(.comment) } | ||
| 248 | /* DWARF debug sections. | ||
| 249 | Symbols in the DWARF debugging sections are relative to the beginning | ||
| 250 | of the section so we begin them at 0. */ | ||
| 251 | /* DWARF 1 */ | ||
| 252 | .debug 0 : { *(.debug) } | ||
| 253 | .line 0 : { *(.line) } | ||
| 254 | /* GNU DWARF 1 extensions */ | ||
| 255 | .debug_srcinfo 0 : { *(.debug_srcinfo) } | ||
| 256 | .debug_sfnames 0 : { *(.debug_sfnames) } | ||
| 257 | /* DWARF 1.1 and DWARF 2 */ | ||
| 258 | .debug_aranges 0 : { *(.debug_aranges) } | ||
| 259 | .debug_pubnames 0 : { *(.debug_pubnames) } | ||
| 260 | /* DWARF 2 */ | ||
| 261 | .debug_info 0 : { *(.debug_info) *(.gnu.linkonce.wi.*) } | ||
| 262 | .debug_abbrev 0 : { *(.debug_abbrev) } | ||
| 263 | .debug_line 0 : { *(.debug_line) } | ||
| 264 | .debug_frame 0 : { *(.debug_frame) } | ||
| 265 | .debug_str 0 : { *(.debug_str) } | ||
| 266 | .debug_loc 0 : { *(.debug_loc) } | ||
| 267 | .debug_macinfo 0 : { *(.debug_macinfo) } | ||
| 268 | } | ||
diff --git a/tmk_core/ldscript_keymap_avr5.x b/tmk_core/ldscript_keymap_avr5.x deleted file mode 100644 index 9b46e6c36..000000000 --- a/tmk_core/ldscript_keymap_avr5.x +++ /dev/null | |||
| @@ -1,268 +0,0 @@ | |||
| 1 | /* | ||
| 2 | * linker script for configurable keymap | ||
| 3 | * | ||
| 4 | * This adds keymap section which places keymap at fixed address and | ||
| 5 | * is based on binutils-avr ldscripts(/usr/lib/ldscripts/avr5.x). | ||
| 6 | */ | ||
| 7 | OUTPUT_FORMAT("elf32-avr","elf32-avr","elf32-avr") | ||
| 8 | OUTPUT_ARCH(avr:5) | ||
| 9 | MEMORY | ||
| 10 | { | ||
| 11 | /* With keymap section | ||
| 12 | * | ||
| 13 | * Flash Map of ATMega32U4(32KB) | ||
| 14 | * +------------+ 0x0000 | ||
| 15 | * | .vectors | | ||
| 16 | * | .progmem | | ||
| 17 | * | .init0-9 | > text region | ||
| 18 | * | .text | | ||
| 19 | * | .fini9-0 | | ||
| 20 | * | | | ||
| 21 | * |------------| _etext | ||
| 22 | * | .data | | ||
| 23 | * | .bss | > data region | ||
| 24 | * | .noinit | | ||
| 25 | * | | | ||
| 26 | * |------------| 0x6800 | ||
| 27 | * | .keymap | > keymap region(2KB) | ||
| 28 | * |------------| 0x7000 | ||
| 29 | * | bootloader | 4KB | ||
| 30 | * +------------+ 0x7FFF | ||
| 31 | */ | ||
| 32 | text (rx) : ORIGIN = 0, LENGTH = 128K | ||
| 33 | keymap (rw!x) : ORIGIN = 0x6800, LENGTH = 2K | ||
| 34 | data (rw!x) : ORIGIN = 0x800060, LENGTH = 0xffa0 | ||
| 35 | eeprom (rw!x) : ORIGIN = 0x810000, LENGTH = 64K | ||
| 36 | fuse (rw!x) : ORIGIN = 0x820000, LENGTH = 1K | ||
| 37 | lock (rw!x) : ORIGIN = 0x830000, LENGTH = 1K | ||
| 38 | signature (rw!x) : ORIGIN = 0x840000, LENGTH = 1K | ||
| 39 | } | ||
| 40 | SECTIONS | ||
| 41 | { | ||
| 42 | /* Read-only sections, merged into text segment: */ | ||
| 43 | .hash : { *(.hash) } | ||
| 44 | .dynsym : { *(.dynsym) } | ||
| 45 | .dynstr : { *(.dynstr) } | ||
| 46 | .gnu.version : { *(.gnu.version) } | ||
| 47 | .gnu.version_d : { *(.gnu.version_d) } | ||
| 48 | .gnu.version_r : { *(.gnu.version_r) } | ||
| 49 | .rel.init : { *(.rel.init) } | ||
| 50 | .rela.init : { *(.rela.init) } | ||
| 51 | .rel.text : | ||
| 52 | { | ||
| 53 | *(.rel.text) | ||
| 54 | *(.rel.text.*) | ||
| 55 | *(.rel.gnu.linkonce.t*) | ||
| 56 | } | ||
| 57 | .rela.text : | ||
| 58 | { | ||
| 59 | *(.rela.text) | ||
| 60 | *(.rela.text.*) | ||
| 61 | *(.rela.gnu.linkonce.t*) | ||
| 62 | } | ||
| 63 | .rel.fini : { *(.rel.fini) } | ||
| 64 | .rela.fini : { *(.rela.fini) } | ||
| 65 | .rel.rodata : | ||
| 66 | { | ||
| 67 | *(.rel.rodata) | ||
| 68 | *(.rel.rodata.*) | ||
| 69 | *(.rel.gnu.linkonce.r*) | ||
| 70 | } | ||
| 71 | .rela.rodata : | ||
| 72 | { | ||
| 73 | *(.rela.rodata) | ||
| 74 | *(.rela.rodata.*) | ||
| 75 | *(.rela.gnu.linkonce.r*) | ||
| 76 | } | ||
| 77 | .rel.data : | ||
| 78 | { | ||
| 79 | *(.rel.data) | ||
| 80 | *(.rel.data.*) | ||
| 81 | *(.rel.gnu.linkonce.d*) | ||
| 82 | } | ||
| 83 | .rela.data : | ||
| 84 | { | ||
| 85 | *(.rela.data) | ||
| 86 | *(.rela.data.*) | ||
| 87 | *(.rela.gnu.linkonce.d*) | ||
| 88 | } | ||
| 89 | .rel.ctors : { *(.rel.ctors) } | ||
| 90 | .rela.ctors : { *(.rela.ctors) } | ||
| 91 | .rel.dtors : { *(.rel.dtors) } | ||
| 92 | .rela.dtors : { *(.rela.dtors) } | ||
| 93 | .rel.got : { *(.rel.got) } | ||
| 94 | .rela.got : { *(.rela.got) } | ||
| 95 | .rel.bss : { *(.rel.bss) } | ||
| 96 | .rela.bss : { *(.rela.bss) } | ||
| 97 | .rel.plt : { *(.rel.plt) } | ||
| 98 | .rela.plt : { *(.rela.plt) } | ||
| 99 | /* Internal text space or external memory. */ | ||
| 100 | .text : | ||
| 101 | { | ||
| 102 | *(.vectors) | ||
| 103 | KEEP(*(.vectors)) | ||
| 104 | /* For data that needs to reside in the lower 64k of progmem. */ | ||
| 105 | *(.progmem.gcc*) | ||
| 106 | *(.progmem*) | ||
| 107 | . = ALIGN(2); | ||
| 108 | __trampolines_start = . ; | ||
| 109 | /* The jump trampolines for the 16-bit limited relocs will reside here. */ | ||
| 110 | *(.trampolines) | ||
| 111 | *(.trampolines*) | ||
| 112 | __trampolines_end = . ; | ||
| 113 | /* For future tablejump instruction arrays for 3 byte pc devices. | ||
| 114 | We don't relax jump/call instructions within these sections. */ | ||
| 115 | *(.jumptables) | ||
| 116 | *(.jumptables*) | ||
| 117 | /* For code that needs to reside in the lower 128k progmem. */ | ||
| 118 | *(.lowtext) | ||
| 119 | *(.lowtext*) | ||
| 120 | __ctors_start = . ; | ||
| 121 | *(.ctors) | ||
| 122 | __ctors_end = . ; | ||
| 123 | __dtors_start = . ; | ||
| 124 | *(.dtors) | ||
| 125 | __dtors_end = . ; | ||
| 126 | KEEP(SORT(*)(.ctors)) | ||
| 127 | KEEP(SORT(*)(.dtors)) | ||
| 128 | /* From this point on, we don't bother about wether the insns are | ||
| 129 | below or above the 16 bits boundary. */ | ||
| 130 | *(.init0) /* Start here after reset. */ | ||
| 131 | KEEP (*(.init0)) | ||
| 132 | *(.init1) | ||
| 133 | KEEP (*(.init1)) | ||
| 134 | *(.init2) /* Clear __zero_reg__, set up stack pointer. */ | ||
| 135 | KEEP (*(.init2)) | ||
| 136 | *(.init3) | ||
| 137 | KEEP (*(.init3)) | ||
| 138 | *(.init4) /* Initialize data and BSS. */ | ||
| 139 | KEEP (*(.init4)) | ||
| 140 | *(.init5) | ||
| 141 | KEEP (*(.init5)) | ||
| 142 | *(.init6) /* C++ constructors. */ | ||
| 143 | KEEP (*(.init6)) | ||
| 144 | *(.init7) | ||
| 145 | KEEP (*(.init7)) | ||
| 146 | *(.init8) | ||
| 147 | KEEP (*(.init8)) | ||
| 148 | *(.init9) /* Call main(). */ | ||
| 149 | KEEP (*(.init9)) | ||
| 150 | *(.text) | ||
| 151 | . = ALIGN(2); | ||
| 152 | *(.text.*) | ||
| 153 | . = ALIGN(2); | ||
| 154 | *(.fini9) /* _exit() starts here. */ | ||
| 155 | KEEP (*(.fini9)) | ||
| 156 | *(.fini8) | ||
| 157 | KEEP (*(.fini8)) | ||
| 158 | *(.fini7) | ||
| 159 | KEEP (*(.fini7)) | ||
| 160 | *(.fini6) /* C++ destructors. */ | ||
| 161 | KEEP (*(.fini6)) | ||
| 162 | *(.fini5) | ||
| 163 | KEEP (*(.fini5)) | ||
| 164 | *(.fini4) | ||
| 165 | KEEP (*(.fini4)) | ||
| 166 | *(.fini3) | ||
| 167 | KEEP (*(.fini3)) | ||
| 168 | *(.fini2) | ||
| 169 | KEEP (*(.fini2)) | ||
| 170 | *(.fini1) | ||
| 171 | KEEP (*(.fini1)) | ||
| 172 | *(.fini0) /* Infinite loop after program termination. */ | ||
| 173 | KEEP (*(.fini0)) | ||
| 174 | _etext = . ; | ||
| 175 | } > text | ||
| 176 | .data : AT (ADDR (.text) + SIZEOF (.text)) | ||
| 177 | { | ||
| 178 | PROVIDE (__data_start = .) ; | ||
| 179 | *(.data) | ||
| 180 | *(.data*) | ||
| 181 | *(.rodata) /* We need to include .rodata here if gcc is used */ | ||
| 182 | *(.rodata*) /* with -fdata-sections. */ | ||
| 183 | *(.gnu.linkonce.d*) | ||
| 184 | . = ALIGN(2); | ||
| 185 | _edata = . ; | ||
| 186 | PROVIDE (__data_end = .) ; | ||
| 187 | } > data | ||
| 188 | .bss : AT (ADDR (.bss)) | ||
| 189 | { | ||
| 190 | PROVIDE (__bss_start = .) ; | ||
| 191 | *(.bss) | ||
| 192 | *(.bss*) | ||
| 193 | *(COMMON) | ||
| 194 | PROVIDE (__bss_end = .) ; | ||
| 195 | } > data | ||
| 196 | __data_load_start = LOADADDR(.data); | ||
| 197 | __data_load_end = __data_load_start + SIZEOF(.data); | ||
| 198 | /* Global data not cleared after reset. */ | ||
| 199 | .noinit : | ||
| 200 | { | ||
| 201 | PROVIDE (__noinit_start = .) ; | ||
| 202 | *(.noinit*) | ||
| 203 | PROVIDE (__noinit_end = .) ; | ||
| 204 | _end = . ; | ||
| 205 | PROVIDE (__heap_start = .) ; | ||
| 206 | } > data | ||
| 207 | /* keymap region is located at end of flash | ||
| 208 | * .fn_actions Fn actions definitions | ||
| 209 | * .keymaps Mapping layers | ||
| 210 | */ | ||
| 211 | .keymap : | ||
| 212 | { | ||
| 213 | PROVIDE(__keymap_start = .) ; | ||
| 214 | *(.keymap.fn_actions) /* 32*actions = 64bytes */ | ||
| 215 | . = ALIGN(0x40); | ||
| 216 | *(.keymap.keymaps) /* rest of .keymap section */ | ||
| 217 | *(.keymap*) | ||
| 218 | /* . = ALIGN(0x800); */ /* keymap section takes 2KB- */ | ||
| 219 | } > keymap = 0x00 /* zero fill */ | ||
| 220 | .eeprom : | ||
| 221 | { | ||
| 222 | *(.eeprom*) | ||
| 223 | __eeprom_end = . ; | ||
| 224 | } > eeprom | ||
| 225 | .fuse : | ||
| 226 | { | ||
| 227 | KEEP(*(.fuse)) | ||
| 228 | KEEP(*(.lfuse)) | ||
| 229 | KEEP(*(.hfuse)) | ||
| 230 | KEEP(*(.efuse)) | ||
| 231 | } > fuse | ||
| 232 | .lock : | ||
| 233 | { | ||
| 234 | KEEP(*(.lock*)) | ||
| 235 | } > lock | ||
| 236 | .signature : | ||
| 237 | { | ||
| 238 | KEEP(*(.signature*)) | ||
| 239 | } > signature | ||
| 240 | /* Stabs debugging sections. */ | ||
| 241 | .stab 0 : { *(.stab) } | ||
| 242 | .stabstr 0 : { *(.stabstr) } | ||
| 243 | .stab.excl 0 : { *(.stab.excl) } | ||
| 244 | .stab.exclstr 0 : { *(.stab.exclstr) } | ||
| 245 | .stab.index 0 : { *(.stab.index) } | ||
| 246 | .stab.indexstr 0 : { *(.stab.indexstr) } | ||
| 247 | .comment 0 : { *(.comment) } | ||
| 248 | /* DWARF debug sections. | ||
| 249 | Symbols in the DWARF debugging sections are relative to the beginning | ||
| 250 | of the section so we begin them at 0. */ | ||
| 251 | /* DWARF 1 */ | ||
| 252 | .debug 0 : { *(.debug) } | ||
| 253 | .line 0 : { *(.line) } | ||
| 254 | /* GNU DWARF 1 extensions */ | ||
| 255 | .debug_srcinfo 0 : { *(.debug_srcinfo) } | ||
| 256 | .debug_sfnames 0 : { *(.debug_sfnames) } | ||
| 257 | /* DWARF 1.1 and DWARF 2 */ | ||
| 258 | .debug_aranges 0 : { *(.debug_aranges) } | ||
| 259 | .debug_pubnames 0 : { *(.debug_pubnames) } | ||
| 260 | /* DWARF 2 */ | ||
| 261 | .debug_info 0 : { *(.debug_info) *(.gnu.linkonce.wi.*) } | ||
| 262 | .debug_abbrev 0 : { *(.debug_abbrev) } | ||
| 263 | .debug_line 0 : { *(.debug_line) } | ||
| 264 | .debug_frame 0 : { *(.debug_frame) } | ||
| 265 | .debug_str 0 : { *(.debug_str) } | ||
| 266 | .debug_loc 0 : { *(.debug_loc) } | ||
| 267 | .debug_macinfo 0 : { *(.debug_macinfo) } | ||
| 268 | } | ||
diff --git a/tmk_core/protocol.mk b/tmk_core/protocol.mk index 78b9deb29..0c41642b9 100644 --- a/tmk_core/protocol.mk +++ b/tmk_core/protocol.mk | |||
| @@ -1,58 +1,57 @@ | |||
| 1 | PROTOCOL_DIR = protocol | 1 | PROTOCOL_DIR = protocol |
| 2 | 2 | ||
| 3 | 3 | ifeq ($(strip $(PS2_MOUSE_ENABLE)), yes) | |
| 4 | ifdef PS2_MOUSE_ENABLE | ||
| 5 | SRC += $(PROTOCOL_DIR)/ps2_mouse.c | 4 | SRC += $(PROTOCOL_DIR)/ps2_mouse.c |
| 6 | OPT_DEFS += -DPS2_MOUSE_ENABLE | 5 | OPT_DEFS += -DPS2_MOUSE_ENABLE |
| 7 | OPT_DEFS += -DMOUSE_ENABLE | 6 | OPT_DEFS += -DMOUSE_ENABLE |
| 8 | endif | 7 | endif |
| 9 | 8 | ||
| 10 | ifdef PS2_USE_BUSYWAIT | 9 | ifeq ($(strip $(PS2_USE_BUSYWAIT)), yes) |
| 11 | SRC += protocol/ps2_busywait.c | 10 | SRC += protocol/ps2_busywait.c |
| 12 | SRC += protocol/ps2_io_avr.c | 11 | SRC += protocol/ps2_io_avr.c |
| 13 | OPT_DEFS += -DPS2_USE_BUSYWAIT | 12 | OPT_DEFS += -DPS2_USE_BUSYWAIT |
| 14 | endif | 13 | endif |
| 15 | 14 | ||
| 16 | ifdef PS2_USE_INT | 15 | ifeq ($(strip $(PS2_USE_INT)), yes) |
| 17 | SRC += protocol/ps2_interrupt.c | 16 | SRC += protocol/ps2_interrupt.c |
| 18 | SRC += protocol/ps2_io_avr.c | 17 | SRC += protocol/ps2_io_avr.c |
| 19 | OPT_DEFS += -DPS2_USE_INT | 18 | OPT_DEFS += -DPS2_USE_INT |
| 20 | endif | 19 | endif |
| 21 | 20 | ||
| 22 | ifdef PS2_USE_USART | 21 | ifeq ($(strip $(PS2_USE_USART)), yes) |
| 23 | SRC += protocol/ps2_usart.c | 22 | SRC += protocol/ps2_usart.c |
| 24 | SRC += protocol/ps2_io_avr.c | 23 | SRC += protocol/ps2_io_avr.c |
| 25 | OPT_DEFS += -DPS2_USE_USART | 24 | OPT_DEFS += -DPS2_USE_USART |
| 26 | endif | 25 | endif |
| 27 | 26 | ||
| 28 | 27 | ||
| 29 | ifdef SERIAL_MOUSE_MICROSOFT_ENABLE | 28 | ifeq ($(strip $(SERIAL_MOUSE_MICROSOFT_ENABLE)), yes) |
| 30 | SRC += $(PROTOCOL_DIR)/serial_mouse_microsoft.c | 29 | SRC += $(PROTOCOL_DIR)/serial_mouse_microsoft.c |
| 31 | OPT_DEFS += -DSERIAL_MOUSE_ENABLE -DSERIAL_MOUSE_MICROSOFT \ | 30 | OPT_DEFS += -DSERIAL_MOUSE_ENABLE -DSERIAL_MOUSE_MICROSOFT \ |
| 32 | -DMOUSE_ENABLE | 31 | -DMOUSE_ENABLE |
| 33 | endif | 32 | endif |
| 34 | 33 | ||
| 35 | ifdef SERIAL_MOUSE_MOUSESYSTEMS_ENABLE | 34 | ifeq ($(strip $(SERIAL_MOUSE_MOUSESYSTEMS_ENABLE)), yes) |
| 36 | SRC += $(PROTOCOL_DIR)/serial_mouse_mousesystems.c | 35 | SRC += $(PROTOCOL_DIR)/serial_mouse_mousesystems.c |
| 37 | OPT_DEFS += -DSERIAL_MOUSE_ENABLE -DSERIAL_MOUSE_MOUSESYSTEMS \ | 36 | OPT_DEFS += -DSERIAL_MOUSE_ENABLE -DSERIAL_MOUSE_MOUSESYSTEMS \ |
| 38 | -DMOUSE_ENABLE | 37 | -DMOUSE_ENABLE |
| 39 | endif | 38 | endif |
| 40 | 39 | ||
| 41 | ifdef SERIAL_MOUSE_USE_SOFT | 40 | ifeq ($(strip $(SERIAL_MOUSE_USE_SOFT)), yes) |
| 42 | SRC += $(PROTOCOL_DIR)/serial_soft.c | 41 | SRC += $(PROTOCOL_DIR)/serial_soft.c |
| 43 | endif | 42 | endif |
| 44 | 43 | ||
| 45 | ifdef SERIAL_MOUSE_USE_UART | 44 | ifeq ($(strip $(SERIAL_MOUSE_USE_UART)), yes) |
| 46 | SRC += $(PROTOCOL_DIR)/serial_uart.c | 45 | SRC += $(PROTOCOL_DIR)/serial_uart.c |
| 47 | endif | 46 | endif |
| 48 | 47 | ||
| 49 | ifdef ADB_MOUSE_ENABLE | 48 | ifeq ($(strip $(ADB_MOUSE_ENABLE)), yes) |
| 50 | OPT_DEFS += -DADB_MOUSE_ENABLE -DMOUSE_ENABLE | 49 | OPT_DEFS += -DADB_MOUSE_ENABLE -DMOUSE_ENABLE |
| 51 | endif | 50 | endif |
| 52 | 51 | ||
| 53 | ifdef XT_ENABLE | 52 | ifeq ($(strip $(XT_ENABLE)), yes) |
| 54 | SRC += $(PROTOCOL_DIR)/xt_interrupt.c | 53 | SRC += $(PROTOCOL_DIR)/xt_interrupt.c |
| 55 | OPT_DEFS += -DXT_ENABLE | 54 | OPT_DEFS += -DXT_ENABLE |
| 56 | endif | 55 | endif |
| 57 | 56 | ||
| 58 | # Search Path | 57 | # Search Path |
diff --git a/tmk_core/protocol/chibios/main.c b/tmk_core/protocol/chibios/main.c index c304f4d79..4b66bc522 100644 --- a/tmk_core/protocol/chibios/main.c +++ b/tmk_core/protocol/chibios/main.c | |||
| @@ -220,8 +220,5 @@ int main(void) { | |||
| 220 | #ifdef RAW_ENABLE | 220 | #ifdef RAW_ENABLE |
| 221 | raw_hid_task(); | 221 | raw_hid_task(); |
| 222 | #endif | 222 | #endif |
| 223 | #if defined(RGBLIGHT_ANIMATIONS) && defined(RGBLIGHT_ENABLE) | ||
| 224 | rgblight_task(); | ||
| 225 | #endif | ||
| 226 | } | 223 | } |
| 227 | } | 224 | } |
diff --git a/tmk_core/protocol/chibios/usb_main.c b/tmk_core/protocol/chibios/usb_main.c index b90bcd037..8fbe877db 100644 --- a/tmk_core/protocol/chibios/usb_main.c +++ b/tmk_core/protocol/chibios/usb_main.c | |||
| @@ -15,6 +15,16 @@ | |||
| 15 | * GPL v2 or later. | 15 | * GPL v2 or later. |
| 16 | */ | 16 | */ |
| 17 | 17 | ||
| 18 | /* | ||
| 19 | * Implementation notes: | ||
| 20 | * | ||
| 21 | * USBEndpointConfig - Configured using explicit order instead of struct member name. | ||
| 22 | * This is due to ChibiOS hal LLD differences, which is dependent on hardware, | ||
| 23 | * "USBv1" devices have `ep_buffers` and "OTGv1" have `in_multiplier`. | ||
| 24 | * Given `USBv1/hal_usb_lld.h` marks the field as "not currently used" this code file | ||
| 25 | * makes the assumption this is safe to avoid littering with preprocessor directives. | ||
| 26 | */ | ||
| 27 | |||
| 18 | #include "ch.h" | 28 | #include "ch.h" |
| 19 | #include "hal.h" | 29 | #include "hal.h" |
| 20 | 30 | ||
| @@ -98,7 +108,7 @@ static const USBDescriptor *usb_get_descriptor_cb(USBDriver *usbp, uint8_t dtype | |||
| 98 | #ifndef KEYBOARD_SHARED_EP | 108 | #ifndef KEYBOARD_SHARED_EP |
| 99 | /* keyboard endpoint state structure */ | 109 | /* keyboard endpoint state structure */ |
| 100 | static USBInEndpointState kbd_ep_state; | 110 | static USBInEndpointState kbd_ep_state; |
| 101 | /* keyboard endpoint initialization structure (IN) */ | 111 | /* keyboard endpoint initialization structure (IN) - see USBEndpointConfig comment at top of file */ |
| 102 | static const USBEndpointConfig kbd_ep_config = { | 112 | static const USBEndpointConfig kbd_ep_config = { |
| 103 | USB_EP_MODE_TYPE_INTR, /* Interrupt EP */ | 113 | USB_EP_MODE_TYPE_INTR, /* Interrupt EP */ |
| 104 | NULL, /* SETUP packet notification callback */ | 114 | NULL, /* SETUP packet notification callback */ |
| @@ -117,7 +127,7 @@ static const USBEndpointConfig kbd_ep_config = { | |||
| 117 | /* mouse endpoint state structure */ | 127 | /* mouse endpoint state structure */ |
| 118 | static USBInEndpointState mouse_ep_state; | 128 | static USBInEndpointState mouse_ep_state; |
| 119 | 129 | ||
| 120 | /* mouse endpoint initialization structure (IN) */ | 130 | /* mouse endpoint initialization structure (IN) - see USBEndpointConfig comment at top of file */ |
| 121 | static const USBEndpointConfig mouse_ep_config = { | 131 | static const USBEndpointConfig mouse_ep_config = { |
| 122 | USB_EP_MODE_TYPE_INTR, /* Interrupt EP */ | 132 | USB_EP_MODE_TYPE_INTR, /* Interrupt EP */ |
| 123 | NULL, /* SETUP packet notification callback */ | 133 | NULL, /* SETUP packet notification callback */ |
| @@ -136,7 +146,7 @@ static const USBEndpointConfig mouse_ep_config = { | |||
| 136 | /* shared endpoint state structure */ | 146 | /* shared endpoint state structure */ |
| 137 | static USBInEndpointState shared_ep_state; | 147 | static USBInEndpointState shared_ep_state; |
| 138 | 148 | ||
| 139 | /* shared endpoint initialization structure (IN) */ | 149 | /* shared endpoint initialization structure (IN) - see USBEndpointConfig comment at top of file */ |
| 140 | static const USBEndpointConfig shared_ep_config = { | 150 | static const USBEndpointConfig shared_ep_config = { |
| 141 | USB_EP_MODE_TYPE_INTR, /* Interrupt EP */ | 151 | USB_EP_MODE_TYPE_INTR, /* Interrupt EP */ |
| 142 | NULL, /* SETUP packet notification callback */ | 152 | NULL, /* SETUP packet notification callback */ |
| @@ -164,58 +174,62 @@ typedef struct { | |||
| 164 | QMKUSBDriver driver; | 174 | QMKUSBDriver driver; |
| 165 | } usb_driver_config_t; | 175 | } usb_driver_config_t; |
| 166 | 176 | ||
| 167 | #define QMK_USB_DRIVER_CONFIG(stream, notification, fixedsize) \ | 177 | /* Reusable initialization structure - see USBEndpointConfig comment at top of file */ |
| 168 | { \ | 178 | #define QMK_USB_DRIVER_CONFIG(stream, notification, fixedsize) \ |
| 169 | .queue_capacity_in = stream##_IN_CAPACITY, .queue_capacity_out = stream##_OUT_CAPACITY, \ | 179 | { \ |
| 170 | .in_ep_config = {.ep_mode = stream##_IN_MODE, \ | 180 | .queue_capacity_in = stream##_IN_CAPACITY, .queue_capacity_out = stream##_OUT_CAPACITY, \ |
| 171 | .setup_cb = NULL, \ | 181 | .in_ep_config = \ |
| 172 | .in_cb = qmkusbDataTransmitted, \ | 182 | { \ |
| 173 | .out_cb = NULL, \ | 183 | stream##_IN_MODE, /* Interrupt EP */ \ |
| 174 | .in_maxsize = stream##_EPSIZE, \ | 184 | NULL, /* SETUP packet notification callback */ \ |
| 175 | .out_maxsize = 0, /* The pointer to the states will be filled during initialization */ \ | 185 | qmkusbDataTransmitted, /* IN notification callback */ \ |
| 176 | .in_state = NULL, \ | 186 | NULL, /* OUT notification callback */ \ |
| 177 | .out_state = NULL, \ | 187 | stream##_EPSIZE, /* IN maximum packet size */ \ |
| 178 | .ep_buffers = 2, \ | 188 | 0, /* OUT maximum packet size */ \ |
| 179 | .setup_buf = NULL}, \ | 189 | NULL, /* IN Endpoint state */ \ |
| 180 | .out_ep_config = \ | 190 | NULL, /* OUT endpoint state */ \ |
| 181 | { \ | 191 | 2, /* IN multiplier */ \ |
| 182 | .ep_mode = stream##_OUT_MODE, \ | 192 | NULL /* SETUP buffer (not a SETUP endpoint) */ \ |
| 183 | .setup_cb = NULL, \ | 193 | }, \ |
| 184 | .in_cb = NULL, \ | 194 | .out_ep_config = \ |
| 185 | .out_cb = qmkusbDataReceived, \ | 195 | { \ |
| 186 | .in_maxsize = 0, \ | 196 | stream##_OUT_MODE, /* Interrupt EP */ \ |
| 187 | .out_maxsize = stream##_EPSIZE, /* The pointer to the states will be filled during initialization */ \ | 197 | NULL, /* SETUP packet notification callback */ \ |
| 188 | .in_state = NULL, \ | 198 | NULL, /* IN notification callback */ \ |
| 189 | .out_state = NULL, \ | 199 | qmkusbDataReceived, /* OUT notification callback */ \ |
| 190 | .ep_buffers = 2, \ | 200 | 0, /* IN maximum packet size */ \ |
| 191 | .setup_buf = NULL, \ | 201 | stream##_EPSIZE, /* OUT maximum packet size */ \ |
| 192 | }, \ | 202 | NULL, /* IN Endpoint state */ \ |
| 193 | .int_ep_config = \ | 203 | NULL, /* OUT endpoint state */ \ |
| 194 | { \ | 204 | 2, /* IN multiplier */ \ |
| 195 | .ep_mode = USB_EP_MODE_TYPE_INTR, \ | 205 | NULL, /* SETUP buffer (not a SETUP endpoint) */ \ |
| 196 | .setup_cb = NULL, \ | 206 | }, \ |
| 197 | .in_cb = qmkusbInterruptTransmitted, \ | 207 | .int_ep_config = \ |
| 198 | .out_cb = NULL, \ | 208 | { \ |
| 199 | .in_maxsize = CDC_NOTIFICATION_EPSIZE, \ | 209 | USB_EP_MODE_TYPE_INTR, /* Interrupt EP */ \ |
| 200 | .out_maxsize = 0, /* The pointer to the states will be filled during initialization */ \ | 210 | NULL, /* SETUP packet notification callback */ \ |
| 201 | .in_state = NULL, \ | 211 | qmkusbInterruptTransmitted, /* IN notification callback */ \ |
| 202 | .out_state = NULL, \ | 212 | NULL, /* OUT notification callback */ \ |
| 203 | .ep_buffers = 2, \ | 213 | CDC_NOTIFICATION_EPSIZE, /* IN maximum packet size */ \ |
| 204 | .setup_buf = NULL, \ | 214 | 0, /* OUT maximum packet size */ \ |
| 205 | }, \ | 215 | NULL, /* IN Endpoint state */ \ |
| 206 | .config = { \ | 216 | NULL, /* OUT endpoint state */ \ |
| 207 | .usbp = &USB_DRIVER, \ | 217 | 2, /* IN multiplier */ \ |
| 208 | .bulk_in = stream##_IN_EPNUM, \ | 218 | NULL, /* SETUP buffer (not a SETUP endpoint) */ \ |
| 209 | .bulk_out = stream##_OUT_EPNUM, \ | 219 | }, \ |
| 210 | .int_in = notification, \ | 220 | .config = { \ |
| 211 | .in_buffers = stream##_IN_CAPACITY, \ | 221 | .usbp = &USB_DRIVER, \ |
| 212 | .out_buffers = stream##_OUT_CAPACITY, \ | 222 | .bulk_in = stream##_IN_EPNUM, \ |
| 213 | .in_size = stream##_EPSIZE, \ | 223 | .bulk_out = stream##_OUT_EPNUM, \ |
| 214 | .out_size = stream##_EPSIZE, \ | 224 | .int_in = notification, \ |
| 215 | .fixed_size = fixedsize, \ | 225 | .in_buffers = stream##_IN_CAPACITY, \ |
| 216 | .ib = (uint8_t[BQ_BUFFER_SIZE(stream##_IN_CAPACITY, stream##_EPSIZE)]){}, \ | 226 | .out_buffers = stream##_OUT_CAPACITY, \ |
| 217 | .ob = (uint8_t[BQ_BUFFER_SIZE(stream##_OUT_CAPACITY, stream##_EPSIZE)]){}, \ | 227 | .in_size = stream##_EPSIZE, \ |
| 218 | } \ | 228 | .out_size = stream##_EPSIZE, \ |
| 229 | .fixed_size = fixedsize, \ | ||
| 230 | .ib = (uint8_t[BQ_BUFFER_SIZE(stream##_IN_CAPACITY, stream##_EPSIZE)]){}, \ | ||
| 231 | .ob = (uint8_t[BQ_BUFFER_SIZE(stream##_OUT_CAPACITY, stream##_EPSIZE)]){}, \ | ||
| 232 | } \ | ||
| 219 | } | 233 | } |
| 220 | 234 | ||
| 221 | typedef struct { | 235 | typedef struct { |
| @@ -367,7 +381,7 @@ static uint16_t get_hword(uint8_t *p) { | |||
| 367 | * Other Device Required Optional Optional Optional Optional Optional | 381 | * Other Device Required Optional Optional Optional Optional Optional |
| 368 | */ | 382 | */ |
| 369 | 383 | ||
| 370 | #ifdef SHARED_EP_ENABLE | 384 | #if defined(SHARED_EP_ENABLE) && !defined(KEYBOARD_SHARED_EP) |
| 371 | static uint8_t set_report_buf[2] __attribute__((aligned(2))); | 385 | static uint8_t set_report_buf[2] __attribute__((aligned(2))); |
| 372 | static void set_led_transfer_cb(USBDriver *usbp) { | 386 | static void set_led_transfer_cb(USBDriver *usbp) { |
| 373 | if ((set_report_buf[0] == REPORT_ID_KEYBOARD) || (set_report_buf[0] == REPORT_ID_NKRO)) { | 387 | if ((set_report_buf[0] == REPORT_ID_KEYBOARD) || (set_report_buf[0] == REPORT_ID_NKRO)) { |
| @@ -606,10 +620,8 @@ uint8_t keyboard_leds(void) { return (uint8_t)(keyboard_led_stats & 0xFF); } | |||
| 606 | void send_keyboard(report_keyboard_t *report) { | 620 | void send_keyboard(report_keyboard_t *report) { |
| 607 | osalSysLock(); | 621 | osalSysLock(); |
| 608 | if (usbGetDriverStateI(&USB_DRIVER) != USB_ACTIVE) { | 622 | if (usbGetDriverStateI(&USB_DRIVER) != USB_ACTIVE) { |
| 609 | osalSysUnlock(); | 623 | goto unlock; |
| 610 | return; | ||
| 611 | } | 624 | } |
| 612 | osalSysUnlock(); | ||
| 613 | 625 | ||
| 614 | #ifdef NKRO_ENABLE | 626 | #ifdef NKRO_ENABLE |
| 615 | if (keymap_config.nkro && keyboard_protocol) { /* NKRO protocol */ | 627 | if (keymap_config.nkro && keyboard_protocol) { /* NKRO protocol */ |
| @@ -618,28 +630,35 @@ void send_keyboard(report_keyboard_t *report) { | |||
| 618 | * until *after* the packet has been transmitted. I think | 630 | * until *after* the packet has been transmitted. I think |
| 619 | * this is more efficient */ | 631 | * this is more efficient */ |
| 620 | /* busy wait, should be short and not very common */ | 632 | /* busy wait, should be short and not very common */ |
| 621 | osalSysLock(); | ||
| 622 | if (usbGetTransmitStatusI(&USB_DRIVER, SHARED_IN_EPNUM)) { | 633 | if (usbGetTransmitStatusI(&USB_DRIVER, SHARED_IN_EPNUM)) { |
| 623 | /* Need to either suspend, or loop and call unlock/lock during | 634 | /* Need to either suspend, or loop and call unlock/lock during |
| 624 | * every iteration - otherwise the system will remain locked, | 635 | * every iteration - otherwise the system will remain locked, |
| 625 | * no interrupts served, so USB not going through as well. | 636 | * no interrupts served, so USB not going through as well. |
| 626 | * Note: for suspend, need USB_USE_WAIT == TRUE in halconf.h */ | 637 | * Note: for suspend, need USB_USE_WAIT == TRUE in halconf.h */ |
| 627 | osalThreadSuspendS(&(&USB_DRIVER)->epc[SHARED_IN_EPNUM]->in_state->thread); | 638 | osalThreadSuspendS(&(&USB_DRIVER)->epc[SHARED_IN_EPNUM]->in_state->thread); |
| 639 | |||
| 640 | /* after osalThreadSuspendS returns USB status might have changed */ | ||
| 641 | if (usbGetDriverStateI(&USB_DRIVER) != USB_ACTIVE) { | ||
| 642 | goto unlock; | ||
| 643 | } | ||
| 628 | } | 644 | } |
| 629 | usbStartTransmitI(&USB_DRIVER, SHARED_IN_EPNUM, (uint8_t *)report, sizeof(struct nkro_report)); | 645 | usbStartTransmitI(&USB_DRIVER, SHARED_IN_EPNUM, (uint8_t *)report, sizeof(struct nkro_report)); |
| 630 | osalSysUnlock(); | ||
| 631 | } else | 646 | } else |
| 632 | #endif /* NKRO_ENABLE */ | 647 | #endif /* NKRO_ENABLE */ |
| 633 | { /* regular protocol */ | 648 | { /* regular protocol */ |
| 634 | /* need to wait until the previous packet has made it through */ | 649 | /* need to wait until the previous packet has made it through */ |
| 635 | /* busy wait, should be short and not very common */ | 650 | /* busy wait, should be short and not very common */ |
| 636 | osalSysLock(); | ||
| 637 | if (usbGetTransmitStatusI(&USB_DRIVER, KEYBOARD_IN_EPNUM)) { | 651 | if (usbGetTransmitStatusI(&USB_DRIVER, KEYBOARD_IN_EPNUM)) { |
| 638 | /* Need to either suspend, or loop and call unlock/lock during | 652 | /* Need to either suspend, or loop and call unlock/lock during |
| 639 | * every iteration - otherwise the system will remain locked, | 653 | * every iteration - otherwise the system will remain locked, |
| 640 | * no interrupts served, so USB not going through as well. | 654 | * no interrupts served, so USB not going through as well. |
| 641 | * Note: for suspend, need USB_USE_WAIT == TRUE in halconf.h */ | 655 | * Note: for suspend, need USB_USE_WAIT == TRUE in halconf.h */ |
| 642 | osalThreadSuspendS(&(&USB_DRIVER)->epc[KEYBOARD_IN_EPNUM]->in_state->thread); | 656 | osalThreadSuspendS(&(&USB_DRIVER)->epc[KEYBOARD_IN_EPNUM]->in_state->thread); |
| 657 | |||
| 658 | /* after osalThreadSuspendS returns USB status might have changed */ | ||
| 659 | if (usbGetDriverStateI(&USB_DRIVER) != USB_ACTIVE) { | ||
| 660 | goto unlock; | ||
| 661 | } | ||
| 643 | } | 662 | } |
| 644 | uint8_t *data, size; | 663 | uint8_t *data, size; |
| 645 | if (keyboard_protocol) { | 664 | if (keyboard_protocol) { |
| @@ -650,9 +669,11 @@ void send_keyboard(report_keyboard_t *report) { | |||
| 650 | size = 8; | 669 | size = 8; |
| 651 | } | 670 | } |
| 652 | usbStartTransmitI(&USB_DRIVER, KEYBOARD_IN_EPNUM, data, size); | 671 | usbStartTransmitI(&USB_DRIVER, KEYBOARD_IN_EPNUM, data, size); |
| 653 | osalSysUnlock(); | ||
| 654 | } | 672 | } |
| 655 | keyboard_report_sent = *report; | 673 | keyboard_report_sent = *report; |
| 674 | |||
| 675 | unlock: | ||
| 676 | osalSysUnlock(); | ||
| 656 | } | 677 | } |
| 657 | 678 | ||
| 658 | /* --------------------------------------------------------- | 679 | /* --------------------------------------------------------- |
diff --git a/tmk_core/protocol/iwrap/main.c b/tmk_core/protocol/iwrap/main.c index 7ba780ede..6e9b5455b 100644 --- a/tmk_core/protocol/iwrap/main.c +++ b/tmk_core/protocol/iwrap/main.c | |||
| @@ -393,7 +393,7 @@ static uint8_t key2asc(uint8_t key) { | |||
| 393 | case KC_BSLASH: | 393 | case KC_BSLASH: |
| 394 | return '\\'; | 394 | return '\\'; |
| 395 | case KC_NONUS_HASH: | 395 | case KC_NONUS_HASH: |
| 396 | return '\\'; | 396 | return '#'; |
| 397 | case KC_SCOLON: | 397 | case KC_SCOLON: |
| 398 | return ';'; | 398 | return ';'; |
| 399 | case KC_QUOTE: | 399 | case KC_QUOTE: |
diff --git a/tmk_core/protocol/lufa/lufa.c b/tmk_core/protocol/lufa/lufa.c index eb166c828..7d325a9ba 100644 --- a/tmk_core/protocol/lufa/lufa.c +++ b/tmk_core/protocol/lufa/lufa.c | |||
| @@ -914,14 +914,11 @@ void virtser_send(const uint8_t byte) { | |||
| 914 | */ | 914 | */ |
| 915 | static void setup_mcu(void) { | 915 | static void setup_mcu(void) { |
| 916 | /* Disable watchdog if enabled by bootloader/fuses */ | 916 | /* Disable watchdog if enabled by bootloader/fuses */ |
| 917 | MCUSR &= ~(1 << WDRF); | 917 | MCUSR &= ~_BV(WDRF); |
| 918 | wdt_disable(); | 918 | wdt_disable(); |
| 919 | 919 | ||
| 920 | /* Disable clock division */ | 920 | /* Disable clock division */ |
| 921 | // clock_prescale_set(clock_div_1); | 921 | clock_prescale_set(clock_div_1); |
| 922 | |||
| 923 | CLKPR = (1 << CLKPCE); | ||
| 924 | CLKPR = (0 << CLKPS3) | (0 << CLKPS2) | (0 << CLKPS1) | (0 << CLKPS0); | ||
| 925 | } | 922 | } |
| 926 | 923 | ||
| 927 | /** \brief Setup USB | 924 | /** \brief Setup USB |
| @@ -1001,10 +998,6 @@ int main(void) { | |||
| 1001 | MIDI_Device_USBTask(&USB_MIDI_Interface); | 998 | MIDI_Device_USBTask(&USB_MIDI_Interface); |
| 1002 | #endif | 999 | #endif |
| 1003 | 1000 | ||
| 1004 | #if defined(RGBLIGHT_ANIMATIONS) && defined(RGBLIGHT_ENABLE) | ||
| 1005 | rgblight_task(); | ||
| 1006 | #endif | ||
| 1007 | |||
| 1008 | #ifdef MODULE_ADAFRUIT_BLE | 1001 | #ifdef MODULE_ADAFRUIT_BLE |
| 1009 | adafruit_ble_task(); | 1002 | adafruit_ble_task(); |
| 1010 | #endif | 1003 | #endif |
diff --git a/tmk_core/protocol/mbed/HIDKeyboard.cpp b/tmk_core/protocol/mbed/HIDKeyboard.cpp deleted file mode 100644 index dbaf108fa..000000000 --- a/tmk_core/protocol/mbed/HIDKeyboard.cpp +++ /dev/null | |||
| @@ -1,260 +0,0 @@ | |||
| 1 | #include <stdint.h> | ||
| 2 | #include "USBHID.h" | ||
| 3 | #include "USBHID_Types.h" | ||
| 4 | #include "USBDescriptor.h" | ||
| 5 | #include "HIDKeyboard.h" | ||
| 6 | |||
| 7 | #define DEFAULT_CONFIGURATION (1) | ||
| 8 | |||
| 9 | HIDKeyboard::HIDKeyboard(uint16_t vendor_id, uint16_t product_id, uint16_t product_release) : USBDevice(vendor_id, product_id, product_release) { USBDevice::connect(); } | ||
| 10 | |||
| 11 | bool HIDKeyboard::sendReport(report_keyboard_t report) { | ||
| 12 | USBDevice::write(EP1IN, report.raw, sizeof(report), MAX_PACKET_SIZE_EP1); | ||
| 13 | return true; | ||
| 14 | } | ||
| 15 | |||
| 16 | uint8_t HIDKeyboard::leds() { return led_state; } | ||
| 17 | |||
| 18 | bool HIDKeyboard::USBCallback_setConfiguration(uint8_t configuration) { | ||
| 19 | if (configuration != DEFAULT_CONFIGURATION) { | ||
| 20 | return false; | ||
| 21 | } | ||
| 22 | |||
| 23 | // Configure endpoints > 0 | ||
| 24 | addEndpoint(EPINT_IN, MAX_PACKET_SIZE_EPINT); | ||
| 25 | // addEndpoint(EPINT_OUT, MAX_PACKET_SIZE_EPINT); | ||
| 26 | |||
| 27 | // We activate the endpoint to be able to recceive data | ||
| 28 | // readStart(EPINT_OUT, MAX_PACKET_SIZE_EPINT); | ||
| 29 | return true; | ||
| 30 | } | ||
| 31 | |||
| 32 | uint8_t *HIDKeyboard::stringImanufacturerDesc() { | ||
| 33 | static uint8_t stringImanufacturerDescriptor[] = { | ||
| 34 | 0x18, /*bLength*/ | ||
| 35 | STRING_DESCRIPTOR, /*bDescriptorType 0x03*/ | ||
| 36 | 't', | ||
| 37 | 0, | ||
| 38 | 'm', | ||
| 39 | 0, | ||
| 40 | 'k', | ||
| 41 | 0, | ||
| 42 | '-', | ||
| 43 | 0, | ||
| 44 | 'k', | ||
| 45 | 0, | ||
| 46 | 'b', | ||
| 47 | 0, | ||
| 48 | 'd', | ||
| 49 | 0, | ||
| 50 | '.', | ||
| 51 | 0, | ||
| 52 | 'c', | ||
| 53 | 0, | ||
| 54 | 'o', | ||
| 55 | 0, | ||
| 56 | 'm', | ||
| 57 | 0 /*bString iManufacturer*/ | ||
| 58 | }; | ||
| 59 | return stringImanufacturerDescriptor; | ||
| 60 | } | ||
| 61 | |||
| 62 | uint8_t *HIDKeyboard::stringIproductDesc() { | ||
| 63 | static uint8_t stringIproductDescriptor[] = { | ||
| 64 | 0x0a, /*bLength*/ | ||
| 65 | STRING_DESCRIPTOR, /*bDescriptorType 0x03*/ | ||
| 66 | 'm', | ||
| 67 | 0, | ||
| 68 | 'b', | ||
| 69 | 0, | ||
| 70 | 'e', | ||
| 71 | 0, | ||
| 72 | 'd', | ||
| 73 | 0 /*bString iProduct*/ | ||
| 74 | }; | ||
| 75 | return stringIproductDescriptor; | ||
| 76 | } | ||
| 77 | |||
| 78 | uint8_t *HIDKeyboard::stringIserialDesc() { | ||
| 79 | static uint8_t stringIserialDescriptor[] = { | ||
| 80 | 0x04, /*bLength*/ | ||
| 81 | STRING_DESCRIPTOR, /*bDescriptorType 0x03*/ | ||
| 82 | '0', 0 /*bString iSerial*/ | ||
| 83 | }; | ||
| 84 | return stringIserialDescriptor; | ||
| 85 | } | ||
| 86 | |||
| 87 | uint8_t *HIDKeyboard::reportDesc() { | ||
| 88 | static uint8_t reportDescriptor[] = { | ||
| 89 | USAGE_PAGE(1), 0x01, // Generic Desktop | ||
| 90 | USAGE(1), 0x06, // Keyboard | ||
| 91 | COLLECTION(1), 0x01, // Application | ||
| 92 | |||
| 93 | USAGE_PAGE(1), 0x07, // Key Codes | ||
| 94 | USAGE_MINIMUM(1), 0xE0, USAGE_MAXIMUM(1), 0xE7, LOGICAL_MINIMUM(1), 0x00, LOGICAL_MAXIMUM(1), 0x01, REPORT_SIZE(1), 0x01, REPORT_COUNT(1), 0x08, INPUT(1), 0x02, // Data, Variable, Absolute | ||
| 95 | |||
| 96 | REPORT_COUNT(1), 0x01, REPORT_SIZE(1), 0x08, INPUT(1), 0x01, // Constant | ||
| 97 | |||
| 98 | REPORT_COUNT(1), 0x05, REPORT_SIZE(1), 0x01, USAGE_PAGE(1), 0x08, // LEDs | ||
| 99 | USAGE_MINIMUM(1), 0x01, USAGE_MAXIMUM(1), 0x05, OUTPUT(1), 0x02, // Data, Variable, Absolute | ||
| 100 | |||
| 101 | REPORT_COUNT(1), 0x01, REPORT_SIZE(1), 0x03, OUTPUT(1), 0x01, // Constant | ||
| 102 | |||
| 103 | REPORT_COUNT(1), 0x06, REPORT_SIZE(1), 0x08, LOGICAL_MINIMUM(1), 0x00, LOGICAL_MAXIMUM(1), 0xFF, USAGE_PAGE(1), 0x07, // Key Codes | ||
| 104 | USAGE_MINIMUM(1), 0x00, USAGE_MAXIMUM(1), 0xFF, INPUT(1), 0x00, // Data, Array | ||
| 105 | END_COLLECTION(0), | ||
| 106 | }; | ||
| 107 | reportLength = sizeof(reportDescriptor); | ||
| 108 | return reportDescriptor; | ||
| 109 | } | ||
| 110 | |||
| 111 | uint16_t HIDKeyboard::reportDescLength() { | ||
| 112 | reportDesc(); | ||
| 113 | return reportLength; | ||
| 114 | } | ||
| 115 | |||
| 116 | #define TOTAL_DESCRIPTOR_LENGTH ((1 * CONFIGURATION_DESCRIPTOR_LENGTH) + (1 * INTERFACE_DESCRIPTOR_LENGTH) + (1 * HID_DESCRIPTOR_LENGTH) + (1 * ENDPOINT_DESCRIPTOR_LENGTH)) | ||
| 117 | uint8_t *HIDKeyboard::configurationDesc() { | ||
| 118 | static uint8_t configurationDescriptor[] = { | ||
| 119 | CONFIGURATION_DESCRIPTOR_LENGTH, // bLength | ||
| 120 | CONFIGURATION_DESCRIPTOR, // bDescriptorType | ||
| 121 | LSB(TOTAL_DESCRIPTOR_LENGTH), // wTotalLength (LSB) | ||
| 122 | MSB(TOTAL_DESCRIPTOR_LENGTH), // wTotalLength (MSB) | ||
| 123 | 0x01, // bNumInterfaces | ||
| 124 | DEFAULT_CONFIGURATION, // bConfigurationValue | ||
| 125 | 0x00, // iConfiguration | ||
| 126 | C_RESERVED | C_REMOTE_WAKEUP, // bmAttributes | ||
| 127 | C_POWER(100), // bMaxPowerHello World from Mbed | ||
| 128 | |||
| 129 | INTERFACE_DESCRIPTOR_LENGTH, // bLength | ||
| 130 | INTERFACE_DESCRIPTOR, // bDescriptorType | ||
| 131 | 0x00, // bInterfaceNumber | ||
| 132 | 0x00, // bAlternateSetting | ||
| 133 | 0x01, // bNumEndpoints | ||
| 134 | HID_CLASS, // bInterfaceClass | ||
| 135 | 1, // bInterfaceSubClass (boot) | ||
| 136 | 1, // bInterfaceProtocol (keyboard) | ||
| 137 | 0x00, // iInterface | ||
| 138 | |||
| 139 | HID_DESCRIPTOR_LENGTH, // bLength | ||
| 140 | HID_DESCRIPTOR, // bDescriptorType | ||
| 141 | LSB(HID_VERSION_1_11), // bcdHID (LSB) | ||
| 142 | MSB(HID_VERSION_1_11), // bcdHID (MSB) | ||
| 143 | 0x00, // bCountryCode | ||
| 144 | 0x01, // bNumDescriptors | ||
| 145 | REPORT_DESCRIPTOR, // bDescriptorType | ||
| 146 | (uint8_t)(LSB(reportDescLength())), // wDescriptorLength (LSB) | ||
| 147 | (uint8_t)(MSB(reportDescLength())), // wDescriptorLength (MSB) | ||
| 148 | |||
| 149 | ENDPOINT_DESCRIPTOR_LENGTH, // bLength | ||
| 150 | ENDPOINT_DESCRIPTOR, // bDescriptorType | ||
| 151 | PHY_TO_DESC(EP1IN), // bEndpointAddress | ||
| 152 | E_INTERRUPT, // bmAttributes | ||
| 153 | LSB(MAX_PACKET_SIZE_EPINT), // wMaxPacketSize (LSB) | ||
| 154 | MSB(MAX_PACKET_SIZE_EPINT), // wMaxPacketSize (MSB) | ||
| 155 | 1, // bInterval (milliseconds) | ||
| 156 | }; | ||
| 157 | return configurationDescriptor; | ||
| 158 | } | ||
| 159 | |||
| 160 | #if 0 | ||
| 161 | uint8_t * HIDKeyboard::deviceDesc() { | ||
| 162 | static uint8_t deviceDescriptor[] = { | ||
| 163 | DEVICE_DESCRIPTOR_LENGTH, /* bLength */ | ||
| 164 | DEVICE_DESCRIPTOR, /* bDescriptorType */ | ||
| 165 | LSB(USB_VERSION_2_0), /* bcdUSB (LSB) */ | ||
| 166 | MSB(USB_VERSION_2_0), /* bcdUSB (MSB) */ | ||
| 167 | 0x00, /* bDeviceClass */ | ||
| 168 | 0x00, /* bDeviceSubClass */ | ||
| 169 | 0x00, /* bDeviceprotocol */ | ||
| 170 | MAX_PACKET_SIZE_EP0, /* bMaxPacketSize0 */ | ||
| 171 | (uint8_t)(LSB(0xfeed)), /* idVendor (LSB) */ | ||
| 172 | (uint8_t)(MSB(0xfeed)), /* idVendor (MSB) */ | ||
| 173 | (uint8_t)(LSB(0x1bed)), /* idProduct (LSB) */ | ||
| 174 | (uint8_t)(MSB(0x1bed)), /* idProduct (MSB) */ | ||
| 175 | (uint8_t)(LSB(0x0002)), /* bcdDevice (LSB) */ | ||
| 176 | (uint8_t)(MSB(0x0002)), /* bcdDevice (MSB) */ | ||
| 177 | 0, /* iManufacturer */ | ||
| 178 | 0, /* iProduct */ | ||
| 179 | 0, /* iSerialNumber */ | ||
| 180 | 0x01 /* bNumConfigurations */ | ||
| 181 | }; | ||
| 182 | return deviceDescriptor; | ||
| 183 | } | ||
| 184 | #endif | ||
| 185 | |||
| 186 | bool HIDKeyboard::USBCallback_request() { | ||
| 187 | bool success = false; | ||
| 188 | CONTROL_TRANSFER *transfer = getTransferPtr(); | ||
| 189 | uint8_t * hidDescriptor; | ||
| 190 | |||
| 191 | // Process additional standard requests | ||
| 192 | |||
| 193 | if ((transfer->setup.bmRequestType.Type == STANDARD_TYPE)) { | ||
| 194 | switch (transfer->setup.bRequest) { | ||
| 195 | case GET_DESCRIPTOR: | ||
| 196 | switch (DESCRIPTOR_TYPE(transfer->setup.wValue)) { | ||
| 197 | case REPORT_DESCRIPTOR: | ||
| 198 | if ((reportDesc() != NULL) && (reportDescLength() != 0)) { | ||
| 199 | transfer->remaining = reportDescLength(); | ||
| 200 | transfer->ptr = reportDesc(); | ||
| 201 | transfer->direction = DEVICE_TO_HOST; | ||
| 202 | success = true; | ||
| 203 | } | ||
| 204 | break; | ||
| 205 | case HID_DESCRIPTOR: | ||
| 206 | // Find the HID descriptor, after the configuration descriptor | ||
| 207 | hidDescriptor = findDescriptor(HID_DESCRIPTOR); | ||
| 208 | if (hidDescriptor != NULL) { | ||
| 209 | transfer->remaining = HID_DESCRIPTOR_LENGTH; | ||
| 210 | transfer->ptr = hidDescriptor; | ||
| 211 | transfer->direction = DEVICE_TO_HOST; | ||
| 212 | success = true; | ||
| 213 | } | ||
| 214 | break; | ||
| 215 | |||
| 216 | default: | ||
| 217 | break; | ||
| 218 | } | ||
| 219 | break; | ||
| 220 | default: | ||
| 221 | break; | ||
| 222 | } | ||
| 223 | } | ||
| 224 | |||
| 225 | // Process class-specific requests | ||
| 226 | if (transfer->setup.bmRequestType.Type == CLASS_TYPE) { | ||
| 227 | switch (transfer->setup.bRequest) { | ||
| 228 | case SET_REPORT: | ||
| 229 | // LED indicator | ||
| 230 | // TODO: check Interface and Report length? | ||
| 231 | // if (transfer->setup.wIndex == INTERFACE_KEYBOAD) { } | ||
| 232 | // if (transfer->setup.wLength == 1) | ||
| 233 | |||
| 234 | transfer->remaining = 1; | ||
| 235 | // transfer->ptr = ?? what ptr should be set when OUT(not used?) | ||
| 236 | transfer->direction = HOST_TO_DEVICE; | ||
| 237 | transfer->notify = true; /* notify with USBCallback_requestCompleted */ | ||
| 238 | success = true; | ||
| 239 | default: | ||
| 240 | break; | ||
| 241 | } | ||
| 242 | } | ||
| 243 | |||
| 244 | return success; | ||
| 245 | } | ||
| 246 | |||
| 247 | void HIDKeyboard::USBCallback_requestCompleted(uint8_t *buf, uint32_t length) { | ||
| 248 | if (length > 0) { | ||
| 249 | CONTROL_TRANSFER *transfer = getTransferPtr(); | ||
| 250 | if (transfer->setup.bmRequestType.Type == CLASS_TYPE) { | ||
| 251 | switch (transfer->setup.bRequest) { | ||
| 252 | case SET_REPORT: | ||
| 253 | led_state = buf[0]; | ||
| 254 | break; | ||
| 255 | default: | ||
| 256 | break; | ||
| 257 | } | ||
| 258 | } | ||
| 259 | } | ||
| 260 | } | ||
diff --git a/tmk_core/protocol/mbed/HIDKeyboard.h b/tmk_core/protocol/mbed/HIDKeyboard.h deleted file mode 100644 index e8ff10869..000000000 --- a/tmk_core/protocol/mbed/HIDKeyboard.h +++ /dev/null | |||
| @@ -1,32 +0,0 @@ | |||
| 1 | #ifndef HIDKEYBOARD_H | ||
| 2 | |||
| 3 | # include "stdint.h" | ||
| 4 | # include "stdbool.h" | ||
| 5 | # include "USBHID.h" | ||
| 6 | # include "report.h" | ||
| 7 | |||
| 8 | class HIDKeyboard : public USBDevice { | ||
| 9 | public: | ||
| 10 | HIDKeyboard(uint16_t vendor_id = 0xFEED, uint16_t product_id = 0xabed, uint16_t product_release = 0x0001); | ||
| 11 | |||
| 12 | bool sendReport(report_keyboard_t report); | ||
| 13 | uint8_t leds(void); | ||
| 14 | |||
| 15 | protected: | ||
| 16 | uint16_t reportLength; | ||
| 17 | virtual bool USBCallback_setConfiguration(uint8_t configuration); | ||
| 18 | virtual uint8_t* stringImanufacturerDesc(); | ||
| 19 | virtual uint8_t* stringIproductDesc(); | ||
| 20 | virtual uint8_t* stringIserialDesc(); | ||
| 21 | virtual uint16_t reportDescLength(); | ||
| 22 | virtual uint8_t* reportDesc(); | ||
| 23 | virtual uint8_t* configurationDesc(); | ||
| 24 | // virtual uint8_t * deviceDesc(); | ||
| 25 | virtual bool USBCallback_request(); | ||
| 26 | virtual void USBCallback_requestCompleted(uint8_t* buf, uint32_t length); | ||
| 27 | |||
| 28 | private: | ||
| 29 | uint8_t led_state; | ||
| 30 | }; | ||
| 31 | |||
| 32 | #endif | ||
diff --git a/tmk_core/protocol/mbed/mbed_driver.cpp b/tmk_core/protocol/mbed/mbed_driver.cpp deleted file mode 100644 index 83086499c..000000000 --- a/tmk_core/protocol/mbed/mbed_driver.cpp +++ /dev/null | |||
| @@ -1,21 +0,0 @@ | |||
| 1 | #include "HIDKeyboard.h" | ||
| 2 | #include "host.h" | ||
| 3 | #include "host_driver.h" | ||
| 4 | #include "mbed_driver.h" | ||
| 5 | |||
| 6 | HIDKeyboard keyboard; | ||
| 7 | |||
| 8 | /* Host driver */ | ||
| 9 | static uint8_t keyboard_leds(void); | ||
| 10 | static void send_keyboard(report_keyboard_t *report); | ||
| 11 | static void send_mouse(report_mouse_t *report); | ||
| 12 | static void send_system(uint16_t data); | ||
| 13 | static void send_consumer(uint16_t data); | ||
| 14 | |||
| 15 | host_driver_t mbed_driver = {keyboard_leds, send_keyboard, send_mouse, send_system, send_consumer}; | ||
| 16 | |||
| 17 | static uint8_t keyboard_leds(void) { return keyboard.leds(); } | ||
| 18 | static void send_keyboard(report_keyboard_t *report) { keyboard.sendReport(*report); } | ||
| 19 | static void send_mouse(report_mouse_t *report) {} | ||
| 20 | static void send_system(uint16_t data) {} | ||
| 21 | static void send_consumer(uint16_t data) {} | ||
diff --git a/tmk_core/protocol/mbed/mbed_driver.h b/tmk_core/protocol/mbed/mbed_driver.h deleted file mode 100644 index dd1153b43..000000000 --- a/tmk_core/protocol/mbed/mbed_driver.h +++ /dev/null | |||
| @@ -1,3 +0,0 @@ | |||
| 1 | #include "host_driver.h" | ||
| 2 | |||
| 3 | extern host_driver_t mbed_driver; | ||
diff --git a/tmk_core/protocol/ps2_io_mbed.c b/tmk_core/protocol/ps2_io_mbed.c deleted file mode 100644 index 9cec3dfbb..000000000 --- a/tmk_core/protocol/ps2_io_mbed.c +++ /dev/null | |||
| @@ -1,51 +0,0 @@ | |||
| 1 | #include <stdbool.h> | ||
| 2 | #include "ps2_io.h" | ||
| 3 | #include "gpio_api.h" | ||
| 4 | |||
| 5 | static gpio_t clock; | ||
| 6 | static gpio_t data; | ||
| 7 | |||
| 8 | /* | ||
| 9 | * Clock | ||
| 10 | */ | ||
| 11 | void clock_init(void) { | ||
| 12 | gpio_init(&clock, P0_9); | ||
| 13 | gpio_mode(&clock, OpenDrain | PullNone); | ||
| 14 | } | ||
| 15 | |||
| 16 | void clock_lo(void) { | ||
| 17 | gpio_dir(&clock, PIN_OUTPUT); | ||
| 18 | gpio_write(&clock, 0); | ||
| 19 | } | ||
| 20 | void clock_hi(void) { | ||
| 21 | gpio_dir(&clock, PIN_OUTPUT); | ||
| 22 | gpio_write(&clock, 1); | ||
| 23 | } | ||
| 24 | |||
| 25 | bool clock_in(void) { | ||
| 26 | gpio_dir(&clock, PIN_INPUT); | ||
| 27 | return gpio_read(&clock); | ||
| 28 | } | ||
| 29 | |||
| 30 | /* | ||
| 31 | * Data | ||
| 32 | */ | ||
| 33 | void data_init(void) { | ||
| 34 | gpio_init(&data, P0_8); | ||
| 35 | gpio_mode(&data, OpenDrain | PullNone); | ||
| 36 | } | ||
| 37 | |||
| 38 | void data_lo(void) { | ||
| 39 | gpio_dir(&data, PIN_OUTPUT); | ||
| 40 | gpio_write(&data, 0); | ||
| 41 | } | ||
| 42 | |||
| 43 | void data_hi(void) { | ||
| 44 | gpio_dir(&data, PIN_OUTPUT); | ||
| 45 | gpio_write(&data, 1); | ||
| 46 | } | ||
| 47 | |||
| 48 | bool data_in(void) { | ||
| 49 | gpio_dir(&data, PIN_INPUT); | ||
| 50 | return gpio_read(&data); | ||
| 51 | } | ||
diff --git a/tmk_core/protocol/serial_soft.c b/tmk_core/protocol/serial_soft.c index b40907995..8624ef733 100644 --- a/tmk_core/protocol/serial_soft.c +++ b/tmk_core/protocol/serial_soft.c | |||
| @@ -68,7 +68,6 @@ POSSIBILITY OF SUCH DAMAGE. | |||
| 68 | #endif | 68 | #endif |
| 69 | 69 | ||
| 70 | /* debug for signal timing, see debug pin with oscilloscope */ | 70 | /* debug for signal timing, see debug pin with oscilloscope */ |
| 71 | #define SERIAL_SOFT_DEBUG | ||
| 72 | #ifdef SERIAL_SOFT_DEBUG | 71 | #ifdef SERIAL_SOFT_DEBUG |
| 73 | # define SERIAL_SOFT_DEBUG_INIT() (DDRD |= 1 << 7) | 72 | # define SERIAL_SOFT_DEBUG_INIT() (DDRD |= 1 << 7) |
| 74 | # define SERIAL_SOFT_DEBUG_TGL() (PORTD ^= 1 << 7) | 73 | # define SERIAL_SOFT_DEBUG_TGL() (PORTD ^= 1 << 7) |
| @@ -169,7 +168,7 @@ void serial_send(uint8_t data) { | |||
| 169 | /* detect edge of start bit */ | 168 | /* detect edge of start bit */ |
| 170 | ISR(SERIAL_SOFT_RXD_VECT) { | 169 | ISR(SERIAL_SOFT_RXD_VECT) { |
| 171 | SERIAL_SOFT_DEBUG_TGL(); | 170 | SERIAL_SOFT_DEBUG_TGL(); |
| 172 | SERIAL_SOFT_RXD_INT_ENTER() | 171 | SERIAL_SOFT_RXD_INT_ENTER(); |
| 173 | 172 | ||
| 174 | uint8_t data = 0; | 173 | uint8_t data = 0; |
| 175 | 174 | ||
diff --git a/tmk_core/protocol/vusb/main.c b/tmk_core/protocol/vusb/main.c index e6291900e..06dc8ae67 100644 --- a/tmk_core/protocol/vusb/main.c +++ b/tmk_core/protocol/vusb/main.c | |||
| @@ -99,10 +99,6 @@ int main(void) { | |||
| 99 | // To prevent failing to configure NOT scan keyboard during configuration | 99 | // To prevent failing to configure NOT scan keyboard during configuration |
| 100 | if (usbConfiguration && usbInterruptIsReady()) { | 100 | if (usbConfiguration && usbInterruptIsReady()) { |
| 101 | keyboard_task(); | 101 | keyboard_task(); |
| 102 | |||
| 103 | #if defined(RGBLIGHT_ANIMATIONS) && defined(RGBLIGHT_ENABLE) | ||
| 104 | rgblight_task(); | ||
| 105 | #endif | ||
| 106 | } | 102 | } |
| 107 | vusb_transfer_keyboard(); | 103 | vusb_transfer_keyboard(); |
| 108 | } | 104 | } |
diff --git a/tmk_core/protocol/vusb/vusb.c b/tmk_core/protocol/vusb/vusb.c index 72445e00b..e66938445 100644 --- a/tmk_core/protocol/vusb/vusb.c +++ b/tmk_core/protocol/vusb/vusb.c | |||
| @@ -26,7 +26,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
| 26 | #include "debug.h" | 26 | #include "debug.h" |
| 27 | #include "host_driver.h" | 27 | #include "host_driver.h" |
| 28 | #include "vusb.h" | 28 | #include "vusb.h" |
| 29 | #include "bootloader.h" | ||
| 30 | #include <util/delay.h> | 29 | #include <util/delay.h> |
| 31 | 30 | ||
| 32 | static uint8_t vusb_keyboard_leds = 0; | 31 | static uint8_t vusb_keyboard_leds = 0; |
| @@ -145,7 +144,7 @@ static void send_consumer(uint16_t data) { | |||
| 145 | *------------------------------------------------------------------*/ | 144 | *------------------------------------------------------------------*/ |
| 146 | static struct { | 145 | static struct { |
| 147 | uint16_t len; | 146 | uint16_t len; |
| 148 | enum { NONE, BOOTLOADER, SET_LED } kind; | 147 | enum { NONE, SET_LED } kind; |
| 149 | } last_req; | 148 | } last_req; |
| 150 | 149 | ||
| 151 | usbMsgLen_t usbFunctionSetup(uchar data[8]) { | 150 | usbMsgLen_t usbFunctionSetup(uchar data[8]) { |
| @@ -173,11 +172,6 @@ usbMsgLen_t usbFunctionSetup(uchar data[8]) { | |||
| 173 | debug("SET_LED: "); | 172 | debug("SET_LED: "); |
| 174 | last_req.kind = SET_LED; | 173 | last_req.kind = SET_LED; |
| 175 | last_req.len = rq->wLength.word; | 174 | last_req.len = rq->wLength.word; |
| 176 | #ifdef BOOTLOADER_SIZE | ||
| 177 | } else if (rq->wValue.word == 0x0301) { | ||
| 178 | last_req.kind = BOOTLOADER; | ||
| 179 | last_req.len = rq->wLength.word; | ||
| 180 | #endif | ||
| 181 | } | 175 | } |
| 182 | return USB_NO_MSG; // to get data in usbFunctionWrite | 176 | return USB_NO_MSG; // to get data in usbFunctionWrite |
| 183 | } else { | 177 | } else { |
| @@ -204,11 +198,6 @@ uchar usbFunctionWrite(uchar *data, uchar len) { | |||
| 204 | last_req.len = 0; | 198 | last_req.len = 0; |
| 205 | return 1; | 199 | return 1; |
| 206 | break; | 200 | break; |
| 207 | case BOOTLOADER: | ||
| 208 | usbDeviceDisconnect(); | ||
| 209 | bootloader_jump(); | ||
| 210 | return 1; | ||
| 211 | break; | ||
| 212 | case NONE: | 201 | case NONE: |
| 213 | default: | 202 | default: |
| 214 | return -1; | 203 | return -1; |
diff --git a/tmk_core/rules.mk b/tmk_core/rules.mk index 31bce33c3..334ff314b 100644 --- a/tmk_core/rules.mk +++ b/tmk_core/rules.mk | |||
| @@ -397,7 +397,7 @@ ifeq ($(findstring avr-gcc,$(CC)),avr-gcc) | |||
| 397 | SIZE_MARGIN = 1024 | 397 | SIZE_MARGIN = 1024 |
| 398 | 398 | ||
| 399 | check-size: | 399 | check-size: |
| 400 | $(eval MAX_SIZE=$(shell n=`$(CC) -E -mmcu=$(MCU) $(CFLAGS) $(OPT_DEFS) tmk_core/common/avr/bootloader_size.c 2> /dev/null | sed -ne '/^#/n;/^AVR_SIZE:/,$${s/^AVR_SIZE: //;p;}'` && echo $$(($$n)) || echo 0)) | 400 | $(eval MAX_SIZE=$(shell n=`$(CC) -E -mmcu=$(MCU) $(CFLAGS) $(OPT_DEFS) tmk_core/common/avr/bootloader_size.c 2> /dev/null | sed -ne 's/\r//;/^#/n;/^AVR_SIZE:/,$${s/^AVR_SIZE: //;p;}'` && echo $$(($$n)) || echo 0)) |
| 401 | $(eval CURRENT_SIZE=$(shell if [ -f $(BUILD_DIR)/$(TARGET).hex ]; then $(SIZE) --target=$(FORMAT) $(BUILD_DIR)/$(TARGET).hex | $(AWK) 'NR==2 {print $$4}'; else printf 0; fi)) | 401 | $(eval CURRENT_SIZE=$(shell if [ -f $(BUILD_DIR)/$(TARGET).hex ]; then $(SIZE) --target=$(FORMAT) $(BUILD_DIR)/$(TARGET).hex | $(AWK) 'NR==2 {print $$4}'; else printf 0; fi)) |
| 402 | $(eval FREE_SIZE=$(shell expr $(MAX_SIZE) - $(CURRENT_SIZE))) | 402 | $(eval FREE_SIZE=$(shell expr $(MAX_SIZE) - $(CURRENT_SIZE))) |
| 403 | $(eval OVER_SIZE=$(shell expr $(CURRENT_SIZE) - $(MAX_SIZE))) | 403 | $(eval OVER_SIZE=$(shell expr $(CURRENT_SIZE) - $(MAX_SIZE))) |
