diff options
| author | sakimisu <[email protected]> | 2023-06-28 21:12:50 +0800 |
|---|---|---|
| committer | sakimisu <[email protected]> | 2023-06-28 21:44:28 +0800 |
| commit | bb583485108d99bbede50dc30937e078fb6198bb (patch) | |
| tree | 0dda401afe1f9e2e29e1f5e803e1e7ad4ae52302 | |
| parent | 8253f074ce4a4572aaf29283c8df218d1670622d (diff) | |
check if current context is in irq when gives sem
| -rw-r--r-- | osal/usb_osal_freertos.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/osal/usb_osal_freertos.c b/osal/usb_osal_freertos.c index 8547a4c0..da8ccd60 100644 --- a/osal/usb_osal_freertos.c +++ b/osal/usb_osal_freertos.c @@ -38,9 +38,13 @@ int usb_osal_sem_give(usb_osal_sem_t sem) BaseType_t xHigherPriorityTaskWoken = pdFALSE; int ret; - ret = xSemaphoreGiveFromISR((SemaphoreHandle_t)sem, &xHigherPriorityTaskWoken); - if (ret == pdPASS) { - portYIELD_FROM_ISR(xHigherPriorityTaskWoken); + if (xPortIsInsideInterrupt()) { + ret = xSemaphoreGiveFromISR((SemaphoreHandle_t)sem, &xHigherPriorityTaskWoken); + if (ret == pdPASS) { + portYIELD_FROM_ISR(xHigherPriorityTaskWoken); + } + } else { + ret = xSemaphoreGive((SemaphoreHandle_t)sem); } return (ret == pdPASS) ? 0 : -ETIMEDOUT; |
