struct regmap *regmap;
/** The external oscillator frequency in Hz. */
unsigned long clkin_hz;
- unsigned int fexcit;
bool hysteresis;
u8 resolution;
/** For reading raw sample value via SPI. */
if (ret < 0)
return ret;
- st->fexcit = fexcit;
-
/*
* Software reset reinitializes the excitation frequency output.
* It does not reset any of the configuration registers.
char *buf)
{
struct ad2s1210_state *st = iio_priv(dev_to_iio_dev(dev));
+ unsigned int value;
+ u16 fexcit;
+ int ret;
- return sprintf(buf, "%u\n", st->fexcit);
+ mutex_lock(&st->lock);
+ ret = regmap_read(st->regmap, AD2S1210_REG_EXCIT_FREQ, &value);
+ if (ret < 0)
+ goto error_ret;
+
+ fexcit = value * st->clkin_hz / (1 << 15);
+
+ ret = sprintf(buf, "%u\n", fexcit);
+
+error_ret:
+ mutex_unlock(&st->lock);
+ return ret;
}
static ssize_t ad2s1210_store_fexcit(struct device *dev,