Expose API for count of used/free channels
This commit is contained in:
1 parent
2981565830
commit
b4d777f7f3
2 files changed
+22
No files matched your search
@@ -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();
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in new issue
Block a user