board: arm: nucleo_f207zg: add DAC support
Add DAC support to nucleo_f207zg:
Signed-off-by: Alexandre Bourdiol <alexandre.bourdiol@st.com>
diff --git a/boards/arm/nucleo_f207zg/doc/index.rst b/boards/arm/nucleo_f207zg/doc/index.rst
index b1f818d..5264ab8 100644
--- a/boards/arm/nucleo_f207zg/doc/index.rst
+++ b/boards/arm/nucleo_f207zg/doc/index.rst
@@ -92,6 +92,8 @@
+-----------+------------+-------------------------------------+
| ADC | on-chip | ADC Controller |
+-----------+------------+-------------------------------------+
+| DAC | on-chip | DAC Controller |
++-----------+------------+-------------------------------------+
Other hardware features are not yet supported on this Zephyr port.
@@ -142,6 +144,8 @@
- LD1 : PB0
- LD2 : PB7
- LD3 : PB14
+- DAC: PA4
+- ADC: PA0
System Clock
------------
diff --git a/boards/arm/nucleo_f207zg/nucleo_f207zg.dts b/boards/arm/nucleo_f207zg/nucleo_f207zg.dts
index 4865cc4..c531323 100644
--- a/boards/arm/nucleo_f207zg/nucleo_f207zg.dts
+++ b/boards/arm/nucleo_f207zg/nucleo_f207zg.dts
@@ -77,7 +77,10 @@
status = "okay";
};
-
&mac {
status = "okay";
};
+
+&dac1 {
+ status = "okay";
+};
diff --git a/boards/arm/nucleo_f207zg/nucleo_f207zg.yaml b/boards/arm/nucleo_f207zg/nucleo_f207zg.yaml
index 89ea116..3db246f 100644
--- a/boards/arm/nucleo_f207zg/nucleo_f207zg.yaml
+++ b/boards/arm/nucleo_f207zg/nucleo_f207zg.yaml
@@ -15,3 +15,4 @@
- watchdog
- counter
- adc
+ - dac
diff --git a/boards/arm/nucleo_f207zg/pinmux.c b/boards/arm/nucleo_f207zg/pinmux.c
index ac17fe8..67ae3b8 100644
--- a/boards/arm/nucleo_f207zg/pinmux.c
+++ b/boards/arm/nucleo_f207zg/pinmux.c
@@ -42,6 +42,9 @@
#if DT_NODE_HAS_STATUS(DT_NODELABEL(adc1), okay) && CONFIG_ADC
{STM32_PIN_PA0, STM32F2_PINMUX_FUNC_PA0_ADC123_IN0},
#endif
+#if DT_NODE_HAS_STATUS(DT_NODELABEL(dac1), okay) && CONFIG_DAC
+ {STM32_PIN_PA4, STM32F2_PINMUX_FUNC_PA4_DAC_OUT1},
+#endif
};
static int pinmux_stm32_init(struct device *port)
diff --git a/drivers/pinmux/stm32/pinmux_stm32f2.h b/drivers/pinmux/stm32/pinmux_stm32f2.h
index c869bdc..d4fbb17 100644
--- a/drivers/pinmux/stm32/pinmux_stm32f2.h
+++ b/drivers/pinmux/stm32/pinmux_stm32f2.h
@@ -50,9 +50,13 @@
#define STM32F2_PINMUX_FUNC_PA4_ADC12_IN4 \
STM32_MODER_ANALOG_MODE
+#define STM32F2_PINMUX_FUNC_PA4_DAC_OUT1 \
+ STM32_MODER_ANALOG_MODE
#define STM32F2_PINMUX_FUNC_PA5_ADC12_IN5 \
STM32_MODER_ANALOG_MODE
+#define STM32F2_PINMUX_FUNC_PA5_DAC_OUT2 \
+ STM32_MODER_ANALOG_MODE
#define STM32F2_PINMUX_FUNC_PA6_ADC12_IN6 \
STM32_MODER_ANALOG_MODE
diff --git a/dts/arm/st/f2/stm32f2.dtsi b/dts/arm/st/f2/stm32f2.dtsi
index 2924ff9..284b99a 100644
--- a/dts/arm/st/f2/stm32f2.dtsi
+++ b/dts/arm/st/f2/stm32f2.dtsi
@@ -267,6 +267,15 @@
status = "disabled";
label = "DMA_2";
};
+
+ dac1: dac@40007400 {
+ compatible = "st,stm32-dac";
+ reg = <0x40007400 0x400>;
+ clocks = <&rcc STM32_CLOCK_BUS_APB1 0x20000000>;
+ status = "disabled";
+ label = "DAC_1";
+ #io-channel-cells = <1>;
+ };
};
otgfs_phy: otgfs_phy {
diff --git a/soc/arm/st_stm32/stm32f2/soc.h b/soc/arm/st_stm32/stm32f2/soc.h
index c13f0cd..df13d38 100644
--- a/soc/arm/st_stm32/stm32f2/soc.h
+++ b/soc/arm/st_stm32/stm32f2/soc.h
@@ -61,6 +61,10 @@
#include <stm32f2xx_ll_adc.h>
#endif
+#ifdef CONFIG_DAC_STM32
+#include <stm32f2xx_ll_dac.h>
+#endif
+
#ifdef CONFIG_DMA_STM32
#include <stm32f2xx_ll_dma.h>
#endif