fix: 修正API生成逻辑中2024库的url
[LuatOS.git] / luat / freertos / luat_msgbus_freertos.c
blob04710ff6056a7786a638521267a4e93b2eb6a3c2
1 #include "luat_base.h"
2 #include "luat_msgbus.h"
4 #ifdef LUAT_FREERTOS_FULL_INCLUDE
5 #include "freertos/FreeRTOS.h"
6 #include "freertos/queue.h"
7 #else
8 #include "FreeRTOS.h"
9 #include "queue.h"
10 #endif
12 static QueueHandle_t xQueue = {0};
14 void luat_msgbus_init(void) {
15 if (!xQueue) {
16 xQueue = xQueueCreate(256, sizeof(rtos_msg_t));
19 uint32_t luat_msgbus_put(rtos_msg_t* msg, size_t timeout) {
20 if (xQueue == NULL)
21 return 1;
22 return xQueueSendFromISR(xQueue, msg, NULL) == pdTRUE ? 0 : 1;
24 uint32_t luat_msgbus_get(rtos_msg_t* msg, size_t timeout) {
25 if (xQueue == NULL)
26 return 1;
27 return xQueueReceive(xQueue, msg, timeout) == pdTRUE ? 0 : 1;
29 uint32_t luat_msgbus_freesize(void) {
30 return 1;
33 uint8_t luat_msgbus_is_empty(void) {
34 return uxQueueMessagesWaiting(xQueue) == 0 ? 1 : 0;
37 uint8_t luat_msgbus_is_ready(void) {
38 return xQueue?1:0;