diff options
Diffstat (limited to 'utils/hwstub/tools/lua/stmp/pwm.lua')
-rw-r--r-- | utils/hwstub/tools/lua/stmp/pwm.lua | 35 |
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 | |||
5 | STMP.pwm = {} | ||
6 | |||
7 | function STMP.pwm.init() | ||
8 | HW.LCDIF.CTRL.SFTRST.clr() | ||
9 | HW.LCDIF.CTRL.CLKGATE.clr() | ||
10 | end | ||
11 | |||
12 | function 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 | ||
18 | end | ||
19 | |||
20 | function 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) | ||
35 | end \ No newline at end of file | ||