diff options
Diffstat (limited to 'tmk_core')
-rw-r--r-- | tmk_core/avr.mk | 1 | ||||
-rw-r--r-- | tmk_core/chibios.mk | 6 | ||||
-rw-r--r-- | tmk_core/common.mk | 9 | ||||
-rw-r--r-- | tmk_core/common/avr/bootloader.c | 54 | ||||
-rw-r--r-- | tmk_core/common/keyboard.c | 11 | ||||
-rw-r--r-- | tmk_core/common/matrix.h | 5 | ||||
-rw-r--r-- | tmk_core/protocol/chibios/main.c | 30 | ||||
-rw-r--r-- | tmk_core/rules.mk | 6 |
8 files changed, 99 insertions, 23 deletions
diff --git a/tmk_core/avr.mk b/tmk_core/avr.mk index 72be5e6da1..3bf2b34f88 100644 --- a/tmk_core/avr.mk +++ b/tmk_core/avr.mk @@ -10,6 +10,7 @@ AR = avr-ar rcs NM = avr-nm HEX = $(OBJCOPY) -O $(FORMAT) -R .eeprom -R .fuse -R .lock -R .signature EEP = $(OBJCOPY) -j .eeprom --set-section-flags=.eeprom="alloc,load" --change-section-lma .eeprom=0 --no-change-warnings -O $(FORMAT) +BIN = diff --git a/tmk_core/chibios.mk b/tmk_core/chibios.mk index 0abb933a8d..cb67ac6f25 100644 --- a/tmk_core/chibios.mk +++ b/tmk_core/chibios.mk @@ -113,6 +113,7 @@ AR = arm-none-eabi-ar NM = arm-none-eabi-nm HEX = $(OBJCOPY) -O $(FORMAT) EEP = +BIN = $(OBJCOPY) -O binary THUMBFLAGS = -DTHUMB_PRESENT -mno-thumb-interwork -DTHUMB_NO_INTERWORKING -mthumb -DTHUMB @@ -151,4 +152,7 @@ else ifneq ("$(wildcard $(KEYBOARD_PATH)/boards/$(BOARD)/bootloader_defs.h)","") endif # List any extra directories to look for libraries here. -EXTRALIBDIRS = $(RULESPATH)/ld
\ No newline at end of file +EXTRALIBDIRS = $(RULESPATH)/ld + +dfu-util: $(BUILD_DIR)/$(TARGET).bin sizeafter + dfu-util -D $(BUILD_DIR)/$(TARGET).bin
\ No newline at end of file diff --git a/tmk_core/common.mk b/tmk_core/common.mk index d71fba9bc1..5bae0d762f 100644 --- a/tmk_core/common.mk +++ b/tmk_core/common.mk @@ -97,6 +97,15 @@ ifeq ($(strip $(KEYMAP_SECTION_ENABLE)), yes) endif endif +ifeq ($(MASTER),right) + OPT_DEFS += -DMASTER_IS_ON_RIGHT +else + ifneq ($(MASTER),left) +$(error MASTER does not have a valid value(left/right)) + endif +endif + + # Version string OPT_DEFS += -DVERSION=$(shell (git describe --always --dirty || echo 'unknown') 2> /dev/null) diff --git a/tmk_core/common/avr/bootloader.c b/tmk_core/common/avr/bootloader.c index 7c744e8c79..fb9bf2d1c3 100644 --- a/tmk_core/common/avr/bootloader.c +++ b/tmk_core/common/avr/bootloader.c @@ -73,26 +73,46 @@ uint32_t reset_key __attribute__ ((section (".noinit"))); /* initialize MCU status by watchdog reset */ void bootloader_jump(void) { -#ifdef PROTOCOL_LUFA - USB_Disable(); - cli(); - _delay_ms(2000); -#endif + #ifndef CATERINA_BOOTLOADER -#ifdef PROTOCOL_PJRC - cli(); - UDCON = 1; - USBCON = (1<<FRZCLK); - UCSR1B = 0; - _delay_ms(5); -#endif + #ifdef PROTOCOL_LUFA + USB_Disable(); + cli(); + _delay_ms(2000); + #endif - // watchdog reset - reset_key = BOOTLOADER_RESET_KEY; - wdt_enable(WDTO_250MS); - for (;;); -} + #ifdef PROTOCOL_PJRC + cli(); + UDCON = 1; + USBCON = (1<<FRZCLK); + UCSR1B = 0; + _delay_ms(5); + #endif + + // watchdog reset + reset_key = BOOTLOADER_RESET_KEY; + wdt_enable(WDTO_250MS); + for (;;); + + #else + // this block may be optional + // TODO: figure it out + + uint16_t *const bootKeyPtr = (uint16_t *)0x0800; + // Value used by Caterina bootloader use to determine whether to run the + // sketch or the bootloader programmer. + uint16_t bootKey = 0x7777; + + *bootKeyPtr = bootKey; + + // setup watchdog timeout + wdt_enable(WDTO_60MS); + + while(1) {} // wait for watchdog timer to trigger + + #endif +} /* this runs before main() */ void bootloader_jump_after_watchdog_reset(void) __attribute__ ((used, naked, section (".init3"))); diff --git a/tmk_core/common/keyboard.c b/tmk_core/common/keyboard.c index 81df8eb73b..3a1262a9f9 100644 --- a/tmk_core/common/keyboard.c +++ b/tmk_core/common/keyboard.c @@ -49,6 +49,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. #ifdef RGBLIGHT_ENABLE # include "rgblight.h" #endif +#ifdef SERIAL_LINK_ENABLE +# include "serial_link/system/serial_link.h" +#endif #ifdef MATRIX_HAS_GHOST static bool has_ghost_in_row(uint8_t row) @@ -167,11 +170,15 @@ MATRIX_LOOP_END: #endif #ifdef SERIAL_MOUSE_ENABLE - serial_mouse_task(); + serial_mouse_task(); #endif #ifdef ADB_MOUSE_ENABLE - adb_mouse_task(); + adb_mouse_task(); +#endif + +#ifdef SERIAL_LINK_ENABLE + serial_link_update(); #endif // update LED diff --git a/tmk_core/common/matrix.h b/tmk_core/common/matrix.h index 71153a5f58..cee3593eee 100644 --- a/tmk_core/common/matrix.h +++ b/tmk_core/common/matrix.h @@ -72,6 +72,11 @@ 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/protocol/chibios/main.c b/tmk_core/protocol/chibios/main.c index 54bb6a8f55..aeb11752f4 100644 --- a/tmk_core/protocol/chibios/main.c +++ b/tmk_core/protocol/chibios/main.c @@ -35,6 +35,9 @@ #ifdef SLEEP_LED_ENABLE #include "sleep_led.h" #endif +#ifdef SERIAL_LINK_ENABLE +#include "serial_link/system/serial_link.h" +#endif #include "suspend.h" @@ -98,9 +101,27 @@ int main(void) { /* init printf */ init_printf(NULL,sendchar_pf); - /* Wait until the USB is active */ - while(USB_DRIVER.state != USB_ACTIVE) +#ifdef SERIAL_LINK_ENABLE + init_serial_link(); +#endif + + host_driver_t* driver = NULL; + + /* Wait until the USB or serial link is active */ + while (true) { + if(USB_DRIVER.state == USB_ACTIVE) { + driver = &chibios_driver; + break; + } +#ifdef SERIAL_LINK_ENABLE + if(is_serial_link_connected()) { + driver = get_serial_link_driver(); + break; + } + serial_link_update(); +#endif chThdSleepMilliseconds(50); + } /* Do need to wait here! * Otherwise the next print might start a transfer on console EP @@ -113,7 +134,7 @@ int main(void) { /* init TMK modules */ keyboard_init(); - host_set_driver(&chibios_driver); + host_set_driver(driver); #ifdef SLEEP_LED_ENABLE sleep_led_init(); @@ -128,6 +149,9 @@ int main(void) { print("[s]"); while(USB_DRIVER.state == USB_SUSPENDED) { /* Do this in the suspended state */ +#ifdef SERIAL_LINK_ENABLE + serial_link_update(); +#endif suspend_power_down(); // on AVR this deep sleeps for 15ms /* Remote wakeup */ if((USB_DRIVER.status & 2) && suspend_wakeup_condition()) { diff --git a/tmk_core/rules.mk b/tmk_core/rules.mk index 7d3d8f9a6b..352e9314b6 100644 --- a/tmk_core/rules.mk +++ b/tmk_core/rules.mk @@ -234,6 +234,7 @@ MSG_COFF = Converting to AVR COFF: MSG_EXTENDED_COFF = Converting to AVR Extended COFF: MSG_FLASH = Creating load file for Flash: MSG_EEPROM = Creating load file for EEPROM: +MSG_BIN = Creating binary load file for Flash: MSG_EXTENDED_LISTING = Creating Extended Listing: MSG_SYMBOL_TABLE = Creating Symbol Table: MSG_LINKING = Linking: @@ -369,6 +370,11 @@ gccversion : $(eval CMD=$(NM) -n $< > $@ ) @$(BUILD_CMD) +%.bin: %.elf + @$(SILENT) || printf "$(MSG_BIN) $@" | $(AWK_CMD) + $(eval CMD=$(BIN) $< $@ || exit 0) + @$(BUILD_CMD) + # Create library from object files. .SECONDARY : $(BUILD_DIR)/$(TARGET).a .PRECIOUS : $(OBJ) |