diff options
author | Amaury Pouly <amaury.pouly@gmail.com> | 2013-06-13 02:12:01 +0200 |
---|---|---|
committer | Amaury Pouly <amaury.pouly@gmail.com> | 2013-06-13 02:25:15 +0200 |
commit | f9cb5de58020936812653c578c79c79a13bc626c (patch) | |
tree | d1d6c29207472bea4daa68d2fffd7e8dbfac998b /utils/hwstub/tools/lua/stmp | |
parent | c5357940ab0108b4102442d07825c44d5be0d22f (diff) | |
download | rockbox-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')
-rw-r--r-- | utils/hwstub/tools/lua/stmp/digctl.lua | 38 | ||||
-rw-r--r-- | utils/hwstub/tools/lua/stmp/lcdif.lua | 100 | ||||
-rw-r--r-- | utils/hwstub/tools/lua/stmp/pinctrl.lua | 253 | ||||
-rw-r--r-- | utils/hwstub/tools/lua/stmp/pwm.lua | 35 |
4 files changed, 426 insertions, 0 deletions
diff --git a/utils/hwstub/tools/lua/stmp/digctl.lua b/utils/hwstub/tools/lua/stmp/digctl.lua new file mode 100644 index 0000000000..8dfc13b7f2 --- /dev/null +++ b/utils/hwstub/tools/lua/stmp/digctl.lua | |||
@@ -0,0 +1,38 @@ | |||
1 | --- | ||
2 | --- DIGCTL | ||
3 | --- | ||
4 | STMP.digctl = {} | ||
5 | |||
6 | local h = HELP:get_topic("STMP"):create_topic("digctl") | ||
7 | h:add("The STMP.digctl table handles the digctl device for all STMPs.") | ||
8 | |||
9 | local hh = h:create_topic("package") | ||
10 | hh:add("The STMP.digctl.package() function returns the name of the package.") | ||
11 | hh:add("The following packages can be returned:") | ||
12 | hh:add("* bga100") | ||
13 | hh:add("* bga169") | ||
14 | hh:add("* tqfp100") | ||
15 | hh:add("* lqfp100") | ||
16 | hh:add("* lqfp128") | ||
17 | |||
18 | function STMP.digctl.package() | ||
19 | local pack = nil | ||
20 | if STMP.is_stmp3600() then | ||
21 | HW.DIGCTL.CTRL.PACKAGE_SENSE_ENABLE.set() | ||
22 | if HW.DIGCTL.STATUS.PACKAGE_TYPE.read() == 1 then | ||
23 | pack = "lqfp100" | ||
24 | else | ||
25 | pack = "bga169" | ||
26 | end | ||
27 | HW.DIGCTL.CTRL.PACKAGE_SENSE_ENABLE.clr() | ||
28 | elseif STMP.is_stmp3700() or STMP.is_stmp3770() or STMP.is_imx233() then | ||
29 | local t = HW.DIGCTL.STATUS.PACKAGE_TYPE.read() | ||
30 | if t == 0 then pack = "bga169" | ||
31 | elseif t == 1 then pack = "bga100" | ||
32 | elseif t == 2 then pack = "tqfp100" | ||
33 | elseif t == 3 then pack = "tqfp128" | ||
34 | end | ||
35 | end | ||
36 | |||
37 | return pack | ||
38 | end \ No newline at end of file | ||
diff --git a/utils/hwstub/tools/lua/stmp/lcdif.lua b/utils/hwstub/tools/lua/stmp/lcdif.lua new file mode 100644 index 0000000000..0878cb1139 --- /dev/null +++ b/utils/hwstub/tools/lua/stmp/lcdif.lua | |||
@@ -0,0 +1,100 @@ | |||
1 | -- | ||
2 | -- LCDIF | ||
3 | -- | ||
4 | |||
5 | STMP.lcdif = {} | ||
6 | |||
7 | function STMP.lcdif.init() | ||
8 | HW.LCDIF.CTRL.SFTRST.set() | ||
9 | HW.LCDIF.CTRL.SFTRST.clr() | ||
10 | HW.LCDIF.CTRL.CLKGATE.clr() | ||
11 | end | ||
12 | |||
13 | function STMP.lcdif.set_system_timing(data_setup, data_hold, cmd_setup, cmd_hold) | ||
14 | HW.LCDIF.TIMING.CMD_HOLD.write(cmd_hold) | ||
15 | HW.LCDIF.TIMING.CMD_SETUP.write(cmd_setup) | ||
16 | HW.LCDIF.TIMING.DATA_HOLD.write(data_hold) | ||
17 | HW.LCDIF.TIMING.DATA_SETUP.write(data_setup) | ||
18 | end | ||
19 | |||
20 | function STMP.lcdif.set_byte_packing_format(val) | ||
21 | HW.LCDIF.CTRL1.BYTE_PACKING_FORMAT.write(val) | ||
22 | end | ||
23 | |||
24 | function STMP.lcdif.set_reset(val) | ||
25 | if STMP.is_stmp3600() then | ||
26 | HW.LCDIF.CTRL.RESET.write(val) | ||
27 | else | ||
28 | HW.LCDIF.CTRL1.RESET.write(val) | ||
29 | end | ||
30 | end | ||
31 | |||
32 | function STMP.lcdif.set_word_length(bus_width) | ||
33 | if STMP.is_stmp3600() or STMP.is_stmp3700() then | ||
34 | if bus_width == 8 then | ||
35 | HW.LCDIF.CTRL.WORD_LENGTH.set() | ||
36 | else | ||
37 | HW.LCDIF.CTRL.WORD_LENGTH.clr() | ||
38 | end | ||
39 | else | ||
40 | error("STMP.lcdif.set_word_length: unimplemented") | ||
41 | end | ||
42 | end | ||
43 | |||
44 | function STMP.lcdif.get_word_length() | ||
45 | if STMP.is_stmp3600() or STMP.is_stmp3700() then | ||
46 | if HW.LCDIF.CTRL.WORD_LENGTH.read() == 1 then | ||
47 | return 8 | ||
48 | else | ||
49 | return 16 | ||
50 | end | ||
51 | else | ||
52 | error("STMP.lcdif.get_word_length: unimplemented") | ||
53 | end | ||
54 | end | ||
55 | |||
56 | function STMP.lcdif.set_data_swizzle(swizzle) | ||
57 | local v = swizzle | ||
58 | if type(swizzle) == "string" then | ||
59 | if swizzle == "NONE" then | ||
60 | v = 0 | ||
61 | else | ||
62 | error("unimplemented") | ||
63 | end | ||
64 | end | ||
65 | HW.LCDIF.CTRL.DATA_SWIZZLE.write(v) | ||
66 | end | ||
67 | |||
68 | function STMP.lcdif.is_busy() | ||
69 | if STMP.is_stmp3600() then | ||
70 | return HW.LCDIF.CTRL.FIFO_STATUS.read() == 0 | ||
71 | else | ||
72 | return HW.LCDIF.STAT.TXFIFO_FULL.read() == 1 | ||
73 | end | ||
74 | end | ||
75 | |||
76 | function STMP.lcdif.send_pio(data_mode, data) | ||
77 | local wl = STMP.lcdif.get_word_length() | ||
78 | if data_mode then | ||
79 | HW.LCDIF.CTRL.DATA_SELECT.set() | ||
80 | else | ||
81 | HW.LCDIF.CTRL.DATA_SELECT.clr() | ||
82 | end | ||
83 | STMP.debug(string.format("lcdif: count = %d", #data)) | ||
84 | HW.LCDIF.CTRL.RUN.clr() | ||
85 | HW.LCDIF.CTRL.COUNT.write(#data) | ||
86 | HW.LCDIF.CTRL.RUN.set() | ||
87 | local i = 1 | ||
88 | while i <= #data do | ||
89 | local v = 0 | ||
90 | local v_size = 0 | ||
91 | while i <= #data and v_size + wl <= 32 do | ||
92 | v = bit32.bor(v, bit32.lshift(data[i], v_size)) | ||
93 | v_size = v_size + wl | ||
94 | i = i + 1 | ||
95 | end | ||
96 | STMP.debug(string.format("lcdif: i=%d send 0x%x", i, v)) | ||
97 | while STMP.lcdif.is_busy() do STMP.debug("lcdif: fifo full") end | ||
98 | HW.LCDIF.DATA.write(v) | ||
99 | end | ||
100 | end \ No newline at end of file | ||
diff --git a/utils/hwstub/tools/lua/stmp/pinctrl.lua b/utils/hwstub/tools/lua/stmp/pinctrl.lua new file mode 100644 index 0000000000..2676f6476b --- /dev/null +++ b/utils/hwstub/tools/lua/stmp/pinctrl.lua | |||
@@ -0,0 +1,253 @@ | |||
1 | --- | ||
2 | --- PINCTRL | ||
3 | --- | ||
4 | STMP.pinctrl = {} | ||
5 | |||
6 | local h = HELP:get_topic("STMP"):create_topic("pinctrl") | ||
7 | h:add("The STMP.pinctrl table handles the pinctrl device for all STMPs.") | ||
8 | h:add("It provides a simple abstraction to set individual pins.") | ||
9 | |||
10 | local hh = h:create_topic("pin") | ||
11 | hh:add("The STMP.pinctrl.pin(x,yy) function returns a table for the pin BxPyy.") | ||
12 | hh:add("Depending on the STMP family, the following function might be available.") | ||
13 | hh:add("* read() returns the value of the pin (the pin does not need to be configured as GPIO)") | ||
14 | hh:add("* write(x) sets the value of the pin (provided it is a GPIO with output enabled)") | ||
15 | hh:add("* set() is equivalent to write(1)") | ||
16 | hh:add("* clr() is equivalent to write(0)") | ||
17 | hh:add("* enable() enables the gpio output (provided it is configured as GPIO).") | ||
18 | hh:add("* disable() disables the gpio output (provided it is configured as GPIO)") | ||
19 | hh:add("* muxsel(x) set pin function to x, which can be an integer or one of: MAIN, ALT1, ALT2, GPIO") | ||
20 | |||
21 | function STMP.pinctrl.pin(bank,pin) | ||
22 | local t = { | ||
23 | read = function() | ||
24 | return bit32.extract(HW.PINCTRL.DINn[bank].read(), pin) | ||
25 | end, | ||
26 | |||
27 | write = function(val) | ||
28 | if val then t.set() else t.clr() end | ||
29 | end, | ||
30 | |||
31 | set = function() | ||
32 | HW.PINCTRL.DOUTn[bank].set(bit32.lshift(1, pin)) | ||
33 | end, | ||
34 | |||
35 | clr = function() | ||
36 | HW.PINCTRL.DOUTn[bank].clr(bit32.lshift(1, pin)) | ||
37 | end, | ||
38 | |||
39 | enable = function() | ||
40 | HW.PINCTRL.DOEn[bank].set(bit32.lshift(1, pin)) | ||
41 | end, | ||
42 | |||
43 | disable = function() | ||
44 | HW.PINCTRL.DOEn[bank].clr(bit32.lshift(1, pin)) | ||
45 | end, | ||
46 | |||
47 | muxsel = function(x) | ||
48 | if type(x) == "string" then | ||
49 | if x == "MAIN" then x = 0 | ||
50 | elseif x == "ALT1" then x = 1 | ||
51 | elseif x == "ALT2" then x = 2 | ||
52 | elseif x == "GPIO" then x = 3 | ||
53 | else error("Invalid muxsel string " .. x) end | ||
54 | end | ||
55 | local v = nil | ||
56 | if STMP.is_stmp3600() then | ||
57 | if pin < 16 then | ||
58 | v = HW.PINCTRL.MUXSELLn[bank] | ||
59 | else | ||
60 | v = HW.PINCTRL.MUXSELHn[bank] | ||
61 | end | ||
62 | else | ||
63 | v = HW.PINCTRL.MUXSELn[2 * bank + math.floor(pin / 16)] | ||
64 | end | ||
65 | v.write(bit32.replace(v.read(), x, (pin % 16) * 2, 2)) | ||
66 | end | ||
67 | } | ||
68 | return t | ||
69 | end | ||
70 | |||
71 | hh = h:create_topic("configure") | ||
72 | hh:add("The STMP.pinctrl.configure(tbl) function configures pins according to a table.") | ||
73 | hh:add("The table must contain a list of subtable, each corresponding to a pin.") | ||
74 | hh:add("Each subtable can configure one or more aspects of a specific pin.") | ||
75 | hh:add("The following characteristics are understood:") | ||
76 | hh:add("* bank: pin bank (mandatory)") | ||
77 | hh:add("* pin: pin number (mandatory) ") | ||
78 | hh:add("* muxsel: same values as STMP.pinctrl.pin().muxsel (optional)") | ||
79 | hh:add("* enable: enable/disable output (optional)") | ||
80 | hh:add("* output: set/clear output (optional)") | ||
81 | hh:add("All non-subtable entries are ignored") | ||
82 | hh:add("All unknown parameters in subtablkes are ignored") | ||
83 | hh:add("") | ||
84 | hh:add("Example:") | ||
85 | hh:add("STMP.pinctrl.configure({{bank=0,pin=1,muxsel=\"GPIO\",enable=false},{bank=0,pin=2,muxsel=\"MAIN\"}})") | ||
86 | |||
87 | function STMP.pinctrl.configure(tbl) | ||
88 | if type(tbl) ~= "table" then error("Parameter must be a table") end | ||
89 | for i,v in pairs(tbl) do | ||
90 | if type(v) == "table" then | ||
91 | if v.bank ~= nil and v.pin ~= nil then | ||
92 | local pin = STMP.pinctrl.pin(v.bank,v.pin) | ||
93 | if v.muxsel ~= nil then | ||
94 | STMP.debug(string.format("cfg B%dP%02d muxsel %s", v.bank, v.pin, v.muxsel)) | ||
95 | pin.muxsel(v.muxsel) | ||
96 | end | ||
97 | if v.enable ~= nil then | ||
98 | STMP.debug(string.format("cfg B%dP%02d enable %s", v.bank, v.pin, v.enable)) | ||
99 | if v.enable then pin.enable() | ||
100 | else pin.disable() end | ||
101 | end | ||
102 | if v.output ~= nil then | ||
103 | STMP.debug(string.format("cfg B%dP%02d output %s", v.bank, v.pin, v.output)) | ||
104 | if v.output then pin.set() | ||
105 | else pin.clr() end | ||
106 | end | ||
107 | end | ||
108 | end | ||
109 | end | ||
110 | end | ||
111 | |||
112 | hh = h:create_topic("configure_ex") | ||
113 | hh:add("The STMP.pinctrl.configure_ex(tbl) function configures pins according to a table.") | ||
114 | hh:add("It is an enhanced version of configure which handles the different families and packages.") | ||
115 | hh:add("The argument must be a table with one entry per STMP family.") | ||
116 | hh:add("Each entry must a subtable with one subentry per package.") | ||
117 | hh:add("Each subentry must be a valid argument to STMP.pinctrl.configure().") | ||
118 | hh:add("The family names are the one returned by STMP.family.") | ||
119 | hh:add("The table can also contain an entry \"all\" which apply to all families") | ||
120 | hh:add("The package names are the one returned by STMP.digctl.package().") | ||
121 | hh:add("The table can also contain an entry \"all\" which apply to all packages.") | ||
122 | |||
123 | function STMP.pinctrl.configure_ex(tbl) | ||
124 | if type(tbl) ~= "table" then error("Parameter must be a table") end | ||
125 | local pack = STMP.digctl.package() | ||
126 | if tbl[STMP.family] ~= nil then | ||
127 | if tbl[STMP.family][pack] ~= nil then STMP.pinctrl.configure(tbl[STMP.family][pack]) end | ||
128 | if tbl[STMP.family]["all"] ~= nil then STMP.pinctrl.configure(tbl[STMP.family]["all"]) end | ||
129 | end | ||
130 | if tbl["all"] ~= nil then | ||
131 | if tbl["all"][pack] ~= nil then STMP.pinctrl.configure(tbl["all"][pack]) end | ||
132 | if tbl["all"]["all"] ~= nil then STMP.pinctrl.configure(tbl["all"]["all"]) end | ||
133 | end | ||
134 | end | ||
135 | |||
136 | hh = h:create_topic("lcdif") | ||
137 | hh:add("The STMP.pinctrl.lcdif tables provides some high level routines to configure the pins.") | ||
138 | hh:add("It is specialised to configure the LCDIF pins correctly.") | ||
139 | hh:add("Some of the modes may not be available on all STMP families.") | ||
140 | |||
141 | STMP.pinctrl.lcdif = {} | ||
142 | |||
143 | local hhh = hh:create_topic("setup_system") | ||
144 | hhh:add("The STMP.pinctrl.lcdif.setup_system(bus_width,busy) functions configure the LCDIF pins.") | ||
145 | hhh:add("It only take cares of the pins used in system mode and for a specified bus width.") | ||
146 | hhh:add("The handled bus widths are 8, 16 and 18") | ||
147 | hhh:add("The busy pin is configured only if busy is true") | ||
148 | |||
149 | function STMP.pinctrl.lcdif.setup_system(bus_width, busy) | ||
150 | local common = | ||
151 | { | ||
152 | stmp3600 = | ||
153 | { | ||
154 | all = | ||
155 | { | ||
156 | lcd_reset = { bank = 1, pin = 16, muxsel = "MAIN"}, | ||
157 | lcd_rs = { bank = 1, pin = 17, muxsel = "MAIN"}, | ||
158 | lcd_wr = { bank = 1, pin = 18, muxsel = "MAIN"}, | ||
159 | lcd_cs = { bank = 1, pin = 19, muxsel = "MAIN"}, | ||
160 | lcd_d0 = {bank = 1, pin = 0, muxsel = "MAIN"}, | ||
161 | lcd_d1 = {bank = 1, pin = 1, muxsel = "MAIN"}, | ||
162 | lcd_d2 = {bank = 1, pin = 2, muxsel = "MAIN"}, | ||
163 | lcd_d3 = {bank = 1, pin = 3, muxsel = "MAIN"}, | ||
164 | lcd_d4 = {bank = 1, pin = 4, muxsel = "MAIN"}, | ||
165 | lcd_d5 = {bank = 1, pin = 5, muxsel = "MAIN"}, | ||
166 | lcd_d6 = {bank = 1, pin = 6, muxsel = "MAIN"}, | ||
167 | lcd_d7 = {bank = 1, pin = 7, muxsel = "MAIN"} | ||
168 | } | ||
169 | }, | ||
170 | stmp3700 = | ||
171 | { | ||
172 | all = | ||
173 | { | ||
174 | lcd_reset = { bank = 1, pin = 16, muxsel = "MAIN"}, | ||
175 | lcd_rs = { bank = 1, pin = 17, muxsel = "MAIN"}, | ||
176 | lcd_wr = { bank = 1, pin = 18, muxsel = "MAIN"}, | ||
177 | lcd_rd = { bank = 1, pin = 19, muxsel = "MAIN"}, | ||
178 | lcd_cs = { bank = 1, pin = 20, muxsel = "MAIN"}, | ||
179 | lcd_d0 = {bank = 1, pin = 0, muxsel = "MAIN"}, | ||
180 | lcd_d1 = {bank = 1, pin = 1, muxsel = "MAIN"}, | ||
181 | lcd_d2 = {bank = 1, pin = 2, muxsel = "MAIN"}, | ||
182 | lcd_d3 = {bank = 1, pin = 3, muxsel = "MAIN"}, | ||
183 | lcd_d4 = {bank = 1, pin = 4, muxsel = "MAIN"}, | ||
184 | lcd_d5 = {bank = 1, pin = 5, muxsel = "MAIN"}, | ||
185 | lcd_d6 = {bank = 1, pin = 6, muxsel = "MAIN"}, | ||
186 | lcd_d7 = {bank = 1, pin = 7, muxsel = "MAIN"} | ||
187 | } | ||
188 | } | ||
189 | } | ||
190 | local bus8_15 = | ||
191 | { | ||
192 | stmp3600 = | ||
193 | { | ||
194 | all = | ||
195 | { | ||
196 | lcd_d8 = {bank = 1, pin = 8, muxsel = "MAIN"}, | ||
197 | lcd_d9 = {bank = 1, pin = 9, muxsel = "MAIN"}, | ||
198 | lcd_d10 = {bank = 1, pin = 10, muxsel = "MAIN"}, | ||
199 | lcd_d11 = {bank = 1, pin = 11, muxsel = "MAIN"}, | ||
200 | lcd_d12 = {bank = 1, pin = 12, muxsel = "MAIN"}, | ||
201 | lcd_d13 = {bank = 1, pin = 13, muxsel = "MAIN"}, | ||
202 | lcd_d14 = {bank = 1, pin = 14, muxsel = "MAIN"}, | ||
203 | lcd_d15 = {bank = 1, pin = 15, muxsel = "MAIN"} | ||
204 | } | ||
205 | }, | ||
206 | stmp3700 = | ||
207 | { | ||
208 | all = | ||
209 | { | ||
210 | lcd_d8 = {bank = 1, pin = 8, muxsel = "MAIN"}, | ||
211 | lcd_d9 = {bank = 1, pin = 9, muxsel = "MAIN"}, | ||
212 | lcd_d10 = {bank = 1, pin = 10, muxsel = "MAIN"}, | ||
213 | lcd_d11 = {bank = 1, pin = 11, muxsel = "MAIN"}, | ||
214 | lcd_d12 = {bank = 1, pin = 12, muxsel = "MAIN"}, | ||
215 | lcd_d13 = {bank = 1, pin = 13, muxsel = "MAIN"}, | ||
216 | lcd_d14 = {bank = 1, pin = 14, muxsel = "MAIN"}, | ||
217 | lcd_d15 = {bank = 1, pin = 15, muxsel = "MAIN"} | ||
218 | } | ||
219 | } | ||
220 | } | ||
221 | local bus16_17 = | ||
222 | { | ||
223 | |||
224 | } | ||
225 | local busy_pin = | ||
226 | { | ||
227 | stmp3600 = | ||
228 | { | ||
229 | all = | ||
230 | { | ||
231 | lcd_busy = { bank = 1, pin = 21, muxsel = "MAIN"}, | ||
232 | } | ||
233 | }, | ||
234 | stmp3700 = | ||
235 | { | ||
236 | all = | ||
237 | { | ||
238 | lcd_busy = { bank = 1, pin = 21, muxsel = "MAIN"}, | ||
239 | } | ||
240 | }, | ||
241 | } | ||
242 | |||
243 | STMP.pinctrl.configure_ex(common) | ||
244 | if bus_width > 8 then | ||
245 | STMP.pinctrl.configure_ex(bus8_15) | ||
246 | end | ||
247 | if bus_width > 16 then | ||
248 | STMP.pinctrl.configure_ex(bus16_17) | ||
249 | end | ||
250 | if busy then | ||
251 | STMP.pinctrl.configure_ex(busy_pin) | ||
252 | end | ||
253 | end | ||
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 | ||