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 $(call EXEC_AVRDUDE,eeprom-righthand.eep) define EXEC_USBASP - avrdude -p $(MCU) -c usbasp -U flash:w:$(BUILD_DIR)/$(TARGET).hex + avrdude -p $(AVRDUDE_MCU) -c usbasp -U flash:w:$(BUILD_DIR)/$(TARGET).hex endef usbasp: $(BUILD_DIR)/$(TARGET).hex check-size cpfirmware @@ -321,7 +321,7 @@ extcoff: $(BUILD_DIR)/$(TARGET).elf bootloader: make -C lib/lufa/Bootloaders/DFU/ clean $(TMK_DIR)/make_dfu_header.sh $(ALL_CONFIGS) - $(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)) + $(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)) $(eval PROGRAM_SIZE_KB=$(shell n=`expr $(MAX_SIZE) / 1024` && echo $$(($$n)) || echo 0)) $(eval BOOT_SECTION_SIZE_KB=$(shell n=`expr $(BOOTLOADER_SIZE) / 1024` && echo $$(($$n)) || echo 0)) $(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) TMK_COMMON_DEFS += -DNO_USB_STARTUP_CHECK endif -ifeq ($(strip $(KEYMAP_SECTION_ENABLE)), yes) - TMK_COMMON_DEFS += -DKEYMAP_SECTION_ENABLE - - ifeq ($(strip $(MCU)),atmega32u2) - TMK_COMMON_LDFLAGS = -Wl,-L$(TMK_DIR),-Tldscript_keymap_avr35.x - else ifeq ($(strip $(MCU)),atmega32u4) - TMK_COMMON_LDFLAGS = -Wl,-L$(TMK_DIR),-Tldscript_keymap_avr5.x - else - TMK_COMMON_LDFLAGS = $(error no ldscript for keymap section) - endif -endif - ifeq ($(strip $(SHARED_EP_ENABLE)), yes) TMK_COMMON_DEFS += -DSHARED_EP_ENABLE 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; # include <fauxclicky.h> #endif +#ifdef IGNORE_MOD_TAP_INTERRUPT_PER_KEY +__attribute__ ((weak)) bool get_ignore_mod_tap_interrupt(uint16_t keycode) { return false; } +#endif + #ifndef TAP_CODE_DELAY # define TAP_CODE_DELAY 0 #endif @@ -308,8 +312,12 @@ void process_action(keyrecord_t *record, action_t action) { default: if (event.pressed) { if (tap_count > 0) { -# ifndef IGNORE_MOD_TAP_INTERRUPT - if (record->tap.interrupted) { +# if !defined(IGNORE_MOD_TAP_INTERRUPT) || defined(IGNORE_MOD_TAP_INTERRUPT_PER_KEY) + if ( +# ifdef IGNORE_MOD_TAP_INTERRUPT_PER_KEY + !get_ignore_mod_tap_interrupt(get_event_keycode(record->event)) && +# endif + record->tap.interrupted) { dprint("mods_tap: tap: cancel: add_mods\n"); // ad hoc: set 0 to cancel tap record->tap.count = 0; @@ -552,7 +560,7 @@ void process_action(keyrecord_t *record, action_t action) { action_macro_play(action_get_macro(record, action.func.id, action.func.opt)); break; #endif -#if defined(BACKLIGHT_ENABLE) | defined(LED_MATRIX_ENABLE) +#if defined(BACKLIGHT_ENABLE) || defined(LED_MATRIX_ENABLE) case ACT_BACKLIGHT: if (!event.pressed) { 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 # define WITHIN_TAPPING_TERM(e) (TIMER_DIFF_16(e.time, tapping_key.event.time) < TAPPING_TERM) # endif +# ifdef TAPPING_FORCE_HOLD_PER_KEY +__attribute__((weak)) bool get_tapping_force_hold(uint16_t keycode, keyrecord_t *record) { return false; } +# endif + static keyrecord_t tapping_key = {}; static keyrecord_t waiting_buffer[WAITING_BUFFER_SIZE] = {}; static uint8_t waiting_buffer_head = 0; @@ -111,7 +115,7 @@ bool process_tapping(keyrecord_t *keyp) { * This can register the key before settlement of tapping, * useful for long TAPPING_TERM but may prevent fast typing. */ -# if defined(TAPPING_TERM_PER_KEY) || (!defined(PER_KEY_TAPPING_TERM) && TAPPING_TERM >= 500) || defined(PERMISSIVE_HOLD) +# if defined(TAPPING_TERM_PER_KEY) || (TAPPING_TERM >= 500) || defined(PERMISSIVE_HOLD) # ifdef TAPPING_TERM_PER_KEY else if ((get_tapping_term(get_event_keycode(tapping_key.event)) >= 500) && IS_RELEASED(event) && waiting_buffer_typed(event)) # else @@ -232,8 +236,13 @@ bool process_tapping(keyrecord_t *keyp) { if (WITHIN_TAPPING_TERM(event)) { if (event.pressed) { if (IS_TAPPING_KEY(event.key)) { -# ifndef TAPPING_FORCE_HOLD - if (!tapping_key.tap.interrupted && tapping_key.tap.count > 0) { +//# ifndef TAPPING_FORCE_HOLD +# if !defined(TAPPING_FORCE_HOLD) || defined(TAPPING_FORCE_HOLD_PER_KEY) + if ( +# ifdef TAPPING_FORCE_HOLD_PER_KEY + !get_tapping_force_hold(get_event_keycode(tapping_key.event), keyp) && +# endif + !tapping_key.tap.interrupted && tapping_key.tap.count > 0) { // sequential tap. keyp->tap = tapping_key.tap; 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 @@ +/* Copyright 2019 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ +#pragma once + +#if defined(STM32F1XX) +# define USE_GPIOV1 +#endif + +#if defined(STM32F1XX) || defined(STM32F2XX) || defined(STM32F4XX) || defined(STM32L1XX) +# define USE_I2CV1 +#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) { #ifdef NKRO_ENABLE " NKRO" #endif -#ifdef KEYMAP_SECTION_ENABLE - " KEYMAP_SECTION" -#endif " " STR(BOOTLOADER_SIZE) "\n"); 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/>. #define EECONFIG_RGB_MATRIX_SPEED (uint8_t *)32 // TODO: Combine these into a single word and single block of EEPROM #define EECONFIG_KEYMAP_UPPER_BYTE (uint8_t *)33 +// Size of EEPROM being used, other code can refer to this for available EEPROM +#define EECONFIG_SIZE 34 /* debug bit */ #define EECONFIG_DEBUG_ENABLE (1 << 0) #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/>. #ifdef VELOCIKEY_ENABLE # include "velocikey.h" #endif +#ifdef VIA_ENABLE +# include "via.h" +#endif // Only enable this if console is enabled to print to #if defined(DEBUG_MATRIX_SCAN_RATE) && defined(CONSOLE_ENABLE) @@ -217,6 +220,9 @@ __attribute__((weak)) bool is_keyboard_master(void) { return true; } void keyboard_init(void) { timer_init(); matrix_init(); +#ifdef VIA_ENABLE + via_init(); +#endif #ifdef QWIIC_ENABLE qwiic_init(); #endif @@ -254,6 +260,7 @@ void keyboard_init(void) { #endif #if defined(NKRO_ENABLE) && defined(FORCE_NKRO) keymap_config.nkro = 1; + eeconfig_update_keymap(keymap_config.raw); #endif keyboard_post_init_kb(); /* Always keep this last */ } @@ -296,13 +303,14 @@ void keyboard_task(void) { } #endif if (debug_matrix) matrix_print(); - for (uint8_t c = 0; c < MATRIX_COLS; c++) { - if (matrix_change & ((matrix_row_t)1 << c)) { + matrix_row_t col_mask = 1; + for (uint8_t c = 0; c < MATRIX_COLS; c++, col_mask <<= 1) { + if (matrix_change & col_mask) { action_exec((keyevent_t){ - .key = (keypos_t){.row = r, .col = c}, .pressed = (matrix_row & ((matrix_row_t)1 << c)), .time = (timer_read() | 1) /* time should not be 0 */ + .key = (keypos_t){.row = r, .col = c}, .pressed = (matrix_row & col_mask), .time = (timer_read() | 1) /* time should not be 0 */ }); // record a processed key - matrix_prev[r] ^= ((matrix_row_t)1 << c); + matrix_prev[r] ^= col_mask; #ifdef QMK_KEYS_PER_SCAN // only jump out if we have processed "enough" keys. if (++keys_processed >= QMK_KEYS_PER_SCAN) @@ -327,6 +335,16 @@ MATRIX_LOOP_END: matrix_scan_perf_task(); #endif +#if defined(RGBLIGHT_ANIMATIONS) && defined(RGBLIGHT_ENABLE) + rgblight_task(); +#endif + +#if defined(BACKLIGHT_ENABLE) +# if defined(BACKLIGHT_PIN) || defined(BACKLIGHT_PINS) + backlight_task(); +# endif +#endif + #ifdef QWIIC_ENABLE qwiic_task(); #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/>. #define KC_MPLY KC_MEDIA_PLAY_PAUSE #define KC_MSEL KC_MEDIA_SELECT #define KC_EJCT KC_MEDIA_EJECT -#define KC_MAIL KC_MAIL #define KC_CALC KC_CALCULATOR #define KC_MYCM KC_MY_COMPUTER #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; # error "MATRIX_ROWS: invalid value" #endif +#define MATRIX_ROW_SHIFTER ((matrix_row_t)1) + #define MATRIX_IS_ON(row, col) (matrix_get_row(row) && (1 << col)) #ifdef __cplusplus @@ -79,11 +81,6 @@ void matrix_scan_kb(void); void matrix_init_user(void); void matrix_scan_user(void); -#ifdef I2C_SPLIT -void slave_matrix_init(void); -uint8_t slave_matrix_scan(void); -#endif - #ifdef __cplusplus } #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 @@ -#include "bootloader.h" - -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 @@ -#include <stdbool.h> - -void suspend_power_down(void) {} -bool suspend_wakeup_condition(void) { return true; } -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 @@ -#include "cmsis.h" -#include "timer.h" - -/* Mill second tick count */ -volatile uint32_t timer_count = 0; - -/* Timer interrupt handler */ -void SysTick_Handler(void) { timer_count++; } - -void timer_init(void) { - timer_count = 0; - SysTick_Config(SystemCoreClock / 1000); /* 1ms tick */ -} - -void timer_clear(void) { timer_count = 0; } - -uint16_t timer_read(void) { return (uint16_t)(timer_count & 0xFFFF); } - -uint32_t timer_read32(void) { return timer_count; } - -uint16_t timer_elapsed(uint16_t last) { return TIMER_DIFF_16(timer_read(), last); } - -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 @@ -#include <cstdarg> -//#include <stdarg.h> -#include "mbed.h" -#include "mbed/xprintf.h" - -#define STRING_STACK_LIMIT 120 - -// TODO -int __xprintf(const char* format, ...) { return 0; } - -#if 0 -/* mbed Serial */ -Serial ser(UART_TX, UART_RX); - -/* TODO: Need small implementation for embedded */ -int xprintf(const char* format, ...) -{ - /* copy from mbed/common/RawSerial.cpp */ - std::va_list arg; - va_start(arg, format); - int len = vsnprintf(NULL, 0, format, arg); - if (len < STRING_STACK_LIMIT) { - char temp[STRING_STACK_LIMIT]; - vsprintf(temp, format, arg); - ser.puts(temp); - } else { - char *temp = new char[len + 1]; - vsprintf(temp, format, arg); - ser.puts(temp); - delete[] temp; - } - va_end(arg); - return len; - -/* Fail: __builtin_va_arg_pack? - * https://gcc.gnu.org/onlinedocs/gcc-4.3.5/gcc/Constructing-Calls.html#Constructing-Calls - void *arg = __builtin_apply_args(); - void *ret = __builtin_apply((void*)(&(ser.printf)), arg, 100); - __builtin_return(ret) -*/ -/* Fail: varargs can not be passed to printf - //int r = ser.printf("test %i\r\n", 123); - va_list arg; - va_start(arg, format); - int r = ser.printf(format, arg); - va_end(arg); - return r; -*/ -} -#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 @@ -#ifndef XPRINTF_H -#define XPRINTF_H - -//#define xprintf(format, ...) __xprintf(format, ##__VA_ARGS__) - -#ifdef __cplusplus -extern "C" { -#endif - -int __xprintf(const char *format, ...); - -#ifdef __cplusplus -} -#endif - -#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" # endif /* USER_PRINT / NORMAL PRINT */ -# elif defined(__arm__) /* __arm__ */ - -# include "mbed/xprintf.h" - -# ifdef USER_PRINT /* USER_PRINT */ - -// Remove normal print defines -# define print(s) -# define println(s) -# define xprintf(fmt, ...) - -// Create user print defines -# define uprintf(fmt, ...) __xprintf(fmt, ##__VA_ARGS__) -# define uprint(s) xprintf(s) -# define uprintln(s) xprintf(s "\r\n") - -# else /* NORMAL PRINT */ - -// Create user & normal print defines -# define xprintf(fmt, ...) __xprintf(fmt, ##__VA_ARGS__) -# define print(s) xprintf(s) -# define println(s) xprintf(s "\r\n") -# define uprint(s) print(s) -# define uprintln(s) println(s) -# define uprintf(fmt, ...) xprintf(fmt, ##__VA_ARGS__) - -# endif /* USER_PRINT / NORMAL PRINT */ - -/* TODO: to select output destinations: UART/USBSerial */ -# define print_set_sendchar(func) - -# endif /* __AVR__ / PROTOCOL_CHIBIOS / PROTOCOL_ARM_ATSAM / __arm__ */ +# endif /* __AVR__ / PROTOCOL_CHIBIOS / PROTOCOL_ARM_ATSAM */ // User print disables the normal print messages in the body of QMK/TMK code and // 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" { # include "clks.h" # define wait_ms(ms) CLK_delay_ms(ms) # define wait_us(us) CLK_delay_us(us) -#elif defined(__arm__) -# include "wait_api.h" #else // Unit tests void wait_ms(uint32_t ms); # 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 @@ -/* - * linker script for configurable keymap - * - * This adds keymap section which places keymap at fixed address and - * is based on binutils-avr ldscripts(/usr/lib/ldscripts/avr5.x). - */ -OUTPUT_FORMAT("elf32-avr","elf32-avr","elf32-avr") -OUTPUT_ARCH(avr:35) -MEMORY -{ - /* With keymap section - * - * Flash Map of ATMega32U4(32KB) - * +------------+ 0x0000 - * | .vectors | - * | .progmem | - * | .init0-9 | > text region - * | .text | - * | .fini9-0 | - * | | - * |------------| _etext - * | .data | - * | .bss | > data region - * | .noinit | - * | | - * |------------| 0x6800 - * | .keymap | > keymap region(2KB) - * |------------| 0x7000 - * | bootloader | 4KB - * +------------+ 0x7FFF - */ - text (rx) : ORIGIN = 0, LENGTH = 64K - keymap (rw!x) : ORIGIN = 0x6800, LENGTH = 2K - data (rw!x) : ORIGIN = 0x800060, LENGTH = 0xffa0 - eeprom (rw!x) : ORIGIN = 0x810000, LENGTH = 64K - fuse (rw!x) : ORIGIN = 0x820000, LENGTH = 1K - lock (rw!x) : ORIGIN = 0x830000, LENGTH = 1K - signature (rw!x) : ORIGIN = 0x840000, LENGTH = 1K -} -SECTIONS -{ - /* Read-only sections, merged into text segment: */ - .hash : { *(.hash) } - .dynsym : { *(.dynsym) } - .dynstr : { *(.dynstr) } - .gnu.version : { *(.gnu.version) } - .gnu.version_d : { *(.gnu.version_d) } - .gnu.version_r : { *(.gnu.version_r) } - .rel.init : { *(.rel.init) } - .rela.init : { *(.rela.init) } - .rel.text : - { - *(.rel.text) - *(.rel.text.*) - *(.rel.gnu.linkonce.t*) - } - .rela.text : - { - *(.rela.text) - *(.rela.text.*) - *(.rela.gnu.linkonce.t*) - } - .rel.fini : { *(.rel.fini) } - .rela.fini : { *(.rela.fini) } - .rel.rodata : - { - *(.rel.rodata) - *(.rel.rodata.*) - *(.rel.gnu.linkonce.r*) - } - .rela.rodata : - { - *(.rela.rodata) - *(.rela.rodata.*) - *(.rela.gnu.linkonce.r*) - } - .rel.data : - { - *(.rel.data) - *(.rel.data.*) - *(.rel.gnu.linkonce.d*) - } - .rela.data : - { - *(.rela.data) - *(.rela.data.*) - *(.rela.gnu.linkonce.d*) - } - .rel.ctors : { *(.rel.ctors) } - .rela.ctors : { *(.rela.ctors) } - .rel.dtors : { *(.rel.dtors) } - .rela.dtors : { *(.rela.dtors) } - .rel.got : { *(.rel.got) } - .rela.got : { *(.rela.got) } - .rel.bss : { *(.rel.bss) } - .rela.bss : { *(.rela.bss) } - .rel.plt : { *(.rel.plt) } - .rela.plt : { *(.rela.plt) } - /* Internal text space or external memory. */ - .text : - { - *(.vectors) - KEEP(*(.vectors)) - /* For data that needs to reside in the lower 64k of progmem. */ - *(.progmem.gcc*) - *(.progmem*) - . = ALIGN(2); - __trampolines_start = . ; - /* The jump trampolines for the 16-bit limited relocs will reside here. */ - *(.trampolines) - *(.trampolines*) - __trampolines_end = . ; - /* For future tablejump instruction arrays for 3 byte pc devices. - We don't relax jump/call instructions within these sections. */ - *(.jumptables) - *(.jumptables*) - /* For code that needs to reside in the lower 128k progmem. */ - *(.lowtext) - *(.lowtext*) - __ctors_start = . ; - *(.ctors) - __ctors_end = . ; - __dtors_start = . ; - *(.dtors) - __dtors_end = . ; - KEEP(SORT(*)(.ctors)) - KEEP(SORT(*)(.dtors)) - /* From this point on, we don't bother about wether the insns are - below or above the 16 bits boundary. */ - *(.init0) /* Start here after reset. */ - KEEP (*(.init0)) - *(.init1) - KEEP (*(.init1)) - *(.init2) /* Clear __zero_reg__, set up stack pointer. */ - KEEP (*(.init2)) - *(.init3) - KEEP (*(.init3)) - *(.init4) /* Initialize data and BSS. */ - KEEP (*(.init4)) - *(.init5) - KEEP (*(.init5)) - *(.init6) /* C++ constructors. */ - KEEP (*(.init6)) - *(.init7) - KEEP (*(.init7)) - *(.init8) - KEEP (*(.init8)) - *(.init9) /* Call main(). */ - KEEP (*(.init9)) - *(.text) - . = ALIGN(2); - *(.text.*) - . = ALIGN(2); - *(.fini9) /* _exit() starts here. */ - KEEP (*(.fini9)) - *(.fini8) - KEEP (*(.fini8)) - *(.fini7) - KEEP (*(.fini7)) - *(.fini6) /* C++ destructors. */ - KEEP (*(.fini6)) - *(.fini5) - KEEP (*(.fini5)) - *(.fini4) - KEEP (*(.fini4)) - *(.fini3) - KEEP (*(.fini3)) - *(.fini2) - KEEP (*(.fini2)) - *(.fini1) - KEEP (*(.fini1)) - *(.fini0) /* Infinite loop after program termination. */ - KEEP (*(.fini0)) - _etext = . ; - } > text - .data : AT (ADDR (.text) + SIZEOF (.text)) - { - PROVIDE (__data_start = .) ; - *(.data) - *(.data*) - *(.rodata) /* We need to include .rodata here if gcc is used */ - *(.rodata*) /* with -fdata-sections. */ - *(.gnu.linkonce.d*) - . = ALIGN(2); - _edata = . ; - PROVIDE (__data_end = .) ; - } > data - .bss : AT (ADDR (.bss)) - { - PROVIDE (__bss_start = .) ; - *(.bss) - *(.bss*) - *(COMMON) - PROVIDE (__bss_end = .) ; - } > data - __data_load_start = LOADADDR(.data); - __data_load_end = __data_load_start + SIZEOF(.data); - /* Global data not cleared after reset. */ - .noinit : - { - PROVIDE (__noinit_start = .) ; - *(.noinit*) - PROVIDE (__noinit_end = .) ; - _end = . ; - PROVIDE (__heap_start = .) ; - } > data - /* keymap region is located at end of flash - * .fn_actions Fn actions definitions - * .keymaps Mapping layers - */ - .keymap : - { - PROVIDE(__keymap_start = .) ; - *(.keymap.fn_actions) /* 32*actions = 64bytes */ - . = ALIGN(0x40); - *(.keymap.keymaps) /* rest of .keymap section */ - *(.keymap*) - /* . = ALIGN(0x800); */ /* keymap section takes 2KB- */ - } > keymap = 0x00 /* zero fill */ - .eeprom : - { - *(.eeprom*) - __eeprom_end = . ; - } > eeprom - .fuse : - { - KEEP(*(.fuse)) - KEEP(*(.lfuse)) - KEEP(*(.hfuse)) - KEEP(*(.efuse)) - } > fuse - .lock : - { - KEEP(*(.lock*)) - } > lock - .signature : - { - KEEP(*(.signature*)) - } > signature - /* Stabs debugging sections. */ - .stab 0 : { *(.stab) } - .stabstr 0 : { *(.stabstr) } - .stab.excl 0 : { *(.stab.excl) } - .stab.exclstr 0 : { *(.stab.exclstr) } - .stab.index 0 : { *(.stab.index) } - .stab.indexstr 0 : { *(.stab.indexstr) } - .comment 0 : { *(.comment) } - /* DWARF debug sections. - Symbols in the DWARF debugging sections are relative to the beginning - of the section so we begin them at 0. */ - /* DWARF 1 */ - .debug 0 : { *(.debug) } - .line 0 : { *(.line) } - /* GNU DWARF 1 extensions */ - .debug_srcinfo 0 : { *(.debug_srcinfo) } - .debug_sfnames 0 : { *(.debug_sfnames) } - /* DWARF 1.1 and DWARF 2 */ - .debug_aranges 0 : { *(.debug_aranges) } - .debug_pubnames 0 : { *(.debug_pubnames) } - /* DWARF 2 */ - .debug_info 0 : { *(.debug_info) *(.gnu.linkonce.wi.*) } - .debug_abbrev 0 : { *(.debug_abbrev) } - .debug_line 0 : { *(.debug_line) } - .debug_frame 0 : { *(.debug_frame) } - .debug_str 0 : { *(.debug_str) } - .debug_loc 0 : { *(.debug_loc) } - .debug_macinfo 0 : { *(.debug_macinfo) } -} 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 @@ -/* - * linker script for configurable keymap - * - * This adds keymap section which places keymap at fixed address and - * is based on binutils-avr ldscripts(/usr/lib/ldscripts/avr5.x). - */ -OUTPUT_FORMAT("elf32-avr","elf32-avr","elf32-avr") -OUTPUT_ARCH(avr:5) -MEMORY -{ - /* With keymap section - * - * Flash Map of ATMega32U4(32KB) - * +------------+ 0x0000 - * | .vectors | - * | .progmem | - * | .init0-9 | > text region - * | .text | - * | .fini9-0 | - * | | - * |------------| _etext - * | .data | - * | .bss | > data region - * | .noinit | - * | | - * |------------| 0x6800 - * | .keymap | > keymap region(2KB) - * |------------| 0x7000 - * | bootloader | 4KB - * +------------+ 0x7FFF - */ - text (rx) : ORIGIN = 0, LENGTH = 128K - keymap (rw!x) : ORIGIN = 0x6800, LENGTH = 2K - data (rw!x) : ORIGIN = 0x800060, LENGTH = 0xffa0 - eeprom (rw!x) : ORIGIN = 0x810000, LENGTH = 64K - fuse (rw!x) : ORIGIN = 0x820000, LENGTH = 1K - lock (rw!x) : ORIGIN = 0x830000, LENGTH = 1K - signature (rw!x) : ORIGIN = 0x840000, LENGTH = 1K -} -SECTIONS -{ - /* Read-only sections, merged into text segment: */ - .hash : { *(.hash) } - .dynsym : { *(.dynsym) } - .dynstr : { *(.dynstr) } - .gnu.version : { *(.gnu.version) } - .gnu.version_d : { *(.gnu.version_d) } - .gnu.version_r : { *(.gnu.version_r) } - .rel.init : { *(.rel.init) } - .rela.init : { *(.rela.init) } - .rel.text : - { - *(.rel.text) - *(.rel.text.*) - *(.rel.gnu.linkonce.t*) - } - .rela.text : - { - *(.rela.text) - *(.rela.text.*) - *(.rela.gnu.linkonce.t*) - } - .rel.fini : { *(.rel.fini) } - .rela.fini : { *(.rela.fini) } - .rel.rodata : - { - *(.rel.rodata) - *(.rel.rodata.*) - *(.rel.gnu.linkonce.r*) - } - .rela.rodata : - { - *(.rela.rodata) - *(.rela.rodata.*) - *(.rela.gnu.linkonce.r*) - } - .rel.data : - { - *(.rel.data) - *(.rel.data.*) - *(.rel.gnu.linkonce.d*) - } - .rela.data : - { - *(.rela.data) - *(.rela.data.*) - *(.rela.gnu.linkonce.d*) - } - .rel.ctors : { *(.rel.ctors) } - .rela.ctors : { *(.rela.ctors) } - .rel.dtors : { *(.rel.dtors) } - .rela.dtors : { *(.rela.dtors) } - .rel.got : { *(.rel.got) } - .rela.got : { *(.rela.got) } - .rel.bss : { *(.rel.bss) } - .rela.bss : { *(.rela.bss) } - .rel.plt : { *(.rel.plt) } - .rela.plt : { *(.rela.plt) } - /* Internal text space or external memory. */ - .text : - { - *(.vectors) - KEEP(*(.vectors)) - /* For data that needs to reside in the lower 64k of progmem. */ - *(.progmem.gcc*) - *(.progmem*) - . = ALIGN(2); - __trampolines_start = . ; - /* The jump trampolines for the 16-bit limited relocs will reside here. */ - *(.trampolines) - *(.trampolines*) - __trampolines_end = . ; - /* For future tablejump instruction arrays for 3 byte pc devices. - We don't relax jump/call instructions within these sections. */ - *(.jumptables) - *(.jumptables*) - /* For code that needs to reside in the lower 128k progmem. */ - *(.lowtext) - *(.lowtext*) - __ctors_start = . ; - *(.ctors) - __ctors_end = . ; - __dtors_start = . ; - *(.dtors) - __dtors_end = . ; - KEEP(SORT(*)(.ctors)) - KEEP(SORT(*)(.dtors)) - /* From this point on, we don't bother about wether the insns are - below or above the 16 bits boundary. */ - *(.init0) /* Start here after reset. */ - KEEP (*(.init0)) - *(.init1) - KEEP (*(.init1)) - *(.init2) /* Clear __zero_reg__, set up stack pointer. */ - KEEP (*(.init2)) - *(.init3) - KEEP (*(.init3)) - *(.init4) /* Initialize data and BSS. */ - KEEP (*(.init4)) - *(.init5) - KEEP (*(.init5)) - *(.init6) /* C++ constructors. */ - KEEP (*(.init6)) - *(.init7) - KEEP (*(.init7)) - *(.init8) - KEEP (*(.init8)) - *(.init9) /* Call main(). */ - KEEP (*(.init9)) - *(.text) - . = ALIGN(2); - *(.text.*) - . = ALIGN(2); - *(.fini9) /* _exit() starts here. */ - KEEP (*(.fini9)) - *(.fini8) - KEEP (*(.fini8)) - *(.fini7) - KEEP (*(.fini7)) - *(.fini6) /* C++ destructors. */ - KEEP (*(.fini6)) - *(.fini5) - KEEP (*(.fini5)) - *(.fini4) - KEEP (*(.fini4)) - *(.fini3) - KEEP (*(.fini3)) - *(.fini2) - KEEP (*(.fini2)) - *(.fini1) - KEEP (*(.fini1)) - *(.fini0) /* Infinite loop after program termination. */ - KEEP (*(.fini0)) - _etext = . ; - } > text - .data : AT (ADDR (.text) + SIZEOF (.text)) - { - PROVIDE (__data_start = .) ; - *(.data) - *(.data*) - *(.rodata) /* We need to include .rodata here if gcc is used */ - *(.rodata*) /* with -fdata-sections. */ - *(.gnu.linkonce.d*) - . = ALIGN(2); - _edata = . ; - PROVIDE (__data_end = .) ; - } > data - .bss : AT (ADDR (.bss)) - { - PROVIDE (__bss_start = .) ; - *(.bss) - *(.bss*) - *(COMMON) - PROVIDE (__bss_end = .) ; - } > data - __data_load_start = LOADADDR(.data); - __data_load_end = __data_load_start + SIZEOF(.data); - /* Global data not cleared after reset. */ - .noinit : - { - PROVIDE (__noinit_start = .) ; - *(.noinit*) - PROVIDE (__noinit_end = .) ; - _end = . ; - PROVIDE (__heap_start = .) ; - } > data - /* keymap region is located at end of flash - * .fn_actions Fn actions definitions - * .keymaps Mapping layers - */ - .keymap : - { - PROVIDE(__keymap_start = .) ; - *(.keymap.fn_actions) /* 32*actions = 64bytes */ - . = ALIGN(0x40); - *(.keymap.keymaps) /* rest of .keymap section */ - *(.keymap*) - /* . = ALIGN(0x800); */ /* keymap section takes 2KB- */ - } > keymap = 0x00 /* zero fill */ - .eeprom : - { - *(.eeprom*) - __eeprom_end = . ; - } > eeprom - .fuse : - { - KEEP(*(.fuse)) - KEEP(*(.lfuse)) - KEEP(*(.hfuse)) - KEEP(*(.efuse)) - } > fuse - .lock : - { - KEEP(*(.lock*)) - } > lock - .signature : - { - KEEP(*(.signature*)) - } > signature - /* Stabs debugging sections. */ - .stab 0 : { *(.stab) } - .stabstr 0 : { *(.stabstr) } - .stab.excl 0 : { *(.stab.excl) } - .stab.exclstr 0 : { *(.stab.exclstr) } - .stab.index 0 : { *(.stab.index) } - .stab.indexstr 0 : { *(.stab.indexstr) } - .comment 0 : { *(.comment) } - /* DWARF debug sections. - Symbols in the DWARF debugging sections are relative to the beginning - of the section so we begin them at 0. */ - /* DWARF 1 */ - .debug 0 : { *(.debug) } - .line 0 : { *(.line) } - /* GNU DWARF 1 extensions */ - .debug_srcinfo 0 : { *(.debug_srcinfo) } - .debug_sfnames 0 : { *(.debug_sfnames) } - /* DWARF 1.1 and DWARF 2 */ - .debug_aranges 0 : { *(.debug_aranges) } - .debug_pubnames 0 : { *(.debug_pubnames) } - /* DWARF 2 */ - .debug_info 0 : { *(.debug_info) *(.gnu.linkonce.wi.*) } - .debug_abbrev 0 : { *(.debug_abbrev) } - .debug_line 0 : { *(.debug_line) } - .debug_frame 0 : { *(.debug_frame) } - .debug_str 0 : { *(.debug_str) } - .debug_loc 0 : { *(.debug_loc) } - .debug_macinfo 0 : { *(.debug_macinfo) } -} 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 @@ PROTOCOL_DIR = protocol - -ifdef PS2_MOUSE_ENABLE +ifeq ($(strip $(PS2_MOUSE_ENABLE)), yes) SRC += $(PROTOCOL_DIR)/ps2_mouse.c OPT_DEFS += -DPS2_MOUSE_ENABLE OPT_DEFS += -DMOUSE_ENABLE endif -ifdef PS2_USE_BUSYWAIT +ifeq ($(strip $(PS2_USE_BUSYWAIT)), yes) SRC += protocol/ps2_busywait.c SRC += protocol/ps2_io_avr.c OPT_DEFS += -DPS2_USE_BUSYWAIT endif -ifdef PS2_USE_INT +ifeq ($(strip $(PS2_USE_INT)), yes) SRC += protocol/ps2_interrupt.c SRC += protocol/ps2_io_avr.c OPT_DEFS += -DPS2_USE_INT endif -ifdef PS2_USE_USART +ifeq ($(strip $(PS2_USE_USART)), yes) SRC += protocol/ps2_usart.c SRC += protocol/ps2_io_avr.c OPT_DEFS += -DPS2_USE_USART endif -ifdef SERIAL_MOUSE_MICROSOFT_ENABLE +ifeq ($(strip $(SERIAL_MOUSE_MICROSOFT_ENABLE)), yes) SRC += $(PROTOCOL_DIR)/serial_mouse_microsoft.c OPT_DEFS += -DSERIAL_MOUSE_ENABLE -DSERIAL_MOUSE_MICROSOFT \ -DMOUSE_ENABLE endif -ifdef SERIAL_MOUSE_MOUSESYSTEMS_ENABLE +ifeq ($(strip $(SERIAL_MOUSE_MOUSESYSTEMS_ENABLE)), yes) SRC += $(PROTOCOL_DIR)/serial_mouse_mousesystems.c OPT_DEFS += -DSERIAL_MOUSE_ENABLE -DSERIAL_MOUSE_MOUSESYSTEMS \ -DMOUSE_ENABLE endif -ifdef SERIAL_MOUSE_USE_SOFT +ifeq ($(strip $(SERIAL_MOUSE_USE_SOFT)), yes) SRC += $(PROTOCOL_DIR)/serial_soft.c endif -ifdef SERIAL_MOUSE_USE_UART +ifeq ($(strip $(SERIAL_MOUSE_USE_UART)), yes) SRC += $(PROTOCOL_DIR)/serial_uart.c endif -ifdef ADB_MOUSE_ENABLE - OPT_DEFS += -DADB_MOUSE_ENABLE -DMOUSE_ENABLE +ifeq ($(strip $(ADB_MOUSE_ENABLE)), yes) + OPT_DEFS += -DADB_MOUSE_ENABLE -DMOUSE_ENABLE endif -ifdef XT_ENABLE - SRC += $(PROTOCOL_DIR)/xt_interrupt.c - OPT_DEFS += -DXT_ENABLE +ifeq ($(strip $(XT_ENABLE)), yes) + SRC += $(PROTOCOL_DIR)/xt_interrupt.c + OPT_DEFS += -DXT_ENABLE endif # 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) { #ifdef RAW_ENABLE raw_hid_task(); #endif -#if defined(RGBLIGHT_ANIMATIONS) && defined(RGBLIGHT_ENABLE) - rgblight_task(); -#endif } } 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 @@ * GPL v2 or later. */ +/* + * Implementation notes: + * + * USBEndpointConfig - Configured using explicit order instead of struct member name. + * This is due to ChibiOS hal LLD differences, which is dependent on hardware, + * "USBv1" devices have `ep_buffers` and "OTGv1" have `in_multiplier`. + * Given `USBv1/hal_usb_lld.h` marks the field as "not currently used" this code file + * makes the assumption this is safe to avoid littering with preprocessor directives. + */ + #include "ch.h" #include "hal.h" @@ -98,7 +108,7 @@ static const USBDescriptor *usb_get_descriptor_cb(USBDriver *usbp, uint8_t dtype #ifndef KEYBOARD_SHARED_EP /* keyboard endpoint state structure */ static USBInEndpointState kbd_ep_state; -/* keyboard endpoint initialization structure (IN) */ +/* keyboard endpoint initialization structure (IN) - see USBEndpointConfig comment at top of file */ static const USBEndpointConfig kbd_ep_config = { USB_EP_MODE_TYPE_INTR, /* Interrupt EP */ NULL, /* SETUP packet notification callback */ @@ -117,7 +127,7 @@ static const USBEndpointConfig kbd_ep_config = { /* mouse endpoint state structure */ static USBInEndpointState mouse_ep_state; -/* mouse endpoint initialization structure (IN) */ +/* mouse endpoint initialization structure (IN) - see USBEndpointConfig comment at top of file */ static const USBEndpointConfig mouse_ep_config = { USB_EP_MODE_TYPE_INTR, /* Interrupt EP */ NULL, /* SETUP packet notification callback */ @@ -136,7 +146,7 @@ static const USBEndpointConfig mouse_ep_config = { /* shared endpoint state structure */ static USBInEndpointState shared_ep_state; -/* shared endpoint initialization structure (IN) */ +/* shared endpoint initialization structure (IN) - see USBEndpointConfig comment at top of file */ static const USBEndpointConfig shared_ep_config = { USB_EP_MODE_TYPE_INTR, /* Interrupt EP */ NULL, /* SETUP packet notification callback */ @@ -164,58 +174,62 @@ typedef struct { QMKUSBDriver driver; } usb_driver_config_t; -#define QMK_USB_DRIVER_CONFIG(stream, notification, fixedsize) \ - { \ - .queue_capacity_in = stream##_IN_CAPACITY, .queue_capacity_out = stream##_OUT_CAPACITY, \ - .in_ep_config = {.ep_mode = stream##_IN_MODE, \ - .setup_cb = NULL, \ - .in_cb = qmkusbDataTransmitted, \ - .out_cb = NULL, \ - .in_maxsize = stream##_EPSIZE, \ - .out_maxsize = 0, /* The pointer to the states will be filled during initialization */ \ - .in_state = NULL, \ - .out_state = NULL, \ - .ep_buffers = 2, \ - .setup_buf = NULL}, \ - .out_ep_config = \ - { \ - .ep_mode = stream##_OUT_MODE, \ - .setup_cb = NULL, \ - .in_cb = NULL, \ - .out_cb = qmkusbDataReceived, \ - .in_maxsize = 0, \ - .out_maxsize = stream##_EPSIZE, /* The pointer to the states will be filled during initialization */ \ - .in_state = NULL, \ - .out_state = NULL, \ - .ep_buffers = 2, \ - .setup_buf = NULL, \ - }, \ - .int_ep_config = \ - { \ - .ep_mode = USB_EP_MODE_TYPE_INTR, \ - .setup_cb = NULL, \ - .in_cb = qmkusbInterruptTransmitted, \ - .out_cb = NULL, \ - .in_maxsize = CDC_NOTIFICATION_EPSIZE, \ - .out_maxsize = 0, /* The pointer to the states will be filled during initialization */ \ - .in_state = NULL, \ - .out_state = NULL, \ - .ep_buffers = 2, \ - .setup_buf = NULL, \ - }, \ - .config = { \ - .usbp = &USB_DRIVER, \ - .bulk_in = stream##_IN_EPNUM, \ - .bulk_out = stream##_OUT_EPNUM, \ - .int_in = notification, \ - .in_buffers = stream##_IN_CAPACITY, \ - .out_buffers = stream##_OUT_CAPACITY, \ - .in_size = stream##_EPSIZE, \ - .out_size = stream##_EPSIZE, \ - .fixed_size = fixedsize, \ - .ib = (uint8_t[BQ_BUFFER_SIZE(stream##_IN_CAPACITY, stream##_EPSIZE)]){}, \ - .ob = (uint8_t[BQ_BUFFER_SIZE(stream##_OUT_CAPACITY, stream##_EPSIZE)]){}, \ - } \ +/* Reusable initialization structure - see USBEndpointConfig comment at top of file */ +#define QMK_USB_DRIVER_CONFIG(stream, notification, fixedsize) \ + { \ + .queue_capacity_in = stream##_IN_CAPACITY, .queue_capacity_out = stream##_OUT_CAPACITY, \ + .in_ep_config = \ + { \ + stream##_IN_MODE, /* Interrupt EP */ \ + NULL, /* SETUP packet notification callback */ \ + qmkusbDataTransmitted, /* IN notification callback */ \ + NULL, /* OUT notification callback */ \ + stream##_EPSIZE, /* IN maximum packet size */ \ + 0, /* OUT maximum packet size */ \ + NULL, /* IN Endpoint state */ \ + NULL, /* OUT endpoint state */ \ + 2, /* IN multiplier */ \ + NULL /* SETUP buffer (not a SETUP endpoint) */ \ + }, \ + .out_ep_config = \ + { \ + stream##_OUT_MODE, /* Interrupt EP */ \ + NULL, /* SETUP packet notification callback */ \ + NULL, /* IN notification callback */ \ + qmkusbDataReceived, /* OUT notification callback */ \ + 0, /* IN maximum packet size */ \ + stream##_EPSIZE, /* OUT maximum packet size */ \ + NULL, /* IN Endpoint state */ \ + NULL, /* OUT endpoint state */ \ + 2, /* IN multiplier */ \ + NULL, /* SETUP buffer (not a SETUP endpoint) */ \ + }, \ + .int_ep_config = \ + { \ + USB_EP_MODE_TYPE_INTR, /* Interrupt EP */ \ + NULL, /* SETUP packet notification callback */ \ + qmkusbInterruptTransmitted, /* IN notification callback */ \ + NULL, /* OUT notification callback */ \ + CDC_NOTIFICATION_EPSIZE, /* IN maximum packet size */ \ + 0, /* OUT maximum packet size */ \ + NULL, /* IN Endpoint state */ \ + NULL, /* OUT endpoint state */ \ + 2, /* IN multiplier */ \ + NULL, /* SETUP buffer (not a SETUP endpoint) */ \ + }, \ + .config = { \ + .usbp = &USB_DRIVER, \ + .bulk_in = stream##_IN_EPNUM, \ + .bulk_out = stream##_OUT_EPNUM, \ + .int_in = notification, \ + .in_buffers = stream##_IN_CAPACITY, \ + .out_buffers = stream##_OUT_CAPACITY, \ + .in_size = stream##_EPSIZE, \ + .out_size = stream##_EPSIZE, \ + .fixed_size = fixedsize, \ + .ib = (uint8_t[BQ_BUFFER_SIZE(stream##_IN_CAPACITY, stream##_EPSIZE)]){}, \ + .ob = (uint8_t[BQ_BUFFER_SIZE(stream##_OUT_CAPACITY, stream##_EPSIZE)]){}, \ + } \ } typedef struct { @@ -367,7 +381,7 @@ static uint16_t get_hword(uint8_t *p) { * Other Device Required Optional Optional Optional Optional Optional */ -#ifdef SHARED_EP_ENABLE +#if defined(SHARED_EP_ENABLE) && !defined(KEYBOARD_SHARED_EP) static uint8_t set_report_buf[2] __attribute__((aligned(2))); static void set_led_transfer_cb(USBDriver *usbp) { 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); } void send_keyboard(report_keyboard_t *report) { osalSysLock(); if (usbGetDriverStateI(&USB_DRIVER) != USB_ACTIVE) { - osalSysUnlock(); - return; + goto unlock; } - osalSysUnlock(); #ifdef NKRO_ENABLE if (keymap_config.nkro && keyboard_protocol) { /* NKRO protocol */ @@ -618,28 +630,35 @@ void send_keyboard(report_keyboard_t *report) { * until *after* the packet has been transmitted. I think * this is more efficient */ /* busy wait, should be short and not very common */ - osalSysLock(); if (usbGetTransmitStatusI(&USB_DRIVER, SHARED_IN_EPNUM)) { /* Need to either suspend, or loop and call unlock/lock during * every iteration - otherwise the system will remain locked, * no interrupts served, so USB not going through as well. * Note: for suspend, need USB_USE_WAIT == TRUE in halconf.h */ osalThreadSuspendS(&(&USB_DRIVER)->epc[SHARED_IN_EPNUM]->in_state->thread); + + /* after osalThreadSuspendS returns USB status might have changed */ + if (usbGetDriverStateI(&USB_DRIVER) != USB_ACTIVE) { + goto unlock; + } } usbStartTransmitI(&USB_DRIVER, SHARED_IN_EPNUM, (uint8_t *)report, sizeof(struct nkro_report)); - osalSysUnlock(); } else #endif /* NKRO_ENABLE */ { /* regular protocol */ /* need to wait until the previous packet has made it through */ /* busy wait, should be short and not very common */ - osalSysLock(); if (usbGetTransmitStatusI(&USB_DRIVER, KEYBOARD_IN_EPNUM)) { /* Need to either suspend, or loop and call unlock/lock during * every iteration - otherwise the system will remain locked, * no interrupts served, so USB not going through as well. * Note: for suspend, need USB_USE_WAIT == TRUE in halconf.h */ osalThreadSuspendS(&(&USB_DRIVER)->epc[KEYBOARD_IN_EPNUM]->in_state->thread); + + /* after osalThreadSuspendS returns USB status might have changed */ + if (usbGetDriverStateI(&USB_DRIVER) != USB_ACTIVE) { + goto unlock; + } } uint8_t *data, size; if (keyboard_protocol) { @@ -650,9 +669,11 @@ void send_keyboard(report_keyboard_t *report) { size = 8; } usbStartTransmitI(&USB_DRIVER, KEYBOARD_IN_EPNUM, data, size); - osalSysUnlock(); } keyboard_report_sent = *report; + +unlock: + osalSysUnlock(); } /* --------------------------------------------------------- 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) { case KC_BSLASH: return '\\'; case KC_NONUS_HASH: - return '\\'; + return '#'; case KC_SCOLON: return ';'; 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) { */ static void setup_mcu(void) { /* Disable watchdog if enabled by bootloader/fuses */ - MCUSR &= ~(1 << WDRF); + MCUSR &= ~_BV(WDRF); wdt_disable(); /* Disable clock division */ - // clock_prescale_set(clock_div_1); - - CLKPR = (1 << CLKPCE); - CLKPR = (0 << CLKPS3) | (0 << CLKPS2) | (0 << CLKPS1) | (0 << CLKPS0); + clock_prescale_set(clock_div_1); } /** \brief Setup USB @@ -1001,10 +998,6 @@ int main(void) { MIDI_Device_USBTask(&USB_MIDI_Interface); #endif -#if defined(RGBLIGHT_ANIMATIONS) && defined(RGBLIGHT_ENABLE) - rgblight_task(); -#endif - #ifdef MODULE_ADAFRUIT_BLE adafruit_ble_task(); #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 @@ -#include <stdint.h> -#include "USBHID.h" -#include "USBHID_Types.h" -#include "USBDescriptor.h" -#include "HIDKeyboard.h" - -#define DEFAULT_CONFIGURATION (1) - -HIDKeyboard::HIDKeyboard(uint16_t vendor_id, uint16_t product_id, uint16_t product_release) : USBDevice(vendor_id, product_id, product_release) { USBDevice::connect(); } - -bool HIDKeyboard::sendReport(report_keyboard_t report) { - USBDevice::write(EP1IN, report.raw, sizeof(report), MAX_PACKET_SIZE_EP1); - return true; -} - -uint8_t HIDKeyboard::leds() { return led_state; } - -bool HIDKeyboard::USBCallback_setConfiguration(uint8_t configuration) { - if (configuration != DEFAULT_CONFIGURATION) { - return false; - } - - // Configure endpoints > 0 - addEndpoint(EPINT_IN, MAX_PACKET_SIZE_EPINT); - // addEndpoint(EPINT_OUT, MAX_PACKET_SIZE_EPINT); - - // We activate the endpoint to be able to recceive data - // readStart(EPINT_OUT, MAX_PACKET_SIZE_EPINT); - return true; -} - -uint8_t *HIDKeyboard::stringImanufacturerDesc() { - static uint8_t stringImanufacturerDescriptor[] = { - 0x18, /*bLength*/ - STRING_DESCRIPTOR, /*bDescriptorType 0x03*/ - 't', - 0, - 'm', - 0, - 'k', - 0, - '-', - 0, - 'k', - 0, - 'b', - 0, - 'd', - 0, - '.', - 0, - 'c', - 0, - 'o', - 0, - 'm', - 0 /*bString iManufacturer*/ - }; - return stringImanufacturerDescriptor; -} - -uint8_t *HIDKeyboard::stringIproductDesc() { - static uint8_t stringIproductDescriptor[] = { - 0x0a, /*bLength*/ - STRING_DESCRIPTOR, /*bDescriptorType 0x03*/ - 'm', - 0, - 'b', - 0, - 'e', - 0, - 'd', - 0 /*bString iProduct*/ - }; - return stringIproductDescriptor; -} - -uint8_t *HIDKeyboard::stringIserialDesc() { - static uint8_t stringIserialDescriptor[] = { - 0x04, /*bLength*/ - STRING_DESCRIPTOR, /*bDescriptorType 0x03*/ - '0', 0 /*bString iSerial*/ - }; - return stringIserialDescriptor; -} - -uint8_t *HIDKeyboard::reportDesc() { - static uint8_t reportDescriptor[] = { - USAGE_PAGE(1), 0x01, // Generic Desktop - USAGE(1), 0x06, // Keyboard - COLLECTION(1), 0x01, // Application - - USAGE_PAGE(1), 0x07, // Key Codes - 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 - - REPORT_COUNT(1), 0x01, REPORT_SIZE(1), 0x08, INPUT(1), 0x01, // Constant - - REPORT_COUNT(1), 0x05, REPORT_SIZE(1), 0x01, USAGE_PAGE(1), 0x08, // LEDs - USAGE_MINIMUM(1), 0x01, USAGE_MAXIMUM(1), 0x05, OUTPUT(1), 0x02, // Data, Variable, Absolute - - REPORT_COUNT(1), 0x01, REPORT_SIZE(1), 0x03, OUTPUT(1), 0x01, // Constant - - REPORT_COUNT(1), 0x06, REPORT_SIZE(1), 0x08, LOGICAL_MINIMUM(1), 0x00, LOGICAL_MAXIMUM(1), 0xFF, USAGE_PAGE(1), 0x07, // Key Codes - USAGE_MINIMUM(1), 0x00, USAGE_MAXIMUM(1), 0xFF, INPUT(1), 0x00, // Data, Array - END_COLLECTION(0), - }; - reportLength = sizeof(reportDescriptor); - return reportDescriptor; -} - -uint16_t HIDKeyboard::reportDescLength() { - reportDesc(); - return reportLength; -} - -#define TOTAL_DESCRIPTOR_LENGTH ((1 * CONFIGURATION_DESCRIPTOR_LENGTH) + (1 * INTERFACE_DESCRIPTOR_LENGTH) + (1 * HID_DESCRIPTOR_LENGTH) + (1 * ENDPOINT_DESCRIPTOR_LENGTH)) -uint8_t *HIDKeyboard::configurationDesc() { - static uint8_t configurationDescriptor[] = { - CONFIGURATION_DESCRIPTOR_LENGTH, // bLength - CONFIGURATION_DESCRIPTOR, // bDescriptorType - LSB(TOTAL_DESCRIPTOR_LENGTH), // wTotalLength (LSB) - MSB(TOTAL_DESCRIPTOR_LENGTH), // wTotalLength (MSB) - 0x01, // bNumInterfaces - DEFAULT_CONFIGURATION, // bConfigurationValue - 0x00, // iConfiguration - C_RESERVED | C_REMOTE_WAKEUP, // bmAttributes - C_POWER(100), // bMaxPowerHello World from Mbed - - INTERFACE_DESCRIPTOR_LENGTH, // bLength - INTERFACE_DESCRIPTOR, // bDescriptorType - 0x00, // bInterfaceNumber - 0x00, // bAlternateSetting - 0x01, // bNumEndpoints - HID_CLASS, // bInterfaceClass - 1, // bInterfaceSubClass (boot) - 1, // bInterfaceProtocol (keyboard) - 0x00, // iInterface - - HID_DESCRIPTOR_LENGTH, // bLength - HID_DESCRIPTOR, // bDescriptorType - LSB(HID_VERSION_1_11), // bcdHID (LSB) - MSB(HID_VERSION_1_11), // bcdHID (MSB) - 0x00, // bCountryCode - 0x01, // bNumDescriptors - REPORT_DESCRIPTOR, // bDescriptorType - (uint8_t)(LSB(reportDescLength())), // wDescriptorLength (LSB) - (uint8_t)(MSB(reportDescLength())), // wDescriptorLength (MSB) - - ENDPOINT_DESCRIPTOR_LENGTH, // bLength - ENDPOINT_DESCRIPTOR, // bDescriptorType - PHY_TO_DESC(EP1IN), // bEndpointAddress - E_INTERRUPT, // bmAttributes - LSB(MAX_PACKET_SIZE_EPINT), // wMaxPacketSize (LSB) - MSB(MAX_PACKET_SIZE_EPINT), // wMaxPacketSize (MSB) - 1, // bInterval (milliseconds) - }; - return configurationDescriptor; -} - -#if 0 -uint8_t * HIDKeyboard::deviceDesc() { - static uint8_t deviceDescriptor[] = { - DEVICE_DESCRIPTOR_LENGTH, /* bLength */ - DEVICE_DESCRIPTOR, /* bDescriptorType */ - LSB(USB_VERSION_2_0), /* bcdUSB (LSB) */ - MSB(USB_VERSION_2_0), /* bcdUSB (MSB) */ - 0x00, /* bDeviceClass */ - 0x00, /* bDeviceSubClass */ - 0x00, /* bDeviceprotocol */ - MAX_PACKET_SIZE_EP0, /* bMaxPacketSize0 */ - (uint8_t)(LSB(0xfeed)), /* idVendor (LSB) */ - (uint8_t)(MSB(0xfeed)), /* idVendor (MSB) */ - (uint8_t)(LSB(0x1bed)), /* idProduct (LSB) */ - (uint8_t)(MSB(0x1bed)), /* idProduct (MSB) */ - (uint8_t)(LSB(0x0002)), /* bcdDevice (LSB) */ - (uint8_t)(MSB(0x0002)), /* bcdDevice (MSB) */ - 0, /* iManufacturer */ - 0, /* iProduct */ - 0, /* iSerialNumber */ - 0x01 /* bNumConfigurations */ - }; - return deviceDescriptor; -} -#endif - -bool HIDKeyboard::USBCallback_request() { - bool success = false; - CONTROL_TRANSFER *transfer = getTransferPtr(); - uint8_t * hidDescriptor; - - // Process additional standard requests - - if ((transfer->setup.bmRequestType.Type == STANDARD_TYPE)) { - switch (transfer->setup.bRequest) { - case GET_DESCRIPTOR: - switch (DESCRIPTOR_TYPE(transfer->setup.wValue)) { - case REPORT_DESCRIPTOR: - if ((reportDesc() != NULL) && (reportDescLength() != 0)) { - transfer->remaining = reportDescLength(); - transfer->ptr = reportDesc(); - transfer->direction = DEVICE_TO_HOST; - success = true; - } - break; - case HID_DESCRIPTOR: - // Find the HID descriptor, after the configuration descriptor - hidDescriptor = findDescriptor(HID_DESCRIPTOR); - if (hidDescriptor != NULL) { - transfer->remaining = HID_DESCRIPTOR_LENGTH; - transfer->ptr = hidDescriptor; - transfer->direction = DEVICE_TO_HOST; - success = true; - } - break; - - default: - break; - } - break; - default: - break; - } - } - - // Process class-specific requests - if (transfer->setup.bmRequestType.Type == CLASS_TYPE) { - switch (transfer->setup.bRequest) { - case SET_REPORT: - // LED indicator - // TODO: check Interface and Report length? - // if (transfer->setup.wIndex == INTERFACE_KEYBOAD) { } - // if (transfer->setup.wLength == 1) - - transfer->remaining = 1; - // transfer->ptr = ?? what ptr should be set when OUT(not used?) - transfer->direction = HOST_TO_DEVICE; - transfer->notify = true; /* notify with USBCallback_requestCompleted */ - success = true; - default: - break; - } - } - - return success; -} - -void HIDKeyboard::USBCallback_requestCompleted(uint8_t *buf, uint32_t length) { - if (length > 0) { - CONTROL_TRANSFER *transfer = getTransferPtr(); - if (transfer->setup.bmRequestType.Type == CLASS_TYPE) { - switch (transfer->setup.bRequest) { - case SET_REPORT: - led_state = buf[0]; - break; - default: - break; - } - } - } -} 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 @@ -#ifndef HIDKEYBOARD_H - -# include "stdint.h" -# include "stdbool.h" -# include "USBHID.h" -# include "report.h" - -class HIDKeyboard : public USBDevice { - public: - HIDKeyboard(uint16_t vendor_id = 0xFEED, uint16_t product_id = 0xabed, uint16_t product_release = 0x0001); - - bool sendReport(report_keyboard_t report); - uint8_t leds(void); - - protected: - uint16_t reportLength; - virtual bool USBCallback_setConfiguration(uint8_t configuration); - virtual uint8_t* stringImanufacturerDesc(); - virtual uint8_t* stringIproductDesc(); - virtual uint8_t* stringIserialDesc(); - virtual uint16_t reportDescLength(); - virtual uint8_t* reportDesc(); - virtual uint8_t* configurationDesc(); - // virtual uint8_t * deviceDesc(); - virtual bool USBCallback_request(); - virtual void USBCallback_requestCompleted(uint8_t* buf, uint32_t length); - - private: - uint8_t led_state; -}; - -#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 @@ -#include "HIDKeyboard.h" -#include "host.h" -#include "host_driver.h" -#include "mbed_driver.h" - -HIDKeyboard keyboard; - -/* Host driver */ -static uint8_t keyboard_leds(void); -static void send_keyboard(report_keyboard_t *report); -static void send_mouse(report_mouse_t *report); -static void send_system(uint16_t data); -static void send_consumer(uint16_t data); - -host_driver_t mbed_driver = {keyboard_leds, send_keyboard, send_mouse, send_system, send_consumer}; - -static uint8_t keyboard_leds(void) { return keyboard.leds(); } -static void send_keyboard(report_keyboard_t *report) { keyboard.sendReport(*report); } -static void send_mouse(report_mouse_t *report) {} -static void send_system(uint16_t data) {} -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 @@ -#include "host_driver.h" - -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 @@ -#include <stdbool.h> -#include "ps2_io.h" -#include "gpio_api.h" - -static gpio_t clock; -static gpio_t data; - -/* - * Clock - */ -void clock_init(void) { - gpio_init(&clock, P0_9); - gpio_mode(&clock, OpenDrain | PullNone); -} - -void clock_lo(void) { - gpio_dir(&clock, PIN_OUTPUT); - gpio_write(&clock, 0); -} -void clock_hi(void) { - gpio_dir(&clock, PIN_OUTPUT); - gpio_write(&clock, 1); -} - -bool clock_in(void) { - gpio_dir(&clock, PIN_INPUT); - return gpio_read(&clock); -} - -/* - * Data - */ -void data_init(void) { - gpio_init(&data, P0_8); - gpio_mode(&data, OpenDrain | PullNone); -} - -void data_lo(void) { - gpio_dir(&data, PIN_OUTPUT); - gpio_write(&data, 0); -} - -void data_hi(void) { - gpio_dir(&data, PIN_OUTPUT); - gpio_write(&data, 1); -} - -bool data_in(void) { - gpio_dir(&data, PIN_INPUT); - return gpio_read(&data); -} 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. #endif /* debug for signal timing, see debug pin with oscilloscope */ -#define SERIAL_SOFT_DEBUG #ifdef SERIAL_SOFT_DEBUG # define SERIAL_SOFT_DEBUG_INIT() (DDRD |= 1 << 7) # define SERIAL_SOFT_DEBUG_TGL() (PORTD ^= 1 << 7) @@ -169,7 +168,7 @@ void serial_send(uint8_t data) { /* detect edge of start bit */ ISR(SERIAL_SOFT_RXD_VECT) { SERIAL_SOFT_DEBUG_TGL(); - SERIAL_SOFT_RXD_INT_ENTER() + SERIAL_SOFT_RXD_INT_ENTER(); uint8_t data = 0; 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) { // To prevent failing to configure NOT scan keyboard during configuration if (usbConfiguration && usbInterruptIsReady()) { keyboard_task(); - -#if defined(RGBLIGHT_ANIMATIONS) && defined(RGBLIGHT_ENABLE) - rgblight_task(); -#endif } vusb_transfer_keyboard(); } 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/>. #include "debug.h" #include "host_driver.h" #include "vusb.h" -#include "bootloader.h" #include <util/delay.h> static uint8_t vusb_keyboard_leds = 0; @@ -145,7 +144,7 @@ static void send_consumer(uint16_t data) { *------------------------------------------------------------------*/ static struct { uint16_t len; - enum { NONE, BOOTLOADER, SET_LED } kind; + enum { NONE, SET_LED } kind; } last_req; usbMsgLen_t usbFunctionSetup(uchar data[8]) { @@ -173,11 +172,6 @@ usbMsgLen_t usbFunctionSetup(uchar data[8]) { debug("SET_LED: "); last_req.kind = SET_LED; last_req.len = rq->wLength.word; -#ifdef BOOTLOADER_SIZE - } else if (rq->wValue.word == 0x0301) { - last_req.kind = BOOTLOADER; - last_req.len = rq->wLength.word; -#endif } return USB_NO_MSG; // to get data in usbFunctionWrite } else { @@ -204,11 +198,6 @@ uchar usbFunctionWrite(uchar *data, uchar len) { last_req.len = 0; return 1; break; - case BOOTLOADER: - usbDeviceDisconnect(); - bootloader_jump(); - return 1; - break; case NONE: default: 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) SIZE_MARGIN = 1024 check-size: - $(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)) + $(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)) $(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)) $(eval FREE_SIZE=$(shell expr $(MAX_SIZE) - $(CURRENT_SIZE))) $(eval OVER_SIZE=$(shell expr $(CURRENT_SIZE) - $(MAX_SIZE))) |