Explorar el Código

change: pins,独立成一个component

Wendal Chen hace 9 meses
padre
commit
8c635cf961

+ 108 - 0
components/pins/binding/luat_lib_pins.c

@@ -0,0 +1,108 @@
+/*
+@module  pins
+@summary 管脚外设复用
+@version 1.0
+@date    2025.4.10
+@tag     @tag LUAT_USE_PINS
+@demo     pins
+@usage
+-- 请使用LuaTools的可视化工具进行配置,你通常不需要使用这个demo
+-- 请使用LuaTools的可视化工具进行配置,你通常不需要使用这个demo
+-- 请使用LuaTools的可视化工具进行配置,你通常不需要使用这个demo
+-- 请使用LuaTools的可视化工具进行配置,你通常不需要使用这个demo
+-- 请使用LuaTools的可视化工具进行配置,你通常不需要使用这个demo
+-- 请使用LuaTools的可视化工具进行配置,你通常不需要使用这个demo
+-- 请使用LuaTools的可视化工具进行配置,你通常不需要使用这个demo
+-- 请使用LuaTools的可视化工具进行配置,你通常不需要使用这个demo
+-- 请使用LuaTools的可视化工具进行配置,你通常不需要使用这个demo
+-- 请使用LuaTools的可视化工具进行配置,你通常不需要使用这个demo
+-- 请使用LuaTools的可视化工具进行配置,你通常不需要使用这个demo
+
+-- 本库的API属于高级用法, 仅动态配置管脚时使用
+-- 本库的API属于高级用法, 仅动态配置管脚时使用
+-- 本库的API属于高级用法, 仅动态配置管脚时使用
+*/
+
+#include "luat_base.h"
+#include "luat_pins.h"
+#include "luat_mcu.h"
+#include <stdlib.h>
+#include "luat_fs.h"
+#include "luat_mem.h"
+
+#define LUAT_LOG_TAG "pins"
+#include "luat_log.h"
+
+/**
+当某种外设允许复用在不同引脚上时,指定某个管脚允许复用成某种外设功能,需要在外设启用前配置好,外设启用时起作用。
+@api pins.setup(pin, func)
+@int 管脚物理编号, 对应模组俯视图下的顺序编号, 例如 67, 68
+@string 功能说明, 例如 "GPIO18", "UART1_TX", "UART1_RX", "SPI1_CLK", "I2C1_CLK", 目前支持的外设有"UART","I2C","SPI","PWM","CAN","GPIO","ONEWIRE"
+@return boolean 配置成功,返回true, 其他情况均返回false, 并在日志中提示失败原因
+@usage
+--把air780epm的PIN67脚,做GPIO 18用
+--pins.setup(67, "GPIO18")
+--把air780epm的PIN55脚,做uart2 rx用
+--pins.setup(55, "UART2_RXD")
+--把air780epm的PIN56脚,做uart2 tx用
+--pins.setup(56, "UART2_TXD")
+ */
+static int l_pins_setup(lua_State *L){
+    size_t len = 0;
+    int pin = 0;
+    int result = 0;
+    int altfun_id = 0;
+    const char* func_name = NULL;
+    pin = luaL_optinteger(L, 1, -1);
+    if (pin < 0)
+    {
+    	LLOGE("pin序号参数错误");
+    	goto LUAT_PIN_SETUP_DONE;
+    }
+    else
+    {
+		if (lua_type(L, 2) == LUA_TSTRING) {
+			func_name = luaL_checklstring(L, 2, &len);
+		}
+		else if (lua_isinteger(L, 2)) {
+			altfun_id = luaL_checkinteger(L, 2);
+		}
+		else {
+			LLOGE("参数错误");
+			goto LUAT_PIN_SETUP_DONE;
+		}
+		result = luat_pins_setup(pin, func_name, len, altfun_id);
+    }
+LUAT_PIN_SETUP_DONE:
+	lua_pushboolean(L, result);
+	return 1;
+}
+
+/**
+加载硬件配置,如果存在/luadb/pins.json,开机后自动加载/luadb/pins.json,无需调用
+@api pins.load(path)
+@string path, 配置文件路径, 可选, 默认值是 /luadb/pins.json
+@return boolean 成功返回true, 失败返回nil, 并在日志中提示失败原因
+@usage
+pins.load("/my.json")
+*/
+static int l_pins_load(lua_State *L) {
+	const char* path = luaL_checkstring(L, 1);
+	int ret = luat_pins_load_from_file(path);
+	lua_pushboolean(L, ret == 0 ? 1 : 0);
+	lua_pushinteger(L, ret);
+	return 2;
+}
+
+#include "rotable2.h"
+static const rotable_Reg_t reg_pins[] =
+{
+    {"setup",     ROREG_FUNC(l_pins_setup)},
+	{"load",      ROREG_FUNC(l_pins_load)},
+	{ NULL,       ROREG_INT(0) }
+};
+
+LUAMOD_API int luaopen_pins( lua_State *L ) {
+    luat_newlib2(L, reg_pins);
+    return 1;
+}

+ 150 - 0
components/pins/include/luat_pins.h

@@ -0,0 +1,150 @@
+
+#ifndef LUAT_PIN_H
+#define LUAT_PIN_H
+#include "luat_mcu.h"
+
+
+typedef enum
+{
+	LUAT_PIN_UART_RX,
+	LUAT_PIN_UART_TX,
+	LUAT_PIN_UART_RTS,
+	LUAT_PIN_UART_CTS,
+	LUAT_PIN_UART_QTY,
+	LUAT_PIN_I2C_SCL = 0,
+	LUAT_PIN_I2C_SDA,
+	LUAT_PIN_I2C_QTY,
+	LUAT_PIN_SPI_MOSI = 0,
+	LUAT_PIN_SPI_MISO,
+	LUAT_PIN_SPI_CLK,
+	LUAT_PIN_SPI_CS,
+	LUAT_PIN_SPI_QTY,
+	LUAT_PIN_PWM_P = 0,
+	LUAT_PIN_PWM_N,
+	LUAT_PIN_PWM_QTY,
+	LUAT_PIN_CAN_RX = 0,
+	LUAT_PIN_CAN_TX,
+	LUAT_PIN_CAN_STB,
+	LUAT_PIN_CAN_QTY,
+	LUAT_PIN_I2S_MOSI = 0,
+	LUAT_PIN_I2S_MISO,
+	LUAT_PIN_I2S_BCLK,
+	LUAT_PIN_I2S_LRCLK,
+	LUAT_PIN_I2S_MCLK,
+	LUAT_PIN_I2S_QTY,
+	LUAT_PIN_SDIO_DATA0 = 0,
+	LUAT_PIN_SDIO_DATA1,
+	LUAT_PIN_SDIO_DATA2,
+	LUAT_PIN_SDIO_DATA3,
+	LUAT_PIN_SDIO_CMD,
+	LUAT_PIN_SDIO_CLK,
+	LUAT_PIN_SDIO_QTY,
+
+	LUAT_PIN_ONLY_ONE_QTY = 1,
+	LUAT_PIN_FUNCTION_MAX = LUAT_PIN_SDIO_QTY,
+	LUAT_PIN_ALT_FUNCTION_MAX = 8,
+}LUAT_PIN_FUNC_E;
+
+typedef struct
+{
+	uint8_t uid;	//用于硬件操作所需的唯一ID
+	uint8_t altfun_id;	//复用功能id
+}luat_pin_iomux_info;	//pin复用信息
+
+typedef union
+{
+	struct
+	{
+		uint16_t function_id:4;
+		uint16_t peripheral_id:4;
+		uint16_t peripheral_type:5;
+		uint16_t is_no_use:1;
+	};
+	uint16_t code;
+}luat_pin_peripheral_function_description_u;
+
+typedef struct
+{
+	uint16_t function_code[LUAT_PIN_ALT_FUNCTION_MAX];
+	uint16_t index;
+	uint8_t uid;
+}luat_pin_function_description_t;
+
+
+typedef struct
+{
+	luat_pin_iomux_info pin_list[LUAT_PIN_UART_QTY];
+}luat_uart_pin_iomux_t;
+
+typedef struct
+{
+	luat_pin_iomux_info pin_list[LUAT_PIN_I2C_QTY];
+}luat_i2c_pin_iomux_t;
+
+typedef struct
+{
+	luat_pin_iomux_info pin_list[LUAT_PIN_SPI_QTY];
+}luat_spi_pin_iomux_t;
+
+typedef struct
+{
+	luat_pin_iomux_info pin_list[LUAT_PIN_PWM_QTY];
+}luat_pwm_pin_iomux_t;
+
+typedef struct
+{
+	luat_pin_iomux_info pin_list[LUAT_PIN_CAN_QTY];
+}luat_can_pin_iomux_t;
+
+typedef struct
+{
+	luat_pin_iomux_info pin_list[LUAT_PIN_I2S_QTY];
+}luat_i2s_pin_iomux_t;
+
+typedef struct
+{
+	luat_pin_iomux_info pin_list[LUAT_PIN_SDIO_QTY];
+}luat_sdio_pin_iomux_t;
+
+
+/**
+ * @brief 获取某种外设的全部pin复用信息
+ * @param type 外设类型,见LUAT_MCU_PERIPHERAL_E
+ * @param id 外设id,例如uart2就填2
+ * @param pin_list 输出pin复用信息表
+ * @return 0成功,其他失败
+ */
+int luat_pin_get_iomux_info(LUAT_MCU_PERIPHERAL_E type, uint8_t id, luat_pin_iomux_info *pin_list);
+/**
+ * @brief 设置某个外设的全部pin复用信息,如果该外设只有一种复用可能性,则不必设置,会直接失败
+ * @param type 外设类型,见LUAT_MCU_PERIPHERAL_E
+ * @param id 外设id,例如uart2就填2
+ * @param pin_list 输入pin复用信息表
+ * @return 0成功,其他失败
+ */
+int luat_pin_set_iomux_info(LUAT_MCU_PERIPHERAL_E type, uint8_t id, luat_pin_iomux_info *pin_list);
+/**
+ * @brief 从模块pin脚号返回芯片pin功能的详细描述
+ * @param num 模块pin脚号
+ * @param pin_function 芯片pin功能的详细描述
+ * @return 0成功,其他失败
+ */
+int luat_pin_get_description_from_num(uint32_t num, luat_pin_function_description_t *pin_function);
+
+/**
+ * @brief 从芯片pin功能的详细描述找出所需功能的altfun_id
+ * @param code 功能id
+ * @param pin_function 芯片pin功能的详细描述
+ * @return 0xff失败,其他成功
+ */
+uint8_t luat_pin_get_altfun_id_from_description(uint16_t code, luat_pin_function_description_t *pin_function);
+
+void luat_pin_iomux_config(luat_pin_iomux_info pin, uint8_t use_altfunction_pull, uint8_t driver_strength);
+
+void luat_pin_iomux_print(luat_pin_iomux_info *pin_list, uint8_t num);
+
+int luat_pins_load_from_file(const char* path);
+
+int luat_pins_setup(uint16_t pin, const char* func_name, size_t name_len, int altfun_id);
+
+#endif

+ 180 - 138
luat/modules/luat_lib_pins.c → components/pins/src/luat_pins.c

@@ -1,36 +1,16 @@
-/*
-@module  pins
-@summary 管脚外设复用
-@version 1.0
-@date    2025.4.10
-@tag     @tag LUAT_USE_PINS
-@demo     pins
-@usage
--- 请使用LuaTools的可视化工具进行配置,你通常不需要使用这个demo
--- 请使用LuaTools的可视化工具进行配置,你通常不需要使用这个demo
--- 请使用LuaTools的可视化工具进行配置,你通常不需要使用这个demo
--- 请使用LuaTools的可视化工具进行配置,你通常不需要使用这个demo
--- 请使用LuaTools的可视化工具进行配置,你通常不需要使用这个demo
--- 请使用LuaTools的可视化工具进行配置,你通常不需要使用这个demo
--- 请使用LuaTools的可视化工具进行配置,你通常不需要使用这个demo
--- 请使用LuaTools的可视化工具进行配置,你通常不需要使用这个demo
--- 请使用LuaTools的可视化工具进行配置,你通常不需要使用这个demo
--- 请使用LuaTools的可视化工具进行配置,你通常不需要使用这个demo
--- 请使用LuaTools的可视化工具进行配置,你通常不需要使用这个demo
-
--- 本库的API属于高级用法, 仅动态配置管脚时使用
--- 本库的API属于高级用法, 仅动态配置管脚时使用
--- 本库的API属于高级用法, 仅动态配置管脚时使用
-*/
 
 #include "luat_base.h"
-#include "luat_pin.h"
+#include "luat_pins.h"
 #include "luat_mcu.h"
 #include <stdlib.h>
+#include "luat_fs.h"
+#include "luat_mem.h"
 
 #define LUAT_LOG_TAG "pins"
 #include "luat_log.h"
 
+#include "cJSON.h"
+
 static int luat_isdigit(char c)
 {
 	return (c >= '0' && c <= '9');
@@ -274,126 +254,188 @@ LUAT_PIN_FUNCTION_ANALYZE_DONE:
 	return description;
 }
 
-/**
-当某种外设允许复用在不同引脚上时,指定某个管脚允许复用成某种外设功能,需要在外设启用前配置好,外设启用时起作用。
-@api pins.setup(pin, func)
-@int 管脚物理编号, 对应模组俯视图下的顺序编号, 例如 67, 68
-@string 功能说明, 例如 "GPIO18", "UART1_TX", "UART1_RX", "SPI1_CLK", "I2C1_CLK", 目前支持的外设有"UART","I2C","SPI","PWM","CAN","GPIO","ONEWIRE"
-@return boolean 配置成功,返回true, 其他情况均返回false, 并在日志中提示失败原因
-@usage
---把air780epm的PIN67脚,做GPIO 18用
---pins.setup(67, "GPIO18")
---把air780epm的PIN55脚,做uart2 rx用
---pins.setup(55, "UART2_RXD")
---把air780epm的PIN56脚,做uart2 tx用
---pins.setup(56, "UART2_TXD")
- */
-static int luat_pin_setup(lua_State *L){
-    size_t len;
-    int pin = 0;
-    int result;
-    int altfun_id;
-    const char* func_name = NULL;
-    luat_pin_peripheral_function_description_u func_description;
-    pin = luaL_optinteger(L, 1, -1);
-    if (pin < 0)
-    {
-    	LLOGE("pin序号参数错误");
-    	goto LUAT_PIN_SETUP_DONE;
-    }
-    else
-    {
-    	luat_pin_function_description_t pin_description;
-    	if (luat_pin_get_description_from_num(pin, &pin_description))
-    	{
-        	LLOGE("pin%d不支持修改", pin);
-        	goto LUAT_PIN_SETUP_DONE;
-    	}
-    	if (!lua_isinteger(L, 2))
-    	{
-    		func_name = luaL_checklstring(L, 2, &len);
-        	if (len < 2)
-        	{
-        		LLOGE("%.*s外设功能描述不正确", len, func_name);
-        		goto LUAT_PIN_SETUP_DONE;
-        	}
+int luat_pins_setup(uint16_t pin, const char* func_name, size_t name_len, int altfun_id) {
+	luat_pin_function_description_t pin_description;
+	luat_pin_peripheral_function_description_u func_description;
+	int result;
+	if (luat_pin_get_description_from_num(pin, &pin_description))
+	{
+		LLOGE("pin%d不支持修改", pin);
+		goto LUAT_PIN_SETUP_DONE;
+	}
+	if (func_name != NULL)
+	{
+		if (name_len < 2)
+		{
+			LLOGE("%.*s外设功能描述不正确", name_len, func_name);
+			goto LUAT_PIN_SETUP_DONE;
+		}
 
-        	func_description = luat_pin_function_analyze(func_name, len);
-        	if (func_description.code == 0xffff)
-        	{
-        		goto LUAT_PIN_SETUP_DONE;
-        	}
-        	altfun_id = luat_pin_get_altfun_id_from_description(func_description.code, &pin_description);
-        	if (altfun_id == 0xff)
-        	{
-        		LLOGE("%.*s不是pin%d的可配置功能", len, func_name, pin);
-        		goto LUAT_PIN_SETUP_DONE;
-        	}
-    	}
-    	else
-    	{
-    		altfun_id = luaL_optinteger(L, 2, LUAT_PIN_ALT_FUNCTION_MAX);
-    		if (altfun_id < LUAT_PIN_ALT_FUNCTION_MAX)
-    		{
-    			func_description.code = pin_description.function_code[altfun_id];
-    			if (func_description.code == 0xffff)
-    			{
-            		LLOGE("没有altfunction%d", altfun_id);
-            		goto LUAT_PIN_SETUP_DONE;
-    			}
-    		}
-    		else
-    		{
-        		LLOGE("没有altfunction%d", altfun_id);
-        		goto LUAT_PIN_SETUP_DONE;
-    		}
-    	}
-    	luat_pin_iomux_info pin_list[LUAT_PIN_FUNCTION_MAX] = {0};
-    	if (!luat_pin_get_iomux_info(func_description.peripheral_type, func_description.peripheral_id, pin_list))
-    	{
-    		pin_list[func_description.function_id].altfun_id = altfun_id;
-    		pin_list[func_description.function_id].uid = pin_description.uid;
-    		if (!luat_pin_set_iomux_info(func_description.peripheral_type, func_description.peripheral_id, pin_list))
-    		{
-    			result = 1;
-    			goto LUAT_PIN_SETUP_DONE;
-    		}
-    	}
-    	if (func_name)
-    	{
-    		LLOGE("%.*s不可配置,请确认硬件手册上该功能可以复用在2个及以上的pin", len, func_name);
-    	}
-    	else
-    	{
-    		LLOGE("altfunction%d不可配置,请确认硬件手册上该功能可以复用在2个及以上的pin", altfun_id);
-    	}
-    }
+		func_description = luat_pin_function_analyze(func_name, name_len);
+		if (func_description.code == 0xffff)
+		{
+			goto LUAT_PIN_SETUP_DONE;
+		}
+		altfun_id = luat_pin_get_altfun_id_from_description(func_description.code, &pin_description);
+		if (altfun_id == 0xff)
+		{
+			LLOGE("%.*s不是pin%d的可配置功能", name_len, func_name, pin);
+			goto LUAT_PIN_SETUP_DONE;
+		}
+	}
+	else
+	{
+		if (altfun_id < LUAT_PIN_ALT_FUNCTION_MAX)
+		{
+			func_description.code = pin_description.function_code[altfun_id];
+			if (func_description.code == 0xffff)
+			{
+				LLOGE("没有altfunction%d", altfun_id);
+				goto LUAT_PIN_SETUP_DONE;
+			}
+		}
+		else
+		{
+			LLOGE("没有altfunction%d", altfun_id);
+			goto LUAT_PIN_SETUP_DONE;
+		}
+	}
+	luat_pin_iomux_info pin_list[LUAT_PIN_FUNCTION_MAX] = {0};
+	if (!luat_pin_get_iomux_info(func_description.peripheral_type, func_description.peripheral_id, pin_list))
+	{
+		pin_list[func_description.function_id].altfun_id = altfun_id;
+		pin_list[func_description.function_id].uid = pin_description.uid;
+		if (!luat_pin_set_iomux_info(func_description.peripheral_type, func_description.peripheral_id, pin_list))
+		{
+			result = 1;
+			goto LUAT_PIN_SETUP_DONE;
+		}
+	}
+	if (func_name)
+	{
+		LLOGE("%.*s不可配置,请确认硬件手册上该功能可以复用在2个及以上的pin", name_len, func_name);
+	}
+	else
+	{
+		LLOGE("altfunction%d不可配置,请确认硬件手册上该功能可以复用在2个及以上的pin", altfun_id);
+	}
 LUAT_PIN_SETUP_DONE:
-	lua_pushboolean(L, result);
-	return 1;
+	return result;
 }
 
-/**
-加载硬件配置,如果存在/luadb/pins.json,开机后自动加载/luadb/pins.json,无需调用
-@api pins.load(path)
-@string path, 配置文件路径, 可选, 默认值是 /luadb/pins.json
-@return boolean 成功返回true, 失败返回nil, 并在日志中提示失败原因
-@usage
-pins.load("/my.json")
-*/
-static int luat_pin_load(lua_State *L){
+// 加载过程
+static int luat_pins_load_from_json(cJSON *root)
+{
+	cJSON *pins = cJSON_GetObjectItem(root, "pins");
+	cJSON *item;
+	cJSON *pin_item;
+	cJSON *func_item;
+	uint16_t pin;
+	const char* func = NULL;
+	if (pins == NULL) {
+		LLOGE("json without pins item!!!");
+		return -101;
+	}
+	int pins_count = cJSON_GetArraySize(pins);
+	if (pins_count < 1) {
+		LLOGE("invaild pins item!!!");
+		return -102;
+	}
+	if (pins_count == 0) {
+		LLOGD("pins is emtry!!!");
+		return -103;
+	}
+	for (size_t i = 0; i < pins_count; i++)
+	{
+		item = cJSON_GetArrayItem(pins, i);
+		if (item == NULL) {
+			LLOGW("emtry pins item[%d]??", i);
+			continue;
+		}
+		if (!cJSON_IsArray(item)) {
+			LLOGW("pins item[%d] is not array", i);
+			continue;
+		}
+		pin_item = cJSON_GetArrayItem(item, 0);
+		func_item = cJSON_GetArrayItem(item, 1);
+		if (pin_item == NULL || func_item == NULL) {
+			LLOGW("pins item[%d] is not vaild!!!", i);
+			continue;
+		}
+		if (!cJSON_IsNumber(pin_item)) {
+			LLOGW("pins item[%d] pin is not number", i);
+			continue;
+		}
+		if (!cJSON_IsString(func_item) || func_item->valuestring == NULL) {
+			LLOGW("pins item[%d] func is not string", i);
+			continue;
+		}
+		pin = pin_item->valueint;
+		func = func_item->valuestring;
+		if (luat_pins_setup(pin, func, strlen(func), 0) != 0) {
+			LLOGW("pins %d %s setup failed", pin, func);
+			continue;
+		}
+	}
+	
+
 	return 0;
 }
 
-#include "rotable2.h"
-static const rotable_Reg_t reg_pins[] =
+static int luat_pins_load_from_bin(const uint8_t *data, size_t len)
 {
-    {"setup",     ROREG_FUNC(luat_pin_setup)},
-	{"load",     ROREG_FUNC(luat_pin_load)},
-	{ NULL,     ROREG_INT(0) }
-};
+	LLOGE("not support bin file yet");
+	return -5;
+}
 
-LUAMOD_API int luaopen_pins( lua_State *L ) {
-    luat_newlib2(L, reg_pins);
-    return 1;
+int luat_pins_load_from_file(const char* path) {
+	size_t flen;
+	int ret = -100;
+	flen = luat_fs_fsize(path);
+	if (flen < 1) {
+		LLOGW("%s not exist!!", path);
+		return -1;
+	}
+	if (flen > 16 * 1024) {
+		LLOGW("%s too large!!", path);
+		return -2;
+	}
+	uint8_t *data = (uint8_t *)luat_heap_malloc(flen);
+	if (data == NULL) {
+		LLOGW("no memory for loading %s", path);
+		return -3;
+	}
+	FILE* fd = luat_fs_fopen(path, "rb");
+	if (fd == NULL) {
+		LLOGW("open %s failed", path);
+		luat_heap_free(data);
+		return -4;
+	}
+	if (luat_fs_fread(data, 1, flen, fd) != flen) {
+		LLOGW("read %s failed", path);
+		luat_heap_free(data);
+		return -4;
+	}
+	luat_fs_fclose(fd);
+	if (memcmp(path + strlen(path) - 4, ".bin", 4) == 0) {
+		ret = luat_pins_load_from_bin(data, flen);
+	}
+	else if (memcmp(path + strlen(path) - 5, ".json", 5)) {
+		cJSON * root = cJSON_ParseWithLength((const char *)data, flen);
+		if (root == NULL) {
+			LLOGE("not valid json %s", path);
+		}
+		else {
+			ret = luat_pins_load_from_json((cJSON *)root);
+			cJSON_Delete(root);
+		}
+	}
+	else {
+		LLOGE("unknown file type %s", path);
+	}
+	if (data) {
+		luat_heap_free(data);
+		data = NULL;
+	}
+	return ret;
 }

+ 0 - 140
luat/include/luat_pin.h

@@ -1,149 +1,9 @@
-
 #ifndef LUAT_PIN_H
 #define LUAT_PIN_H
-#include "luat_mcu.h"
-
-
-typedef enum
-{
-	LUAT_PIN_UART_RX,
-	LUAT_PIN_UART_TX,
-	LUAT_PIN_UART_RTS,
-	LUAT_PIN_UART_CTS,
-	LUAT_PIN_UART_QTY,
-	LUAT_PIN_I2C_SCL = 0,
-	LUAT_PIN_I2C_SDA,
-	LUAT_PIN_I2C_QTY,
-	LUAT_PIN_SPI_MOSI = 0,
-	LUAT_PIN_SPI_MISO,
-	LUAT_PIN_SPI_CLK,
-	LUAT_PIN_SPI_CS,
-	LUAT_PIN_SPI_QTY,
-	LUAT_PIN_PWM_P = 0,
-	LUAT_PIN_PWM_N,
-	LUAT_PIN_PWM_QTY,
-	LUAT_PIN_CAN_RX = 0,
-	LUAT_PIN_CAN_TX,
-	LUAT_PIN_CAN_STB,
-	LUAT_PIN_CAN_QTY,
-	LUAT_PIN_I2S_MOSI = 0,
-	LUAT_PIN_I2S_MISO,
-	LUAT_PIN_I2S_BCLK,
-	LUAT_PIN_I2S_LRCLK,
-	LUAT_PIN_I2S_MCLK,
-	LUAT_PIN_I2S_QTY,
-	LUAT_PIN_SDIO_DATA0 = 0,
-	LUAT_PIN_SDIO_DATA1,
-	LUAT_PIN_SDIO_DATA2,
-	LUAT_PIN_SDIO_DATA3,
-	LUAT_PIN_SDIO_CMD,
-	LUAT_PIN_SDIO_CLK,
-	LUAT_PIN_SDIO_QTY,
-
-	LUAT_PIN_ONLY_ONE_QTY = 1,
-	LUAT_PIN_FUNCTION_MAX = LUAT_PIN_SDIO_QTY,
-	LUAT_PIN_ALT_FUNCTION_MAX = 8,
-}LUAT_PIN_FUNC_E;
-
-typedef struct
-{
-	uint8_t uid;	//用于硬件操作所需的唯一ID
-	uint8_t altfun_id;	//复用功能id
-}luat_pin_iomux_info;	//pin复用信息
-
-typedef union
-{
-	struct
-	{
-		uint16_t function_id:4;
-		uint16_t peripheral_id:4;
-		uint16_t peripheral_type:5;
-		uint16_t is_no_use:1;
-	};
-	uint16_t code;
-}luat_pin_peripheral_function_description_u;
-
-typedef struct
-{
-	uint16_t function_code[LUAT_PIN_ALT_FUNCTION_MAX];
-	uint16_t index;
-	uint8_t uid;
-}luat_pin_function_description_t;
-
-
-typedef struct
-{
-	luat_pin_iomux_info pin_list[LUAT_PIN_UART_QTY];
-}luat_uart_pin_iomux_t;
-
-typedef struct
-{
-	luat_pin_iomux_info pin_list[LUAT_PIN_I2C_QTY];
-}luat_i2c_pin_iomux_t;
-
-typedef struct
-{
-	luat_pin_iomux_info pin_list[LUAT_PIN_SPI_QTY];
-}luat_spi_pin_iomux_t;
-
-typedef struct
-{
-	luat_pin_iomux_info pin_list[LUAT_PIN_PWM_QTY];
-}luat_pwm_pin_iomux_t;
-
-typedef struct
-{
-	luat_pin_iomux_info pin_list[LUAT_PIN_CAN_QTY];
-}luat_can_pin_iomux_t;
-
-typedef struct
-{
-	luat_pin_iomux_info pin_list[LUAT_PIN_I2S_QTY];
-}luat_i2s_pin_iomux_t;
-
-typedef struct
-{
-	luat_pin_iomux_info pin_list[LUAT_PIN_SDIO_QTY];
-}luat_sdio_pin_iomux_t;
 
 
 int luat_pin_to_gpio(const char* pin_name);
 
 int luat_pin_parse(const char* pin_name, size_t* zone, size_t* index);
 
-/**
- * @brief 获取某种外设的全部pin复用信息
- * @param type 外设类型,见LUAT_MCU_PERIPHERAL_E
- * @param id 外设id,例如uart2就填2
- * @param pin_list 输出pin复用信息表
- * @return 0成功,其他失败
- */
-int luat_pin_get_iomux_info(LUAT_MCU_PERIPHERAL_E type, uint8_t id, luat_pin_iomux_info *pin_list);
-/**
- * @brief 设置某个外设的全部pin复用信息,如果该外设只有一种复用可能性,则不必设置,会直接失败
- * @param type 外设类型,见LUAT_MCU_PERIPHERAL_E
- * @param id 外设id,例如uart2就填2
- * @param pin_list 输入pin复用信息表
- * @return 0成功,其他失败
- */
-int luat_pin_set_iomux_info(LUAT_MCU_PERIPHERAL_E type, uint8_t id, luat_pin_iomux_info *pin_list);
-/**
- * @brief 从模块pin脚号返回芯片pin功能的详细描述
- * @param num 模块pin脚号
- * @param pin_function 芯片pin功能的详细描述
- * @return 0成功,其他失败
- */
-int luat_pin_get_description_from_num(uint32_t num, luat_pin_function_description_t *pin_function);
-
-/**
- * @brief 从芯片pin功能的详细描述找出所需功能的altfun_id
- * @param code 功能id
- * @param pin_function 芯片pin功能的详细描述
- * @return 0xff失败,其他成功
- */
-uint8_t luat_pin_get_altfun_id_from_description(uint16_t code, luat_pin_function_description_t *pin_function);
-
-void luat_pin_iomux_config(luat_pin_iomux_info pin, uint8_t use_altfunction_pull, uint8_t driver_strength);
-
-void luat_pin_iomux_print(luat_pin_iomux_info *pin_list, uint8_t num);
 #endif