From 3307b04eede304900e3455f3327c6dafbe516700 Mon Sep 17 00:00:00 2001 From: Christian Soffke Date: Wed, 26 Nov 2025 18:23:28 +0100 Subject: [PATCH] usb: Shorten debounce interval for USB status by event The introduction of a debounce interval for USB status by event (see e75a3fb), often resulted in the FiiO M3K crashing after disconnecting from USB. Shortening the interval to 10ms appears to fix this, or make a crash much less likely at the very least. Change-Id: Ibf1f02779ab1704d9b1c86d39b21648a3e2c4e9d --- firmware/usb.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/firmware/usb.c b/firmware/usb.c index d45600c0f3..d1a4054d2d 100644 --- a/firmware/usb.c +++ b/firmware/usb.c @@ -70,7 +70,12 @@ #endif /* USB detect debouncing interval (200ms taken from the usb polling code) */ -#define USB_DEBOUNCE_TIME (200*HZ/1000) +#define USB_DEBOUNCE_POLL (200*HZ/1000) +/* NOTE: "usb_dw_gonak_effective:failed!" *PANIC*s can be observed when + disconnecting the FiiO M3K from USB with the debounce interval + for USB_STATUS_BY_EVENT set to 200ms, as above (see e75a3fb). + Adjusting the interval to 10ms reduces likelihood of a panic. */ +#define USB_DEBOUNCE_TIME (10*HZ/1000) bool do_screendump_instead_of_usb = false; @@ -690,7 +695,7 @@ static void usb_tick(void) if(current_firewire_status != last_firewire_status) { last_firewire_status = current_firewire_status; - firewire_countdown = USB_DEBOUNCE_TIME; + firewire_countdown = USB_DEBOUNCE_POLL; } else { @@ -712,7 +717,7 @@ static void usb_tick(void) if(current_status != last_usb_status) { last_usb_status = current_status; - usb_countdown = USB_DEBOUNCE_TIME; + usb_countdown = USB_DEBOUNCE_POLL; } else {