Skip to content

Commit 1ebffbd

Browse files
soburikartben
authored andcommitted
include: zephyr: dt-bindings: gpio: Add arduino-header-r3 defines
To make the pin names of the Arduino header easier to understand, we will introduce a macro definition for the pin names. We will use this to update the definition of `arduino_uno_r4`. Signed-off-by: TOKITA Hiroshi <[email protected]>
1 parent 172811b commit 1ebffbd

File tree

3 files changed

+93
-58
lines changed

3 files changed

+93
-58
lines changed

boards/arduino/uno_r4/arduino_uno_r4_minima.overlay

Lines changed: 30 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
#include "arduino_uno_r4_minima-pinctrl.dtsi"
88

9+
#include <zephyr/dt-bindings/gpio/arduino-header-r3.h>
910
#include <zephyr/dt-bindings/pwm/pwm.h>
1011
#include <zephyr/dt-bindings/pwm/ra_pwm.h>
1112

@@ -15,7 +16,7 @@
1516
leds {
1617
compatible = "gpio-leds";
1718
led: led {
18-
gpios = <&ioport1 11 GPIO_ACTIVE_HIGH>;
19+
gpios = <&arduino_header ARDUINO_HEADER_R3_D13 GPIO_ACTIVE_HIGH>;
1920
};
2021
};
2122

@@ -38,39 +39,39 @@
3839
#gpio-cells = <2>;
3940
gpio-map-mask = <0xffffffff 0xffffffc0>;
4041
gpio-map-pass-thru = <0 0x3f>;
41-
gpio-map = <0 0 &ioport0 14 0>, /* A0 */
42-
<1 0 &ioport0 0 0>, /* A1 */
43-
<2 0 &ioport0 1 0>, /* A2 */
44-
<3 0 &ioport0 2 0>, /* A3 */
45-
<4 0 &ioport1 1 0>, /* A4 */
46-
<5 0 &ioport1 0 0>, /* A5 */
47-
<6 0 &ioport3 1 0>, /* D0 */
48-
<7 0 &ioport3 2 0>, /* D1 */
49-
<8 0 &ioport1 5 0>, /* D2 */
50-
<9 0 &ioport1 4 0>, /* D3 */
51-
<10 0 &ioport1 3 0>, /* D4 */
52-
<11 0 &ioport1 2 0>, /* D5 */
53-
<12 0 &ioport1 6 0>, /* D6 */
54-
<13 0 &ioport1 7 0>, /* D7 */
55-
<14 0 &ioport3 4 0>, /* D8 */
56-
<15 0 &ioport3 3 0>, /* D9 */
57-
<16 0 &ioport1 12 0>, /* D10 */
58-
<17 0 &ioport1 9 0>, /* D11 */
59-
<18 0 &ioport1 10 0>, /* D12 */
60-
<19 0 &ioport1 11 0>, /* D13 */
61-
<20 0 &ioport1 1 0>, /* D14 */
62-
<21 0 &ioport1 0 0>; /* D15 */
42+
gpio-map = <ARDUINO_HEADER_R3_A0 0 &ioport0 14 0>,
43+
<ARDUINO_HEADER_R3_A1 0 &ioport0 0 0>,
44+
<ARDUINO_HEADER_R3_A2 0 &ioport0 1 0>,
45+
<ARDUINO_HEADER_R3_A3 0 &ioport0 2 0>,
46+
<ARDUINO_HEADER_R3_A4 0 &ioport1 1 0>,
47+
<ARDUINO_HEADER_R3_A5 0 &ioport1 0 0>,
48+
<ARDUINO_HEADER_R3_D0 0 &ioport3 1 0>,
49+
<ARDUINO_HEADER_R3_D1 0 &ioport3 2 0>,
50+
<ARDUINO_HEADER_R3_D2 0 &ioport1 5 0>,
51+
<ARDUINO_HEADER_R3_D3 0 &ioport1 4 0>,
52+
<ARDUINO_HEADER_R3_D4 0 &ioport1 3 0>,
53+
<ARDUINO_HEADER_R3_D5 0 &ioport1 2 0>,
54+
<ARDUINO_HEADER_R3_D6 0 &ioport1 6 0>,
55+
<ARDUINO_HEADER_R3_D7 0 &ioport1 7 0>,
56+
<ARDUINO_HEADER_R3_D8 0 &ioport3 4 0>,
57+
<ARDUINO_HEADER_R3_D9 0 &ioport3 3 0>,
58+
<ARDUINO_HEADER_R3_D10 0 &ioport1 12 0>,
59+
<ARDUINO_HEADER_R3_D11 0 &ioport1 9 0>,
60+
<ARDUINO_HEADER_R3_D12 0 &ioport1 10 0>,
61+
<ARDUINO_HEADER_R3_D13 0 &ioport1 11 0>,
62+
<ARDUINO_HEADER_R3_D14 0 &ioport1 1 0>,
63+
<ARDUINO_HEADER_R3_D15 0 &ioport1 0 0>;
6364
};
6465

6566
arduino_adc: analog-connector {
6667
compatible = "arduino,uno-adc";
6768
#io-channel-cells = <1>;
68-
io-channel-map = <0 &adc0 9>, /* A0 = P009 = CH09 */
69-
<1 &adc0 0>, /* A1 = P000 = CH00 */
70-
<2 &adc0 1>, /* A2 = P001 = CH01 */
71-
<3 &adc0 2>, /* A3 = P002 = CH02 */
72-
<4 &adc0 21>, /* A4 = P101 = CH21 */
73-
<5 &adc0 22>; /* A5 = P100 = CH22 */
69+
io-channel-map = <ARDUINO_HEADER_R3_A0 &adc0 9>, /* P009 = CH09 */
70+
<ARDUINO_HEADER_R3_A1 &adc0 0>, /* P000 = CH00 */
71+
<ARDUINO_HEADER_R3_A2 &adc0 1>, /* P001 = CH01 */
72+
<ARDUINO_HEADER_R3_A3 &adc0 2>, /* P002 = CH02 */
73+
<ARDUINO_HEADER_R3_A4 &adc0 21>, /* P101 = CH21 */
74+
<ARDUINO_HEADER_R3_A5 &adc0 22>; /* P100 = CH22 */
7475
};
7576
};
7677

boards/arduino/uno_r4/arduino_uno_r4_wifi.overlay

Lines changed: 30 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
#include "arduino_uno_r4_wifi-pinctrl.dtsi"
88

9+
#include <zephyr/dt-bindings/gpio/arduino-header-r3.h>
910
#include <zephyr/dt-bindings/pwm/pwm.h>
1011
#include <zephyr/dt-bindings/pwm/ra_pwm.h>
1112

@@ -15,7 +16,7 @@
1516
leds {
1617
compatible = "gpio-leds";
1718
led: led {
18-
gpios = <&ioport1 2 GPIO_ACTIVE_HIGH>;
19+
gpios = <&arduino_header ARDUINO_HEADER_R3_D13 GPIO_ACTIVE_HIGH>;
1920
};
2021
};
2122

@@ -38,39 +39,39 @@
3839
#gpio-cells = <2>;
3940
gpio-map-mask = <0xffffffff 0xffffffc0>;
4041
gpio-map-pass-thru = <0 0x3f>;
41-
gpio-map = <0 0 &ioport0 14 0>, /* A0 */
42-
<1 0 &ioport0 0 0>, /* A1 */
43-
<2 0 &ioport0 1 0>, /* A2 */
44-
<3 0 &ioport0 2 0>, /* A3 */
45-
<4 0 &ioport1 1 0>, /* A4 */
46-
<5 0 &ioport1 0 0>, /* A5 */
47-
<6 0 &ioport3 1 0>, /* D0 */
48-
<7 0 &ioport3 2 0>, /* D1 */
49-
<8 0 &ioport1 4 0>, /* D2 */
50-
<9 0 &ioport1 5 0>, /* D3 */
51-
<10 0 &ioport1 6 0>, /* D4 */
52-
<11 0 &ioport1 7 0>, /* D5 */
53-
<12 0 &ioport1 11 0>, /* D6 */
54-
<13 0 &ioport1 12 0>, /* D7 */
55-
<14 0 &ioport3 4 0>, /* D8 */
56-
<15 0 &ioport3 3 0>, /* D9 */
57-
<16 0 &ioport1 3 0>, /* D10 */
58-
<17 0 &ioport4 11 0>, /* D11 */
59-
<18 0 &ioport4 10 0>, /* D12 */
60-
<19 0 &ioport1 2 0>, /* D13 */
61-
<20 0 &ioport1 1 0>, /* D14 */
62-
<21 0 &ioport1 0 0>; /* D15 */
42+
gpio-map = <ARDUINO_HEADER_R3_A0 0 &ioport0 14 0>,
43+
<ARDUINO_HEADER_R3_A1 0 &ioport0 0 0>,
44+
<ARDUINO_HEADER_R3_A2 0 &ioport0 1 0>,
45+
<ARDUINO_HEADER_R3_A3 0 &ioport0 2 0>,
46+
<ARDUINO_HEADER_R3_A4 0 &ioport1 1 0>,
47+
<ARDUINO_HEADER_R3_A5 0 &ioport1 0 0>,
48+
<ARDUINO_HEADER_R3_D0 0 &ioport3 1 0>,
49+
<ARDUINO_HEADER_R3_D1 0 &ioport3 2 0>,
50+
<ARDUINO_HEADER_R3_D2 0 &ioport1 4 0>,
51+
<ARDUINO_HEADER_R3_D3 0 &ioport1 5 0>,
52+
<ARDUINO_HEADER_R3_D4 0 &ioport1 6 0>,
53+
<ARDUINO_HEADER_R3_D5 0 &ioport1 7 0>,
54+
<ARDUINO_HEADER_R3_D6 0 &ioport1 11 0>,
55+
<ARDUINO_HEADER_R3_D7 0 &ioport1 12 0>,
56+
<ARDUINO_HEADER_R3_D8 0 &ioport3 4 0>,
57+
<ARDUINO_HEADER_R3_D9 0 &ioport3 3 0>,
58+
<ARDUINO_HEADER_R3_D10 0 &ioport1 3 0>,
59+
<ARDUINO_HEADER_R3_D11 0 &ioport4 11 0>,
60+
<ARDUINO_HEADER_R3_D12 0 &ioport4 10 0>,
61+
<ARDUINO_HEADER_R3_D13 0 &ioport1 2 0>,
62+
<ARDUINO_HEADER_R3_D14 0 &ioport1 1 0>,
63+
<ARDUINO_HEADER_R3_D15 0 &ioport1 0 0>;
6364
};
6465

6566
arduino_adc: analog-connector {
6667
compatible = "arduino,uno-adc";
6768
#io-channel-cells = <1>;
68-
io-channel-map = <0 &adc0 9>, /* A0 = P009 = CH09 */
69-
<1 &adc0 0>, /* A1 = P000 = CH00 */
70-
<2 &adc0 1>, /* A2 = P001 = CH01 */
71-
<3 &adc0 2>, /* A3 = P002 = CH02 */
72-
<4 &adc0 21>, /* A4 = P101 = CH21 */
73-
<5 &adc0 22>; /* A5 = P100 = CH22 */
69+
io-channel-map = <ARDUINO_HEADER_R3_A0 &adc0 9>, /* P009 = CH09 */
70+
<ARDUINO_HEADER_R3_A1 &adc0 0>, /* P000 = CH00 */
71+
<ARDUINO_HEADER_R3_A2 &adc0 1>, /* P001 = CH01 */
72+
<ARDUINO_HEADER_R3_A3 &adc0 2>, /* P002 = CH02 */
73+
<ARDUINO_HEADER_R3_A4 &adc0 21>, /* P101 = CH21 */
74+
<ARDUINO_HEADER_R3_A5 &adc0 22>; /* P100 = CH22 */
7475
};
7576
};
7677

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/**
2+
* Copyright (c) 2025 TOKITA Hiroshi
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
#ifndef ZEPHYR_INCLUDE_DT_BINDINGS_GPIO_ARDUINO_HEADER_R3_H_
8+
#define ZEPHYR_INCLUDE_DT_BINDINGS_GPIO_ARDUINO_HEADER_R3_H_
9+
10+
#define ARDUINO_HEADER_R3_A0 0
11+
#define ARDUINO_HEADER_R3_A1 1
12+
#define ARDUINO_HEADER_R3_A2 2
13+
#define ARDUINO_HEADER_R3_A3 3
14+
#define ARDUINO_HEADER_R3_A4 4
15+
#define ARDUINO_HEADER_R3_A5 5
16+
#define ARDUINO_HEADER_R3_D0 6
17+
#define ARDUINO_HEADER_R3_D1 7
18+
#define ARDUINO_HEADER_R3_D2 8
19+
#define ARDUINO_HEADER_R3_D3 9
20+
#define ARDUINO_HEADER_R3_D4 10
21+
#define ARDUINO_HEADER_R3_D5 11
22+
#define ARDUINO_HEADER_R3_D6 12
23+
#define ARDUINO_HEADER_R3_D7 13
24+
#define ARDUINO_HEADER_R3_D8 14
25+
#define ARDUINO_HEADER_R3_D9 15
26+
#define ARDUINO_HEADER_R3_D10 16
27+
#define ARDUINO_HEADER_R3_D11 17
28+
#define ARDUINO_HEADER_R3_D12 18
29+
#define ARDUINO_HEADER_R3_D13 19
30+
#define ARDUINO_HEADER_R3_D14 20
31+
#define ARDUINO_HEADER_R3_D15 21
32+
33+
#endif /* ZEPHYR_INCLUDE_DT_BINDINGS_GPIO_ARDUINO_HEADER_R3_H_ */

0 commit comments

Comments
 (0)