From 9f041460313bc16e3f8a9677faced4d38d343d9a Mon Sep 17 00:00:00 2001 From: tmk Date: Sat, 28 Mar 2020 21:55:20 +0900 Subject: [PATCH 1/4] lufa: Fix comment on INTERRUPT_CONTROL_ENDPOINT --- tmk_core/protocol/lufa.mk | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tmk_core/protocol/lufa.mk b/tmk_core/protocol/lufa.mk index 0b4b7847..7afedd73 100644 --- a/tmk_core/protocol/lufa.mk +++ b/tmk_core/protocol/lufa.mk @@ -41,7 +41,8 @@ VPATH += $(TMK_DIR)/$(TMK_LUFA_PATH) TMK_LUFA_OPTS = -DUSB_DEVICE_ONLY TMK_LUFA_OPTS += -DUSE_FLASH_DESCRIPTORS TMK_LUFA_OPTS += -DUSE_STATIC_OPTIONS="(USB_DEVICE_OPT_FULLSPEED | USB_OPT_REG_ENABLED | USB_OPT_AUTO_PLL)" -# Do not enable this for converters in particular, it blocks other tasks long. +# Do not enable INTERRUPT_CONTROL_ENDPOINT for converters which requires ISR in particular, +# it can block other ISRs long like 500-1000us for HID keyboard LED report. #TMK_LUFA_OPTS += -DINTERRUPT_CONTROL_ENDPOINT TMK_LUFA_OPTS += -DFIXED_CONTROL_ENDPOINT_SIZE=8 TMK_LUFA_OPTS += -DFIXED_NUM_CONFIGURATIONS=1 From 2173767a78e3353f40b2bc6bb3f29bc67c896470 Mon Sep 17 00:00:00 2001 From: tmk Date: Sat, 28 Mar 2020 21:56:54 +0900 Subject: [PATCH 2/4] Remove INTERRUPT_CONTROL_ENDPOINT from converters The LUFA feature can prevent converter's ISR from handing signal instantly. The interrupt can block a while for Standard Device Requests and 500-1000us for keyboard LED report. --- converter/adb_usb/Makefile | 3 --- converter/ibm4704_usb/Makefile | 3 --- converter/ibmpc_usb/Makefile | 3 --- converter/m0110_usb/Makefile | 3 --- converter/news_usb/Makefile | 3 --- converter/next_usb/Makefile | 3 --- converter/pana_m8/Makefile | 1 - converter/pc88_usb/Makefile | 3 --- converter/pc88_usb/Makefile.unimap | 3 --- converter/pc98_usb/Makefile | 3 --- converter/ps2_usb/Makefile | 3 --- converter/sun_usb/Makefile | 3 --- converter/terminal_usb/Makefile | 3 --- converter/usb_usb/Makefile | 3 --- converter/x68k_usb/Makefile | 3 --- converter/xt_usb/Makefile | 3 --- 16 files changed, 46 deletions(-) diff --git a/converter/adb_usb/Makefile b/converter/adb_usb/Makefile index fe94d9f7..ba87b07e 100644 --- a/converter/adb_usb/Makefile +++ b/converter/adb_usb/Makefile @@ -53,9 +53,6 @@ ARCH ?= AVR8 # CPU clock adjust registers or the clock division fuses), this will be equal to F_CPU. F_USB ?= $(F_CPU) -# Interrupt driven control endpoint task(+60) -OPT_DEFS += -DINTERRUPT_CONTROL_ENDPOINT - # Boot Section Size in *bytes* # Teensy halfKay 512 diff --git a/converter/ibm4704_usb/Makefile b/converter/ibm4704_usb/Makefile index f930cb59..b6adf08d 100644 --- a/converter/ibm4704_usb/Makefile +++ b/converter/ibm4704_usb/Makefile @@ -70,9 +70,6 @@ ARCH ?= AVR8 # CPU clock adjust registers or the clock division fuses), this will be equal to F_CPU. F_USB ?= $(F_CPU) -# Interrupt driven control endpoint task(+60) -OPT_DEFS += -DINTERRUPT_CONTROL_ENDPOINT - # Boot Section Size in *bytes* # Teensy halfKay 512 diff --git a/converter/ibmpc_usb/Makefile b/converter/ibmpc_usb/Makefile index 2b272a59..30ce9248 100644 --- a/converter/ibmpc_usb/Makefile +++ b/converter/ibmpc_usb/Makefile @@ -50,9 +50,6 @@ ARCH ?= AVR8 # CPU clock adjust registers or the clock division fuses), this will be equal to F_CPU. F_USB ?= $(F_CPU) -# Interrupt driven control endpoint task. Do not enable this. -# This blocks long for capslock and etc. and can prevent signal handling. -#OPT_DEFS += -DINTERRUPT_CONTROL_ENDPOINT # This improves response of keyboard when wakeup OPT_DEFS += -DSUSPEND_MODE_STANDBY diff --git a/converter/m0110_usb/Makefile b/converter/m0110_usb/Makefile index 71d675ac..d54fe596 100644 --- a/converter/m0110_usb/Makefile +++ b/converter/m0110_usb/Makefile @@ -65,9 +65,6 @@ ARCH ?= AVR8 # CPU clock adjust registers or the clock division fuses), this will be equal to F_CPU. F_USB ?= $(F_CPU) -# Interrupt driven control endpoint task -OPT_DEFS += -DINTERRUPT_CONTROL_ENDPOINT - # Boot Section Size in bytes # Teensy halfKay 512 diff --git a/converter/news_usb/Makefile b/converter/news_usb/Makefile index e94a4f61..77a61e93 100644 --- a/converter/news_usb/Makefile +++ b/converter/news_usb/Makefile @@ -58,9 +58,6 @@ ARCH = AVR8 # CPU clock adjust registers or the clock division fuses), this will be equal to F_CPU. F_USB = $(F_CPU) -# Interrupt driven control endpoint task(+60) -OPT_DEFS += -DINTERRUPT_CONTROL_ENDPOINT - # Boot Section Size in *bytes* # Teensy halfKay 512 diff --git a/converter/next_usb/Makefile b/converter/next_usb/Makefile index f3143c25..7e6e7230 100644 --- a/converter/next_usb/Makefile +++ b/converter/next_usb/Makefile @@ -68,9 +68,6 @@ ARCH ?= AVR8 # CPU clock adjust registers or the clock division fuses), this will be equal to F_CPU. F_USB ?= $(F_CPU) -# Interrupt driven control endpoint task(+60) -#OPT_DEFS += -DINTERRUPT_CONTROL_ENDPOINT - # Boot Section Size in *bytes* # Teensy halfKay 512 diff --git a/converter/pana_m8/Makefile b/converter/pana_m8/Makefile index 93f3c462..39a5885e 100644 --- a/converter/pana_m8/Makefile +++ b/converter/pana_m8/Makefile @@ -10,7 +10,6 @@ OPT_DEFS += -DBOOTLOADER_SIZE=4096 # LUFA specific ARCH ?= AVR8 F_USB ?= $(F_CPU) -OPT_DEFS += -DINTERRUPT_CONTROL_ENDPOINT # Build Options diff --git a/converter/pc88_usb/Makefile b/converter/pc88_usb/Makefile index c6af9735..05be2234 100644 --- a/converter/pc88_usb/Makefile +++ b/converter/pc88_usb/Makefile @@ -49,9 +49,6 @@ ARCH ?= AVR8 # CPU clock adjust registers or the clock division fuses), this will be equal to F_CPU. F_USB ?= $(F_CPU) -# Interrupt driven control endpoint task -OPT_DEFS += -DINTERRUPT_CONTROL_ENDPOINT - # Build Options # *Comment out* to disable the options. diff --git a/converter/pc88_usb/Makefile.unimap b/converter/pc88_usb/Makefile.unimap index da526033..4e71d822 100644 --- a/converter/pc88_usb/Makefile.unimap +++ b/converter/pc88_usb/Makefile.unimap @@ -49,9 +49,6 @@ ARCH ?= AVR8 # CPU clock adjust registers or the clock division fuses), this will be equal to F_CPU. F_USB ?= $(F_CPU) -# Interrupt driven control endpoint task -OPT_DEFS += -DINTERRUPT_CONTROL_ENDPOINT - # Build Options # *Comment out* to disable the options. diff --git a/converter/pc98_usb/Makefile b/converter/pc98_usb/Makefile index 0f284a1b..5f7a0686 100644 --- a/converter/pc98_usb/Makefile +++ b/converter/pc98_usb/Makefile @@ -49,9 +49,6 @@ ARCH ?= AVR8 # CPU clock adjust registers or the clock division fuses), this will be equal to F_CPU. F_USB ?= $(F_CPU) -# Interrupt driven control endpoint task -#OPT_DEFS += -DINTERRUPT_CONTROL_ENDPOINT - # Build Options # *Comment out* to disable the options. diff --git a/converter/ps2_usb/Makefile b/converter/ps2_usb/Makefile index 5f9c4042..f8c470d0 100644 --- a/converter/ps2_usb/Makefile +++ b/converter/ps2_usb/Makefile @@ -68,9 +68,6 @@ ARCH ?= AVR8 # CPU clock adjust registers or the clock division fuses), this will be equal to F_CPU. F_USB ?= $(F_CPU) -# Interrupt driven control endpoint task -# Not work with suart debug -#OPT_DEFS += -DINTERRUPT_CONTROL_ENDPOINT # This improves response of keyboard when wakeup OPT_DEFS += -DSUSPEND_MODE_STANDBY diff --git a/converter/sun_usb/Makefile b/converter/sun_usb/Makefile index 20addfc9..366bac70 100644 --- a/converter/sun_usb/Makefile +++ b/converter/sun_usb/Makefile @@ -52,9 +52,6 @@ ARCH ?= AVR8 # CPU clock adjust registers or the clock division fuses), this will be equal to F_CPU. F_USB ?= $(F_CPU) -# Interrupt driven control endpoint task -OPT_DEFS += -DINTERRUPT_CONTROL_ENDPOINT - # Build Options # *Comment out* to disable the options. diff --git a/converter/terminal_usb/Makefile b/converter/terminal_usb/Makefile index fc07155f..766e92fe 100644 --- a/converter/terminal_usb/Makefile +++ b/converter/terminal_usb/Makefile @@ -50,9 +50,6 @@ ARCH = AVR8 # CPU clock adjust registers or the clock division fuses), this will be equal to F_CPU. F_USB = $(F_CPU) -# Interrupt driven control endpoint task -OPT_DEFS += -DINTERRUPT_CONTROL_ENDPOINT - # Boot Section Size in bytes # Teensy halfKay 512 diff --git a/converter/usb_usb/Makefile b/converter/usb_usb/Makefile index 65b6d949..4b88b651 100644 --- a/converter/usb_usb/Makefile +++ b/converter/usb_usb/Makefile @@ -82,9 +82,6 @@ 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) -# Interrupt driven control endpoint task -OPT_DEFS += -DINTERRUPT_CONTROL_ENDPOINT - # Build Options diff --git a/converter/x68k_usb/Makefile b/converter/x68k_usb/Makefile index 41e32b18..ae5f3c8e 100644 --- a/converter/x68k_usb/Makefile +++ b/converter/x68k_usb/Makefile @@ -54,9 +54,6 @@ ARCH ?= AVR8 # CPU clock adjust registers or the clock division fuses), this will be equal to F_CPU. F_USB ?= $(F_CPU) -# Interrupt driven control endpoint task(+60) -OPT_DEFS += -DINTERRUPT_CONTROL_ENDPOINT - # Boot Section Size in *bytes* # Teensy halfKay 512 diff --git a/converter/xt_usb/Makefile b/converter/xt_usb/Makefile index 081d2a2a..f9946a9a 100644 --- a/converter/xt_usb/Makefile +++ b/converter/xt_usb/Makefile @@ -69,9 +69,6 @@ ARCH ?= AVR8 # CPU clock adjust registers or the clock division fuses), this will be equal to F_CPU. F_USB ?= $(F_CPU) -# Interrupt driven control endpoint task(+60) -OPT_DEFS += -DINTERRUPT_CONTROL_ENDPOINT - # Boot Section Size in *bytes* # Teensy halfKay 512 From e2ac2d746fa3f2c3dfed97cf4a9a148a5fb2beca Mon Sep 17 00:00:00 2001 From: tmk Date: Sun, 29 Mar 2020 14:37:55 +0900 Subject: [PATCH 3/4] usb_usb: Remove hook_usb_startup_wait_loop matrix_scan in hook_usb_startup_wait_loop is not required for FC660C since commit dd7b75: SOF timing fix of USB_Host_Shield_2.0. Without INTERRUPT_CONTROL_ENDPOINT the matrix_scan blocks around 2300ms and prevents getting USB configured. In the result console_putc starts sending before hid_listen is ready and chars are lost. console_is_ready delay value should be around 5000ms if matrix_scan is needed in hook_usb_startup_wait_loop. --- converter/usb_usb/usb_usb.cpp | 7 ------- 1 file changed, 7 deletions(-) diff --git a/converter/usb_usb/usb_usb.cpp b/converter/usb_usb/usb_usb.cpp index 3d08b118..625a3b82 100644 --- a/converter/usb_usb/usb_usb.cpp +++ b/converter/usb_usb/usb_usb.cpp @@ -226,13 +226,6 @@ void led_set(uint8_t usb_led) if (kbd4.isReady()) kbd4.SetReport(0, 0, 2, 0, 1, &usb_led); } -// We need to keep doing UHS2 USB::Task() to initialize keyboard -// even before USB is not configured. -void hook_usb_startup_wait_loop(void) -{ - matrix_scan(); -} - // We need to keep doing UHS2 USB::Task() to initialize keyboard // even during USB bus is suspended and remote wakeup is not enabled yet on LUFA side. // This situation can happen just after pluging converter into USB port. From 8c72e9331492f2d5c9e854cff81ed237ab9b3faf Mon Sep 17 00:00:00 2001 From: tmk Date: Sun, 29 Mar 2020 22:15:29 +0900 Subject: [PATCH 4/4] ibm4704: Use INTERRUPT_CONTROL_ENDPOINT to debug prints --- converter/ibm4704_usb/Makefile | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/converter/ibm4704_usb/Makefile b/converter/ibm4704_usb/Makefile index b6adf08d..007e0e01 100644 --- a/converter/ibm4704_usb/Makefile +++ b/converter/ibm4704_usb/Makefile @@ -70,6 +70,10 @@ ARCH ?= AVR8 # CPU clock adjust registers or the clock division fuses), this will be equal to F_CPU. F_USB ?= $(F_CPU) +# TODO: This can prevent converter ISR from handling signal instantly, better remove it. +# Without this option debug prints from enable_break() won't be displayed comopletely. +OPT_DEFS += -DINTERRUPT_CONTROL_ENDPOINT + # Boot Section Size in *bytes* # Teensy halfKay 512