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

boards/common/nrf52xxxdk: Expose LEDs via saul_pwm #17399

Merged
merged 1 commit into from
Dec 15, 2021

Conversation

maribu
Copy link
Member

@maribu maribu commented Dec 14, 2021

Contribution description

As the title says. This allows dimming the LEDs instead of only turning them on and off.

Testing procedure

make BOARD=nrf52840dk PROGRAMMER=openocd -C examples/saul

[...]

help
2021-12-14 20:34:02,723 # help
2021-12-14 20:34:02,725 # Command              Description
2021-12-14 20:34:02,728 # ---------------------------------------
2021-12-14 20:34:02,732 # reboot               Reboot the node
2021-12-14 20:34:02,736 # version              Prints current RIOT_VERSION
2021-12-14 20:34:02,741 # pm                   interact with layered PM subsystem
2021-12-14 20:34:02,747 # ps                   Prints information about running threads.
2021-12-14 20:34:02,753 # saul                 interact with sensors and actuators using SAUL
> saul
2021-12-14 20:34:03,742 # saul
2021-12-14 20:34:03,743 # ID	Class		Name
2021-12-14 20:34:03,745 # #0	SENSE_BTN	Button 1
2021-12-14 20:34:03,747 # #1	SENSE_BTN	Button 2
2021-12-14 20:34:03,748 # #2	SENSE_BTN	Button 3
2021-12-14 20:34:03,750 # #3	SENSE_BTN	Button 4
2021-12-14 20:34:03,752 # #4	ACT_DIMMER	LED 1
2021-12-14 20:34:03,754 # #5	ACT_DIMMER	LED 2
2021-12-14 20:34:03,756 # #6	ACT_DIMMER	LED 3
2021-12-14 20:34:03,758 # #7	ACT_DIMMER	LED 4
2021-12-14 20:34:03,760 # #8	SENSE_TEMP	NRF_TEMP
> saul write 4 1
2021-12-14 20:34:09,340 # saul write 4 1
2021-12-14 20:34:09,342 # Writing to device #4 - LED 1
2021-12-14 20:34:09,344 # Data:	              1 
2021-12-14 20:34:09,347 # data successfully written to device #4
> saul write 4 100
2021-12-14 20:34:14,456 # saul write 4 100
2021-12-14 20:34:14,458 # Writing to device #4 - LED 1
2021-12-14 20:34:14,463 # Data:	            100 
2021-12-14 20:34:14,465 # data successfully written to device #4
> saul write 4 50
2021-12-14 20:34:17,740 # saul write 4 50
2021-12-14 20:34:17,742 # Writing to device #4 - LED 1
2021-12-14 20:34:17,744 # Data:	             50 
2021-12-14 20:34:17,748 # data successfully written to device #4
> saul write 4 20
2021-12-14 20:34:20,106 # saul write 4 20
2021-12-14 20:34:20,108 # Writing to device #4 - LED 1
2021-12-14 20:34:20,110 # Data:	             20 
2021-12-14 20:34:20,114 # data successfully written to device #4
> saul write 4 10
2021-12-14 20:34:21,785 # saul write 4 10
2021-12-14 20:34:21,788 # Writing to device #4 - LED 1
2021-12-14 20:34:21,790 # Data:	             10 
2021-12-14 20:34:21,793 # data successfully written to device #4
> saul write 5 10
2021-12-14 20:34:24,725 # saul write 5 10
2021-12-14 20:34:24,727 # Writing to device #5 - LED 2
2021-12-14 20:34:24,729 # Data:	             10 
2021-12-14 20:34:24,732 # data successfully written to device #5
> saul write 6 10
2021-12-14 20:34:27,183 # saul write 6 10
2021-12-14 20:34:27,186 # Writing to device #6 - LED 3
2021-12-14 20:34:27,188 # Data:	             10 
2021-12-14 20:34:27,191 # data successfully written to device #6
> saul write 7 10
2021-12-14 20:34:29,919 # saul write 7 10
2021-12-14 20:34:29,921 # Writing to device #7 - LED 4
2021-12-14 20:34:29,923 # Data:	             10 
2021-12-14 20:34:29,929 # data successfully written to device #7
> saul write 7 100
2021-12-14 20:34:32,382 # saul write 7 100
2021-12-14 20:34:32,389 # Writing to device #7 - LED 4
2021-12-14 20:34:32,390 # Data:	            100 
2021-12-14 20:34:32,392 # data successfully written to device #7
> saul write 7 255
2021-12-14 20:34:36,024 # saul write 7 255
2021-12-14 20:34:36,026 # Writing to device #7 - LED 4
2021-12-14 20:34:36,028 # Data:	            255 
2021-12-14 20:34:36,031 # data successfully written to device #7
> saul write 7 256
2021-12-14 20:34:40,222 # saul write 7 256
2021-12-14 20:34:40,225 # Writing to device #7 - LED 4
2021-12-14 20:34:40,227 # Data:	            256 
2021-12-14 20:34:40,230 # error: failure to write to device #7
> saul write 7 255
2021-12-14 20:34:45,455 # saul write 7 255
2021-12-14 20:34:45,458 # Writing to device #7 - LED 4
2021-12-14 20:34:45,460 # Data:	            255 
2021-12-14 20:34:45,463 # data successfully written to device #7
> 2021-12-14 20:35:17,711 # Exiting Pyterm

Note: The LEDs were dimmed as expected.

Issues/PRs references

None

@github-actions github-actions bot added the Area: boards Area: Board ports label Dec 14, 2021
@maribu maribu added Impact: minor The PR is small in size and might only require a quick look of a knowledgeable reviewer Type: enhancement The issue suggests enhanceable parts / The PR enhances parts of the codebase / documentation CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR labels Dec 14, 2021
@maribu maribu requested a review from chrysn December 14, 2021 19:40
* @ingroup boards_common_nrf52
* @ingroup boards_common_nrf52xxxdk
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doxygen group defined here:

/**
* @defgroup boards_common_nrf52xxxdk NRF52 DK common
* @ingroup boards_common_nrf52
* @{
*
* @file
* @brief Peripheral configuration for the nRF52 DK
*
* @author Hauke Petersen <hauke.petersen@fu-berlin.de>
*
*/

So it was indeed missorted before

@chrysn
Copy link
Member

chrysn commented Dec 14, 2021

I was about to complain about this relying on the boards to set up their PWM with matching pins, but as the PWM setup is done in the same module, that's fine. (A comment in periph_conf_common.h indicating that this assignment is relied on by the pwm_params might be useful.)

I don't have any of the boards, you indicated you tested it on nrf52840dk. Any others you have at hand? (Not insisting on further checks though, as the PWM channels were already configured and thus, if it's broken after this commit it was before as well).

@chrysn chrysn added Reviewed: 1-fundamentals The fundamentals of the PR were reviewed according to the maintainer guidelines Reviewed: 2-code-design The code design of the PR was reviewed according to the maintainer guidelines Reviewed: 4-code-style The adherence to coding conventions by the PR were reviewed according to the maintainer guidelines labels Dec 14, 2021
@fjmolinas fjmolinas removed the CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR label Dec 14, 2021
@@ -1,5 +1,6 @@
ifneq (,$(filter saul_default,$(USEMODULE)))
USEMODULE += saul_gpio
USEMODULE += saul_pwm
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Kconfig change is missing, please re-add ci label when addressed.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That CI check is worth its weight in gold. (Metaphorically speaking, assigning some arbitrary weight to the check). Without that, Kconfig migration would be a whack-a-mole. I think I should just put it in my commit hooks.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In fact, this would have not been caught by Murdock, since SAUL is not yet fully modeled. Nice catch!

This allows dimming the LEDs instead of only turning them on and off.
@maribu maribu force-pushed the boards/common/nrf52xxxdk branch from 490f3f9 to c118df3 Compare December 14, 2021 21:03
@github-actions github-actions bot added the Area: Kconfig Area: Kconfig integration label Dec 14, 2021
@maribu maribu added the CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR label Dec 14, 2021
@chrysn chrysn added the Reviewed: 5-documentation The documentation details of the PR were reviewed according to the maintainer guidelines label Dec 15, 2021
Copy link
Member

@chrysn chrysn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I trust your test (in combination with the PWMs already being configured for these pins). ACK.

@maribu maribu added CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR and removed CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR labels Dec 15, 2021
@maribu maribu merged commit 26eed0a into RIOT-OS:master Dec 15, 2021
@maribu maribu deleted the boards/common/nrf52xxxdk branch December 15, 2021 10:08
@maribu
Copy link
Member Author

maribu commented Dec 15, 2021

Thanks for the quick review!

@fjmolinas fjmolinas added this to the Release 2022.01 milestone Jan 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: boards Area: Board ports Area: Kconfig Area: Kconfig integration CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR Impact: minor The PR is small in size and might only require a quick look of a knowledgeable reviewer Reviewed: 1-fundamentals The fundamentals of the PR were reviewed according to the maintainer guidelines Reviewed: 2-code-design The code design of the PR was reviewed according to the maintainer guidelines Reviewed: 4-code-style The adherence to coding conventions by the PR were reviewed according to the maintainer guidelines Reviewed: 5-documentation The documentation details of the PR were reviewed according to the maintainer guidelines Type: enhancement The issue suggests enhanceable parts / The PR enhances parts of the codebase / documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants