Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ruanhaishen
Nodemcu Firmware
Commits
5e6cb4d1
Commit
5e6cb4d1
authored
Aug 29, 2022
by
Joo Aun Saw
Committed by
Johny Mattsson
Aug 30, 2022
Browse files
uart: slight clean up of uart.setup
parent
ddc770a6
Changes
1
Hide whitespace changes
Inline
Side-by-side
components/modules/uart.c
View file @
5e6cb4d1
...
@@ -132,7 +132,7 @@ static int uart_on( lua_State* L )
...
@@ -132,7 +132,7 @@ static int uart_on( lua_State* L )
// Lua: actualbaud = setup( id, baud, databits, parity, stopbits, echo )
// Lua: actualbaud = setup( id, baud, databits, parity, stopbits, echo )
static
int
uart_setup
(
lua_State
*
L
)
static
int
uart_setup
(
lua_State
*
L
)
{
{
unsigned
id
,
databits
,
parity
,
stopbits
,
echo
=
1
;
unsigned
id
,
databits
,
parity
,
stopbits
;
uint32_t
baud
,
res
;
uint32_t
baud
,
res
;
uart_pins_t
pins
;
uart_pins_t
pins
;
uart_pins_t
*
pins_to_use
=
NULL
;
uart_pins_t
*
pins_to_use
=
NULL
;
...
@@ -144,13 +144,14 @@ static int uart_setup( lua_State* L )
...
@@ -144,13 +144,14 @@ static int uart_setup( lua_State* L )
databits
=
luaL_checkinteger
(
L
,
3
);
databits
=
luaL_checkinteger
(
L
,
3
);
parity
=
luaL_checkinteger
(
L
,
4
);
parity
=
luaL_checkinteger
(
L
,
4
);
stopbits
=
luaL_checkinteger
(
L
,
5
);
stopbits
=
luaL_checkinteger
(
L
,
5
);
if
(
id
==
CONFIG_ESP_CONSOLE_UART_NUM
&&
lua_isnumber
(
L
,
6
)){
if
(
id
==
CONFIG_ESP_CONSOLE_UART_NUM
){
echo
=
lua_tointeger
(
L
,
6
);
if
(
!
lua_isnoneornil
(
L
,
6
))
{
if
(
echo
!=
0
)
input_echo
=
luaL_checkinteger
(
L
,
6
)
>
0
;
input_echo
=
true
;
}
else
}
else
{
input_echo
=
false
;
if
(
!
lua_isnoneornil
(
L
,
6
))
{
}
else
if
(
id
!=
CONFIG_ESP_CONSOLE_UART_NUM
&&
lua_istable
(
L
,
6
))
{
luaL_checktable
(
L
,
6
);
lua_getfield
(
L
,
6
,
"tx"
);
lua_getfield
(
L
,
6
,
"tx"
);
pins
.
tx_pin
=
luaL_checkint
(
L
,
-
1
);
pins
.
tx_pin
=
luaL_checkint
(
L
,
-
1
);
lua_getfield
(
L
,
6
,
"rx"
);
lua_getfield
(
L
,
6
,
"rx"
);
...
@@ -173,6 +174,7 @@ static int uart_setup( lua_State* L )
...
@@ -173,6 +174,7 @@ static int uart_setup( lua_State* L )
pins
.
flow_control
=
luaL_optint
(
L
,
-
1
,
PLATFORM_UART_FLOW_NONE
);
pins
.
flow_control
=
luaL_optint
(
L
,
-
1
,
PLATFORM_UART_FLOW_NONE
);
pins_to_use
=
&
pins
;
pins_to_use
=
&
pins
;
}
}
}
res
=
platform_uart_setup
(
id
,
baud
,
databits
,
parity
,
stopbits
,
pins_to_use
);
res
=
platform_uart_setup
(
id
,
baud
,
databits
,
parity
,
stopbits
,
pins_to_use
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment