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
2ab4de9c
Commit
2ab4de9c
authored
Jun 27, 2015
by
Vowstar
Browse files
Merge pull request #512 from jmattsson/boot-reason
Expose boot reason in Lua
parents
0c064bf0
7bd10e8a
Changes
2
Hide whitespace changes
Inline
Side-by-side
app/include/rom.h
View file @
2ab4de9c
...
@@ -39,6 +39,9 @@ extern unsigned char * base64_decode(const unsigned char *src, size_t len, size_
...
@@ -39,6 +39,9 @@ extern unsigned char * base64_decode(const unsigned char *src, size_t len, size_
extern
void
mem_init
(
void
*
start_addr
);
extern
void
mem_init
(
void
*
start_addr
);
// 2, 3 = reset (module dependent?), 4 = wdt
int
rtc_get_reset_reason
(
void
);
// Hardware exception handling
// Hardware exception handling
struct
exception_frame
struct
exception_frame
{
{
...
...
app/modules/node.c
View file @
2ab4de9c
...
@@ -414,6 +414,13 @@ static int node_setcpufreq(lua_State* L)
...
@@ -414,6 +414,13 @@ static int node_setcpufreq(lua_State* L)
return
1
;
return
1
;
}
}
// Lua: code = bootreason()
static
int
node_bootreason
(
lua_State
*
L
)
{
lua_pushnumber
(
L
,
rtc_get_reset_reason
());
return
1
;
}
// Module function map
// Module function map
#define MIN_OPT_LEVEL 2
#define MIN_OPT_LEVEL 2
#include "lrodefs.h"
#include "lrodefs.h"
...
@@ -438,6 +445,7 @@ const LUA_REG_TYPE node_map[] =
...
@@ -438,6 +445,7 @@ const LUA_REG_TYPE node_map[] =
{
LSTRKEY
(
"CPU80MHZ"
),
LNUMVAL
(
CPU80MHZ
)
},
{
LSTRKEY
(
"CPU80MHZ"
),
LNUMVAL
(
CPU80MHZ
)
},
{
LSTRKEY
(
"CPU160MHZ"
),
LNUMVAL
(
CPU160MHZ
)
},
{
LSTRKEY
(
"CPU160MHZ"
),
LNUMVAL
(
CPU160MHZ
)
},
{
LSTRKEY
(
"setcpufreq"
),
LFUNCVAL
(
node_setcpufreq
)
},
{
LSTRKEY
(
"setcpufreq"
),
LFUNCVAL
(
node_setcpufreq
)
},
{
LSTRKEY
(
"bootreason"
),
LFUNCVAL
(
node_bootreason
)
},
// Combined to dsleep(us, option)
// Combined to dsleep(us, option)
// { LSTRKEY( "dsleepsetoption" ), LFUNCVAL( node_deepsleep_setoption) },
// { LSTRKEY( "dsleepsetoption" ), LFUNCVAL( node_deepsleep_setoption) },
#if LUA_OPTIMIZE_MEMORY > 0
#if LUA_OPTIMIZE_MEMORY > 0
...
...
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