1
0
Fork 0
forked from len0rd/rockbox

hwstub: introduce lua code for the STMP and Creative ZEN V/Mozaic

Change-Id: Ice5f509a2e0d2114436d4760f338b9203ef96691
This commit is contained in:
Amaury Pouly 2013-06-13 02:12:01 +02:00
parent c5357940ab
commit f9cb5de580
8 changed files with 661 additions and 0 deletions

View file

@ -0,0 +1,35 @@
--
-- LCDIF
--
STMP.pwm = {}
function STMP.pwm.init()
HW.LCDIF.CTRL.SFTRST.clr()
HW.LCDIF.CTRL.CLKGATE.clr()
end
function STMP.pwm.enable(chan, en)
if en then
HW.PWM.CTRL.set(bit32.lshift(1, chan))
else
HW.PWM.CTRL.clr(bit32.lshift(1, chan))
end
end
function STMP.pwm.setup(channel, period, cdiv, active, active_state, inactive, inactive_state)
-- stop
STMP.pwm.enable(channel, false)
-- setup pin
--FIXME
-- watch the order ! active THEN period
-- NOTE: the register value is period-1
HW.PWM.ACTIVEn[channel].ACTIVE.write(active)
HW.PWM.ACTIVEn[channel].INACTIVE.write(inactive)
HW.PWM.PERIODn[channel].PERIOD.write(period - 1)
HW.PWM.PERIODn[channel].ACTIVE_STATE.write(active_state)
HW.PWM.PERIODn[channel].INACTIVE_STATE.write(inactive_state)
HW.PWM.PERIODn[channel].CDIV.write(cdiv)
-- restore
STMP.pwm.enable(channel, true)
end