summaryrefslogtreecommitdiff
path: root/utils/hwstub/tools/lua/stmp/pwm.lua
diff options
context:
space:
mode:
authorAmaury Pouly <amaury.pouly@gmail.com>2013-06-13 02:12:01 +0200
committerAmaury Pouly <amaury.pouly@gmail.com>2013-06-13 02:25:15 +0200
commitf9cb5de58020936812653c578c79c79a13bc626c (patch)
treed1d6c29207472bea4daa68d2fffd7e8dbfac998b /utils/hwstub/tools/lua/stmp/pwm.lua
parentc5357940ab0108b4102442d07825c44d5be0d22f (diff)
downloadrockbox-f9cb5de58020936812653c578c79c79a13bc626c.tar.gz
rockbox-f9cb5de58020936812653c578c79c79a13bc626c.zip
hwstub: introduce lua code for the STMP and Creative ZEN V/Mozaic
Change-Id: Ice5f509a2e0d2114436d4760f338b9203ef96691
Diffstat (limited to 'utils/hwstub/tools/lua/stmp/pwm.lua')
-rw-r--r--utils/hwstub/tools/lua/stmp/pwm.lua35
1 files changed, 35 insertions, 0 deletions
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 @@
1--
2-- LCDIF
3--
4
5STMP.pwm = {}
6
7function STMP.pwm.init()
8 HW.LCDIF.CTRL.SFTRST.clr()
9 HW.LCDIF.CTRL.CLKGATE.clr()
10end
11
12function STMP.pwm.enable(chan, en)
13 if en then
14 HW.PWM.CTRL.set(bit32.lshift(1, chan))
15 else
16 HW.PWM.CTRL.clr(bit32.lshift(1, chan))
17 end
18end
19
20function STMP.pwm.setup(channel, period, cdiv, active, active_state, inactive, inactive_state)
21 -- stop
22 STMP.pwm.enable(channel, false)
23 -- setup pin
24 --FIXME
25 -- watch the order ! active THEN period
26 -- NOTE: the register value is period-1
27 HW.PWM.ACTIVEn[channel].ACTIVE.write(active)
28 HW.PWM.ACTIVEn[channel].INACTIVE.write(inactive)
29 HW.PWM.PERIODn[channel].PERIOD.write(period - 1)
30 HW.PWM.PERIODn[channel].ACTIVE_STATE.write(active_state)
31 HW.PWM.PERIODn[channel].INACTIVE_STATE.write(inactive_state)
32 HW.PWM.PERIODn[channel].CDIV.write(cdiv)
33 -- restore
34 STMP.pwm.enable(channel, true)
35end \ No newline at end of file