diff options
| author | Zhihong Chen <[email protected]> | 2024-04-09 16:44:35 +0800 |
|---|---|---|
| committer | sakumisu <[email protected]> | 2024-04-13 11:08:53 +0800 |
| commit | 4357a1d7d17698396b1543f1ffb3038bc3a8fcdd (patch) | |
| tree | 70ec8252fcd991e8834678e23852f093b7adcb73 | |
| parent | c1cb6e397be31c5a5d9300c38b75834db3584583 (diff) | |
osal: freeRTOS: fix enter/exit critical
- fix enter/exit critical
Signed-off-by: Zhihong Chen <[email protected]>
| -rw-r--r-- | osal/usb_osal_freertos.c | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/osal/usb_osal_freertos.c b/osal/usb_osal_freertos.c index 14118570..db0e238d 100644 --- a/osal/usb_osal_freertos.c +++ b/osal/usb_osal_freertos.c @@ -173,13 +173,25 @@ void usb_osal_timer_stop(struct usb_osal_timer *timer) size_t usb_osal_enter_critical_section(void) { - taskDISABLE_INTERRUPTS(); - return 1; + size_t ret; + + if (xPortIsInsideInterrupt()) { + ret = taskENTER_CRITICAL_FROM_ISR(); + } else { + taskENTER_CRITICAL(); + ret = 1; + } + + return ret; } void usb_osal_leave_critical_section(size_t flag) { - taskENABLE_INTERRUPTS(); + if (xPortIsInsideInterrupt()) { + taskEXIT_CRITICAL_FROM_ISR(flag); + } else { + taskEXIT_CRITICAL(); + } } void usb_osal_msleep(uint32_t delay) |
