Skip to content

Commit e06a245

Browse files
committed
Arduino.h: Remove builtin_led_gpios rule
Now that GPIO can be specified generically, we will discontinue the definition generation of LED_BUILTIN from builtin_led_gpios. Delete this definition where automatic generation from led0 is not an issue, and define it in variant.h in all other cases. Signed-off-by: TOKITA Hiroshi <[email protected]>
1 parent b009050 commit e06a245

File tree

9 files changed

+13
-38
lines changed

9 files changed

+13
-38
lines changed

cores/arduino/Arduino.h

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,8 @@ int digitalPinToInterrupt(pin_size_t pin);
4949

5050
#include <variant.h>
5151

52-
#ifndef LED_BUILTIN
53-
#if DT_NODE_HAS_PROP(DT_PATH(zephyr_user), builtin_led_gpios) \
54-
&& (DT_PROP_LEN(DT_PATH(zephyr_user), builtin_led_gpios) > 0)
55-
#define LED_BUILTIN ZARD_GLOBAL_GPIO_NUM(DT_PATH(zephyr_user), builtin_led_gpios, 0)
56-
#elif DT_NODE_EXISTS(DT_ALIAS(led0))
52+
#if !defined(LED_BUILTIN) && DT_NODE_EXISTS(DT_ALIAS(led0))
5753
#define LED_BUILTIN ZARD_GLOBAL_GPIO_NUM(DT_ALIAS(led0), gpios, 0)
58-
#endif
5954
#endif // LED_BUILTIN
6055

6156
#ifdef __cplusplus

documentation/variants.md

Lines changed: 4 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -151,31 +151,12 @@ The following example instantiates `Wire` and `Wire2` with each `i2c0` and `i2c1
151151

152152
### Configure Builtin-LED
153153

154-
The `builtin-led-gpios` node defines the Builtin-LED.
155-
This node defines the `LED_BUILTIN` value by looking up the `digital-pin-gpios`
156-
array to find the index of the pin.
154+
If `LED_BUILTIN` is defined, it will take precedence.
155+
This is usually defined in each board's variant.h file.
157156

158-
The node is phandle-array, which uses the format same as `digital-pin-gpios`.
157+
If the `LED_BUILTIN` is not defined and the LED node aliased as `led0` available,
158+
`LED_BUILTIN` referencing `led0` will be automatically defined.
159159

160-
It set the digital pin number to the `LED_BUILTIN` if found the pin
161-
that defined in `builtin-led-gpios` from `digital-pin-gpios`.
162-
163-
If the `builtin-led-gpios` is not defined, Use the node aliased as `led0`
164-
to define `LED_BUILTIN`.
165-
166-
The `LED_BUILTIN` does not define here if it has not found both nodes or
167-
defined `LED_BUILTIN` already.
168-
169-
For example, in the case of the 13th digital pins connected to the onboard LED,
170-
define `builtin-led-gpios` as follows.
171-
172-
```
173-
/ {
174-
zephyr,user {
175-
builtin-led-gpios = <&arduino_nano_header 13 0>;
176-
};
177-
};
178-
```
179160

180161
### Overlays from scratch
181162

variants/arduino_nano_33_ble_nrf52840/arduino_nano_33_ble_nrf52840.overlay

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,6 @@
4040
<&arduino_nano_header 20 0>,
4141
<&arduino_nano_header 21 0>;
4242

43-
builtin-led-gpios = <&arduino_nano_header 13 0>;
44-
4543
pwms = <&pwm1 1 255 PWM_POLARITY_NORMAL>,
4644
<&pwm1 2 255 PWM_POLARITY_NORMAL>,
4745
<&pwm1 3 255 PWM_POLARITY_NORMAL>,

variants/arduino_nano_33_ble_nrf52840/variant.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,7 @@
33
*
44
* SPDX-License-Identifier: Apache-2.0
55
*/
6+
7+
#pragma once
8+
9+
#define LED_BUILTIN D13

variants/arduino_nano_33_ble_nrf52840_sense/arduino_nano_33_ble_nrf52840_sense.overlay

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,6 @@
4040
<&arduino_nano_header 20 0>,
4141
<&arduino_nano_header 21 0>;
4242

43-
builtin-led-gpios = <&arduino_nano_header 13 0>;
44-
4543
pwms = <&pwm1 1 255 PWM_POLARITY_NORMAL>,
4644
<&pwm1 2 255 PWM_POLARITY_NORMAL>,
4745
<&pwm1 3 255 PWM_POLARITY_NORMAL>,

variants/arduino_nano_33_ble_nrf52840_sense/variant.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,7 @@
33
*
44
* SPDX-License-Identifier: Apache-2.0
55
*/
6+
7+
#pragma once
8+
9+
#define LED_BUILTIN D13

variants/beagleconnect_freedom_cc1352p7/beagleconnect_freedom_cc1352p7.overlay

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,6 @@
5757
<&gpio0 27 GPIO_ACTIVE_HIGH>, /* D7 - MB2 CS - A4 */
5858
<&gpio0 28 GPIO_ACTIVE_HIGH>; /* D3 - MB1 CS - A5 */
5959

60-
builtin-led-gpios = <&gpio0 18 GPIO_ACTIVE_HIGH>; /* 2.4GHz TX/RX */
61-
6260
gpio-ports = <&gpio0>;
6361
serials = <&uart0 &uart1>;
6462
i2cs = <&i2c0>;

variants/cc3220sf_launchxl_cc3220sf/cc3220sf_launchxl_cc3220sf.overlay

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
<&boosterpack_header 30 0>, /* GPIO_00 */
3030
<&boosterpack_header 31 0>, /* GPIO_24 */
3131
<&boosterpack_header 32 0>; /* GPIO_23 */
32-
builtin-led-gpios = <&boosterpack_header 10 0>; /* GREEN_LED */
3332

3433
gpio-ports = <&gpioa0>, <&gpioa1>, <&gpioa2>, <&gpioa3>;
3534
serials = <&boosterpack_serial>;

variants/rpi_pico_rp2040/rpi_pico_rp2040.overlay

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,6 @@
3838
<&pico_header 27 0>,
3939
<&pico_header 28 0>;
4040

41-
builtin-led-gpios = <&gpio0 25 0>;
42-
4341
pwm-pin-gpios = <&pico_header 2 0>,
4442
<&pico_header 3 0>,
4543
<&pico_header 7 0>,

0 commit comments

Comments
 (0)