1
0
mirror of https://github.com/elua/elua.git synced 2025-01-08 20:56:17 +08:00
elua/doc/en/refman.html

751 lines
34 KiB
HTML
Raw Normal View History

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Strict//EN">
<html><head>
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
<meta http-equiv="Content-Language" content="en-us"><title>Product</title>
<link rel="stylesheet" type="text/css" href="../style.css"></head>
<body style="background-color: rgb(255, 255, 255);">
<h3>eLua Modules Reference Manual
</h3>
<h3><a name="genericmodules"></a>Generic
Modules</h3><br><h3><a name="bitmodule"></a>bit</h3>
Bitwise&nbsp;operations in eLua is implemented thru
the&nbsp;BitLib library, from Reuben Thomas.<br>
BitLib project is hosted at LuaForge on
http://luaforge.net/projects/bitlib<br>
<p class="MsoNormal" style="font-family: Verdana;"><a name="bit_bnot"></a>Res = bit.bnot( value )</p>
<p class="MsoNormal" style="font-family: Verdana;">
unary negation
</p>
<p class="MsoNormal" style="font-family: Verdana;">
&nbsp;
</p>
<p class="MsoNormal" style="font-family: Verdana;"><a name="bit_band"></a> Res = bit.band( v1, v2, ... )</p>
<p class="MsoNormal" style="font-family: Verdana;"><b>bitwise
</b>"and"
</p>
<p class="MsoNormal" style="font-family: Verdana;">
&nbsp;
</p>
<p class="MsoNormal" style="font-family: Verdana;"><a name="bit_bor"></a> Res = bit.bor( v1, v2, ... )</p>
<p class="MsoNormal" style="font-family: Verdana;"><span style="font-weight: bold;">&nbsp;</span><b class="info" style="font-weight: bold;">bitwise</b><b class="info" style="font-weight: bold;">
</b><span class="info" style="font-weight: bold;">"or"</span>
</p>
<p class="MsoNormal" style="font-family: Verdana;">
&nbsp;
</p>
<p class="MsoNormal" style="font-family: Verdana;"><a name="bit_bxor"></a> Res = bit.bxor( v1, v2, ... )</p>
<p class="MsoNormal" style="font-family: Verdana;">
<b>bitwise</b><b> </b>"exclusive or"
</p>
<p class="MsoNormal" style="font-family: Verdana;">
&nbsp;
</p>
<p class="MsoNormal" style="font-family: Verdana;"><a name="bit_lshift"></a> Res = bit.lshift( value, pos )</p>
<p class="MsoNormal" style="font-family: Verdana;">
shift "value" left "pos" positions.
</p>
<p class="MsoNormal" style="font-family: Verdana;">
&nbsp;
</p>
<p class="MsoNormal" style="font-family: Verdana;"><a name="bit_rshift"></a> Res = bit.rshift( value, pos )</p>
<p class="MsoNormal" style="font-family: Verdana;">
shift "value" right "pos" positions. The sign is not propagated.
</p>
<p class="MsoNormal" style="font-family: Verdana;">
&nbsp;
</p>
<p class="MsoNormal" style="font-family: Verdana;"><a name="bit_arshift"></a> Res = bit.arshift( value, pos )</p>
<p class="MsoNormal" style="font-family: Verdana;">
shift "value" right "pos" positions. The sign is propagated
("arithmetic shift").
</p>
<p class="MsoNormal" style="font-family: Verdana;">
&nbsp;
</p>
<p class="MsoNormal" style="font-family: Verdana;"><a name="bit_bit"></a> Res = bit.bit( bitno )</p>
<p class="MsoNormal" style="font-family: Verdana;">
a shortcut for bit.lshift( 1, bitno )
</p>
<p class="MsoNormal" style="font-family: Verdana;">
&nbsp;
</p>
<p class="MsoNormal" style="font-family: Verdana;"><a name="bit_set"></a> Res1, Res2, ... = bit.set( bitno, v1,
v2, ... )</p>
<p class="MsoNormal" style="font-family: Verdana;">
set the bit at position "bitno" in v1, v2, ... to 1.
</p>
<p class="MsoNormal" style="font-family: Verdana;">
&nbsp;
</p>
<p class="MsoNormal" style="font-family: Verdana;"><a name="bit_clear"></a> Res1, Res2, ... = bit.clear( bitno,
v1, v2, ... )</p>
<p class="MsoNormal" style="font-family: Verdana;">
set the bit at position "bitno"in v1, v2, ... to 0.
</p>
<p class="MsoNormal" style="font-family: Verdana;">
&nbsp;
</p>
<p class="MsoNormal" style="font-family: Verdana;"><a name="bit_isset"></a> Res = bit.isset( value, bitno )</p>
<p class="MsoNormal" style="font-family: Verdana;">
returns true if bit at position "bitno" in "value" is 1, false
otherwise.
</p>
<p class="MsoNormal" style="font-family: Verdana;">
&nbsp;
</p>
<p class="MsoNormal" style="font-family: Verdana;"><a name="bit_isclear"></a> Res = bit.isclear( value, bitno )</p>
<p class="MsoNormal" style="font-family: Verdana;">
returns true if bit at position "bitno" in "value" is 0, false
otherwise.
</p>
<br style="font-family: Verdana;">
<br style="font-family: Verdana;">
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<h3><a name="cpumodule"></a>cpu</h3>
<p class="MsoNormal" style="font-family: Verdana;"><br>
</p>
<p style="margin-bottom: 0in;"> </p>
<font face="Bitstream Vera Sans Mono, sans-serif"><a name="cpu_write32"></a>write32( address, data ) : write
the 32-bit data at the specified address</font>
<p style="margin-bottom: 0in;"></p>
<p style="margin-bottom: 0in;">
</p>
<p style="margin-bottom: 0in;"> <font face="Bitstream Vera Sans Mono, sans-serif"><a name="cpu_write16"></a>write16( address, data ) : write
the 16-bit data at the specified address</font>
</p>
<p style="margin-bottom: 0in;">
</p>
<p style="margin-bottom: 0in;"> <font face="Bitstream Vera Sans Mono, sans-serif"><a name="cpu_write8"></a>write8( address, data ) : write the
8-bit data at the specified address</font> <br>
</p>
<p style="margin-bottom: 0in;"><br>
</p>
<br>
<font face="Bitstream Vera Sans Mono, sans-serif"><a name="cpu_read32"></a>Data =&nbsp;read32( address ) :
reads 32-bit data from the specified address</font>
<p style="margin-bottom: 0in;"></p>
<p style="margin-bottom: 0in;">
</p>
<p style="margin-bottom: 0in;"> <font face="Bitstream Vera Sans Mono, sans-serif"><a name="cpu_read16"></a>Data = read16( address ) : reads
16-bit data from the specified address</font>
</p>
<p style="margin-bottom: 0in;">
</p>
<p style="margin-bottom: 0in;"> <font face="Bitstream Vera Sans Mono, sans-serif"><a name="cpu_read8"></a>Data = read8( address ) : reads 8-bit
data from the specified address</font></p>
<p style="margin-bottom: 0in;"><br>
</p>
<br>
<p style="margin-bottom: 0in;"><a name="cpu_disableinterrupts"></a>
[cpu.disableinterrupts()]&nbsp;&nbsp; <font face="Bitstream Vera Sans Mono, sans-serif">cli(): disable
CPU interrupts</font>
</p>
<p style="margin-bottom: 0in;"> <br>
</p>
<p style="margin-bottom: 0in;"> <br>
</p>
<p style="margin-bottom: 0in;"><a name="cpu_enableinterrupts"></a>
[cpu.enableinterrupts()]&nbsp;&nbsp; <font face="Bitstream Vera Sans Mono, sans-serif">sei(): enable
CPU interrupts</font>
</p>
<p style="margin-bottom: 0in;"> <br>
</p>
<p style="margin-bottom: 0in;">
</p>
<p style="margin-bottom: 0in;"> <font face="Bitstream Vera Sans Mono, sans-serif"><br>
</font></p>
<p style="margin-bottom: 0in;"> <font face="Bitstream Vera Sans Mono, sans-serif"><a name="cpu_clockfrequency"></a>[cpu.clockfrequency()]&nbsp;&nbsp;&nbsp;&nbsp;
Clock = clock(): returns the CPU frequency</font>
</p>
<p style="margin-bottom: 0in;"> <br>
</p>
<p style="margin-bottom: 0in;"> <font face="Bitstream Vera Sans Mono, sans-serif">Also, you can
expose as many CPU constants (for example memory mapped registers)</font>
</p>
<p style="margin-bottom: 0in;"> <font face="Bitstream Vera Sans Mono, sans-serif">as you want to
this module. You might want to use this feature to access some </font>
</p>
<p style="margin-bottom: 0in;"> <font face="Bitstream Vera Sans Mono, sans-serif">CPU memory areas
(as defined in the CPU header files from the CPU support </font>
</p>
<p style="margin-bottom: 0in;"> <font face="Bitstream Vera Sans Mono, sans-serif">package)
directly from Lua. To do this, you'll need to define the </font>
</p>
<p style="margin-bottom: 0in;"> <font face="Bitstream Vera Sans Mono, sans-serif">PLATFORM_CPU_CONSTANTS
macro in the platform's platform_conf.h file </font>
</p>
<p style="margin-bottom: 0in;"> <font face="Bitstream Vera Sans Mono, sans-serif">(src/platform/&lt;platform
name&gt;/platform_conf.h). Include all your constants in a </font>
</p>
<p style="margin-bottom: 0in;"> <font face="Bitstream Vera Sans Mono, sans-serif">_C(
&lt;constant name&gt; ) definition, and then build your project.</font>
</p>
<p style="margin-bottom: 0in;"> <font face="Bitstream Vera Sans Mono, sans-serif">For example,
let's suppose that your CPU's interrupt controler has 3 memory</font>
</p>
<p style="margin-bottom: 0in;"> <font face="Bitstream Vera Sans Mono, sans-serif">mapped
registers: INT_REG_ENABLE, INT_REG_DISABLE and INT_REG_MASK. If you want</font>
</p>
<p style="margin-bottom: 0in;"> <font face="Bitstream Vera Sans Mono, sans-serif">to access them
from Lua, locate the header that defines the values of these</font>
</p>
<p style="margin-bottom: 0in;"> <font face="Bitstream Vera Sans Mono, sans-serif">registers (I'll
assume its name is "cpu.h") and add these lines to the</font>
</p>
<p style="margin-bottom: 0in;"> <font face="Bitstream Vera Sans Mono, sans-serif">platform_conf.h:</font>
</p>
<p style="margin-bottom: 0in;"> <br>
</p>
<p style="margin-bottom: 0in;"> <font face="Bitstream Vera Sans Mono, sans-serif">#include "cpu.h"</font>
</p>
<p style="margin-bottom: 0in;"> <br>
</p>
<p style="margin-bottom: 0in;"> <font face="Bitstream Vera Sans Mono, sans-serif">#define
PLATFORM_CPU_CONSTANTS\</font>
</p>
<p style="margin-bottom: 0in;"> <font face="Bitstream Vera Sans Mono, sans-serif">_C(
INT_REG_ENABLE ),\</font>
</p>
<p style="margin-bottom: 0in;"> <font face="Bitstream Vera Sans Mono, sans-serif">_C(
INT_REG_DISABLE ),\</font>
</p>
<p style="margin-bottom: 0in;"> <font face="Bitstream Vera Sans Mono, sans-serif">_C( INT_REG_MASK
)</font>
</p>
<p style="margin-bottom: 0in;"> <br>
</p>
<p style="margin-bottom: 0in;"> <font face="Bitstream Vera Sans Mono, sans-serif">After this
you'll be able to access the regs directly from Lua, like this:</font>
</p>
<p style="margin-bottom: 0in;"> <br>
</p>
<p style="margin-bottom: 0in;"> <font face="Bitstream Vera Sans Mono, sans-serif">data = cpu.r32(
cpu.INT_REG_ENABLE )</font>
</p>
<p style="margin-bottom: 0in;"> <font face="Bitstream Vera Sans Mono, sans-serif">cpu.w32(
cpu.INT_REG_ENABLE, data )</font>
</p>
<p style="margin-bottom: 0in;"> <br>
</p>
<p style="margin-bottom: 0in;"> <font face="Bitstream Vera Sans Mono, sans-serif">For a
"real-life" example, see the src/platform/lm3s/platform_conf.h file.</font>
</p>
<p style="margin-bottom: 0in;">
</p>
<p style="margin-bottom: 0in;"> <font face="Bitstream Vera Sans Mono, sans-serif">[uart.sendstring]
uart.sendstr( id, str1, str2, ... ): this is similar to "uart.send",
but its parameters are string.&nbsp;</font>
</p>
<p style="margin-bottom: 0in;"> <br>
</p>
<p style="margin-bottom: 0in;"> </p>
<h3><a name="gpiomodule">gpio</a></h3>
<p class="MsoNormal" style="font-family: Verdana;">
<b>[gpio] pio</b><br>
</p>
<br>
<p class="MsoNormal" style="font-family: Verdana;"><a name="gpio_setpinvalue"></a> [gpio.setpinvalue] pio.setpin(
value, Pin1, Pin2 ... ): set the value to all the pins in the list
</p>
<p class="MsoNormal" style="font-family: Verdana;">
&nbsp; to "value" (0 or 1).
</p>
<p class="MsoNormal" style="font-family: Verdana;">
&nbsp;
</p>
<p class="MsoNormal" style="font-family: Verdana;"><a name="gpio_setpinhigh"></a> [gpio.setpinhigh] pio.set(
Pin1, Pin2, ... ): set the value of all the pins in the list to 1.
</p>
<p class="MsoNormal" style="font-family: Verdana;">
&nbsp;
</p>
<p class="MsoNormal" style="font-family: Verdana;"><a name="gpio_getpinvalue"></a> [gpio.getpinvalue] Val1, Val2,
... = pio.get( Pin1, Pin2, ... ): reads one or more pins and returns
</p>
<p class="MsoNormal" style="font-family: Verdana;">
&nbsp; their values (0 or 1).
</p>
<p class="MsoNormal" style="font-family: Verdana;">
&nbsp;
</p>
<p class="MsoNormal" style="font-family: Verdana;"><a name="gpio_setpinlow"></a> [gpio.setpinlow] pio.clear(
Pin1, Pin2, ... ): set the value of all the pins in the list to 0.
</p>
<p class="MsoNormal" style="font-family: Verdana;">
&nbsp;
</p>
<p class="MsoNormal" style="font-family: Verdana;"><a name="gpio_configpin"></a> [gpio.configpin(gpio.DIR,
gpio.DIR_INPUT)] pio.input( Pin1, Pin2, ... ): set the specified pin(s)
as input(s).
</p>
<p class="MsoNormal" style="font-family: Verdana;">
&nbsp;
</p>
<p class="MsoNormal" style="font-family: Verdana;">
[gpio.configpin(gpio.DIR, gpio.DIR_OUTPUT)] pio.output( Pin1, Pin2, ...
): set the specified pin(s) as output(s).
</p>
<p class="MsoNormal" style="font-family: Verdana;">
&nbsp;
</p>
<p class="MsoNormal" style="font-family: Verdana;"><a name="gpio_setportvalue"></a> [gpio.setportvalue]
pio.setport( value, Port1, Port2, ... ): set the value of all the ports
in the
</p>
<p class="MsoNormal" style="font-family: Verdana;">
&nbsp; list to "value".
</p>
<p class="MsoNormal" style="font-family: Verdana;">
&nbsp;
</p>
<p class="MsoNormal" style="font-family: Verdana;"><a name="gpio_getportvalue"></a> [gpio.getportvalue] Val1,
Val2, ... = pio.getport( Port1, Port2, ... ): reads one or more ports
and
</p>
<p class="MsoNormal" style="font-family: Verdana;">
&nbsp; returns their values.
</p>
<p class="MsoNormal" style="font-family: Verdana;">
&nbsp;
</p>
<p class="MsoNormal" style="font-family: Verdana;"><a name="gpio_getportname"></a> [gpio.getportname]
Port = pio.port( code ): return the physical port number associated
with the given code. For example, "pio.port( pio.P0_20 )" will return
0.
</p>
<p class="MsoNormal" style="font-family: Verdana;">
&nbsp;
</p>
<p class="MsoNormal" style="font-family: Verdana;"><a name="gpio_getpinnumber"></a> [gpio.getpinnumber] Pin =
pio.pin( code ): return the physical pin number associated with the
</p>
<p class="MsoNormal" style="font-family: Verdana;">
given code. For example, "pio.pin( pio.P0_20 )" will return 20.
</p>
<br>
<a name="gpio_togglepin"></a>[gpio.togglepin([Pin1],
[Pin2], ...)]<br>
<br>
<a name="gpio_toogleport"></a>[gpio.toggleport([Port1],
[Port2], ...)]<br style="font-family: Verdana;">
<br>
Another idea (can be added to the above ?)<br>
[gpio.configport(gpio.[FUNCTION], gpio.MASK, [MASK])]<br>
Ex:<br>
&nbsp; gpio.configpin(gpio.DIR,
gpio.DIR_INPUT)&nbsp;&nbsp;&nbsp; (.DIR_OUTPUT)<br>
&nbsp; gpio.configpin(gpio.PULL,
gpio.PULL_UP)&nbsp;&nbsp;&nbsp;&nbsp; (.PULL_DOWN,
PULL_NO)<br style="font-family: Verdana;">
<br>
<p class="MsoNormal" style="font-family: Verdana;">
[gpio.configport(gpio.DIR, gpio.DIR_INPUT, [Port1], [Port2], ...)]
pio.port_input( Port1, Port2, ... ): set the specified port(s) as
input(s).
</p>
<p class="MsoNormal" style="font-family: Verdana;">
&nbsp;
</p>
<p class="MsoNormal" style="font-family: Verdana;">
[gpio.configport(gpio.DIR, gpio.DIR_OUTPUT, [Port1], [Port2], ...)]
pio.port_output( Port1, Port2, ... ): set the specified port(s) as
output(s).
</p>
<p class="MsoNormal" style="font-family: Verdana;">
&nbsp;
</p>
<p class="MsoNormal" style="font-family: Verdana;">
[gpio.configpin(gpio.PULL, gpio.PULL_UP, [Pin1], [Pin2], ...)]
pio.pullup( Pin1, Pin2, ... ): enable internal pullups on the specified
pins.Note that some CPUs might not provide this feature.
</p>
<p class="MsoNormal" style="font-family: Verdana;">
&nbsp;
</p>
<p class="MsoNormal" style="font-family: Verdana;">
[gpio.configpin(gpio.PULL, gpio.PULL_DOWN, [Pin1], [Pin2], ...)]
pio.pulldown( Pin1, Pin2, ... ): enable internal pulldowns on the
specified pins. Note that some CPUs might not provide this feature.
</p>
<p class="MsoNormal" style="font-family: Verdana;">
&nbsp;
</p>
<p class="MsoNormal" style="font-family: Verdana;">
[gpio.configpin(gpio.PULL, gpio.PULL_NO, [Pin1], [Pin2], ...)]
pio.nopull( Pin1, Pin2, ... ): disable the pullups/pulldowns on the
specifiedpins. Note that some CPUs might not provide this feature.
</p>
<br>
<h3><a name="netmodule"></a>net</h3>
<br>
<h3><a name="pwmmodule"></a>pwm</h3>
<span style="font-weight: bold;"></span><br>
<p style="margin-bottom: 0in;"> <br>
</p>
<p style="margin-bottom: 0in;"> <font face="Bitstream Vera Sans Mono, sans-serif">It allows Lua to
use the PWM blocks on the target CPU.</font>
</p>
<p style="margin-bottom: 0in;"> <br>
</p>
<p style="margin-bottom: 0in;"> <font face="Bitstream Vera Sans Mono, sans-serif"><strike><a name="pwm_setup"></a>[pwm.setup]</strike>(</font><font face="Bitstream Vera Sans Mono, sans-serif">pwm.setup( id,
frequency, Active Cycle ) &nbsp; &nbsp; &nbsp;</font><font face="Bitstream Vera Sans Mono, sans-serif">
Data = pwm.setup( id, frequency, duty ): sets the PWM block 'id' to
generate the specified frequency with the specified duty cycle (duty is
an integer number from 0 to 100, specifying the duty cycle in
percents). It returns the actual frequency set on the PWM block.</font>
</p>
<p style="margin-bottom: 0in;">
</p>
<p style="margin-bottom: 0in;"> <br>
</p>
<p style="margin-bottom: 0in;"> Here there is a bigger
change on the proposal.
</p>
<p style="margin-bottom: 0in;"> The Timer Clock and the
PWM "frame" frequency would be set up in the same function (.setup)
</p>
<p style="margin-bottom: 0in;"> The normal control
function would only set the active cicle (.setcycle)
</p>
<p style="margin-bottom: 0in;"> The original .setup
function would then be replaced by:
</p>
<p style="margin-bottom: 0in;"> <br>
</p>
<p style="margin-bottom: 0in;"> <font face="Bitstream Vera Sans Mono, sans-serif">[pwm.setup( id,
tmrclock, pwm_frequency )</font> ]<br>
</p>
<p style="margin-bottom: 0in;"> <a name="pwm_setcycle"></a>[pwm.setcycle(
id, active_cycle )]</p>
<p style="margin-bottom: 0in;"><font face="Bitstream Vera Sans Mono, sans-serif"><a name="pwm_start"></a>[pwm.start()]&nbsp;&nbsp;
pwm.start( id ): start the PWM block 'id'.</font>
</p>
<p style="margin-bottom: 0in;">
</p>
<p style="margin-bottom: 0in;"> <font face="Bitstream Vera Sans Mono, sans-serif"><a name="pwm_stop"></a>[</font><font face="Bitstream Vera Sans Mono, sans-serif">pwm.stop()]&nbsp;&nbsp;&nbsp;
</font><font face="Bitstream Vera Sans Mono, sans-serif">pwm.stop(
id ): stop the PWM block 'id'.</font>
</p>
<br>
<p style="margin-bottom: 0in;"> <font face="Bitstream Vera Sans Mono, sans-serif"><a name="pwm_setclock"></a>Data = pwm.setclock( id, clock ):
set the base clock of the PWM block 'id' to</font>
</p>
<p style="margin-bottom: 0in;"> <font face="Bitstream Vera Sans Mono, sans-serif">the given clock.
In returns the actual clock set on the PWM block.</font>
</p>
<p style="margin-bottom: 0in;"> <br>
</p>
<p style="margin-bottom: 0in;"> <font face="Bitstream Vera Sans Mono, sans-serif">[</font><font face="Bitstream Vera Sans Mono, sans-serif"><strike>pwm.getclock</strike>]
</font><font face="Bitstream Vera Sans Mono, sans-serif">Data
= pwm.getclock( id ): returns the base clock of the PWM block 'id'.</font>
</p>
<p style="margin-bottom: 0in;">
</p>
<p style="margin-bottom: 0in;"> <br>
</p>
<h3><a name="spimodule"></a>spi</h3>
<span style="font-weight: bold;"></span><br>
<big><span style="font-family: Helvetica,Arial,sans-serif;"></span><font style="font-family: Helvetica,Arial,sans-serif;" size="2"><big><a name="spi_setup"></a>Actual_clock = spi.setup( id,
spi.MASTER | spi.SLAVE, clock, cpol, cpha,</big></font><span style="font-family: Helvetica,Arial,sans-serif;">
</span><br style="font-family: Helvetica,Arial,sans-serif;">
<span style="font-family: Helvetica,Arial,sans-serif;">
&nbsp; </span><font style="font-family: Helvetica,Arial,sans-serif;" size="2"><big>databits):
set the SPI interface with the given parameters, returns the clock</big></font><span style="font-family: Helvetica,Arial,sans-serif;">
</span><br style="font-family: Helvetica,Arial,sans-serif;">
<span style="font-family: Helvetica,Arial,sans-serif;">
&nbsp; </span><font style="font-family: Helvetica,Arial,sans-serif;" size="2"><big>that
was set for the interface.</big></font><span style="font-family: Helvetica,Arial,sans-serif;">
</span><br style="font-family: Helvetica,Arial,sans-serif;">
<span style="font-family: Helvetica,Arial,sans-serif;">
&nbsp;
</span><br style="font-family: Helvetica,Arial,sans-serif;">
<font style="font-family: Helvetica,Arial,sans-serif;" size="2"><big><a name="spi_select"></a>spi.select(
</big></font><font style="font-family: Helvetica,Arial,sans-serif;" size="2"><big>id</big></font><font style="font-family: Helvetica,Arial,sans-serif;" size="2"><big>
): sets the selected spi as active (sets the SS line of the given
interface).</big></font><span style="font-family: Helvetica,Arial,sans-serif;">
</span><br style="font-family: Helvetica,Arial,sans-serif;">
<font style="font-family: Helvetica,Arial,sans-serif;" size="2"><big>&nbsp;</big></font><span style="font-family: Helvetica,Arial,sans-serif;">
</span><br style="font-family: Helvetica,Arial,sans-serif;">
<font style="font-family: Helvetica,Arial,sans-serif;" size="2"><big><a name="spi_unselect"></a>spi.unselect(
id ): clears the SS line of the given interface.</big></font><span style="font-family: Helvetica,Arial,sans-serif;">
</span><br style="font-family: Helvetica,Arial,sans-serif;">
<font style="font-family: Helvetica,Arial,sans-serif;" size="2"><big>&nbsp;</big></font><span style="font-family: Helvetica,Arial,sans-serif;">
</span><br style="font-family: Helvetica,Arial,sans-serif;">
<font style="font-family: Helvetica,Arial,sans-serif;" size="2"><big><a name="spi_send"></a>spi.send(
id, Data1, Data2, ... ): sends all the data to the specified SPI</big></font><span style="font-family: Helvetica,Arial,sans-serif;">
</span><br style="font-family: Helvetica,Arial,sans-serif;">
<span style="font-family: Helvetica,Arial,sans-serif;">
&nbsp; </span><font style="font-family: Helvetica,Arial,sans-serif;" size="2"><big>interface.</big></font><span style="font-family: Helvetica,Arial,sans-serif;">
</span><br style="font-family: Helvetica,Arial,sans-serif;">
<span style="font-family: Helvetica,Arial,sans-serif;">
&nbsp;
</span><br style="font-family: Helvetica,Arial,sans-serif;">
<font style="font-family: Helvetica,Arial,sans-serif;" size="2"><big><a name="spi_sendrecv"></a>[</big></font><font style="font-family: Helvetica,Arial,sans-serif;" size="2"><big>spi.sendrecv(</big></font><font style="font-family: Helvetica,Arial,sans-serif;" size="2"><big>id,
Out1, Out2, ...</big></font><font style="font-family: Helvetica,Arial,sans-serif;" size="2"><big>)]&nbsp;&nbsp;&nbsp;&nbsp;
</big></font><font style="font-family: Helvetica,Arial,sans-serif;" size="2"><big>In1,
In2, ... = spi.send_recv( id, Out1, Out2, ... ): sends all the "out"
bytes</big></font><span style="font-family: Helvetica,Arial,sans-serif;"> </span><font style="font-family: Helvetica,Arial,sans-serif;" size="2"><big>to
the specified SPI interface and returts the data read after each sent
byte.</big></font><span style="font-family: Helvetica,Arial,sans-serif;">
</span><br style="font-family: Helvetica,Arial,sans-serif;">
<br style="font-family: Helvetica,Arial,sans-serif;">
<font style="font-family: Helvetica,Arial,sans-serif;" size="2"><big>Returning
several values in this blocking way would not complicate some queued
send implementations ? (ok, this could be another function :)</big></font><span style="font-family: Helvetica,Arial,sans-serif;">
</span><br style="font-family: Helvetica,Arial,sans-serif;">
<br style="font-family: Helvetica,Arial,sans-serif;">
<font style="font-family: Helvetica,Arial,sans-serif;" size="2"><big>Sending multiple data/chars in a single
call and not in
a table argument does not allow the data to be built in run time
(without some string massage, of course :)</big></font><br>
<br>
<br>
<br>
</big>
<h3><a name="sysmodule"></a>sys</h3>
<br>
<p style="margin-bottom: 0in;"> <font face="Bitstream Vera Sans Mono, sans-serif"><a name="sys_platform"></a>[sys.platform()]&nbsp;&nbsp;&nbsp;
pd.platform(): returns the platform name (f.e. LM3S)</font>
</p>
<p style="margin-bottom: 0in;">
</p>
<p style="margin-bottom: 0in;"> <font face="Bitstream Vera Sans Mono, sans-serif"><a name="sys_mcu"></a>[sys.mcu()]&nbsp;&nbsp;&nbsp;
pd.cpu(): returns the CPU name (f.e. LM3S8962)</font>
</p>
<p style="margin-bottom: 0in;"> <font face="Bitstream Vera Sans Mono, sans-serif"><a name="sys_cpu"></a>[sys.cpu()]&nbsp;&nbsp;&nbsp;
would return ARM Cortex M3 in this case.....</font></p>
<p style="margin-bottom: 0in;"><font face="Bitstream Vera Sans Mono, sans-serif"><br>
</font></p>
<font face="Bitstream Vera Sans Mono, sans-serif">&nbsp;&nbsp;<a name="sys_board"></a>[sys.board()]</font><font face="Bitstream Vera Sans Mono, sans-serif">&nbsp;
pd.board(): returns the CPU board (f.e. EK-LM3S8962)</font>
<p style="margin-bottom: 0in;"> <br>
</p>
<h3><a name="term_termmodule">term</a></h3>
&nbsp; &nbsp;Terminal support
<p> <a name="term_clear"></a>[term.clear]
term.clrscr(): clear the screen </p>
<p> &nbsp; <br>
<a name="term_cleareol"></a>[term.cleareol]
term.clreol(): clear from the current cursor position to the end of the
line </p>
<p> &nbsp; </p>
<p><a name="term_moveto"></a> [term.moveto]
term.gotoxy( x, y ): position the cursor at the given coordinates<br>
</p>
<br>
<p><a name="term_moveup"></a> [term.moveup]
term.up( delta ): move the cursor up "delta" lines </p>
<p> &nbsp; </p>
<p><a name="term_movedown"></a> [term.movedown]
term.down( delta ): move the cursor down "delta" lines </p>
<p> &nbsp; </p>
<p><a name="term_moveleft"></a> [term.moveleft]
term.left( delta ): move the cursor left "delta" lines </p>
<p> &nbsp; <br>
<a name="term_moveright"></a>[term.moveright] term.right(
delta ): move the cursor right "delta" lines </p>
<p> &nbsp; </p>
<p><a name="term_getlinecount"></a>
[term.getlinecount] Lines = term.lines(): returns the number of lines </p>
<p> &nbsp; </p>
<p><a name="term_getcolcount"></a>
[term.getcolcount] Cols = term.cols(): returns the number of columns </p>
<p> &nbsp; </p>
<br>
<p><a name="term_printstr"></a> [term.printstr]
term.putstr( s1, s2, ... ): writes the specified string(s) to the
terminal<br>
</p>
<p> </p>
<p> [term.printchar] term.put( c1, c2, ... ): writes the
specified character(s) to the terminal </p>
<p>&nbsp; </p>
<p><a name="term_getx"></a> [term.getx] Cx =
term.cursorx(): return the cursor X position </p>
<p> &nbsp; </p>
<p> <a name="term_gety"></a>[term.gety] Cy =
term.cursory(): return the cursor Y position </p>
<p> &nbsp; </p>
<p> <font size="2"><a name="term_inputchar"></a>[term.inputchar]
c = term.getch( term.WAIT | term.NOWAIT ): returns a char read from the
</font> </p>
<font size="2">&nbsp; terminal.</font>
<br style="font-family: Verdana;">
<br>
<br>
<h3><a name="tmr_tmrmodule"></a>tmr</h3>
<span style="font-weight: bold;"></span><big><br>
</big>
<p style="margin-bottom: 0in;"> <font face="Bitstream Vera Sans Mono, sans-serif">It allows Lua to
execute timer specific operations (delay, read timer value,</font>
</p>
<p style="margin-bottom: 0in;"> <font face="Bitstream Vera Sans Mono, sans-serif">start timer, get
time difference).</font>
</p>
<p style="margin-bottom: 0in;"> <br>
</p>
<p style="margin-bottom: 0in;"> <font face="Bitstream Vera Sans Mono, sans-serif"><a name="tmr_delay"></a>tmr.delay( id, delay ): uses timer
'id' to wait for 'delay' us.</font>
</p>
<p style="margin-bottom: 0in;"> <br>
</p>
<p style="margin-bottom: 0in;"> <font face="Bitstream Vera Sans Mono, sans-serif"><span style="font-style: italic;"><a name="tmr_read"></a></span>Data
= tmr.read( id ): reads the value of timer 'id'. The returned value is </font>
</p>
<p style="margin-bottom: 0in;"> <font face="Bitstream Vera Sans Mono, sans-serif">platform
dependent.</font>
</p>
<p style="margin-bottom: 0in;">
</p>
<p style="margin-bottom: 0in;"> <font face="Bitstream Vera Sans Mono, sans-serif"><span style="font-style: italic;"><a name="tmr_start"></a></span>Data
= tmr.start( id ): start the timer 'id', and also returns its value at</font>
</p>
<p style="margin-bottom: 0in;"> <font face="Bitstream Vera Sans Mono, sans-serif">the moment of
start. The returned value is platform dependent.</font>
</p>
<p style="margin-bottom: 0in;">
</p>
<p style="margin-bottom: 0in;"> <font face="Bitstream Vera Sans Mono, sans-serif"><a name="tmr_diff"></a>diff
= tmr.diff( id, end, start ): returns the time difference (in us)
between</font>
</p>
<p style="margin-bottom: 0in;"> <font face="Bitstream Vera Sans Mono, sans-serif">the timer values
'end' and 'start' (obtained from calling tmr.start or</font>
</p>
<p style="margin-bottom: 0in;"> <font face="Bitstream Vera Sans Mono, sans-serif">tmr.read). The
order of end/start is irrelevant. </font>
</p>
<p style="margin-bottom: 0in;">
</p>
<p style="margin-bottom: 0in;"> <font face="Bitstream Vera Sans Mono, sans-serif"><a name="tmr_mindelay"></a>Data = tmr.mindelay( id ): returns
the minimum delay (in us ) that can be </font>
</p>
<p style="margin-bottom: 0in;"> <font face="Bitstream Vera Sans Mono, sans-serif">achieved by
calling the tmr.delay function. If the return value is 0, the </font>
</p>
<p style="margin-bottom: 0in;"> <font face="Bitstream Vera Sans Mono, sans-serif">platform layer
is capable of executing sub-microsecond delays.</font>
</p>
<p style="margin-bottom: 0in;">
</p>
<p style="margin-bottom: 0in;"> <font face="Bitstream Vera Sans Mono, sans-serif"><a name="tmr_maxdelay"></a>Data = tmr.maxdelay( id ): returns
the maximum delay (in us) that can be</font>
</p>
<p style="margin-bottom: 0in;"> <font face="Bitstream Vera Sans Mono, sans-serif">achieved by
calling the tmr.delay function.</font>
</p>
<p style="margin-bottom: 0in;">
</p>
<p style="margin-bottom: 0in;"> <font face="Bitstream Vera Sans Mono, sans-serif"><a name="tmr_setclock"></a>Data = tmr.setclock( id, clock ):
sets the clock of the given timer. Returns the</font>
</p>
<p style="margin-bottom: 0in;"> <font face="Bitstream Vera Sans Mono, sans-serif">actual clock set
for the timer.</font>
</p>
<p style="margin-bottom: 0in;">
</p>
<p style="margin-bottom: 0in;"> <font face="Bitstream Vera Sans Mono, sans-serif"><a name="tmr_getclock"></a>Data = tmr.getclock( id ): return
the clock of the given timer.</font>
</p>
<br>
<br>
<br>
<br>
<br>
<h3><a name="uartmodule"></a>uart</h3>
<p style="margin-bottom: 0in;"> <font face="Bitstream Vera Sans Mono, sans-serif"><a name="uart_setup"></a>[uart.setup(</font><font face="Bitstream Vera Sans Mono, sans-serif"> id, baud,
databits, </font>
</p>
<p style="margin-bottom: 0in;"> <font face="Bitstream Vera Sans Mono, sans-serif">uart.PARITY_EVEN
|uart.</font><font face="Bitstream Vera Sans Mono, sans-serif">PARITY</font><font face="Bitstream Vera Sans Mono, sans-serif">_ODD | uart.</font><font face="Bitstream Vera Sans Mono, sans-serif">PARITY</font><font face="Bitstream Vera Sans Mono, sans-serif">_NONE, </font>
</p>
<p style="margin-bottom: 0in;"> <font face="Bitstream Vera Sans Mono, sans-serif">uart.STOPBITS_1
| uart.STOPBITS_1_5 | uart.STOPBITS_2
)]&nbsp;&nbsp;&nbsp;&nbsp; Actual_baud = uart.setup(
id, baud, databits, </font>
</p>
<p style="margin-bottom: 0in;"> <font face="Bitstream Vera Sans Mono, sans-serif">uart.PAR_EVEN
|uart.PAR_ODD | uart.PAR_NONE, </font>
</p>
<p style="margin-bottom: 0in;"> <font face="Bitstream Vera Sans Mono, sans-serif">uart.STOP_1 |
uart.STOP_1_5 | uart.STOP_2 ): set the UART interface with the</font>
</p>
<p style="margin-bottom: 0in;"> <font face="Bitstream Vera Sans Mono, sans-serif">given
parameters, returns the baud rate that was set for the UART.</font>
</p>
<p style="margin-bottom: 0in;">
</p>
<p style="margin-bottom: 0in;"> <font face="Bitstream Vera Sans Mono, sans-serif"><br>
</font></p>
<p style="margin-bottom: 0in;"> <font face="Bitstream Vera Sans Mono, sans-serif"><a name="uart_send"></a>[</font><font face="Bitstream Vera Sans Mono, sans-serif">uart.send] </font><font face="Bitstream Vera Sans Mono, sans-serif">uart.send( id,
Data1, Data2, ... ): send all the data to the specified UART interface.</font>
</p>
<p style="margin-bottom: 0in;"> <font face="Bitstream Vera Sans Mono, sans-serif">#### Data 1 only
!?!!<br>
</font></p>
<p style="margin-bottom: 0in;">
</p>
<p style="margin-bottom: 0in;"> <font face="Bitstream Vera Sans Mono, sans-serif"><br>
</font></p>
<p style="margin-bottom: 0in;"> <font face="Bitstream Vera Sans Mono, sans-serif"><a name="uart_recv"></a>[</font><font face="Bitstream Vera Sans Mono, sans-serif">uart.recv(</font><font face="Bitstream Vera Sans Mono, sans-serif"> id,
uart.TIMEOUT_NO | <strike>uart.TIMEOUT_INFINITE</strike> |
timeout )</font><font face="Bitstream Vera Sans Mono, sans-serif">
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font><font face="Bitstream Vera Sans Mono, sans-serif">Data =
uart.recv( id, uart.NO_TIMEOUT | uart.INF_TIMEOUT | timeout ): reads a </font>
</p>
<p style="margin-bottom: 0in;"> <font face="Bitstream Vera Sans Mono, sans-serif">byte from the
specified UART interface.</font></p>
<p style="margin-bottom: 0in;"></p>
<p style="margin-bottom: 0in;">
</p>
<h3><a name="platdepmodules"></a>eLua Platform
Dependent
Modules</h3><h3><a name="adcmodule"></a>adc</h3>Currently runs on: LM3S <br><br><a name="adc_sample"></a>adc.sample(channel_id) - generate one processed sample<br><br><a name="adc_getsamples"></a>adc.getsamples(channel_id,
count) - request (count) samples from the buffer. if singular, an
integer is returned. &nbsp;if multiple, a table of integers is returned. &nbsp;If
count is either zero or omitted, all available samples are returned.<br><br><a name="adc_maxval"></a>adc.maxval(channel_id) - returns largest integer one can expect for this channel on a given platform (based on bit depth)<br><br><a name="adc_samplesready"></a>adc.samplesready(channel_id) - returns number of samples waiting in the buffer<br><br><a name="adc_dataready"></a>adc.dataready(channel_id)
- if running in non-blocking mode, this will indicate if all of the
samples requested from the last sample or <br>burst have been acquired and
are waiting in the buffer<br><br><a name="adc_setmode"></a>adc.setmode(channel_id,
mode) - mode: 0 sets mode to blocking (getsamples will wait for
requested samples to be captured before returning), 1 sets non-blocking<br><br><a name="adc_setsmoothing"></a>adc.setsmoothing(channel_id, length) - set the length of the smoothing filter, this must be a power of 2 (maximum = 128)<br><br><a name="adc_getsmoothing"></a>adc.getsmoothing(channel_id) - get the current smoothing length in use<br><br><a name="adc_burst"></a>adc.burst(
channel_id, count, timer_id, frequency) - request that (count) samples
(must be greater than zero and a power of 2) be converted from
(channel_id), using (timer_id) at (frequency)<br><br>
<h3><a name="dispmodule"></a>disp</h3>
<span style="font-weight: bold;"></span>Currently runs on: LM3S <br>
<p class="MsoNormal"><a name="disp_init"></a>
disp.init </p>
<p class="MsoNormal"> <br>
</p>
<p class="MsoNormal"><a name="disp_enable"></a>
disp.enable </p>
<p class="MsoNormal"> <br>
</p>
<p class="MsoNormal"><a name="disp_disable"></a>
disp.disable </p>
<p class="MsoNormal"> <br>
</p>
<p class="MsoNormal"> <a name="disp_on"></a>disp.on
</p>
<p class="MsoNormal"> <br>
</p>
<p class="MsoNormal"><a name="disp_off"></a>
disp.off<br>
</p>
<p class="MsoNormal" style="color: rgb(0, 0, 255);">
<br>
</p>
&nbsp; &nbsp;<a name="disp_print"></a>disp.print<br>
<br>
<p class="MsoNormal"><a name="disp_draw"></a>
disp.draw </p>
</body></html>