/
led.lua
64 lines (59 loc) · 1.54 KB
/
led.lua
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
63
-- eLua blinking led example, the Hello World of embedded :)
local uartid, invert, ledpin = 0, false
if pd.board() == "SAM7-EX256" then
ledpin = pio.PB_20
elseif pd.board() == "EK-LM3S8962" or pd.board() == "EK-LM3S6965" then
ledpin = pio.PF_0
elseif pd.board() == "EAGLE-100" then
ledpin = pio.PE_1
elseif pd.board() == "STR9-COMSTICK" then
ledpin = pio.P9_0
elseif pd.board() == "LPC-H2888" then
ledpin = pio.P2_1
elseif pd.board() == "MOD711" then
ledpin = pio.P1_7
uartid = 1
elseif pd.board() == "ATEVK1100" then
ledpin = pio.PB_27
invert = true
elseif pd.board() == "STR-E912" then
ledpin = pio.P6_4
elseif pd.board() == "ELUA-PUC" then
ledpin = pio.P1_20
elseif pd.board() == "ET-STM32" then
ledpin = pio.PA_5
elseif pd.board() == "STM32F4DISCOVERY" then
ledpin = pio.PD_13
uartid = uart.CDC
elseif pd.board() == "MBED" then
ledpin = mbed.pio.LED1
mbed.pio.configpin( ledpin, 0, 0, 0 )
elseif pd.board() == "MIZAR32" then
ledpin = pio.PB_29
invert = true
else
print( "\nError: Unknown board " .. pd.board() .. " !" )
return
end
function cycle()
if not invert then
pio.pin.sethigh( ledpin )
else
pio.pin.setlow( ledpin )
end
tmr.delay( 0, 500000 )
if not invert then
pio.pin.setlow( ledpin )
else
pio.pin.sethigh( ledpin )
end
tmr.delay( 0, 500000 )
end
pio.pin.setdir( pio.OUTPUT, ledpin )
print( "Hello from eLua on " .. pd.board() )
print "Watch your LED blinking :)"
print "Enjoy eLua !"
print "Press any key to end this demo.\n"
while uart.getchar( uartid, 0 ) == "" do
cycle()
end