From 95e5875b8208df76d0dc52a7f87a5b6012cce7db Mon Sep 17 00:00:00 2001 From: Bogdan Marinescu Date: Mon, 1 Sep 2008 20:32:43 +0000 Subject: [PATCH] getting ready for 0.4 --- romfs/hangman.lua | 2 +- romfs/led.lua | 6 +++-- romfs/piano.lua | 2 +- romfs/pwmled.lua | 28 ++++++++++++++++++++++ romfs/tvbgone.lua | 49 ++++++++++++++++++++++++++------------- src/main.c | 2 +- src/platform/str9/conf.py | 2 +- 7 files changed, 69 insertions(+), 22 deletions(-) create mode 100644 romfs/pwmled.lua diff --git a/romfs/hangman.lua b/romfs/hangman.lua index b12c9b57..eabf0a28 100644 --- a/romfs/hangman.lua +++ b/romfs/hangman.lua @@ -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 diff --git a/romfs/led.lua b/romfs/led.lua index 0d9281b8..77a513e1 100644 --- a/romfs/led.lua +++ b/romfs/led.lua @@ -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 diff --git a/romfs/piano.lua b/romfs/piano.lua index ca7cb054..1aa1648d 100644 --- a/romfs/piano.lua +++ b/romfs/piano.lua @@ -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 diff --git a/romfs/pwmled.lua b/romfs/pwmled.lua new file mode 100644 index 00000000..4be86bd8 --- /dev/null +++ b/romfs/pwmled.lua @@ -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 ) diff --git a/romfs/tvbgone.lua b/romfs/tvbgone.lua index add123e7..e1bbf2cd 100644 --- a/romfs/tvbgone.lua +++ b/romfs/tvbgone.lua @@ -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() diff --git a/src/main.c b/src/main.c index 355a2499..31411852 100644 --- a/src/main.c +++ b/src/main.c @@ -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 diff --git a/src/platform/str9/conf.py b/src/platform/str9/conf.py index d4533437..9f0b8902 100644 --- a/src/platform/str9/conf.py +++ b/src/platform/str9/conf.py @@ -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