Skip to content

Commit 230280e

Browse files
soburikartben
authored andcommitted
boards: arduino: uno_r4: Add ADC, PWM, I2C, SPI, and TRNG
Add support for basic peripherals. Signed-off-by: TOKITA Hiroshi <[email protected]>
1 parent 380494a commit 230280e

21 files changed

+546
-1
lines changed

boards/arduino/uno_r4/arduino_uno_r4-pinctrl.dtsi

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,32 @@
1616
psels = <RA_PSEL(RA_PSEL_SCI_2, 3, 1)>;
1717
};
1818
};
19+
20+
iic1_default: iic1_default {
21+
group1 {
22+
/* SCL1 SDA1 */
23+
psels = <RA_PSEL(RA_PSEL_I2C, 1, 0)>,
24+
<RA_PSEL(RA_PSEL_I2C, 1, 1)>;
25+
drive-strength = "medium";
26+
};
27+
};
28+
29+
adc0_default: adc0_default {
30+
group1 {
31+
/* input */
32+
psels = <RA_PSEL(RA_PSEL_ADC, 0, 9)>,
33+
<RA_PSEL(RA_PSEL_ADC, 0, 0)>,
34+
<RA_PSEL(RA_PSEL_ADC, 0, 1)>,
35+
<RA_PSEL(RA_PSEL_ADC, 0, 2)>;
36+
renesas,analog-enable;
37+
};
38+
};
39+
40+
pwm7_default: pwm7_default {
41+
group1 {
42+
/* GTIOC7A GTIOC7B */
43+
psels = <RA_PSEL(RA_PSEL_GPT1, 3, 4)>,
44+
<RA_PSEL(RA_PSEL_GPT1, 3, 3)>;
45+
};
46+
};
1947
};

boards/arduino/uno_r4/arduino_uno_r4.dts

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
zephyr,shell-uart = &uart2;
2121
zephyr,sram = &sram0;
2222
zephyr,flash = &flash0;
23+
zephyr,entropy = &trng;
2324
zephyr,code-partition = &code_partition;
2425
};
2526
};
@@ -28,7 +29,7 @@
2829
status = "okay";
2930
pinctrl-0 = <&sci2_default>;
3031
pinctrl-names = "default";
31-
interrupts = <4 1>, <5 1>, <6 1>, <7 1>;
32+
interrupts = <0 1>, <1 1>, <2 1>, <3 1>;
3233
interrupt-names = "rxi", "txi", "tei", "eri";
3334

3435
uart2: uart {
@@ -41,6 +42,12 @@
4142
status = "okay";
4243
};
4344

45+
&adc0 {
46+
status = "okay";
47+
pinctrl-0 = <&adc0_default>;
48+
pinctrl-names = "default";
49+
};
50+
4451
&port_irq0 {
4552
interrupts = <27 12>;
4653
status = "okay";
@@ -51,6 +58,29 @@
5158
status = "okay";
5259
};
5360

61+
&trng {
62+
status = "okay";
63+
};
64+
65+
&pwm7 {
66+
pinctrl-0 = <&pwm7_default>;
67+
pinctrl-names = "default";
68+
interrupts = <8 1>, <9 1>;
69+
interrupt-names = "gtioca", "overflow";
70+
status = "okay";
71+
};
72+
73+
&iic1 {
74+
pinctrl-0 = <&iic1_default>;
75+
pinctrl-names = "default";
76+
#address-cells = <1>;
77+
#size-cells = <0>;
78+
clock-frequency = <DT_FREQ_M(1)>;
79+
interrupts = <10 1>, <11 1>, <12 1>, <13 1>;
80+
interrupt-names = "rxi", "txi", "tei", "eri";
81+
status = "okay";
82+
};
83+
5484
&flash0 {
5585
partitions {
5686
compatible = "fixed-partitions";
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
/*
2+
* Copyright (c) 2023 TOKITA Hiroshi <[email protected]>
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
&pinctrl {
8+
spi1_default: spi1_default {
9+
group1 {
10+
/* MOSI MISO RSPCK SSL */
11+
psels = <RA_PSEL(RA_PSEL_SPI, 1, 9)>,
12+
<RA_PSEL(RA_PSEL_SPI, 1, 10)>,
13+
<RA_PSEL(RA_PSEL_SPI, 1, 11)>,
14+
<RA_PSEL(RA_PSEL_SPI, 1, 12)>;
15+
};
16+
};
17+
};

boards/arduino/uno_r4/arduino_uno_r4_minima.overlay

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@
44
* SPDX-License-Identifier: Apache-2.0
55
*/
66

7+
#include "arduino_uno_r4_minima-pinctrl.dtsi"
8+
9+
#include <zephyr/dt-bindings/pwm/pwm.h>
10+
#include <zephyr/dt-bindings/pwm/ra_pwm.h>
11+
712
/ {
813
model = "Arduino Uno R4 Minima";
914

@@ -14,8 +19,18 @@
1419
};
1520
};
1621

22+
pwm_leds {
23+
compatible = "pwm-leds";
24+
status = "disabled";
25+
pwm_led: pwm_led {
26+
pwms = <&pwm3 0 PWM_MSEC(1) PWM_POLARITY_NORMAL>;
27+
label = "PWM_LED";
28+
};
29+
};
30+
1731
aliases {
1832
led0 = &led;
33+
pwm-led0 = &pwm_led;
1934
};
2035

2136
arduino_header: connector {
@@ -47,3 +62,14 @@
4762
<21 0 &ioport1 0 0>; /* D15 */
4863
};
4964
};
65+
66+
&spi1 {
67+
pinctrl-0 = <&spi1_default>;
68+
pinctrl-names = "default";
69+
interrupts = <28 1>, <29 1>, <30 1>, <31 1>;
70+
interrupt-names = "rxi", "txi", "tei", "eri";
71+
status = "okay";
72+
};
73+
74+
arduino_i2c: &iic1 {};
75+
arduino_spi: &spi1 {};

boards/arduino/uno_r4/arduino_uno_r4_minima.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,8 @@ toolchain:
77
- gnuarmemb
88
ram: 32
99
supported:
10+
- adc
1011
- gpio
12+
- pwm
13+
- spi
1114
- uart
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/*
2+
* Copyright (c) 2024 TOKITA Hiroshi <[email protected]>
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
&pinctrl {
8+
iic0_default: iic0_default {
9+
group1 {
10+
/* SCL0 SDA0 */
11+
psels = <RA_PSEL(RA_PSEL_I2C, 4, 0)>,
12+
<RA_PSEL(RA_PSEL_I2C, 4, 1)>;
13+
drive-strength = "medium";
14+
};
15+
};
16+
17+
spi0_default: spi0_default {
18+
group1 {
19+
/* MOSI MISO RSPCK SSL */
20+
psels = <RA_PSEL(RA_PSEL_SPI, 4, 11)>,
21+
<RA_PSEL(RA_PSEL_SPI, 4, 10)>,
22+
<RA_PSEL(RA_PSEL_SPI, 1, 2)>,
23+
<RA_PSEL(RA_PSEL_SPI, 1, 3)>;
24+
};
25+
};
26+
};

boards/arduino/uno_r4/arduino_uno_r4_wifi.overlay

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@
44
* SPDX-License-Identifier: Apache-2.0
55
*/
66

7+
#include "arduino_uno_r4_wifi-pinctrl.dtsi"
8+
9+
#include <zephyr/dt-bindings/pwm/pwm.h>
10+
#include <zephyr/dt-bindings/pwm/ra_pwm.h>
11+
712
/ {
813
model = "Arduino Uno R4 WiFi";
914

@@ -14,8 +19,18 @@
1419
};
1520
};
1621

22+
pwm_leds {
23+
compatible = "pwm-leds";
24+
status = "disabled";
25+
pwm_led: pwm_led {
26+
pwms = <&pwm2 1 PWM_MSEC(1) PWM_POLARITY_NORMAL>;
27+
label = "PWM_LED";
28+
};
29+
};
30+
1731
aliases {
1832
led0 = &led;
33+
pwm-led0 = &pwm_led;
1934
};
2035

2136
arduino_header: connector {
@@ -47,3 +62,26 @@
4762
<21 0 &ioport1 0 0>; /* D15 */
4863
};
4964
};
65+
66+
&spi0 {
67+
pinctrl-0 = <&spi0_default>;
68+
pinctrl-names = "default";
69+
interrupts = <28 1>, <29 1>, <30 1>, <31 1>;
70+
interrupt-names = "rxi", "txi", "tei", "eri";
71+
status = "okay";
72+
};
73+
74+
&iic0 {
75+
pinctrl-0 = <&iic0_default>;
76+
pinctrl-names = "default";
77+
#address-cells = <1>;
78+
#size-cells = <0>;
79+
clock-frequency = <DT_FREQ_M(1)>;
80+
interrupts = <14 1>, <15 1>, <16 1>, <17 1>;
81+
interrupt-names = "rxi", "txi", "tei", "eri";
82+
status = "okay";
83+
};
84+
85+
qwiic_i2c: &iic0 {};
86+
arduino_i2c: &iic1 {};
87+
arduino_spi: &spi0 {};

boards/arduino/uno_r4/arduino_uno_r4_wifi.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,8 @@ toolchain:
77
- gnuarmemb
88
ram: 32
99
supported:
10+
- adc
1011
- gpio
12+
- pwm
13+
- spi
1114
- uart
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/*
2+
* Copyright (c) 2025 TOKITA Hiroshi
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
#include <zephyr/dt-bindings/pwm/pwm.h>
8+
#include <zephyr/dt-bindings/pwm/ra_pwm.h>
9+
10+
/ {
11+
leds {
12+
status = "disabled";
13+
};
14+
15+
pwm_leds {
16+
status = "okay";
17+
};
18+
};
19+
20+
&pinctrl {
21+
pwm3_default: pwm3_default {
22+
group1 {
23+
/* GTIOC3A */
24+
psels = <RA_PSEL(RA_PSEL_GPT1, 1, 11)>;
25+
};
26+
};
27+
};
28+
29+
&pwm3 {
30+
pinctrl-0 = <&pwm3_default>;
31+
pinctrl-names = "default";
32+
interrupts = <30 1>, <31 1>;
33+
interrupt-names = "gtioca", "overflow";
34+
status = "okay";
35+
divider = <RA_PWM_SOURCE_DIV_1024>;
36+
};
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/*
2+
* Copyright (c) 2025 TOKITA Hiroshi
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
#include <zephyr/dt-bindings/pwm/pwm.h>
8+
#include <zephyr/dt-bindings/pwm/ra_pwm.h>
9+
10+
/ {
11+
leds {
12+
status = "disabled";
13+
};
14+
15+
pwm_leds {
16+
status = "okay";
17+
};
18+
};
19+
20+
&pinctrl {
21+
pwm2_default: pwm2_default {
22+
group1 {
23+
/* GTIOC2B */
24+
psels = <RA_PSEL(RA_PSEL_GPT1, 1, 2)>;
25+
};
26+
};
27+
};
28+
29+
&pwm2 {
30+
pinctrl-0 = <&pwm2_default>;
31+
pinctrl-names = "default";
32+
interrupts = <30 1>, <31 1>;
33+
interrupt-names = "gtioca", "overflow";
34+
status = "okay";
35+
divider = <RA_PWM_SOURCE_DIV_1024>;
36+
};

0 commit comments

Comments
 (0)