Skip to content

Commit 6a022c7

Browse files
committed
add note for tud_task() behavior in freertos example
1 parent b034c18 commit 6a022c7

File tree

4 files changed

+8
-5
lines changed

4 files changed

+8
-5
lines changed

examples/device/cdc_msc_freertos/src/main.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,10 +130,10 @@ void usb_device_task(void* param)
130130
// RTOS forever loop
131131
while (1)
132132
{
133-
// tinyusb device task
133+
// put this thread to waiting state until there is new events
134134
tud_task();
135135

136-
tud_cdc_write_flush();
136+
// following code only run if tud_task() process at least 1 event
137137
}
138138
}
139139

@@ -196,6 +196,7 @@ void cdc_task(void* params)
196196
// for throughput test e.g
197197
// $ dd if=/dev/zero of=/dev/ttyACM0 count=10000
198198
tud_cdc_write(buf, count);
199+
tud_cdc_write_flush();
199200
}
200201
}
201202

examples/device/hid_composite_freertos/src/main.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,8 +132,10 @@ void usb_device_task(void* param)
132132
// RTOS forever loop
133133
while (1)
134134
{
135-
// tinyusb device task
135+
// put this thread to waiting state until there is new events
136136
tud_task();
137+
138+
// following code only run if tud_task() process at least 1 event
137139
}
138140
}
139141

src/device/usbd.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ void tud_task_ext(uint32_t timeout_ms, bool in_isr);
5252
TU_ATTR_ALWAYS_INLINE static inline
5353
void tud_task (void)
5454
{
55-
tud_task_ext(OSAL_TIMEOUT_WAIT_FOREVER, false);
55+
tud_task_ext(UINT32_MAX, false);
5656
}
5757

5858
// Check if there is pending events need proccessing by tud_task()

src/host/usbh.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ void tuh_task_ext(uint32_t timeout_ms, bool in_isr);
100100
TU_ATTR_ALWAYS_INLINE static inline
101101
void tuh_task(void)
102102
{
103-
tuh_task_ext(OSAL_TIMEOUT_WAIT_FOREVER, false);
103+
tuh_task_ext(UINT32_MAX, false);
104104
}
105105

106106
// Interrupt handler, name alias to HCD

0 commit comments

Comments
 (0)