Update tmr.c

I don't know C so good, but looks like we can decrease tmr.delay latency
This commit is contained in:
Kirill 2015-04-08 11:24:39 +05:00
parent 263179ea14
commit 0b71b9abaa
1 changed files with 2 additions and 9 deletions

View File

@ -71,15 +71,8 @@ static int tmr_delay( lua_State* L )
us = luaL_checkinteger( L, 1 ); us = luaL_checkinteger( L, 1 );
if ( us <= 0 ) if ( us <= 0 )
return luaL_error( L, "wrong arg range" ); return luaL_error( L, "wrong arg range" );
unsigned sec = (unsigned)us / 1000000;
unsigned remain = (unsigned)us % 1000000; os_delay_us( us );
int i = 0;
for(i=0;i<sec;i++){
os_delay_us( 1000000 );
WRITE_PERI_REG(0x60000914, 0x73);
}
if(remain>0)
os_delay_us( remain );
return 0; return 0;
} }