aboutsummaryrefslogtreecommitdiff
path: root/tmk_core
diff options
context:
space:
mode:
Diffstat (limited to 'tmk_core')
-rw-r--r--tmk_core/avr.mk2
-rw-r--r--tmk_core/chibios.mk6
-rw-r--r--tmk_core/common/arm_atsam/_timer.h19
-rw-r--r--tmk_core/common/avr/_timer.h19
-rw-r--r--tmk_core/common/avr/gpio.h15
-rw-r--r--tmk_core/common/chibios/_timer.h19
-rw-r--r--tmk_core/common/chibios/bootloader.c2
-rw-r--r--tmk_core/common/chibios/gpio.h16
-rw-r--r--tmk_core/common/host.c14
-rw-r--r--tmk_core/common/keyboard.c24
-rw-r--r--tmk_core/common/timer.h24
-rw-r--r--tmk_core/protocol/chibios/usb_main.c34
-rw-r--r--tmk_core/protocol/lufa/lufa.c34
-rw-r--r--tmk_core/protocol/usb_descriptor.c2
-rw-r--r--tmk_core/protocol/vusb/vusb.c3
-rw-r--r--tmk_core/rules.mk2
16 files changed, 187 insertions, 48 deletions
diff --git a/tmk_core/avr.mk b/tmk_core/avr.mk
index eb934ffe6..b787e77ec 100644
--- a/tmk_core/avr.mk
+++ b/tmk_core/avr.mk
@@ -301,7 +301,7 @@ ifneq ($(strip $(BOOTLOADER)), qmk-dfu)
301endif 301endif
302 make -C lib/lufa/Bootloaders/DFU/ clean 302 make -C lib/lufa/Bootloaders/DFU/ clean
303 $(QMK_BIN) generate-dfu-header --quiet --keyboard $(KEYBOARD) --output lib/lufa/Bootloaders/DFU/Keyboard.h 303 $(QMK_BIN) generate-dfu-header --quiet --keyboard $(KEYBOARD) --output lib/lufa/Bootloaders/DFU/Keyboard.h
304 $(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)) 304 $(eval MAX_SIZE=$(shell n=`$(CC) -E -mmcu=$(MCU) -D__ASSEMBLER__ $(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))
305 $(eval PROGRAM_SIZE_KB=$(shell n=`expr $(MAX_SIZE) / 1024` && echo $$(($$n)) || echo 0)) 305 $(eval PROGRAM_SIZE_KB=$(shell n=`expr $(MAX_SIZE) / 1024` && echo $$(($$n)) || echo 0))
306 $(eval BOOT_SECTION_SIZE_KB=$(shell n=`expr $(BOOTLOADER_SIZE) / 1024` && echo $$(($$n)) || echo 0)) 306 $(eval BOOT_SECTION_SIZE_KB=$(shell n=`expr $(BOOTLOADER_SIZE) / 1024` && echo $$(($$n)) || echo 0))
307 $(eval FLASH_SIZE_KB=$(shell n=`expr $(PROGRAM_SIZE_KB) + $(BOOT_SECTION_SIZE_KB)` && echo $$(($$n)) || echo 0)) 307 $(eval FLASH_SIZE_KB=$(shell n=`expr $(PROGRAM_SIZE_KB) + $(BOOT_SECTION_SIZE_KB)` && echo $$(($$n)) || echo 0))
diff --git a/tmk_core/chibios.mk b/tmk_core/chibios.mk
index 97299b7d3..7eda36046 100644
--- a/tmk_core/chibios.mk
+++ b/tmk_core/chibios.mk
@@ -390,8 +390,10 @@ ifndef TEENSY_LOADER_CLI
390 endif 390 endif
391endif 391endif
392 392
393TEENSY_LOADER_CLI_MCU ?= $(MCU_LDSCRIPT)
394
393define EXEC_TEENSY 395define EXEC_TEENSY
394 $(TEENSY_LOADER_CLI) -mmcu=$(MCU_LDSCRIPT) -w -v $(BUILD_DIR)/$(TARGET).hex 396 $(TEENSY_LOADER_CLI) -mmcu=$(TEENSY_LOADER_CLI_MCU) -w -v $(BUILD_DIR)/$(TARGET).hex
395endef 397endef
396 398
397teensy: $(BUILD_DIR)/$(TARGET).hex cpfirmware sizeafter 399teensy: $(BUILD_DIR)/$(TARGET).hex cpfirmware sizeafter
@@ -408,6 +410,8 @@ else ifeq ($(strip $(BOOTLOADER)),kiibohd)
408 $(call EXEC_DFU_UTIL) 410 $(call EXEC_DFU_UTIL)
409else ifeq ($(strip $(MCU_FAMILY)),KINETIS) 411else ifeq ($(strip $(MCU_FAMILY)),KINETIS)
410 $(call EXEC_TEENSY) 412 $(call EXEC_TEENSY)
413else ifeq ($(strip $(MCU_FAMILY)),MIMXRT1062)
414 $(call EXEC_TEENSY)
411else ifeq ($(strip $(MCU_FAMILY)),STM32) 415else ifeq ($(strip $(MCU_FAMILY)),STM32)
412 $(call EXEC_DFU_UTIL) 416 $(call EXEC_DFU_UTIL)
413else 417else
diff --git a/tmk_core/common/arm_atsam/_timer.h b/tmk_core/common/arm_atsam/_timer.h
new file mode 100644
index 000000000..77402b612
--- /dev/null
+++ b/tmk_core/common/arm_atsam/_timer.h
@@ -0,0 +1,19 @@
1/* Copyright 2021 Simon Arlott
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// The platform is 32-bit, so prefer 32-bit timers to avoid overflow
19#define FAST_TIMER_T_SIZE 32
diff --git a/tmk_core/common/avr/_timer.h b/tmk_core/common/avr/_timer.h
new file mode 100644
index 000000000..b81e0f68b
--- /dev/null
+++ b/tmk_core/common/avr/_timer.h
@@ -0,0 +1,19 @@
1/* Copyright 2021 Simon Arlott
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// The platform is 8-bit, so prefer 16-bit timers to reduce code size
19#define FAST_TIMER_T_SIZE 16
diff --git a/tmk_core/common/avr/gpio.h b/tmk_core/common/avr/gpio.h
index 231556c29..e9be68491 100644
--- a/tmk_core/common/avr/gpio.h
+++ b/tmk_core/common/avr/gpio.h
@@ -20,6 +20,8 @@
20 20
21typedef uint8_t pin_t; 21typedef uint8_t pin_t;
22 22
23/* Operation of GPIO by pin. */
24
23#define setPinInput(pin) (DDRx_ADDRESS(pin) &= ~_BV((pin)&0xF), PORTx_ADDRESS(pin) &= ~_BV((pin)&0xF)) 25#define setPinInput(pin) (DDRx_ADDRESS(pin) &= ~_BV((pin)&0xF), PORTx_ADDRESS(pin) &= ~_BV((pin)&0xF))
24#define setPinInputHigh(pin) (DDRx_ADDRESS(pin) &= ~_BV((pin)&0xF), PORTx_ADDRESS(pin) |= _BV((pin)&0xF)) 26#define setPinInputHigh(pin) (DDRx_ADDRESS(pin) &= ~_BV((pin)&0xF), PORTx_ADDRESS(pin) |= _BV((pin)&0xF))
25#define setPinInputLow(pin) _Static_assert(0, "AVR processors cannot implement an input as pull low") 27#define setPinInputLow(pin) _Static_assert(0, "AVR processors cannot implement an input as pull low")
@@ -32,3 +34,16 @@ typedef uint8_t pin_t;
32#define readPin(pin) ((bool)(PINx_ADDRESS(pin) & _BV((pin)&0xF))) 34#define readPin(pin) ((bool)(PINx_ADDRESS(pin) & _BV((pin)&0xF)))
33 35
34#define togglePin(pin) (PORTx_ADDRESS(pin) ^= _BV((pin)&0xF)) 36#define togglePin(pin) (PORTx_ADDRESS(pin) ^= _BV((pin)&0xF))
37
38/* Operation of GPIO by port. */
39
40typedef uint8_t port_data_t;
41
42#define readPort(port) PINx_ADDRESS(port)
43
44#define setPortBitInput(port, bit) (DDRx_ADDRESS(port) &= ~_BV((bit)&0xF), PORTx_ADDRESS(port) &= ~_BV((bit)&0xF))
45#define setPortBitInputHigh(port, bit) (DDRx_ADDRESS(port) &= ~_BV((bit)&0xF), PORTx_ADDRESS(port) |= _BV((bit)&0xF))
46#define setPortBitOutput(port, bit) (DDRx_ADDRESS(port) |= _BV((bit)&0xF))
47
48#define writePortBitLow(port, bit) (PORTx_ADDRESS(port) &= ~_BV((bit)&0xF))
49#define writePortBitHigh(port, bit) (PORTx_ADDRESS(port) |= _BV((bit)&0xF))
diff --git a/tmk_core/common/chibios/_timer.h b/tmk_core/common/chibios/_timer.h
new file mode 100644
index 000000000..77402b612
--- /dev/null
+++ b/tmk_core/common/chibios/_timer.h
@@ -0,0 +1,19 @@
1/* Copyright 2021 Simon Arlott
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// The platform is 32-bit, so prefer 32-bit timers to avoid overflow
19#define FAST_TIMER_T_SIZE 32
diff --git a/tmk_core/common/chibios/bootloader.c b/tmk_core/common/chibios/bootloader.c
index 11f7abf43..76d52ea60 100644
--- a/tmk_core/common/chibios/bootloader.c
+++ b/tmk_core/common/chibios/bootloader.c
@@ -95,7 +95,7 @@ void enter_bootloader_mode_if_requested(void) {
95 } 95 }
96} 96}
97 97
98#elif defined(KL2x) || defined(K20x) || defined(MK66F18) // STM32_BOOTLOADER_DUAL_BANK // STM32_BOOTLOADER_ADDRESS 98#elif defined(KL2x) || defined(K20x) || defined(MK66F18) || defined(MIMXRT1062) // STM32_BOOTLOADER_DUAL_BANK // STM32_BOOTLOADER_ADDRESS
99/* Kinetis */ 99/* Kinetis */
100 100
101# if defined(BOOTLOADER_KIIBOHD) 101# if defined(BOOTLOADER_KIIBOHD)
diff --git a/tmk_core/common/chibios/gpio.h b/tmk_core/common/chibios/gpio.h
index 5d0e142ab..4d057f1ca 100644
--- a/tmk_core/common/chibios/gpio.h
+++ b/tmk_core/common/chibios/gpio.h
@@ -20,6 +20,8 @@
20 20
21typedef ioline_t pin_t; 21typedef ioline_t pin_t;
22 22
23/* Operation of GPIO by pin. */
24
23#define setPinInput(pin) palSetLineMode(pin, PAL_MODE_INPUT) 25#define setPinInput(pin) palSetLineMode(pin, PAL_MODE_INPUT)
24#define setPinInputHigh(pin) palSetLineMode(pin, PAL_MODE_INPUT_PULLUP) 26#define setPinInputHigh(pin) palSetLineMode(pin, PAL_MODE_INPUT_PULLUP)
25#define setPinInputLow(pin) palSetLineMode(pin, PAL_MODE_INPUT_PULLDOWN) 27#define setPinInputLow(pin) palSetLineMode(pin, PAL_MODE_INPUT_PULLDOWN)
@@ -32,3 +34,17 @@ typedef ioline_t pin_t;
32#define readPin(pin) palReadLine(pin) 34#define readPin(pin) palReadLine(pin)
33 35
34#define togglePin(pin) palToggleLine(pin) 36#define togglePin(pin) palToggleLine(pin)
37
38/* Operation of GPIO by port. */
39
40typedef uint16_t port_data_t;
41
42#define readPort(pin) palReadPort(PAL_PORT(pin))
43
44#define setPortBitInput(pin, bit) palSetPadMode(PAL_PORT(pin), bit, PAL_MODE_INPUT)
45#define setPortBitInputHigh(pin, bit) palSetPadMode(PAL_PORT(pin), bit, PAL_MODE_INPUT_PULLUP)
46#define setPortBitInputLow(pin, bit) palSetPadMode(PAL_PORT(pin), bit, PAL_MODE_INPUT_PULLDOWN)
47#define setPortBitOutput(pin, bit) palSetPadMode(PAL_PORT(pin), bit, PAL_MODE_OUTPUT_PUSHPULL)
48
49#define writePortBitLow(pin, bit) palClearLine(PAL_LINE(PAL_PORT(pin), bit))
50#define writePortBitHigh(pin, bit) palSetLine(PAL_LINE(PAL_PORT(pin), bit))
diff --git a/tmk_core/common/host.c b/tmk_core/common/host.c
index e7d92cfac..a8b391e89 100644
--- a/tmk_core/common/host.c
+++ b/tmk_core/common/host.c
@@ -17,6 +17,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
17 17
18#include <stdint.h> 18#include <stdint.h>
19//#include <avr/interrupt.h> 19//#include <avr/interrupt.h>
20#include "keyboard.h"
20#include "keycode.h" 21#include "keycode.h"
21#include "host.h" 22#include "host.h"
22#include "util.h" 23#include "util.h"
@@ -35,15 +36,20 @@ void host_set_driver(host_driver_t *d) { driver = d; }
35 36
36host_driver_t *host_get_driver(void) { return driver; } 37host_driver_t *host_get_driver(void) { return driver; }
37 38
39#ifdef SPLIT_KEYBOARD
40uint8_t split_led_state = 0;
41void set_split_host_keyboard_leds(uint8_t led_state) { split_led_state = led_state; }
42#endif
43
38uint8_t host_keyboard_leds(void) { 44uint8_t host_keyboard_leds(void) {
45#ifdef SPLIT_KEYBOARD
46 if (!is_keyboard_master()) return split_led_state;
47#endif
39 if (!driver) return 0; 48 if (!driver) return 0;
40 return (*driver->keyboard_leds)(); 49 return (*driver->keyboard_leds)();
41} 50}
42 51
43led_t host_keyboard_led_state(void) { 52led_t host_keyboard_led_state(void) { return (led_t)host_keyboard_leds(); }
44 if (!driver) return (led_t){0};
45 return (led_t)((*driver->keyboard_leds)());
46}
47 53
48/* send report */ 54/* send report */
49void host_keyboard_send(report_keyboard_t *report) { 55void host_keyboard_send(report_keyboard_t *report) {
diff --git a/tmk_core/common/keyboard.c b/tmk_core/common/keyboard.c
index 3d6092e71..28fa97bc8 100644
--- a/tmk_core/common/keyboard.c
+++ b/tmk_core/common/keyboard.c
@@ -85,6 +85,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
85#ifdef OLED_DRIVER_ENABLE 85#ifdef OLED_DRIVER_ENABLE
86# include "oled_driver.h" 86# include "oled_driver.h"
87#endif 87#endif
88#ifdef ST7565_ENABLE
89# include "st7565.h"
90#endif
88#ifdef VELOCIKEY_ENABLE 91#ifdef VELOCIKEY_ENABLE
89# include "velocikey.h" 92# include "velocikey.h"
90#endif 93#endif
@@ -100,6 +103,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
100#ifdef EEPROM_DRIVER 103#ifdef EEPROM_DRIVER
101# include "eeprom_driver.h" 104# include "eeprom_driver.h"
102#endif 105#endif
106#if defined(CRC_ENABLE)
107# include "crc.h"
108#endif
103 109
104static uint32_t last_input_modification_time = 0; 110static uint32_t last_input_modification_time = 0;
105uint32_t last_input_activity_time(void) { return last_input_modification_time; } 111uint32_t last_input_activity_time(void) { return last_input_modification_time; }
@@ -297,6 +303,9 @@ void keyboard_init(void) {
297 timer_init(); 303 timer_init();
298 sync_timer_init(); 304 sync_timer_init();
299 matrix_init(); 305 matrix_init();
306#if defined(CRC_ENABLE)
307 crc_init();
308#endif
300#ifdef VIA_ENABLE 309#ifdef VIA_ENABLE
301 via_init(); 310 via_init();
302#endif 311#endif
@@ -306,6 +315,9 @@ void keyboard_init(void) {
306#ifdef OLED_DRIVER_ENABLE 315#ifdef OLED_DRIVER_ENABLE
307 oled_init(OLED_ROTATION_0); 316 oled_init(OLED_ROTATION_0);
308#endif 317#endif
318#ifdef ST7565_ENABLE
319 st7565_init(DISPLAY_ROTATION_0);
320#endif
309#ifdef PS2_MOUSE_ENABLE 321#ifdef PS2_MOUSE_ENABLE
310 ps2_mouse_init(); 322 ps2_mouse_init();
311#endif 323#endif
@@ -470,6 +482,18 @@ MATRIX_LOOP_END:
470# endif 482# endif
471#endif 483#endif
472 484
485#ifdef ST7565_ENABLE
486 st7565_task();
487# ifndef ST7565_DISABLE_TIMEOUT
488 // Wake up display if user is using those fabulous keys or spinning those encoders!
489# ifdef ENCODER_ENABLE
490 if (matrix_changed || encoders_changed) st7565_on();
491# else
492 if (matrix_changed) st7565_on();
493# endif
494# endif
495#endif
496
473#ifdef MOUSEKEY_ENABLE 497#ifdef MOUSEKEY_ENABLE
474 // mousekey repeat & acceleration 498 // mousekey repeat & acceleration
475 mousekey_task(); 499 mousekey_task();
diff --git a/tmk_core/common/timer.h b/tmk_core/common/timer.h
index 58f637dd9..928811a2b 100644
--- a/tmk_core/common/timer.h
+++ b/tmk_core/common/timer.h
@@ -1,5 +1,6 @@
1/* 1/*
2Copyright 2011 Jun Wako <wakojun@gmail.com> 2Copyright 2011 Jun Wako <wakojun@gmail.com>
3Copyright 2021 Simon Arlott
3 4
4This program is free software: you can redistribute it and/or modify 5This program is free software: you can redistribute it and/or modify
5it under the terms of the GNU General Public License as published by 6it under the terms of the GNU General Public License as published by
@@ -17,13 +18,13 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
17 18
18#pragma once 19#pragma once
19 20
21#if __has_include_next("_timer.h")
22# include_next "_timer.h" /* Include the platform's _timer.h */
23#endif
24
20#include <stdint.h> 25#include <stdint.h>
21#include <stdbool.h> 26#include <stdbool.h>
22 27
23#if defined(__AVR__)
24# include "avr/timer_avr.h"
25#endif
26
27#define TIMER_DIFF(a, b, max) ((max == UINT8_MAX) ? ((uint8_t)((a) - (b))) : ((max == UINT16_MAX) ? ((uint16_t)((a) - (b))) : ((max == UINT32_MAX) ? ((uint32_t)((a) - (b))) : ((a) >= (b) ? (a) - (b) : (max) + 1 - (b) + (a))))) 28#define TIMER_DIFF(a, b, max) ((max == UINT8_MAX) ? ((uint8_t)((a) - (b))) : ((max == UINT16_MAX) ? ((uint16_t)((a) - (b))) : ((max == UINT32_MAX) ? ((uint32_t)((a) - (b))) : ((a) >= (b) ? (a) - (b) : (max) + 1 - (b) + (a)))))
28#define TIMER_DIFF_8(a, b) TIMER_DIFF(a, b, UINT8_MAX) 29#define TIMER_DIFF_8(a, b) TIMER_DIFF(a, b, UINT8_MAX)
29#define TIMER_DIFF_16(a, b) TIMER_DIFF(a, b, UINT16_MAX) 30#define TIMER_DIFF_16(a, b) TIMER_DIFF(a, b, UINT16_MAX)
@@ -47,6 +48,21 @@ uint32_t timer_elapsed32(uint32_t last);
47#define timer_expired(current, future) ((uint16_t)(current - future) < UINT16_MAX / 2) 48#define timer_expired(current, future) ((uint16_t)(current - future) < UINT16_MAX / 2)
48#define timer_expired32(current, future) ((uint32_t)(current - future) < UINT32_MAX / 2) 49#define timer_expired32(current, future) ((uint32_t)(current - future) < UINT32_MAX / 2)
49 50
51// Use an appropriate timer integer size based on architecture (16-bit will overflow sooner)
52#if FAST_TIMER_T_SIZE < 32
53# define TIMER_DIFF_FAST(a, b) TIMER_DIFF_16(a, b)
54# define timer_expired_fast(current, future) timer_expired(current, future)
55typedef uint16_t fast_timer_t;
56fast_timer_t inline timer_read_fast(void) { return timer_read(); }
57fast_timer_t inline timer_elapsed_fast(fast_timer_t last) { return timer_elapsed(last); }
58#else
59# define TIMER_DIFF_FAST(a, b) TIMER_DIFF_32(a, b)
60# define timer_expired_fast(current, future) timer_expired32(current, future)
61typedef uint32_t fast_timer_t;
62fast_timer_t inline timer_read_fast(void) { return timer_read32(); }
63fast_timer_t inline timer_elapsed_fast(fast_timer_t last) { return timer_elapsed32(last); }
64#endif
65
50#ifdef __cplusplus 66#ifdef __cplusplus
51} 67}
52#endif 68#endif
diff --git a/tmk_core/protocol/chibios/usb_main.c b/tmk_core/protocol/chibios/usb_main.c
index d04302aca..407b8ea75 100644
--- a/tmk_core/protocol/chibios/usb_main.c
+++ b/tmk_core/protocol/chibios/usb_main.c
@@ -903,7 +903,8 @@ static void send_extra(uint8_t report_id, uint16_t data) {
903 return; 903 return;
904 } 904 }
905 905
906 report_extra_t report = {.report_id = report_id, .usage = data}; 906 static report_extra_t report;
907 report = (report_extra_t){.report_id = report_id, .usage = data};
907 908
908 usbStartTransmitI(&USB_DRIVER, SHARED_IN_EPNUM, (uint8_t *)&report, sizeof(report_extra_t)); 909 usbStartTransmitI(&USB_DRIVER, SHARED_IN_EPNUM, (uint8_t *)&report, sizeof(report_extra_t));
909 osalSysUnlock(); 910 osalSysUnlock();
@@ -1051,45 +1052,44 @@ void virtser_task(void) {
1051#ifdef JOYSTICK_ENABLE 1052#ifdef JOYSTICK_ENABLE
1052 1053
1053void send_joystick_packet(joystick_t *joystick) { 1054void send_joystick_packet(joystick_t *joystick) {
1054 joystick_report_t rep = { 1055 static joystick_report_t rep;
1056 rep = (joystick_report_t) {
1055# if JOYSTICK_AXES_COUNT > 0 1057# if JOYSTICK_AXES_COUNT > 0
1056 .axes = 1058 .axes =
1057 { 1059 { joystick->axes[0],
1058 joystick->axes[0],
1059 1060
1060# if JOYSTICK_AXES_COUNT >= 2 1061# if JOYSTICK_AXES_COUNT >= 2
1061 joystick->axes[1], 1062 joystick->axes[1],
1062# endif 1063# endif
1063# if JOYSTICK_AXES_COUNT >= 3 1064# if JOYSTICK_AXES_COUNT >= 3
1064 joystick->axes[2], 1065 joystick->axes[2],
1065# endif 1066# endif
1066# if JOYSTICK_AXES_COUNT >= 4 1067# if JOYSTICK_AXES_COUNT >= 4
1067 joystick->axes[3], 1068 joystick->axes[3],
1068# endif 1069# endif
1069# if JOYSTICK_AXES_COUNT >= 5 1070# if JOYSTICK_AXES_COUNT >= 5
1070 joystick->axes[4], 1071 joystick->axes[4],
1071# endif 1072# endif
1072# if JOYSTICK_AXES_COUNT >= 6 1073# if JOYSTICK_AXES_COUNT >= 6
1073 joystick->axes[5], 1074 joystick->axes[5],
1074# endif 1075# endif
1075 }, 1076 },
1076# endif // JOYSTICK_AXES_COUNT>0 1077# endif // JOYSTICK_AXES_COUNT>0
1077 1078
1078# if JOYSTICK_BUTTON_COUNT > 0 1079# if JOYSTICK_BUTTON_COUNT > 0
1079 .buttons = 1080 .buttons = {
1080 { 1081 joystick->buttons[0],
1081 joystick->buttons[0],
1082 1082
1083# if JOYSTICK_BUTTON_COUNT > 8 1083# if JOYSTICK_BUTTON_COUNT > 8
1084 joystick->buttons[1], 1084 joystick->buttons[1],
1085# endif 1085# endif
1086# if JOYSTICK_BUTTON_COUNT > 16 1086# if JOYSTICK_BUTTON_COUNT > 16
1087 joystick->buttons[2], 1087 joystick->buttons[2],
1088# endif 1088# endif
1089# if JOYSTICK_BUTTON_COUNT > 24 1089# if JOYSTICK_BUTTON_COUNT > 24
1090 joystick->buttons[3], 1090 joystick->buttons[3],
1091# endif 1091# endif
1092 } 1092 }
1093# endif // JOYSTICK_BUTTON_COUNT>0 1093# endif // JOYSTICK_BUTTON_COUNT>0
1094 }; 1094 };
1095 1095
diff --git a/tmk_core/protocol/lufa/lufa.c b/tmk_core/protocol/lufa/lufa.c
index 63619fdb3..4ac079e16 100644
--- a/tmk_core/protocol/lufa/lufa.c
+++ b/tmk_core/protocol/lufa/lufa.c
@@ -314,45 +314,44 @@ static void Console_Task(void) {
314void send_joystick_packet(joystick_t *joystick) { 314void send_joystick_packet(joystick_t *joystick) {
315 uint8_t timeout = 255; 315 uint8_t timeout = 255;
316 316
317 joystick_report_t r = { 317 static joystick_report_t;
318 r = (joystick_report_t) {
318# if JOYSTICK_AXES_COUNT > 0 319# if JOYSTICK_AXES_COUNT > 0
319 .axes = 320 .axes =
320 { 321 { joystick->axes[0],
321 joystick->axes[0],
322 322
323# if JOYSTICK_AXES_COUNT >= 2 323# if JOYSTICK_AXES_COUNT >= 2
324 joystick->axes[1], 324 joystick->axes[1],
325# endif 325# endif
326# if JOYSTICK_AXES_COUNT >= 3 326# if JOYSTICK_AXES_COUNT >= 3
327 joystick->axes[2], 327 joystick->axes[2],
328# endif 328# endif
329# if JOYSTICK_AXES_COUNT >= 4 329# if JOYSTICK_AXES_COUNT >= 4
330 joystick->axes[3], 330 joystick->axes[3],
331# endif 331# endif
332# if JOYSTICK_AXES_COUNT >= 5 332# if JOYSTICK_AXES_COUNT >= 5
333 joystick->axes[4], 333 joystick->axes[4],
334# endif 334# endif
335# if JOYSTICK_AXES_COUNT >= 6 335# if JOYSTICK_AXES_COUNT >= 6
336 joystick->axes[5], 336 joystick->axes[5],
337# endif 337# endif
338 }, 338 },
339# endif // JOYSTICK_AXES_COUNT>0 339# endif // JOYSTICK_AXES_COUNT>0
340 340
341# if JOYSTICK_BUTTON_COUNT > 0 341# if JOYSTICK_BUTTON_COUNT > 0
342 .buttons = 342 .buttons = {
343 { 343 joystick->buttons[0],
344 joystick->buttons[0],
345 344
346# if JOYSTICK_BUTTON_COUNT > 8 345# if JOYSTICK_BUTTON_COUNT > 8
347 joystick->buttons[1], 346 joystick->buttons[1],
348# endif 347# endif
349# if JOYSTICK_BUTTON_COUNT > 16 348# if JOYSTICK_BUTTON_COUNT > 16
350 joystick->buttons[2], 349 joystick->buttons[2],
351# endif 350# endif
352# if JOYSTICK_BUTTON_COUNT > 24 351# if JOYSTICK_BUTTON_COUNT > 24
353 joystick->buttons[3], 352 joystick->buttons[3],
354# endif 353# endif
355 } 354 }
356# endif // JOYSTICK_BUTTON_COUNT>0 355# endif // JOYSTICK_BUTTON_COUNT>0
357 }; 356 };
358 357
@@ -768,7 +767,8 @@ static void send_extra(uint8_t report_id, uint16_t data) {
768 767
769 if (USB_DeviceState != DEVICE_STATE_Configured) return; 768 if (USB_DeviceState != DEVICE_STATE_Configured) return;
770 769
771 report_extra_t r = {.report_id = report_id, .usage = data}; 770 static report_extra_t r;
771 r = (report_extra_t){.report_id = report_id, .usage = data};
772 Endpoint_SelectEndpoint(SHARED_IN_EPNUM); 772 Endpoint_SelectEndpoint(SHARED_IN_EPNUM);
773 773
774 /* Check if write ready for a polling interval around 10ms */ 774 /* Check if write ready for a polling interval around 10ms */
diff --git a/tmk_core/protocol/usb_descriptor.c b/tmk_core/protocol/usb_descriptor.c
index ba7760f28..c88aceb6e 100644
--- a/tmk_core/protocol/usb_descriptor.c
+++ b/tmk_core/protocol/usb_descriptor.c
@@ -351,7 +351,7 @@ const USB_Descriptor_Device_t PROGMEM DeviceDescriptor = {
351 .Size = sizeof(USB_Descriptor_Device_t), 351 .Size = sizeof(USB_Descriptor_Device_t),
352 .Type = DTYPE_Device 352 .Type = DTYPE_Device
353 }, 353 },
354 .USBSpecification = VERSION_BCD(1, 1, 0), 354 .USBSpecification = VERSION_BCD(2, 0, 0),
355 355
356#if VIRTSER_ENABLE 356#if VIRTSER_ENABLE
357 .Class = USB_CSCP_IADDeviceClass, 357 .Class = USB_CSCP_IADDeviceClass,
diff --git a/tmk_core/protocol/vusb/vusb.c b/tmk_core/protocol/vusb/vusb.c
index 9362fbde7..876a31378 100644
--- a/tmk_core/protocol/vusb/vusb.c
+++ b/tmk_core/protocol/vusb/vusb.c
@@ -272,7 +272,8 @@ static void send_extra(uint8_t report_id, uint16_t data) {
272 last_id = report_id; 272 last_id = report_id;
273 last_data = data; 273 last_data = data;
274 274
275 report_extra_t report = {.report_id = report_id, .usage = data}; 275 static report_extra_t report;
276 report = (report_extra_t){.report_id = report_id, .usage = data};
276 if (usbInterruptIsReadyShared()) { 277 if (usbInterruptIsReadyShared()) {
277 usbSetInterruptShared((void *)&report, sizeof(report_extra_t)); 278 usbSetInterruptShared((void *)&report, sizeof(report_extra_t));
278 } 279 }
diff --git a/tmk_core/rules.mk b/tmk_core/rules.mk
index fc2dc68be..597f7aa82 100644
--- a/tmk_core/rules.mk
+++ b/tmk_core/rules.mk
@@ -458,7 +458,7 @@ ifeq ($(findstring avr-gcc,$(CC)),avr-gcc)
458SIZE_MARGIN = 1024 458SIZE_MARGIN = 1024
459 459
460check-size: 460check-size:
461 $(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)) 461 $(eval MAX_SIZE=$(shell n=`$(CC) -E -mmcu=$(MCU) -D__ASSEMBLER__ $(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))
462 $(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)) 462 $(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))
463 $(eval FREE_SIZE=$(shell expr $(MAX_SIZE) - $(CURRENT_SIZE))) 463 $(eval FREE_SIZE=$(shell expr $(MAX_SIZE) - $(CURRENT_SIZE)))
464 $(eval OVER_SIZE=$(shell expr $(CURRENT_SIZE) - $(MAX_SIZE))) 464 $(eval OVER_SIZE=$(shell expr $(CURRENT_SIZE) - $(MAX_SIZE)))