32
32
#include "semphr.h"
33
33
#include "queue.h"
34
34
#include "task.h"
35
+ #include "tusb_option.h"
35
36
36
37
#ifdef __cplusplus
37
38
extern "C" {
@@ -58,7 +59,19 @@ static inline osal_semaphore_t osal_semaphore_create(osal_semaphore_def_t* semde
58
59
59
60
static inline bool osal_semaphore_post (osal_semaphore_t sem_hdl , bool in_isr )
60
61
{
61
- return in_isr ? xSemaphoreGiveFromISR (sem_hdl , NULL ) : xSemaphoreGive (sem_hdl );
62
+ if (!in_isr ){
63
+ return xSemaphoreGive (sem_hdl ) != 0 ;
64
+ }
65
+ BaseType_t xHigherPriorityTaskWoken ;
66
+ BaseType_t res = xSemaphoreGiveFromISR (sem_hdl , & xHigherPriorityTaskWoken );
67
+ #if CFG_TUSB_MCU == OPT_MCU_ESP32S2
68
+ if (xHigherPriorityTaskWoken ) {
69
+ portYIELD_FROM_ISR ();
70
+ }
71
+ #else
72
+ portYIELD_FROM_ISR (xHigherPriorityTaskWoken );
73
+ #endif
74
+ return res != 0 ;
62
75
}
63
76
64
77
static inline bool osal_semaphore_wait (osal_semaphore_t sem_hdl , uint32_t msec )
@@ -125,7 +138,19 @@ static inline bool osal_queue_receive(osal_queue_t qhdl, void* data)
125
138
126
139
static inline bool osal_queue_send (osal_queue_t qhdl , void const * data , bool in_isr )
127
140
{
128
- return in_isr ? xQueueSendToBackFromISR (qhdl , data , NULL ) : xQueueSendToBack (qhdl , data , OSAL_TIMEOUT_WAIT_FOREVER );
141
+ if (!in_isr ){
142
+ return xQueueSendToBack (qhdl , data , OSAL_TIMEOUT_WAIT_FOREVER ) != 0 ;
143
+ }
144
+ BaseType_t xHigherPriorityTaskWoken ;
145
+ BaseType_t res = xQueueSendToBackFromISR (qhdl , data , & xHigherPriorityTaskWoken );
146
+ #if CFG_TUSB_MCU == OPT_MCU_ESP32S2
147
+ if (xHigherPriorityTaskWoken ) {
148
+ portYIELD_FROM_ISR ();
149
+ }
150
+ #else
151
+ portYIELD_FROM_ISR (xHigherPriorityTaskWoken );
152
+ #endif
153
+ return res != 0 ;
129
154
}
130
155
131
156
static inline bool osal_queue_empty (osal_queue_t qhdl )
0 commit comments