!drivers/pwm: remove PWM_MULTICHAN option#18864
Open
raiden00pl wants to merge 1 commit into
Open
Conversation
Member
Author
|
CI run with nuttx-apps branch is here: https://github.com/raiden00pl/manual-nuttx-ci/actions/runs/25676150035 |
Contributor
|
@raiden00pl please fix: |
xiaoxiang781216
previously approved these changes
May 11, 2026
jerpelea
previously approved these changes
May 11, 2026
michallenc
reviewed
May 11, 2026
Contributor
michallenc
left a comment
There was a problem hiding this comment.
so far LGTM, I can test on SAMv7 later today.
acassis
previously approved these changes
May 11, 2026
4c46b05 to
95fef1f
Compare
michallenc
previously approved these changes
May 12, 2026
Contributor
michallenc
left a comment
There was a problem hiding this comment.
Tested on SAMv7, all looks good.
linguini1
reviewed
May 12, 2026
| pwminfo("TIM%u channel: %u duty: %08" PRIx32 "\n", | ||
| priv->timid, channel, duty); | ||
|
|
||
| #ifndef CONFIG_PWM_MULTICHAN |
Contributor
There was a problem hiding this comment.
Maybe we can change this to #if CONFIG_PWM_NCHAN == 1
Member
Author
There was a problem hiding this comment.
optimizing such a simple case is a matter for the compiler. when CONFIG_PWM_NCHANNELS=1 this code should be easy to optimise:
for (i = 0; ret == OK && i < CONFIG_PWM_NCHANNELS; i++)
{
/* Break the loop if all following channels are not configured */
if (info->channels[i].channel == -1)
{
break;
}
/* Set output if channel configured */
if (info->channels[i].channel != 0)
{
ret = pwm_duty_update(dev, info->channels[i].channel,
info->channels[i].duty);
}
}
| uint32_t ch2_pin; /* Channel 3 pin */ | ||
| uint32_t ch3_pin; /* Channel 4 pin */ | ||
| #ifndef CONFIG_PWM_MULTICHAN | ||
| uint8_t channel; /* Assigned channel */ |
Contributor
There was a problem hiding this comment.
For such things is it worth keeping the optimization by checking CONFIG_PWM_NCHAN > 1?
| pwminfo("TIM%u channel: %u duty: %08" PRIx32 "\n", | ||
| priv->timid, channel, duty); | ||
|
|
||
| #ifndef CONFIG_PWM_MULTICHAN |
| #endif | ||
|
|
||
| DEBUGASSERT(info->frequency > 0); | ||
| #ifndef CONFIG_PWM_MULTICHAN |
| pwminfo("TIM%u channel: %u duty: %08" PRIx32 "\n", | ||
| priv->timid, channel, duty); | ||
|
|
||
| #ifndef CONFIG_PWM_MULTICHAN |
| pwminfo("TIM%u channel: %u duty: %08" PRIx32 "\n", | ||
| priv->timid, channel, duty); | ||
|
|
||
| #ifndef CONFIG_PWM_MULTICHAN |
BREAKING CHANGE: remove PWM_MULTICHAN option PWM_MULTICHAN option is redundant, we can just set CONFIG_PWM_NCHANNELS > 1. At default CONFIG_PWM_NCHANNELS is set to 1, so the default behavior is preserved. Access to single channel API is now `info->channels[0].XXX` instead of `info->XXX` This is the first step to simplify PWM implementation and make it more portable. Signed-off-by: raiden00pl <raiden00@railab.me>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
BREAKING CHANGE: remove PWM_MULTICHAN option
PWM_MULTICHAN option is redundant, we can just set CONFIG_PWM_NCHANNELS > 1. This is the first step to simplify PWM implementation and make it more portable.
apps part apache/nuttx-apps#3475
Impact
simplify API, no functional changes. old
CONFIG_PWM_MULTICHAN=nis now achieved withCONFIG_PWM_NCHANNELS = 1Testing
CI