mirror of
https://github.com/hathach/tinyusb.git
synced 2025-04-15 20:42:23 +00:00
fix freertos issue when 1 tick > 1 ms
This commit is contained in:
parent
a90839688c
commit
669e36d674
@ -132,6 +132,8 @@ void usb_device_task(void* param)
|
||||
{
|
||||
// tinyusb device task
|
||||
tud_task();
|
||||
|
||||
tud_cdc_write_flush();
|
||||
}
|
||||
}
|
||||
|
||||
@ -194,12 +196,8 @@ 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();
|
||||
}
|
||||
}
|
||||
|
||||
// For ESP32-S2 this delay is essential to allow idle how to run and reset wdt
|
||||
vTaskDelay(pdMS_TO_TICKS(10));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -37,6 +37,20 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
TU_ATTR_ALWAYS_INLINE static inline uint32_t _osal_ms2tick(uint32_t msec)
|
||||
{
|
||||
if (msec == OSAL_TIMEOUT_WAIT_FOREVER) return portMAX_DELAY;
|
||||
if (msec == 0) return 0;
|
||||
|
||||
uint32_t ticks = pdMS_TO_TICKS(msec);
|
||||
|
||||
// configTICK_RATE_HZ is less than 1000 and 1 tick > 1 ms
|
||||
// we still need to delay at least 1 tick
|
||||
if (ticks == 0) ticks =1 ;
|
||||
|
||||
return ticks;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// TASK API
|
||||
//--------------------------------------------------------------------+
|
||||
@ -80,8 +94,7 @@ TU_ATTR_ALWAYS_INLINE static inline bool osal_semaphore_post(osal_semaphore_t se
|
||||
|
||||
TU_ATTR_ALWAYS_INLINE static inline bool osal_semaphore_wait (osal_semaphore_t sem_hdl, uint32_t msec)
|
||||
{
|
||||
uint32_t const ticks = (msec == OSAL_TIMEOUT_WAIT_FOREVER) ? portMAX_DELAY : pdMS_TO_TICKS(msec);
|
||||
return xSemaphoreTake(sem_hdl, ticks);
|
||||
return xSemaphoreTake(sem_hdl, _osal_ms2tick(msec));
|
||||
}
|
||||
|
||||
TU_ATTR_ALWAYS_INLINE static inline void osal_semaphore_reset(osal_semaphore_t const sem_hdl)
|
||||
@ -137,8 +150,7 @@ TU_ATTR_ALWAYS_INLINE static inline osal_queue_t osal_queue_create(osal_queue_de
|
||||
|
||||
TU_ATTR_ALWAYS_INLINE static inline bool osal_queue_receive(osal_queue_t qhdl, void* data, uint32_t msec)
|
||||
{
|
||||
uint32_t const ticks = (msec == OSAL_TIMEOUT_WAIT_FOREVER) ? portMAX_DELAY : pdMS_TO_TICKS(msec);
|
||||
return xQueueReceive(qhdl, data, ticks);
|
||||
return xQueueReceive(qhdl, data, _osal_ms2tick(msec));
|
||||
}
|
||||
|
||||
TU_ATTR_ALWAYS_INLINE static inline bool osal_queue_send(osal_queue_t qhdl, void const * data, bool in_isr)
|
||||
|
Loading…
x
Reference in New Issue
Block a user