Просмотр исходного кода

update: 优化rtos/freertos的适配实现

Wendal Chen 2 лет назад
Родитель
Сommit
010db7753e

+ 12 - 7
components/rtos/freertos/luat_common_freertos.c

@@ -1,20 +1,25 @@
-#include "luat_base.h"
-#include "luat_rtos.h"
-#include "luat_mcu.h"
-#include "luat_malloc.h"
-#include "common.h"
-#include "c_common.h"
 
-#if (defined(CONFIG_IDF_CMAKE))
+
+#ifdef LUAT_FREERTOS_FULL_INCLUDE
 #include "freertos/FreeRTOS.h"
 #include "freertos/task.h"
 #include "freertos/queue.h"
+#include "freertos/semphr.h"
+#include "freertos/timers.h"
 #else
 #include "FreeRTOS.h"
 #include "task.h"
 #include "queue.h"
+#include "semphr.h"
+#include "timers.h"
 #endif
 
+#include "luat_base.h"
+#include "luat_rtos.h"
+#include "luat_mcu.h"
+#include "luat_malloc.h"
+#include "c_common.h"
+
 #define LUAT_LOG_TAG "rtos"
 #include "luat_log.h"
 

+ 11 - 3
components/rtos/freertos/luat_rtos_freertos_mutex.c

@@ -1,14 +1,22 @@
-#include "luat_base.h"
-#include "luat_rtos.h"
 
-#if (defined(CONFIG_IDF_CMAKE))
+
+#ifdef LUAT_FREERTOS_FULL_INCLUDE
 #include "freertos/FreeRTOS.h"
+#include "freertos/task.h"
+#include "freertos/queue.h"
 #include "freertos/semphr.h"
+#include "freertos/timers.h"
 #else
 #include "FreeRTOS.h"
+#include "task.h"
+#include "queue.h"
 #include "semphr.h"
+#include "timers.h"
 #endif
 
+#include "luat_base.h"
+#include "luat_rtos.h"
+
 int luat_rtos_mutex_create(luat_rtos_mutex_t *mutex_handle)
 {
 	if (!mutex_handle) return -1;

+ 11 - 3
components/rtos/freertos/luat_rtos_freertos_queue.c

@@ -1,14 +1,22 @@
-#include "luat_base.h"
-#include "luat_rtos.h"
 
-#if (defined(CONFIG_IDF_CMAKE))
+#ifdef LUAT_FREERTOS_FULL_INCLUDE
 #include "freertos/FreeRTOS.h"
+#include "freertos/task.h"
 #include "freertos/queue.h"
+#include "freertos/semphr.h"
+#include "freertos/timers.h"
 #else
 #include "FreeRTOS.h"
+#include "task.h"
 #include "queue.h"
+#include "semphr.h"
+#include "timers.h"
 #endif
 
+#include "luat_base.h"
+#include "luat_rtos.h"
+
+
 int luat_rtos_queue_create(luat_rtos_queue_t *queue_handle, uint32_t item_count, uint32_t item_size)
 {
 	if (!queue_handle) return -1;

+ 11 - 3
components/rtos/freertos/luat_rtos_freertos_semaphore.c

@@ -1,14 +1,22 @@
-#include "luat_base.h"
-#include "luat_rtos.h"
 
-#if (defined(CONFIG_IDF_CMAKE))
+#ifdef LUAT_FREERTOS_FULL_INCLUDE
 #include "freertos/FreeRTOS.h"
+#include "freertos/task.h"
+#include "freertos/queue.h"
 #include "freertos/semphr.h"
+#include "freertos/timers.h"
 #else
 #include "FreeRTOS.h"
+#include "task.h"
+#include "queue.h"
 #include "semphr.h"
+#include "timers.h"
 #endif
 
+#include "luat_base.h"
+#include "luat_rtos.h"
+
+
 int luat_rtos_semaphore_create(luat_rtos_semaphore_t *semaphore_handle, uint32_t init_count)
 {
 	if (!semaphore_handle) return -1;

+ 11 - 6
components/rtos/freertos/luat_rtos_freertos_task.c

@@ -1,17 +1,22 @@
-#include "luat_base.h"
-#include "luat_rtos.h"
-#include "common.h"
 
-#if (defined(CONFIG_IDF_CMAKE))
+#ifdef LUAT_FREERTOS_FULL_INCLUDE
 #include "freertos/FreeRTOS.h"
 #include "freertos/task.h"
 #include "freertos/queue.h"
+#include "freertos/semphr.h"
+#include "freertos/timers.h"
 #else
 #include "FreeRTOS.h"
 #include "task.h"
 #include "queue.h"
+#include "semphr.h"
+#include "timers.h"
 #endif
 
+
+#include "luat_base.h"
+#include "luat_rtos.h"
+
 typedef struct
 {
 	uint32_t ID;
@@ -134,7 +139,7 @@ int luat_rtos_event_send(luat_rtos_task_handle task_handle, uint32_t id, uint32_
 
 int luat_rtos_event_recv(luat_rtos_task_handle task_handle, uint32_t wait_event_id, luat_event_t *out_event, luat_rtos_event_wait_callback_t *callback_fun, uint32_t timeout){
 	if (!task_handle) return -1;
-	return get_event_from_task(task_handle, wait_event_id, (void *)out_event, callback_fun, timeout);
+	return get_event_from_task(task_handle, wait_event_id, (void *)out_event, (CBFuncEx_t)callback_fun, timeout);
 }
 
 int luat_send_event_to_task(void *task_handle, uint32_t id, uint32_t param1, uint32_t param2, uint32_t param3)
@@ -146,7 +151,7 @@ int luat_send_event_to_task(void *task_handle, uint32_t id, uint32_t param1, uin
 int luat_wait_event_from_task(void *task_handle, uint32_t wait_event_id, luat_event_t *out_event, void *call_back, uint32_t ms)
 {
 	if (!task_handle) return -1;
-	return get_event_from_task(task_handle, wait_event_id, (void *)out_event, call_back, ms);
+	return get_event_from_task(task_handle, wait_event_id, (void *)out_event, (CBFuncEx_t)call_back, ms);
 }
 
 /* ------------------------------------------------ critical begin----------------------------------------------- */

+ 11 - 4
components/rtos/freertos/luat_rtos_freertos_timer.c

@@ -1,15 +1,22 @@
-#include "luat_base.h"
-#include "luat_rtos.h"
-#include "luat_malloc.h"
 
-#if (defined(CONFIG_IDF_CMAKE))
+#ifdef LUAT_FREERTOS_FULL_INCLUDE
 #include "freertos/FreeRTOS.h"
+#include "freertos/task.h"
+#include "freertos/queue.h"
+#include "freertos/semphr.h"
 #include "freertos/timers.h"
 #else
 #include "FreeRTOS.h"
+#include "task.h"
+#include "queue.h"
+#include "semphr.h"
 #include "timers.h"
 #endif
 
+#include "luat_base.h"
+#include "luat_rtos.h"
+#include "luat_malloc.h"
+
 typedef struct
 {
 	void *timer;