You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by ag...@apache.org on 2020/01/16 19:13:56 UTC

[incubator-nuttx-apps] branch pr19 updated: add simple HTS221, LSM303 and LSM6DSL examples (#19)

This is an automated email from the ASF dual-hosted git repository.

aguettouche pushed a commit to branch pr19
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx-apps.git


The following commit(s) were added to refs/heads/pr19 by this push:
     new 9cc5893  add simple HTS221, LSM303 and LSM6DSL examples (#19)
9cc5893 is described below

commit 9cc589382d3c17967451bada9a19391a1424d602
Author: Mateusz Szafoni <ra...@users.noreply.github.com>
AuthorDate: Thu Jan 16 20:13:51 2020 +0100

    add simple HTS221, LSM303 and LSM6DSL examples (#19)
---
 examples/README.txt                           |  15 ++++
 examples/hts221_reader/Kconfig                |  11 +++
 examples/hts221_reader/Make.defs              |  39 ++++++++++
 examples/hts221_reader/Makefile               |  49 ++++++++++++
 examples/hts221_reader/hts221_reader_main.c   |  98 ++++++++++++++++++++++++
 examples/lsm303_reader/Kconfig                |  11 +++
 examples/lsm303_reader/Make.defs              |  39 ++++++++++
 examples/lsm303_reader/Makefile               |  49 ++++++++++++
 examples/lsm303_reader/lsm303_reader_main.c   | 104 ++++++++++++++++++++++++++
 examples/lsm6dsl_reader/Kconfig               |  11 +++
 examples/lsm6dsl_reader/Make.defs             |  39 ++++++++++
 examples/lsm6dsl_reader/Makefile              |  49 ++++++++++++
 examples/lsm6dsl_reader/lsm6dsl_reader_main.c | 104 ++++++++++++++++++++++++++
 13 files changed, 618 insertions(+)

diff --git a/examples/README.txt b/examples/README.txt
index 5aaed9c..5e604b4 100644
--- a/examples/README.txt
+++ b/examples/README.txt
@@ -691,6 +691,21 @@ examples/lis2csh_reader
   A simple reader example for the LIS3DSH acceleration sensor as found on
   STM32F4Discovery rev. C
 
+examples/hts221_reader
+^^^^^^^^^^^^^^^^^^^^^^^
+
+  A simple reader example for the HTS221 humidity sensor.
+
+examples/lsm303_reader
+^^^^^^^^^^^^^^^^^^^^^^^
+
+  A simple reader example for the LSM303 acc-mag sensor.
+
+examples/lsm6dsl_reader
+^^^^^^^^^^^^^^^^^^^^^^^
+
+  A simple reader example for the LSM6DSL acc-gyro sensor.
+
 examples/media
 ^^^^^^^^^^^^^^
 
diff --git a/examples/hts221_reader/Kconfig b/examples/hts221_reader/Kconfig
new file mode 100755
index 0000000..e171744
--- /dev/null
+++ b/examples/hts221_reader/Kconfig
@@ -0,0 +1,11 @@
+#
+# For a description of the syntax of this configuration file,
+# see the file kconfig-language.txt in the NuttX tools repository.
+#
+
+config EXAMPLES_HTS221_READER
+	bool "HTS221 reader example"
+	default n
+	depends on SENSORS_HTS221
+	---help---
+		Enable the HTS221 reader example
diff --git a/examples/hts221_reader/Make.defs b/examples/hts221_reader/Make.defs
new file mode 100755
index 0000000..7073fe5
--- /dev/null
+++ b/examples/hts221_reader/Make.defs
@@ -0,0 +1,39 @@
+############################################################################
+# apps/examples/hts221_reader/Make.defs
+# Adds selected applications to apps/ build
+#
+#   Copyright (C) 2020 Gregory Nutt. All rights reserved.
+#   Author: Mateusz Szafoni <ra...@railab.me>
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+#
+# 1. Redistributions of source code must retain the above copyright
+#    notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+#    notice, this list of conditions and the following disclaimer in
+#    the documentation and/or other materials provided with the
+#    distribution.
+# 3. Neither the name NuttX nor the names of its contributors may be
+#    used to endorse or promote products derived from this software
+#    without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+# POSSIBILITY OF SUCH DAMAGE.
+#
+############################################################################
+
+ifeq ($(CONFIG_EXAMPLES_HTS221_READER),y)
+CONFIGURED_APPS += examples/hts221_reader
+endif
diff --git a/examples/hts221_reader/Makefile b/examples/hts221_reader/Makefile
new file mode 100755
index 0000000..a0a9a6b
--- /dev/null
+++ b/examples/hts221_reader/Makefile
@@ -0,0 +1,49 @@
+############################################################################
+# apps/examples/hts221_reader/Makefile
+#
+#   Copyright (C) 2020 Gregory Nutt. All rights reserved.
+#   Author: Mateusz Szafoni <ra...@railab.me>
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+#
+# 1. Redistributions of source code must retain the above copyright
+#    notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+#    notice, this list of conditions and the following disclaimer in
+#    the documentation and/or other materials provided with the
+#    distribution.
+# 3. Neither the name NuttX nor the names of its contributors may be
+#    used to endorse or promote products derived from this software
+#    without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+# POSSIBILITY OF SUCH DAMAGE.
+#
+############################################################################
+
+-include $(TOPDIR)/Make.defs
+
+# hts221_reader example
+
+MAINSRC = hts221_reader_main.c
+
+# application info
+
+PROGNAME = hts221_reader
+PRIORITY = SCHED_PRIORITY_DEFAULT
+STACKSIZE = 2048
+MODULE = $(CONFIG_EXAMPLES_HTS221_READER)
+
+include $(APPDIR)/Application.mk
diff --git a/examples/hts221_reader/hts221_reader_main.c b/examples/hts221_reader/hts221_reader_main.c
new file mode 100644
index 0000000..9a58c00
--- /dev/null
+++ b/examples/hts221_reader/hts221_reader_main.c
@@ -0,0 +1,98 @@
+/****************************************************************************
+ * examples/hts221_reader/hts221_reader_main.c
+ *
+ *   Copyright (C) 2020 Gregory Nutt. All rights reserved.
+ *   Author: Mateusz Szafoni <ra...@railab.me>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the
+ *    distribution.
+ * 3. Neither the name NuttX nor the names of its contributors may be
+ *    used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <sys/ioctl.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <errno.h>
+#include <unistd.h>
+
+#include <debug.h>
+
+#include <nuttx/sensors/hts221.h>
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * lsm303_reader_main
+ ****************************************************************************/
+
+int main(int argc, FAR char *argv[])
+{
+  FILE *sensor;
+  hts221_conv_data_t sensor_data;
+  int i = 0;
+  int ret;
+
+  sensor = fopen("/dev/hts2210", "r");
+  if (sensor == NULL)
+    {
+      printf("Unable to create file\n");
+      return -ENOENT;
+    }
+
+  ret = ioctl(fileno(sensor), SNIOC_START, 0);
+  if (ret < 0)
+    {
+      printf("IOCTL SNIOC_START failed %d\n", ret);
+    }
+
+  for (i = 0; 1; i++)
+    {
+      ret = ioctl(fileno(sensor),  SNIOC_READ_CONVERT_DATA,
+                  (unsigned long)&sensor_data);
+      if (ret < 0)
+        {
+          printf("IOCTL READ failed %d\n", ret);
+        }
+
+      printf("temp: %d, hum: %d\n",
+             sensor_data.temperature,
+             sensor_data.humidity);
+
+      sleep(2);
+    }
+
+  fclose(sensor);
+  return EXIT_SUCCESS;
+}
diff --git a/examples/lsm303_reader/Kconfig b/examples/lsm303_reader/Kconfig
new file mode 100755
index 0000000..501f905
--- /dev/null
+++ b/examples/lsm303_reader/Kconfig
@@ -0,0 +1,11 @@
+#
+# For a description of the syntax of this configuration file,
+# see the file kconfig-language.txt in the NuttX tools repository.
+#
+
+config EXAMPLES_LSM303_READER
+	bool "LSM303 reader example"
+	default n
+	depends on SENSORS_LSM303AGR
+	---help---
+		Enable the LSM303 reader example
diff --git a/examples/lsm303_reader/Make.defs b/examples/lsm303_reader/Make.defs
new file mode 100755
index 0000000..75dfb34
--- /dev/null
+++ b/examples/lsm303_reader/Make.defs
@@ -0,0 +1,39 @@
+############################################################################
+# apps/examples/lsm303_reader/Make.defs
+# Adds selected applications to apps/ build
+#
+#   Copyright (C) 2020 Gregory Nutt. All rights reserved.
+#   Author: Mateusz Szafoni <ra...@railab.me>
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+#
+# 1. Redistributions of source code must retain the above copyright
+#    notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+#    notice, this list of conditions and the following disclaimer in
+#    the documentation and/or other materials provided with the
+#    distribution.
+# 3. Neither the name NuttX nor the names of its contributors may be
+#    used to endorse or promote products derived from this software
+#    without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+# POSSIBILITY OF SUCH DAMAGE.
+#
+############################################################################
+
+ifeq ($(CONFIG_EXAMPLES_LSM303_READER),y)
+CONFIGURED_APPS += examples/lsm303_reader
+endif
diff --git a/examples/lsm303_reader/Makefile b/examples/lsm303_reader/Makefile
new file mode 100755
index 0000000..0e11a15
--- /dev/null
+++ b/examples/lsm303_reader/Makefile
@@ -0,0 +1,49 @@
+############################################################################
+# apps/examples/lsm303_reader/Makefile
+#
+#   Copyright (C) 2020 Gregory Nutt. All rights reserved.
+#   Author: Mateusz Szafoni <ra...@railab.me>
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+#
+# 1. Redistributions of source code must retain the above copyright
+#    notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+#    notice, this list of conditions and the following disclaimer in
+#    the documentation and/or other materials provided with the
+#    distribution.
+# 3. Neither the name NuttX nor the names of its contributors may be
+#    used to endorse or promote products derived from this software
+#    without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+# POSSIBILITY OF SUCH DAMAGE.
+#
+############################################################################
+
+-include $(TOPDIR)/Make.defs
+
+# lsm303_reader example
+
+MAINSRC = lsm303_reader_main.c
+
+# application info
+
+PROGNAME = lsm303_reader
+PRIORITY = SCHED_PRIORITY_DEFAULT
+STACKSIZE = 2048
+MODULE = $(CONFIG_EXAMPLES_LSM303_READER)
+
+include $(APPDIR)/Application.mk
diff --git a/examples/lsm303_reader/lsm303_reader_main.c b/examples/lsm303_reader/lsm303_reader_main.c
new file mode 100644
index 0000000..f21c016
--- /dev/null
+++ b/examples/lsm303_reader/lsm303_reader_main.c
@@ -0,0 +1,104 @@
+/****************************************************************************
+ * examples/lsm303_reader/lsm303_reader_main.c
+ *
+ *   Copyright (C) 2020 Gregory Nutt. All rights reserved.
+ *   Author: Mateusz Szafoni <ra...@railab.me>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the
+ *    distribution.
+ * 3. Neither the name NuttX nor the names of its contributors may be
+ *    used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <sys/ioctl.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <errno.h>
+#include <unistd.h>
+
+#include <debug.h>
+
+#include <nuttx/sensors/lsm303agr.h>
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * lsm303_reader_main
+ ****************************************************************************/
+
+int main(int argc, FAR char *argv[])
+{
+  FILE *sensor;
+  struct lsm303agr_sensor_data_s sensor_data;
+  int i = 0;
+  int ret;
+
+  sensor = fopen("/dev/lsm303agr0", "r");
+  if (sensor == NULL)
+    {
+      printf("Unable to create file\n");
+      return -ENOENT;
+    }
+
+  ret = ioctl(fileno(sensor), SNIOC_START, 0);
+  if (ret < 0)
+    {
+      printf("IOCTL SNIOC_START failed %d\n", ret);
+    }
+
+  for (i = 0; 1; i++)
+    {
+      ret = ioctl(fileno(sensor), SNIOC_LSM303AGRSENSORREAD,
+                  (unsigned long)&sensor_data);
+      if (ret < 0)
+        {
+          printf("IOCTL READ failed %d\n", ret);
+        }
+
+      printf("time:%d x:%d y:%d z:%d m_x:%d m_y:%d m_z:%d temp:%d\n",
+             sensor_data.timestamp,
+             sensor_data.x_data,
+             sensor_data.y_data,
+             sensor_data.z_data,
+             sensor_data.m_x_data,
+             sensor_data.m_y_data,
+             sensor_data.m_z_data,
+             sensor_data.temperature);
+
+      sleep(2);
+    }
+
+  fclose(sensor);
+  return EXIT_SUCCESS;
+}
diff --git a/examples/lsm6dsl_reader/Kconfig b/examples/lsm6dsl_reader/Kconfig
new file mode 100755
index 0000000..d27e770
--- /dev/null
+++ b/examples/lsm6dsl_reader/Kconfig
@@ -0,0 +1,11 @@
+#
+# For a description of the syntax of this configuration file,
+# see the file kconfig-language.txt in the NuttX tools repository.
+#
+
+config EXAMPLES_LSM6DSL_READER
+	bool "LSM6DSL reader example"
+	default n
+	depends on SENSORS_LSM6DSL
+	---help---
+		Enable the LSM6DSL reader example
diff --git a/examples/lsm6dsl_reader/Make.defs b/examples/lsm6dsl_reader/Make.defs
new file mode 100755
index 0000000..9fed1ce
--- /dev/null
+++ b/examples/lsm6dsl_reader/Make.defs
@@ -0,0 +1,39 @@
+############################################################################
+# apps/examples/lsm6dsl_reader/Make.defs
+# Adds selected applications to apps/ build
+#
+#   Copyright (C) 2017 Florian Olbrich. All rights reserved.
+#   Author: Florian Olbrich <fl...@oth-regensburg.de>
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+#
+# 1. Redistributions of source code must retain the above copyright
+#    notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+#    notice, this list of conditions and the following disclaimer in
+#    the documentation and/or other materials provided with the
+#    distribution.
+# 3. Neither the name NuttX nor the names of its contributors may be
+#    used to endorse or promote products derived from this software
+#    without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+# POSSIBILITY OF SUCH DAMAGE.
+#
+############################################################################
+
+ifeq ($(CONFIG_EXAMPLES_LSM6DSL_READER),y)
+CONFIGURED_APPS += examples/lsm6dsl_reader
+endif
diff --git a/examples/lsm6dsl_reader/Makefile b/examples/lsm6dsl_reader/Makefile
new file mode 100755
index 0000000..4d558b0
--- /dev/null
+++ b/examples/lsm6dsl_reader/Makefile
@@ -0,0 +1,49 @@
+############################################################################
+# apps/examples/lsm6dsl_reader/Makefile
+#
+#   Copyright (C) 2020 Gregory Nutt. All rights reserved.
+#   Author: Mateusz Szafoni <ra...@railab.me>
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+#
+# 1. Redistributions of source code must retain the above copyright
+#    notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+#    notice, this list of conditions and the following disclaimer in
+#    the documentation and/or other materials provided with the
+#    distribution.
+# 3. Neither the name NuttX nor the names of its contributors may be
+#    used to endorse or promote products derived from this software
+#    without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+# POSSIBILITY OF SUCH DAMAGE.
+#
+############################################################################
+
+-include $(TOPDIR)/Make.defs
+
+# lsm6dsl_reader example
+
+MAINSRC = lsm6dsl_reader_main.c
+
+# application info
+
+PROGNAME = lsm6dsl_reader
+PRIORITY = SCHED_PRIORITY_DEFAULT
+STACKSIZE = 2048
+MODULE = $(CONFIG_EXAMPLES_LSM6DSL_READER)
+
+include $(APPDIR)/Application.mk
diff --git a/examples/lsm6dsl_reader/lsm6dsl_reader_main.c b/examples/lsm6dsl_reader/lsm6dsl_reader_main.c
new file mode 100644
index 0000000..5803be0
--- /dev/null
+++ b/examples/lsm6dsl_reader/lsm6dsl_reader_main.c
@@ -0,0 +1,104 @@
+/****************************************************************************
+ * examples/lsm6dsl_reader/lsm6dsl_reader_main.c
+ *
+ *   Copyright (C) 2020 Gregory Nutt. All rights reserved.
+ *   Author: Mateusz Szafoni <ra...@railab.me>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the
+ *    distribution.
+ * 3. Neither the name NuttX nor the names of its contributors may be
+ *    used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <sys/ioctl.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <errno.h>
+#include <unistd.h>
+
+#include <debug.h>
+
+#include <nuttx/sensors/lsm6dsl.h>
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * lsm6dsl_reader_main
+ ****************************************************************************/
+
+int main(int argc, FAR char *argv[])
+{
+  FILE *sensor;
+  struct lsm6dsl_sensor_data_s sensor_data;
+  int i = 0;
+  int ret;
+
+  sensor = fopen("/dev/lsm6dsl0", "r");
+  if (sensor == NULL)
+    {
+      printf("Unable to create file\n");
+      return -ENOENT;
+    }
+
+  ret = ioctl(fileno(sensor), SNIOC_START, 0);
+  if (ret < 0)
+    {
+      printf("IOCTL SNIOC_START failed %d\n", ret);
+    }
+
+  for (i = 0; 1; i++)
+    {
+      ret = ioctl(fileno(sensor), SNIOC_LSM6DSLSENSORREAD,
+                  (unsigned long)&sensor_data);
+      if (ret < 0)
+        {
+          printf("IOCTL READ failed %d\n", ret);
+        }
+
+      printf("time:%d x:%d y:%d z:%d m_x:%d m_y:%d m_z:%d temp:%d\n",
+             sensor_data.timestamp,
+             sensor_data.x_data,
+             sensor_data.y_data,
+             sensor_data.z_data,
+             sensor_data.g_x_data,
+             sensor_data.g_y_data,
+             sensor_data.g_z_data,
+             sensor_data.temperature);
+
+      sleep(2);
+    }
+
+  fclose(sensor);
+  return EXIT_SUCCESS;
+}