-
-
Notifications
You must be signed in to change notification settings - Fork 345
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
Implement HardwarePWM class for Rp2040 and update Basic PWM sample #2908
Conversation
ea80d94
to
26c5cdd
Compare
Let's build succeed but requires implementing.
Clarify what DUTY means, it's not immediately obvious and the term is used extensively.
Accommodates variable-length pin lists
71b25a9
to
ec644fc
Compare
@pljakobs This PR updates the Basic_HwPWM sample which I know you were intending to do, but wanted to get Rp2040 support in there first. Would you have a look and let me know if you'd like any changes? |
// Not implemented | ||
} | ||
|
||
uint32_t HardwarePWM::getFrequency(uint8_t pin) const |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I note we can get the frequency for an individual pin, added for esp32 support I believe, but no corresponding setFrequency
or setPeriod
for a pin. We should either do that or get rid of the pin
parameter I think.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the way it's currently implemented for the esp32 is that the frequency is global, not per pin.
While the esp32 platform can set the frequency per timer (of which it has up to eight, depending on the actual Soc), timers are mapped to Pins and there can be more pins than timers.
Getting the frequency for a sigle pin, with the current implementation, makes indeed no sense.
I think this is something that should be part of an extended implementation that exposes the better hardware of the esp32 and rp2040 platforms.
On the BasicHWPwm, I have something that works a bit better for me. I'll clean it up and push it in the next days (I'm travelling right now)
@mikee47 Is this PR ready for merging? |
I have no additional edits right now. |
Yes, I'm all done thanks. |
The
Basic_HwPWM
sample should work for all architectures. Esp32 is fixed but Rp2040 requires an implementation so may as well do that here.Note that as with the Esp32, the Rp2040 PWM hardware is much more capable than the
HardwarePWM
class allows, but it is an easy way to port existing code and get started.TODO: