Home | History | Annotate | only in /device/google/contexthub/firmware/os/drivers/st_lsm6dsm
Up to higher level directory
NameDateSize
README05-Oct-20173.5K
st_lsm6dsm.c05-Oct-2017133.7K
st_lsm6dsm_ak09916_slave.h05-Oct-20173K
st_lsm6dsm_lis3mdl_slave.h05-Oct-20175.4K
st_lsm6dsm_lps22hb_slave.h05-Oct-20173.9K
st_lsm6dsm_lsm303agr_slave.h05-Oct-20173.7K

README

      1 LSM6DSM device driver for Google nanohub.
      2 Driver is by default configured to work on STMicroelectronics nucleo board using SPI.
      3 
      4 
      5 ---------- Default driver configuration ----------
      6 SPI bus ID : 1 (PB12: SPI_NSS, PB13: SPI_CLK, PB14: SPI_MISO, PB15: SPI_MOSI)
      7 SPI frequency: 10MHz
      8 Interrupts: INT1 (PB6), INT2 (unused)
      9 
     10 
     11 ---------- Compiling FLAGS ----------
     12 LSM6DSM driver supports FLAGS at compile time to enable/disable features.
     13 It is necessary to modify variant Makefile to include directive to compile the
     14 driver itself and enable flags.
     15 
     16 Supported flags:
     17 * LSM6DSM_DBG_ENABLED: enable debug messages
     18 * LSM6DSM_ACCEL_CALIB_ENABLED: enable accelerometer bias calibration library
     19 * LSM6DSM_GYRO_CALIB_ENABLED: enable gyroscope bias calibration library
     20 * LSM6DSM_MAGN_CALIB_ENABLED: enable magnetometer calibration library (if magnetometer is enabled)
     21 * LSM6DSM_I2C_MASTER_USE_INTERNAL_PULLUP: enable internal pull-up resistors for I2C master (if at least one I2C sensor is enabled)
     22 
     23 Supported I2C master flags:
     24 
     25 -> Magnetometer sensor (only one per time can be used):
     26 * LSM6DSM_I2C_MASTER_LIS3MDL: enable support for STMicroelectronics LIS3MDL magnetometer sensor
     27 * LSM6DSM_I2C_MASTER_LSM303AGR: enable support for STMicroelectronics LSM303AGR magnetometer sensor
     28 * LSM6DSM_I2C_MASTER_AK09916: enable support for AKM AK09916 magnetometer sensor
     29 
     30 -> Barometer sensor (only one per time can be used):
     31 * LSM6DSM_I2C_MASTER_LPS22HB: enable support for STMicroelectronics LPS22HB pressure sensor
     32 
     33 Example: firmware/variant/nucleo/nucleo.mk
     34 
     35 FLAGS += -DLSM6DSM_DBG_ENABLED -DLSM6DSM_ACCEL_CALIB_ENABLED -DLSM6DSM_GYRO_CALIB_ENABLED
     36 FLAGS += -DLSM6DSM_I2C_MASTER_LSM303AGR -DLSM6DSM_I2C_MASTER_USE_INTERNAL_PULLUP -DLSM6DSM_MAGN_CALIB_ENABLED
     37 SRCS_os += os/drivers/st_lsm6dsm/st_lsm6dsm.c
     38 
     39 
     40 ---------- Driver porting ----------
     41 If sensor is used in different HW setup, here few modifications to apply into driver:
     42 
     43 Regarding SPI:
     44 #define LSM6DSM_SPI_SLAVE_BUS_ID                            1              /* SPI bus ID, on STM32F4xx indicate SPI2 */
     45 #define LSM6DSM_SPI_SLAVE_FREQUENCY_HZ                      10000000       /* SPI frequency in Hz */
     46 #define LSM6DSM_SPI_SLAVE_CS_GPIO                           GPIO_PB(12)    /* SPI NSS pin, on STM32F4xx indicate NSS of SPI2 */
     47 
     48 Regarding interrupts:
     49 #define LSM6DSM_INT_IRQ                                     EXTI9_5_IRQn
     50 #define LSM6DSM_INT1_GPIO                                   GPIO_PB(6)     /* LSM6DSM INT1 is required, here connected to STM32F4xx PB6 */
     51 
     52 Sensors Orientation:
     53 Sensors orientation can be modified through rotation matrices. Accelerometer and gyroscope are sharing same
     54 configuration (LSM6DSM_ROT_MATRIX), magnetometer sensor different one (LSM6DSM_MAGN_ROT_MATRIX).
     55 It is following standard rule of matrices moltiplications.
     56 Here an example:
     57 
     58                        [r11 r12 r13]
     59 [x" y" z"] = [x y z] * [r21 r22 r23] = [(x*r11 + y*r21 + z*r31) (x*r12 + y*r22 + z*r32) (x*r13 + y*r23 + z*r33)]
     60                        [r31 r32 r33]
     61 
     62 where x,y,z are sensors output and x",y",z" are android coordinate system data.
     63 Matrix is so defined:
     64 #define LSM6DSM_ROT_MATRIX             r11,r12,r13,r21,r22,r23,r31,r32,r33
     65 
     66 r** can only be: 0 or 1 or -1.
     67 
     68 
     69 - Supported features:
     70 > Accel & Gyro data;
     71 > Accel bias calibration through accel_cal lib;
     72 > Gyro bias calibration through gyro_cal & gyro_stillnes_detect libs;
     73 > Step detector & counter;
     74 > Significant motion;
     75 > Magnetometer sensor connected through I2C master interface (LIS3MDL, LSM303AGR, AK09916);
     76 > Magnetometer calibration though mag_cal lib;
     77 > Pressure sensor connected through I2C master interface (LPS22HB);
     78