uart: slight clean up of uart.setup
This commit is contained in:
parent
ddc770a6f7
commit
5e6cb4d1fa
|
@ -132,7 +132,7 @@ static int uart_on( lua_State* L )
|
|||
// Lua: actualbaud = setup( id, baud, databits, parity, stopbits, echo )
|
||||
static int uart_setup( lua_State* L )
|
||||
{
|
||||
unsigned id, databits, parity, stopbits, echo = 1;
|
||||
unsigned id, databits, parity, stopbits;
|
||||
uint32_t baud, res;
|
||||
uart_pins_t pins;
|
||||
uart_pins_t* pins_to_use = NULL;
|
||||
|
@ -144,13 +144,14 @@ static int uart_setup( lua_State* L )
|
|||
databits = luaL_checkinteger( L, 3 );
|
||||
parity = luaL_checkinteger( L, 4 );
|
||||
stopbits = luaL_checkinteger( L, 5 );
|
||||
if(id == CONFIG_ESP_CONSOLE_UART_NUM && lua_isnumber(L,6)){
|
||||
echo = lua_tointeger(L,6);
|
||||
if(echo!=0)
|
||||
input_echo = true;
|
||||
else
|
||||
input_echo = false;
|
||||
} else if(id != CONFIG_ESP_CONSOLE_UART_NUM && lua_istable( L, 6 )) {
|
||||
if(id == CONFIG_ESP_CONSOLE_UART_NUM){
|
||||
if (!lua_isnoneornil(L, 6)) {
|
||||
input_echo = luaL_checkinteger(L, 6) > 0;
|
||||
}
|
||||
} else {
|
||||
if (!lua_isnoneornil(L, 6)) {
|
||||
luaL_checktable(L, 6);
|
||||
|
||||
lua_getfield (L, 6, "tx");
|
||||
pins.tx_pin = luaL_checkint(L, -1);
|
||||
lua_getfield (L, 6, "rx");
|
||||
|
@ -173,6 +174,7 @@ static int uart_setup( lua_State* L )
|
|||
pins.flow_control = luaL_optint(L, -1, PLATFORM_UART_FLOW_NONE);
|
||||
|
||||
pins_to_use = &pins;
|
||||
}
|
||||
}
|
||||
|
||||
res = platform_uart_setup( id, baud, databits, parity, stopbits, pins_to_use );
|
||||
|
|
Loading…
Reference in New Issue