// SPDX-License-Identifier: GPL-2.0-only /* * Analog devices AD5764, AD5764R, AD5744, AD5744R quad-channel * Digital to Analog Converters driver * * Copyright 2011 Analog Devices Inc.
*/
/** * struct ad5764_chip_info - chip specific information * @int_vref: Value of the internal reference voltage in uV - 0 if external * reference voltage is used * @channels: channel specification
*/ struct ad5764_chip_info { unsignedlong int_vref; conststruct iio_chan_spec *channels;
};
/** * struct ad5764_state - driver instance specific data * @spi: spi_device * @chip_info: chip info * @vref_reg: vref supply regulators * @lock: lock to protect the data buffer during SPI ops * @data: spi transfer buffers
*/
/* * DMA (thus cache coherency maintenance) may require the * transfer buffers to live in their own cache lines.
*/ union {
__be32 d32;
u8 d8[4];
} data[2] __aligned(IIO_DMA_MINALIGN);
};
ret = spi_sync_transfer(st->spi, t, ARRAY_SIZE(t)); if (ret >= 0)
*val = be32_to_cpu(st->data[1].d32) & 0xffff;
mutex_unlock(&st->lock);
return ret;
}
staticint ad5764_chan_info_to_reg(struct iio_chan_spec const *chan, long info)
{ switch (info) { case IIO_CHAN_INFO_RAW: return AD5764_REG_DATA(chan->address); case IIO_CHAN_INFO_CALIBBIAS: return AD5764_REG_OFFSET(chan->address); case IIO_CHAN_INFO_CALIBSCALE: return AD5764_REG_FINE_GAIN(chan->address); default: break;
}
return 0;
}
staticint ad5764_write_raw(struct iio_dev *indio_dev, struct iio_chan_spec const *chan, int val, int val2, long info)
{ constint max_val = (1 << chan->scan_type.realbits); unsignedint reg;
switch (info) { case IIO_CHAN_INFO_RAW: if (val >= max_val || val < 0) return -EINVAL;
val <<= chan->scan_type.shift; break; case IIO_CHAN_INFO_CALIBBIAS: if (val >= 128 || val < -128) return -EINVAL; break; case IIO_CHAN_INFO_CALIBSCALE: if (val >= 32 || val < -32) return -EINVAL; break; default: return -EINVAL;
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.