2014-12-22 12:35:05 +01:00
|
|
|
// Auxiliary Lua modules. All of them are declared here, then each platform
|
|
|
|
// decides what module(s) to register in the src/platform/xxxxx/platform_conf.h file
|
|
|
|
// FIXME: no longer platform_conf.h - either CPU header file, or board file
|
|
|
|
|
|
|
|
#ifndef __AUXMODS_H__
|
|
|
|
#define __AUXMODS_H__
|
|
|
|
|
|
|
|
#include "lua.h"
|
|
|
|
|
2015-06-18 10:31:40 +02:00
|
|
|
#define AUXLIB_GPIO "gpio"
|
2014-12-22 12:35:05 +01:00
|
|
|
LUALIB_API int ( luaopen_gpio )( lua_State *L );
|
|
|
|
|
|
|
|
#define AUXLIB_SPI "spi"
|
|
|
|
LUALIB_API int ( luaopen_spi )( lua_State *L );
|
|
|
|
|
|
|
|
#define AUXLIB_CAN "can"
|
|
|
|
LUALIB_API int ( luaopen_can )( lua_State *L );
|
|
|
|
|
|
|
|
#define AUXLIB_TMR "tmr"
|
|
|
|
LUALIB_API int ( luaopen_tmr )( lua_State *L );
|
|
|
|
|
|
|
|
#define AUXLIB_PD "pd"
|
|
|
|
LUALIB_API int ( luaopen_pd )( lua_State *L );
|
|
|
|
|
|
|
|
#define AUXLIB_UART "uart"
|
|
|
|
LUALIB_API int ( luaopen_uart )( lua_State *L );
|
|
|
|
|
|
|
|
#define AUXLIB_TERM "term"
|
|
|
|
LUALIB_API int ( luaopen_term )( lua_State *L );
|
|
|
|
|
|
|
|
#define AUXLIB_PWM "pwm"
|
|
|
|
LUALIB_API int ( luaopen_pwm )( lua_State *L );
|
|
|
|
|
|
|
|
#define AUXLIB_PACK "pack"
|
|
|
|
LUALIB_API int ( luaopen_pack )( lua_State *L );
|
|
|
|
|
|
|
|
#define AUXLIB_BIT "bit"
|
|
|
|
LUALIB_API int ( luaopen_bit )( lua_State *L );
|
|
|
|
|
|
|
|
#define AUXLIB_NET "net"
|
|
|
|
LUALIB_API int ( luaopen_net )( lua_State *L );
|
|
|
|
|
|
|
|
#define AUXLIB_CPU "cpu"
|
|
|
|
LUALIB_API int ( luaopen_cpu )( lua_State* L );
|
|
|
|
|
|
|
|
#define AUXLIB_ADC "adc"
|
|
|
|
LUALIB_API int ( luaopen_adc )( lua_State *L );
|
|
|
|
|
2015-06-18 10:31:40 +02:00
|
|
|
#define AUXLIB_RPC "rpc"
|
2014-12-22 12:35:05 +01:00
|
|
|
LUALIB_API int ( luaopen_rpc )( lua_State *L );
|
|
|
|
|
|
|
|
#define AUXLIB_BITARRAY "bitarray"
|
|
|
|
LUALIB_API int ( luaopen_bitarray )( lua_State *L );
|
|
|
|
|
2015-06-18 10:31:40 +02:00
|
|
|
#define AUXLIB_ELUA "elua"
|
2014-12-22 12:35:05 +01:00
|
|
|
LUALIB_API int ( luaopen_elua )( lua_State *L );
|
|
|
|
|
2015-06-18 10:31:40 +02:00
|
|
|
#define AUXLIB_I2C "i2c"
|
2014-12-22 12:35:05 +01:00
|
|
|
LUALIB_API int ( luaopen_i2c )( lua_State *L );
|
|
|
|
|
2015-06-18 10:31:40 +02:00
|
|
|
#define AUXLIB_WIFI "wifi"
|
2014-12-22 12:35:05 +01:00
|
|
|
LUALIB_API int ( luaopen_wifi )( lua_State *L );
|
|
|
|
|
2015-06-18 10:31:40 +02:00
|
|
|
#define AUXLIB_COAP "coap"
|
2015-02-04 18:32:57 +01:00
|
|
|
LUALIB_API int ( luaopen_coap )( lua_State *L );
|
|
|
|
|
2015-06-18 10:31:40 +02:00
|
|
|
#define AUXLIB_MQTT "mqtt"
|
2015-01-23 04:48:05 +01:00
|
|
|
LUALIB_API int ( luaopen_mqtt )( lua_State *L );
|
|
|
|
|
2015-01-29 23:47:13 +01:00
|
|
|
#define AUXLIB_U8G "u8g"
|
|
|
|
LUALIB_API int ( luaopen_u8g )( lua_State *L );
|
|
|
|
|
2015-06-18 10:31:40 +02:00
|
|
|
#define AUXLIB_NODE "node"
|
2014-12-22 12:35:05 +01:00
|
|
|
LUALIB_API int ( luaopen_node )( lua_State *L );
|
|
|
|
|
2015-06-18 10:31:40 +02:00
|
|
|
#define AUXLIB_FILE "file"
|
2014-12-22 12:35:05 +01:00
|
|
|
LUALIB_API int ( luaopen_file )( lua_State *L );
|
|
|
|
|
2015-06-18 10:31:40 +02:00
|
|
|
#define AUXLIB_OW "ow"
|
2014-12-22 12:35:05 +01:00
|
|
|
LUALIB_API int ( luaopen_ow )( lua_State *L );
|
|
|
|
|
2015-06-18 10:31:40 +02:00
|
|
|
#define AUXLIB_CJSON "cjson"
|
2015-04-12 17:34:11 +02:00
|
|
|
LUALIB_API int ( luaopen_cjson )( lua_State *L );
|
2015-03-16 02:00:33 +01:00
|
|
|
|
2015-06-18 10:31:40 +02:00
|
|
|
#define AUXLIB_CRYPTO "crypto"
|
|
|
|
LUALIB_API int ( luaopen_crypto )( lua_State *L );
|
|
|
|
|
|
|
|
#define AUXLIB_RC "rc"
|
|
|
|
LUALIB_API int ( luaopen_rc )( lua_State *L );
|
|
|
|
|
|
|
|
#define AUXLIB_DHT "dht"
|
|
|
|
LUALIB_API int ( luaopen_dht )( lua_State *L );
|
|
|
|
|
2014-12-22 12:35:05 +01:00
|
|
|
// Helper macros
|
|
|
|
#define MOD_CHECK_ID( mod, id )\
|
|
|
|
if( !platform_ ## mod ## _exists( id ) )\
|
|
|
|
return luaL_error( L, #mod" %d does not exist", ( unsigned )id )
|
|
|
|
|
|
|
|
#define MOD_CHECK_TIMER( id )\
|
|
|
|
if( id == PLATFORM_TIMER_SYS_ID && !platform_timer_sys_available() )\
|
|
|
|
return luaL_error( L, "the system timer is not available on this platform" );\
|
|
|
|
if( !platform_timer_exists( id ) )\
|
|
|
|
return luaL_error( L, "timer %d does not exist", ( unsigned )id )\
|
|
|
|
|
|
|
|
#define MOD_CHECK_RES_ID( mod, id, resmod, resid )\
|
|
|
|
if( !platform_ ## mod ## _check_ ## resmod ## _id( id, resid ) )\
|
|
|
|
return luaL_error( L, #resmod" %d not valid with " #mod " %d", ( unsigned )resid, ( unsigned )id )
|
|
|
|
|
|
|
|
#define MOD_REG_NUMBER( L, name, val )\
|
|
|
|
lua_pushnumber( L, val );\
|
|
|
|
lua_setfield( L, -2, name )
|
|
|
|
|
2015-03-01 23:11:24 +01:00
|
|
|
#define MOD_REG_LUDATA( L, name, val )\
|
|
|
|
lua_pushlightuserdata( L, val );\
|
|
|
|
lua_setfield( L, -2, name )
|
|
|
|
|
2014-12-22 12:35:05 +01:00
|
|
|
#endif
|
|
|
|
|