Browse Source

boards: arduino: uno_r4: Add ADC, PWM, I2C, SPI, and TRNG

Add support for basic peripherals.

Signed-off-by: TOKITA Hiroshi <tokita.hiroshi@gmail.com>
pull/84458/merge
TOKITA Hiroshi 5 months ago committed by Benjamin Cabé
parent
commit
230280e0e9
  1. 28
      boards/arduino/uno_r4/arduino_uno_r4-pinctrl.dtsi
  2. 32
      boards/arduino/uno_r4/arduino_uno_r4.dts
  3. 17
      boards/arduino/uno_r4/arduino_uno_r4_minima-pinctrl.dtsi
  4. 26
      boards/arduino/uno_r4/arduino_uno_r4_minima.overlay
  5. 3
      boards/arduino/uno_r4/arduino_uno_r4_minima.yaml
  6. 26
      boards/arduino/uno_r4/arduino_uno_r4_wifi-pinctrl.dtsi
  7. 38
      boards/arduino/uno_r4/arduino_uno_r4_wifi.overlay
  8. 3
      boards/arduino/uno_r4/arduino_uno_r4_wifi.yaml
  9. 36
      samples/basic/blinky_pwm/boards/arduino_uno_r4_r7fa4m1ab3cfm_minima.overlay
  10. 36
      samples/basic/blinky_pwm/boards/arduino_uno_r4_r7fa4m1ab3cfm_wifi.overlay
  11. 36
      samples/basic/fade_led/boards/arduino_uno_r4_r7fa4m1ab3cfm_minima.overlay
  12. 36
      samples/basic/fade_led/boards/arduino_uno_r4_r7fa4m1ab3cfm_wifi.overlay
  13. 53
      samples/drivers/adc/adc_dt/boards/arduino_uno_r4.overlay
  14. 3
      samples/drivers/led/pwm/boards/arduino_uno_r4_r7fa4m1ab3cfm_minima.conf
  15. 30
      samples/drivers/led/pwm/boards/arduino_uno_r4_r7fa4m1ab3cfm_minima.overlay
  16. 3
      samples/drivers/led/pwm/boards/arduino_uno_r4_r7fa4m1ab3cfm_wifi.conf
  17. 30
      samples/drivers/led/pwm/boards/arduino_uno_r4_r7fa4m1ab3cfm_wifi.overlay
  18. 35
      tests/drivers/adc/adc_api/boards/arduino_uno_r4.overlay
  19. 34
      tests/drivers/pwm/pwm_loopback/boards/arduino_uno_r4.overlay
  20. 21
      tests/drivers/spi/spi_loopback/boards/arduino_uno_r4_r7fa4m1ab3cfm_minima.overlay
  21. 21
      tests/drivers/spi/spi_loopback/boards/arduino_uno_r4_r7fa4m1ab3cfm_wifi.overlay

28
boards/arduino/uno_r4/arduino_uno_r4-pinctrl.dtsi

@ -16,4 +16,32 @@
psels = <RA_PSEL(RA_PSEL_SCI_2, 3, 1)>; psels = <RA_PSEL(RA_PSEL_SCI_2, 3, 1)>;
}; };
}; };
iic1_default: iic1_default {
group1 {
/* SCL1 SDA1 */
psels = <RA_PSEL(RA_PSEL_I2C, 1, 0)>,
<RA_PSEL(RA_PSEL_I2C, 1, 1)>;
drive-strength = "medium";
};
};
adc0_default: adc0_default {
group1 {
/* input */
psels = <RA_PSEL(RA_PSEL_ADC, 0, 9)>,
<RA_PSEL(RA_PSEL_ADC, 0, 0)>,
<RA_PSEL(RA_PSEL_ADC, 0, 1)>,
<RA_PSEL(RA_PSEL_ADC, 0, 2)>;
renesas,analog-enable;
};
};
pwm7_default: pwm7_default {
group1 {
/* GTIOC7A GTIOC7B */
psels = <RA_PSEL(RA_PSEL_GPT1, 3, 4)>,
<RA_PSEL(RA_PSEL_GPT1, 3, 3)>;
};
};
}; };

32
boards/arduino/uno_r4/arduino_uno_r4.dts

@ -20,6 +20,7 @@
zephyr,shell-uart = &uart2; zephyr,shell-uart = &uart2;
zephyr,sram = &sram0; zephyr,sram = &sram0;
zephyr,flash = &flash0; zephyr,flash = &flash0;
zephyr,entropy = &trng;
zephyr,code-partition = &code_partition; zephyr,code-partition = &code_partition;
}; };
}; };
@ -28,7 +29,7 @@
status = "okay"; status = "okay";
pinctrl-0 = <&sci2_default>; pinctrl-0 = <&sci2_default>;
pinctrl-names = "default"; pinctrl-names = "default";
interrupts = <4 1>, <5 1>, <6 1>, <7 1>; interrupts = <0 1>, <1 1>, <2 1>, <3 1>;
interrupt-names = "rxi", "txi", "tei", "eri"; interrupt-names = "rxi", "txi", "tei", "eri";
uart2: uart { uart2: uart {
@ -41,6 +42,12 @@
status = "okay"; status = "okay";
}; };
&adc0 {
status = "okay";
pinctrl-0 = <&adc0_default>;
pinctrl-names = "default";
};
&port_irq0 { &port_irq0 {
interrupts = <27 12>; interrupts = <27 12>;
status = "okay"; status = "okay";
@ -51,6 +58,29 @@
status = "okay"; status = "okay";
}; };
&trng {
status = "okay";
};
&pwm7 {
pinctrl-0 = <&pwm7_default>;
pinctrl-names = "default";
interrupts = <8 1>, <9 1>;
interrupt-names = "gtioca", "overflow";
status = "okay";
};
&iic1 {
pinctrl-0 = <&iic1_default>;
pinctrl-names = "default";
#address-cells = <1>;
#size-cells = <0>;
clock-frequency = <DT_FREQ_M(1)>;
interrupts = <10 1>, <11 1>, <12 1>, <13 1>;
interrupt-names = "rxi", "txi", "tei", "eri";
status = "okay";
};
&flash0 { &flash0 {
partitions { partitions {
compatible = "fixed-partitions"; compatible = "fixed-partitions";

17
boards/arduino/uno_r4/arduino_uno_r4_minima-pinctrl.dtsi

@ -0,0 +1,17 @@
/*
* Copyright (c) 2023 TOKITA Hiroshi <tokita.hiroshi@fujitsu.com>
*
* SPDX-License-Identifier: Apache-2.0
*/
&pinctrl {
spi1_default: spi1_default {
group1 {
/* MOSI MISO RSPCK SSL */
psels = <RA_PSEL(RA_PSEL_SPI, 1, 9)>,
<RA_PSEL(RA_PSEL_SPI, 1, 10)>,
<RA_PSEL(RA_PSEL_SPI, 1, 11)>,
<RA_PSEL(RA_PSEL_SPI, 1, 12)>;
};
};
};

26
boards/arduino/uno_r4/arduino_uno_r4_minima.overlay

@ -4,6 +4,11 @@
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
*/ */
#include "arduino_uno_r4_minima-pinctrl.dtsi"
#include <zephyr/dt-bindings/pwm/pwm.h>
#include <zephyr/dt-bindings/pwm/ra_pwm.h>
/ { / {
model = "Arduino Uno R4 Minima"; model = "Arduino Uno R4 Minima";
@ -14,8 +19,18 @@
}; };
}; };
pwm_leds {
compatible = "pwm-leds";
status = "disabled";
pwm_led: pwm_led {
pwms = <&pwm3 0 PWM_MSEC(1) PWM_POLARITY_NORMAL>;
label = "PWM_LED";
};
};
aliases { aliases {
led0 = &led; led0 = &led;
pwm-led0 = &pwm_led;
}; };
arduino_header: connector { arduino_header: connector {
@ -47,3 +62,14 @@
<21 0 &ioport1 0 0>; /* D15 */ <21 0 &ioport1 0 0>; /* D15 */
}; };
}; };
&spi1 {
pinctrl-0 = <&spi1_default>;
pinctrl-names = "default";
interrupts = <28 1>, <29 1>, <30 1>, <31 1>;
interrupt-names = "rxi", "txi", "tei", "eri";
status = "okay";
};
arduino_i2c: &iic1 {};
arduino_spi: &spi1 {};

3
boards/arduino/uno_r4/arduino_uno_r4_minima.yaml

@ -7,5 +7,8 @@ toolchain:
- gnuarmemb - gnuarmemb
ram: 32 ram: 32
supported: supported:
- adc
- gpio - gpio
- pwm
- spi
- uart - uart

26
boards/arduino/uno_r4/arduino_uno_r4_wifi-pinctrl.dtsi

@ -0,0 +1,26 @@
/*
* Copyright (c) 2024 TOKITA Hiroshi <tokita.hiroshi@fujitsu.com>
*
* SPDX-License-Identifier: Apache-2.0
*/
&pinctrl {
iic0_default: iic0_default {
group1 {
/* SCL0 SDA0 */
psels = <RA_PSEL(RA_PSEL_I2C, 4, 0)>,
<RA_PSEL(RA_PSEL_I2C, 4, 1)>;
drive-strength = "medium";
};
};
spi0_default: spi0_default {
group1 {
/* MOSI MISO RSPCK SSL */
psels = <RA_PSEL(RA_PSEL_SPI, 4, 11)>,
<RA_PSEL(RA_PSEL_SPI, 4, 10)>,
<RA_PSEL(RA_PSEL_SPI, 1, 2)>,
<RA_PSEL(RA_PSEL_SPI, 1, 3)>;
};
};
};

38
boards/arduino/uno_r4/arduino_uno_r4_wifi.overlay

@ -4,6 +4,11 @@
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
*/ */
#include "arduino_uno_r4_wifi-pinctrl.dtsi"
#include <zephyr/dt-bindings/pwm/pwm.h>
#include <zephyr/dt-bindings/pwm/ra_pwm.h>
/ { / {
model = "Arduino Uno R4 WiFi"; model = "Arduino Uno R4 WiFi";
@ -14,8 +19,18 @@
}; };
}; };
pwm_leds {
compatible = "pwm-leds";
status = "disabled";
pwm_led: pwm_led {
pwms = <&pwm2 1 PWM_MSEC(1) PWM_POLARITY_NORMAL>;
label = "PWM_LED";
};
};
aliases { aliases {
led0 = &led; led0 = &led;
pwm-led0 = &pwm_led;
}; };
arduino_header: connector { arduino_header: connector {
@ -47,3 +62,26 @@
<21 0 &ioport1 0 0>; /* D15 */ <21 0 &ioport1 0 0>; /* D15 */
}; };
}; };
&spi0 {
pinctrl-0 = <&spi0_default>;
pinctrl-names = "default";
interrupts = <28 1>, <29 1>, <30 1>, <31 1>;
interrupt-names = "rxi", "txi", "tei", "eri";
status = "okay";
};
&iic0 {
pinctrl-0 = <&iic0_default>;
pinctrl-names = "default";
#address-cells = <1>;
#size-cells = <0>;
clock-frequency = <DT_FREQ_M(1)>;
interrupts = <14 1>, <15 1>, <16 1>, <17 1>;
interrupt-names = "rxi", "txi", "tei", "eri";
status = "okay";
};
qwiic_i2c: &iic0 {};
arduino_i2c: &iic1 {};
arduino_spi: &spi0 {};

3
boards/arduino/uno_r4/arduino_uno_r4_wifi.yaml

@ -7,5 +7,8 @@ toolchain:
- gnuarmemb - gnuarmemb
ram: 32 ram: 32
supported: supported:
- adc
- gpio - gpio
- pwm
- spi
- uart - uart

36
samples/basic/blinky_pwm/boards/arduino_uno_r4_r7fa4m1ab3cfm_minima.overlay

@ -0,0 +1,36 @@
/*
* Copyright (c) 2025 TOKITA Hiroshi
*
* SPDX-License-Identifier: Apache-2.0
*/
#include <zephyr/dt-bindings/pwm/pwm.h>
#include <zephyr/dt-bindings/pwm/ra_pwm.h>
/ {
leds {
status = "disabled";
};
pwm_leds {
status = "okay";
};
};
&pinctrl {
pwm3_default: pwm3_default {
group1 {
/* GTIOC3A */
psels = <RA_PSEL(RA_PSEL_GPT1, 1, 11)>;
};
};
};
&pwm3 {
pinctrl-0 = <&pwm3_default>;
pinctrl-names = "default";
interrupts = <30 1>, <31 1>;
interrupt-names = "gtioca", "overflow";
status = "okay";
divider = <RA_PWM_SOURCE_DIV_1024>;
};

36
samples/basic/blinky_pwm/boards/arduino_uno_r4_r7fa4m1ab3cfm_wifi.overlay

@ -0,0 +1,36 @@
/*
* Copyright (c) 2025 TOKITA Hiroshi
*
* SPDX-License-Identifier: Apache-2.0
*/
#include <zephyr/dt-bindings/pwm/pwm.h>
#include <zephyr/dt-bindings/pwm/ra_pwm.h>
/ {
leds {
status = "disabled";
};
pwm_leds {
status = "okay";
};
};
&pinctrl {
pwm2_default: pwm2_default {
group1 {
/* GTIOC2B */
psels = <RA_PSEL(RA_PSEL_GPT1, 1, 2)>;
};
};
};
&pwm2 {
pinctrl-0 = <&pwm2_default>;
pinctrl-names = "default";
interrupts = <30 1>, <31 1>;
interrupt-names = "gtioca", "overflow";
status = "okay";
divider = <RA_PWM_SOURCE_DIV_1024>;
};

36
samples/basic/fade_led/boards/arduino_uno_r4_r7fa4m1ab3cfm_minima.overlay

@ -0,0 +1,36 @@
/*
* Copyright (c) 2025 TOKITA Hiroshi
*
* SPDX-License-Identifier: Apache-2.0
*/
#include <zephyr/dt-bindings/pwm/pwm.h>
#include <zephyr/dt-bindings/pwm/ra_pwm.h>
/ {
leds {
status = "disabled";
};
pwm_leds {
status = "okay";
};
};
&pinctrl {
pwm3_default: pwm3_default {
group1 {
/* GTIOC3A */
psels = <RA_PSEL(RA_PSEL_GPT1, 1, 11)>;
};
};
};
&pwm3 {
pinctrl-0 = <&pwm3_default>;
pinctrl-names = "default";
interrupts = <30 1>, <31 1>;
interrupt-names = "gtioca", "overflow";
status = "okay";
divider = <RA_PWM_SOURCE_DIV_1024>;
};

36
samples/basic/fade_led/boards/arduino_uno_r4_r7fa4m1ab3cfm_wifi.overlay

@ -0,0 +1,36 @@
/*
* Copyright (c) 2025 TOKITA Hiroshi
*
* SPDX-License-Identifier: Apache-2.0
*/
#include <zephyr/dt-bindings/pwm/pwm.h>
#include <zephyr/dt-bindings/pwm/ra_pwm.h>
/ {
leds {
status = "disabled";
};
pwm_leds {
status = "okay";
};
};
&pinctrl {
pwm2_default: pwm2_default {
group1 {
/* GTIOC2B */
psels = <RA_PSEL(RA_PSEL_GPT1, 1, 2)>;
};
};
};
&pwm2 {
pinctrl-0 = <&pwm2_default>;
pinctrl-names = "default";
interrupts = <30 1>, <31 1>;
interrupt-names = "gtioca", "overflow";
status = "okay";
divider = <RA_PWM_SOURCE_DIV_1024>;
};

53
samples/drivers/adc/adc_dt/boards/arduino_uno_r4.overlay

@ -0,0 +1,53 @@
/*
* Copyright (c) 2025 TOKITA Hiroshi
*
* SPDX-License-Identifier: Apache-2.0
*/
/ {
zephyr,user {
io-channels = <&adc0 0>, <&adc0 1>, <&adc0 2>, <&adc0 9>;
};
};
&adc0 {
status = "okay";
#address-cells = <1>;
#size-cells = <0>;
channel@0 {
reg = <0>;
zephyr,gain = "ADC_GAIN_1";
zephyr,reference = "ADC_REF_VDD_1";
zephyr,resolution = <12>;
zephyr,acquisition-time = <ADC_ACQ_TIME_DEFAULT>;
zephyr,vref-mv = <5000>;
};
channel@1 {
reg = <1>;
zephyr,gain = "ADC_GAIN_1";
zephyr,reference = "ADC_REF_VDD_1";
zephyr,resolution = <12>;
zephyr,acquisition-time = <ADC_ACQ_TIME_DEFAULT>;
zephyr,vref-mv = <5000>;
};
channel@2 {
reg = <2>;
zephyr,gain = "ADC_GAIN_1";
zephyr,reference = "ADC_REF_VDD_1";
zephyr,resolution = <12>;
zephyr,acquisition-time = <ADC_ACQ_TIME_DEFAULT>;
zephyr,vref-mv = <5000>;
};
channel@9 {
reg = <9>;
zephyr,gain = "ADC_GAIN_1";
zephyr,reference = "ADC_REF_VDD_1";
zephyr,resolution = <12>;
zephyr,acquisition-time = <ADC_ACQ_TIME_DEFAULT>;
zephyr,vref-mv = <5000>;
};
};

3
samples/drivers/led/pwm/boards/arduino_uno_r4_r7fa4m1ab3cfm_minima.conf

@ -0,0 +1,3 @@
CONFIG_BLINK_DELAY_SHORT=20
CONFIG_BLINK_DELAY_LONG=65
CONFIG_FADE_DELAY=15

30
samples/drivers/led/pwm/boards/arduino_uno_r4_r7fa4m1ab3cfm_minima.overlay

@ -0,0 +1,30 @@
#include <zephyr/dt-bindings/pwm/pwm.h>
#include <zephyr/dt-bindings/pwm/ra_pwm.h>
/ {
leds {
status = "disabled";
};
pwm_leds {
status = "okay";
};
};
&pinctrl {
pwm3_default: pwm3_default {
group1 {
/* GTIOC3A */
psels = <RA_PSEL(RA_PSEL_GPT1, 1, 11)>;
};
};
};
&pwm3 {
pinctrl-0 = <&pwm3_default>;
pinctrl-names = "default";
interrupts = <30 1>, <31 1>;
interrupt-names = "gtioca", "overflow";
status = "okay";
divider = <RA_PWM_SOURCE_DIV_1024>;
};

3
samples/drivers/led/pwm/boards/arduino_uno_r4_r7fa4m1ab3cfm_wifi.conf

@ -0,0 +1,3 @@
CONFIG_BLINK_DELAY_SHORT=20
CONFIG_BLINK_DELAY_LONG=65
CONFIG_FADE_DELAY=15

30
samples/drivers/led/pwm/boards/arduino_uno_r4_r7fa4m1ab3cfm_wifi.overlay

@ -0,0 +1,30 @@
#include <zephyr/dt-bindings/pwm/pwm.h>
#include <zephyr/dt-bindings/pwm/ra_pwm.h>
/ {
leds {
status = "disabled";
};
pwm_leds {
status = "okay";
};
};
&pinctrl {
pwm2_default: pwm2_default {
group1 {
/* GTIOC2B */
psels = <RA_PSEL(RA_PSEL_GPT1, 1, 2)>;
};
};
};
&pwm2 {
pinctrl-0 = <&pwm2_default>;
pinctrl-names = "default";
interrupts = <30 1>, <31 1>;
interrupt-names = "gtioca", "overflow";
status = "okay";
divider = <RA_PWM_SOURCE_DIV_1024>;
};

35
tests/drivers/adc/adc_api/boards/arduino_uno_r4.overlay

@ -0,0 +1,35 @@
/*
* Copyright (c) 2025 TOKITA Hiroshi
*
* SPDX-License-Identifier: Apache-2.0
*/
/ {
zephyr,user {
io-channels = <&adc0 0>, <&adc0 1>;
};
};
&adc0 {
status = "okay";
#address-cells = <1>;
#size-cells = <0>;
channel@0 {
reg = <0>;
zephyr,gain = "ADC_GAIN_1";
zephyr,reference = "ADC_REF_INTERNAL";
zephyr,resolution = <12>;
zephyr,acquisition-time = <ADC_ACQ_TIME_DEFAULT>;
zephyr,vref-mv = <5000>;
};
channel@1 {
reg = <1>;
zephyr,gain = "ADC_GAIN_1";
zephyr,reference = "ADC_REF_INTERNAL";
zephyr,resolution = <12>;
zephyr,acquisition-time = <ADC_ACQ_TIME_DEFAULT>;
zephyr,vref-mv = <5000>;
};
};

34
tests/drivers/pwm/pwm_loopback/boards/arduino_uno_r4.overlay

@ -0,0 +1,34 @@
/*
* Copyright (c) 2025 TOKITA Hiroshi
*
* SPDX-License-Identifier: Apache-2.0
*/
#include <zephyr/dt-bindings/pwm/pwm.h>
#include <zephyr/dt-bindings/pwm/ra_pwm.h>
/ {
pwm_loopback_0 {
compatible = "test-pwm-loopback";
/* first index must be a 32-Bit timer */
pwms = <&pwm0 0 0 PWM_POLARITY_NORMAL>,
<&pwm7 0 0 PWM_POLARITY_NORMAL>;
};
};
&pinctrl {
pwm0_default: pwm0_default {
group1 {
/* GTIOC0A */
psels = <RA_PSEL(RA_PSEL_GPT1, 1, 7)>;
};
};
};
&pwm0 {
pinctrl-0 = <&pwm0_default>;
pinctrl-names = "default";
interrupts = <30 1>, <31 1>;
interrupt-names = "gtioca", "overflow";
status = "okay";
};

21
tests/drivers/spi/spi_loopback/boards/arduino_uno_r4_r7fa4m1ab3cfm_minima.overlay

@ -0,0 +1,21 @@
/*
* Copyright (c) 2025 TOKITA Hiroshi
* SPDX-License-Identifier: Apache-2.0
*/
&spi1 {
rx-dtc;
tx-dtc;
slow@0 {
compatible = "test-spi-loopback-slow";
reg = <0>;
spi-max-frequency = <2000000>;
};
fast@0 {
compatible = "test-spi-loopback-fast";
reg = <0>;
spi-max-frequency = <3000000>;
};
};

21
tests/drivers/spi/spi_loopback/boards/arduino_uno_r4_r7fa4m1ab3cfm_wifi.overlay

@ -0,0 +1,21 @@
/*
* Copyright (c) 2025 TOKITA Hiroshi
* SPDX-License-Identifier: Apache-2.0
*/
&spi0 {
rx-dtc;
tx-dtc;
slow@0 {
compatible = "test-spi-loopback-slow";
reg = <0>;
spi-max-frequency = <2000000>;
};
fast@0 {
compatible = "test-spi-loopback-fast";
reg = <0>;
spi-max-frequency = <3000000>;
};
};
Loading…
Cancel
Save