-
Notifications
You must be signed in to change notification settings - Fork 7.8k
drivers: pwm: extend API to support events #93275
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
base: main
Are you sure you want to change the base?
Conversation
aa08572
to
49349f4
Compare
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.
Update tests/drivers/build_all/pwm/testcase.yaml
with:
diff --git a/tests/drivers/build_all/pwm/testcase.yaml b/tests/drivers/build_all/pwm/testcase.yaml
index 34156300b5d..270637d4625 100644
--- a/tests/drivers/build_all/pwm/testcase.yaml
+++ b/tests/drivers/build_all/pwm/testcase.yaml
@@ -43,6 +43,8 @@ tests:
platform_allow:
- sam_e70_xplained/same70q21
- sam_v71_xult/samv71q21b
+ extra_configs:
+ - CONFIG_PWM_INTERRUPT=y
drivers.pwm.stm32.build:
platform_allow: disco_l475_iot1
drivers.pwm.xec.build:
Ping to all reviewers Should this be brought to the architecture working group meeting? |
I believe it should be. I am not convinced this is the right approach. We typically do not just expose IRQs to the application like this. |
What's the alternative? BTW, this is also very similar to the PWM capture API. A usecase would be to use it for IR input/output, where I'd expect similar APIs. Envision a "remote control" subsystem using these drivers as carriers. |
I don't think it is. The PWM capture callback provides the captured values upon a complete capture. The API proposed here merely forwards an IRQ from the device to the upper layer (subsystem or application).
For that, wouldn't it be more abstract to offload the "train" of PWM cycles to be handled in the driver/device itself? E.g. "perform N PWM cycles with period X, pulse width Y with callback on completion", or even the same but with multiple encoded PWM configurations to be "played" like a stream" With the API proposed here, the subsystem would receive a callback upon each completed PWM cycle and have to respond to that, preventing hardware offload for capable devices. |
@javlands Please provide some context to this. What is your use-case? |
I can elaborate for my colleague The use-case is a PWM peripheral connected to an IR LED, to emit an RC (remote control) code it is typically required to encode this by alternating pulses and spaces. Tracking the number of periods is desired to have an accurate carrier representation of an RC code. |
The additions in this PR are too closely coupled to the interrupt part, rather than the "event" part. User's care when an event occurs, like
whether this event occurs via interrupt, or via reading a status register of an external device, triggered by an interrupt pin for example, is not relevant to the user. So the API should abstract that part away :) |
Architecture WG meeting:
|
I get @henrikbrixandersen 's concerns ("preventing hardware offload") in a general view, but for my stepper use-case it doesn't matter. For my drv8849 stepper driver I'm using |
baa7e54
to
e38f743
Compare
Extend the PWM API to support events, as some controllers allow interrupts if e.g., a pwm period has ended or a fault occured. Signed-off-by: Jaro Van Landschoot <[email protected]>
The SAM4S pwm supports several events. This commit implements the events when a channel period has ended or a fault event has occured. Signed-off-by: Jaro Van Landschoot <[email protected]>
Add the pwm event functions of the sam pwm driver to the build all test. Signed-off-by: Jaro Van Landschoot <[email protected]>
|
Hi all! Thanks for the feedback, I've processed it all: A renaming was done from "interrupt" to "event", and the gpio API was used as a reference to (re)build the API:
|
Please update the PR title and description to match. Thanks. |
Uh oh!
There was an error while loading. Please reload this page.