1LSM6DSM device driver for Google nanohub. 2Driver is by default configured to work on STMicroelectronics nucleo board using SPI. 3 4 5---------- Default driver configuration ---------- 6SPI bus ID : 1 (PB12: SPI_NSS, PB13: SPI_CLK, PB14: SPI_MISO, PB15: SPI_MOSI) 7SPI frequency: 10MHz 8Interrupts: INT1 (PB6), INT2 (unused) 9 10 11---------- Compiling FLAGS ---------- 12LSM6DSM driver supports FLAGS at compile time to enable/disable features. 13It is necessary to modify variant Makefile to include directive to compile the 14driver itself and enable flags. 15 16Supported 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 23Supported 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 33Example: firmware/variant/nucleo/nucleo.mk 34 35FLAGS += -DLSM6DSM_DBG_ENABLED -DLSM6DSM_ACCEL_CALIB_ENABLED -DLSM6DSM_GYRO_CALIB_ENABLED 36FLAGS += -DLSM6DSM_I2C_MASTER_LSM303AGR -DLSM6DSM_I2C_MASTER_USE_INTERNAL_PULLUP -DLSM6DSM_MAGN_CALIB_ENABLED 37SRCS_os += os/drivers/st_lsm6dsm/st_lsm6dsm.c 38 39 40---------- Driver porting ---------- 41If sensor is used in different HW setup, here few modifications to apply into driver: 42 43Regarding 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 48Regarding 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 52Sensors Orientation: 53Sensors orientation can be modified through rotation matrices. Accelerometer and gyroscope are sharing same 54configuration (LSM6DSM_ROT_MATRIX), magnetometer sensor different one (LSM6DSM_MAGN_ROT_MATRIX). 55It is following standard rule of matrices moltiplications. 56Here 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 62where x,y,z are sensors output and x",y",z" are android coordinate system data. 63Matrix is so defined: 64#define LSM6DSM_ROT_MATRIX r11,r12,r13,r21,r22,r23,r31,r32,r33 65 66r** 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