Skip to content

variants: Introduce the builtin-led-gpios node #61

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

Merged
merged 2 commits into from
Nov 19, 2022

Conversation

soburi
Copy link
Member

@soburi soburi commented Oct 10, 2022

Introduce the builtin-led-gpios node to make possible to configuring
the builtin-led from dts.
This node uses to determine the value of the LED_BUILTIN macro.

Use the led0 alias to determine the LED_BUILTIN if the builtin-led-gpios
is not defined.

The behavior can override by defining the LED_BUILTIN in pinmap.h.
It uses definitions that are defined in the header preferentially.


The PR is contineued from #60.
I will rebase if #60 merged.

@soburi soburi marked this pull request as draft October 10, 2022 07:39
@soburi soburi force-pushed the builtin-led-gpios branch 2 times, most recently from 62d1863 to e4be5a6 Compare October 18, 2022 22:14
Copy link
Collaborator

@szczys szczys left a comment

Choose a reason for hiding this comment

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

This is a nice improvement and the changes LGTM.

This PR should also include an update to the variant documentation on this topic:

### Overlays using previously-defined Arduino headers
When an Arduino header exists in a board's in-tree DTS file it can easily be
used to create the necessary overlay file. Assign the relevant mapping using the
Arduino header label (usually either `&arduino_header` or `&arduino_nano_header`
and the `gpio_map` number. The second number is used to add GPIO flags and may
safely be left as zero.
For example, creating an overlay file for the Nordic nRF52840 Development Kit
uses [the Arduino header definitions](https://github.com/zephyrproject-rtos/zephyr/blob/6f8ee2cdf7dd4d746de58909204ea0ce156d5bb4/boards/arm/nrf52840dk_nrf52840/nrf52840dk_nrf52840.dts#L74-L101), beginning with the first digital pin:
```
/ {
zephyr,user {
d0_gpios = <&arduino_header 6 0>; /* Digital */
d1_gpios = <&arduino_header 7 0>;
...
d13_gpios = <&arduino_header 19 0>;
d14_gpios = <&arduino_header 0 0>; /* Analog */
d15_gpios = <&arduino_header 1 0>;
...
d19_gpios = <&arduino_header 5 0>;
d20_gpios = <&arduino_header 20 0>; /* SDA */
d21_gpios = <&arduino_header 21 0>; /* SCL */
d22_gpios = <&gpio0 13 GPIO_ACTIVE_LOW>; /* LED0 */
};
};
```

Introduce the `builtin-led-gpios` node to make possible to configuring
the builtin-led from dts.
This node uses to determine the value of the `LED_BUILTIN` macro.

Use the `led0` alias to determine the `LED_BUILTIN` if the `builtin-led-gpios`
is not defined.

The behavior can override by defining the `LED_BUILTIN` in pinmap.h.
It uses definitions that are defined in the header preferentially.

Signed-off-by: TOKITA Hiroshi <tokita.hiroshi@fujitsu.com>
Add a description for `builtin-led-gpios`

Signed-off-by: TOKITA Hiroshi <tokita.hiroshi@fujitsu.com>
@soburi soburi marked this pull request as ready for review November 13, 2022 22:28
@soburi
Copy link
Member Author

soburi commented Nov 13, 2022

@szczys

Thank you for reviewing.

This PR should also include an update to the variant documentation on this topic:

I update the document.

Copy link
Collaborator

@DhruvaG2000 DhruvaG2000 left a comment

Choose a reason for hiding this comment

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

This makes the overall code around builtin LEDs much more generic and future proof. Great addition!

Tested-by: Dhruva Gole

@DhruvaG2000 DhruvaG2000 merged commit 87eff28 into zephyrproject-rtos:main Nov 19, 2022
@soburi soburi deleted the builtin-led-gpios branch November 19, 2022 21:55
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.

3 participants