drivers: dac: Add dummy driver for vnd,dac

Add dummy driver for "vnd,dac" to use in build_all tests.

Signed-off-by: TOKITA Hiroshi <tokita.hiroshi@gmail.com>
This commit is contained in:
TOKITA Hiroshi 2024-09-29 09:06:58 +09:00 committed by Alberto Escolar
parent cc6dfb6220
commit 1f30346d4f
5 changed files with 62 additions and 0 deletions

View File

@ -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)

View File

@ -59,4 +59,6 @@ source "drivers/dac/Kconfig.ad559x"
source "drivers/dac/Kconfig.ad569x"
source "drivers/dac/Kconfig.test"
endif # DAC

6
drivers/dac/Kconfig.test Normal file
View File

@ -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

45
drivers/dac/dac_test.c Normal file
View File

@ -0,0 +1,45 @@
/*
* Copyright (c) 2024 TOKITA Hiroshi
*
* SPDX-License-Identifier: Apache-2.0
*/
#define DT_DRV_COMPAT vnd_dac
#include <zephyr/kernel.h>
#include <zephyr/drivers/dac.h>
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)

View File

@ -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