diff --git a/doc/build_dist_doc.sh b/doc/build_dist_doc.sh
index 89a859f0..1ef6ecff 100755
--- a/doc/build_dist_doc.sh
+++ b/doc/build_dist_doc.sh
@@ -39,6 +39,7 @@ then
for lang in en pt
do
rm -f $lang/arch_platform_*.html
+ rm -f $lang/refman_gen_*.html
done
rm -f index_*.html wb/wb_usr.lua ssSearch*.html wb_bar_*.html
rm -f wb_search*.txt wb_title*.html wb_tree*.html
diff --git a/doc/builddoc.lua b/doc/builddoc.lua
index e99ae10b..daeb11ae 100644
--- a/doc/builddoc.lua
+++ b/doc/builddoc.lua
@@ -7,7 +7,7 @@ local doc_sections = { "arch_platform", "refman_gen" }
local components =
{
arch_platform = { "ll", "pio", "spi", "uart", "timers", "pwm", "cpu", "eth" },
- refman_gen = { "cpu" }
+ refman_gen = { "bit", "pd", "cpu", "pack" }
}
-- List here all languages for the documentation (make sure to keep English ("en") the first one)
@@ -40,6 +40,8 @@ end
- the string "eLua" becomes eLua
- strings between two tildas (~~) get special code-like formatting
- newlines are changed to ' ' if 'keepnl' isn't true
+- '&' is translated to its corresponding HTML code.
+- '<<' and '>>" are also translated to the corresponding HTML codes (note the repetition).
--]]
local function format_string( str, keepnl )
-- replace double "special chars" with "temps" for later use
@@ -49,23 +51,36 @@ local function format_string( str, keepnl )
str = str:gsub( "%^%^", "\004" )
str = str:gsub( "~~", "\005" )
+ -- Translate 'special' HTML chars to their equivalents
+ local tr_table =
+ {
+ [ "%&" ] = "&",
+ }
+ for char, rep in pairs( tr_table ) do
+ str = str:gsub( char, rep )
+ end
+
+ -- some double chars are replaced directly with their HTML codes
+ str = str:gsub( "<<", "<" )
+ str = str:gsub( ">>", ">" )
+
-- replace eLua with eLua
str = str:gsub( "eLua", "eLua" )
-- $string$ becomes string>
- str = str:gsub( "%$([^%s][^%$]+)%$", "%1" )
+ str = str:gsub( "%$([^%s%$][^%$]*)%$", "%1" )
-- %string% becomes string
- str = str:gsub( "%%([^%s][^%%]+)%%", "%1" )
+ str = str:gsub( "%%([^%s%%][^%%]*)%%", "%1" )
-- @ref@text@ becomes text
- str = str:gsub( "@([^%s][^@]+)@([^%s][^@]+)@", '%2' )
+ str = str:gsub( "@([^%s@][^@]*)@([^%s@][^@]*)@", '%2' )
-- ^ref^text^ becomes text
- str = str:gsub( "%^([^%s][^%^]+)%^([^%s][^%^]+)%^", '%2' )
+ str = str:gsub( "%^([^%s%^][^%^]*)%^([^%s%^][^%^]*)%^", '%2' )
-- strings between two tildas (~~) get special code-like formatting
- str = str:gsub( "~([^%s][^~]+)~", function( x )
+ str = str:gsub( "~([^%s~][^~]*)~", function( x )
x = x:gsub( "\n", "
" )
x = x:gsub( "%s%s+", function( x ) return ( " " ):rep( #x ) end )
return "
" .. x .. "
This part of the reference manual presents the generic modules in eLua (see here for more information about generic +modules).
+ diff --git a/doc/en/tut_bootstick.html b/doc/en/tut_bootstick.html index a2bb14e0..0bf6db4a 100644 --- a/doc/en/tut_bootstick.html +++ b/doc/en/tut_bootstick.html @@ -36,7 +36,7 @@ Your call.To have your own bootable eLua USB stick you'll need: +
To have your own bootable eLua USB stick you'll need:
To put everything together, part of the Ethernet platform interface for the $m3s$ platform is given below:
+To put everything together, part of the Ethernet platform interface for the $lm3s$ platform is given below:
~u32 platform_eth_get_elapsed_time() { if( eth_timer_fired ) diff --git a/doc/luadoc/refman_gen_bit.lua b/doc/luadoc/refman_gen_bit.lua new file mode 100644 index 00000000..598e5d38 --- /dev/null +++ b/doc/luadoc/refman_gen_bit.lua @@ -0,0 +1,145 @@ +-- eLua reference manual - bit module + +data_en = +{ + + -- Title + title = "eLua reference manual - bit module", + + -- Menu name + menu_name = "bit", + + -- Overview + overview = [[Since Lua doesn't have built-in capabilities for bit operations, the $bit$ module was added to eLua to fill this gap. It is based on the ^http://luaforge.net/projects/bitlib^bitlib^ + library written by Reuben Thomas (slightly adapted to eLua) and provides basic bit operations (like setting and clearing bits) and bitwise operations.]], + + -- Functions + funcs = + { + { sig = "number = #bit.bit#( position )", + desc = "Generate a number with a 1 bit (used for mask generation). Equivalent to %1 <<<< position% in C.", + args = + { + { name = "position", desc = "position of the bit that will be set to 1." }, + }, + ret = "$number$ - a number with only one 1 bit at $position$ (the rest are set to 0." + }, + + { sig = "flag = #bit.isset#( value, position )", + desc = "Test if a given bit is set.", + args = + { + { name = "value", desc = "the value to test." }, + { name = "position", desc = "bit position to test." } + }, + ret = "$flag$ - 1 if the bit at the given position is 1, 0 otherwise." + }, + + { sig = "flag = #bit.isclear#( value, position )", + desc = "Test if a given bit is cleared.", + args = + { + { name = "value", desc = "the value to test." }, + { name = "position", desc = "bit position to test." } + }, + ret = "$flag$ - 1 if the bit at the given position is 0, 0 othewise." + }, + + { sig = "number = #bit.set#( value, pos1, pos2, ..., posn )", + desc = "Set bits in a number.", + args = + { + { name = "value", desc = "the base number." }, + { name = "pos1", desc = "position of the first bit to set." }, + { name = "pos2", desc = "position of the second bit to set." }, + { name = "posn", desc = "position of the nth bit to set." } + }, + ret = "$number$ - the number with the bit(s) set in the given position(s)." + }, + + { sig = "number = #bit.clear#( value, pos1, pos2, ..., posn )", + desc = "Clear bits in a number.", + args = + { + { name = "value", desc = "the base number." }, + { name = "pos1", desc = "position of the first bit to clear." }, + { name = "pos2", desc = "position of the second bit to clear." }, + { name = "posn", desc = "position of thet nth bit to clear." }, + }, + ret = "$number$ - the number with the bit(s) cleared in the given position(s)." + }, + + { sig = "number = #bit.bnot#( value )", + desc = "Bitwise negation, equivalent to %~~value% in C.", + args = + { + { name = "value", desc = "the number to negate." }, + }, + ret = "$number$ - the bitwise negated value of the number.", + }, + + { sig = "number = #bit.band#( val1, val2, ... valn )", + desc = "Bitwise AND, equivalent to %val1 & val2 & ... & valn% in C.", + args = + { + { name = "val1", desc = "first AND argument." }, + { name = "val2", desc = "second AND argument." }, + { name = "valn", desc = "nth AND argument." }, + }, + ret = "$number$ - the bitwise AND of all the arguments." + }, + + { sig = "number = #bit.bor#( val1, val2, ... valn )", + desc = "Bitwise OR, equivalent to %val1 | val2 | ... | valn% in C.", + args = + { + { name = "val1", desc = "first OR argument." }, + { name = "val2", desc = "second OR argument." }, + { name = "valn", desc = "nth OR argument." } + }, + ret = "$number$ - the bitwise OR of all the arguments." + }, + + { sig = "number = #bit.bxor#( val1, val2, ... valn )", + desc = "Bitwise exclusive OR (XOR), equivalent to %val1 ^^ val2 ^^ ... ^^ valn% in C.", + args = + { + { name = "val1", desc = "first XOR argument." }, + { name = "val2", desc = "second XOR argument." }, + { name = "valn", desc = "nth XOR argument." } + }, + ret = "$number$ - the bitwise exclusive OR of all the arguments." + }, + + { sig = "number = #bit.lshift#( value, shift )", + desc = "Left-shift a number, equivalent to %value << shift% in C.", + args = + { + { name = "value", desc = "the value to shift." }, + { name = "shift", desc = "positions to shift." }, + }, + ret = "$number$ - the number shifted left", + }, + + { sig = "number = #bit.rshift#( value, shift )", + desc = "Logical right shift a number, equivalent to %( unsigned )value >>>> shift% in C.", + args = + { + { name = "value", desc = "the value to shift." }, + { name = "shift", desc = "positions to shift." }, + }, + ret = "$number$ - the number shifted right (logically)." + }, + + { sig = "number = #bit.arshift#( value, shift )", + desc = "Arithmetic right shift a number equivalent to %value >>>> shift% in C.", + args = + { + { name = "value", desc = "the value to shift." }, + { name = "shift", desc = "positions to shift." } + }, + ret = "$number$ - the number shifted right (arithmetically)." + } + } +} + diff --git a/doc/luadoc/refman_gen_cpu.lua b/doc/luadoc/refman_gen_cpu.lua new file mode 100644 index 00000000..e41adb2f --- /dev/null +++ b/doc/luadoc/refman_gen_cpu.lua @@ -0,0 +1,109 @@ +-- eLua reference manual - CPU module + +data_en = +{ + + -- Title + title = "eLua reference manual - CPU module", + + -- Menu name + menu_name = "cpu", + + -- Overview + overview = [[This module deals with low-level access to CPU (and related modules) functionality, such as reading and writing memory, or + enabling and disabling interrupts. It also offers access to platform specific CPU-related constants using a special macro defined in the + platform's $platform_conf.h$ file, as exaplained @#cpu_constants@here@.]], + + -- Data structures, constants and types + structures = + { + { text = [[cpu.INT_GPIOA +cpu.INT_GPIOB +............. +cpu.INT_UDMA]], + name = "CPU constants", + desc = [[eLua has a mechanism that lets the user export an unlimited number of constants to the $cpu$ module. Although in theory any kind of constant can be exposed by this module, +one should only use constants related to the CPU and its subsystems (as shown above, where a number of CPU specific interrupt masks are exposed to Lua using this mechanism). To use this +mechanism, just declare the $PLATFORM_CPU_CONSTANTS$ macro in your platform's $platform_conf.h$ file and list all your constants as part of this macro, each enclosed in a special macro called +$_C$. For example, to get the constants listed above declare your $PLATFORM_CPU_CONSTANTS$ macro like this: +~#define PLATFORM_CPU_CONSTANTS\ + _C( INT_GPIOA ),\ + _C( INT_GPIOB ),\ + ................. + _C( INT_UDMA )~+
It's worth to note that adding more constants does not increas RAM usage, only Flash usage, so you can expose as much constants as you need without worrying about RAM consumption.]] + }, + }, + + -- Functions + funcs = + { + { sig = "#cpu.w32#( address, data )", + desc = "Writes a 32-bit word to memory.", + args = + { + { name = "address", desc = "the memory address." }, + { name = "data", desc = "the 32-bit data to write." } + }, + }, + + { sig = "data = #cpu.r32#( address )", + desc = "Read a 32-bit word from memory.", + args = + { + { name = "address", desc = "the memory address." } + }, + ret = "$data$ - the 32-bit word read from memory." + }, + + { sig = "#cpu.w16#( address, data )", + desc = "Writes a 16-bit word to memory.", + args = + { + { name = "address", desc = "the memory address." }, + { name = "data", desc = "the 16-bit data to write." } + }, + }, + + { sig = "data = #cpu.r16#( address )", + desc = "Reads a 16-bit word from memory.", + args = + { + { name = "address", desc = "the memory address." } + }, + ret = "$data$ - the 16-bit word read from memory." + }, + + { sig = "#cpu.w8#( address, data )", + desc = "Writes a byte to memory.", + args = + { + { name = "address", desc = "the memory address." }, + { name = "data", desc = "the byte to write." } + } + }, + + { sig = "data = #cpu.r8#( address )", + desc = "Reads a byte from memory.", + args = + { + { name = "address", desc = "the memory address" } + }, + ret = "$data$ - the byte read from memory." + }, + + { sig = "#cpu.cli#()", + desc = "Disable CPU interrupts." + }, + + { sig = "#cpu.sei#()", + desc = "Enable CPU interrupts." + }, + + { sig = "clock = #cpu.clock#()", + desc = "Get the CPU core frequency.", + ret = "$clock$ - the CPU clock (in Hertz)." + } + }, +} + diff --git a/doc/luadoc/refman_gen_pack.lua b/doc/luadoc/refman_gen_pack.lua new file mode 100644 index 00000000..57cfc116 --- /dev/null +++ b/doc/luadoc/refman_gen_pack.lua @@ -0,0 +1,135 @@ +-- eLua reference manual - pack + +data_en = +{ + + -- Title + title = "eLua reference manual - pack", + + -- Menu name + menu_name = "pack", + + -- Overview + overview = [[This module allows for arbitrary packing of data into Lua strings and unpacking data from Lua strings. In this way, a string can be used to store data in a platform-indepdendent +manner. It is based on the ^http://www.tecgraf.puc-rio.br/~~lhf/ftp/lua/#lpack^lpack^ module from Luiz Henrique de Figueiredo (with some minor tweaks).
+Both methods of this module (@#pack@pack@ and @#unpack@unpack@) use a $format string$ to describe how to pack/unpack the data. The format string contains one or more $data specifiers$, each +data specifier is applied to a single variable that must be packed/unpacked. The data specifier has the following general format:
+~[endianness]<where: +
Format specifier | +Corresponding variable type | +
---|---|
'z' | +zero-terminated string | +
'p' | +string preceded by length byte | +
'P' | +string preceded by length word | +
'a' | +string preceded by length size_t | +
'A' | +string | +
'f' | +float | +
'd' | +double | +
'n' | +Lua number | +
'c' | +char | +
'b' | +byte = unsigned char | +
'h' | +short | +
'H' | +unsigned short | +
'i' | +int | +
'I' | +unsigned int | +
'l' | +long | +
'L' | +unsigned long | +