Browse Source

add: 把之前做的network适配提交一下, 差几个timer/task的函数未完成

Wendal Chen 3 years ago
parent
commit
3415e9ace1

+ 4 - 0
app/port/luat_base_air101.c

@@ -185,6 +185,10 @@ static const luaL_Reg loadedlibs[] = {
 #endif
 #ifdef LUAT_USE_I2S
   {"i2s", luaopen_i2s},
+#endif
+#ifdef LUAT_USE_NETWORK
+  {"network", luaopen_network_adapter},
+  {"w5500",   luaopen_w5500},
 #endif
   {NULL, NULL}
 };

+ 31 - 0
app/port/luat_ccommon_air101.c

@@ -0,0 +1,31 @@
+#include "luat_base.h"
+#include "c_common.h"
+
+#include "FreeRTOS.h"
+#include "task.h"
+
+
+void luat_task_suspend_all(void) {
+    vTaskSuspendAll();
+}
+
+void luat_task_resume_all(void) {
+    xTaskResumeAll();
+}
+
+uint64_t GetSysTickMS() {
+    return xTaskGetTickCount();
+}
+
+
+void OS_Free(void* ptr) {
+    luat_heap_free(ptr);
+}
+
+void* OS_Zalloc(size_t len) {
+    void* ptr = luat_heap_malloc(len);
+	if (ptr) {
+		memset(ptr, 0, len);
+	}
+	return ptr;
+}

+ 6 - 0
app/port/luat_conf_bsp.h

@@ -46,6 +46,12 @@
 // i2s
 //#define LUAt_USE_I2S 1
 
+// 外置网络支持
+// #define LUAT_USE_NETWORK 1
+// #define LUAT_USE_W5500 1
+// #define LUAT_USE_DHCP 1
+// #define LUAT_USE_DNS 1
+
 //----------------------------
 // 常用工具库, 按需启用, cjson和pack是强烈推荐启用的
 #define LUAT_USE_CRYPTO  1

+ 41 - 0
app/port/luat_network_air101.c

@@ -0,0 +1,41 @@
+#include "luat_base.h"
+#include "luat_rtos.h"
+#include "c_common.h"
+#include "luat_malloc.h"
+
+#include "FreeRTOS.h"
+#include "semphr.h"
+#include "task.h"
+
+void DBG_Printf(const char* format, ...) {
+    
+}
+
+void DBG_HexPrintf(void *Data, unsigned int len) {
+
+}
+
+LUAT_RET luat_send_event_to_task(void *task_handle, uint32_t id, uint32_t param1, uint32_t param2, uint32_t param3) {
+    return LUAT_ERR_OK;
+}
+
+LUAT_RET luat_wait_event_from_task(void *task_handle, uint32_t wait_event_id, void *out_event, void *call_back, uint32_t ms) {
+    return LUAT_ERR_OK;
+}
+
+void luat_stop_rtos_timer(void *timer) {
+
+}
+
+
+void luat_release_rtos_timer(void *timer) {
+
+}
+
+void *luat_create_rtos_timer(void *cb, void *param, void *task_handle) {
+
+}
+
+int luat_start_rtos_timer(void *timer, uint32_t ms, uint8_t is_repeat) {
+    return 0;
+}

+ 3 - 0
app/port/luat_spi_air101.c

@@ -183,3 +183,6 @@ int luat_spi_send(int spi_id, const char* send_buf, size_t length) {
         return -1;
 }
 
+int luat_spi_config_dma(int spi_id, uint32_t tx_channel, uint32_t rx_channel) {
+    return 0;
+}

+ 12 - 2
xmake.lua

@@ -341,9 +341,19 @@ target("air10x")
     add_includedirs(luatos.."components/qrcode",{public = true})
     add_files(luatos.."components/qrcode/*.c")
 
+    -- c_common
+    add_includedirs(luatos.."components/common",{public = true})
+    add_files(luatos.."components/common/*.c")
+
     -- network
-    -- add_includedirs(luatos.."components/network/adapter",{public = true})
-    -- add_files(luatos.."components/network/adapter/*.c")
+    add_includedirs(luatos.."components/network/adapter",{public = true})
+    add_files(luatos.."components/network/adapter/*.c")
+
+    -- w5500
+    add_includedirs(luatos.."components/ethernet/common",{public = true})
+    add_files(luatos.."components/ethernet/common/*.c")
+    add_includedirs(luatos.."components/ethernet/w5500",{public = true})
+    add_files(luatos.."components/ethernet/w5500/*.c")
 
 	after_build(function(target)
         sdk_dir = target:toolchains()[1]:sdkdir().."/"