Skip to content

Commit

Permalink
add note for tud_task() behavior in freertos example
Browse files Browse the repository at this point in the history
  • Loading branch information
hathach committed Apr 20, 2022
1 parent b034c18 commit 6a022c7
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 5 deletions.
5 changes: 3 additions & 2 deletions examples/device/cdc_msc_freertos/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -130,10 +130,10 @@ void usb_device_task(void* param)
// RTOS forever loop
while (1)
{
// tinyusb device task
// put this thread to waiting state until there is new events
tud_task();

tud_cdc_write_flush();
// following code only run if tud_task() process at least 1 event
}
}

Expand Down Expand Up @@ -196,6 +196,7 @@ void cdc_task(void* params)
// for throughput test e.g
// $ dd if=/dev/zero of=/dev/ttyACM0 count=10000
tud_cdc_write(buf, count);
tud_cdc_write_flush();
}
}

Expand Down
4 changes: 3 additions & 1 deletion examples/device/hid_composite_freertos/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,10 @@ void usb_device_task(void* param)
// RTOS forever loop
while (1)
{
// tinyusb device task
// put this thread to waiting state until there is new events
tud_task();

// following code only run if tud_task() process at least 1 event
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/device/usbd.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ void tud_task_ext(uint32_t timeout_ms, bool in_isr);
TU_ATTR_ALWAYS_INLINE static inline
void tud_task (void)
{
tud_task_ext(OSAL_TIMEOUT_WAIT_FOREVER, false);
tud_task_ext(UINT32_MAX, false);
}

// Check if there is pending events need proccessing by tud_task()
Expand Down
2 changes: 1 addition & 1 deletion src/host/usbh.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ void tuh_task_ext(uint32_t timeout_ms, bool in_isr);
TU_ATTR_ALWAYS_INLINE static inline
void tuh_task(void)
{
tuh_task_ext(OSAL_TIMEOUT_WAIT_FOREVER, false);
tuh_task_ext(UINT32_MAX, false);
}

// Interrupt handler, name alias to HCD
Expand Down

0 comments on commit 6a022c7

Please sign in to comment.