// Файл: <папка_вашего_проекта>/src/tfa9882_driver.c
#define DT_DRV_COMPAT tfa9882_codec
#include <zephyr/device.h>
#include <zephyr/audio/codec.h>
static int tfa9882_configure(const struct device *dev, struct audio_codec_cfg *cfg)
{
ARG_UNUSED(dev);
ARG_UNUSED(cfg);
return 0; // Нам нечего конфигурировать, возвращаем успех
}
static int tfa9882_set_property(const struct device *dev, audio_property_t property,
audio_channel_t channel, audio_property_value_t val)
{
ARG_UNUSED(dev); ARG_UNUSED(property); ARG_UNUSED(channel); ARG_UNUSED(val);
return 0;
}
static int tfa9882_start(const struct device *dev, audio_dai_dir_t dir)
{
ARG_UNUSED(dev); ARG_UNUSED(dir);
return 0;
}
static int tfa9882_stop(const struct device *dev, audio_dai_dir_t dir)
{
ARG_UNUSED(dev); ARG_UNUSED(dir);
return 0;
}
static const struct audio_codec_api tfa9882_api = {
.configure = tfa9882_configure,
.set_property = tfa9882_set_property,
.start = tfa9882_start,
.stop = tfa9882_stop,
};
static int tfa9882_init(const struct device *dev)
{
ARG_UNUSED(dev);
return 0;
}
// Регистрируем устройство для каждой найденной ноды в devicetree
#define TFA9882_DEFINE(inst) \
DEVICE_DT_INST_DEFINE(inst, tfa9882_init, NULL, NULL, NULL, POST_KERNEL, \
CONFIG_AUDIO_CODEC_INIT_PRIORITY, &tfa9882_api);
DT_INST_FOREACH_STATUS_OKAY(TFA9882_DEFINE)