Skip to content

Commit 10a9af5

Browse files
authored
Merge pull request #93 from burbankb/master
Allow HardwarePWM::addPin method to return true if _count == MAX_CHAN…
2 parents 49568c0 + e61fbe9 commit 10a9af5

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

cores/nRF5/HardwarePWM.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,14 +78,20 @@ void HardwarePWM::setClockDiv(uint8_t div)
7878
*/
7979
bool HardwarePWM::addPin(uint8_t pin)
8080
{
81-
VERIFY( isPinValid(pin) && (_count < MAX_CHANNELS) );
81+
VERIFY( isPinValid(pin) && (_count <= MAX_CHANNELS) );
8282

8383
// Check if pin is already configured
8484
for(uint8_t i=0; i<_count; i++)
8585
{
8686
if (_pwm->PSEL.OUT[i] == pin) return true;
8787
}
8888

89+
if ((_count >= MAX_CHANNELS))
90+
{
91+
//Pin not already configured, but this HardwarePWM is full
92+
return false;
93+
}
94+
8995
pinMode(pin, OUTPUT);
9096
digitalWrite(pin, LOW);
9197

0 commit comments

Comments
 (0)