// SPDX-License-Identifier: GPL-2.0-only /* * ad2s1200.c simple support for the ADI Resolver to Digital Converters: * AD2S1200/1205 * * Copyright (c) 2018-2018 David Veenstra <davidjulianveenstra@gmail.com> * Copyright (c) 2010-2010 Analog Devices Inc.
*/
/* input clock on serial interface */ #define AD2S1200_HZ 8192000 /* clock period in nano second */ #define AD2S1200_TSCLK (1000000000 / AD2S1200_HZ)
/** * struct ad2s1200_state - driver instance specific data. * @lock: protects both the GPIO pins and the rx buffer. * @sdev: spi device. * @sample: GPIO pin SAMPLE. * @rdvel: GPIO pin RDVEL. * @rx: buffer for spi transfers.
*/ struct ad2s1200_state { struct mutex lock; struct spi_device *sdev; struct gpio_desc *sample; struct gpio_desc *rdvel;
__be16 rx __aligned(IIO_DMA_MINALIGN);
};
staticint ad2s1200_read_raw(struct iio_dev *indio_dev, struct iio_chan_spec const *chan, int *val, int *val2, long m)
{ struct ad2s1200_state *st = iio_priv(indio_dev); int ret;
switch (m) { case IIO_CHAN_INFO_SCALE: switch (chan->type) { case IIO_ANGL: /* 2 * Pi / (2^12 - 1) ~= 0.001534355 */
*val = 0;
*val2 = 1534355; return IIO_VAL_INT_PLUS_NANO; case IIO_ANGL_VEL: /* 2 * Pi ~= 6.283185 */
*val = 6;
*val2 = 283185; return IIO_VAL_INT_PLUS_MICRO; default: return -EINVAL;
} break; case IIO_CHAN_INFO_RAW:
mutex_lock(&st->lock);
gpiod_set_value(st->sample, 0);
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.