Skip to content

Commit a1bd7cf

Browse files
djiatsaf-stkartben
authored andcommitted
tests: drivers: adc: adc_api: update adc_api test
- add nucleo_c071rb overlay file to setup adc node - The C0 serie has two HSI clock sources, HSI48 and HSI48USB. To make it simpler and compatible with the existing clock driver, HSI48 is renamed to HSI (node already present in the stm32c0.dtsi). HSI48USB will correspond to HSI48. With SYNC mode, we have an overrun on the ADC, so we configure it in ASYNC mode. - Update STM32 HSI macro according to changes Signed-off-by: Fabrice DJIATSA <[email protected]>
1 parent 7d6f106 commit a1bd7cf

File tree

3 files changed

+47
-3
lines changed

3 files changed

+47
-3
lines changed

boards/st/nucleo_c071rb/nucleo_c071rb.dts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,10 @@
7272
status = "okay";
7373
};
7474

75+
&clk_hsi {
76+
status = "okay";
77+
};
78+
7579
&rcc {
7680
clocks = <&clk_hse>;
7781
clock-frequency = <DT_FREQ_M(48)>;
@@ -138,7 +142,9 @@
138142
&adc1 {
139143
pinctrl-0 = <&adc1_in0_pa0 &adc1_in1_pa1 &adc1_in4_pa4>;
140144
pinctrl-names = "default";
141-
st,adc-clock-source = "SYNC";
145+
st,adc-clock-source = "ASYNC";
146+
clocks = <&rcc STM32_CLOCK(APB1_2, 20U)>,
147+
<&rcc STM32_SRC_HSI ADC_SEL(2)>;
142148
st,adc-prescaler = <4>;
143149
status = "okay";
144150
vref-mv = <3300>;

include/zephyr/dt-bindings/clock/stm32c0_clock.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@
2424
/* defined in stm32_common_clocks.h */
2525
/** Fixed clocks */
2626
/* Low speed clocks defined in stm32_common_clocks.h */
27-
#define STM32_SRC_HSI48 (STM32_SRC_LSI + 1)
28-
#define STM32_SRC_HSE (STM32_SRC_HSI48 + 1)
27+
#define STM32_SRC_HSI (STM32_SRC_LSI + 1)
28+
#define STM32_SRC_HSE (STM32_SRC_HSI + 1)
2929
/** Peripheral bus clock */
3030
#define STM32_SRC_PCLK (STM32_SRC_HSE + 1)
3131

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
/*
2+
* SPDX-License-Identifier: Apache-2.0
3+
*
4+
* Copyright (c) 2025 STMicroelectronics
5+
*/
6+
7+
/ {
8+
zephyr,user {
9+
/* adjust channel number according to pinmux in board.dts */
10+
io-channels = <&adc1 0>, <&adc1 1>;
11+
};
12+
};
13+
14+
&adc1 {
15+
16+
dmas = <&dmamux1 0 5 (STM32_DMA_PERIPH_RX | STM32_DMA_MEM_16BITS |
17+
STM32_DMA_PERIPH_16BITS)>;
18+
dma-names = "dmamux";
19+
20+
#address-cells = <1>;
21+
#size-cells = <0>;
22+
23+
channel@0 {
24+
reg = <0>;
25+
zephyr,gain = "ADC_GAIN_1";
26+
zephyr,reference = "ADC_REF_INTERNAL";
27+
zephyr,acquisition-time = <ADC_ACQ_TIME_MAX>;
28+
zephyr,resolution = <12>;
29+
};
30+
31+
channel@1 {
32+
reg = <1>;
33+
zephyr,gain = "ADC_GAIN_1";
34+
zephyr,reference = "ADC_REF_INTERNAL";
35+
zephyr,acquisition-time = <ADC_ACQ_TIME_MAX>;
36+
zephyr,resolution = <12>;
37+
};
38+
};

0 commit comments

Comments
 (0)