Lines Matching +full:dac +full:- +full:reference

4  * SPDX-License-Identifier: Apache-2.0
18 #include <zephyr/drivers/dac.h>
40 /* Specifies the source of the reference voltage. */
42 REF_INTERNAL, /* Internal 2.5V voltage reference. */
43 REF_EXTERNAL, /* External pin voltage reference. */
46 /* Specifies the reference voltage multiplier. */
60 /* Number of bits in the DAC register: Either 12, 14 or 16. */
66 const struct dacx0501_config *config = dev->config; in dacx0501_reg_read()
70 status = i2c_write_read_dt(&config->i2c_spec, &addr, sizeof(addr), raw_data, in dacx0501_reg_read()
76 /* DAC is big endian. */ in dacx0501_reg_read()
83 const struct dacx0501_config *config = dev->config; in dacx0501_reg_write()
86 /* DAC is big endian. */ in dacx0501_reg_write()
89 return i2c_write_dt(&config->i2c_spec, write_cmd, sizeof(write_cmd)); in dacx0501_reg_write()
95 struct dacx0501_data *data = dev->data; in dacx0501_channel_setup()
98 if (channel_cfg->channel_id != 0) { in dacx0501_channel_setup()
99 LOG_ERR("Unsupported channel %d", channel_cfg->channel_id); in dacx0501_channel_setup()
100 return -ENOTSUP; in dacx0501_channel_setup()
103 if (channel_cfg->resolution != data->resolution) { in dacx0501_channel_setup()
104 LOG_ERR("Unsupported resolution %d. Actual: %d", channel_cfg->resolution, in dacx0501_channel_setup()
105 data->resolution); in dacx0501_channel_setup()
106 return -ENOTSUP; in dacx0501_channel_setup()
109 if (channel_cfg->internal) { in dacx0501_channel_setup()
111 return -ENOTSUP; in dacx0501_channel_setup()
119 struct dacx0501_data *data = dev->data; in dacx0501_write_value()
123 return -ENOTSUP; in dacx0501_write_value()
126 if (value >= (1 << data->resolution)) { in dacx0501_write_value()
128 return -EINVAL; in dacx0501_write_value()
131 value <<= (16 - data->resolution); in dacx0501_write_value()
138 const struct dacx0501_config *config = dev->config; in dacx0501_init()
139 struct dacx0501_data *data = dev->data; in dacx0501_init()
143 if (!i2c_is_ready_dt(&config->i2c_spec)) { in dacx0501_init()
144 LOG_ERR("I2C bus %s not ready", config->i2c_spec.bus->name); in dacx0501_init()
145 return -ENODEV; in dacx0501_init()
155 data->resolution = 16 - 2 * FIELD_GET(DACX0501_MASK_DEVICE_ID_RES, device_id); in dacx0501_init()
159 config->voltage_reference == REF_EXTERNAL)); in dacx0501_init()
167 FIELD_PREP(DACX0501_MASK_GAIN_REFDIV_EN, config->output_gain == VM_DIV2) | in dacx0501_init()
168 FIELD_PREP(DACX0501_MASK_GAIN_BUFF_GAIN, config->output_gain == VM_MUL2)); in dacx0501_init()
177 static DEVICE_API(dac, dacx0501_driver_api) = {