瀏覽代碼

osal: freeRTOS: fix enter/exit critical

- fix enter/exit critical

Signed-off-by: Zhihong Chen <zhihong.chen@hpmicro.com>
Zhihong Chen 1 年之前
父節點
當前提交
4357a1d7d1
共有 1 個文件被更改,包括 15 次插入3 次删除
  1. 15 3
      osal/usb_osal_freertos.c

+ 15 - 3
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)