-
Notifications
You must be signed in to change notification settings - Fork 6.7k
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
drivers: pwm_nrf5_sw: Fix the driver and make it support nRF9x SoCs #15287
Conversation
All checks are passing now. Review history of this comment for details about previous failed status. |
95ba0bb
to
1babcc9
Compare
Fixed checkpatch and codeowners issues. |
Is there a filed bug for this PR? Otherwise, it shouldn't go to 1.14 - we are close to release, AFAIK |
I am not aware of any. The bug was reported on slack:
Sure. Could you file an issue in GH with "bug" and 1.14" that relates to the slack report? |
cc @overheat |
1babcc9
to
333e1ba
Compare
Added one line that I somehow lost during splitting the changes into several logical commits. Sorry about that. |
333e1ba
to
42c19c9
Compare
Removed a no longer needed overlay file that was changing the |
42c19c9
to
12e755a
Compare
@cvinayak @kl-cruz @nordic-krch can you please take a look? |
724759a
to
8a4c7d1
Compare
Adjust the timer prescaler used by the pwm_nrf5_sw driver according to the requested period length, so that it does not need to be specified at the build time. Remove the incorrect "scaling" that was done to the requested pulse and period cycles to fit them into 16 bits. Signed-off-by: Andrzej Głąbek <[email protected]>
Remove the no longer used "clock-prescaler" property from the bindings for "nordic,nrf-sw-pwm" compatible nodes and all assignments to this property. This means also the removal of the bbc_microbit.overlay file from the servo_motor sample (as the assignment is the only purpose of this file) together with the entry covering this file in CODEOWNERS. Signed-off-by: Andrzej Głąbek <[email protected]>
GPIOTE base channel number taken from DeviceTree was not used consistenly, hence the driver could properly work only when this number had the value of 0. TIMER was not stopped during the reconfiguration of the channel and this could lead to the inversion of the PWM polarity. The config structure was removed on the occasion as it unnecessarily complicated the code of this currently single-instance only driver. Signed-off-by: Andrzej Głąbek <[email protected]>
8a4c7d1
to
52ebe69
Compare
Rebased on master. |
52ebe69
to
9cf417d
Compare
@anangl is there any way to detect if there is conflict in TIMER instance usage? |
9cf417d
to
452c3eb
Compare
Now instead of accessing peripheral registers directly, the driver uses the nrfx HAL functions. This makes the code easier to maintain and also gives the possibility to use pins from GPIO port P1 on nRF52840 (absolute numbers 32-47) as the GPIO HAL provides the needed translation. Signed-off-by: Andrzej Głąbek <[email protected]>
Move all channel initialization code that does not need to be executed on every pin reconfiguration (like initialization of the PPI channels) to the driver initialization function. Simplify the routine that checks the requested period and the one that finds a suitable channel for driving the pin. Signed-off-by: Andrzej Głąbek <[email protected]>
The nrfx Hardware PWM driver cannot be used in this sample since the driver does not allow to set a period longer than ~262 ms. The sw_pwm node is made enabled by default in dts for all nRF52 series SoCs (just like it is already done for nRF51 series) so that there is no need to do it for particular boards to make the SW PWM driver available for them (this will only cause that the corresponding DT_ macros will be created, the driver will be compiled and used after it is selected in Kconfig). Signed-off-by: Andrzej Głąbek <[email protected]>
Now the driver uses DPPI or PPI depending on the presence of one of these interfaces in a given SoC, hence it can be used on nRF9x SoCs as well. Remove the '5' from its name then, and make the blink_led sample using it for the nrf9160_pca10090 board, thus making the sample working properly on this board. Signed-off-by: Andrzej Głąbek <[email protected]>
This approach provides more flexibility (the PPI channels utilized by this driver no longer need to have consecutive numbers) and eliminates the need of certain hacks in nrfx_glue.h and radio_nrf5_ppi.h. Signed-off-by: Andrzej Głąbek <[email protected]>
452c3eb
to
b13987f
Compare
This PR makes the blink_led sample working (again) on boards with nRF52 series SoCs. The SW PWM driver is selected for them instead of the default HW one, as the latter cannot handle periods longer than ~262 ms (this is a hardware limitation).
It also fixes a couple of issues (details below) found in the pwm_nrf5_sw driver and makes it support nRF9x SoCs as well, so that the blink_led sample can be run on boards equipped with those.
drivers: pwm_nrf5_sw: Use dynamically adjusted timer prescaler
Adjust the timer prescaler used by the pwm_nrf5_sw driver according to
the requested period length, so that it does not need to be specified
at the build time. Remove the incorrect "scaling" that was done to the
requested pulse and period cycles to fit them into 16 bits.
samples: blink_led: Use nRF SW PWM driver for nRF52 boards
The nrfx Hardware PWM driver cannot be used in this sample
since the driver does not allow to set a period longer than ~262 ms.
drivers: pwm_nrf5_sw: Correct the use of GPIOTE channels and TIMER
GPIOTE base channel number taken from DeviceTree was not used
consistenly, hence the driver could properly work only when this
number had the value of 0.
TIMER was not stopped during the reconfiguration of the channel
and this could lead to the inversion of the PWM polarity.
The config structure was removed on the occasion as it unnecessarily
complicated the code of this currently single-instance only driver.
drivers: pwm_nrf5_sw: Use nrfx HALs instead of direct register accesses
Now instead of accessing peripheral registers directly, the driver
uses the nrfx HAL functions. This makes the code easier to maintain
and also gives the possibility to use pins from GPIO port P1 on
nRF52840 (absolute numbers 32-47) as the GPIO HAL provides the needed
translation.
drivers: pwm_nrf5_sw: Refactor the code
Move all channel initialization code that does not need to be executed
on every pin reconfiguration (like initialization of the PPI channels)
to the driver initialization function. Simplify the routines that check
the requested period and find a suitable channel for driving the pin.
drivers: pwm_nrf5_sw: Make the driver support nRF9x series SoCs as well
Now the driver uses DPPI or PPI depending on the presence of one of
these interfaces in a given SoC, hence it can be used on nRF9x SoCs
as well. Remove the '5' from its name then, and make the blink_led
sampe use it for the nrf9160_pca10090 board, thus making the sample
working properly on this board.
Fixes #15323.