diff options
| author | hathach <[email protected]> | 2020-09-01 12:02:25 +0700 |
|---|---|---|
| committer | hathach <[email protected]> | 2020-09-01 12:02:25 +0700 |
| commit | be708bb8a444a6e8f8676be842fcfd02a583ed0b (patch) | |
| tree | a72cd5e5491ade67c40b0a5f152d9d697420caaf /src/osal | |
| parent | d108ea4326d824da73da0a4f9632c5da6aa2e3ec (diff) | |
| parent | f10b8145afb6d7b78fbf31b525951b4137e1d774 (diff) | |
Merge branch 'master' into update-host
Diffstat (limited to 'src/osal')
| -rw-r--r-- | src/osal/osal_freertos.h | 36 |
1 files changed, 34 insertions, 2 deletions
diff --git a/src/osal/osal_freertos.h b/src/osal/osal_freertos.h index 42ea1fd19..004bd1b6b 100644 --- a/src/osal/osal_freertos.h +++ b/src/osal/osal_freertos.h @@ -58,7 +58,23 @@ static inline osal_semaphore_t osal_semaphore_create(osal_semaphore_def_t* semde static inline bool osal_semaphore_post(osal_semaphore_t sem_hdl, bool in_isr) { - return in_isr ? xSemaphoreGiveFromISR(sem_hdl, NULL) : xSemaphoreGive(sem_hdl); + if ( !in_isr ) + { + return xSemaphoreGive(sem_hdl) != 0; + } + else + { + BaseType_t xHigherPriorityTaskWoken; + BaseType_t res = xSemaphoreGiveFromISR(sem_hdl, &xHigherPriorityTaskWoken); + +#if CFG_TUSB_MCU == OPT_MCU_ESP32S2 + if ( xHigherPriorityTaskWoken ) portYIELD_FROM_ISR(); +#else + portYIELD_FROM_ISR(xHigherPriorityTaskWoken); +#endif + + return res != 0; + } } static inline bool osal_semaphore_wait (osal_semaphore_t sem_hdl, uint32_t msec) @@ -125,7 +141,23 @@ static inline bool osal_queue_receive(osal_queue_t qhdl, void* data) static inline bool osal_queue_send(osal_queue_t qhdl, void const * data, bool in_isr) { - return in_isr ? xQueueSendToBackFromISR(qhdl, data, NULL) : xQueueSendToBack(qhdl, data, OSAL_TIMEOUT_WAIT_FOREVER); + if ( !in_isr ) + { + return xQueueSendToBack(qhdl, data, OSAL_TIMEOUT_WAIT_FOREVER) != 0; + } + else + { + BaseType_t xHigherPriorityTaskWoken; + BaseType_t res = xQueueSendToBackFromISR(qhdl, data, &xHigherPriorityTaskWoken); + +#if CFG_TUSB_MCU == OPT_MCU_ESP32S2 + if ( xHigherPriorityTaskWoken ) portYIELD_FROM_ISR(); +#else + portYIELD_FROM_ISR(xHigherPriorityTaskWoken); +#endif + + return res != 0; + } } static inline bool osal_queue_empty(osal_queue_t qhdl) |
