Linux-IIO Archive on lore.kernel.org
 help / color / Atom feed
* Adding "fault count" support to opt3001
@ 2019-09-27 17:08 David Frey
  2019-10-06  9:40 ` Jonathan Cameron
  0 siblings, 1 reply; 2+ messages in thread
From: David Frey @ 2019-09-27 17:08 UTC (permalink / raw)
  To: linux-iio

Hi,

The TI opt3001 light sensor has a fault count field in its configuration
register.  See http://www.ti.com/lit/ds/symlink/opt3001.pdf on page 23.
Basically, this field controls how many samples must be above the high
threshold or below the low threshold in order to trigger the interrupt.
Currently the driver initializes this field to 0 meaning that one fault
will trigger an interrupt.

0b00 -> 1
0b01 -> 2
0b10 -> 4
0b11 -> 8

The driver has an IIO event which allows for the high/low threshold to
be set and enabled/disabled.  I would like to add the ability to specify
the fault count as well and I'm wondering how this should be done.  I
believe it should be done by adding a .mask_shared_by_type =
BIT(IIO_EV_INFO_???) definition within the struct iio_event_spec, but
I'm not sure if any of the existing IIO_EV_INFO_ values are appropriate.
 The only one that might be appropriate is IIO_EV_INFO_HYSTERESIS.

Am I going about this the right way?
Is IIO_EV_INFO_HYSTERESIS appropriate?
Should a new enum value be defined?

Thanks,
David

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Adding "fault count" support to opt3001
  2019-09-27 17:08 Adding "fault count" support to opt3001 David Frey
@ 2019-10-06  9:40 ` Jonathan Cameron
  0 siblings, 0 replies; 2+ messages in thread
From: Jonathan Cameron @ 2019-10-06  9:40 UTC (permalink / raw)
  To: David Frey; +Cc: linux-iio

On Fri, 27 Sep 2019 10:08:19 -0700
David Frey <dpfrey@gmail.com> wrote:

> Hi,
> 
> The TI opt3001 light sensor has a fault count field in its configuration
> register.  See http://www.ti.com/lit/ds/symlink/opt3001.pdf on page 23.
> Basically, this field controls how many samples must be above the high
> threshold or below the low threshold in order to trigger the interrupt.
> Currently the driver initializes this field to 0 meaning that one fault
> will trigger an interrupt.
> 
> 0b00 -> 1
> 0b01 -> 2
> 0b10 -> 4
> 0b11 -> 8
> 
> The driver has an IIO event which allows for the high/low threshold to
> be set and enabled/disabled.  I would like to add the ability to specify
> the fault count as well and I'm wondering how this should be done.  I
> believe it should be done by adding a .mask_shared_by_type =
> BIT(IIO_EV_INFO_???) definition within the struct iio_event_spec, but
> I'm not sure if any of the existing IIO_EV_INFO_ values are appropriate.
>  The only one that might be appropriate is IIO_EV_INFO_HYSTERESIS.

If I have understood what this is correctly...

IIO_EV_INFO_PERIOD is the right one.  From a userspace point of view
it really doesn't care how many samples it is, what it cares about is
how long it needs to break the threshold for.  So across different
sensor types it might want to ignore camera flashes for example.

This does mean it becomes dependent on the sampling frequency. Now
I can't actually work out from that datasheet what controls the sampling
frequency...  I suppose it might just start a new reading immediately
after the previous one, but there isn't anything that I can see that
documents that.  Any ideas?

> 
> Am I going about this the right way?
> Is IIO_EV_INFO_HYSTERESIS appropriate?
> Should a new enum value be defined?
> 
> Thanks,
> David


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, back to index

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-09-27 17:08 Adding "fault count" support to opt3001 David Frey
2019-10-06  9:40 ` Jonathan Cameron

Linux-IIO Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-iio/0 linux-iio/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-iio linux-iio/ https://lore.kernel.org/linux-iio \
		linux-iio@vger.kernel.org linux-iio@archiver.kernel.org
	public-inbox-index linux-iio

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-iio


AGPL code for this site: git clone https://public-inbox.org/ public-inbox