Combined dsleep_set_options(option) to dsleep( us, option )

* dsleep( us, option )
Hardware has to support deep-sleep wake up (XPD_DCDC connects to EXT_RSTB with 0R). system_deep_sleep(0) ,set no wake up timer,connect a GPIO to pin RST, the chip will wake up by a falling-edge on pin RST.
** us: Integer
time to sleep.
if us = 0, it will sleep forever.
** option: Integer
option=0, init data byte 108 is valuable;
option>0, init data byte 108 is valueless.
More details as follows:
0, RF_CAL or not after deep-sleep wake up, depends on init data byte 108.
1, RF_CAL after deep-sleep wake up, there will belarge current.
2, no RF_CAL after deep-sleep wake up, there will only be small current.
4, disable RF after deep-sleep wake up, just like modem sleep, there will be the smallest current.
This commit is contained in:
HuangRui 2015-01-29 14:21:38 +08:00
parent 00e2adccdb
commit 5894df1da6
1 changed files with 38 additions and 19 deletions

View File

@ -11,7 +11,8 @@
#include "romfs.h"
#include "c_string.h"
#include "driver/uart.h"
#include "spi_flash.h"
//#include "spi_flash.h"
#include "user_interface.h"
#include "flash_api.h"
// Lua: restart()
@ -21,30 +22,47 @@ static int node_restart( lua_State* L )
return 0;
}
// Lua: dsleep( us )
// Lua: dsleep( us, option )
static int node_deepsleep( lua_State* L )
{
s32 us;
us = luaL_checkinteger( L, 1 );
// if ( us <= 0 )
if ( us < 0 )
return luaL_error( L, "wrong arg range" );
system_deep_sleep( us );
return 0;
}
// Lua: dsleep_set_options
static int node_deepsleep_setoption( lua_State* L )
{
s32 option;
option = luaL_checkinteger( L, 1 );
s32 us, option;
//us = luaL_checkinteger( L, 1 );
// Set deleep option, skip if nil
if ( lua_isnumber(L, 2) )
{
option = lua_tointeger(L, 2);
if ( option < 0 || option > 4)
return luaL_error( L, "wrong arg range" );
else
deep_sleep_set_option( option );
}
// Set deleep time, skip if nil
if ( lua_isnumber(L, 1) )
{
us = lua_tointeger(L, 1);
// if ( us <= 0 )
if ( us < 0 )
return luaL_error( L, "wrong arg range" );
else
system_deep_sleep( us );
}
return 0;
}
// Lua: dsleep_set_options
// Combined to dsleep( us, option )
// static int node_deepsleep_setoption( lua_State* L )
// {
// s32 option;
// option = luaL_checkinteger( L, 1 );
// if ( option < 0 || option > 4)
// return luaL_error( L, "wrong arg range" );
// else
// deep_sleep_set_option( option );
// return 0;
// }
// Lua: info()
static int node_info( lua_State* L )
{
lua_pushinteger(L, NODE_VERSION_MAJOR);
@ -307,7 +325,8 @@ const LUA_REG_TYPE node_map[] =
{ LSTRKEY( "input" ), LFUNCVAL( node_input ) },
{ LSTRKEY( "output" ), LFUNCVAL( node_output ) },
{ LSTRKEY( "readvdd33" ), LFUNCVAL( node_readvdd33) },
{ LSTRKEY( "dsleepsetoption" ), LFUNCVAL( node_deepsleep_setoption) },
// Combined to dsleep(us, option)
// { LSTRKEY( "dsleepsetoption" ), LFUNCVAL( node_deepsleep_setoption) },
#if LUA_OPTIMIZE_MEMORY > 0
#endif