From f9cb5de58020936812653c578c79c79a13bc626c Mon Sep 17 00:00:00 2001 From: Amaury Pouly Date: Thu, 13 Jun 2013 02:12:01 +0200 Subject: hwstub: introduce lua code for the STMP and Creative ZEN V/Mozaic Change-Id: Ice5f509a2e0d2114436d4760f338b9203ef96691 --- utils/hwstub/tools/lua/stmp/pwm.lua | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 utils/hwstub/tools/lua/stmp/pwm.lua (limited to 'utils/hwstub/tools/lua/stmp/pwm.lua') diff --git a/utils/hwstub/tools/lua/stmp/pwm.lua b/utils/hwstub/tools/lua/stmp/pwm.lua new file mode 100644 index 0000000000..8b078af5a7 --- /dev/null +++ b/utils/hwstub/tools/lua/stmp/pwm.lua @@ -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 \ No newline at end of file -- cgit v1.2.3