aboutsummaryrefslogtreecommitdiff
path: root/tmk_core
diff options
context:
space:
mode:
authorJames Young <18669334+noroadsleft@users.noreply.github.com>2020-11-28 12:02:18 -0800
committerGitHub <noreply@github.com>2020-11-28 12:02:18 -0800
commitc66df1664497546f32662409778731143e45a552 (patch)
treeda73a2d532a27685a31d932b3a44a707d4a3af81 /tmk_core
parent15385d4113414d42bd062c60c9de5df797d3157f (diff)
downloadqmk_firmware-c66df1664497546f32662409778731143e45a552.tar.gz
qmk_firmware-c66df1664497546f32662409778731143e45a552.zip
2020 November 28 Breaking Changes Update (#11053)
* Branch point for 2020 November 28 Breaking Change * Remove matrix_col_t to allow MATRIX_ROWS > 32 (#10183) * Add support for soft serial to ATmega32U2 (#10204) * Change MIDI velocity implementation to allow direct control of velocity value (#9940) * Add ability to build a subset of all keyboards based on platform. * Actually use eeprom_driver_init(). * Make bootloader_jump weak for ChibiOS. (#10417) * Joystick 16-bit support (#10439) * Per-encoder resolutions (#10259) * Share button state from mousekey to pointing_device (#10179) * Add hotfix for chibios keyboards not wake (#10088) * Add advanced/efficient RGB Matrix Indicators (#8564) * Naming change. * Support for STM32 GPIOF,G,H,I,J,K (#10206) * Add milc as a dependency and remove the installed milc (#10563) * ChibiOS upgrade: early init conversions (#10214) * ChibiOS upgrade: configuration file migrator (#9952) * Haptic and solenoid cleanup (#9700) * XD75 cleanup (#10524) * OLED display update interval support (#10388) * Add definition based on currently-selected serial driver. (#10716) * New feature: Retro Tapping per key (#10622) * Allow for modification of output RGB values when using rgblight/rgb_matrix. (#10638) * Add housekeeping task callbacks so that keyboards/keymaps are capable of executing code for each main loop iteration. (#10530) * Rescale both ChibiOS and AVR backlighting. * Reduce Helix keyboard build variation (#8669) * Minor change to behavior allowing display updates to continue between task ticks (#10750) * Some GPIO manipulations in matrix.c change to atomic. (#10491) * qmk cformat (#10767) * [Keyboard] Update the Speedo firmware for v3.0 (#10657) * Maartenwut/Maarten namechange to evyd13/Evy (#10274) * [quantum] combine repeated lines of code (#10837) * Add step sequencer feature (#9703) * aeboards/ext65 refactor (#10820) * Refactor xelus/dawn60 for Rev2 later (#10584) * add DEBUG_MATRIX_SCAN_RATE_ENABLE to common_features.mk (#10824) * [Core] Added `add_oneshot_mods` & `del_oneshot_mods` (#10549) * update chibios os usb for the otg driver (#8893) * Remove HD44780 References, Part 4 (#10735) * [Keyboard] Add Valor FRL TKL (+refactor) (#10512) * Fix cursor position bug in oled_write_raw functions (#10800) * Fixup version.h writing when using SKIP_VERSION=yes (#10972) * Allow for certain code in the codebase assuming length of string. (#10974) * Add AT90USB support for serial.c (#10706) * Auto shift: support repeats and early registration (#9826) * Rename ledmatrix.h to match .c file (#7949) * Split RGB_MATRIX_ENABLE into _ENABLE and _DRIVER (#10231) * Split LED_MATRIX_ENABLE into _ENABLE and _DRIVER (#10840) * Merge point for 2020 Nov 28 Breaking Change
Diffstat (limited to 'tmk_core')
-rw-r--r--tmk_core/chibios.mk10
-rw-r--r--tmk_core/common/action.c66
-rw-r--r--tmk_core/common/action_util.c31
-rw-r--r--tmk_core/common/action_util.h7
-rw-r--r--tmk_core/common/arm_atsam/suspend.c2
-rw-r--r--tmk_core/common/chibios/bootloader.c10
-rw-r--r--tmk_core/common/eeconfig.c13
-rw-r--r--tmk_core/common/keyboard.c21
-rw-r--r--tmk_core/common/keyboard.h3
-rw-r--r--tmk_core/common/matrix.h10
-rw-r--r--tmk_core/common/report.h4
-rw-r--r--tmk_core/protocol/arm_atsam.mk6
-rw-r--r--tmk_core/protocol/arm_atsam/arm_atsam_protocol.h2
-rw-r--r--tmk_core/protocol/arm_atsam/main_arm_atsam.c4
-rw-r--r--tmk_core/protocol/arm_atsam/md_rgb_matrix.c (renamed from tmk_core/protocol/arm_atsam/led_matrix.c)12
-rw-r--r--tmk_core/protocol/arm_atsam/md_rgb_matrix.h (renamed from tmk_core/protocol/arm_atsam/led_matrix.h)2
-rw-r--r--tmk_core/protocol/arm_atsam/md_rgb_matrix_programs.c (renamed from tmk_core/protocol/arm_atsam/led_matrix_programs.c)2
-rw-r--r--tmk_core/protocol/chibios/main.c11
-rw-r--r--tmk_core/protocol/chibios/usb_main.c81
-rw-r--r--tmk_core/protocol/chibios/usb_main.h3
-rw-r--r--tmk_core/protocol/lufa/lufa.c4
-rw-r--r--tmk_core/protocol/usb_descriptor.c15
-rw-r--r--tmk_core/protocol/usb_descriptor.h20
-rw-r--r--tmk_core/protocol/vusb/main.c4
24 files changed, 289 insertions, 54 deletions
diff --git a/tmk_core/chibios.mk b/tmk_core/chibios.mk
index 2bd53f0dc..e53edccee 100644
--- a/tmk_core/chibios.mk
+++ b/tmk_core/chibios.mk
@@ -123,6 +123,8 @@ else ifneq ("$(wildcard $(KEYBOARD_PATH_1)/chconf.h)","")
123 CHCONFDIR = $(KEYBOARD_PATH_1) 123 CHCONFDIR = $(KEYBOARD_PATH_1)
124else ifneq ("$(wildcard $(TOP_DIR)/platforms/chibios/$(BOARD)/configs/chconf.h)","") 124else ifneq ("$(wildcard $(TOP_DIR)/platforms/chibios/$(BOARD)/configs/chconf.h)","")
125 CHCONFDIR = $(TOP_DIR)/platforms/chibios/$(BOARD)/configs 125 CHCONFDIR = $(TOP_DIR)/platforms/chibios/$(BOARD)/configs
126else ifneq ("$(wildcard $(TOP_DIR)/platforms/chibios/common/configs/chconf.h)","")
127 CHCONFDIR = $(TOP_DIR)/platforms/chibios/common/configs
126endif 128endif
127 129
128ifneq ("$(wildcard $(KEYBOARD_PATH_5)/halconf.h)","") 130ifneq ("$(wildcard $(KEYBOARD_PATH_5)/halconf.h)","")
@@ -137,6 +139,8 @@ else ifneq ("$(wildcard $(KEYBOARD_PATH_1)/halconf.h)","")
137 HALCONFDIR = $(KEYBOARD_PATH_1) 139 HALCONFDIR = $(KEYBOARD_PATH_1)
138else ifneq ("$(wildcard $(TOP_DIR)/platforms/chibios/$(BOARD)/configs/halconf.h)","") 140else ifneq ("$(wildcard $(TOP_DIR)/platforms/chibios/$(BOARD)/configs/halconf.h)","")
139 HALCONFDIR = $(TOP_DIR)/platforms/chibios/$(BOARD)/configs 141 HALCONFDIR = $(TOP_DIR)/platforms/chibios/$(BOARD)/configs
142else ifneq ("$(wildcard $(TOP_DIR)/platforms/chibios/common/configs/halconf.h)","")
143 HALCONFDIR = $(TOP_DIR)/platforms/chibios/common/configs
140endif 144endif
141 145
142# HAL-OSAL files (optional). 146# HAL-OSAL files (optional).
@@ -183,8 +187,8 @@ else ifneq ("$(wildcard $(KEYBOARD_PATH_2)/ld/$(MCU_LDSCRIPT).ld)","")
183 LDSCRIPT = $(KEYBOARD_PATH_2)/ld/$(MCU_LDSCRIPT).ld 187 LDSCRIPT = $(KEYBOARD_PATH_2)/ld/$(MCU_LDSCRIPT).ld
184else ifneq ("$(wildcard $(KEYBOARD_PATH_1)/ld/$(MCU_LDSCRIPT).ld)","") 188else ifneq ("$(wildcard $(KEYBOARD_PATH_1)/ld/$(MCU_LDSCRIPT).ld)","")
185 LDSCRIPT = $(KEYBOARD_PATH_1)/ld/$(MCU_LDSCRIPT).ld 189 LDSCRIPT = $(KEYBOARD_PATH_1)/ld/$(MCU_LDSCRIPT).ld
186else ifneq ("$(wildcard $(TOP_DIR)/platforms/chibios/ld/$(MCU_LDSCRIPT).ld)","") 190else ifneq ("$(wildcard $(TOP_DIR)/platforms/chibios/common/ld/$(MCU_LDSCRIPT).ld)","")
187 LDSCRIPT = $(TOP_DIR)/platforms/chibios/ld/$(MCU_LDSCRIPT).ld 191 LDSCRIPT = $(TOP_DIR)/platforms/chibios/common/ld/$(MCU_LDSCRIPT).ld
188else ifneq ("$(wildcard $(STARTUPLD_CONTRIB)/$(MCU_LDSCRIPT).ld)","") 192else ifneq ("$(wildcard $(STARTUPLD_CONTRIB)/$(MCU_LDSCRIPT).ld)","")
189 LDSCRIPT = $(STARTUPLD_CONTRIB)/$(MCU_LDSCRIPT).ld 193 LDSCRIPT = $(STARTUPLD_CONTRIB)/$(MCU_LDSCRIPT).ld
190 USE_CHIBIOS_CONTRIB = yes 194 USE_CHIBIOS_CONTRIB = yes
@@ -209,6 +213,8 @@ CHIBISRC := $(patsubst $(TOP_DIR)/%,%,$(CHIBISRC))
209 213
210EXTRAINCDIRS += $(CHIBIOS)/os/license $(CHIBIOS)/os/oslib/include \ 214EXTRAINCDIRS += $(CHIBIOS)/os/license $(CHIBIOS)/os/oslib/include \
211 $(TOP_DIR)/platforms/chibios/$(BOARD)/configs \ 215 $(TOP_DIR)/platforms/chibios/$(BOARD)/configs \
216 $(TOP_DIR)/platforms/chibios/common/configs \
217 $(HALCONFDIR) $(CHCONFDIR) \
212 $(STARTUPINC) $(KERNINC) $(PORTINC) $(OSALINC) \ 218 $(STARTUPINC) $(KERNINC) $(PORTINC) $(OSALINC) \
213 $(HALINC) $(PLATFORMINC) $(BOARDINC) $(TESTINC) \ 219 $(HALINC) $(PLATFORMINC) $(BOARDINC) $(TESTINC) \
214 $(STREAMSINC) $(CHIBIOS)/os/various $(COMMON_VPATH) 220 $(STREAMSINC) $(CHIBIOS)/os/various $(COMMON_VPATH)
diff --git a/tmk_core/common/action.c b/tmk_core/common/action.c
index ee9aa0df7..77da0139f 100644
--- a/tmk_core/common/action.c
+++ b/tmk_core/common/action.c
@@ -37,9 +37,13 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
37# include "nodebug.h" 37# include "nodebug.h"
38#endif 38#endif
39 39
40#ifdef POINTING_DEVICE_ENABLE
41# include "pointing_device.h"
42#endif
43
40int tp_buttons; 44int tp_buttons;
41 45
42#ifdef RETRO_TAPPING 46#if defined(RETRO_TAPPING) || defined(RETRO_TAPPING_PER_KEY)
43int retro_tapping_counter = 0; 47int retro_tapping_counter = 0;
44#endif 48#endif
45 49
@@ -51,6 +55,10 @@ int retro_tapping_counter = 0;
51__attribute__((weak)) bool get_ignore_mod_tap_interrupt(uint16_t keycode, keyrecord_t *record) { return false; } 55__attribute__((weak)) bool get_ignore_mod_tap_interrupt(uint16_t keycode, keyrecord_t *record) { return false; }
52#endif 56#endif
53 57
58#ifdef RETRO_TAPPING_PER_KEY
59__attribute__((weak)) bool get_retro_tapping(uint16_t keycode, keyrecord_t *record) { return false; }
60#endif
61
54#ifndef TAP_CODE_DELAY 62#ifndef TAP_CODE_DELAY
55# define TAP_CODE_DELAY 0 63# define TAP_CODE_DELAY 0
56#endif 64#endif
@@ -67,7 +75,7 @@ void action_exec(keyevent_t event) {
67 dprint("EVENT: "); 75 dprint("EVENT: ");
68 debug_event(event); 76 debug_event(event);
69 dprintln(); 77 dprintln();
70#ifdef RETRO_TAPPING 78#if defined(RETRO_TAPPING) || defined(RETRO_TAPPING_PER_KEY)
71 retro_tapping_counter++; 79 retro_tapping_counter++;
72#endif 80#endif
73 } 81 }
@@ -220,6 +228,19 @@ void process_record_handler(keyrecord_t *record) {
220 process_action(record, action); 228 process_action(record, action);
221} 229}
222 230
231#if defined(PS2_MOUSE_ENABLE) || defined(POINTING_DEVICE_ENABLE)
232void register_button(bool pressed, enum mouse_buttons button) {
233# ifdef PS2_MOUSE_ENABLE
234 tp_buttons = pressed ? tp_buttons | button : tp_buttons & ~button;
235# endif
236# ifdef POINTING_DEVICE_ENABLE
237 report_mouse_t currentReport = pointing_device_get_report();
238 currentReport.buttons = pressed ? currentReport.buttons | button : currentReport.buttons & ~button;
239 pointing_device_set_report(currentReport);
240# endif
241}
242#endif
243
223/** \brief Take an action and processes it. 244/** \brief Take an action and processes it.
224 * 245 *
225 * FIXME: Needs documentation. 246 * FIXME: Needs documentation.
@@ -404,15 +425,23 @@ void process_action(keyrecord_t *record, action_t action) {
404 if (event.pressed) { 425 if (event.pressed) {
405 mousekey_on(action.key.code); 426 mousekey_on(action.key.code);
406 switch (action.key.code) { 427 switch (action.key.code) {
407# ifdef PS2_MOUSE_ENABLE 428# if defined(PS2_MOUSE_ENABLE) || defined(POINTING_DEVICE_ENABLE)
408 case KC_MS_BTN1: 429 case KC_MS_BTN1:
409 tp_buttons |= (1 << 0); 430 register_button(true, MOUSE_BTN1);
410 break; 431 break;
411 case KC_MS_BTN2: 432 case KC_MS_BTN2:
412 tp_buttons |= (1 << 1); 433 register_button(true, MOUSE_BTN2);
413 break; 434 break;
414 case KC_MS_BTN3: 435 case KC_MS_BTN3:
415 tp_buttons |= (1 << 2); 436 register_button(true, MOUSE_BTN3);
437 break;
438# endif
439# ifdef POINTING_DEVICE_ENABLE
440 case KC_MS_BTN4:
441 register_button(true, MOUSE_BTN4);
442 break;
443 case KC_MS_BTN5:
444 register_button(true, MOUSE_BTN5);
416 break; 445 break;
417# endif 446# endif
418 default: 447 default:
@@ -422,15 +451,23 @@ void process_action(keyrecord_t *record, action_t action) {
422 } else { 451 } else {
423 mousekey_off(action.key.code); 452 mousekey_off(action.key.code);
424 switch (action.key.code) { 453 switch (action.key.code) {
425# ifdef PS2_MOUSE_ENABLE 454# if defined(PS2_MOUSE_ENABLE) || defined(POINTING_DEVICE_ENABLE)
426 case KC_MS_BTN1: 455 case KC_MS_BTN1:
427 tp_buttons &= ~(1 << 0); 456 register_button(false, MOUSE_BTN1);
428 break; 457 break;
429 case KC_MS_BTN2: 458 case KC_MS_BTN2:
430 tp_buttons &= ~(1 << 1); 459 register_button(false, MOUSE_BTN2);
431 break; 460 break;
432 case KC_MS_BTN3: 461 case KC_MS_BTN3:
433 tp_buttons &= ~(1 << 2); 462 register_button(false, MOUSE_BTN3);
463 break;
464# endif
465# ifdef POINTING_DEVICE_ENABLE
466 case KC_MS_BTN4:
467 register_button(false, MOUSE_BTN4);
468 break;
469 case KC_MS_BTN5:
470 register_button(false, MOUSE_BTN5);
434 break; 471 break;
435# endif 472# endif
436 default: 473 default:
@@ -692,20 +729,23 @@ void process_action(keyrecord_t *record, action_t action) {
692#endif 729#endif
693 730
694#ifndef NO_ACTION_TAPPING 731#ifndef NO_ACTION_TAPPING
695# ifdef RETRO_TAPPING 732# if defined(RETRO_TAPPING) || defined(RETRO_TAPPING_PER_KEY)
696 if (!is_tap_action(action)) { 733 if (!is_tap_action(action)) {
697 retro_tapping_counter = 0; 734 retro_tapping_counter = 0;
698 } else { 735 } else {
699 if (event.pressed) { 736 if (event.pressed) {
700 if (tap_count > 0) { 737 if (tap_count > 0) {
701 retro_tapping_counter = 0; 738 retro_tapping_counter = 0;
702 } else {
703 } 739 }
704 } else { 740 } else {
705 if (tap_count > 0) { 741 if (tap_count > 0) {
706 retro_tapping_counter = 0; 742 retro_tapping_counter = 0;
707 } else { 743 } else {
708 if (retro_tapping_counter == 2) { 744 if (
745# ifdef RETRO_TAPPING_PER_KEY
746 get_retro_tapping(get_event_keycode(record->event, false), record) &&
747# endif
748 retro_tapping_counter == 2) {
709 tap_code(action.layer_tap.code); 749 tap_code(action.layer_tap.code);
710 } 750 }
711 retro_tapping_counter = 0; 751 retro_tapping_counter = 0;
diff --git a/tmk_core/common/action_util.c b/tmk_core/common/action_util.c
index fd0e4409f..000503b08 100644
--- a/tmk_core/common/action_util.c
+++ b/tmk_core/common/action_util.c
@@ -290,6 +290,32 @@ void set_macro_mods(uint8_t mods) { macro_mods = mods; }
290void clear_macro_mods(void) { macro_mods = 0; } 290void clear_macro_mods(void) { macro_mods = 0; }
291 291
292#ifndef NO_ACTION_ONESHOT 292#ifndef NO_ACTION_ONESHOT
293/** \brief get oneshot mods
294 *
295 * FIXME: needs doc
296 */
297uint8_t get_oneshot_mods(void) { return oneshot_mods; }
298
299void add_oneshot_mods(uint8_t mods) {
300 if ((oneshot_mods & mods) != mods) {
301# if (defined(ONESHOT_TIMEOUT) && (ONESHOT_TIMEOUT > 0))
302 oneshot_time = timer_read();
303# endif
304 oneshot_mods |= mods;
305 oneshot_mods_changed_kb(mods);
306 }
307}
308
309void del_oneshot_mods(uint8_t mods) {
310 if (oneshot_mods & mods) {
311 oneshot_mods &= ~mods;
312# if (defined(ONESHOT_TIMEOUT) && (ONESHOT_TIMEOUT > 0))
313 oneshot_time = oneshot_mods ? timer_read() : 0;
314# endif
315 oneshot_mods_changed_kb(oneshot_mods);
316 }
317}
318
293/** \brief set oneshot mods 319/** \brief set oneshot mods
294 * 320 *
295 * FIXME: needs doc 321 * FIXME: needs doc
@@ -316,11 +342,6 @@ void clear_oneshot_mods(void) {
316 oneshot_mods_changed_kb(oneshot_mods); 342 oneshot_mods_changed_kb(oneshot_mods);
317 } 343 }
318} 344}
319/** \brief get oneshot mods
320 *
321 * FIXME: needs doc
322 */
323uint8_t get_oneshot_mods(void) { return oneshot_mods; }
324#endif 345#endif
325 346
326/** \brief Called when the one shot modifiers have been changed. 347/** \brief Called when the one shot modifiers have been changed.
diff --git a/tmk_core/common/action_util.h b/tmk_core/common/action_util.h
index 5dd8393da..743ff1406 100644
--- a/tmk_core/common/action_util.h
+++ b/tmk_core/common/action_util.h
@@ -57,12 +57,11 @@ void set_macro_mods(uint8_t mods);
57void clear_macro_mods(void); 57void clear_macro_mods(void);
58 58
59/* oneshot modifier */ 59/* oneshot modifier */
60void set_oneshot_mods(uint8_t mods);
61uint8_t get_oneshot_mods(void); 60uint8_t get_oneshot_mods(void);
61void add_oneshot_mods(uint8_t mods);
62void del_oneshot_mods(uint8_t mods);
63void set_oneshot_mods(uint8_t mods);
62void clear_oneshot_mods(void); 64void clear_oneshot_mods(void);
63void oneshot_toggle(void);
64void oneshot_enable(void);
65void oneshot_disable(void);
66bool has_oneshot_mods_timed_out(void); 65bool has_oneshot_mods_timed_out(void);
67 66
68uint8_t get_oneshot_locked_mods(void); 67uint8_t get_oneshot_locked_mods(void);
diff --git a/tmk_core/common/arm_atsam/suspend.c b/tmk_core/common/arm_atsam/suspend.c
index d1077be4c..e51426128 100644
--- a/tmk_core/common/arm_atsam/suspend.c
+++ b/tmk_core/common/arm_atsam/suspend.c
@@ -1,6 +1,6 @@
1#include "matrix.h" 1#include "matrix.h"
2#include "i2c_master.h" 2#include "i2c_master.h"
3#include "led_matrix.h" 3#include "md_rgb_matrix.h"
4#include "suspend.h" 4#include "suspend.h"
5 5
6/** \brief Suspend idle 6/** \brief Suspend idle
diff --git a/tmk_core/common/chibios/bootloader.c b/tmk_core/common/chibios/bootloader.c
index 7b2cf5c43..f6d016ec9 100644
--- a/tmk_core/common/chibios/bootloader.c
+++ b/tmk_core/common/chibios/bootloader.c
@@ -32,7 +32,7 @@
32 32
33extern uint32_t __ram0_end__; 33extern uint32_t __ram0_end__;
34 34
35void bootloader_jump(void) { 35__attribute__((weak)) void bootloader_jump(void) {
36 // For STM32 MCUs with dual-bank flash, and we're incapable of jumping to the bootloader. The first valid flash 36 // For STM32 MCUs with dual-bank flash, and we're incapable of jumping to the bootloader. The first valid flash
37 // bank is executed unconditionally after a reset, so it doesn't enter DFU unless BOOT0 is high. Instead, we do 37 // bank is executed unconditionally after a reset, so it doesn't enter DFU unless BOOT0 is high. Instead, we do
38 // it with hardware...in this case, we pull a GPIO high/low depending on the configuration, connects 3.3V to 38 // it with hardware...in this case, we pull a GPIO high/low depending on the configuration, connects 3.3V to
@@ -58,7 +58,7 @@ void enter_bootloader_mode_if_requested(void) {} // not needed at all, but if a
58 58
59extern uint32_t __ram0_end__; 59extern uint32_t __ram0_end__;
60 60
61void bootloader_jump(void) { 61__attribute__((weak)) void bootloader_jump(void) {
62 *MAGIC_ADDR = BOOTLOADER_MAGIC; // set magic flag => reset handler will jump into boot loader 62 *MAGIC_ADDR = BOOTLOADER_MAGIC; // set magic flag => reset handler will jump into boot loader
63 NVIC_SystemReset(); 63 NVIC_SystemReset();
64} 64}
@@ -85,8 +85,8 @@ void enter_bootloader_mode_if_requested(void) {
85# if defined(BOOTLOADER_KIIBOHD) 85# if defined(BOOTLOADER_KIIBOHD)
86/* Kiibohd Bootloader (MCHCK and Infinity KB) */ 86/* Kiibohd Bootloader (MCHCK and Infinity KB) */
87# define SCB_AIRCR_VECTKEY_WRITEMAGIC 0x05FA0000 87# define SCB_AIRCR_VECTKEY_WRITEMAGIC 0x05FA0000
88const uint8_t sys_reset_to_loader_magic[] = "\xff\x00\x7fRESET TO LOADER\x7f\x00\xff"; 88const uint8_t sys_reset_to_loader_magic[] = "\xff\x00\x7fRESET TO LOADER\x7f\x00\xff";
89void bootloader_jump(void) { 89__attribute__((weak)) void bootloader_jump(void) {
90 __builtin_memcpy((void *)VBAT, (const void *)sys_reset_to_loader_magic, sizeof(sys_reset_to_loader_magic)); 90 __builtin_memcpy((void *)VBAT, (const void *)sys_reset_to_loader_magic, sizeof(sys_reset_to_loader_magic));
91 // request reset 91 // request reset
92 SCB->AIRCR = SCB_AIRCR_VECTKEY_WRITEMAGIC | SCB_AIRCR_SYSRESETREQ_Msk; 92 SCB->AIRCR = SCB_AIRCR_VECTKEY_WRITEMAGIC | SCB_AIRCR_SYSRESETREQ_Msk;
@@ -95,7 +95,7 @@ void bootloader_jump(void) {
95# else /* defined(BOOTLOADER_KIIBOHD) */ 95# else /* defined(BOOTLOADER_KIIBOHD) */
96/* Default for Kinetis - expecting an ARM Teensy */ 96/* Default for Kinetis - expecting an ARM Teensy */
97# include "wait.h" 97# include "wait.h"
98void bootloader_jump(void) { 98__attribute__((weak)) void bootloader_jump(void) {
99 wait_ms(100); 99 wait_ms(100);
100 __BKPT(0); 100 __BKPT(0);
101} 101}
diff --git a/tmk_core/common/eeconfig.c b/tmk_core/common/eeconfig.c
index fe56c57d1..e15897552 100644
--- a/tmk_core/common/eeconfig.c
+++ b/tmk_core/common/eeconfig.c
@@ -13,6 +13,10 @@
13# include "eeprom_driver.h" 13# include "eeprom_driver.h"
14#endif 14#endif
15 15
16#if defined(HAPTIC_ENABLE)
17# include "haptic.h"
18#endif
19
16/** \brief eeconfig enable 20/** \brief eeconfig enable
17 * 21 *
18 * FIXME: needs doc 22 * FIXME: needs doc
@@ -65,6 +69,15 @@ void eeconfig_init_quantum(void) {
65 eeprom_update_byte(EECONFIG_HANDEDNESS, 0); 69 eeprom_update_byte(EECONFIG_HANDEDNESS, 0);
66#endif 70#endif
67 71
72#if defined(HAPTIC_ENABLE)
73 haptic_reset();
74#else
75 // this is used in case haptic is disabled, but we still want sane defaults
76 // in the haptic configuration eeprom. All zero will trigger a haptic_reset
77 // when a haptic-enabled firmware is loaded onto the keyboard.
78 eeprom_update_dword(EECONFIG_HAPTIC, 0);
79#endif
80
68 eeconfig_init_kb(); 81 eeconfig_init_kb();
69} 82}
70 83
diff --git a/tmk_core/common/keyboard.c b/tmk_core/common/keyboard.c
index b0394af00..8c7bdc8b5 100644
--- a/tmk_core/common/keyboard.c
+++ b/tmk_core/common/keyboard.c
@@ -235,6 +235,20 @@ __attribute__((weak)) bool is_keyboard_left(void) { return true; }
235 */ 235 */
236__attribute__((weak)) bool should_process_keypress(void) { return is_keyboard_master(); } 236__attribute__((weak)) bool should_process_keypress(void) { return is_keyboard_master(); }
237 237
238/** \brief housekeeping_task_kb
239 *
240 * Override this function if you have a need to execute code for every keyboard main loop iteration.
241 * This is specific to keyboard-level functionality.
242 */
243__attribute__((weak)) void housekeeping_task_kb(void) {}
244
245/** \brief housekeeping_task_user
246 *
247 * Override this function if you have a need to execute code for every keyboard main loop iteration.
248 * This is specific to user/keymap-level functionality.
249 */
250__attribute__((weak)) void housekeeping_task_user(void) {}
251
238/** \brief keyboard_init 252/** \brief keyboard_init
239 * 253 *
240 * FIXME: needs doc 254 * FIXME: needs doc
@@ -291,6 +305,10 @@ void keyboard_init(void) {
291 dip_switch_init(); 305 dip_switch_init();
292#endif 306#endif
293 307
308#if defined(DEBUG_MATRIX_SCAN_RATE) && defined(CONSOLE_ENABLE)
309 debug_enable = true;
310#endif
311
294 keyboard_post_init_kb(); /* Always keep this last */ 312 keyboard_post_init_kb(); /* Always keep this last */
295} 313}
296 314
@@ -315,6 +333,9 @@ void keyboard_task(void) {
315 uint8_t keys_processed = 0; 333 uint8_t keys_processed = 0;
316#endif 334#endif
317 335
336 housekeeping_task_kb();
337 housekeeping_task_user();
338
318#if defined(OLED_DRIVER_ENABLE) && !defined(OLED_DISABLE_TIMEOUT) 339#if defined(OLED_DRIVER_ENABLE) && !defined(OLED_DISABLE_TIMEOUT)
319 uint8_t ret = matrix_scan(); 340 uint8_t ret = matrix_scan();
320#else 341#else
diff --git a/tmk_core/common/keyboard.h b/tmk_core/common/keyboard.h
index 79d949089..caa18e7e7 100644
--- a/tmk_core/common/keyboard.h
+++ b/tmk_core/common/keyboard.h
@@ -71,6 +71,9 @@ void keyboard_pre_init_user(void);
71void keyboard_post_init_kb(void); 71void keyboard_post_init_kb(void);
72void keyboard_post_init_user(void); 72void keyboard_post_init_user(void);
73 73
74void housekeeping_task_kb(void);
75void housekeeping_task_user(void);
76
74#ifdef __cplusplus 77#ifdef __cplusplus
75} 78}
76#endif 79#endif
diff --git a/tmk_core/common/matrix.h b/tmk_core/common/matrix.h
index 78506059e..31ec84430 100644
--- a/tmk_core/common/matrix.h
+++ b/tmk_core/common/matrix.h
@@ -30,16 +30,6 @@ typedef uint32_t matrix_row_t;
30# error "MATRIX_COLS: invalid value" 30# error "MATRIX_COLS: invalid value"
31#endif 31#endif
32 32
33#if (MATRIX_ROWS <= 8)
34typedef uint8_t matrix_col_t;
35#elif (MATRIX_ROWS <= 16)
36typedef uint16_t matrix_col_t;
37#elif (MATRIX_ROWS <= 32)
38typedef uint32_t matrix_col_t;
39#else
40# error "MATRIX_ROWS: invalid value"
41#endif
42
43#define MATRIX_ROW_SHIFTER ((matrix_row_t)1) 33#define MATRIX_ROW_SHIFTER ((matrix_row_t)1)
44 34
45#define MATRIX_IS_ON(row, col) (matrix_get_row(row) && (1 << col)) 35#define MATRIX_IS_ON(row, col) (matrix_get_row(row) && (1 << col))
diff --git a/tmk_core/common/report.h b/tmk_core/common/report.h
index 1aa33c998..610addf43 100644
--- a/tmk_core/common/report.h
+++ b/tmk_core/common/report.h
@@ -192,7 +192,11 @@ typedef struct {
192 192
193typedef struct { 193typedef struct {
194#if JOYSTICK_AXES_COUNT > 0 194#if JOYSTICK_AXES_COUNT > 0
195# if JOYSTICK_AXES_RESOLUTION > 8
196 int16_t axes[JOYSTICK_AXES_COUNT];
197# else
195 int8_t axes[JOYSTICK_AXES_COUNT]; 198 int8_t axes[JOYSTICK_AXES_COUNT];
199# endif
196#endif 200#endif
197 201
198#if JOYSTICK_BUTTON_COUNT > 0 202#if JOYSTICK_BUTTON_COUNT > 0
diff --git a/tmk_core/protocol/arm_atsam.mk b/tmk_core/protocol/arm_atsam.mk
index 8d6f724f0..5bb45d658 100644
--- a/tmk_core/protocol/arm_atsam.mk
+++ b/tmk_core/protocol/arm_atsam.mk
@@ -4,9 +4,9 @@ SRC += $(ARM_ATSAM_DIR)/adc.c
4SRC += $(ARM_ATSAM_DIR)/clks.c 4SRC += $(ARM_ATSAM_DIR)/clks.c
5SRC += $(ARM_ATSAM_DIR)/d51_util.c 5SRC += $(ARM_ATSAM_DIR)/d51_util.c
6SRC += $(ARM_ATSAM_DIR)/i2c_master.c 6SRC += $(ARM_ATSAM_DIR)/i2c_master.c
7ifeq ($(RGB_MATRIX_ENABLE),custom) 7ifeq ($(RGB_MATRIX_DRIVER),custom)
8 SRC += $(ARM_ATSAM_DIR)/led_matrix_programs.c 8 SRC += $(ARM_ATSAM_DIR)/md_rgb_matrix_programs.c
9 SRC += $(ARM_ATSAM_DIR)/led_matrix.c 9 SRC += $(ARM_ATSAM_DIR)/md_rgb_matrix.c
10endif 10endif
11SRC += $(ARM_ATSAM_DIR)/main_arm_atsam.c 11SRC += $(ARM_ATSAM_DIR)/main_arm_atsam.c
12SRC += $(ARM_ATSAM_DIR)/spi.c 12SRC += $(ARM_ATSAM_DIR)/spi.c
diff --git a/tmk_core/protocol/arm_atsam/arm_atsam_protocol.h b/tmk_core/protocol/arm_atsam/arm_atsam_protocol.h
index 8cb00b872..d126c66e7 100644
--- a/tmk_core/protocol/arm_atsam/arm_atsam_protocol.h
+++ b/tmk_core/protocol/arm_atsam/arm_atsam_protocol.h
@@ -35,7 +35,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
35 35
36# include "main_arm_atsam.h" 36# include "main_arm_atsam.h"
37# ifdef RGB_MATRIX_ENABLE 37# ifdef RGB_MATRIX_ENABLE
38# include "led_matrix.h" 38# include "md_rgb_matrix.h"
39# include "rgb_matrix.h" 39# include "rgb_matrix.h"
40# endif 40# endif
41# include "issi3733_driver.h" 41# include "issi3733_driver.h"
diff --git a/tmk_core/protocol/arm_atsam/main_arm_atsam.c b/tmk_core/protocol/arm_atsam/main_arm_atsam.c
index e4e79d351..e10be52fb 100644
--- a/tmk_core/protocol/arm_atsam/main_arm_atsam.c
+++ b/tmk_core/protocol/arm_atsam/main_arm_atsam.c
@@ -305,6 +305,10 @@ int main(void) {
305 // dprintf("5v=%u 5vu=%u dlow=%u dhi=%u gca=%u gcd=%u\r\n", v_5v, v_5v_avg, v_5v_avg - V5_LOW, v_5v_avg - V5_HIGH, gcr_actual, gcr_desired); 305 // dprintf("5v=%u 5vu=%u dlow=%u dhi=%u gca=%u gcd=%u\r\n", v_5v, v_5v_avg, v_5v_avg - V5_LOW, v_5v_avg - V5_HIGH, gcr_actual, gcr_desired);
306 } 306 }
307#endif // CONSOLE_ENABLE 307#endif // CONSOLE_ENABLE
308
309 // Run housekeeping
310 housekeeping_task_kb();
311 housekeeping_task_user();
308 } 312 }
309 313
310 return 1; 314 return 1;
diff --git a/tmk_core/protocol/arm_atsam/led_matrix.c b/tmk_core/protocol/arm_atsam/md_rgb_matrix.c
index 69cb03a9f..439aaf8b3 100644
--- a/tmk_core/protocol/arm_atsam/led_matrix.c
+++ b/tmk_core/protocol/arm_atsam/md_rgb_matrix.c
@@ -23,7 +23,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
23 23
24#ifdef USE_MASSDROP_CONFIGURATOR 24#ifdef USE_MASSDROP_CONFIGURATOR
25__attribute__((weak)) led_instruction_t led_instructions[] = {{.end = 1}}; 25__attribute__((weak)) led_instruction_t led_instructions[] = {{.end = 1}};
26static void led_matrix_massdrop_config_override(int i); 26static void md_rgb_matrix_config_override(int i);
27#endif // USE_MASSDROP_CONFIGURATOR 27#endif // USE_MASSDROP_CONFIGURATOR
28 28
29void SERCOM1_0_Handler(void) { 29void SERCOM1_0_Handler(void) {
@@ -188,7 +188,7 @@ void issi3733_prepare_arrays(void) {
188 } 188 }
189} 189}
190 190
191void led_matrix_prepare(void) { 191void md_rgb_matrix_prepare(void) {
192 for (uint8_t i = 0; i < ISSI3733_LED_COUNT; i++) { 192 for (uint8_t i = 0; i < ISSI3733_LED_COUNT; i++) {
193 *led_map[i].rgb.r = 0; 193 *led_map[i].rgb.r = 0;
194 *led_map[i].rgb.g = 0; 194 *led_map[i].rgb.g = 0;
@@ -199,7 +199,7 @@ void led_matrix_prepare(void) {
199void led_set_one(int i, uint8_t r, uint8_t g, uint8_t b) { 199void led_set_one(int i, uint8_t r, uint8_t g, uint8_t b) {
200 if (i < ISSI3733_LED_COUNT) { 200 if (i < ISSI3733_LED_COUNT) {
201#ifdef USE_MASSDROP_CONFIGURATOR 201#ifdef USE_MASSDROP_CONFIGURATOR
202 led_matrix_massdrop_config_override(i); 202 md_rgb_matrix_config_override(i);
203#else 203#else
204 led_buffer[i].r = r; 204 led_buffer[i].r = r;
205 led_buffer[i].g = g; 205 led_buffer[i].g = g;
@@ -219,7 +219,7 @@ void init(void) {
219 219
220 issi3733_prepare_arrays(); 220 issi3733_prepare_arrays();
221 221
222 led_matrix_prepare(); 222 md_rgb_matrix_prepare();
223 223
224 gcr_min_counter = 0; 224 gcr_min_counter = 0;
225 v_5v_cat_hit = 0; 225 v_5v_cat_hit = 0;
@@ -290,7 +290,7 @@ void flush(void) {
290 i2c_led_q_run(); 290 i2c_led_q_run();
291} 291}
292 292
293void led_matrix_indicators(void) { 293void md_rgb_matrix_indicators(void) {
294 uint8_t kbled = keyboard_leds(); 294 uint8_t kbled = keyboard_leds();
295 if (kbled && rgb_matrix_config.enable) { 295 if (kbled && rgb_matrix_config.enable) {
296 for (uint8_t i = 0; i < ISSI3733_LED_COUNT; i++) { 296 for (uint8_t i = 0; i < ISSI3733_LED_COUNT; i++) {
@@ -397,7 +397,7 @@ static void led_run_pattern(led_setup_t* f, float* ro, float* go, float* bo, flo
397 } 397 }
398} 398}
399 399
400static void led_matrix_massdrop_config_override(int i) { 400static void md_rgb_matrix_config_override(int i) {
401 float ro = 0; 401 float ro = 0;
402 float go = 0; 402 float go = 0;
403 float bo = 0; 403 float bo = 0;
diff --git a/tmk_core/protocol/arm_atsam/led_matrix.h b/tmk_core/protocol/arm_atsam/md_rgb_matrix.h
index 8eaa5623b..322b0f99d 100644
--- a/tmk_core/protocol/arm_atsam/led_matrix.h
+++ b/tmk_core/protocol/arm_atsam/md_rgb_matrix.h
@@ -86,7 +86,7 @@ extern uint8_t gcr_actual_last;
86 86
87void gcr_compute(void); 87void gcr_compute(void);
88 88
89void led_matrix_indicators(void); 89void md_rgb_matrix_indicators(void);
90 90
91/*------------------------- Legacy Lighting Support ------------------------*/ 91/*------------------------- Legacy Lighting Support ------------------------*/
92 92
diff --git a/tmk_core/protocol/arm_atsam/led_matrix_programs.c b/tmk_core/protocol/arm_atsam/md_rgb_matrix_programs.c
index 360102ba8..b43008cc5 100644
--- a/tmk_core/protocol/arm_atsam/led_matrix_programs.c
+++ b/tmk_core/protocol/arm_atsam/md_rgb_matrix_programs.c
@@ -17,7 +17,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
17 17
18#ifdef USE_MASSDROP_CONFIGURATOR 18#ifdef USE_MASSDROP_CONFIGURATOR
19 19
20# include "led_matrix.h" 20# include "md_rgb_matrix.h"
21 21
22// Teal <-> Salmon 22// Teal <-> Salmon
23led_setup_t leds_teal_salmon[] = { 23led_setup_t leds_teal_salmon[] = {
diff --git a/tmk_core/protocol/chibios/main.c b/tmk_core/protocol/chibios/main.c
index a0d28f9af..400c0b8f5 100644
--- a/tmk_core/protocol/chibios/main.c
+++ b/tmk_core/protocol/chibios/main.c
@@ -54,6 +54,9 @@
54#ifdef STM32_EEPROM_ENABLE 54#ifdef STM32_EEPROM_ENABLE
55# include "eeprom_stm32.h" 55# include "eeprom_stm32.h"
56#endif 56#endif
57#ifdef EEPROM_DRIVER
58# include "eeprom_driver.h"
59#endif
57#include "suspend.h" 60#include "suspend.h"
58#include "wait.h" 61#include "wait.h"
59 62
@@ -150,6 +153,9 @@ int main(void) {
150#ifdef STM32_EEPROM_ENABLE 153#ifdef STM32_EEPROM_ENABLE
151 EEPROM_Init(); 154 EEPROM_Init();
152#endif 155#endif
156#ifdef EEPROM_DRIVER
157 eeprom_driver_init();
158#endif
153 159
154 // TESTING 160 // TESTING
155 // chThdCreateStatic(waThread1, sizeof(waThread1), NORMALPRIO, Thread1, NULL); 161 // chThdCreateStatic(waThread1, sizeof(waThread1), NORMALPRIO, Thread1, NULL);
@@ -230,6 +236,7 @@ int main(void) {
230 /* Remote wakeup */ 236 /* Remote wakeup */
231 if (suspend_wakeup_condition()) { 237 if (suspend_wakeup_condition()) {
232 usbWakeupHost(&USB_DRIVER); 238 usbWakeupHost(&USB_DRIVER);
239 restart_usb_driver(&USB_DRIVER);
233 } 240 }
234 } 241 }
235 /* Woken up */ 242 /* Woken up */
@@ -258,5 +265,9 @@ int main(void) {
258#ifdef RAW_ENABLE 265#ifdef RAW_ENABLE
259 raw_hid_task(); 266 raw_hid_task();
260#endif 267#endif
268
269 // Run housekeeping
270 housekeeping_task_kb();
271 housekeeping_task_user();
261 } 272 }
262} 273}
diff --git a/tmk_core/protocol/chibios/usb_main.c b/tmk_core/protocol/chibios/usb_main.c
index ae33e86a7..bb4bf6a58 100644
--- a/tmk_core/protocol/chibios/usb_main.c
+++ b/tmk_core/protocol/chibios/usb_main.c
@@ -165,6 +165,19 @@ static const USBEndpointConfig shared_ep_config = {
165}; 165};
166#endif 166#endif
167 167
168#if STM32_USB_USE_OTG1
169typedef struct {
170 size_t queue_capacity_in;
171 size_t queue_capacity_out;
172 USBInEndpointState in_ep_state;
173 USBOutEndpointState out_ep_state;
174 USBInEndpointState int_ep_state;
175 USBEndpointConfig inout_ep_config;
176 USBEndpointConfig int_ep_config;
177 const QMKUSBConfig config;
178 QMKUSBDriver driver;
179} usb_driver_config_t;
180#else
168typedef struct { 181typedef struct {
169 size_t queue_capacity_in; 182 size_t queue_capacity_in;
170 size_t queue_capacity_out; 183 size_t queue_capacity_out;
@@ -177,7 +190,54 @@ typedef struct {
177 const QMKUSBConfig config; 190 const QMKUSBConfig config;
178 QMKUSBDriver driver; 191 QMKUSBDriver driver;
179} usb_driver_config_t; 192} usb_driver_config_t;
193#endif
180 194
195#if STM32_USB_USE_OTG1
196/* Reusable initialization structure - see USBEndpointConfig comment at top of file */
197#define QMK_USB_DRIVER_CONFIG(stream, notification, fixedsize) \
198 { \
199 .queue_capacity_in = stream##_IN_CAPACITY, .queue_capacity_out = stream##_OUT_CAPACITY, \
200 .inout_ep_config = \
201 { \
202 stream##_IN_MODE, /* Interrupt EP */ \
203 NULL, /* SETUP packet notification callback */ \
204 qmkusbDataTransmitted, /* IN notification callback */ \
205 qmkusbDataReceived, /* OUT notification callback */ \
206 stream##_EPSIZE, /* IN maximum packet size */ \
207 stream##_EPSIZE, /* OUT maximum packet size */ \
208 NULL, /* IN Endpoint state */ \
209 NULL, /* OUT endpoint state */ \
210 2, /* IN multiplier */ \
211 NULL /* SETUP buffer (not a SETUP endpoint) */ \
212 }, \
213 .int_ep_config = \
214 { \
215 USB_EP_MODE_TYPE_INTR, /* Interrupt EP */ \
216 NULL, /* SETUP packet notification callback */ \
217 qmkusbInterruptTransmitted, /* IN notification callback */ \
218 NULL, /* OUT notification callback */ \
219 CDC_NOTIFICATION_EPSIZE, /* IN maximum packet size */ \
220 0, /* OUT maximum packet size */ \
221 NULL, /* IN Endpoint state */ \
222 NULL, /* OUT endpoint state */ \
223 2, /* IN multiplier */ \
224 NULL, /* SETUP buffer (not a SETUP endpoint) */ \
225 }, \
226 .config = { \
227 .usbp = &USB_DRIVER, \
228 .bulk_in = stream##_IN_EPNUM, \
229 .bulk_out = stream##_OUT_EPNUM, \
230 .int_in = notification, \
231 .in_buffers = stream##_IN_CAPACITY, \
232 .out_buffers = stream##_OUT_CAPACITY, \
233 .in_size = stream##_EPSIZE, \
234 .out_size = stream##_EPSIZE, \
235 .fixed_size = fixedsize, \
236 .ib = (__attribute__((aligned(4))) uint8_t[BQ_BUFFER_SIZE(stream##_IN_CAPACITY, stream##_EPSIZE)]){}, \
237 .ob = (__attribute__((aligned(4))) uint8_t[BQ_BUFFER_SIZE(stream##_OUT_CAPACITY, stream##_EPSIZE)]){}, \
238 } \
239 }
240#else
181/* Reusable initialization structure - see USBEndpointConfig comment at top of file */ 241/* Reusable initialization structure - see USBEndpointConfig comment at top of file */
182#define QMK_USB_DRIVER_CONFIG(stream, notification, fixedsize) \ 242#define QMK_USB_DRIVER_CONFIG(stream, notification, fixedsize) \
183 { \ 243 { \
@@ -235,6 +295,7 @@ typedef struct {
235 .ob = (__attribute__((aligned(4))) uint8_t[BQ_BUFFER_SIZE(stream##_OUT_CAPACITY, stream##_EPSIZE)]){}, \ 295 .ob = (__attribute__((aligned(4))) uint8_t[BQ_BUFFER_SIZE(stream##_OUT_CAPACITY, stream##_EPSIZE)]){}, \
236 } \ 296 } \
237 } 297 }
298#endif
238 299
239typedef struct { 300typedef struct {
240 union { 301 union {
@@ -327,8 +388,12 @@ static void usb_event_cb(USBDriver *usbp, usbevent_t event) {
327 usbInitEndpointI(usbp, SHARED_IN_EPNUM, &shared_ep_config); 388 usbInitEndpointI(usbp, SHARED_IN_EPNUM, &shared_ep_config);
328#endif 389#endif
329 for (int i = 0; i < NUM_USB_DRIVERS; i++) { 390 for (int i = 0; i < NUM_USB_DRIVERS; i++) {
391 #if STM32_USB_USE_OTG1
392 usbInitEndpointI(usbp, drivers.array[i].config.bulk_in, &drivers.array[i].inout_ep_config);
393 #else
330 usbInitEndpointI(usbp, drivers.array[i].config.bulk_in, &drivers.array[i].in_ep_config); 394 usbInitEndpointI(usbp, drivers.array[i].config.bulk_in, &drivers.array[i].in_ep_config);
331 usbInitEndpointI(usbp, drivers.array[i].config.bulk_out, &drivers.array[i].out_ep_config); 395 usbInitEndpointI(usbp, drivers.array[i].config.bulk_out, &drivers.array[i].out_ep_config);
396 #endif
332 if (drivers.array[i].config.int_in) { 397 if (drivers.array[i].config.int_in) {
333 usbInitEndpointI(usbp, drivers.array[i].config.int_in, &drivers.array[i].int_ep_config); 398 usbInitEndpointI(usbp, drivers.array[i].config.int_in, &drivers.array[i].int_ep_config);
334 } 399 }
@@ -553,12 +618,21 @@ static const USBConfig usbcfg = {
553 */ 618 */
554void init_usb_driver(USBDriver *usbp) { 619void init_usb_driver(USBDriver *usbp) {
555 for (int i = 0; i < NUM_USB_DRIVERS; i++) { 620 for (int i = 0; i < NUM_USB_DRIVERS; i++) {
621 #if STM32_USB_USE_OTG1
622 QMKUSBDriver *driver = &drivers.array[i].driver;
623 drivers.array[i].inout_ep_config.in_state = &drivers.array[i].in_ep_state;
624 drivers.array[i].inout_ep_config.out_state = &drivers.array[i].out_ep_state;
625 drivers.array[i].int_ep_config.in_state = &drivers.array[i].int_ep_state;
626 qmkusbObjectInit(driver, &drivers.array[i].config);
627 qmkusbStart(driver, &drivers.array[i].config);
628 #else
556 QMKUSBDriver *driver = &drivers.array[i].driver; 629 QMKUSBDriver *driver = &drivers.array[i].driver;
557 drivers.array[i].in_ep_config.in_state = &drivers.array[i].in_ep_state; 630 drivers.array[i].in_ep_config.in_state = &drivers.array[i].in_ep_state;
558 drivers.array[i].out_ep_config.out_state = &drivers.array[i].out_ep_state; 631 drivers.array[i].out_ep_config.out_state = &drivers.array[i].out_ep_state;
559 drivers.array[i].int_ep_config.in_state = &drivers.array[i].int_ep_state; 632 drivers.array[i].int_ep_config.in_state = &drivers.array[i].int_ep_state;
560 qmkusbObjectInit(driver, &drivers.array[i].config); 633 qmkusbObjectInit(driver, &drivers.array[i].config);
561 qmkusbStart(driver, &drivers.array[i].config); 634 qmkusbStart(driver, &drivers.array[i].config);
635 #endif
562 } 636 }
563 637
564 /* 638 /*
@@ -574,6 +648,13 @@ void init_usb_driver(USBDriver *usbp) {
574 chVTObjectInit(&keyboard_idle_timer); 648 chVTObjectInit(&keyboard_idle_timer);
575} 649}
576 650
651void restart_usb_driver(USBDriver *usbp) {
652 usbStop(usbp);
653 usbDisconnectBus(usbp);
654 usbStart(usbp, &usbcfg);
655 usbConnectBus(usbp);
656}
657
577/* --------------------------------------------------------- 658/* ---------------------------------------------------------
578 * Keyboard functions 659 * Keyboard functions
579 * --------------------------------------------------------- 660 * ---------------------------------------------------------
diff --git a/tmk_core/protocol/chibios/usb_main.h b/tmk_core/protocol/chibios/usb_main.h
index 94baf9b35..d8813f480 100644
--- a/tmk_core/protocol/chibios/usb_main.h
+++ b/tmk_core/protocol/chibios/usb_main.h
@@ -35,6 +35,9 @@
35/* Initialize the USB driver and bus */ 35/* Initialize the USB driver and bus */
36void init_usb_driver(USBDriver *usbp); 36void init_usb_driver(USBDriver *usbp);
37 37
38/* Restart the USB driver and bus */
39void restart_usb_driver(USBDriver *usbp);
40
38/* --------------- 41/* ---------------
39 * Keyboard header 42 * Keyboard header
40 * --------------- 43 * ---------------
diff --git a/tmk_core/protocol/lufa/lufa.c b/tmk_core/protocol/lufa/lufa.c
index cec004402..878be7d34 100644
--- a/tmk_core/protocol/lufa/lufa.c
+++ b/tmk_core/protocol/lufa/lufa.c
@@ -1104,6 +1104,10 @@ int main(void) {
1104#if !defined(INTERRUPT_CONTROL_ENDPOINT) 1104#if !defined(INTERRUPT_CONTROL_ENDPOINT)
1105 USB_USBTask(); 1105 USB_USBTask();
1106#endif 1106#endif
1107
1108 // Run housekeeping
1109 housekeeping_task_kb();
1110 housekeeping_task_user();
1107 } 1111 }
1108} 1112}
1109 1113
diff --git a/tmk_core/protocol/usb_descriptor.c b/tmk_core/protocol/usb_descriptor.c
index f5d32445d..a0c0d4cdc 100644
--- a/tmk_core/protocol/usb_descriptor.c
+++ b/tmk_core/protocol/usb_descriptor.c
@@ -41,6 +41,10 @@
41#include "usb_descriptor.h" 41#include "usb_descriptor.h"
42#include "usb_descriptor_common.h" 42#include "usb_descriptor_common.h"
43 43
44#ifdef JOYSTICK_ENABLE
45# include "joystick.h"
46#endif
47
44// clang-format off 48// clang-format off
45 49
46/* 50/*
@@ -308,10 +312,17 @@ const USB_Descriptor_HIDReport_Datatype_t PROGMEM JoystickReport[] = {
308 HID_RI_USAGE(8, 0x35), // Rz 312 HID_RI_USAGE(8, 0x35), // Rz
309# endif 313# endif
310# if JOYSTICK_AXES_COUNT >= 1 314# if JOYSTICK_AXES_COUNT >= 1
311 HID_RI_LOGICAL_MINIMUM(8, -127), 315 # if JOYSTICK_AXES_RESOLUTION == 8
312 HID_RI_LOGICAL_MAXIMUM(8, 127), 316 HID_RI_LOGICAL_MINIMUM(8, -JOYSTICK_RESOLUTION),
317 HID_RI_LOGICAL_MAXIMUM(8, JOYSTICK_RESOLUTION),
313 HID_RI_REPORT_COUNT(8, JOYSTICK_AXES_COUNT), 318 HID_RI_REPORT_COUNT(8, JOYSTICK_AXES_COUNT),
314 HID_RI_REPORT_SIZE(8, 0x08), 319 HID_RI_REPORT_SIZE(8, 0x08),
320 # else
321 HID_RI_LOGICAL_MINIMUM(16, -JOYSTICK_RESOLUTION),
322 HID_RI_LOGICAL_MAXIMUM(16, JOYSTICK_RESOLUTION),
323 HID_RI_REPORT_COUNT(8, JOYSTICK_AXES_COUNT),
324 HID_RI_REPORT_SIZE(8, 0x10),
325 # endif
315 HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_ABSOLUTE), 326 HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_ABSOLUTE),
316# endif 327# endif
317 328
diff --git a/tmk_core/protocol/usb_descriptor.h b/tmk_core/protocol/usb_descriptor.h
index 02a4b1ce5..aa8863f43 100644
--- a/tmk_core/protocol/usb_descriptor.h
+++ b/tmk_core/protocol/usb_descriptor.h
@@ -205,7 +205,11 @@ enum usb_endpoints {
205 205
206#ifdef RAW_ENABLE 206#ifdef RAW_ENABLE
207 RAW_IN_EPNUM = NEXT_EPNUM, 207 RAW_IN_EPNUM = NEXT_EPNUM,
208 #if STM32_USB_USE_OTG1
209 #define RAW_OUT_EPNUM RAW_IN_EPNUM
210 #else
208 RAW_OUT_EPNUM = NEXT_EPNUM, 211 RAW_OUT_EPNUM = NEXT_EPNUM,
212 #endif
209#endif 213#endif
210 214
211#ifdef SHARED_EP_ENABLE 215#ifdef SHARED_EP_ENABLE
@@ -219,7 +223,11 @@ enum usb_endpoints {
219 // ChibiOS has enough memory and descriptor to actually enable the endpoint 223 // ChibiOS has enough memory and descriptor to actually enable the endpoint
220 // It could use the same endpoint numbers, as that's supported by ChibiOS 224 // It could use the same endpoint numbers, as that's supported by ChibiOS
221 // But the QMK code currently assumes that the endpoint numbers are different 225 // But the QMK code currently assumes that the endpoint numbers are different
226 #if STM32_USB_USE_OTG1
227 #define CONSOLE_OUT_EPNUM CONSOLE_IN_EPNUM
228 #else
222 CONSOLE_OUT_EPNUM = NEXT_EPNUM, 229 CONSOLE_OUT_EPNUM = NEXT_EPNUM,
230 #endif
223# else 231# else
224# define CONSOLE_OUT_EPNUM CONSOLE_IN_EPNUM 232# define CONSOLE_OUT_EPNUM CONSOLE_IN_EPNUM
225# endif 233# endif
@@ -227,17 +235,29 @@ enum usb_endpoints {
227 235
228#ifdef MIDI_ENABLE 236#ifdef MIDI_ENABLE
229 MIDI_STREAM_IN_EPNUM = NEXT_EPNUM, 237 MIDI_STREAM_IN_EPNUM = NEXT_EPNUM,
238 #if STM32_USB_USE_OTG1
239 #define MIDI_STREAM_OUT_EPNUM MIDI_STREAM_IN_EPNUM
240 #else
230 MIDI_STREAM_OUT_EPNUM = NEXT_EPNUM, 241 MIDI_STREAM_OUT_EPNUM = NEXT_EPNUM,
242 #endif
231#endif 243#endif
232 244
233#ifdef VIRTSER_ENABLE 245#ifdef VIRTSER_ENABLE
234 CDC_NOTIFICATION_EPNUM = NEXT_EPNUM, 246 CDC_NOTIFICATION_EPNUM = NEXT_EPNUM,
235 CDC_IN_EPNUM = NEXT_EPNUM, 247 CDC_IN_EPNUM = NEXT_EPNUM,
248 #if STM32_USB_USE_OTG1
249 #define CDC_OUT_EPNUM CDC_IN_EPNUM
250 #else
236 CDC_OUT_EPNUM = NEXT_EPNUM, 251 CDC_OUT_EPNUM = NEXT_EPNUM,
252 #endif
237#endif 253#endif
238#ifdef JOYSTICK_ENABLE 254#ifdef JOYSTICK_ENABLE
239 JOYSTICK_IN_EPNUM = NEXT_EPNUM, 255 JOYSTICK_IN_EPNUM = NEXT_EPNUM,
256 #if STM32_USB_USE_OTG1
257 JOYSTICK_OUT_EPNUM = JOYSTICK_IN_EPNUM,
258 #else
240 JOYSTICK_OUT_EPNUM = NEXT_EPNUM, 259 JOYSTICK_OUT_EPNUM = NEXT_EPNUM,
260 #endif
241#endif 261#endif
242}; 262};
243 263
diff --git a/tmk_core/protocol/vusb/main.c b/tmk_core/protocol/vusb/main.c
index a57df5ce0..0e3447d92 100644
--- a/tmk_core/protocol/vusb/main.c
+++ b/tmk_core/protocol/vusb/main.c
@@ -153,6 +153,10 @@ int main(void) {
153 console_task(); 153 console_task();
154 } 154 }
155#endif 155#endif
156
157 // Run housekeeping
158 housekeeping_task_kb();
159 housekeeping_task_user();
156 } else if (suspend_wakeup_condition()) { 160 } else if (suspend_wakeup_condition()) {
157 usb_remote_wakeup(); 161 usb_remote_wakeup();
158 } 162 }