Expose API for count of used/free channels

This commit is contained in:
Henry Gabryjelski committed 2020-07-28 23:05:09 -07:00
1 parent 2981565830
commit b4d777f7f3
2 files changed
+22

No files matched your search

+18
View File
@@ -218,3 +218,21 @@ uint16_t HardwarePWM::readChannel(uint8_t ch)
return (_seq0[ch] & 0x7FFF);
}
uint8_t HardwarePWM::usedChannelCount(void)
{
uint8_t usedChannels = 0;
for(int i=0; i<MAX_CHANNELS; i++)
{
if ( _pwm->PSEL.OUT[i] & PWM_PSEL_OUT_CONNECT_Msk )
{
usedChannels++;
}
}
return usedChannels;
}
uint8_t HardwarePWM::freeChannelCount(void)
{
return MAX_CHANNELS - usedChannelCount();
}
+4
View File
@@ -96,6 +96,10 @@ class HardwarePWM
// Read current set value
uint16_t readPin (uint8_t pin);
uint16_t readChannel (uint8_t ch);
// Get count of used / free channels
uint8_t usedChannelCount();
uint8_t freeChannelCount();
};
extern HardwarePWM HwPWM0;