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

getting ready for 0.4

This commit is contained in:
Bogdan Marinescu 2008-09-01 20:32:43 +00:00
parent e0ae30c61e
commit 95e5875b82
7 changed files with 69 additions and 22 deletions

View File

@ -4,7 +4,7 @@
-- we need a random function
-- using math.random for now, which implies target=lua, not lualong
if not math then
print "\nError: Hangman needs the math module (disabled when target=lualong) !\n"
print "\nError: Hangman needs the math module (disabled when target=lualong) !"
return
end

View File

@ -4,10 +4,12 @@ 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() == "STR9-comStick" then
elseif pd.board() == "STR9-COMSTICK" then
ledpin = pio.P9_0
elseif pd.board() == "LPC-H2888" then
ledpin = pio.P2_1
else
print( "\nError: Unknown board " .. pd.board() .. " !\n" )
print( "\nError: Unknown board " .. pd.board() .. " !" )
return
end

View File

@ -13,7 +13,7 @@ elseif pd.board() == "SAM7-EX256" then
pwmid, tmrid = 0, 1
tmr.setclock( 1, 1000000 )
else
print( pd.board() .. " not supported with this example\n" )
print( pd.board() .. " not supported with this example" )
return
end

28
romfs/pwmled.lua Normal file
View File

@ -0,0 +1,28 @@
-- Control LED intensity with PWM
local pwmid, tmrid, ledpin
if pd.board() == 'EK-LM3S8962' or pd.board() == 'EK-LM3S6965' then
pwmid, tmrid = 0, 1
pwm.setclock( pwmid, 25000000 )
else
print( pd.board() .. " not supported by this example" )
return
end
print( tmr.mindelay( tmrid ), tmr.maxdelay( tmrid ), tmr.getclock( tmrid ) )
print "Control LED with PWM (fade up/down)"
print "Press any key to exit"
local crtduty, incr = 10, 5
pwm.setup( pwmid, 50000, crtduty )
pwm.start( pwmid )
while uart.recv( 0, 0, 0 ) < 0 do
if crtduty == 95 or crtduty == 5 then
incr = -incr
end
crtduty = crtduty + incr
pwm.setup( pwmid, 50000, crtduty )
tmr.delay( tmrid, 50000 )
end
pwm.stop( pwmid )

View File

@ -1,12 +1,5 @@
-- TVBGone in eLua
-- Adapted from LadyAda's TVBGone project
-- Currently working only on the LM3S platform
-- Safety checks
if pwm == nil or tmr == nil or pio == nil then
print "The PWM and/or TMR/PIO modules not found, exiting"
return
end
-- Check codes file
local codes = io.open( "/rom/codes.bin", "rb" )
@ -15,17 +8,35 @@ if codes == nil then
return
end
-- Setup PWM
local pwmid = pwm.PWM2
local tmrid = tmr.TMR0
local led = pio.PF_0
pwm.setclock( pwmid, 25000000 )
local pwmid, tmrid
if pd.board() == 'EK-LM3S8962' or pd.board() == 'EK-LM3S6965' then
pwmid, tmrid = 2, 1
pwm.setclock( pwmid, 25000000 )
led, startpin, exitpin = pio.PF_0, pio.PF_1, pio.PE_1
else
print( pd.board() .. " not supported with this example" )
return
end
-- Setup PIO
pio.output( led )
local _, fstr, freq, timesstr, ontime, offtime
pio.input( startpin, exitpin )
pio.pullup( startpin, exitpin )
-- Local variables
local _, fstr, freq, timesstr, ontime, offtime, runme
-- Send all the codes in an infinite loop
collectgarbage( "stop" )
while true do
runme = true
while runme do
while pio.get( startpin ) == 1 do
if pio.get( exitpin ) == 0 then
runme = false
break
end
end
if not runme then break end
pio.set( led )
codes:seek( "set", 0 )
while true do
@ -41,12 +52,18 @@ while true do
tmr.delay( tmrid, ontime * 10 )
pwm.stop( pwmid )
if offtime == 0 then break end
tmr.delay( tmrid, offtime * 10 )
tmr.delay( tmrid, offtime * 10 )
if pio.get( exitpin ) == 0 then
runme = false
break
end
end
if not runme then break end
tmr.delay( tmrid, 250000 )
end
pio.clear( led )
tmr.delay( tmrid, 1000000 )
if not runme then break end
tmr.delay( tmrid, 500000 )
end
codes:close()

View File

@ -19,7 +19,7 @@ extern char etext[];
// Maximum file size that can be received via XMODEM
// Should be a multiple of 128
#define XMODEM_MAX_FILE_SIZE 3072
#define XMODEM_MAX_FILE_SIZE 4096
#ifdef BUILD_XMODEM

View File

@ -5,7 +5,7 @@ cpumode = ARGUMENTS.get( 'cpumode', 'arm' ).lower()
specific_files = "startup912.s startup_generic.s platform.c 91x_scu.c 91x_fmi.c 91x_gpio.c 91x_uart.c 91x_tim.c"
# Check CPU
if cputype == 'str912fw44':
if cputype == 'STR912FW44':
ldscript = "str912fw44.lds"
else:
print "Invalid STR9 CPU %s", cputype