diff options
author | Amaury Pouly <amaury.pouly@gmail.com> | 2013-12-24 15:24:40 +0100 |
---|---|---|
committer | Amaury Pouly <amaury.pouly@gmail.com> | 2013-12-24 15:24:40 +0100 |
commit | 5b865de73afc6e577187e6ccd545749351a02c37 (patch) | |
tree | 5b92b399ecc295ac70f8ce4cda71e9b3b395244d /utils/hwstub | |
parent | 1dc91b4560fb296509cdda81ab32276c7d653ecd (diff) | |
download | rockbox-5b865de73afc6e577187e6ccd545749351a02c37.tar.gz rockbox-5b865de73afc6e577187e6ccd545749351a02c37.zip |
hwstub: add delay function
Change-Id: Iab208ed59a9a2540a64b190357411d3de28f288e
Diffstat (limited to 'utils/hwstub')
-rw-r--r-- | utils/hwstub/tools/hwstub_shell.cpp | 14 | ||||
-rw-r--r-- | utils/hwstub/tools/init.lua | 7 |
2 files changed, 21 insertions, 0 deletions
diff --git a/utils/hwstub/tools/hwstub_shell.cpp b/utils/hwstub/tools/hwstub_shell.cpp index d70fd6dc06..2a3fc177ed 100644 --- a/utils/hwstub/tools/hwstub_shell.cpp +++ b/utils/hwstub/tools/hwstub_shell.cpp | |||
@@ -27,6 +27,7 @@ | |||
27 | #include <readline/readline.h> | 27 | #include <readline/readline.h> |
28 | #include <readline/history.h> | 28 | #include <readline/history.h> |
29 | #include <lua.hpp> | 29 | #include <lua.hpp> |
30 | #include <unistd.h> | ||
30 | #include "soc_desc.hpp" | 31 | #include "soc_desc.hpp" |
31 | 32 | ||
32 | #if LUA_VERSION_NUM < 502 | 33 | #if LUA_VERSION_NUM < 502 |
@@ -244,6 +245,16 @@ int my_lua_quit(lua_State *state) | |||
244 | return 0; | 245 | return 0; |
245 | } | 246 | } |
246 | 247 | ||
248 | int my_lua_udelay(lua_State *state) | ||
249 | { | ||
250 | int n = lua_gettop(state); | ||
251 | if(n != 1) | ||
252 | luaL_error(state, "udelay takes one argument"); | ||
253 | long usec = lua_tointeger(state, -1); | ||
254 | usleep(usec); | ||
255 | return 0; | ||
256 | } | ||
257 | |||
247 | bool my_lua_import_hwstub() | 258 | bool my_lua_import_hwstub() |
248 | { | 259 | { |
249 | int oldtop = lua_gettop(g_lua); | 260 | int oldtop = lua_gettop(g_lua); |
@@ -377,6 +388,9 @@ bool my_lua_import_hwstub() | |||
377 | lua_settable(g_lua, -3); | 388 | lua_settable(g_lua, -3); |
378 | lua_setfield(g_lua, -2, "help"); | 389 | lua_setfield(g_lua, -2, "help"); |
379 | 390 | ||
391 | lua_pushcclosure(g_lua, my_lua_udelay, 0); | ||
392 | lua_setfield(g_lua, -2, "udelay"); | ||
393 | |||
380 | lua_setglobal(g_lua, "hwstub"); | 394 | lua_setglobal(g_lua, "hwstub"); |
381 | 395 | ||
382 | lua_pushcfunction(g_lua, my_lua_help); | 396 | lua_pushcfunction(g_lua, my_lua_help); |
diff --git a/utils/hwstub/tools/init.lua b/utils/hwstub/tools/init.lua index 74f610a2ee..4c62de007f 100644 --- a/utils/hwstub/tools/init.lua +++ b/utils/hwstub/tools/init.lua | |||
@@ -108,4 +108,11 @@ end | |||
108 | -- | 108 | -- |
109 | DEV = hwstub.dev | 109 | DEV = hwstub.dev |
110 | 110 | ||
111 | -- | ||
112 | -- Misc | ||
113 | -- | ||
114 | function hwstub.mdelay(msec) | ||
115 | hwstub.udelay(msec * 1000) | ||
116 | end | ||
117 | |||
111 | require "lua/load" | 118 | require "lua/load" |