mirror of
https://github.com/Fishwaldo/bl_mcu_sdk.git
synced 2025-07-22 20:59:03 +00:00
[refactor][components] Restructure the catalogue, sync from internal repo
This commit is contained in:
parent
681e8c744a
commit
89592fc9a3
3357 changed files with 616226 additions and 159127 deletions
75
components/runtime/lua/lhal/llib_mtimer.c
Normal file
75
components/runtime/lua/lhal/llib_mtimer.c
Normal file
|
@ -0,0 +1,75 @@
|
|||
/*
|
||||
** $Id: llib_mtimer.c $
|
||||
** mtimer
|
||||
*/
|
||||
|
||||
#define llib_dev_c
|
||||
#define LUA_LIB
|
||||
|
||||
#ifdef DBG_TAG
|
||||
#undef DBG_TAG
|
||||
#endif
|
||||
#define DBG_TAG "LMTIMER"
|
||||
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
#include "lprefix.h"
|
||||
|
||||
#include "lua.h"
|
||||
|
||||
#include "lauxlib.h"
|
||||
#include "lualib.h"
|
||||
|
||||
#include "bflb_mtimer.h"
|
||||
|
||||
static int mtimer_config(lua_State *L)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int mtimer_delay_ms(lua_State *L)
|
||||
{
|
||||
uint32_t time = luaL_checkinteger(L, 1);
|
||||
bflb_mtimer_delay_ms(time);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int mtimer_get_time_ms(lua_State *L)
|
||||
{
|
||||
uint32_t time = bflb_mtimer_get_time_ms();
|
||||
lua_pushinteger(L, time);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int mtimer_delay_us(lua_State *L)
|
||||
{
|
||||
uint32_t time = luaL_checkinteger(L, 1);
|
||||
bflb_mtimer_delay_us(time);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int mtimer_get_time_us(lua_State *L)
|
||||
{
|
||||
uint32_t time = bflb_mtimer_get_time_us();
|
||||
lua_pushinteger(L, time);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static const luaL_Reg l_mtimer_lib[] = {
|
||||
{ "config", NULL },
|
||||
{ "delay_ms", mtimer_delay_ms },
|
||||
{ "delay_us", mtimer_delay_us },
|
||||
{ "get_time_ms", mtimer_get_time_ms },
|
||||
{ "get_time_us", mtimer_get_time_us },
|
||||
/* config placeholders */
|
||||
{ NULL, NULL }
|
||||
};
|
||||
|
||||
/* }====================================================== */
|
||||
|
||||
LUAMOD_API int luaopen_llib_mtimer(lua_State *L)
|
||||
{
|
||||
/*!< TODO Assert */
|
||||
luaL_newlib(L, l_mtimer_lib);
|
||||
return 1;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue