瀏覽代碼

del:直接使用主库freertos移植

Dozingfiretruck 3 年之前
父節點
當前提交
ee8fe8bff2
共有 2 個文件被更改,包括 0 次插入124 次删除
  1. 0 28
      app/port/luat_msgbus_air101.c
  2. 0 96
      app/port/luat_timer_air101.c

+ 0 - 28
app/port/luat_msgbus_air101.c

@@ -1,28 +0,0 @@
-#include "luat_base.h"
-#include "luat_msgbus.h"
-#include "luat_malloc.h"
-#include "wm_osal.h"
-#include "FreeRTOS.h"
-#include "rtosqueue.h"
-
-static QueueHandle_t xQueue = {0};
-
-void luat_msgbus_init(void) {
-    if (!xQueue) {
-        xQueue = xQueueCreate(256, sizeof(rtos_msg_t));
-    }
-}
-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;
-}
-uint32_t luat_msgbus_get(rtos_msg_t* msg, size_t timeout) {
-    if (xQueue == NULL)
-        return 1;
-    return xQueueReceive(xQueue, msg, timeout) == pdTRUE ? 0 : 1;
-}
-uint32_t luat_msgbus_freesize(void) {
-    return 1;
-}
-

+ 0 - 96
app/port/luat_timer_air101.c

@@ -1,96 +0,0 @@
-
-#include "luat_base.h"
-#include "luat_malloc.h"
-#include "luat_timer.h"
-#include "luat_msgbus.h"
-#include "FreeRTOS.h"
-#include "task.h"
-#include "wm_osal.h"
-#define LUAT_LOG_TAG "luat.timer"
-#include "luat_log.h"
-
-#define FREERTOS_TIMER_COUNT 64
-static luat_timer_t* timers[FREERTOS_TIMER_COUNT] = {0};
-
-static void luat_timer_callback(void *ptmr, void *parg) {
-    // LLOGD("timer callback");
-    rtos_msg_t msg;
-    size_t timer_id = (size_t)parg;
-    luat_timer_t *timer = luat_timer_get(timer_id);
-    if (timer == NULL)
-        return;
-    msg.handler = timer->func;
-    msg.ptr = timer;
-    msg.arg1 = timer_id;
-    msg.arg2 = 0;
-    luat_msgbus_put(&msg, 1);
-    // LLOGD("timer msgbus re=%ld", re);
-}
-
-static int nextTimerSlot() {
-    for (size_t i = 0; i < FREERTOS_TIMER_COUNT; i++)
-    {
-        if (timers[i] == NULL) {
-            return i;
-        }
-    }
-    return -1;
-}
-
-int luat_timer_start(luat_timer_t* timer) {
-    tls_os_timer_t *os_timer = NULL;
-    int timerIndex;
-    int ret;
-    // LLOGD(">>luat_timer_start timeout=%ld", timer->timeout);
-    timerIndex = nextTimerSlot();
-    // LLOGD("timer id=%ld", timerIndex);
-    if (timerIndex < 0) {
-        return 1; // too many timer!!
-    }
-    if (timer->timeout < (1000 / configTICK_RATE_HZ))
-        timer->timeout = 1000 / configTICK_RATE_HZ;
-    ret =  tls_os_timer_create(&os_timer, luat_timer_callback, (void*)timer->id,(timer->timeout)/(1000 / configTICK_RATE_HZ), timer->repeat ? 1 : 0, NULL);
-    // LLOGD("timer id=%ld, osTimerNew=%08X", timerIndex, (int)timer);
-    if (TLS_OS_SUCCESS != ret)
-    {
-       return 1;
-    }
-    timers[timerIndex] = timer;
-    timer->os_timer = os_timer;
-    tls_os_timer_start(os_timer);
-    return 0;
-}
-
-int luat_timer_stop(luat_timer_t* timer) {
-    if (!timer)
-        return 1;
-    for (size_t i = 0; i < FREERTOS_TIMER_COUNT; i++)
-    {
-        if (timers[i] == timer) {
-            timers[i] = NULL;
-            break;
-        }
-    }
-    tls_os_timer_stop(timer->os_timer);
-    tls_os_timer_delete(timer->os_timer);
-    return 0;
-}
-
-luat_timer_t* luat_timer_get(size_t timer_id) {
-    for (size_t i = 0; i < FREERTOS_TIMER_COUNT; i++)
-    {
-        if (timers[i] && timers[i]->id == timer_id) {
-            return timers[i];
-        }
-    }
-    return NULL;
-}
-
-
-int luat_timer_mdelay(size_t ms) {
-    if (ms >= (1000 / configTICK_RATE_HZ)) {
-        vTaskDelay(ms / (1000 / configTICK_RATE_HZ));
-    }
-    return 0;
-}
-