Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add helper functions to HwPWM Instance #760

Merged
merged 4 commits into from
Jun 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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