From a49505c465eff574b8cfcbf80e084e00124336be Mon Sep 17 00:00:00 2001 From: Hrvoje Cavrak Date: Sat, 6 Jan 2024 00:21:01 +0100 Subject: [PATCH] Fixing a strange bug due to tusb_inited(). Interesting things happen when TinyUSB is used both for host and device. bool tusb_inited(void) { bool ret = false; ret = ret || tud_inited(); ret = ret || tuh_inited(); return ret; } -> This is effectively tud_inited() || tuh_inited(), which is great but tuh_task() should check tuh_inited() not tusb_inited(). This way, tusb_inited() returns true when tinyusb device gets inited correctly and tuh_task gets stuck in an endless loop with watchdog rebooting the device. --- src/main.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main.c b/src/main.c index 872752f..b58b478 100644 --- a/src/main.c +++ b/src/main.c @@ -58,7 +58,8 @@ void core1_main() { global_state.core1_last_loop_pass = time_us_64(); // USB host task, needs to run as often as possible - tuh_task(); + if (tuh_inited()) + tuh_task(); // Receives data over serial from the other board receive_char(&in_packet, &global_state);