-
Notifications
You must be signed in to change notification settings - Fork 6.7k
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
Refactor STM32 PWM driver using LL API #24569
Refactor STM32 PWM driver using LL API #24569
Conversation
All checks are passing now. checkpatch (informational only, not a failure)
Tip: The bot edits this comment instead of posting a new one, so you can check the comment's history to see earlier messages. |
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.
This PR is ambitious has it encompass 2 major changes: Boards Kconfig to dts transition and conversion to LL, plus and additional rather unrelated change (polarity support).
Please split these 3 changes to individual PRs.
Regarding the Kconfig to dts transition, I think the node labeling sound like the best option:
timers1: timers@40012c00 {
compatible = "st,stm32-timers";
{...}
pmw1: pwm@1 {
compatible = "st,stm32-pwm";
status = "disabled";
st,prescaler = <10000>;
label = "PWM_1";
#pwm-cells = <2>;
};
Besides, it would help getting rid of the paths in following expressions:
green_pwm_led: green_pwm_led {
pwms = <&{/soc/timers@40000000/pwm} 1 4>;
@erwango I have rebased this PR now that PWM uses DT. I have splitted it in two commits, the first one is the refactor and the second the addition of the polarity flag support. I can split it into 2 PRs, not sure if needed, though. |
|
||
pwm-cells: | ||
- channel | ||
# period in terms of nanoseconds | ||
- period | ||
- flags |
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.
flags is either PWM_POLARITY_NORMAL
or PWM_POLARITY_INVERTED
, correct ?
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.
Yes, they're defined #include <dt-bindings/pwm/pwm.h>
. I guess that flags could potentially be used for other purposes in the future.
@erwango ping |
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.
Txs for this welcome change.
Some comments, but otherwise it's fine to me.
The PWM drivers has been refactored using the HAL LL API. Not only that, but the set pin_set function is now faster, as channel output compare is just initialized if needed. NOTE: Has been tested using H743zi board for now. Signed-off-by: Gerard Marull-Paretas <[email protected]>
Add support for the polarity flag in the STM32 PWM driver. STM32 boards using PWM have been updated accordingly. Signed-off-by: Gerard Marull-Paretas <[email protected]>
I'm sorry if this is the wrong section but that is my first time contributing to Zephyr.
The PWM_POLARITY_MASK set to 0<<0 forces the if statement to always be false. My recommendation would either be to change the defines in dt-bindings/pwm/pwm.h to:
Doing this fix has proven correct behavior of PWM polarity on my Nucleo64 board. |
The PWM driver has been refactored using the HAL LL API. Not only that, but the set pin_set function is now faster, as channel output compare is just initialized if needed.
Support for the polarity flag has also been added to the STM32 PWM driver. STM32 boards using PWM have been updated accordingly.
Fixes #23629