summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorHa Thach <[email protected]>2022-04-20 23:32:50 +0700
committerGitHub <[email protected]>2022-04-20 23:32:50 +0700
commit55a5fd59d7263289f5c26d52ab206ed571cc1e0c (patch)
tree17f0c6d038ea9a73fdc78d94f15e50f2b3233b5c /examples
parent9c8c5c1c53214b8954bb28c33a496b5b423d5ecc (diff)
parent87572871d586856242c1fa44b1532a09e624162d (diff)
Merge pull request #1440 from hathach/osal-queue-timeout
Osal queue timeout
Diffstat (limited to 'examples')
-rw-r--r--examples/device/cdc_msc_freertos/src/main.c14
-rw-r--r--examples/device/hid_composite_freertos/src/main.c4
2 files changed, 12 insertions, 6 deletions
diff --git a/examples/device/cdc_msc_freertos/src/main.c b/examples/device/cdc_msc_freertos/src/main.c
index 0a1c964ae..a5e907199 100644
--- a/examples/device/cdc_msc_freertos/src/main.c
+++ b/examples/device/cdc_msc_freertos/src/main.c
@@ -130,8 +130,11 @@ 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
+ tud_cdc_write_flush();
}
}
@@ -181,7 +184,7 @@ void cdc_task(void* params)
// if ( tud_cdc_connected() )
{
// There are data available
- if ( tud_cdc_available() )
+ while ( tud_cdc_available() )
{
uint8_t buf[64];
@@ -194,12 +197,13 @@ 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();
}
+
+ tud_cdc_write_flush();
}
- // For ESP32-S2 this delay is essential to allow idle how to run and reset wdt
- vTaskDelay(pdMS_TO_TICKS(10));
+ // For ESP32-Sx this delay is essential to allow idle how to run and reset watchdog
+ vTaskDelay(1);
}
}
diff --git a/examples/device/hid_composite_freertos/src/main.c b/examples/device/hid_composite_freertos/src/main.c
index 1695f968c..317b64611 100644
--- a/examples/device/hid_composite_freertos/src/main.c
+++ b/examples/device/hid_composite_freertos/src/main.c
@@ -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
}
}