Skip to content

RFC: drivers: pwm: add functions for capturing pwm pulse width and period #26026

@henrikbrixandersen

Description

@henrikbrixandersen

Introduction

Extend the Zephyr RTOS PWM API with functions for capturing PWM pulse width and period time.

Problem description

Many PWM controllers supports capturing PWM pulse width and period time/frequency, but Zephyr currently lacks an API for exposing this functionality.

Proposed change

Add two API functions for capturing the PWM pulse width and period:

  • pwm_pin_capture_cycles()
  • pwm_pin_capture_cycles_async()

Detailed RFC

Proposed change (Detailed)

Please see PR #26025 for proposed API.

Dependencies

None.

Concerns and Unresolved Questions

Not sure if the pwm_pin_capture_cycles_async() function will be useful to anybody. I do not have a use for it, but since this is how other asynchronous Zephyr RTOS APIs are done, I have added it for completeness.

Alternatives

PWM capture could also be implemented as a sensor driver, but seeing that many PWM controllers allow channels/pins to be used for PWM generation while others are used for PWM capture, it would be difficult to share the device between these two functions.

The Linux kernel PWM subsystem allows for PWM controllers to provide a capture function as well.

Metadata

Metadata

Assignees

No one assigned

    Labels

    RFCRequest For Comments: want input from the communityarea: APIChanges to public APIsarea: PWMPulse Width Modulation

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions