From 91264ba704f5141bdb6788cf249ed3ab30cd7e32 Mon Sep 17 00:00:00 2001 From: "Daniel P. Carvalho" Date: Thu, 29 Jul 2021 17:55:46 -0300 Subject: [PATCH] nucleo-g431kb: modify COMP example COMP example was changed to use DAC3CH2 signal on COMP INM input. --- .../nucleo-g431kb/configs/comp/defconfig | 7 ++++++ .../arm/stm32/nucleo-g431kb/src/stm32_dac.c | 23 +++++++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/boards/arm/stm32/nucleo-g431kb/configs/comp/defconfig b/boards/arm/stm32/nucleo-g431kb/configs/comp/defconfig index 5ac495da0f..154423ef95 100644 --- a/boards/arm/stm32/nucleo-g431kb/configs/comp/defconfig +++ b/boards/arm/stm32/nucleo-g431kb/configs/comp/defconfig @@ -16,7 +16,10 @@ CONFIG_ARCH_STACKDUMP=y CONFIG_BOARD_LOOPSPERMSEC=5483 CONFIG_BUILTIN=y CONFIG_COMP=y +CONFIG_DAC=y CONFIG_DEFAULT_SMALL=y +CONFIG_EXAMPLES_DAC=y +CONFIG_EXAMPLES_DAC_DEVPATH="/dev/dac5" CONFIG_INTELHEX_BINARY=y CONFIG_NSH_ARCHINIT=y CONFIG_NSH_BUILTIN_APPS=y @@ -32,7 +35,11 @@ CONFIG_START_MONTH=6 CONFIG_START_YEAR=2021 CONFIG_STM32_COMP2=y CONFIG_STM32_COMP2_HYST=3 +CONFIG_STM32_COMP2_INM=4 CONFIG_STM32_COMP2_OUT=y +CONFIG_STM32_DAC3=y +CONFIG_STM32_DAC3CH2=y +CONFIG_STM32_DAC3CH2_MODE=3 CONFIG_STM32_DISABLE_IDLE_SLEEP_DURING_DEBUG=y CONFIG_STM32_FORCEPOWER=y CONFIG_STM32_JTAG_FULL_ENABLE=y diff --git a/boards/arm/stm32/nucleo-g431kb/src/stm32_dac.c b/boards/arm/stm32/nucleo-g431kb/src/stm32_dac.c index e5bed08fe2..1040a8b7d3 100644 --- a/boards/arm/stm32/nucleo-g431kb/src/stm32_dac.c +++ b/boards/arm/stm32/nucleo-g431kb/src/stm32_dac.c @@ -42,6 +42,10 @@ static struct dac_dev_s *g_dac1; #endif +#ifdef CONFIG_STM32_DAC3CH2 +static struct dac_dev_s *g_dac5; +#endif + /**************************************************************************** * Public Functions ****************************************************************************/ @@ -80,6 +84,25 @@ int stm32_dac_setup(void) return ret; } +#endif + +#ifdef CONFIG_STM32_DAC3CH2 + g_dac5 = stm32_dacinitialize(5); + if (g_dac5 == NULL) + { + aerr("ERROR: Failed to get DAC interface\n"); + return -ENODEV; + } + + /* Register the DAC driver at "/dev/dac5" */ + + ret = dac_register("/dev/dac5", g_dac5); + if (ret < 0) + { + aerr("ERROR: dac_register() failed: %d\n", ret); + return ret; + } + #endif UNUSED(ret);