Lines Matching +full:dac +full:- +full:reference
4 * SPDX-License-Identifier: Apache-2.0
9 #include <zephyr/drivers/dac.h>
11 #include <zephyr/dt-bindings/dac/dacx0508.h>
36 uint8_t reference; member
47 const struct dacx0508_config *config = dev->config; in dacx0508_reg_read()
71 return -EWOULDBLOCK; in dacx0508_reg_read()
76 ret = spi_write_dt(&config->bus, &tx); in dacx0508_reg_read()
81 ret = spi_read_dt(&config->bus, &rx); in dacx0508_reg_read()
87 return -EIO; in dacx0508_reg_read()
96 const struct dacx0508_config *config = dev->config; in dacx0508_reg_write()
114 return -EWOULDBLOCK; in dacx0508_reg_write()
117 return spi_write_dt(&config->bus, &tx); in dacx0508_reg_write()
153 const struct dacx0508_config *config = dev->config; in dacx0508_channel_setup()
154 struct dacx0508_data *data = dev->data; in dacx0508_channel_setup()
156 if (channel_cfg->channel_id > DACX0508_MAX_CHANNEL - 1) { in dacx0508_channel_setup()
157 LOG_ERR("Unsupported channel %d", channel_cfg->channel_id); in dacx0508_channel_setup()
158 return -ENOTSUP; in dacx0508_channel_setup()
161 if (channel_cfg->resolution != config->resolution) { in dacx0508_channel_setup()
162 LOG_ERR("Unsupported resolution %d", channel_cfg->resolution); in dacx0508_channel_setup()
163 return -ENOTSUP; in dacx0508_channel_setup()
166 if (channel_cfg->internal) { in dacx0508_channel_setup()
168 return -ENOTSUP; in dacx0508_channel_setup()
171 data->configured |= BIT(channel_cfg->channel_id); in dacx0508_channel_setup()
179 const struct dacx0508_config *config = dev->config; in dacx0508_write_value()
180 struct dacx0508_data *data = dev->data; in dacx0508_write_value()
184 if (channel > DACX0508_MAX_CHANNEL - 1) { in dacx0508_write_value()
186 return -ENOTSUP; in dacx0508_write_value()
189 if (!(data->configured & BIT(channel))) { in dacx0508_write_value()
191 return -EINVAL; in dacx0508_write_value()
194 if (value >= (1 << config->resolution)) { in dacx0508_write_value()
196 return -EINVAL; in dacx0508_write_value()
199 value <<= (16 - config->resolution); in dacx0508_write_value()
205 return -EIO; in dacx0508_write_value()
218 return -EIO; in dacx0508_soft_reset()
227 const struct dacx0508_config *config = dev->config; in dacx0508_device_id_check()
236 return -EIO; in dacx0508_device_id_check()
241 if (resolution != (16 - config->resolution) >> 1) { in dacx0508_device_id_check()
243 return -EINVAL; in dacx0508_device_id_check()
249 return -EINVAL; in dacx0508_device_id_check()
257 const struct dacx0508_config *config = dev->config; in dacx0508_setup()
262 switch (config->reference) { in dacx0508_setup()
280 LOG_ERR("unsupported channel reference type '%d'", in dacx0508_setup()
281 config->reference); in dacx0508_setup()
282 return -ENOTSUP; in dacx0508_setup()
289 return -EIO; in dacx0508_setup()
296 return -EIO; in dacx0508_setup()
301 tmp |= config->gain[i] << i; in dacx0508_setup()
307 return -EIO; in dacx0508_setup()
314 return -EIO; in dacx0508_setup()
320 return -EIO; in dacx0508_setup()
326 return -EIO; in dacx0508_setup()
334 const struct dacx0508_config *config = dev->config; in dacx0508_init()
335 struct dacx0508_data *data = dev->data; in dacx0508_init()
338 if (!spi_is_ready_dt(&config->bus)) { in dacx0508_init()
339 LOG_ERR("SPI bus %s not ready", config->bus.bus->name); in dacx0508_init()
340 return -ENODEV; in dacx0508_init()
345 LOG_ERR("Soft-reset failed"); in dacx0508_init()
359 data->configured = 0; in dacx0508_init()
364 static DEVICE_API(dac, dacx0508_driver_api) = {
372 static struct dacx0508_data dac##t##_data_##n; \
373 static const struct dacx0508_config dac##t##_config_##n = { \
378 .reference = DT_PROP(INST_DT_DACX0508(n, t), \
391 &dac##t##_data_##n, \
392 &dac##t##_config_##n, POST_KERNEL, \
397 * DAC60508: 12-bit
402 * DAC70508: 14-bit
407 * DAC80508: 16-bit