From b334ba77c0269fd6e3395e25bf6c4d04317da399 Mon Sep 17 00:00:00 2001 From: Alex Fabre Date: Tue, 25 Jun 2024 11:34:13 +0200 Subject: [PATCH] boards: st: add `adc1` peripheral for `nucleo_h533re` This nucleo board inherit from the root `h5` dts some special nodes: - `vbat` on adc1 channel 2 - `vref` on adc1 channel 17 - `die_temp` on adc1 channel 16 The issue is discussed here: https://github.com/zephyrproject-rtos/zephyr/issues/72914 (cherry picked from commit 648f6dcac41e009f376d7793014e4557c8404fe1) Original-Signed-off-by: Alex Fabre GitOrigin-RevId: 648f6dcac41e009f376d7793014e4557c8404fe1 Change-Id: I73bbe54c7534709464e3d7eb23c6461b44c1932e Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/zephyr/+/5666209 Reviewed-by: Ting Shen Tested-by: Ting Shen Tested-by: ChromeOS Prod (Robot) Commit-Queue: Ting Shen --- boards/st/nucleo_h533re/nucleo_h533re.dts | 18 +++++++++++++ .../adc/adc_api/boards/nucleo_h533re.overlay | 25 +++++++++++++++++++ 2 files changed, 43 insertions(+) create mode 100644 tests/drivers/adc/adc_api/boards/nucleo_h533re.overlay diff --git a/boards/st/nucleo_h533re/nucleo_h533re.dts b/boards/st/nucleo_h533re/nucleo_h533re.dts index 7071a5e21a8..5dc9e15aa2b 100644 --- a/boards/st/nucleo_h533re/nucleo_h533re.dts +++ b/boards/st/nucleo_h533re/nucleo_h533re.dts @@ -53,7 +53,9 @@ pwm-led0 = &green_pwm_led; sw0 = &user_button; watchdog0 = &iwdg; + die-temp0 = &die_temp; volt-sensor0 = &vref; + volt-sensor1 = &vbat; }; }; @@ -118,10 +120,26 @@ }; }; +&adc1 { + pinctrl-0 = <&adc1_inp0_pa0>; /* Arduino A0 */ + pinctrl-names = "default"; + st,adc-clock-source = ; + st,adc-prescaler = <8>; + status = "okay"; +}; + +&die_temp { + status = "okay"; +}; + &vref { status = "okay"; }; +&vbat { + status = "okay"; +}; + &rng { status = "okay"; }; diff --git a/tests/drivers/adc/adc_api/boards/nucleo_h533re.overlay b/tests/drivers/adc/adc_api/boards/nucleo_h533re.overlay new file mode 100644 index 00000000000..9f34fcb72e8 --- /dev/null +++ b/tests/drivers/adc/adc_api/boards/nucleo_h533re.overlay @@ -0,0 +1,25 @@ +/* + * SPDX-License-Identifier: Apache-2.0 + * + * Copyright (c) Alex Fabre + */ + +/ { + zephyr,user { + /* adjust channel number according to pinmux in board.dts */ + io-channels = <&adc1 0>; + }; +}; + +&adc1 { + #address-cells = <1>; + #size-cells = <0>; + + channel@0 { + reg = <0>; + zephyr,gain = "ADC_GAIN_1"; + zephyr,reference = "ADC_REF_INTERNAL"; + zephyr,acquisition-time = ; + zephyr,resolution = <12>; + }; +};