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.
This commit is contained in:
Hrvoje Cavrak 2024-01-06 00:21:01 +01:00
parent e2be2e13e0
commit a49505c465

View File

@ -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);