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

Update nuttx_PWM.c file to support multiple PWM blocks #20

Merged
merged 2 commits into from
Jul 26, 2021

Conversation

michallenc
Copy link
Contributor

This PR removes global declaration of pwm_info_s structure and moves it locally to functions init() and inout() to support multiple PWM blocks. It is necessary to run for loop from 0 to CONFIG_PWM_NCHANNELS and set all channels to 0 also in inout() function, otherwise there will be hard faults. Also adds some comments as the code was getting a little bit harder to read.

I also experimented a little bit with completely removing pwm_info_s structure from init() function and then removing PWMIOC_SETCHARACTERISTICS ioctl command from that function too so init() would only open the device and then execute PWMIOC_START start command. It seemed to be working fine but then I found out that PWMIOC_SETCHARACTERISTICS should be sent before PWMIOC_START according to this https://github.com/apache/incubator-nuttx/blob/master/drivers/timers/pwm.c#L497. But maybe it is worth to take a closer look at this in the future.

… of nuttx-export

Signed-off-by: Michal Lenc <michallenc@seznam.cz>
…in functions to support multiple PWM blocks

Signed-off-by: Michal Lenc <michallenc@seznam.cz>
@robertobucher robertobucher merged commit dbb7dfb into robertobucher:master Jul 26, 2021
@michallenc michallenc deleted the pwm-multiblock branch August 6, 2021 21:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants