- Notifications
You must be signed in to change notification settings - Fork43
DISCONTINUED (October 2022): the maintenance for this repository has been discontinued. Please refer tohttps://github.com/STMicroelectronics/st-mems-android-linux-drivers-iio for the up-to-date drivers repository. This repository contains Linux Kernel (v3.10, v3.14, v3.18, v4.9, v4.14, v4.19) including STMicroelectronics MEMS IIO sensor support
License
STMicroelectronics/STMems_Linux_IIO_drivers
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
DISCONTINUED (October 2022): the maintenance for this repository has been discontinued.
Please refer to:
https://github.com/STMicroelectronics/st-mems-android-linux-drivers-iio
for the up-to-date drivers repository.
* Introduction* Integration details* More information* Copyright
This repository contains Linux kernel v4.4 with STMicroelectronics MEMS sensor support. STM sensor drivers are located under the directorydrivers/iio organized by sensor type:
LSM6DS3, LSM6DS3H, LSM6DSL, LSM6DSM, LSM9DS0, LSM9DS1, ISM330DLC, LSM6DSO, ASM330LHH, LSM6DSR, ISM330DHCX, LSM6DSO32,LSM6DSOX, LSM6DSRX, LSM6DSO32X, ASM330LHHX
LIS2DH, LIS2DH12, LIS3DH, LIS2DG, LSM303AH, LIS2DS12, LIS2HH12, LIS2DW12, LIS3LV02DL,LSM303DLH, LSM303DLHC, LSM330D, LSM330DL, LSM330DLC, LIS331DL, LIS331DLH, LSM303DL,LSM303DLM, LSM330, LSM303AGR, LIS3DHH, IIS2DH, ISM303DAC, IIS3DHHC, IIS2DLPC, AIS2IH
L3G4200D, LSM330D, LSM330DL, L3GD20, L3GD20H, L3G4IS, LSM330, LSM330DLC
LIS3MDL, LSM9DS1, LSM303AH, LSM303AGR, LSM303DLH, LSM303DLHC, LSM303DLM, LIS2MDL, IIS2MDC, ISM303DAC
HTS221
LPS22HB, LPS22HD, LPS25H, LPS331AP, LPS001WP, LPS33HW, LPS35HW, LPS22HH, LPS27HHW, LPS22DF
STTS22H
Data collected by STM sensors are pushed to userland through the kernel buffers of Linux IIO framework. User space applications can get sensor events by reading the related IIO devices created in the /dev directory (/dev/iio{x}). Please seeIIO for more information.
All STM MEMS sensors supportI2C/SPI digital interface. Please refer toI2C andSPI for detailed documentation.
In order to explain how to integrate STM sensors in a different kernel, please consider the followingLSM6DSM IMU example
- Copy driver source code into the target directory (e.g.drivers/iio/imu)
- Edit related Kconfig (e.g.drivers/iio/imu/Kconfig) to includeLSM6DSM support:
source "drivers/iio/imu/st_lsm6dsm/Kconfig"
- Edit related Makefile (e.g.drivers/iio/imu/Makefile) adding the following line:
obj-y += lsm6dsm/
- Add custom events intoinclude/uapi/linux/iio/types.h (follow a sample patch for kernel 4.4):
@@ -85,6 +93,7 @@ enum iio_event_type { IIO_EV_TYPE_THRESH_ADAPTIVE, IIO_EV_TYPE_MAG_ADAPTIVE, IIO_EV_TYPE_CHANGE, + IIO_EV_TYPE_FIFO_FLUSH, }; @@ -92,6 +101,8 @@ enum iio_event_direction { IIO_EV_DIR_RISING, IIO_EV_DIR_FALLING, IIO_EV_DIR_NONE, + IIO_EV_DIR_FIFO_EMPTY, + IIO_EV_DIR_FIFO_DATA, };
- Add custom channel typesinclude/uapi/linux/iio/types.h depending on the custom sensor implemented into driver (follow a sample patch for kernel 4.4):
@@ -37,6 +37,14 @@ enum iio_chan_type { IIO_VELOCITY, IIO_CONCENTRATION, IIO_RESISTANCE, + IIO_SIGN_MOTION, + IIO_STEP_DETECTOR, + IIO_STEP_COUNTER, + IIO_TILT, + IIO_TAP, + IIO_TAP_TAP, + IIO_WRIST_TILT_GESTURE, + IIO_GESTURE, + IIO_WKUP, + IIO_FREE_FALL, };
To enable driver probing, add the lsm6dsm node to the platform device tree as described below.
Required properties:
- compatible: "st,lsm6dsm"
- reg: the I2C address or SPI chip select the device will respond to
- interrupt-parent: phandle to the parent interrupt controller as documented ininterrupts
- interrupts: interrupt mapping for IRQ as documented ininterrupts
Recommended properties for SPI bus usage:
- spi-max-frequency: maximum SPI bus frequency as documented inSPI
Optional properties:
- st,drdy-int-pin: MEMS sensor interrupt line to use (default 1)
I2C example (based on Raspberry PI 3):
&i2c0 { status = "ok"; #address-cells = <0x1>; #size-cells = <0x0>; lsm6dsm@6b { compatible = "st,lsm6dsm"; reg = <0x6b>; interrupt-parent = <&gpio>; interrupts = <26 IRQ_TYPE_LEVEL_HIGH>; };
SPI example (based on Raspberry PI 3):
&spi0 { status = "ok"; #address-cells = <0x1>; #size-cells = <0x0>; lsm6dsm@0 { spi-max-frequency = <500000>; compatible = "st,lsm6dsm"; reg = <0>; interrupt-parent = <&gpio>; interrupts = <26 IRQ_TYPE_LEVEL_HIGH>; };
Configure kernel withmake menuconfig (alternatively usemake xconfig ormake qconfig)
Device Drivers ---> <M> Industrial I/O support ---> Inertial measurement units ---> <M> STMicroelectronics LSM6DSM/LSM6DSL sensor --->
https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/Documentation/iio
https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/Documentation/i2c
https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/Documentation/spi
Copyright (C) 2019 STMicroelectronics
This software is distributed under the GNU General Public License - see the accompanying COPYING file for more details.
About
DISCONTINUED (October 2022): the maintenance for this repository has been discontinued. Please refer tohttps://github.com/STMicroelectronics/st-mems-android-linux-drivers-iio for the up-to-date drivers repository. This repository contains Linux Kernel (v3.10, v3.14, v3.18, v4.9, v4.14, v4.19) including STMicroelectronics MEMS IIO sensor support
Topics
Resources
License
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Releases
Packages0
Uh oh!
There was an error while loading.Please reload this page.
Contributors4,621
Uh oh!
There was an error while loading.Please reload this page.