You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by xi...@apache.org on 2023/08/27 02:05:10 UTC

[nuttx] branch master updated (7109fd6121 -> af4a065efb)

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

xiaoxiang pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git


    from 7109fd6121 sensors/Kconfig: fix wrong depends on SN_XXX
     new 8665acaffa lsm9ds1.c: fix printf warnings
     new af4a065efb nrf52840-dk: add lsm9ds1 sensor support

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../include/{nrf52_progmem.h => nrf52_lsm9ds1.h}    | 16 ++++++++--------
 boards/arm/nrf52/common/src/CMakeLists.txt          |  4 ++++
 boards/arm/nrf52/common/src/Make.defs               |  4 ++++
 .../src/nrf52_lsm9ds1.c                             | 21 +++++++--------------
 boards/arm/nrf52/nrf52840-dk/src/nrf52_bringup.c    | 16 +++++++++++++++-
 drivers/sensors/lsm9ds1.c                           |  7 ++++---
 6 files changed, 42 insertions(+), 26 deletions(-)
 copy boards/arm/nrf52/common/include/{nrf52_progmem.h => nrf52_lsm9ds1.h} (80%)
 copy boards/arm/nrf52/{arduino-nano-33ble => common}/src/nrf52_lsm9ds1.c (85%)


[nuttx] 01/02: lsm9ds1.c: fix printf warnings

Posted by xi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git

commit 8665acaffaaceb0d0b2febe6c298a4586980c557
Author: raiden00pl <ra...@railab.me>
AuthorDate: Sat Aug 26 15:42:41 2023 +0200

    lsm9ds1.c: fix printf warnings
---
 drivers/sensors/lsm9ds1.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/sensors/lsm9ds1.c b/drivers/sensors/lsm9ds1.c
index 948f86dad4..cc98061979 100644
--- a/drivers/sensors/lsm9ds1.c
+++ b/drivers/sensors/lsm9ds1.c
@@ -1367,14 +1367,16 @@ static int lsm9ds1_ioctl(FAR struct file *filep, int cmd, unsigned long arg)
 
       case SNIOC_SETSAMPLERATE:
         ret = priv->ops->setsamplerate(priv, (uint32_t)arg);
-        sninfo("sample rate: %08x ret: %d\n", (uint32_t)arg, ret);
+        sninfo("sample rate: %08" PRId32 " ret: %d\n",
+               (uint32_t)arg, ret);
         break;
 
       /* Set the full-scale range. Arg: uint32_t value. */
 
       case SNIOC_SETFULLSCALE:
         ret = priv->ops->setfullscale(priv, (uint32_t)arg);
-        sninfo("full-scale range: %08x ret: %d\n", (uint32_t)arg, ret);
+        sninfo("full-scale range: %08" PRId32 " ret: %d\n",
+               (uint32_t)arg, ret);
         break;
 
       /* Unrecognized commands */
@@ -1550,5 +1552,4 @@ int lsm9ds1mag_register(FAR const char *devpath,
   return lsm9ds1_register(devpath, i2c, addr, &g_lsm9ds1mag_ops,
                           LSM9DS1_OUT_X_L_M);
 }
-
 #endif /* CONFIG_I2C && CONFIG_SENSORS_LSM9DS1 */


[nuttx] 02/02: nrf52840-dk: add lsm9ds1 sensor support

Posted by xi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git

commit af4a065efb43e547e5e6efc1aef7960dda16e382
Author: raiden00pl <ra...@railab.me>
AuthorDate: Sat Aug 26 15:46:03 2023 +0200

    nrf52840-dk: add lsm9ds1 sensor support
---
 boards/arm/nrf52/common/include/nrf52_lsm9ds1.h  | 46 +++++++++++
 boards/arm/nrf52/common/src/CMakeLists.txt       |  4 +
 boards/arm/nrf52/common/src/Make.defs            |  4 +
 boards/arm/nrf52/common/src/nrf52_lsm9ds1.c      | 97 ++++++++++++++++++++++++
 boards/arm/nrf52/nrf52840-dk/src/nrf52_bringup.c | 16 +++-
 5 files changed, 166 insertions(+), 1 deletion(-)

diff --git a/boards/arm/nrf52/common/include/nrf52_lsm9ds1.h b/boards/arm/nrf52/common/include/nrf52_lsm9ds1.h
new file mode 100644
index 0000000000..80f79c9c51
--- /dev/null
+++ b/boards/arm/nrf52/common/include/nrf52_lsm9ds1.h
@@ -0,0 +1,46 @@
+/****************************************************************************
+ * boards/arm/nrf52/common/include/nrf52_lsm9ds1.h
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.  The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ ****************************************************************************/
+
+#ifndef __BOARDS_ARM_NRF52_COMMON_INCLUDE_NRF52_LSM9DS1_H
+#define __BOARDS_ARM_NRF52_COMMON_INCLUDE_NRF52_LSM9DS1_H
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+/****************************************************************************
+ * Public Functions Prototypes
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: nrf52_lsm9ds1_initialize
+ *
+ * Description:
+ *   Initialize I2C-based LSM9DS1.
+ *
+ ****************************************************************************/
+
+#ifdef CONFIG_SENSORS_LSM9DS1
+int nrf52_lsm9ds1_initialize(int bus);
+#endif
+
+#endif /* __BOARDS_ARM_NRF52_COMMON_INCLUDE_NRF52_LSM9DS1_H */
diff --git a/boards/arm/nrf52/common/src/CMakeLists.txt b/boards/arm/nrf52/common/src/CMakeLists.txt
index 5a2844de3e..7c3d75b759 100644
--- a/boards/arm/nrf52/common/src/CMakeLists.txt
+++ b/boards/arm/nrf52/common/src/CMakeLists.txt
@@ -32,6 +32,10 @@ if(CONFIG_ARCH_BOARD_COMMON)
     list(APPEND SRCS nrf52_progmem.c)
   endif()
 
+  if(CONFIG_SENSORS_LSM9DS1)
+    list(APPEND SRCS nrf52_lsm9ds1.c)
+  endif()
+
   target_sources(board PRIVATE ${SRCS})
 
 endif()
diff --git a/boards/arm/nrf52/common/src/Make.defs b/boards/arm/nrf52/common/src/Make.defs
index 7656988081..07994dc14a 100644
--- a/boards/arm/nrf52/common/src/Make.defs
+++ b/boards/arm/nrf52/common/src/Make.defs
@@ -32,6 +32,10 @@ ifeq ($(CONFIG_NRF52_PROGMEM),y)
   CSRCS += nrf52_progmem.c
 endif
 
+ifeq ($(CONFIG_SENSORS_LSM9DS1),y)
+CSRCS += nrf52_lsm9ds1.c
+endif
+
 DEPPATH += --dep-path src
 VPATH += :src
 CFLAGS += ${INCDIR_PREFIX}$(TOPDIR)$(DELIM)arch$(DELIM)$(CONFIG_ARCH)$(DELIM)src$(DELIM)board$(DELIM)src
diff --git a/boards/arm/nrf52/common/src/nrf52_lsm9ds1.c b/boards/arm/nrf52/common/src/nrf52_lsm9ds1.c
new file mode 100644
index 0000000000..af6ba01b3d
--- /dev/null
+++ b/boards/arm/nrf52/common/src/nrf52_lsm9ds1.c
@@ -0,0 +1,97 @@
+/****************************************************************************
+ * boards/arm/nrf52/common/src/nrf52_lsm9ds1.c
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.  The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+#include <nuttx/arch.h>
+
+#include <errno.h>
+#include <debug.h>
+
+#include <nuttx/board.h>
+#include "nrf52_i2c.h"
+#include <nuttx/sensors/lsm9ds1.h>
+
+/****************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************/
+
+#define LSM9DS1MAG_DEVPATH "/dev/lsm9ds1mag0"
+#define LSM9DS1ACC_DEVPATH "/dev/lsm9ds1acc0"
+#define LSM9DS1GYR_DEVPATH "/dev/lsm9ds1gyr0"
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: nrf52_lsm9ds1_initialize
+ *
+ * Description:
+ *   Initialize I2C-based LSM9DS1.
+ *
+ ****************************************************************************/
+
+int nrf52_lsm9ds1_initialize(int bus)
+{
+  struct i2c_master_s *i2c;
+  int ret = OK;
+
+  sninfo("Initializing LMS6DSL!\n");
+
+  i2c = nrf52_i2cbus_initialize(bus);
+  if (i2c == NULL)
+    {
+      return -ENODEV;
+    }
+
+  sninfo("INFO: Initializing LMS9DS1 9DoF sensor over I2C%d\n", bus);
+
+  /* Register snesors as character devices */
+
+  ret = lsm9ds1mag_register(LSM9DS1MAG_DEVPATH, i2c, LSM9DS1MAG_ADDR1);
+  if (ret < 0)
+    {
+      snerr("ERROR: Failed to initialize LMS9DS1 mag driver %s\n",
+            LSM9DS1MAG_DEVPATH);
+      return -ENODEV;
+    }
+
+  ret = lsm9ds1gyro_register(LSM9DS1GYR_DEVPATH, i2c, LSM9DS1GYRO_ADDR1);
+  if (ret < 0)
+    {
+      snerr("ERROR: Failed to initialize LMS9DS1 gyro driver %s\n",
+            LSM9DS1MAG_DEVPATH);
+      return -ENODEV;
+    }
+
+  ret = lsm9ds1accel_register(LSM9DS1ACC_DEVPATH, i2c, LSM9DS1ACCEL_ADDR1);
+  if (ret < 0)
+    {
+      snerr("ERROR: Failed to initialize LMS9DS1 accel driver %s\n",
+            LSM9DS1MAG_DEVPATH);
+      return -ENODEV;
+    }
+
+  return ret;
+}
diff --git a/boards/arm/nrf52/nrf52840-dk/src/nrf52_bringup.c b/boards/arm/nrf52/nrf52840-dk/src/nrf52_bringup.c
index cc2ceac865..f59b7b7a97 100644
--- a/boards/arm/nrf52/nrf52840-dk/src/nrf52_bringup.c
+++ b/boards/arm/nrf52/nrf52840-dk/src/nrf52_bringup.c
@@ -57,13 +57,18 @@
 #  include "nrf52_sdc.h"
 #endif
 
+#ifdef CONFIG_SENSORS_LSM9DS1
+#  include "nrf52_lsm9ds1.h"
+#endif
+
 #include "nrf52840-dk.h"
 
 /****************************************************************************
  * Pre-processor Definitions
  ****************************************************************************/
 
-#define NRF52_TIMER (0)
+#define NRF52_TIMER    (0)
+#define LMS9DS1_I2CBUS (0)
 
 /****************************************************************************
  * Public Functions
@@ -295,6 +300,15 @@ int nrf52_bringup(void)
     }
 #endif /* CONFIG_MTD */
 
+#ifdef CONFIG_SENSORS_LSM9DS1
+  ret = nrf52_lsm9ds1_initialize(LMS9DS1_I2CBUS);
+  if (ret < 0)
+    {
+      syslog(LOG_ERR, "ERROR: Failed to initialize LSM9DS1 driver: %d\n",
+             ret);
+    }
+#endif /* CONFIG_SENSORS_LSM6DSL */
+
   UNUSED(ret);
   return OK;
 }