File tree 1 file changed +44
-0
lines changed
1 file changed +44
-0
lines changed Original file line number Diff line number Diff line change
1
+ /*
2
+
3
+ PWM MODULE
4
+
5
+ Copyright (C) 2019-2022 by Maxim Prokhorov <prokhorov dot max at outlook dot com>
6
+
7
+ */
8
+
9
+ #pragma once
10
+
11
+ #include < cstddef>
12
+ #include < cstdint>
13
+
14
+ // Associate list of PINs with CHANNELs
15
+ bool pwmInitPins (const uint8_t * begin, const uint8_t * end);
16
+
17
+ template <typename T>
18
+ bool pwmInitPins (const T& pins) {
19
+ return pwmInitPins (pins.data (), pins.data () + pins.size ());
20
+ }
21
+
22
+ // PWM driver accepts certain value range
23
+ struct PwmRange {
24
+ uint32_t min;
25
+ uint32_t max;
26
+ };
27
+
28
+ // u32 values accepted by pwmDuty()
29
+ PwmRange pwmRange ();
30
+
31
+ // Number of configured PWM channels
32
+ size_t pwmChannels ();
33
+
34
+ // Update specific channel with raw value (see pwmRange())
35
+ void pwmDuty (size_t channel, uint32_t duty);
36
+
37
+ // Or, using a percentage value
38
+ void pwmDuty (size_t channel, float duty);
39
+
40
+ // Apply all channel duty values
41
+ void pwmUpdate ();
42
+
43
+ // Configure driver. Should be called *before* initializing any pins.
44
+ void pwmSetup ();
You can’t perform that action at this time.
0 commit comments