Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
ruanhaishen
Nodemcu Firmware
Commits
dba57fa0
Commit
dba57fa0
authored
Aug 24, 2021
by
Johny Mattsson
Browse files
Merge branch 'dev-esp32-idf4-lua53' into dev-esp32-idf4
parents
3a6961cc
8e5ce49d
Changes
224
Hide whitespace changes
Inline
Side-by-side
components/modules/Kconfig
View file @
dba57fa0
...
...
@@ -21,12 +21,26 @@ menu "NodeMCU modules"
help
Includes the simple BlueTooth HCI module.
config NODEMCU_CMODULE_CAN
depends on CONFIG_IDF_TARGET_ESP32
bool "CAN module"
default "n"
help
Includes the can module.
config NODEMCU_CMODULE_CRYPTO
bool "Crypto module"
default "n"
help
Includes the crypto module.
config NODEMCU_CMODULE_DAC
depends on IDF_TARGET_ESP32 || IDF_TARGET_ESP32S2
bool "DAC module"
default "n"
help
Includes the dac module.
config NODEMCU_CMODULE_DHT
bool "DHT11/21/22/AM2301/AM2302 module"
default "n"
...
...
@@ -40,6 +54,14 @@ menu "NodeMCU modules"
Includes the encoder module. This provides hex and base64 encoding
and decoding functionality.
config NODEMCU_CMODULE_ETH
depends on IDF_TARGET_ESP32
select ETH_USE_ESP32_EMAC
bool "Ethernet module"
default "n"
help
Includes the ethernet module.
config NODEMCU_CMODULE_FILE
bool "File module"
default "y"
...
...
@@ -64,6 +86,13 @@ menu "NodeMCU modules"
help
Includes the I2C module (recommended).
config NODEMCU_CMODULE_I2S
depends on IDF_TARGET_ESP32
bool "I2S module"
default "n"
help
Includes the I2S module.
config NODEMCU_CMODULE_LEDC
bool "LEDC module"
default "n"
...
...
@@ -102,6 +131,20 @@ menu "NodeMCU modules"
requires a partition table with at least two OTA partitions, plus
the OTA data partition. See the IDF documentation for details.
config NODEMCU_CMODULE_PIPE
bool "Pipe module"
default "y"
help
Includes the pipe module (required by our Lua VM).
config NODEMCU_CMODULE_PULSECNT
depends on IDF_TARGET_ESP32
bool "Pulse counter module"
default "n"
help
Includes the pulse counter module to use ESP32's built-in pulse
counting hardware.
config NODEMCU_CMODULE_QRCODEGEN
bool "QR Code Generator module"
default "n"
...
...
@@ -109,6 +152,13 @@ menu "NodeMCU modules"
Includes the QR Code Generator from
https://www.nayuki.io/page/qr-code-generator-library
config NODEMCU_CMODULE_SDMMC
depends on IDF_TARGET_ESP32
bool "SD-MMC module"
default "n"
help
Includes the sdmmc module.
config NODEMCU_CMODULE_SIGMA_DELTA
bool "Sigma-Delta module"
default "n"
...
...
@@ -147,6 +197,14 @@ menu "NodeMCU modules"
help
Includes the timer module (recommended).
config NODEMCU_CMODULE_TOUCH
depends on IDF_TARGET_ESP32
bool "Touch module"
default "n"
help
Includes the touch module to use ESP32's built-in touch sensor
hardware.
config NODEMCU_CMODULE_U8G2
bool "U8G2 module"
default "n"
...
...
@@ -182,4 +240,10 @@ menu "NodeMCU modules"
help
Includes the time module.
config NODEMCU_CMODULE_UART
bool "UART module"
default y
help
Includes the UART module (required by our Lua VM).
endmenu
components/modules/adc.c
View file @
dba57fa0
...
...
@@ -60,7 +60,7 @@ static int read_hall_sensor( lua_State *L )
}
// Module function map
LROT_BEGIN
(
adc
)
LROT_BEGIN
(
adc
,
NULL
,
0
)
LROT_FUNCENTRY
(
setwidth
,
adc_set_width
)
LROT_FUNCENTRY
(
setup
,
adc_setup
)
LROT_FUNCENTRY
(
read
,
adc_read
)
...
...
components/modules/bit.c
View file @
dba57fa0
...
...
@@ -119,7 +119,7 @@ static int bit_clear( lua_State* L )
return
1
;
}
LROT_BEGIN
(
bit
)
LROT_BEGIN
(
bit
,
NULL
,
0
)
LROT_FUNCENTRY
(
bnot
,
bit_bnot
)
LROT_FUNCENTRY
(
band
,
bit_band
)
LROT_FUNCENTRY
(
bor
,
bit_bor
)
...
...
components/modules/bthci.c
View file @
dba57fa0
...
...
@@ -216,7 +216,7 @@ static int send_hci_command (lua_State *L, uint8_t *data, unsigned len)
if
(
lua_gettop
(
L
)
>
0
&&
!
lua_isnil
(
L
,
-
1
))
{
cmd_q
[
i
].
cmd
=
cmd
;
luaL_check
any
function
(
L
,
-
1
);
luaL_checkfunction
(
L
,
-
1
);
lua_pushvalue
(
L
,
-
1
);
cmd_q
[
i
].
cb_ref
=
luaL_ref
(
L
,
LUA_REGISTRYINDEX
);
}
...
...
@@ -271,7 +271,7 @@ static void invoke_cmd_q_callback (
else
lua_pushnil
(
L
);
// no error
lua_pushlstring
(
L
,
(
const
char
*
)
data
,
len
);
// extra bytes, if any
lua
_
call
(
L
,
2
,
0
);
lua
L_p
call
x
(
L
,
2
,
0
);
}
}
...
...
@@ -316,7 +316,7 @@ static void handle_hci_event (task_param_t arg, task_prio_t prio)
uint8_t
*
report
=
&
hci_event
[
5
];
lua_rawgeti
(
L
,
LUA_REGISTRYINDEX
,
adv_rep_cb_ref
);
lua_pushlstring
(
L
,
(
const
char
*
)
report
,
len
-
2
);
lua
_
call
(
L
,
1
,
0
);
lua
L_p
call
x
(
L
,
1
,
0
);
}
}
}
...
...
@@ -424,7 +424,7 @@ static int lbthci_adv_setparams (lua_State *L)
uint8_t
adv_chan_map
=
ADV_CHAN_ALL
;
uint8_t
adv_filter_pol
=
ADV_FILTER_NONE
;
luaL_check
any
table
(
L
,
1
);
luaL_checktable
(
L
,
1
);
lua_settop
(
L
,
2
);
// Pad a nil into the function slot if necessary
get_opt_field_int
(
1
,
adv_interval_min
,
"interval_min"
);
...
...
@@ -501,7 +501,7 @@ static int lbthci_scan_setparams (lua_State *L)
uint8_t
own_addr_type
=
0
;
uint8_t
filter_policy
=
0
;
luaL_check
any
table
(
L
,
1
);
luaL_checktable
(
L
,
1
);
lua_settop
(
L
,
2
);
// Pad a nil into the function slot if necessary
get_opt_field_int
(
1
,
scan_mode
,
"mode"
);
...
...
@@ -557,7 +557,7 @@ static int lbthci_rawhci (lua_State *L)
}
LROT_BEGIN
(
bthci_adv
)
LROT_BEGIN
(
bthci_adv
,
NULL
,
0
)
LROT_FUNCENTRY
(
enable
,
lbthci_adv_enable
)
LROT_FUNCENTRY
(
setdata
,
lbthci_adv_setdata
)
LROT_FUNCENTRY
(
setparams
,
lbthci_adv_setparams
)
...
...
@@ -576,14 +576,14 @@ LROT_BEGIN(bthci_adv)
LROT_END
(
bthci_adv
,
NULL
,
0
)
LROT_BEGIN
(
bthci_scan
)
LROT_BEGIN
(
bthci_scan
,
NULL
,
0
)
LROT_FUNCENTRY
(
enable
,
lbthci_scan
)
LROT_FUNCENTRY
(
setparams
,
lbthci_scan_setparams
)
LROT_FUNCENTRY
(
on
,
lbthci_scan_on
)
LROT_END
(
bthci_scan
,
NULL
,
0
)
LROT_BEGIN
(
bthci
)
LROT_BEGIN
(
bthci
,
NULL
,
0
)
LROT_FUNCENTRY
(
rawhci
,
lbthci_rawhci
)
LROT_FUNCENTRY
(
reset
,
lbthci_reset
)
LROT_TABENTRY
(
adv
,
bthci_adv
)
...
...
components/modules
-esp32
/can.c
→
components/modules/can.c
View file @
dba57fa0
...
...
@@ -46,7 +46,7 @@ static void can_data_task( task_param_t param, task_prio_t prio ) {
lua_pushinteger
(
L
,
frame
->
MsgID
);
lua_pushlstring
(
L
,
(
char
*
)
frame
->
data
.
u8
,
frame
->
DLC
);
free
(
frame
);
lua
_
call
(
L
,
3
,
0
);
lua
L_p
call
x
(
L
,
3
,
0
);
}
// RTOS
...
...
@@ -77,9 +77,9 @@ static int can_setup( lua_State *L )
{
if
(
xCanTaskHandle
!=
NULL
)
luaL_error
(
L
,
"Stop CAN before setup"
);
luaL_check
any
table
(
L
,
1
);
luaL_checktable
(
L
,
1
);
luaL_check
any
function
(
L
,
2
);
luaL_checkfunction
(
L
,
2
);
lua_settop
(
L
,
2
);
if
(
can_on_received
!=
LUA_NOREF
)
luaL_unref
(
L
,
LUA_REGISTRYINDEX
,
can_on_received
);
can_on_received
=
luaL_ref
(
L
,
LUA_REGISTRYINDEX
);
...
...
@@ -148,7 +148,7 @@ static int can_send( lua_State *L )
}
// Module function map
LROT_BEGIN
(
can
)
LROT_BEGIN
(
can
,
NULL
,
0
)
LROT_FUNCENTRY
(
setup
,
can_setup
)
LROT_FUNCENTRY
(
start
,
can_start
)
LROT_FUNCENTRY
(
stop
,
can_stop
)
...
...
components/modules/common.h
View file @
dba57fa0
...
...
@@ -2,6 +2,9 @@
#define modules_common_h
#include "lua.h"
#include <stdint.h>
#include <stdbool.h>
#include <stddef.h>
/* Some common code shared between modules */
...
...
components/modules/crypto.c
View file @
dba57fa0
...
...
@@ -153,22 +153,22 @@ static int crypto_hash_gc(lua_State* L) {
}
// The following table defines methods of the hasher object
LROT_BEGIN
(
crypto_hasher
)
LROT_FUNCENTRY
(
update
,
crypto_hash_update
)
LROT_FUNCENTRY
(
finalize
,
crypto_hash_finalize
)
LROT_BEGIN
(
crypto_hasher
,
NULL
,
0
)
LROT_FUNCENTRY
(
__gc
,
crypto_hash_gc
)
LROT_TABENTRY
(
__index
,
crypto_hasher
)
LROT_FUNCENTRY
(
update
,
crypto_hash_update
)
LROT_FUNCENTRY
(
finalize
,
crypto_hash_finalize
)
LROT_END
(
crypto_hasher
,
NULL
,
0
)
// This table defines the functions of the crypto module:
LROT_BEGIN
(
crypto
)
LROT_BEGIN
(
crypto
,
NULL
,
0
)
LROT_FUNCENTRY
(
new_hash
,
crypto_new_hash
)
LROT_FUNCENTRY
(
new_hmac
,
crypto_new_hmac
)
LROT_END
(
crypto
,
NULL
,
0
)
// luaopen_crypto is the crypto module initialization function
int
luaopen_crypto
(
lua_State
*
L
)
{
luaL_rometatable
(
L
,
HASH_METATABLE
,
(
void
*
)
crypto_hasher
_map
);
// create metatable for crypto.hash
luaL_rometatable
(
L
,
HASH_METATABLE
,
LROT_TABLEREF
(
crypto_hasher
)
);
// create metatable for crypto.hash
return
0
;
}
...
...
components/modules
-esp32
/dac.c
→
components/modules/dac.c
View file @
dba57fa0
...
...
@@ -52,7 +52,7 @@ static int ldac_write( lua_State *L )
// Module function map
LROT_BEGIN
(
dac
)
LROT_BEGIN
(
dac
,
NULL
,
0
)
LROT_FUNCENTRY
(
enable
,
ldac_enable
)
LROT_FUNCENTRY
(
disable
,
ldac_disable
)
LROT_FUNCENTRY
(
write
,
ldac_write
)
...
...
components/modules/dht.c
View file @
dba57fa0
...
...
@@ -91,7 +91,7 @@ static int ldht_read2x( lua_State *L )
}
LROT_BEGIN
(
dht
)
LROT_BEGIN
(
dht
,
NULL
,
0
)
LROT_FUNCENTRY
(
read11
,
ldht_read11
)
LROT_FUNCENTRY
(
read2x
,
ldht_read2x
)
LROT_NUMENTRY
(
OK
,
LDHT_OK
)
...
...
components/modules/encoder.c
View file @
dba57fa0
...
...
@@ -116,7 +116,7 @@ static uint8_t *fromHex ( lua_State* L, const uint8_t *msg, size_t *len){
}
else
if
(
*
p
>=
'A'
&&
*
p
<=
'F'
)
{
b
=
*
p
++
-
(
'A'
-
10
);
}
else
{
lua
M
_freearray
(
L
,
out
,
*
len
,
uint8_t
);
lua
N
_freearray
(
L
,
out
,
*
len
);
luaL_error
(
L
,
"Invalid hex string"
);
__builtin_unreachable
();
}
...
...
@@ -140,7 +140,7 @@ static int do_func (lua_State *L, uint8_t * (*conv_func)(lua_State *, const uint
if
(
output
)
{
lua_pushlstring
(
L
,
(
char
*
)
output
,
len
);
lua
M
_freearray
(
L
,
output
,
len
,
uint8_t
);
lua
N
_freearray
(
L
,
output
,
len
);
}
else
{
lua_pushstring
(
L
,
""
);
}
...
...
@@ -156,7 +156,7 @@ static int do_func (lua_State *L, uint8_t * (*conv_func)(lua_State *, const uint
DECLARE_FUNCTION
(
toHex
);
// Module function map
LROT_BEGIN
(
encoder
)
LROT_BEGIN
(
encoder
,
NULL
,
0
)
LROT_FUNCENTRY
(
fromBase64
,
encoder_fromBase64
)
LROT_FUNCENTRY
(
toBase64
,
encoder_toBase64
)
LROT_FUNCENTRY
(
fromHex
,
encoder_fromHex
)
...
...
components/modules
-esp32
/eth.c
→
components/modules/eth.c
View file @
dba57fa0
...
...
@@ -119,7 +119,7 @@ static void on_event(esp_event_base_t base, int32_t id, const void *data)
lua_pushstring
(
L
,
events
[
idx
].
name
);
lua_createtable
(
L
,
0
,
5
);
events
[
idx
].
fill_cb_arg
(
L
,
data
);
lua_pcall
(
L
,
2
,
0
,
0
);
lua
L
_pcall
x
(
L
,
2
,
0
);
lua_settop
(
L
,
top
);
}
...
...
@@ -184,7 +184,7 @@ static int leth_on( lua_State *L )
{
const
char
*
event_name
=
luaL_checkstring
(
L
,
1
);
if
(
!
lua_isnoneornil
(
L
,
2
))
{
luaL_check
any
function
(
L
,
2
);
luaL_checkfunction
(
L
,
2
);
}
lua_settop
(
L
,
2
);
...
...
@@ -274,7 +274,7 @@ cleanup_mac_phy:
}
LROT_BEGIN
(
eth
)
LROT_BEGIN
(
eth
,
NULL
,
0
)
LROT_FUNCENTRY
(
init
,
leth_init
)
LROT_FUNCENTRY
(
on
,
leth_on
)
LROT_FUNCENTRY
(
get_speed
,
leth_get_speed
)
...
...
components/modules/file.c
View file @
dba57fa0
...
...
@@ -58,7 +58,7 @@ static int32_t file_rtc_cb( vfs_time *tm )
lua_State
*
L
=
lua_getstate
();
lua_rawgeti
(
L
,
LUA_REGISTRYINDEX
,
rtc_cb_ref
);
lua
_
call
(
L
,
0
,
1
);
lua
L_p
call
x
(
L
,
0
,
1
);
if
(
lua_type
(
L
,
lua_gettop
(
L
)
)
==
LUA_TTABLE
)
{
table2tm
(
L
,
tm
);
...
...
@@ -86,8 +86,7 @@ static int file_on(lua_State *L)
case
ON_RTC
:
luaL_unref
(
L
,
LUA_REGISTRYINDEX
,
rtc_cb_ref
);
if
((
lua_type
(
L
,
2
)
==
LUA_TFUNCTION
)
||
(
lua_type
(
L
,
2
)
==
LUA_TLIGHTFUNCTION
))
{
if
(
lua_isfunction
(
L
,
2
))
{
lua_pushvalue
(
L
,
2
);
// copy argument (func) to the top of stack
rtc_cb_ref
=
luaL_ref
(
L
,
LUA_REGISTRYINDEX
);
vfs_register_rtc_cb
(
file_rtc_cb
);
...
...
@@ -430,7 +429,7 @@ static int file_g_read( lua_State* L, int n, int16_t end_char, int fd )
}
if
(
heap_mem
)
{
lua
M
_freearray
(
L
,
heap_mem
,
bufsize
,
char
);
lua
N
_freearray
(
L
,
heap_mem
,
bufsize
);
}
if
(
err
){
...
...
@@ -550,7 +549,9 @@ static int file_chdir( lua_State *L )
}
#endif
LROT_BEGIN
(
file_obj
)
LROT_BEGIN
(
file_obj
,
NULL
,
0
)
LROT_FUNCENTRY
(
__gc
,
file_obj_free
)
LROT_TABENTRY
(
__index
,
file_obj
)
LROT_FUNCENTRY
(
close
,
file_close
)
LROT_FUNCENTRY
(
read
,
file_read
)
LROT_FUNCENTRY
(
readline
,
file_readline
)
...
...
@@ -558,12 +559,10 @@ LROT_BEGIN(file_obj)
LROT_FUNCENTRY
(
writeline
,
file_writeline
)
LROT_FUNCENTRY
(
seek
,
file_seek
)
LROT_FUNCENTRY
(
flush
,
file_flush
)
LROT_FUNCENTRY
(
__gc
,
file_obj_free
)
LROT_TABENTRY
(
__index
,
file_obj
)
LROT_END
(
file_obj
,
NULL
,
0
)
// Module function map
LROT_BEGIN
(
file
)
LROT_BEGIN
(
file
,
NULL
,
0
)
LROT_FUNCENTRY
(
list
,
file_list
)
LROT_FUNCENTRY
(
open
,
file_open
)
LROT_FUNCENTRY
(
close
,
file_close
)
...
...
@@ -589,7 +588,7 @@ LROT_BEGIN(file)
LROT_END
(
file
,
NULL
,
0
)
int
luaopen_file
(
lua_State
*
L
)
{
luaL_rometatable
(
L
,
"file.obj"
,
(
void
*
)
file_obj
_map
);
luaL_rometatable
(
L
,
"file.obj"
,
LROT_TABLEREF
(
file_obj
)
);
return
0
;
}
...
...
components/modules/gpio.c
View file @
dba57fa0
...
...
@@ -79,7 +79,7 @@ static int lgpio_config (lua_State *L)
luaL_checkstack
(
L
,
5
,
"out of mem"
);
for
(
int
i
=
1
;
i
<=
n
;
++
i
)
{
luaL_check
any
table
(
L
,
i
);
luaL_checktable
(
L
,
i
);
gpio_config_t
cfg
;
cfg
.
intr_type
=
GPIO_INTR_DISABLE
;
...
...
@@ -141,7 +141,7 @@ static int lgpio_trig (lua_State *L)
int
gpio
=
luaL_checkint
(
L
,
1
);
int
intr_type
=
luaL_optint
(
L
,
2
,
GPIO_INTR_DISABLE
);
if
(
!
lua_isnoneornil
(
L
,
3
))
luaL_check
any
function
(
L
,
3
);
luaL_checkfunction
(
L
,
3
);
lua_settop
(
L
,
3
);
...
...
@@ -235,7 +235,7 @@ static void nodemcu_gpio_callback_task (task_param_t param, task_prio_t prio)
lua_rawgeti
(
L
,
LUA_REGISTRYINDEX
,
gpio_cb_refs
[
gpio
]);
lua_pushinteger
(
L
,
gpio
);
lua_pushinteger
(
L
,
level
);
lua
_
call
(
L
,
2
,
0
);
lua
L_p
call
x
(
L
,
2
,
0
);
gpio_intr_enable
(
gpio
);
}
}
...
...
@@ -250,7 +250,7 @@ static int nodemcu_gpio_init (lua_State *L)
}
LROT_BEGIN
(
lgpio
)
LROT_BEGIN
(
lgpio
,
NULL
,
0
)
LROT_FUNCENTRY
(
config
,
lgpio_config
)
LROT_FUNCENTRY
(
read
,
lgpio_read
)
LROT_FUNCENTRY
(
trig
,
lgpio_trig
)
...
...
components/modules/http.c
View file @
dba57fa0
...
...
@@ -335,7 +335,7 @@ static int make_callback(lhttp_context_t *context, int id, void *data, size_t da
// Lowercase all header names
luaL_getmetafield
(
L
,
-
1
,
"lower"
);
lua_insert
(
L
,
-
2
);
lua
_
call
(
L
,
1
,
1
);
lua
L_p
call
x
(
L
,
1
,
1
);
char
*
val
=
item
->
data
+
item
->
len
+
1
;
lua_pushstring
(
L
,
val
);
lua_settable
(
L
,
-
3
);
...
...
@@ -366,7 +366,7 @@ static int make_callback(lhttp_context_t *context, int id, void *data, size_t da
if
(
id
!=
HTTP_REQUEST_COMPLETE
)
{
context_setflag
(
context
,
InCallback
);
}
int
err
=
lua_pcall
(
L
,
lua_gettop
(
L
)
-
1
,
1
,
0
);
int
err
=
lua
L
_pcall
x
(
L
,
lua_gettop
(
L
)
-
1
,
1
);
context_clearflag
(
context
,
InCallback
);
if
(
err
)
{
const
char
*
msg
=
lua_type
(
L
,
-
1
)
==
LUA_TSTRING
?
lua_tostring
(
L
,
-
1
)
:
"<?>"
;
...
...
@@ -657,7 +657,7 @@ static int http_accumulate_complete(lua_State *L)
context_setref
(
L
,
context
,
HeadersCallback
);
}
else
{
lua_rawgeti
(
L
,
cache_table
,
2
);
// headers
lua
_
call
(
L
,
3
,
0
);
lua
L_p
call
x
(
L
,
3
,
0
);
}
// unset this since it contains a reference to the context and would prevent the context to be garbage collected
context_unsetref
(
L
,
context
,
CompleteCallback
);
...
...
@@ -692,7 +692,7 @@ static int make_oneshot_request(lua_State *L, int callback_idx)
// Finally, call request
lua_pushcfunction
(
L
,
http_lapi_request
);
lua_pushvalue
(
L
,
-
2
);
// context
lua
_
call
(
L
,
1
,
0
);
lua
L_p
call
x
(
L
,
1
,
0
);
if
(
async
)
{
return
0
;
...
...
@@ -736,7 +736,7 @@ static int http_lapi_get(lua_State *L)
lua_pushinteger
(
L
,
HTTP_METHOD_GET
);
lua_pushvalue
(
L
,
2
);
// options
lua
_
call
(
L
,
3
,
1
);
// returns context
lua
L_p
call
x
(
L
,
3
,
1
);
// returns context
return
make_oneshot_request
(
L
,
3
);
}
...
...
@@ -768,17 +768,17 @@ static int http_lapi_post(lua_State *L)
lua_pushinteger
(
L
,
HTTP_METHOD_POST
);
lua_pushvalue
(
L
,
2
);
// options
lua
_
call
(
L
,
3
,
1
);
// returns context
lua
L_p
call
x
(
L
,
3
,
1
);
// returns context
lua_pushcfunction
(
L
,
http_lapi_setpostdata
);
lua_pushvalue
(
L
,
-
2
);
// context
lua_pushvalue
(
L
,
3
);
// body
lua
_
call
(
L
,
2
,
0
);
lua
L_p
call
x
(
L
,
2
,
0
);
return
make_oneshot_request
(
L
,
4
);
// 4 = callback idx
}
LROT_BEGIN
(
http
)
LROT_BEGIN
(
http
,
NULL
,
0
)
LROT_FUNCENTRY
(
createConnection
,
http_lapi_createConnection
)
LROT_NUMENTRY
(
GET
,
HTTP_METHOD_GET
)
LROT_NUMENTRY
(
POST
,
HTTP_METHOD_POST
)
...
...
@@ -790,7 +790,9 @@ LROT_BEGIN(http)
LROT_FUNCENTRY
(
post
,
http_lapi_post
)
LROT_END
(
http
,
NULL
,
0
)
LROT_BEGIN
(
http_context
)
LROT_BEGIN
(
http_context
,
NULL
,
0
)
LROT_FUNCENTRY
(
__gc
,
context_gc
)
LROT_TABENTRY
(
__index
,
http_context
)
LROT_FUNCENTRY
(
on
,
http_lapi_on
)
LROT_FUNCENTRY
(
request
,
http_lapi_request
)
LROT_FUNCENTRY
(
setmethod
,
http_lapi_setmethod
)
...
...
@@ -799,13 +801,11 @@ LROT_BEGIN(http_context)
LROT_FUNCENTRY
(
setpostdata
,
http_lapi_setpostdata
)
LROT_FUNCENTRY
(
close
,
context_close
)
LROT_FUNCENTRY
(
ack
,
http_lapi_ack
)
LROT_FUNCENTRY
(
__gc
,
context_gc
)
LROT_TABENTRY
(
__index
,
http_context
)
LROT_END
(
http_context
,
NULL
,
0
)
static
int
luaopen_http
(
lua_State
*
L
)
{
luaL_rometatable
(
L
,
http_context_mt
,
(
void
*
)
http_context
_map
);
luaL_rometatable
(
L
,
http_context_mt
,
LROT_TABLEREF
(
http_context
)
);
lhttp_request_task_id
=
task_get_id
(
lhttp_request_task
);
lhttp_event_task_id
=
task_get_id
(
lhttp_event_task
);
return
0
;
...
...
components/modules/i2c.c
View file @
dba57fa0
...
...
@@ -210,7 +210,7 @@ static int i2c_read( lua_State *L )
}
}
LROT_BEGIN
(
i2c
)
LROT_BEGIN
(
i2c
,
NULL
,
0
)
LROT_FUNCENTRY
(
setup
,
i2c_setup
)
LROT_FUNCENTRY
(
start
,
i2c_start
)
LROT_FUNCENTRY
(
stop
,
i2c_stop
)
...
...
components/modules/i2c_common.h
View file @
dba57fa0
...
...
@@ -29,7 +29,7 @@ int li2c_hw_master_transfer( lua_State *L );
// ***************************************************************************
// Hardware slave prototypes
//
LROT_EXTERN
(
li2c_slave
);
extern
LROT_TABLE
(
li2c_slave
);
void
li2c_hw_slave_init
(
lua_State
*
L
);
...
...
components/modules/i2c_hw_master.c
View file @
dba57fa0
...
...
@@ -4,6 +4,7 @@
#include "lmem.h"
#include "driver/i2c.h"
#include "soc/i2c_reg.h"
#include "hal/i2c_ll.h"
#include "i2c_common.h"
...
...
@@ -110,7 +111,7 @@ static void i2c_transfer_task( task_param_t param, task_prio_t prio )
lua_pushnil
(
L
);
}
lua_pushboolean
(
L
,
job
->
err
==
ESP_OK
);
lua
_
call
(
L
,
2
,
0
);
lua
L_p
call
x
(
L
,
2
,
0
);
}
// free all memory
...
...
@@ -219,7 +220,7 @@ int li2c_hw_master_setup( lua_State *L, unsigned id, unsigned sda, unsigned scl,
int
timeoutcycles
;
i2c_lua_checkerr
(
L
,
i2c_get_timeout
(
port
,
&
timeoutcycles
)
);
timeoutcycles
=
timeoutcycles
*
stretchfactor
;
luaL_argcheck
(
L
,
timeoutcycles
*
stretchfactor
<=
I2C_TIME
_
OUT
_REG_V
,
5
,
"excessive stretch factor"
);
luaL_argcheck
(
L
,
timeoutcycles
*
stretchfactor
<=
I2C_
LL_MAX_
TIMEOUT
,
5
,
"excessive stretch factor"
);
i2c_lua_checkerr
(
L
,
i2c_set_timeout
(
port
,
timeoutcycles
)
);
i2c_lua_checkerr
(
L
,
i2c_driver_install
(
port
,
cfg
.
mode
,
0
,
0
,
0
));
...
...
@@ -319,7 +320,7 @@ int li2c_hw_master_transfer( lua_State *L )
luaL_error
(
L
,
"no commands scheduled"
);
stack
++
;
if
(
lua_isfunction
(
L
,
stack
)
||
lua_islightfunction
(
L
,
stack
))
{
if
(
lua_isfunction
(
L
,
stack
))
{
lua_pushvalue
(
L
,
stack
);
// copy argument (func) to the top of stack
luaL_unref
(
L
,
LUA_REGISTRYINDEX
,
job
->
cb_ref
);
job
->
cb_ref
=
luaL_ref
(
L
,
LUA_REGISTRYINDEX
);
...
...
components/modules/i2c_hw_slave.c
View file @
dba57fa0
...
...
@@ -109,7 +109,7 @@ static void i2c_receive_task( task_param_t param, task_prio_t prio )
}
else
{
lua_pushnil
(
L
);
}
lua
_
call
(
L
,
2
,
0
);
lua
L_p
call
x
(
L
,
2
,
0
);
}
// free all memory
...
...
@@ -173,7 +173,7 @@ static int li2c_slave_setup( lua_State *L )
ud
->
port
=
port
;
int
stack
=
1
;
luaL_check
any
table
(
L
,
++
stack
);
luaL_checktable
(
L
,
++
stack
);
lua_settop
(
L
,
stack
);
i2c_config_t
cfg
;
...
...
@@ -305,7 +305,7 @@ static int li2c_slave_on( lua_State *L )
luaL_unref
(
L
,
LUA_REGISTRYINDEX
,
ud
->
receivedcb_ref
);
++
stack
;
if
(
lua_isfunction
(
L
,
stack
)
||
lua_islightfunction
(
L
,
stack
))
{
if
(
lua_isfunction
(
L
,
stack
))
{
lua_pushvalue
(
L
,
stack
);
// copy argument (func) to the top of stack
ud
->
receivedcb_ref
=
luaL_ref
(
L
,
LUA_REGISTRYINDEX
);
}
...
...
@@ -318,7 +318,7 @@ static int li2c_slave_on( lua_State *L )
}
LROT_
PUBLIC_
BEGIN
(
li2c_slave
)
LROT_BEGIN
(
li2c_slave
,
NULL
,
0
)
LROT_FUNCENTRY
(
on
,
li2c_slave_on
)
LROT_FUNCENTRY
(
setup
,
li2c_slave_setup
)
LROT_FUNCENTRY
(
send
,
li2c_slave_send
)
...
...
components/modules
-esp32
/i2s.c
→
components/modules/i2s.c
View file @
dba57fa0
...
...
@@ -55,7 +55,7 @@ static void i2s_tx_task( task_param_t param, task_prio_t prio ) {
lua_rawgeti
(
L
,
LUA_REGISTRYINDEX
,
is
->
cb
);
lua_pushinteger
(
L
,
i2s_id
);
lua_pushstring
(
L
,
"tx"
);
lua
_
call
(
L
,
2
,
0
);
lua
L_p
call
x
(
L
,
2
,
0
);
}
}
...
...
@@ -68,7 +68,7 @@ static void i2s_rx_task( task_param_t param, task_prio_t prio ) {
lua_rawgeti
(
L
,
LUA_REGISTRYINDEX
,
is
->
cb
);
lua_pushinteger
(
L
,
i2s_id
);
lua_pushstring
(
L
,
"rx"
);
lua
_
call
(
L
,
2
,
0
);
lua
L_p
call
x
(
L
,
2
,
0
);
}
}
...
...
@@ -134,7 +134,7 @@ static int node_i2s_start( lua_State *L )
int
top
=
lua_gettop
(
L
);
luaL_check
any
table
(
L
,
2
);
luaL_checktable
(
L
,
2
);
i2s_config_t
i2s_config
;
memset
(
&
i2s_config
,
0
,
sizeof
(
i2s_config
)
);
...
...
@@ -309,7 +309,7 @@ static int node_i2s_mute( lua_State *L )
// Module function map
LROT_BEGIN
(
i2s
)
LROT_BEGIN
(
i2s
,
NULL
,
0
)
LROT_FUNCENTRY
(
start
,
node_i2s_start
)
LROT_FUNCENTRY
(
stop
,
node_i2s_stop
)
LROT_FUNCENTRY
(
read
,
node_i2s_read
)
...
...
components/modules/ledc.c
View file @
dba57fa0
...
...
@@ -17,7 +17,7 @@ typedef struct {
static
int
lledc_new_channel
(
lua_State
*
L
)
{
const
int
top
=
lua_gettop
(
L
);
luaL_check
any
table
(
L
,
1
);
luaL_checktable
(
L
,
1
);
/* Setup timer */
ledc_timer_config_t
ledc_timer
;
...
...
@@ -231,7 +231,8 @@ static int lledc_set_fade( lua_State *L ) {
}
// Module function map
LROT_BEGIN
(
ledc_channel
)
LROT_BEGIN
(
ledc_channel
,
NULL
,
0
)
LROT_TABENTRY
(
__index
,
ledc_channel
)
LROT_FUNCENTRY
(
getduty
,
lledc_get_duty
)
LROT_FUNCENTRY
(
setduty
,
lledc_set_duty
)
LROT_FUNCENTRY
(
getfreq
,
lledc_get_freq
)
...
...
@@ -245,11 +246,9 @@ LROT_BEGIN(ledc_channel)
LROT_FUNCENTRY
(
fadewithtime
,
lledc_set_fade_with_time
)
LROT_FUNCENTRY
(
fadewithstep
,
lledc_set_fade_with_step
)
LROT_FUNCENTRY
(
fade
,
lledc_set_fade
)
LROT_TABENTRY
(
__index
,
ledc_channel
)
LROT_END
(
ledc_channel
,
NULL
,
0
)
LROT_BEGIN
(
ledc
)
LROT_BEGIN
(
ledc
,
NULL
,
0
)
LROT_FUNCENTRY
(
newChannel
,
lledc_new_channel
)
#if SOC_LEDC_SUPPORT_HS_MODE
...
...
@@ -295,7 +294,7 @@ LROT_BEGIN(ledc)
LROT_END
(
ledc
,
NULL
,
0
)
int
luaopen_ledc
(
lua_State
*
L
)
{
luaL_rometatable
(
L
,
"ledc.channel"
,
(
void
*
)
ledc_channel
_map
);
// create metatable for ledc.channel
luaL_rometatable
(
L
,
"ledc.channel"
,
LROT_TABLEREF
(
ledc_channel
)
);
// create metatable for ledc.channel
return
0
;
}
...
...
Prev
1
…
5
6
7
8
9
10
11
12
Next
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