Skip to content

Commit a95d23e

Browse files
committed
Add removeAllPins to HwPWM instance
Given that no function exists to enumerate added pins, this allows for the HwPWM instance to be completely reset.
1 parent 0ea975e commit a95d23e

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

cores/nRF5/HardwarePWM.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,15 @@ bool HardwarePWM::removePin(uint8_t pin)
205205
return true;
206206
}
207207

208+
bool HardwarePWM::removeAllPins(void)
209+
{
210+
for(int ch=0; ch<MAX_CHANNELS; ch++)
211+
{
212+
_set_psel(ch, 0xFFFFFFFFUL);
213+
}
214+
return true;
215+
}
216+
208217
bool HardwarePWM::writeChannel(uint8_t ch, uint16_t value, bool inverted)
209218
{
210219
VERIFY( ch < MAX_CHANNELS );

cores/nRF5/HardwarePWM.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,9 @@ class HardwarePWM
9494
// Remove a pin from PWM module
9595
bool removePin (uint8_t pin);
9696

97+
// Remove all pins from PWM module
98+
bool removeAllPins (void);
99+
97100
// Get the mapped channel of a pin
98101
int pin2channel(uint8_t pin) const
99102
{

0 commit comments

Comments
 (0)