diff --git a/drivers/dac/CMakeLists.txt b/drivers/dac/CMakeLists.txt index d6869cc234a..eec91be800a 100644 --- a/drivers/dac/CMakeLists.txt +++ b/drivers/dac/CMakeLists.txt @@ -24,3 +24,4 @@ zephyr_library_sources_ifdef(CONFIG_DAC_AD56XX dac_ad56xx.c) zephyr_library_sources_ifdef(CONFIG_DAC_AD569X dac_ad569x.c) zephyr_library_sources_ifdef(CONFIG_USERSPACE dac_handlers.c) zephyr_library_sources_ifdef(CONFIG_DAC_MCUX_GAU dac_mcux_gau.c) +zephyr_library_sources_ifdef(CONFIG_DAC_TEST dac_test.c) diff --git a/drivers/dac/Kconfig b/drivers/dac/Kconfig index 08680b96404..26b17f1a31d 100644 --- a/drivers/dac/Kconfig +++ b/drivers/dac/Kconfig @@ -59,4 +59,6 @@ source "drivers/dac/Kconfig.ad559x" source "drivers/dac/Kconfig.ad569x" +source "drivers/dac/Kconfig.test" + endif # DAC diff --git a/drivers/dac/Kconfig.test b/drivers/dac/Kconfig.test new file mode 100644 index 00000000000..dbca0a8c8ba --- /dev/null +++ b/drivers/dac/Kconfig.test @@ -0,0 +1,6 @@ +# Copyright (c) 2024 TOKITA Hiroshi +# SPDX-License-Identifier: Apache-2.0 + +config DAC_TEST + def_bool DT_HAS_VND_DAC_ENABLED + depends on DT_HAS_VND_DAC_ENABLED diff --git a/drivers/dac/dac_test.c b/drivers/dac/dac_test.c new file mode 100644 index 00000000000..24880c5bcc4 --- /dev/null +++ b/drivers/dac/dac_test.c @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2024 TOKITA Hiroshi + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#define DT_DRV_COMPAT vnd_dac + +#include +#include + +int vnd_dac_channel_setup(const struct device *dev, const struct dac_channel_cfg *channel_cfg) +{ + ARG_UNUSED(dev); + ARG_UNUSED(channel_cfg); + + return -ENOTSUP; +} + +int vnd_dac_write_value(const struct device *dev, uint8_t channel, uint32_t value) +{ + ARG_UNUSED(dev); + ARG_UNUSED(channel); + ARG_UNUSED(value); + + return -ENOTSUP; +} + +static const struct dac_driver_api vnd_dac_driver_api = { + .channel_setup = vnd_dac_channel_setup, + .write_value = vnd_dac_write_value, +}; + +static int vnd_dac_init(const struct device *dev) +{ + ARG_UNUSED(dev); + + return 0; +} + +#define VND_DAC_INIT(index) \ + DEVICE_DT_INST_DEFINE(index, &vnd_dac_init, NULL, NULL, NULL, POST_KERNEL, \ + CONFIG_DAC_INIT_PRIORITY, &vnd_dac_driver_api); + +DT_INST_FOREACH_STATUS_OKAY(VND_DAC_INIT) diff --git a/dts/bindings/test/vnd,dac.yaml b/dts/bindings/test/vnd,dac.yaml new file mode 100644 index 00000000000..b7682b22d51 --- /dev/null +++ b/dts/bindings/test/vnd,dac.yaml @@ -0,0 +1,8 @@ +# Copyright (c) 2024 TOKITA Hiroshi +# SPDX-License-Identifier: Apache-2.0 + +description: Test DAC node + +compatible: "vnd,dac" + +include: dac-controller.yaml