File tree Expand file tree Collapse file tree 2 files changed +22
-0
lines changed Expand file tree Collapse file tree 2 files changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -218,3 +218,21 @@ uint16_t HardwarePWM::readChannel(uint8_t ch)
218
218
return (_seq0[ch] & 0x7FFF );
219
219
}
220
220
221
+ uint8_t HardwarePWM::usedChannelCount (void )
222
+ {
223
+ uint8_t usedChannels = 0 ;
224
+ for (int i=0 ; i<MAX_CHANNELS; i++)
225
+ {
226
+ if ( _pwm->PSEL .OUT [i] & PWM_PSEL_OUT_CONNECT_Msk )
227
+ {
228
+ usedChannels++;
229
+ }
230
+ }
231
+ return usedChannels;
232
+ }
233
+
234
+ uint8_t HardwarePWM::freeChannelCount (void )
235
+ {
236
+ return MAX_CHANNELS - usedChannelCount ();
237
+ }
238
+
Original file line number Diff line number Diff line change @@ -96,6 +96,10 @@ class HardwarePWM
96
96
// Read current set value
97
97
uint16_t readPin (uint8_t pin);
98
98
uint16_t readChannel (uint8_t ch);
99
+
100
+ // Get count of used / free channels
101
+ uint8_t usedChannelCount ();
102
+ uint8_t freeChannelCount ();
99
103
};
100
104
101
105
extern HardwarePWM HwPWM0;
You can’t perform that action at this time.
0 commit comments