Update tmr.c

This commit is contained in:
Kirill 2015-04-10 22:38:59 +05:00
parent c1a0d25ae0
commit c7e56dff56
1 changed files with 8 additions and 9 deletions

View File

@ -87,10 +87,9 @@ static int tmr_delay_ms( lua_State* L )
return luaL_error( L, "wrong arg range" ); return luaL_error( L, "wrong arg range" );
int i = 0; int i = 0;
for(i=0;i<1000;i++) // 1ms == 1000us. Simple stupid and should work. for(i=0;i<ms;i++) //May be later this will need some calibration or refactoring.
//May be later this will need some calibration or refactoring.
{ {
os_delay_us( ms ); os_delay_us( 1000 );
WRITE_PERI_REG(0x60000914, 0x73); //Watchdog clear to aviod system reboot WRITE_PERI_REG(0x60000914, 0x73); //Watchdog clear to aviod system reboot
} }
@ -100,16 +99,16 @@ static int tmr_delay_ms( lua_State* L )
// Lua: delay( s ) // Lua: delay( s )
static int tmr_delay_s( lua_State* L ) static int tmr_delay_s( lua_State* L )
{ {
s32 ms; s32 s;
ms = luaL_checkinteger( L, 1 ); s = luaL_checkinteger( L, 1 );
if ( ms <= 0 ) if ( s <= 0 )
return luaL_error( L, "wrong arg range" ); return luaL_error( L, "wrong arg range" );
int i = 0; int i = 0;
for(i=0;i<1000000;i++) // 1s == 1000000us. Simple stupid and should work. s = s * 1000
//May be later this will need some calibration or refactoring. for(i=0;i<s;i++) // May be later this will need some calibration or refactoring.
{ {
os_delay_us( ms ); os_delay_us( 1000 );
WRITE_PERI_REG(0x60000914, 0x73); //Watchdog clear to aviod system reboot WRITE_PERI_REG(0x60000914, 0x73); //Watchdog clear to aviod system reboot
} }