From: tmk Date: Sat, 17 Sep 2016 01:20:52 +0000 (+0900) Subject: ps2_usb: Change Makefiles X-Git-Url: https://git.friedersdorff.com/?a=commitdiff_plain;h=5ee5b6bd7eab427befd0e938a80242e06f7dbd30;p=max%2Ftmk_keyboard.git ps2_usb: Change Makefiles --- diff --git a/converter/ps2_usb/Makefile b/converter/ps2_usb/Makefile index dd034264..21a743b5 100644 --- a/converter/ps2_usb/Makefile +++ b/converter/ps2_usb/Makefile @@ -1,31 +1,39 @@ -# -# Makefile for Teensy -# # Target file name (without extension). -TARGET = ps2_usb_lufa +TARGET ?= ps2_usb # Directory common source filess exist -TMK_DIR = ../../tmk_core +TMK_DIR ?= ../../tmk_core # Directory keyboard dependent files exist -TARGET_DIR = . +TARGET_DIR ?= . # project specific files -SRC = matrix.c \ +SRC ?= matrix.c \ led.c +# +# Keymap file +# +ifdef UNIMAP_ENABLE + KEYMAP_FILE = unimap +else + ifdef ACTIONMAP_ENABLE + KEYMAP_FILE = actionmap + else + KEYMAP_FILE = keymap + endif +endif ifdef KEYMAP - SRC := keymap_$(KEYMAP).c $(SRC) + SRC := $(KEYMAP_FILE)_$(KEYMAP).c $(SRC) else - SRC := keymap_plain.c $(SRC) + SRC := $(KEYMAP_FILE)_plain.c $(SRC) endif -CONFIG_H = config.h +CONFIG_H ?= config.h # MCU name -#MCU = at90usb1287 -MCU = atmega32u4 +MCU ?= atmega32u2 # Processor frequency. # This will define a symbol, F_CPU, in all source code files equal to the @@ -38,14 +46,14 @@ MCU = atmega32u4 # does not *change* the processor frequency - it should merely be updated to # reflect the processor speed set externally so that the code can use accurate # software delays. -F_CPU = 16000000 +F_CPU ?= 16000000 # # LUFA specific # # Target architecture (see library "Board Types" documentation). -ARCH = AVR8 +ARCH ?= AVR8 # Input clock frequency. # This will define a symbol, F_USB, in all source code files equal to the @@ -58,7 +66,7 @@ ARCH = AVR8 # # If no clock division is performed on the input clock inside the AVR (via the # CPU clock adjust registers or the clock division fuses), this will be equal to F_CPU. -F_USB = $(F_CPU) +F_USB ?= $(F_CPU) # Interrupt driven control endpoint task(+60) #OPT_DEFS += -DINTERRUPT_CONTROL_ENDPOINT @@ -70,25 +78,26 @@ F_USB = $(F_CPU) # Atmel DFU loader 4096 # LUFA bootloader 4096 # USBaspLoader 2048 -OPT_DEFS += -DBOOTLOADER_SIZE=512 +BOOTLOADER_SIZE ?= 4096 +OPT_DEFS += -DBOOTLOADER_SIZE=$(BOOTLOADER_SIZE) # Build Options # comment out to disable the options. # -#BOOTMAGIC_ENABLE = yes # Virtual DIP switch configuration(+1000) -MOUSEKEY_ENABLE = yes # Mouse keys(+4700) -EXTRAKEY_ENABLE = yes # Audio control and System control(+450) -CONSOLE_ENABLE = yes # Console for debug(+400) -COMMAND_ENABLE = yes # Commands for debug and configuration -NKRO_ENABLE = yes # USB Nkey Rollover - not yet supported in LUFA +BOOTMAGIC_ENABLE ?= no # Virtual DIP switch configuration(+1000) +MOUSEKEY_ENABLE ?= no # Mouse keys(+4700) +EXTRAKEY_ENABLE ?= yes # Audio control and System control(+450) +CONSOLE_ENABLE ?= yes # Console for debug(+400) +COMMAND_ENABLE ?= yes # Commands for debug and configuration +NKRO_ENABLE ?= yes # USB Nkey Rollover - not yet supported in LUFA # PS/2 Options # -#PS2_USE_USART = yes # uses hardware USART engine for PS/2 signal receive(recomened) -PS2_USE_INT = yes # uses external interrupt for falling edge of PS/2 clock pin -#PS2_USE_BUSYWAIT = yes # uses primitive reference code +#PS2_USE_USART ?= yes # uses hardware USART engine for PS/2 signal receive(recomened) +PS2_USE_INT ?= yes # uses external interrupt for falling edge of PS/2 clock pin +#PS2_USE_BUSYWAIT ?= yes # uses primitive reference code # Optimize size but this may cause error "relocation truncated to fit" diff --git a/converter/ps2_usb/Makefile.pjrc b/converter/ps2_usb/Makefile.pjrc deleted file mode 100644 index 88ee387d..00000000 --- a/converter/ps2_usb/Makefile.pjrc +++ /dev/null @@ -1,74 +0,0 @@ -# Target file name (without extension). -TARGET = ps2_usb_pjrc - -# Directory common source filess exist -TMK_DIR = ../../tmk_core - -# Directory keyboard dependent files exist -TARGET_DIR = . - -# keyboard dependent files -SRC = matrix.c \ - led.c - -ifdef KEYMAP - SRC := keymap_$(KEYMAP).c $(SRC) -else - SRC := keymap_plain.c $(SRC) -endif - -CONFIG_H = config.h - - -# MCU name, you MUST set this to match the board you are using -# type "make clean" after changing this, so all files will be rebuilt -#MCU = at90usb162 # Teensy 1.0 -MCU = atmega32u4 # Teensy 2.0 -#MCU = at90usb646 # Teensy++ 1.0 -#MCU = at90usb1286 # Teensy++ 2.0 - - -# Processor frequency. -# Normally the first thing your program should do is set the clock prescaler, -# so your program will run at the correct speed. You should also set this -# variable to same clock speed. The _delay_ms() macro uses this, and many -# examples use this variable to calculate timings. Do not add a "UL" here. -F_CPU = 16000000 - - -# Boot Section Size in *bytes* -# Teensy halfKay 512 -# Teensy++ halfKay 1024 -# Atmel DFU loader 4096 -# LUFA bootloader 4096 -# USBaspLoader 2048 -OPT_DEFS += -DBOOTLOADER_SIZE=4096 - - -# Build Options -# *Comment out* to disable the options. -# -#BOOTMAGIC_ENABLE = yes # Virtual DIP switch configuration(+1000) -MOUSEKEY_ENABLE = yes # Mouse keys -EXTRAKEY_ENABLE = yes # Audio control and System control -CONSOLE_ENABLE = yes # Console for debug(+400) -COMMAND_ENABLE = yes # Commands for debug and configuration -NKRO_ENABLE = yes # USB Nkey Rollover - - -# PS/2 Options -# -#PS2_USE_USART = yes # uses hardware USART engine for PS/2 signal receive(recomened) -#PS2_USE_INT = yes # uses external interrupt for falling edge of PS/2 clock pin -PS2_USE_BUSYWAIT = yes # uses primitive reference code - - -# Search Path -VPATH += $(TARGET_DIR) -VPATH += $(TMK_DIR) - - -include $(TMK_DIR)/protocol.mk -include $(TMK_DIR)/protocol/pjrc.mk -include $(TMK_DIR)/common.mk -include $(TMK_DIR)/rules.mk diff --git a/converter/ps2_usb/Makefile.rev1 b/converter/ps2_usb/Makefile.rev1 new file mode 100644 index 00000000..0d607652 --- /dev/null +++ b/converter/ps2_usb/Makefile.rev1 @@ -0,0 +1,17 @@ +TARGET ?= ps2_usb_rev1 +MCU = atmega32u4 +CONFIG_H = config_rev1.h +BOOTLOADER_SIZE = 4096 + +BOOTMAGIC_ENABLE ?= no +MOUSEKEY_ENABLE ?= yes +EXTRAKEY_ENABLE ?= yes +CONSOLE_ENABLE ?= yes +COMMAND_ENABLE ?= yes +NKRO_ENABLE ?= yes + +PS2_USE_USART = yes +PS2_USE_INT = no +PS2_USE_BUSYWAIT = no + +include Makefile diff --git a/converter/ps2_usb/Makefile.rev2 b/converter/ps2_usb/Makefile.rev2 new file mode 100644 index 00000000..8b34d4fa --- /dev/null +++ b/converter/ps2_usb/Makefile.rev2 @@ -0,0 +1,17 @@ +TARGET ?= ps2_usb_rev2 +MCU = atmega32u2 +CONFIG_H = config_rev2.h +BOOTLOADER_SIZE = 4096 + +BOOTMAGIC_ENABLE ?= no +MOUSEKEY_ENABLE ?= no +EXTRAKEY_ENABLE ?= yes +CONSOLE_ENABLE ?= yes +COMMAND_ENABLE ?= yes +NKRO_ENABLE ?= yes + +PS2_USE_USART = no +PS2_USE_INT = yes +PS2_USE_BUSYWAIT = no + +include Makefile diff --git a/converter/ps2_usb/Makefile.tmk_rev1 b/converter/ps2_usb/Makefile.tmk_rev1 deleted file mode 100644 index 644845f9..00000000 --- a/converter/ps2_usb/Makefile.tmk_rev1 +++ /dev/null @@ -1,97 +0,0 @@ -# -# Makefile for TMK keyboard converter rev2 -# https://github.com/tmk/keyboard_converter#pcb-rev1 -# -# Target file name (without extension). -TARGET = ps2_usb_tmk_rev1 - -# Directory common source filess exist -TMK_DIR = ../../tmk_core - -# Directory keyboard dependent files exist -TARGET_DIR = . - -# project specific files -SRC = matrix.c \ - led.c - -ifdef KEYMAP - SRC := keymap_$(KEYMAP).c $(SRC) -else - SRC := keymap_plain.c $(SRC) -endif - -CONFIG_H = config_tmk_rev1.h - - -# MCU name -MCU = atmega32u4 - -# Processor frequency. -# This will define a symbol, F_CPU, in all source code files equal to the -# processor frequency in Hz. You can then use this symbol in your source code to -# calculate timings. Do NOT tack on a 'UL' at the end, this will be done -# automatically to create a 32-bit value in your source code. -# -# This will be an integer division of F_USB below, as it is sourced by -# F_USB after it has run through any CPU prescalers. Note that this value -# does not *change* the processor frequency - it should merely be updated to -# reflect the processor speed set externally so that the code can use accurate -# software delays. -F_CPU = 16000000 - - -# -# LUFA specific -# -# Target architecture (see library "Board Types" documentation). -ARCH = AVR8 - -# Input clock frequency. -# This will define a symbol, F_USB, in all source code files equal to the -# input clock frequency (before any prescaling is performed) in Hz. This value may -# differ from F_CPU if prescaling is used on the latter, and is required as the -# raw input clock is fed directly to the PLL sections of the AVR for high speed -# clock generation for the USB and other AVR subsections. Do NOT tack on a 'UL' -# at the end, this will be done automatically to create a 32-bit value in your -# source code. -# -# If no clock division is performed on the input clock inside the AVR (via the -# CPU clock adjust registers or the clock division fuses), this will be equal to F_CPU. -F_USB = $(F_CPU) - - -# Boot Section Size in *bytes* -# Teensy halfKay 512 -# Teensy++ halfKay 1024 -# Atmel DFU loader 4096 -# LUFA bootloader 4096 -# USBaspLoader 2048 -OPT_DEFS += -DBOOTLOADER_SIZE=4096 - - -# Build Options -# comment out to disable the options. -# -#BOOTMAGIC_ENABLE = yes # Virtual DIP switch configuration(+1000) -MOUSEKEY_ENABLE = yes # Mouse keys(+4700) -EXTRAKEY_ENABLE = yes # Audio control and System control(+450) -CONSOLE_ENABLE = yes # Console for debug(+400) -COMMAND_ENABLE = yes # Commands for debug and configuration -#NKRO_ENABLE = yes # USB Nkey Rollover - not yet supported in LUFA - - -# PS/2 Options -# -PS2_USE_USART = yes # uses hardware USART engine for PS/2 signal receive(recomened) -#PS2_USE_BUSYWAIT = yes # uses primitive reference code - - -# Search Path -VPATH += $(TARGET_DIR) -VPATH += $(TMK_DIR) - -include $(TMK_DIR)/protocol.mk -include $(TMK_DIR)/protocol/lufa.mk -include $(TMK_DIR)/common.mk -include $(TMK_DIR)/rules.mk diff --git a/converter/ps2_usb/Makefile.tmk_rev2 b/converter/ps2_usb/Makefile.tmk_rev2 deleted file mode 100644 index 83243280..00000000 --- a/converter/ps2_usb/Makefile.tmk_rev2 +++ /dev/null @@ -1,97 +0,0 @@ -# -# Makefile for TMK keyboard converter rev2 -# https://github.com/tmk/keyboard_converter#pcb-rev2 -# -# Target file name (without extension). -TARGET = ps2_usb_tmk_rev2 - -# Directory common source filess exist -TMK_DIR = ../../tmk_core - -# Directory keyboard dependent files exist -TARGET_DIR = . - -# project specific files -SRC = matrix.c \ - led.c - -ifdef KEYMAP - SRC := keymap_$(KEYMAP).c $(SRC) -else - SRC := keymap_plain.c $(SRC) -endif - -CONFIG_H = config_tmk_rev2.h - - -# MCU name -MCU = atmega32u2 - -# Processor frequency. -# This will define a symbol, F_CPU, in all source code files equal to the -# processor frequency in Hz. You can then use this symbol in your source code to -# calculate timings. Do NOT tack on a 'UL' at the end, this will be done -# automatically to create a 32-bit value in your source code. -# -# This will be an integer division of F_USB below, as it is sourced by -# F_USB after it has run through any CPU prescalers. Note that this value -# does not *change* the processor frequency - it should merely be updated to -# reflect the processor speed set externally so that the code can use accurate -# software delays. -F_CPU = 16000000 - - -# -# LUFA specific -# -# Target architecture (see library "Board Types" documentation). -ARCH = AVR8 - -# Input clock frequency. -# This will define a symbol, F_USB, in all source code files equal to the -# input clock frequency (before any prescaling is performed) in Hz. This value may -# differ from F_CPU if prescaling is used on the latter, and is required as the -# raw input clock is fed directly to the PLL sections of the AVR for high speed -# clock generation for the USB and other AVR subsections. Do NOT tack on a 'UL' -# at the end, this will be done automatically to create a 32-bit value in your -# source code. -# -# If no clock division is performed on the input clock inside the AVR (via the -# CPU clock adjust registers or the clock division fuses), this will be equal to F_CPU. -F_USB = $(F_CPU) - - -# Boot Section Size in *bytes* -# Teensy halfKay 512 -# Teensy++ halfKay 1024 -# Atmel DFU loader 4096 -# LUFA bootloader 4096 -# USBaspLoader 2048 -OPT_DEFS += -DBOOTLOADER_SIZE=4096 - - -# Build Options -# comment out to disable the options. -# -#BOOTMAGIC_ENABLE = yes # Virtual DIP switch configuration(+1000) -MOUSEKEY_ENABLE = yes # Mouse keys(+4700) -EXTRAKEY_ENABLE = yes # Audio control and System control(+450) -CONSOLE_ENABLE = yes # Console for debug(+400) -COMMAND_ENABLE = yes # Commands for debug and configuration -#NKRO_ENABLE = yes # USB Nkey Rollover - not yet supported in LUFA - - -# PS/2 Options -# -PS2_USE_INT = yes # uses external interrupt for falling edge of PS/2 clock pin -#PS2_USE_BUSYWAIT = yes # uses primitive reference code - - -# Search Path -VPATH += $(TARGET_DIR) -VPATH += $(TMK_DIR) - -include $(TMK_DIR)/protocol.mk -include $(TMK_DIR)/protocol/lufa.mk -include $(TMK_DIR)/common.mk -include $(TMK_DIR)/rules.mk diff --git a/converter/ps2_usb/Makefile.unimap.rev1 b/converter/ps2_usb/Makefile.unimap.rev1 new file mode 100644 index 00000000..c62b1874 --- /dev/null +++ b/converter/ps2_usb/Makefile.unimap.rev1 @@ -0,0 +1,5 @@ +TARGET = ps2_usb_rev1_unimap +UNIMAP_ENABLE = yes +KEYMAP_SECTION_ENABLE = yes + +include Makefile.rev1 diff --git a/converter/ps2_usb/Makefile.unimap.rev2 b/converter/ps2_usb/Makefile.unimap.rev2 new file mode 100644 index 00000000..5579f701 --- /dev/null +++ b/converter/ps2_usb/Makefile.unimap.rev2 @@ -0,0 +1,5 @@ +TARGET = ps2_usb_rev2_unimap +UNIMAP_ENABLE = yes +KEYMAP_SECTION_ENABLE = yes + +include Makefile.rev2 diff --git a/converter/ps2_usb/README.md b/converter/ps2_usb/README.md index 74464e26..1ad28589 100644 --- a/converter/ps2_usb/README.md +++ b/converter/ps2_usb/README.md @@ -5,36 +5,30 @@ This firmware converts PS/2 keyboard protocol to USB.(It supports Scan Code Set Connect Wires ------------- -In case of Teensy2.0(ATMega32U4): - 1. Connect **Vcc** and **GND**. 2. Connect **Clock** and **Data** line. - **Interrupt**: **Clock** is on `PD1` and **Data** on `PD0`.(Recommended. Soarer's converter compatible) - **Busywait**: **Clock** is on `PD1` and **Data** on `PD0`. - **USART**: **Clock** is on `PD5` and **Data** on `PD2`. -3. Optionally you need pull-up resistor. 1K-10K Ohm is OK. +3. You need pull-up resistors. 1K-10K Ohm would be fine. To change pin configuration edit **config.h** and **Makefile**. Build Firmware -------------- -For **PJRC Teensy** just run `make`: - - $ make clean - $ make - -To select keymap: +For **TMK converter Rev.2**: - $ make clean - $ make KEYMAP=[plain|jis|spacefn|...] + $ make -f Makefile.rev2 clean + $ make -f Makefile.rev2 KEYMAP=plain -After that you will find HEX file `ps2_usb_lufa.hex` in current directory. +To program firmware push the button on converter and run: + $ make -f Makefile.rev2 KEYMAP=plain dfu -- For **TMK converter Rev.1** use `make -f Makefile.tmk_rev1` instead of `make` and HEX file is `ps2_usb_tmk_rev1.hex`. -- For **TMK converter Rev.2** use `make -f Makefile.tmk_rev2` instead of `make` and HEX file is `ps2_usb_tmk_rev2.hex`. +- For **TMK converter Rev.1** use `make -f Makefile.rev1` instead. +- To select keymap use `jis`, `spacefn` or your own in place of `plain`. Keymap diff --git a/converter/ps2_usb/config_tmk_rev1.h b/converter/ps2_usb/config_rev1.h similarity index 100% rename from converter/ps2_usb/config_tmk_rev1.h rename to converter/ps2_usb/config_rev1.h diff --git a/converter/ps2_usb/config_tmk_rev2.h b/converter/ps2_usb/config_rev2.h similarity index 100% rename from converter/ps2_usb/config_tmk_rev2.h rename to converter/ps2_usb/config_rev2.h