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 PWM support for Renesas RA8 board #76140

Merged
merged 3 commits into from
Oct 11, 2024

Conversation

duynguyenxa
Copy link
Member

@duynguyenxa duynguyenxa commented Jul 21, 2024

This PR add PWM driver support for Renesas RA8 board, it's using GPT hardware

@zephyrbot
Copy link
Collaborator

zephyrbot commented Jul 21, 2024

The following west manifest projects have been modified in this Pull Request:

Name Old Revision New Revision Diff

Note: This message is automatically posted and updated by the Manifest GitHub Action.

@zephyrbot zephyrbot added manifest manifest-hal_renesas DNM This PR should not be merged (Do Not Merge) labels Jul 21, 2024
@ydamigos ydamigos added the platform: Renesas RA Renesas Electronics Corporation, RA label Jul 25, 2024
@zephyrbot zephyrbot removed the DNM This PR should not be merged (Do Not Merge) label Sep 6, 2024
@duynguyenxa duynguyenxa marked this pull request as ready for review September 11, 2024 10:56
@zephyrbot zephyrbot added the area: PWM Pulse Width Modulation label Sep 11, 2024
@duynguyenxa duynguyenxa changed the title Add PWM support for Renesas EK RA8M1 board Add PWM support for Renesas RA8 board Sep 30, 2024
thaoluonguw
thaoluonguw previously approved these changes Oct 1, 2024
soburi
soburi previously approved these changes Oct 1, 2024
KhiemNguyenT
KhiemNguyenT previously approved these changes Oct 3, 2024
drivers/pwm/pwm_renesas_ra8.c Outdated Show resolved Hide resolved
drivers/pwm/pwm_renesas_ra8.c Outdated Show resolved Hide resolved
#if GPT_CFG_OUTPUT_SUPPORT_ENABLE

/* Check if custom GTIOR settings are provided. */
if (0 == p_extend->gtior_setting.gtior) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (0 == p_extend->gtior_setting.gtior) {
if (p_extend->gtior_setting.gtior == 0) {

I think I know what's behind the inverted condition but that's very unusual in the Zephyr code base and just makes the codde look unfamiliar.

Same for the others below.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I updated it, thanks

drivers/pwm/pwm_renesas_ra8.c Outdated Show resolved Hide resolved
Comment on lines 92 to 73
#if GPT_PRV_EXTRA_FEATURES_ENABLED == GPT_CFG_OUTPUT_SUPPORT_ENABLE
else if (p_cfg->mode >= TIMER_MODE_TRIANGLE_WAVE_SYMMETRIC_PWM) {
gtion = GPT_PRV_GTIO_TOGGLE_COMPARE_MATCH;
}
#endif
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should really be a switch (p_cfg->mode)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your comment but I think we have nested if else conditions here, and greater comparison as well. Could we use if else condition for more resonable?

Copy link
Member

@fabiobaltieri fabiobaltieri Oct 4, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see, alright it's just that it's very hard to follow these "else if" broken by the precompiler directives

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how about: could you make a separate functoin that gets p_cfg->mode as an input and returns the gtion value? Then you can have intermediate returns and you should be able to avoid the split if-else I think

Copy link
Contributor

@quytranpzz quytranpzz Oct 8, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@fabiobaltieri: Sorry for the late response.
Actually we use only TIMER_MODE_PWM mode on PWM driver with our GPT hardware. For some reason, we defined this function with multiple modes, but to avoid confusion, I removed the others, only define1 value gtion for TIMER_MODE_PWM here. Thanks again for your comments.

drivers/pwm/pwm_renesas_ra8.c Outdated Show resolved Hide resolved
drivers/pwm/pwm_renesas_ra8.c Outdated Show resolved Hide resolved
drivers/pwm/pwm_renesas_ra8.c Outdated Show resolved Hide resolved
drivers/pwm/pwm_renesas_ra8.c Outdated Show resolved Hide resolved
drivers/pwm/pwm_renesas_ra8.c Outdated Show resolved Hide resolved
drivers/pwm/pwm_renesas_ra8.c Outdated Show resolved Hide resolved
drivers/pwm/pwm_renesas_ra8.c Outdated Show resolved Hide resolved
drivers/pwm/pwm_renesas_ra8.c Outdated Show resolved Hide resolved
duynguyenxa and others added 3 commits October 8, 2024 14:29
Add PWM driver code support for RA8. This support is using
GPT HW

Signed-off-by: Duy Phuong Hoang. Nguyen <duy.nguyen.xa@renesas.com>
Add support for PWM driver on MCK-RA8T1

Signed-off-by: Quy Tran <quy.tran.pz@renesas.com>
Add support for PWM driver on EK-RA8D1

Signed-off-by: Quy Tran <quy.tran.pz@renesas.com>
@KhiemNguyenT KhiemNguyenT self-requested a review October 11, 2024 06:31
@KhiemNguyenT KhiemNguyenT added this to the v4.0.0 milestone Oct 11, 2024
@carlescufi carlescufi merged commit 4793e00 into zephyrproject-rtos:main Oct 11, 2024
26 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: PWM Pulse Width Modulation platform: Renesas RA Renesas Electronics Corporation, RA
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants