-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathwatchdog.cpp
More file actions
62 lines (51 loc) · 1.46 KB
/
watchdog.cpp
File metadata and controls
62 lines (51 loc) · 1.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
/**************************************************************************
* Copyright (C), AirM2M Tech. Co., Ltd.
*
* Name: watchdog.cpp
* Author: panjun
* Version: V0.1
* Date: 2016/09/13
*
* Description:
* Watchdog.
* History:
* panjun 16/09/13 Initially create file.
**************************************************************************/
#include "stdafx.h"
#include "lua.hpp"
#include "platform.h"
#include "platform_conf.h"
#include "platform_watchdog.h"
// watchdog.open(mode[,io])
static int l_watchdog_open(lua_State *L) {
watchdog_info_t info;
info.mode = luaL_checkinteger(L, 1);
info.param.pin_ctl = luaL_checkinteger(L, 2);
lua_pushinteger(L, platform_watchdog_open(&info));
return 1;
}
// watchdog.close()
static int l_watchdog_close(lua_State *L) {
lua_pushinteger(L, platform_watchdog_close());
return 1;
}
// watchdog.kick()
static int l_watchdog_kick(lua_State *L) {
lua_pushinteger(L, platform_watchdog_kick());
return 1;
}
#define MIN_OPT_LEVEL 2
// Module function map
const luaL_reg watchdog_map[] =
{
{"open", l_watchdog_open},
{"close", l_watchdog_close},
{"kick", l_watchdog_kick},
{ NULL, NULL }
};
LUALIB_API int luaopen_watchdog( lua_State *L )
{
luaL_register( L, AUXLIB_WATCHDOG, watchdog_map );
MOD_REG_NUMBER(L, "DEFAULT", WATCHDOG_DEFAULT_MODE);
return 1;
}