linux-iio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 0/2] iio: proximity: add PulsedLight LIDAR sensor support
@ 2015-08-03  4:27 Matt Ranostay
  2015-08-03  4:27 ` [PATCH v2 1/2] devicetree: add PulsedLight vendor prefix Matt Ranostay
  2015-08-03  4:27 ` [PATCH v2 2/2] iio: proximity: add support for PulsedLight LIDAR Matt Ranostay
  0 siblings, 2 replies; 8+ messages in thread
From: Matt Ranostay @ 2015-08-03  4:27 UTC (permalink / raw)
  To: marex, jic23, lars, vladimir.barinov; +Cc: linux-iio, devicetree, Matt Ranostay

PulsedLight "blue label" v2 LIDAR sensor can be polled over 100HZ with
the sysfs + hrtimer iio trigger, or using single raw measurment.

This patchset adds support for this range finding LIDAR module, and reports
distance back in meters to centimeter resolution with +/- 2.5 CM of accuracy
at ~40 meters.

Changesfrom v1:
* Add check for invalid signal return
* Removed un-nedded IIO_CHAN_INFO_CALIBBIAS software biasing
* Mark i2c buffer cacheline aligned
* Added IIO_CHAN_INFO_SCALE for centimeter scale
* Minor tab alignment changes

Matt Ranostay (2):
  devicetree: add PulsedLight vendor prefix
  iio: proximity: add support for PulsedLight LIDAR

 .../devicetree/bindings/vendor-prefixes.txt        |   1 +
 drivers/iio/proximity/Kconfig                      |  12 +
 drivers/iio/proximity/Makefile                     |   1 +
 drivers/iio/proximity/lidar.c                      | 284 +++++++++++++++++++++
 4 files changed, 298 insertions(+)
 create mode 100644 drivers/iio/proximity/lidar.c

-- 
1.9.1


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

* [PATCH v2 1/2] devicetree: add PulsedLight vendor prefix
  2015-08-03  4:27 [PATCH v2 0/2] iio: proximity: add PulsedLight LIDAR sensor support Matt Ranostay
@ 2015-08-03  4:27 ` Matt Ranostay
  2015-08-03  4:27 ` [PATCH v2 2/2] iio: proximity: add support for PulsedLight LIDAR Matt Ranostay
  1 sibling, 0 replies; 8+ messages in thread
From: Matt Ranostay @ 2015-08-03  4:27 UTC (permalink / raw)
  To: marex, jic23, lars, vladimir.barinov; +Cc: linux-iio, devicetree, Matt Ranostay

Signed-off-by: Matt Ranostay <mranostay@gmail.com>
---
 Documentation/devicetree/bindings/vendor-prefixes.txt | 1 +
 1 file changed, 1 insertion(+)

diff --git a/Documentation/devicetree/bindings/vendor-prefixes.txt b/Documentation/devicetree/bindings/vendor-prefixes.txt
index 6284568..0f318c3 100644
--- a/Documentation/devicetree/bindings/vendor-prefixes.txt
+++ b/Documentation/devicetree/bindings/vendor-prefixes.txt
@@ -164,6 +164,7 @@ phytec	PHYTEC Messtechnik GmbH
 picochip	Picochip Ltd
 plathome	Plat'Home Co., Ltd.
 pixcir  PIXCIR MICROELECTRONICS Co., Ltd
+pulsedlight	PulsedLight, Inc
 powervr	PowerVR (deprecated, use img)
 qca	Qualcomm Atheros, Inc.
 qcom	Qualcomm Technologies, Inc
-- 
1.9.1


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

* [PATCH v2 2/2] iio: proximity: add support for PulsedLight LIDAR
  2015-08-03  4:27 [PATCH v2 0/2] iio: proximity: add PulsedLight LIDAR sensor support Matt Ranostay
  2015-08-03  4:27 ` [PATCH v2 1/2] devicetree: add PulsedLight vendor prefix Matt Ranostay
@ 2015-08-03  4:27 ` Matt Ranostay
  2015-08-03  6:48   ` Peter Meerwald
  1 sibling, 1 reply; 8+ messages in thread
From: Matt Ranostay @ 2015-08-03  4:27 UTC (permalink / raw)
  To: marex, jic23, lars, vladimir.barinov; +Cc: linux-iio, devicetree, Matt Ranostay

Add support for the PulsedLight LIDAR rangefinder sensor which allows
high speed (over 300Hz) distance measurements using Barker Coding within
40 meter range.

Support only tested on the "blue label" rev 2, but may work using low
sample frequencies on the original version.

Signed-off-by: Matt Ranostay <mranostay@gmail.com>
---
 drivers/iio/proximity/Kconfig  |  12 ++
 drivers/iio/proximity/Makefile |   1 +
 drivers/iio/proximity/lidar.c  | 284 +++++++++++++++++++++++++++++++++++++++++
 3 files changed, 297 insertions(+)
 create mode 100644 drivers/iio/proximity/lidar.c

diff --git a/drivers/iio/proximity/Kconfig b/drivers/iio/proximity/Kconfig
index 41a8d8f..e64fc5b 100644
--- a/drivers/iio/proximity/Kconfig
+++ b/drivers/iio/proximity/Kconfig
@@ -20,6 +20,18 @@ endmenu
 
 menu "Proximity sensors"
 
+config LIDAR
+	tristate "PulsedLight LIDAR sensor"
+	select IIO_BUFFER
+	select IIO_TRIGGERED_BUFFER
+	depends on I2C
+	help
+	  Say Y to build a driver for PulsedLight LIDAR range finding
+	  sensor.
+
+	  To compile this driver as a module, choose M here: the
+	  module will be called lidar.
+
 config SX9500
 	tristate "SX9500 Semtech proximity sensor"
 	select IIO_BUFFER
diff --git a/drivers/iio/proximity/Makefile b/drivers/iio/proximity/Makefile
index 9818dc5..36a95f3 100644
--- a/drivers/iio/proximity/Makefile
+++ b/drivers/iio/proximity/Makefile
@@ -4,4 +4,5 @@
 
 # When adding new entries keep the list in alphabetical order
 obj-$(CONFIG_AS3935)		+= as3935.o
+obj-$(CONFIG_LIDAR)		+= lidar.o
 obj-$(CONFIG_SX9500)		+= sx9500.o
diff --git a/drivers/iio/proximity/lidar.c b/drivers/iio/proximity/lidar.c
new file mode 100644
index 0000000..e7c2df4
--- /dev/null
+++ b/drivers/iio/proximity/lidar.c
@@ -0,0 +1,284 @@
+/*
+ * lidar.c - Support for PulsedLight LIDAR range finding sensor
+ *
+ * Copyright (C) 2015 Matt Ranostay <mranostay@gmail.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * TODO: runtime pm, interrupt mode, and signal strength reporting
+ *
+ */
+
+#include <linux/err.h>
+#include <linux/init.h>
+#include <linux/i2c.h>
+#include <linux/delay.h>
+#include <linux/mutex.h>
+#include <linux/module.h>
+#include <linux/iio/iio.h>
+#include <linux/iio/sysfs.h>
+#include <linux/iio/buffer.h>
+#include <linux/iio/trigger.h>
+#include <linux/iio/triggered_buffer.h>
+#include <linux/iio/trigger_consumer.h>
+
+#define LIDAR_REG_CONTROL		0x00
+#define LIDAR_REG_CONTROL_ACQUIRE	BIT(2)
+
+#define LIDAR_REG_STATUS		0x01
+#define LIDAR_REG_STATUS_INVALID	BIT(3)
+#define LIDAR_REG_STATUS_READY		BIT(0)
+
+#define LIDAR_REG_DATA_HBYTE	0x0f
+#define LIDAR_REG_DATA_LBYTE	0x10
+
+#define LIDAR_DRV_NAME "lidar"
+
+struct lidar_data {
+	struct mutex lock;
+	struct iio_dev *indio_dev;
+	struct i2c_client *client;
+
+	/* 2 byte distance + 8 byte timestamp */
+	u16 buffer[5] ____cacheline_aligned;
+};
+
+static const struct iio_chan_spec lidar_channels[] = {
+	{
+		.type = IIO_DISTANCE,
+		.info_mask_separate =
+			BIT(IIO_CHAN_INFO_RAW) | BIT(IIO_CHAN_INFO_SCALE),
+		.scan_index = 0,
+		.scan_type = {
+			.sign = 'u',
+			.realbits = 16,
+			.storagebits = 16,
+		},
+	},
+	IIO_CHAN_SOFT_TIMESTAMP(1),
+};
+
+static int lidar_read_byte(struct lidar_data *data, int reg)
+{
+	struct i2c_client *client = data->client;
+	int ret;
+
+	ret = i2c_smbus_write_byte(client, reg);
+	if (ret < 0) {
+		dev_err(&client->dev, "cannot write addr value");
+		return ret;
+	}
+
+	ret = i2c_smbus_read_byte(client);
+	if (ret < 0) {
+		dev_err(&client->dev, "cannot read data value");
+		return ret;
+	}
+
+	return ret;
+}
+
+static inline int lidar_write_control(struct lidar_data *data, int val)
+{
+	return i2c_smbus_write_byte_data(data->client, LIDAR_REG_CONTROL, val);
+}
+
+static int lidar_read_measurement(struct lidar_data *data, u16 *reg)
+{
+	int ret;
+	int val;
+
+	ret = lidar_read_byte(data, LIDAR_REG_DATA_HBYTE);
+	if (ret < 0)
+		return ret;
+	val = ret << 8;
+
+	ret = lidar_read_byte(data, LIDAR_REG_DATA_LBYTE);
+	if (ret < 0)
+		return ret;
+
+	val |= ret;
+	*reg = val;
+
+	return 0;
+}
+
+static int lidar_get_measurement(struct lidar_data *data, u16 *reg)
+{
+	struct i2c_client *client = data->client;
+	int tries = 10;
+	int ret;
+
+	/* start sample */
+	ret = lidar_write_control(data, LIDAR_REG_CONTROL_ACQUIRE);
+	if (ret < 0) {
+		dev_err(&client->dev, "cannot send start measurement command");
+		return ret;
+	}
+
+	while (tries--) {
+		usleep_range(1000, 2000);
+
+		ret = lidar_read_byte(data, LIDAR_REG_STATUS);
+		if (ret < 0)
+			break;
+
+		/* return 0 since laser is likely pointed out of range */
+		if (ret & LIDAR_REG_STATUS_INVALID) {
+			*reg = 0;
+			ret = 0;
+			break;
+		}
+
+		/* sample ready to read */
+		if (!(ret & LIDAR_REG_STATUS_READY)) {
+			ret = lidar_read_measurement(data, reg);
+			break;
+		}
+	}
+
+	return ret;
+}
+
+static int lidar_read_raw(struct iio_dev *indio_dev,
+			  struct iio_chan_spec const *chan,
+			  int *val, int *val2, long mask)
+{
+	struct lidar_data *data = iio_priv(indio_dev);
+	int ret = -EINVAL;
+
+	mutex_lock(&data->lock);
+
+	if (iio_buffer_enabled(indio_dev) && mask == IIO_CHAN_INFO_RAW) {
+		ret = -EBUSY;
+		goto error_busy;
+	}
+
+
+	switch (mask) {
+	case IIO_CHAN_INFO_RAW: {
+		u16 reg;
+
+		ret = lidar_get_measurement(data, &reg);
+		if (!ret) {
+			*val = reg;
+			ret = IIO_VAL_INT;
+		}
+		break;
+	}
+	case IIO_CHAN_INFO_SCALE:
+		*val = 0;
+		*val2 = 10000;
+		ret = IIO_VAL_INT_PLUS_MICRO;
+		break;
+	}
+
+error_busy:
+	mutex_unlock(&data->lock);
+
+	return ret;
+}
+
+static irqreturn_t lidar_trigger_handler(int irq, void *private)
+{
+	struct iio_poll_func *pf = private;
+	struct iio_dev *indio_dev = pf->indio_dev;
+	struct lidar_data *data = iio_priv(indio_dev);
+	int ret;
+
+	ret = lidar_get_measurement(data, &data->buffer[0]);
+	if (!ret) {
+		iio_push_to_buffers_with_timestamp(indio_dev, data->buffer,
+						   iio_get_time_ns());
+	} else {
+		dev_err(&data->client->dev, "cannot read LIDAR measurement");
+	}
+
+	iio_trigger_notify_done(indio_dev->trig);
+
+	return IRQ_HANDLED;
+}
+
+static const struct iio_info lidar_info = {
+	.driver_module = THIS_MODULE,
+	.read_raw = lidar_read_raw,
+};
+
+static int lidar_probe(struct i2c_client *client,
+		       const struct i2c_device_id *id)
+{
+	struct lidar_data *data;
+	struct iio_dev *indio_dev;
+	int ret;
+
+	indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*data));
+	if (!indio_dev)
+		return -ENOMEM;
+
+	indio_dev->info = &lidar_info;
+	indio_dev->name = LIDAR_DRV_NAME;
+	indio_dev->channels = lidar_channels;
+	indio_dev->num_channels = ARRAY_SIZE(lidar_channels);
+	indio_dev->modes = INDIO_DIRECT_MODE;
+
+	data = iio_priv(indio_dev);
+	i2c_set_clientdata(client, indio_dev);
+
+	data->client = client;
+	data->indio_dev = indio_dev;
+	mutex_init(&data->lock);
+
+	ret = iio_triggered_buffer_setup(indio_dev, NULL,
+					 lidar_trigger_handler, NULL);
+	if (ret)
+		return ret;
+
+	ret = iio_device_register(indio_dev);
+	if (ret)
+		goto error_unreg_buffer;
+
+	return 0;
+
+error_unreg_buffer:
+	iio_triggered_buffer_cleanup(indio_dev);
+
+	return ret;
+}
+
+static int lidar_remove(struct i2c_client *client)
+{
+	struct iio_dev *indio_dev = i2c_get_clientdata(client);
+
+	iio_device_unregister(indio_dev);
+	iio_triggered_buffer_cleanup(indio_dev);
+
+	return 0;
+}
+
+static const struct i2c_device_id lidar_id[] = {
+	{"lidar", 0},
+	{ },
+};
+MODULE_DEVICE_TABLE(i2c, lidar_id);
+
+static struct i2c_driver lidar_driver = {
+	.driver = {
+		.name	= LIDAR_DRV_NAME,
+	},
+	.probe		= lidar_probe,
+	.remove		= lidar_remove,
+	.id_table	= lidar_id,
+};
+module_i2c_driver(lidar_driver);
+
+MODULE_AUTHOR("Matt Ranostay <mranostay@gmail.com>");
+MODULE_DESCRIPTION("PulsedLight LIDAR sensor");
+MODULE_LICENSE("GPL");
-- 
1.9.1


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

* Re: [PATCH v2 2/2] iio: proximity: add support for PulsedLight LIDAR
  2015-08-03  4:27 ` [PATCH v2 2/2] iio: proximity: add support for PulsedLight LIDAR Matt Ranostay
@ 2015-08-03  6:48   ` Peter Meerwald
  2015-08-03  8:21     ` Matt Ranostay
  0 siblings, 1 reply; 8+ messages in thread
From: Peter Meerwald @ 2015-08-03  6:48 UTC (permalink / raw)
  To: Matt Ranostay; +Cc: marex, jic23, lars, vladimir.barinov, linux-iio

On Sun, 2 Aug 2015, Matt Ranostay wrote:

> Add support for the PulsedLight LIDAR rangefinder sensor which allows
> high speed (over 300Hz) distance measurements using Barker Coding within
> 40 meter range.
> 
> Support only tested on the "blue label" rev 2, but may work using low
> sample frequencies on the original version.
> 
> Signed-off-by: Matt Ranostay <mranostay@gmail.com>
> ---
>  drivers/iio/proximity/Kconfig  |  12 ++
>  drivers/iio/proximity/Makefile |   1 +
>  drivers/iio/proximity/lidar.c  | 284 +++++++++++++++++++++++++++++++++++++++++
>  3 files changed, 297 insertions(+)
>  create mode 100644 drivers/iio/proximity/lidar.c
> 
> diff --git a/drivers/iio/proximity/Kconfig b/drivers/iio/proximity/Kconfig
> index 41a8d8f..e64fc5b 100644
> --- a/drivers/iio/proximity/Kconfig
> +++ b/drivers/iio/proximity/Kconfig
> @@ -20,6 +20,18 @@ endmenu
>  
>  menu "Proximity sensors"
>  
> +config LIDAR
> +	tristate "PulsedLight LIDAR sensor"
> +	select IIO_BUFFER
> +	select IIO_TRIGGERED_BUFFER
> +	depends on I2C
> +	help
> +	  Say Y to build a driver for PulsedLight LIDAR range finding
> +	  sensor.
> +
> +	  To compile this driver as a module, choose M here: the
> +	  module will be called lidar.
> +
>  config SX9500
>  	tristate "SX9500 Semtech proximity sensor"
>  	select IIO_BUFFER
> diff --git a/drivers/iio/proximity/Makefile b/drivers/iio/proximity/Makefile
> index 9818dc5..36a95f3 100644
> --- a/drivers/iio/proximity/Makefile
> +++ b/drivers/iio/proximity/Makefile
> @@ -4,4 +4,5 @@
>  
>  # When adding new entries keep the list in alphabetical order
>  obj-$(CONFIG_AS3935)		+= as3935.o
> +obj-$(CONFIG_LIDAR)		+= lidar.o
>  obj-$(CONFIG_SX9500)		+= sx9500.o
> diff --git a/drivers/iio/proximity/lidar.c b/drivers/iio/proximity/lidar.c
> new file mode 100644
> index 0000000..e7c2df4
> --- /dev/null
> +++ b/drivers/iio/proximity/lidar.c
> @@ -0,0 +1,284 @@
> +/*
> + * lidar.c - Support for PulsedLight LIDAR range finding sensor
> + *
> + * Copyright (C) 2015 Matt Ranostay <mranostay@gmail.com>
> + *
> + * This program is free software; you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License as published by
> + * the Free Software Foundation; either version 2 of the License, or
> + * (at your option) any later version.
> + *
> + * This program is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
> + * GNU General Public License for more details.
> + *
> + * TODO: runtime pm, interrupt mode, and signal strength reporting
> + *
> + */
> +
> +#include <linux/err.h>
> +#include <linux/init.h>
> +#include <linux/i2c.h>
> +#include <linux/delay.h>
> +#include <linux/mutex.h>
> +#include <linux/module.h>
> +#include <linux/iio/iio.h>
> +#include <linux/iio/sysfs.h>
> +#include <linux/iio/buffer.h>
> +#include <linux/iio/trigger.h>
> +#include <linux/iio/triggered_buffer.h>
> +#include <linux/iio/trigger_consumer.h>
> +
> +#define LIDAR_REG_CONTROL		0x00
> +#define LIDAR_REG_CONTROL_ACQUIRE	BIT(2)
> +
> +#define LIDAR_REG_STATUS		0x01
> +#define LIDAR_REG_STATUS_INVALID	BIT(3)
> +#define LIDAR_REG_STATUS_READY		BIT(0)
> +
> +#define LIDAR_REG_DATA_HBYTE	0x0f
> +#define LIDAR_REG_DATA_LBYTE	0x10
> +
> +#define LIDAR_DRV_NAME "lidar"
> +
> +struct lidar_data {
> +	struct mutex lock;
> +	struct iio_dev *indio_dev;
> +	struct i2c_client *client;
> +
> +	/* 2 byte distance + 8 byte timestamp */
> +	u16 buffer[5] ____cacheline_aligned;
> +};
> +
> +static const struct iio_chan_spec lidar_channels[] = {
> +	{
> +		.type = IIO_DISTANCE,
> +		.info_mask_separate =
> +			BIT(IIO_CHAN_INFO_RAW) | BIT(IIO_CHAN_INFO_SCALE),
> +		.scan_index = 0,
> +		.scan_type = {
> +			.sign = 'u',
> +			.realbits = 16,
> +			.storagebits = 16,
> +		},
> +	},
> +	IIO_CHAN_SOFT_TIMESTAMP(1),
> +};
> +
> +static int lidar_read_byte(struct lidar_data *data, int reg)
> +{
> +	struct i2c_client *client = data->client;
> +	int ret;
> +
> +	ret = i2c_smbus_write_byte(client, reg);
> +	if (ret < 0) {
> +		dev_err(&client->dev, "cannot write addr value");
> +		return ret;
> +	}
> +
> +	ret = i2c_smbus_read_byte(client);
> +	if (ret < 0) {
> +		dev_err(&client->dev, "cannot read data value");
> +		return ret;
> +	}
> +
> +	return ret;
> +}
> +
> +static inline int lidar_write_control(struct lidar_data *data, int val)
> +{
> +	return i2c_smbus_write_byte_data(data->client, LIDAR_REG_CONTROL, val);
> +}
> +
> +static int lidar_read_measurement(struct lidar_data *data, u16 *reg)
> +{
> +	int ret;
> +	int val;
> +
> +	ret = lidar_read_byte(data, LIDAR_REG_DATA_HBYTE);
> +	if (ret < 0)
> +		return ret;
> +	val = ret << 8;
> +
> +	ret = lidar_read_byte(data, LIDAR_REG_DATA_LBYTE);
> +	if (ret < 0)
> +		return ret;
> +
> +	val |= ret;
> +	*reg = val;
> +
> +	return 0;
> +}
> +
> +static int lidar_get_measurement(struct lidar_data *data, u16 *reg)
> +{
> +	struct i2c_client *client = data->client;
> +	int tries = 10;
> +	int ret;
> +
> +	/* start sample */
> +	ret = lidar_write_control(data, LIDAR_REG_CONTROL_ACQUIRE);
> +	if (ret < 0) {
> +		dev_err(&client->dev, "cannot send start measurement command");
> +		return ret;
> +	}
> +
> +	while (tries--) {
> +		usleep_range(1000, 2000);
> +
> +		ret = lidar_read_byte(data, LIDAR_REG_STATUS);
> +		if (ret < 0)
> +			break;
> +
> +		/* return 0 since laser is likely pointed out of range */
> +		if (ret & LIDAR_REG_STATUS_INVALID) {
> +			*reg = 0;
> +			ret = 0;
> +			break;
> +		}
> +
> +		/* sample ready to read */
> +		if (!(ret & LIDAR_REG_STATUS_READY)) {
> +			ret = lidar_read_measurement(data, reg);
> +			break;
> +		}
> +	}
> +

what happens when the timeout occurs?
no error code is set

> +	return ret;
> +}
> +
> +static int lidar_read_raw(struct iio_dev *indio_dev,
> +			  struct iio_chan_spec const *chan,
> +			  int *val, int *val2, long mask)
> +{
> +	struct lidar_data *data = iio_priv(indio_dev);
> +	int ret = -EINVAL;
> +
> +	mutex_lock(&data->lock);
> +
> +	if (iio_buffer_enabled(indio_dev) && mask == IIO_CHAN_INFO_RAW) {
> +		ret = -EBUSY;
> +		goto error_busy;
> +	}
> +
> +
> +	switch (mask) {
> +	case IIO_CHAN_INFO_RAW: {
> +		u16 reg;
> +
> +		ret = lidar_get_measurement(data, &reg);
> +		if (!ret) {
> +			*val = reg;
> +			ret = IIO_VAL_INT;
> +		}
> +		break;
> +	}
> +	case IIO_CHAN_INFO_SCALE:
> +		*val = 0;
> +		*val2 = 10000;
> +		ret = IIO_VAL_INT_PLUS_MICRO;
> +		break;
> +	}
> +
> +error_busy:
> +	mutex_unlock(&data->lock);
> +
> +	return ret;
> +}
> +
> +static irqreturn_t lidar_trigger_handler(int irq, void *private)
> +{
> +	struct iio_poll_func *pf = private;
> +	struct iio_dev *indio_dev = pf->indio_dev;
> +	struct lidar_data *data = iio_priv(indio_dev);
> +	int ret;
> +
> +	ret = lidar_get_measurement(data, &data->buffer[0]);
> +	if (!ret) {
> +		iio_push_to_buffers_with_timestamp(indio_dev, data->buffer,
> +						   iio_get_time_ns());
> +	} else {
> +		dev_err(&data->client->dev, "cannot read LIDAR measurement");
> +	}
> +
> +	iio_trigger_notify_done(indio_dev->trig);
> +
> +	return IRQ_HANDLED;
> +}
> +
> +static const struct iio_info lidar_info = {
> +	.driver_module = THIS_MODULE,
> +	.read_raw = lidar_read_raw,
> +};
> +
> +static int lidar_probe(struct i2c_client *client,
> +		       const struct i2c_device_id *id)
> +{
> +	struct lidar_data *data;
> +	struct iio_dev *indio_dev;
> +	int ret;
> +
> +	indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*data));
> +	if (!indio_dev)
> +		return -ENOMEM;
> +
> +	indio_dev->info = &lidar_info;
> +	indio_dev->name = LIDAR_DRV_NAME;
> +	indio_dev->channels = lidar_channels;
> +	indio_dev->num_channels = ARRAY_SIZE(lidar_channels);
> +	indio_dev->modes = INDIO_DIRECT_MODE;
> +
> +	data = iio_priv(indio_dev);
> +	i2c_set_clientdata(client, indio_dev);
> +
> +	data->client = client;
> +	data->indio_dev = indio_dev;
> +	mutex_init(&data->lock);
> +
> +	ret = iio_triggered_buffer_setup(indio_dev, NULL,
> +					 lidar_trigger_handler, NULL);
> +	if (ret)
> +		return ret;
> +
> +	ret = iio_device_register(indio_dev);
> +	if (ret)
> +		goto error_unreg_buffer;
> +
> +	return 0;
> +
> +error_unreg_buffer:
> +	iio_triggered_buffer_cleanup(indio_dev);
> +
> +	return ret;
> +}
> +
> +static int lidar_remove(struct i2c_client *client)
> +{
> +	struct iio_dev *indio_dev = i2c_get_clientdata(client);
> +
> +	iio_device_unregister(indio_dev);
> +	iio_triggered_buffer_cleanup(indio_dev);
> +
> +	return 0;
> +}
> +
> +static const struct i2c_device_id lidar_id[] = {
> +	{"lidar", 0},
> +	{ },
> +};
> +MODULE_DEVICE_TABLE(i2c, lidar_id);
> +
> +static struct i2c_driver lidar_driver = {
> +	.driver = {
> +		.name	= LIDAR_DRV_NAME,
> +	},
> +	.probe		= lidar_probe,
> +	.remove		= lidar_remove,
> +	.id_table	= lidar_id,
> +};
> +module_i2c_driver(lidar_driver);
> +
> +MODULE_AUTHOR("Matt Ranostay <mranostay@gmail.com>");
> +MODULE_DESCRIPTION("PulsedLight LIDAR sensor");
> +MODULE_LICENSE("GPL");
> 

-- 

Peter Meerwald
+43-664-2444418 (mobile)

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

* Re: [PATCH v2 2/2] iio: proximity: add support for PulsedLight LIDAR
  2015-08-03  6:48   ` Peter Meerwald
@ 2015-08-03  8:21     ` Matt Ranostay
  2015-08-04 20:35       ` Tristan Lelong
  0 siblings, 1 reply; 8+ messages in thread
From: Matt Ranostay @ 2015-08-03  8:21 UTC (permalink / raw)
  To: Peter Meerwald
  Cc: Marek Vašut, Jonathan Cameron, Lars-Peter Clausen,
	Vladimir Barinov, linux-iio@vger.kernel.org

On Sun, Aug 2, 2015 at 11:48 PM, Peter Meerwald <pmeerw@pmeerw.net> wrote:
> On Sun, 2 Aug 2015, Matt Ranostay wrote:
>
>> Add support for the PulsedLight LIDAR rangefinder sensor which allows
>> high speed (over 300Hz) distance measurements using Barker Coding within
>> 40 meter range.
>>
>> Support only tested on the "blue label" rev 2, but may work using low
>> sample frequencies on the original version.
>>
>> Signed-off-by: Matt Ranostay <mranostay@gmail.com>
>> ---
>>  drivers/iio/proximity/Kconfig  |  12 ++
>>  drivers/iio/proximity/Makefile |   1 +
>>  drivers/iio/proximity/lidar.c  | 284 +++++++++++++++++++++++++++++++++++++++++
>>  3 files changed, 297 insertions(+)
>>  create mode 100644 drivers/iio/proximity/lidar.c
>>
>> diff --git a/drivers/iio/proximity/Kconfig b/drivers/iio/proximity/Kconfig
>> index 41a8d8f..e64fc5b 100644
>> --- a/drivers/iio/proximity/Kconfig
>> +++ b/drivers/iio/proximity/Kconfig
>> @@ -20,6 +20,18 @@ endmenu
>>
>>  menu "Proximity sensors"
>>
>> +config LIDAR
>> +     tristate "PulsedLight LIDAR sensor"
>> +     select IIO_BUFFER
>> +     select IIO_TRIGGERED_BUFFER
>> +     depends on I2C
>> +     help
>> +       Say Y to build a driver for PulsedLight LIDAR range finding
>> +       sensor.
>> +
>> +       To compile this driver as a module, choose M here: the
>> +       module will be called lidar.
>> +
>>  config SX9500
>>       tristate "SX9500 Semtech proximity sensor"
>>       select IIO_BUFFER
>> diff --git a/drivers/iio/proximity/Makefile b/drivers/iio/proximity/Makefile
>> index 9818dc5..36a95f3 100644
>> --- a/drivers/iio/proximity/Makefile
>> +++ b/drivers/iio/proximity/Makefile
>> @@ -4,4 +4,5 @@
>>
>>  # When adding new entries keep the list in alphabetical order
>>  obj-$(CONFIG_AS3935)         += as3935.o
>> +obj-$(CONFIG_LIDAR)          += lidar.o
>>  obj-$(CONFIG_SX9500)         += sx9500.o
>> diff --git a/drivers/iio/proximity/lidar.c b/drivers/iio/proximity/lidar.c
>> new file mode 100644
>> index 0000000..e7c2df4
>> --- /dev/null
>> +++ b/drivers/iio/proximity/lidar.c
>> @@ -0,0 +1,284 @@
>> +/*
>> + * lidar.c - Support for PulsedLight LIDAR range finding sensor
>> + *
>> + * Copyright (C) 2015 Matt Ranostay <mranostay@gmail.com>
>> + *
>> + * This program is free software; you can redistribute it and/or modify
>> + * it under the terms of the GNU General Public License as published by
>> + * the Free Software Foundation; either version 2 of the License, or
>> + * (at your option) any later version.
>> + *
>> + * This program is distributed in the hope that it will be useful,
>> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
>> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
>> + * GNU General Public License for more details.
>> + *
>> + * TODO: runtime pm, interrupt mode, and signal strength reporting
>> + *
>> + */
>> +
>> +#include <linux/err.h>
>> +#include <linux/init.h>
>> +#include <linux/i2c.h>
>> +#include <linux/delay.h>
>> +#include <linux/mutex.h>
>> +#include <linux/module.h>
>> +#include <linux/iio/iio.h>
>> +#include <linux/iio/sysfs.h>
>> +#include <linux/iio/buffer.h>
>> +#include <linux/iio/trigger.h>
>> +#include <linux/iio/triggered_buffer.h>
>> +#include <linux/iio/trigger_consumer.h>
>> +
>> +#define LIDAR_REG_CONTROL            0x00
>> +#define LIDAR_REG_CONTROL_ACQUIRE    BIT(2)
>> +
>> +#define LIDAR_REG_STATUS             0x01
>> +#define LIDAR_REG_STATUS_INVALID     BIT(3)
>> +#define LIDAR_REG_STATUS_READY               BIT(0)
>> +
>> +#define LIDAR_REG_DATA_HBYTE 0x0f
>> +#define LIDAR_REG_DATA_LBYTE 0x10
>> +
>> +#define LIDAR_DRV_NAME "lidar"
>> +
>> +struct lidar_data {
>> +     struct mutex lock;
>> +     struct iio_dev *indio_dev;
>> +     struct i2c_client *client;
>> +
>> +     /* 2 byte distance + 8 byte timestamp */
>> +     u16 buffer[5] ____cacheline_aligned;
>> +};
>> +
>> +static const struct iio_chan_spec lidar_channels[] = {
>> +     {
>> +             .type = IIO_DISTANCE,
>> +             .info_mask_separate =
>> +                     BIT(IIO_CHAN_INFO_RAW) | BIT(IIO_CHAN_INFO_SCALE),
>> +             .scan_index = 0,
>> +             .scan_type = {
>> +                     .sign = 'u',
>> +                     .realbits = 16,
>> +                     .storagebits = 16,
>> +             },
>> +     },
>> +     IIO_CHAN_SOFT_TIMESTAMP(1),
>> +};
>> +
>> +static int lidar_read_byte(struct lidar_data *data, int reg)
>> +{
>> +     struct i2c_client *client = data->client;
>> +     int ret;
>> +
>> +     ret = i2c_smbus_write_byte(client, reg);
>> +     if (ret < 0) {
>> +             dev_err(&client->dev, "cannot write addr value");
>> +             return ret;
>> +     }
>> +
>> +     ret = i2c_smbus_read_byte(client);
>> +     if (ret < 0) {
>> +             dev_err(&client->dev, "cannot read data value");
>> +             return ret;
>> +     }
>> +
>> +     return ret;
>> +}
>> +
>> +static inline int lidar_write_control(struct lidar_data *data, int val)
>> +{
>> +     return i2c_smbus_write_byte_data(data->client, LIDAR_REG_CONTROL, val);
>> +}
>> +
>> +static int lidar_read_measurement(struct lidar_data *data, u16 *reg)
>> +{
>> +     int ret;
>> +     int val;
>> +
>> +     ret = lidar_read_byte(data, LIDAR_REG_DATA_HBYTE);
>> +     if (ret < 0)
>> +             return ret;
>> +     val = ret << 8;
>> +
>> +     ret = lidar_read_byte(data, LIDAR_REG_DATA_LBYTE);
>> +     if (ret < 0)
>> +             return ret;
>> +
>> +     val |= ret;
>> +     *reg = val;
>> +
>> +     return 0;
>> +}
>> +
>> +static int lidar_get_measurement(struct lidar_data *data, u16 *reg)
>> +{
>> +     struct i2c_client *client = data->client;
>> +     int tries = 10;
>> +     int ret;
>> +
>> +     /* start sample */
>> +     ret = lidar_write_control(data, LIDAR_REG_CONTROL_ACQUIRE);
>> +     if (ret < 0) {
>> +             dev_err(&client->dev, "cannot send start measurement command");
>> +             return ret;
>> +     }
>> +
>> +     while (tries--) {
>> +             usleep_range(1000, 2000);
>> +
>> +             ret = lidar_read_byte(data, LIDAR_REG_STATUS);
>> +             if (ret < 0)
>> +                     break;
>> +
>> +             /* return 0 since laser is likely pointed out of range */
>> +             if (ret & LIDAR_REG_STATUS_INVALID) {
>> +                     *reg = 0;
>> +                     ret = 0;
>> +                     break;
>> +             }
>> +
>> +             /* sample ready to read */
>> +             if (!(ret & LIDAR_REG_STATUS_READY)) {
>> +                     ret = lidar_read_measurement(data, reg);
>> +                     break;
>> +             }
>> +     }
>> +
>
> what happens when the timeout occurs?
> no error code is set

Ah yes it should return an error code.  Would a -EIO be a logical choice?

>
>> +     return ret;
>> +}
>> +
>> +static int lidar_read_raw(struct iio_dev *indio_dev,
>> +                       struct iio_chan_spec const *chan,
>> +                       int *val, int *val2, long mask)
>> +{
>> +     struct lidar_data *data = iio_priv(indio_dev);
>> +     int ret = -EINVAL;
>> +
>> +     mutex_lock(&data->lock);
>> +
>> +     if (iio_buffer_enabled(indio_dev) && mask == IIO_CHAN_INFO_RAW) {
>> +             ret = -EBUSY;
>> +             goto error_busy;
>> +     }
>> +
>> +
>> +     switch (mask) {
>> +     case IIO_CHAN_INFO_RAW: {
>> +             u16 reg;
>> +
>> +             ret = lidar_get_measurement(data, &reg);
>> +             if (!ret) {
>> +                     *val = reg;
>> +                     ret = IIO_VAL_INT;
>> +             }
>> +             break;
>> +     }
>> +     case IIO_CHAN_INFO_SCALE:
>> +             *val = 0;
>> +             *val2 = 10000;
>> +             ret = IIO_VAL_INT_PLUS_MICRO;
>> +             break;
>> +     }
>> +
>> +error_busy:
>> +     mutex_unlock(&data->lock);
>> +
>> +     return ret;
>> +}
>> +
>> +static irqreturn_t lidar_trigger_handler(int irq, void *private)
>> +{
>> +     struct iio_poll_func *pf = private;
>> +     struct iio_dev *indio_dev = pf->indio_dev;
>> +     struct lidar_data *data = iio_priv(indio_dev);
>> +     int ret;
>> +
>> +     ret = lidar_get_measurement(data, &data->buffer[0]);
>> +     if (!ret) {
>> +             iio_push_to_buffers_with_timestamp(indio_dev, data->buffer,
>> +                                                iio_get_time_ns());
>> +     } else {
>> +             dev_err(&data->client->dev, "cannot read LIDAR measurement");
>> +     }
>> +
>> +     iio_trigger_notify_done(indio_dev->trig);
>> +
>> +     return IRQ_HANDLED;
>> +}
>> +
>> +static const struct iio_info lidar_info = {
>> +     .driver_module = THIS_MODULE,
>> +     .read_raw = lidar_read_raw,
>> +};
>> +
>> +static int lidar_probe(struct i2c_client *client,
>> +                    const struct i2c_device_id *id)
>> +{
>> +     struct lidar_data *data;
>> +     struct iio_dev *indio_dev;
>> +     int ret;
>> +
>> +     indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*data));
>> +     if (!indio_dev)
>> +             return -ENOMEM;
>> +
>> +     indio_dev->info = &lidar_info;
>> +     indio_dev->name = LIDAR_DRV_NAME;
>> +     indio_dev->channels = lidar_channels;
>> +     indio_dev->num_channels = ARRAY_SIZE(lidar_channels);
>> +     indio_dev->modes = INDIO_DIRECT_MODE;
>> +
>> +     data = iio_priv(indio_dev);
>> +     i2c_set_clientdata(client, indio_dev);
>> +
>> +     data->client = client;
>> +     data->indio_dev = indio_dev;
>> +     mutex_init(&data->lock);
>> +
>> +     ret = iio_triggered_buffer_setup(indio_dev, NULL,
>> +                                      lidar_trigger_handler, NULL);
>> +     if (ret)
>> +             return ret;
>> +
>> +     ret = iio_device_register(indio_dev);
>> +     if (ret)
>> +             goto error_unreg_buffer;
>> +
>> +     return 0;
>> +
>> +error_unreg_buffer:
>> +     iio_triggered_buffer_cleanup(indio_dev);
>> +
>> +     return ret;
>> +}
>> +
>> +static int lidar_remove(struct i2c_client *client)
>> +{
>> +     struct iio_dev *indio_dev = i2c_get_clientdata(client);
>> +
>> +     iio_device_unregister(indio_dev);
>> +     iio_triggered_buffer_cleanup(indio_dev);
>> +
>> +     return 0;
>> +}
>> +
>> +static const struct i2c_device_id lidar_id[] = {
>> +     {"lidar", 0},
>> +     { },
>> +};
>> +MODULE_DEVICE_TABLE(i2c, lidar_id);
>> +
>> +static struct i2c_driver lidar_driver = {
>> +     .driver = {
>> +             .name   = LIDAR_DRV_NAME,
>> +     },
>> +     .probe          = lidar_probe,
>> +     .remove         = lidar_remove,
>> +     .id_table       = lidar_id,
>> +};
>> +module_i2c_driver(lidar_driver);
>> +
>> +MODULE_AUTHOR("Matt Ranostay <mranostay@gmail.com>");
>> +MODULE_DESCRIPTION("PulsedLight LIDAR sensor");
>> +MODULE_LICENSE("GPL");
>>
>
> --
>
> Peter Meerwald
> +43-664-2444418 (mobile)

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

* Re: [PATCH v2 2/2] iio: proximity: add support for PulsedLight LIDAR
  2015-08-03  8:21     ` Matt Ranostay
@ 2015-08-04 20:35       ` Tristan Lelong
  2015-08-05  1:45         ` Matt Ranostay
  0 siblings, 1 reply; 8+ messages in thread
From: Tristan Lelong @ 2015-08-04 20:35 UTC (permalink / raw)
  To: Matt Ranostay
  Cc: Peter Meerwald, Marek Vašut, Jonathan Cameron,
	Lars-Peter Clausen, Vladimir Barinov, linux-iio@vger.kernel.org

On Mon, Aug 03, 2015 at 01:21:08AM -0700, Matt Ranostay wrote:
> On Sun, Aug 2, 2015 at 11:48 PM, Peter Meerwald <pmeerw@pmeerw.net> wrote:
> > On Sun, 2 Aug 2015, Matt Ranostay wrote:
> >
> >> +
> >> +static int lidar_get_measurement(struct lidar_data *data, u16 *reg)
> >> +{
> >> +     struct i2c_client *client = data->client;
> >> +     int tries = 10;
> >> +     int ret;
> >> +
> >> +     /* start sample */
> >> +     ret = lidar_write_control(data, LIDAR_REG_CONTROL_ACQUIRE);
> >> +     if (ret < 0) {
> >> +             dev_err(&client->dev, "cannot send start measurement command");
> >> +             return ret;
> >> +     }
> >> +
> >> +     while (tries--) {
> >> +             usleep_range(1000, 2000);
> >> +
> >> +             ret = lidar_read_byte(data, LIDAR_REG_STATUS);
> >> +             if (ret < 0)
> >> +                     break;
> >> +
> >> +             /* return 0 since laser is likely pointed out of range */
> >> +             if (ret & LIDAR_REG_STATUS_INVALID) {
> >> +                     *reg = 0;
> >> +                     ret = 0;
> >> +                     break;
> >> +             }
> >> +
> >> +             /* sample ready to read */
> >> +             if (!(ret & LIDAR_REG_STATUS_READY)) {
> >> +                     ret = lidar_read_measurement(data, reg);
> >> +                     break;
> >> +             }
> >> +     }
> >> +
> >
> > what happens when the timeout occurs?
> > no error code is set
> 
> Ah yes it should return an error code.  Would a -EIO be a logical choice?
> 

I would think -ETIMEDOUT to make more sense here.

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

* Re: [PATCH v2 2/2] iio: proximity: add support for PulsedLight LIDAR
  2015-08-04 20:35       ` Tristan Lelong
@ 2015-08-05  1:45         ` Matt Ranostay
  2015-08-05  7:13           ` Tristan Lelong
  0 siblings, 1 reply; 8+ messages in thread
From: Matt Ranostay @ 2015-08-05  1:45 UTC (permalink / raw)
  To: Tristan Lelong
  Cc: Peter Meerwald, Marek Vašut, Jonathan Cameron,
	Lars-Peter Clausen, Vladimir Barinov, linux-iio@vger.kernel.org

On Tue, Aug 4, 2015 at 1:35 PM, Tristan Lelong <tristan@lelong.xyz> wrote:
> On Mon, Aug 03, 2015 at 01:21:08AM -0700, Matt Ranostay wrote:
>> On Sun, Aug 2, 2015 at 11:48 PM, Peter Meerwald <pmeerw@pmeerw.net> wrote:
>> > On Sun, 2 Aug 2015, Matt Ranostay wrote:
>> >
>> >> +
>> >> +static int lidar_get_measurement(struct lidar_data *data, u16 *reg)
>> >> +{
>> >> +     struct i2c_client *client = data->client;
>> >> +     int tries = 10;
>> >> +     int ret;
>> >> +
>> >> +     /* start sample */
>> >> +     ret = lidar_write_control(data, LIDAR_REG_CONTROL_ACQUIRE);
>> >> +     if (ret < 0) {
>> >> +             dev_err(&client->dev, "cannot send start measurement command");
>> >> +             return ret;
>> >> +     }
>> >> +
>> >> +     while (tries--) {
>> >> +             usleep_range(1000, 2000);
>> >> +
>> >> +             ret = lidar_read_byte(data, LIDAR_REG_STATUS);
>> >> +             if (ret < 0)
>> >> +                     break;
>> >> +
>> >> +             /* return 0 since laser is likely pointed out of range */
>> >> +             if (ret & LIDAR_REG_STATUS_INVALID) {
>> >> +                     *reg = 0;
>> >> +                     ret = 0;
>> >> +                     break;
>> >> +             }
>> >> +
>> >> +             /* sample ready to read */
>> >> +             if (!(ret & LIDAR_REG_STATUS_READY)) {
>> >> +                     ret = lidar_read_measurement(data, reg);
>> >> +                     break;
>> >> +             }
>> >> +     }
>> >> +
>> >
>> > what happens when the timeout occurs?
>> > no error code is set
>>
>> Ah yes it should return an error code.  Would a -EIO be a logical choice?
>>
>
> I would think -ETIMEDOUT to make more sense here.

Isn't that more applicable for a networking driver to use?

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

* Re: [PATCH v2 2/2] iio: proximity: add support for PulsedLight LIDAR
  2015-08-05  1:45         ` Matt Ranostay
@ 2015-08-05  7:13           ` Tristan Lelong
  0 siblings, 0 replies; 8+ messages in thread
From: Tristan Lelong @ 2015-08-05  7:13 UTC (permalink / raw)
  To: Matt Ranostay
  Cc: Peter Meerwald, Marek Vašut, Jonathan Cameron,
	Lars-Peter Clausen, Vladimir Barinov, linux-iio@vger.kernel.org

On Tue, Aug 04, 2015 at 06:45:22PM -0700, Matt Ranostay wrote:
> On Tue, Aug 4, 2015 at 1:35 PM, Tristan Lelong <tristan@lelong.xyz> wrote:
> > On Mon, Aug 03, 2015 at 01:21:08AM -0700, Matt Ranostay wrote:
> >> On Sun, Aug 2, 2015 at 11:48 PM, Peter Meerwald <pmeerw@pmeerw.net> wrote:
> >> > On Sun, 2 Aug 2015, Matt Ranostay wrote:
> >> >
> >> >> +
> >> >> +static int lidar_get_measurement(struct lidar_data *data, u16 *reg)
> >> >> +{
> >> >> +     struct i2c_client *client = data->client;
> >> >> +     int tries = 10;
> >> >> +     int ret;
> >> >> +
> >> >> +     /* start sample */
> >> >> +     ret = lidar_write_control(data, LIDAR_REG_CONTROL_ACQUIRE);
> >> >> +     if (ret < 0) {
> >> >> +             dev_err(&client->dev, "cannot send start measurement command");
> >> >> +             return ret;
> >> >> +     }
> >> >> +
> >> >> +     while (tries--) {
> >> >> +             usleep_range(1000, 2000);
> >> >> +
> >> >> +             ret = lidar_read_byte(data, LIDAR_REG_STATUS);
> >> >> +             if (ret < 0)
> >> >> +                     break;
> >> >> +
> >> >> +             /* return 0 since laser is likely pointed out of range */
> >> >> +             if (ret & LIDAR_REG_STATUS_INVALID) {
> >> >> +                     *reg = 0;
> >> >> +                     ret = 0;
> >> >> +                     break;
> >> >> +             }
> >> >> +
> >> >> +             /* sample ready to read */
> >> >> +             if (!(ret & LIDAR_REG_STATUS_READY)) {
> >> >> +                     ret = lidar_read_measurement(data, reg);
> >> >> +                     break;
> >> >> +             }
> >> >> +     }
> >> >> +
> >> >
> >> > what happens when the timeout occurs?
> >> > no error code is set
> >>
> >> Ah yes it should return an error code.  Would a -EIO be a logical choice?
> >>
> >
> > I would think -ETIMEDOUT to make more sense here.
> 
> Isn't that more applicable for a networking driver to use?

IMHO this error code is generic and should be used when a certain operation doesn't provide any result after a determined period of time. 
In your case, no measurement is available after 10 to 20 msec.

It is used in other iio drivers on similar use cases,
Although it often comes after wait_for_completion_timeout, the scenario is pretty similar:
- start measurement
- wait for measure to be ready

Regards

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

end of thread, other threads:[~2015-08-05  7:10 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-08-03  4:27 [PATCH v2 0/2] iio: proximity: add PulsedLight LIDAR sensor support Matt Ranostay
2015-08-03  4:27 ` [PATCH v2 1/2] devicetree: add PulsedLight vendor prefix Matt Ranostay
2015-08-03  4:27 ` [PATCH v2 2/2] iio: proximity: add support for PulsedLight LIDAR Matt Ranostay
2015-08-03  6:48   ` Peter Meerwald
2015-08-03  8:21     ` Matt Ranostay
2015-08-04 20:35       ` Tristan Lelong
2015-08-05  1:45         ` Matt Ranostay
2015-08-05  7:13           ` Tristan Lelong

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).