Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1374371
| From | Slawomir Stepien <sst@poczta.fm> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | Re: [PATCH] iio: potentiometer: add driver for Maxim Integrated DS1803 |
| Date | 2016-04-08 19:10 +0200 |
| Message-ID | <rlI4W-7ce-15@gated-at.bofh.it> (permalink) |
| References | <rllrJ-6RI-19@gated-at.bofh.it> <rlnWy-kj-9@gated-at.bofh.it> <rlGwa-5UD-23@gated-at.bofh.it> <rlH8R-6t5-13@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
On Apr 08, 2016 18:00, Peter Meerwald-Stadler wrote:
>
> > > maybe a #define to explain the name of register 0
> >
> > Well this zero is not register nor any kind of command that DS1803 needs to send
> > back pots values.
> > DS1803 only requires the standard R/W bit to be set as read.
> > I used _word_ function series to get back a word (16 bits) as this poti returns
> > 16 bits.
> >
> > How should I named it?
> >
> > #define NON_COMMAND 0
> > ?
>
> maybe i2c_transfer() is more appropriate then
>
> u8 databuf[2];
> struct i2c_msg msgs[2] = {
> { .addr = client->addr, .len = sizeof(databuf), .buf = databuf,
> .flags = I2C_M_RD } };
> ret = i2c_transfer(client->adapter, msgs, 2);
>
> this does not send any data to the chip but only reads two bytes
Good point. But maybe the better solution would be to use i2c_master_recv?
Anyhow I will check both options ;)
> > Or should I use different function? (2x i2c_smbus_read_byte?)
> >
> > The i2c_smbus_read_byte() function also used 0 as command
> > for its transfers...
>
> > > > +static int ds1803_write_raw(struct iio_dev *indio_dev,
> > > > + struct iio_chan_spec const *chan,
> > > > + int val, int val2, long mask)
> > > > +{
> > > > + struct ds1803_data *data = iio_priv(indio_dev);
> > > > + int pot = chan->channel;
> > > > +
> > > > + switch (mask) {
> > > > + case IIO_CHAN_INFO_RAW:
> > > > + if (val > DS1803_MAX_POS || val < 0)
> > >
> > > check that val2 is 0 or use .write_raw_get_fmt
> >
> > At this point I do not know why should I do it, but I will look into that.
>
> write_raw expects a VAL_INT_PLUS_MICROS per default, passed
> in val and val2
>
> you can change that with .write_raw_get_fmt (e.g. to expect VAL_INT),
> or just make sure that the micros are 0
Thank you for the explanation.
--
Slawomir Stepien
Back to linux.kernel | Previous | Next — Previous in thread | Find similar | Unroll thread
[PATCH] iio: potentiometer: add driver for Maxim Integrated DS1803 Slawomir Stepien <sst@poczta.fm> - 2016-04-07 19:00 +0200
Re: [PATCH] iio: potentiometer: add driver for Maxim Integrated DS1803 Peter Meerwald-Stadler <pmeerw@pmeerw.net> - 2016-04-07 21:40 +0200
Re: [PATCH] iio: potentiometer: add driver for Maxim Integrated DS1803 Slawomir Stepien <sst@poczta.fm> - 2016-04-08 17:30 +0200
Re: [PATCH] iio: potentiometer: add driver for Maxim Integrated DS1803 Peter Meerwald-Stadler <pmeerw@pmeerw.net> - 2016-04-08 18:10 +0200
Re: [PATCH] iio: potentiometer: add driver for Maxim Integrated DS1803 Slawomir Stepien <sst@poczta.fm> - 2016-04-08 19:10 +0200
csiph-web