Re: [PATCH RFC] iio: mxs-lradc: add scaling to enable divide_by_two operation

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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
--
To unsubscribe from this list: send the line "unsubscribe linux-iio" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Input]     [Linux Kernel]     [Linux SCSI]     [X.org]

  Powered by Linux