فهرست منبع

fix: freertos luat_msgbus_put assert

豆豆 7 ماه پیش
والد
کامیت
03834af3c7
1فایلهای تغییر یافته به همراه13 افزوده شده و 1 حذف شده
  1. 13 1
      luat/freertos/luat_msgbus_freertos.c

+ 13 - 1
luat/freertos/luat_msgbus_freertos.c

@@ -1,5 +1,6 @@
 #include "luat_base.h"
 #include "luat_msgbus.h"
+#include "luat_rtos.h"
 
 #ifdef LUAT_FREERTOS_FULL_INCLUDE
 #include "freertos/FreeRTOS.h"
@@ -19,7 +20,18 @@ void luat_msgbus_init(void) {
 uint32_t luat_msgbus_put(rtos_msg_t* msg, size_t timeout) {
     if (xQueue == NULL)
         return 1;
-    return xQueueSendFromISR(xQueue, msg, NULL) == pdTRUE ? 0 : 1;
+    if (luat_rtos_get_ipsr())
+	{
+        BaseType_t pxHigherPriorityTaskWoken;
+		if (xQueueSendFromISR(xQueue, msg, &pxHigherPriorityTaskWoken) != pdPASS)
+			return -1;
+		portYIELD_FROM_ISR(pxHigherPriorityTaskWoken);
+		return 0;
+    }
+    else
+    {
+        return xQueueSend(xQueue, msg, NULL) == pdTRUE ? 0 : 1;
+    }
 }
 uint32_t luat_msgbus_get(rtos_msg_t* msg, size_t timeout) {
     if (xQueue == NULL)