Skip to content

Commit

Permalink
Merge pull request #760 from jgartrel/master
Browse files Browse the repository at this point in the history
Add helper functions to HwPWM Instance
  • Loading branch information
hathach authored Jun 27, 2023
2 parents 357fa90 + 27b0c34 commit fb4eb52
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
9 changes: 9 additions & 0 deletions cores/nRF5/HardwarePWM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,15 @@ bool HardwarePWM::removePin(uint8_t pin)
return true;
}

bool HardwarePWM::removeAllPins(void)
{
for(int ch=0; ch<MAX_CHANNELS; ch++)
{
_set_psel(ch, 0xFFFFFFFFUL);
}
return true;
}

bool HardwarePWM::writeChannel(uint8_t ch, uint16_t value, bool inverted)
{
VERIFY( ch < MAX_CHANNELS );
Expand Down
3 changes: 3 additions & 0 deletions cores/nRF5/HardwarePWM.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,9 @@ class HardwarePWM
// Remove a pin from PWM module
bool removePin (uint8_t pin);

// Remove all pins from PWM module
bool removeAllPins (void);

// Get the mapped channel of a pin
int pin2channel(uint8_t pin) const
{
Expand Down

0 comments on commit fb4eb52

Please sign in to comment.