mirror of
https://github.com/elua/elua.git
synced 2025-01-08 20:56:17 +08:00
Add initial refman entry for can module.
This commit is contained in:
parent
2812e9eef3
commit
d04fb2b2bb
@ -15,7 +15,7 @@ local doc_sections = { "arch_platform", "refman_gen", "refman_ps_lm3s" }
|
||||
local components =
|
||||
{
|
||||
arch_platform = { "ll", "pio", "spi", "uart", "timers", "pwm", "cpu", "eth", "adc" },
|
||||
refman_gen = { "bit", "pd", "cpu", "pack", "adc", "term", "pio", "uart", "spi", "tmr", "pwm", "net" },
|
||||
refman_gen = { "bit", "pd", "cpu", "pack", "adc", "term", "pio", "uart", "spi", "tmr", "pwm", "net", "can" },
|
||||
refman_ps_lm3s = { "disp" }
|
||||
}
|
||||
|
||||
|
136
doc/eluadoc/refman_gen_can.lua
Normal file
136
doc/eluadoc/refman_gen_can.lua
Normal file
@ -0,0 +1,136 @@
|
||||
-- eLua reference manual - CAN module
|
||||
|
||||
data_en =
|
||||
{
|
||||
|
||||
-- Title
|
||||
title = "eLua reference manual - CAN module",
|
||||
|
||||
-- Menu name
|
||||
menu_name = "can",
|
||||
|
||||
-- Overview
|
||||
overview = [[This module contains functions for accessing the CAN interfaces of the eLua CPU]],
|
||||
|
||||
-- Structures
|
||||
structures =
|
||||
{
|
||||
{ text = [[// eLua CAN ID types
|
||||
enum
|
||||
{
|
||||
ELUA_CAN_ID_STD = 0, // exported as $net.ID_STD$
|
||||
ELUA_CAN_ID_EXT, // exported as $can.ID_EXT$
|
||||
};]],
|
||||
name = "CAN ID types",
|
||||
desc = "These are the CAN identifier types supported by eLua. Standard identifiers are 11 bits in length, extended identifiers are 29 bits.",
|
||||
}
|
||||
},
|
||||
|
||||
-- Functions
|
||||
funcs =
|
||||
{
|
||||
{ sig = "clock = #can.setup#( id, clock )",
|
||||
desc = "Setup the CAN interface",
|
||||
args =
|
||||
{
|
||||
"$id$ - the ID of the CAN interface.",
|
||||
"$clock$ - the clock of the CAN interface.",
|
||||
},
|
||||
ret = "The actual clock set on the CAN interface. Depending on the hardware, this might have a different value than the $clock$ parameter."
|
||||
},
|
||||
|
||||
{ sig = "#can.send#( id, canid, canidtype, message )",
|
||||
desc = "Send message over the CAN bus.",
|
||||
args =
|
||||
{
|
||||
"$id$ - the ID of the CAN interface.",
|
||||
"$canid$ - CAN identifier number.",
|
||||
"$canidtype$ - identifier type as defined @#can_id_types@here@.",
|
||||
"$message$ - message in string format, 8 or fewer bytes."
|
||||
},
|
||||
},
|
||||
|
||||
{ sig = "canid, canidtype, message = #can.recv#( id )",
|
||||
desc = "Receive CAN bus message.",
|
||||
args =
|
||||
{
|
||||
"$id$ - the ID of the CAN interface.",
|
||||
},
|
||||
ret =
|
||||
{
|
||||
"$canid$ - CAN identifier number.",
|
||||
"$canidtype$ - identifier type as defined @#can_id_types@here@.",
|
||||
"$message$ - message in string format, 8 or fewer bytes."
|
||||
}
|
||||
}
|
||||
|
||||
},
|
||||
}
|
||||
|
||||
data_pt =
|
||||
{
|
||||
|
||||
-- Title
|
||||
title = "eLua reference manual - CAN module",
|
||||
|
||||
-- Menu name
|
||||
menu_name = "can",
|
||||
|
||||
-- Overview
|
||||
overview = [[This module contains functions for accessing the CAN interfaces of the eLua CPU]],
|
||||
|
||||
-- Structures
|
||||
structures =
|
||||
{
|
||||
{ text = [[// eLua CAN ID types
|
||||
enum
|
||||
{
|
||||
ELUA_CAN_ID_STD = 0, // exported as $net.ID_STD$
|
||||
ELUA_CAN_ID_EXT, // exported as $can.ID_EXT$
|
||||
};]],
|
||||
name = "CAN ID types",
|
||||
desc = "These are the CAN identifier types supported by eLua. Standard identifiers are 11 bits in length, extended identifiers are 29 bits.",
|
||||
}
|
||||
},
|
||||
|
||||
-- Functions
|
||||
funcs =
|
||||
{
|
||||
{ sig = "clock = #can.setup#( id, clock )",
|
||||
desc = "Setup the CAN interface",
|
||||
args =
|
||||
{
|
||||
"$id$ - the ID of the CAN interface.",
|
||||
"$clock$ - the clock of the CAN interface.",
|
||||
},
|
||||
ret = "The actual clock set on the CAN interface. Depending on the hardware, this might have a different value than the $clock$ parameter."
|
||||
},
|
||||
|
||||
{ sig = "#can.send#( id, canid, canidtype, message )",
|
||||
desc = "Send message over the CAN bus.",
|
||||
args =
|
||||
{
|
||||
"$id$ - the ID of the CAN interface.",
|
||||
"$canid$ - CAN identifier number.",
|
||||
"$canidtype$ - identifier type as defined @#can_id_types@here@.",
|
||||
"$message$ - message in string format, 8 or fewer bytes."
|
||||
},
|
||||
},
|
||||
|
||||
{ sig = "canid, canidtype, message = #can.recv#( id )",
|
||||
desc = "Receive CAN bus message.",
|
||||
args =
|
||||
{
|
||||
"$id$ - the ID of the CAN interface.",
|
||||
},
|
||||
ret =
|
||||
{
|
||||
"$canid$ - CAN identifier number.",
|
||||
"$canidtype$ - identifier type as defined @#can_id_types@here@.",
|
||||
"$message$ - message in string format, 8 or fewer bytes."
|
||||
}
|
||||
}
|
||||
|
||||
},
|
||||
}
|
||||
|
@ -72,6 +72,13 @@ pio_type platform_pio_op( unsigned port, pio_type pinmask, int op );
|
||||
// Maximum length for any CAN message
|
||||
#define PLATFORM_CAN_MAXLEN 8
|
||||
|
||||
// eLua CAN ID types
|
||||
enum
|
||||
{
|
||||
ELUA_CAN_ID_STD = 0,
|
||||
ELUA_CAN_ID_EXT
|
||||
};
|
||||
|
||||
int platform_can_exists( unsigned id );
|
||||
u32 platform_can_setup( unsigned id, u32 clock );
|
||||
void platform_can_send( unsigned id, u32 canid, u8 idtype, u8 len, const u8 *data );
|
||||
|
@ -69,6 +69,10 @@ const LUA_REG_TYPE can_map[] =
|
||||
{ LSTRKEY( "setup" ), LFUNCVAL( can_setup ) },
|
||||
{ LSTRKEY( "send" ), LFUNCVAL( can_send ) },
|
||||
{ LSTRKEY( "recv" ), LFUNCVAL( can_recv ) },
|
||||
#if LUA_OPTIMIZE_MEMORY > 0
|
||||
{ LSTRKEY( "ID_STD" ), LNUMVAL( ELUA_CAN_ID_STD ) },
|
||||
{ LSTRKEY( "ID_EXT" ), LNUMVAL( ELUA_CAN_ID_EXT ) },
|
||||
#endif
|
||||
{ LNILKEY, LNILVAL }
|
||||
};
|
||||
|
||||
@ -79,6 +83,10 @@ LUALIB_API int luaopen_can( lua_State *L )
|
||||
#else // #if LUA_OPTIMIZE_MEMORY > 0
|
||||
luaL_register( L, AUXLIB_CAN, can_map );
|
||||
|
||||
// Module constants
|
||||
MOD_REG_NUMBER( L, "ID_STD", ELUA_CAN_ID_STD );
|
||||
MOD_REG_NUMBER( L, "ID_EXT", ELUA_CAN_ID_EXT );
|
||||
|
||||
return 1;
|
||||
#endif // #if LUA_OPTIMIZE_MEMORY > 0
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user