Skip to content

Commit

Permalink
Boiler plate driver implemented with WHO_AM_I register reading. This …
Browse files Browse the repository at this point in the history
…adds support for the driver to all RP2040 devices and also adds the documentation page for the driver, to be added to as it's implemented.
  • Loading branch information
linguini1 committed Oct 11, 2024
1 parent 6e68dde commit 20c042e
Show file tree
Hide file tree
Showing 6 changed files with 619 additions and 0 deletions.
40 changes: 40 additions & 0 deletions Documentation/components/drivers/special/sensors/lsm6dso32.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
LSM6DSO32
=========

Contributed by Carleton University InSpace.

The LSM6DSO32 is an inertial measurement unit that contains an accelerometer and
gyroscope.

Application Programming Interface
=================================

The header file for the LSM6DSO32 interface can be included using:

.. code-block:: c
#include <nuttx/sensors/lsm6dso32.h>
The LSM6DSO32 registration function allows the driver to be registered as a
POSIX character driver.

The standard POSIX `read()` function will return the 3 axes measurements of both
acceleration and angular velocity in plain-text, which is useful when
debugging/testing the driver using `cat` from the shell.

The `write()` operation is not implemented for this sensor.

Specific operations the sensor offers can be performed via the POSIX `ioctl`
operation. The supported commands are:

* :c:macro:`SNIOC_WHO_AM_I`

.. c:macro:: SNIOC_WHO_AM_I
This command reads the `WHO_AM_I` register of the sensor. The register value is
returned in the argument to the command, which must be a `uint8_t` pointer.

.. code-block:: c
uint8_t whoami = 0;
err = ioctl(sensor, SNIOC_WHO_AM_I, &whoami);
15 changes: 15 additions & 0 deletions boards/arm/rp2040/common/src/rp2040_common_bringup.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,11 @@
#include "rp2040_i2c.h"
#endif

#ifdef CONFIG_SENSORS_LSM6DSO32
#include <nuttx/sensors/lsm6dso32.h>
#include "rp2040_i2c.h"
#endif

#ifdef CONFIG_SENSORS_MAX6675
#include <nuttx/sensors/max6675.h>
#include "rp2040_max6675.h"
Expand Down Expand Up @@ -508,6 +513,16 @@ int rp2040_common_bringup(void)
}
#endif

#ifdef CONFIG_SENSORS_LSM6DSO32
/* Try to register LSM6DSO32 device as /dev/imu0 at I2C0. */

ret = lsm6dso32_register("/dev/imu0", rp2040_i2cbus_initialize(0), 0x6b);
if (ret < 0)
{
syslog(LOG_ERR, "ERROR: couldn't initialize LSM6DSO32: %d\n", ret);
}
#endif // CONFIG_SENSORS_LSM6DSO32

#ifdef CONFIG_VIDEO_FB
ret = fb_register(0, 0);
if (ret < 0)
Expand Down
16 changes: 16 additions & 0 deletions drivers/sensors/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -723,6 +723,22 @@ config LSM6DSL_I2C_FREQUENCY
range 1 400000
depends on SENSORS_LSM6DSL

config SENSORS_LSM6DSO32
bool "LSM6DSO32 inertial module"
default n
select I2C
---help---
Enable driver support for the Semtech LSM6DSO32 intertial module.

if SENSORS_LSM6DSO32

config LSM6DSO32_I2C_FREQUENCY
int "LSM6DSO32 I2C frequency"
default 400000
range 1 400000

endif # SENSORS_LSM6DSO32

config SENSORS_LSM9DS1
bool "STMicro LSM9DS1 support"
default n
Expand Down
4 changes: 4 additions & 0 deletions drivers/sensors/Make.defs
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,10 @@ ifeq ($(CONFIG_SENSORS_SHT4X),y)
CSRCS += sht4x.c
endif

ifeq ($(CONFIG_SENSORS_LSM6DSO32),y)
CSRCS += lsm6dso32.c
endif

ifeq ($(CONFIG_SENSORS_SPS30),y)
CSRCS += sps30.c
endif
Expand Down
Loading

0 comments on commit 20c042e

Please sign in to comment.