|
|
@@ -74,6 +74,9 @@ int l_uart_handler(lua_State *L, void* ptr) {
|
|
|
@int 校验位, 可选 uart.None/uart.Even/uart.Odd
|
|
|
@int 大小端, 默认小端 uart.LSB, 可选 uart.MSB
|
|
|
@int 缓冲区大小, 默认值1024
|
|
|
+@int 485模式下的转换GPIO, 默认值0xffffffff
|
|
|
+@int 485模式下的rx方向GPIO的电平, 默认值0
|
|
|
+@int 485模式下tx向rx转换的延迟时间,默认值12bit的时间,单位us
|
|
|
@return int 成功返回0,失败返回其他值
|
|
|
@usage
|
|
|
-- 最常用115200 8N1
|
|
|
@@ -90,6 +93,9 @@ static int l_uart_setup(lua_State *L)
|
|
|
uart_config->parity = luaL_optinteger(L, 5, LUAT_PARITY_NONE);
|
|
|
uart_config->bit_order = luaL_optinteger(L, 6, LUAT_BIT_ORDER_LSB);
|
|
|
uart_config->bufsz = luaL_optinteger(L, 7, 1024);
|
|
|
+ uart_config->pin485 = luaL_optinteger(L, 8, 0xffffffff);
|
|
|
+ uart_config->rx_level = luaL_optinteger(L, 9, 0);
|
|
|
+ uart_config->delay = luaL_optinteger(L, 10, 12000000/uart_config->baud_rate);
|
|
|
|
|
|
int result = luat_uart_setup(uart_config);
|
|
|
lua_pushinteger(L, result);
|