Skip to content

Commit 6501425

Browse files
committed
Don't sync SOF between device and host
This makes it so that the SOF clock on the downstream facing side is no longer synchronized to the upstream facing side on the single Pico variant. While I think overall the behavior was desirable, unfortunately it caused issues in certain situations, causing devices to not work if they were plugged into HID Remapper before it was plugged into the PC or if the PC was turned on with everything already plugged in. There were related issues with KVM switches and sleep/wake. Also because the processing engine didn't run at all when there were no SOF packets coming from the host, HID Remapper couldn't be used as a USB-to-GPIO decoder without a host. All of these issues could probably be addressed while keeping the SOF synchronization with some additional effort. We might revisit this in the future.
1 parent 6e0c56b commit 6501425

1 file changed

Lines changed: 9 additions & 7 deletions

File tree

firmware/src/remapper_single.cc

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,20 @@
1111
#include "remapper.h"
1212
#include "tick.h"
1313

14+
static bool __no_inline_not_in_flash_func(manual_sof)(repeating_timer_t* rt) {
15+
pio_usb_host_frame();
16+
set_tick_pending();
17+
return true;
18+
}
19+
20+
static repeating_timer_t sof_timer;
21+
1422
void extra_init() {
1523
pio_usb_configuration_t pio_cfg = PIO_USB_DEFAULT_CONFIG;
1624
pio_cfg.pin_dp = PICO_DEFAULT_PIO_USB_DP_PIN;
1725
pio_cfg.skip_alarm_pool = true;
1826
tuh_configure(BOARD_TUH_RHPORT, TUH_CFGID_RPI_PIO_USB_CONFIGURATION, &pio_cfg);
27+
add_repeating_timer_us(-1000, manual_sof, NULL, &sof_timer);
1928
}
2029

2130
uint32_t get_gpio_valid_pins_mask() {
@@ -123,14 +132,7 @@ void send_out_report() {
123132
do_send_out_report();
124133
}
125134

126-
static int64_t __no_inline_not_in_flash_func(manual_sof)(alarm_id_t id, void* user_data) {
127-
pio_usb_host_frame();
128-
set_tick_pending();
129-
return 0;
130-
}
131-
132135
void __no_inline_not_in_flash_func(sof_callback)() {
133-
add_alarm_in_us(150, manual_sof, NULL, true);
134136
}
135137

136138
void get_report_cb(uint8_t dev_addr, uint8_t interface, uint8_t report_id, uint8_t report_type, uint8_t* report, uint16_t len) {

0 commit comments

Comments
 (0)