From: Hector Palacios <hector.palacios@digi.com>
To: Alexandre Belloni <alexandre.belloni@free-electrons.com>
Cc: Lars-Peter Clausen <lars@metafoo.de>,
"linux-iio@vger.kernel.org" <linux-iio@vger.kernel.org>,
"marex@denx.de" <marex@denx.de>,
"fabio.estevam@freescale.com" <fabio.estevam@freescale.com>
Subject: Re: [PATCH RFC] iio: mxs-lradc: add scaling to enable divide_by_two operation
Date: Thu, 4 Jul 2013 16:50:09 +0200 [thread overview]
Message-ID: <51D58BA1.2090906@digi.com> (raw)
In-Reply-To: <51D4575E.2040002@free-electrons.com>
Dear Alexandre,
On 07/03/2013 06:54 PM, Alexandre Belloni wrote:
>> Then let's say I have implemented a function to modify the scale (which
>> should eventually allow me to enable/disable the by two divisor). What
>> is the user supposed to write to the 'scale'? Is he supposed to supply a
>> decimal number like 0.45177 * 2 = 0.903? This would be pretty odd.
>> Should I create a table instead so that writing a 0 means divisor
>> disabled and writing 1 means divisor enabled, for example?
>>
>
> That is why you should provide an in_voltageX_scale_available file,
> providing a list of valid values.
Getting there...
So since all channels may have the optional divider by two I need to have two
available scales per channel, for example:
int scale_avail[LRADC_MAX_TOTAL_CHANS][2][2];
where the first [2] is the number of available scales per channel (with divisor
disabled/enabled) and the second [2] is for storing the integer and nanoV parts.
Then I must populate each channel with the two available scales:
[0] = 0.451660156 -> [0][0] = 0
-> [0][1] = 451660156
[1] = 0.903320312 -> [1][0] = 0
-> [1][1] = 903320312
where the [0] value is calculated by dividing the Vref by the realbits and the [1]
value is calculated by multiplying the [0] by two.
Then in the write_raw function I must check whether the integer and nano components
(val, val2) match those of the array, and if they match the one at the component [1],
then I can finally set the divisor flag on the register, or else clear it. Is this
correct?
Best regards,
--
Hector Palacios
next prev parent reply other threads:[~2013-07-04 14:58 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-07-03 10:06 [PATCH RFC] iio: mxs-lradc: add scaling to enable divide_by_two operation Hector Palacios
2013-07-03 10:25 ` Alexandre Belloni
2013-07-03 10:39 ` Hector Palacios
2013-07-03 10:46 ` Lars-Peter Clausen
2013-07-03 16:39 ` Hector Palacios
2013-07-03 16:54 ` Alexandre Belloni
2013-07-03 17:01 ` Lars-Peter Clausen
2013-07-04 8:58 ` Hector Palacios
2013-07-04 9:10 ` Lars-Peter Clausen
2013-07-04 9:17 ` Alexandre Belloni
2013-07-04 14:50 ` Hector Palacios [this message]
2013-07-03 11:25 ` Marek Vasut
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=51D58BA1.2090906@digi.com \
--to=hector.palacios@digi.com \
--cc=alexandre.belloni@free-electrons.com \
--cc=fabio.estevam@freescale.com \
--cc=lars@metafoo.de \
--cc=linux-iio@vger.kernel.org \
--cc=marex@denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox