Skip to content

!drivers: separate pulse count from PWM driver#18916

Draft
raiden00pl wants to merge 14 commits into
apache:masterfrom
raiden00pl:nuttx_pwm_pulse_refactor
Draft

!drivers: separate pulse count from PWM driver#18916
raiden00pl wants to merge 14 commits into
apache:masterfrom
raiden00pl:nuttx_pwm_pulse_refactor

Conversation

@raiden00pl
Copy link
Copy Markdown
Member

@raiden00pl raiden00pl commented May 20, 2026

Summary

BREAKING CHANGE: separate pulse count feature from PWM driver.

Coupling PWM driver with pulse count feature was bad decision from the beginning, these are two different things:

  • PWM is a modulation scheme: it continuously represents a value by varying duty cycle, usually at a fixed frequency.
  • Pulse train generation is a finite waveform transaction: generate N edges/pulses with selected timing, then complete.

This change introduce a new pulse count driver with new API. Now user can generate pulse train by providing:

  • high pulse length in ns
  • low pulse length in ns
  • pulse count

All architectures supporting pulse count have been modified.

Dependency-for: apache/nuttx-apps#3490.

Impact

Breaking change. Users must migrate their code to use the new driver with new API.

Testing

TODO: I can test on stm32 archs. All stm32 and at32 are based on the same stm32 driver. I'll add it later.

Help with tests would be useful for tivia and tlsr82 boards.

stm32c0 with PWM in background and pulse count train for 1 sec:

image

raiden00pl added 11 commits May 20, 2026 10:25
BREAKING CHANGE: separate pulse count feature from PWM driver.

Coupling PWM driver with pulse count feature was bad decision from the beginning,
these are two different things:

- PWM is a modulation scheme: it continuously represents a value by varying duty
cycle, usually at a fixed frequency.
- Pulse train generation is a finite waveform transaction: generate N edges/pulses
with selected timing, then complete.

This change introduce a new pulse count driver with new API.
Now user can generate pulse train by providing:

- high pulse length in ns
- low pulse length in ns
- pulse count

All architectures supporting pulse count have been adapted in subsequent commits.
Users must migrate their code to use the new driver with new API.

Signed-off-by: raiden00pl <raiden00@railab.me>
BREAKING CHANGE: separate pulse count from PWM driver

Pulse count handling was removed from PWM driver and moved to a separate driver.
For details about this change, look at previous commit.

Signed-off-by: raiden00pl <raiden00@railab.me>
BREAKING CHANGE: separate pulse count from PWM driver

Pulse count handling was removed from PWM driver and moved to a separate driver.
For details about this change, look at previous commit.

Signed-off-by: raiden00pl <raiden00@railab.me>
BREAKING CHANGE: separate pulse count from PWM driver

Pulse count handling was removed from PWM driver and moved to a separate driver.
For details about this change, look at previous commit.

Signed-off-by: raiden00pl <raiden00@railab.me>
BREAKING CHANGE: separate pulse count from PWM driver

Pulse count handling was removed from PWM driver and moved to a separate driver.
For details about this change, look at previous commit.

Signed-off-by: raiden00pl <raiden00@railab.me>
BREAKING CHANGE: separate pulse count from PWM driver

Pulse count handling was removed from PWM driver and moved to a separate driver.
For details about this change, look at previous commit.

Signed-off-by: raiden00pl <raiden00@railab.me>
BREAKING CHANGE: separate pulse count from PWM driver

Pulse count handling was removed from PWM driver and moved to a separate driver.
For details about this change, look at previous commit.

Signed-off-by: raiden00pl <raiden00@railab.me>
BREAKING CHANGE: separate pulse count from PWM driver

Pulse count handling was removed from PWM driver and moved to a separate driver.
For details about this change, look at previous commit.

Signed-off-by: raiden00pl <raiden00@railab.me>
BREAKING CHANGE: separate pulse count from PWM driver

Pulse count handling was removed from PWM driver and moved to a separate driver.
For details about this change, look at previous commit.

Signed-off-by: raiden00pl <raiden00@railab.me>
BREAKING CHANGE: separate pulse count from PWM driver

Pulse count handling was removed from PWM driver and moved to a separate driver.
For details about this change, look at previous commit.

Signed-off-by: raiden00pl <raiden00@railab.me>
remove PULSECOUNT references from PWM drivers that not implemet PWM feature.
PULSECOUNT for these architectures was not implemented, so we just remove all references to it.

Signed-off-by: raiden00pl <raiden00@railab.me>
Comment thread drivers/timers/pulsecount.c
@github-actions github-actions Bot added Arch: arm Issues related to ARM (32-bit) architecture Arch: risc-v Issues related to the RISC-V (32-bit or 64-bit) architecture Area: Drivers Drivers issues Size: XL The size of the change in this PR is very large. Consider breaking down the PR into smaller pieces. labels May 20, 2026
add pulse count example for nucleo-h743zi2

Signed-off-by: raiden00pl <raiden00@railab.me>
add pulse count example for nucleo-f446re

Signed-off-by: raiden00pl <raiden00@railab.me>
add pulse count example for nucleo-c092rc

Signed-off-by: raiden00pl <raiden00@railab.me>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Arch: arm Issues related to ARM (32-bit) architecture Arch: risc-v Issues related to the RISC-V (32-bit or 64-bit) architecture Area: Drivers Drivers issues Board: arm Size: XL The size of the change in this PR is very large. Consider breaking down the PR into smaller pieces.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants