Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
LSM9DS1_Types.h@4:681443188833, 2020-01-27 (annotated)
- Committer:
 - zmoutaou
 - Date:
 - Mon Jan 27 10:47:24 2020 +0000
 - Revision:
 - 4:681443188833
 - Parent:
 - 0:e8167f37725c
 
LSM9DS1 first example
Who changed what in which revision?
| User | Revision | Line number | New contents of line | 
|---|---|---|---|
| jmar7 | 0:e8167f37725c | 1 | /****************************************************************************** | 
| jmar7 | 0:e8167f37725c | 2 | LSM9DS1_Types.h | 
| jmar7 | 0:e8167f37725c | 3 | SFE_LSM9DS1 Library - LSM9DS1 Types and Enumerations | 
| jmar7 | 0:e8167f37725c | 4 | Jim Lindblom @ SparkFun Electronics | 
| jmar7 | 0:e8167f37725c | 5 | Original Creation Date: April 21, 2015 | 
| jmar7 | 0:e8167f37725c | 6 | https://github.com/sparkfun/LSM9DS1_Breakout | 
| jmar7 | 0:e8167f37725c | 7 | |
| jmar7 | 0:e8167f37725c | 8 | This file defines all types and enumerations used by the LSM9DS1 class. | 
| jmar7 | 0:e8167f37725c | 9 | |
| jmar7 | 0:e8167f37725c | 10 | Development environment specifics: | 
| jmar7 | 0:e8167f37725c | 11 | IDE: Arduino 1.6.0 | 
| jmar7 | 0:e8167f37725c | 12 | Hardware Platform: Arduino Uno | 
| jmar7 | 0:e8167f37725c | 13 | LSM9DS1 Breakout Version: 1.0 | 
| jmar7 | 0:e8167f37725c | 14 | |
| jmar7 | 0:e8167f37725c | 15 | This code is beerware; if you see me (or any other SparkFun employee) at the | 
| jmar7 | 0:e8167f37725c | 16 | local, and you've found our code helpful, please buy us a round! | 
| jmar7 | 0:e8167f37725c | 17 | |
| jmar7 | 0:e8167f37725c | 18 | Distributed as-is; no warranty is given. | 
| jmar7 | 0:e8167f37725c | 19 | ******************************************************************************/ | 
| jmar7 | 0:e8167f37725c | 20 | |
| jmar7 | 0:e8167f37725c | 21 | #ifndef __LSM9DS1_Types_H__ | 
| jmar7 | 0:e8167f37725c | 22 | #define __LSM9DS1_Types_H__ | 
| jmar7 | 0:e8167f37725c | 23 | |
| jmar7 | 0:e8167f37725c | 24 | #include "LSM9DS1_Registers.h" | 
| jmar7 | 0:e8167f37725c | 25 | |
| jmar7 | 0:e8167f37725c | 26 | // The LSM9DS1 functions over both I2C or SPI. This library supports both. | 
| jmar7 | 0:e8167f37725c | 27 | // But the interface mode used must be sent to the LSM9DS1 constructor. Use | 
| jmar7 | 0:e8167f37725c | 28 | // one of these two as the first parameter of the constructor. | 
| jmar7 | 0:e8167f37725c | 29 | enum interface_mode | 
| jmar7 | 0:e8167f37725c | 30 | { | 
| jmar7 | 0:e8167f37725c | 31 | IMU_MODE_SPI, | 
| jmar7 | 0:e8167f37725c | 32 | IMU_MODE_I2C, | 
| jmar7 | 0:e8167f37725c | 33 | }; | 
| jmar7 | 0:e8167f37725c | 34 | |
| jmar7 | 0:e8167f37725c | 35 | // accel_scale defines all possible FSR's of the accelerometer: | 
| jmar7 | 0:e8167f37725c | 36 | enum accel_scale | 
| jmar7 | 0:e8167f37725c | 37 | { | 
| jmar7 | 0:e8167f37725c | 38 | A_SCALE_2G, // 00: 2g | 
| jmar7 | 0:e8167f37725c | 39 | A_SCALE_16G,// 01: 16g | 
| jmar7 | 0:e8167f37725c | 40 | A_SCALE_4G, // 10: 4g | 
| jmar7 | 0:e8167f37725c | 41 | A_SCALE_8G // 11: 8g | 
| jmar7 | 0:e8167f37725c | 42 | }; | 
| jmar7 | 0:e8167f37725c | 43 | |
| jmar7 | 0:e8167f37725c | 44 | // gyro_scale defines the possible full-scale ranges of the gyroscope: | 
| jmar7 | 0:e8167f37725c | 45 | enum gyro_scale | 
| jmar7 | 0:e8167f37725c | 46 | { | 
| jmar7 | 0:e8167f37725c | 47 | G_SCALE_245DPS, // 00: 245 degrees per second | 
| jmar7 | 0:e8167f37725c | 48 | G_SCALE_500DPS, // 01: 500 dps | 
| jmar7 | 0:e8167f37725c | 49 | G_SCALE_2000DPS, // 11: 2000 dps | 
| jmar7 | 0:e8167f37725c | 50 | }; | 
| jmar7 | 0:e8167f37725c | 51 | |
| jmar7 | 0:e8167f37725c | 52 | // mag_scale defines all possible FSR's of the magnetometer: | 
| jmar7 | 0:e8167f37725c | 53 | enum mag_scale | 
| jmar7 | 0:e8167f37725c | 54 | { | 
| jmar7 | 0:e8167f37725c | 55 | M_SCALE_4GS, // 00: 4Gs | 
| jmar7 | 0:e8167f37725c | 56 | M_SCALE_8GS, // 01: 8Gs | 
| jmar7 | 0:e8167f37725c | 57 | M_SCALE_12GS, // 10: 12Gs | 
| jmar7 | 0:e8167f37725c | 58 | M_SCALE_16GS, // 11: 16Gs | 
| jmar7 | 0:e8167f37725c | 59 | }; | 
| jmar7 | 0:e8167f37725c | 60 | |
| jmar7 | 0:e8167f37725c | 61 | // gyro_odr defines all possible data rate/bandwidth combos of the gyro: | 
| jmar7 | 0:e8167f37725c | 62 | enum gyro_odr | 
| jmar7 | 0:e8167f37725c | 63 | { | 
| jmar7 | 0:e8167f37725c | 64 | //! TODO | 
| jmar7 | 0:e8167f37725c | 65 | G_ODR_PD, // Power down (0) | 
| jmar7 | 0:e8167f37725c | 66 | G_ODR_149, // 14.9 Hz (1) | 
| jmar7 | 0:e8167f37725c | 67 | G_ODR_595, // 59.5 Hz (2) | 
| jmar7 | 0:e8167f37725c | 68 | G_ODR_119, // 119 Hz (3) | 
| jmar7 | 0:e8167f37725c | 69 | G_ODR_238, // 238 Hz (4) | 
| jmar7 | 0:e8167f37725c | 70 | G_ODR_476, // 476 Hz (5) | 
| jmar7 | 0:e8167f37725c | 71 | G_ODR_952 // 952 Hz (6) | 
| jmar7 | 0:e8167f37725c | 72 | }; | 
| jmar7 | 0:e8167f37725c | 73 | // accel_oder defines all possible output data rates of the accelerometer: | 
| jmar7 | 0:e8167f37725c | 74 | enum accel_odr | 
| jmar7 | 0:e8167f37725c | 75 | { | 
| jmar7 | 0:e8167f37725c | 76 | XL_POWER_DOWN, // Power-down mode (0x0) | 
| jmar7 | 0:e8167f37725c | 77 | XL_ODR_10, // 10 Hz (0x1) | 
| jmar7 | 0:e8167f37725c | 78 | XL_ODR_50, // 50 Hz (0x02) | 
| jmar7 | 0:e8167f37725c | 79 | XL_ODR_119, // 119 Hz (0x3) | 
| jmar7 | 0:e8167f37725c | 80 | XL_ODR_238, // 238 Hz (0x4) | 
| jmar7 | 0:e8167f37725c | 81 | XL_ODR_476, // 476 Hz (0x5) | 
| jmar7 | 0:e8167f37725c | 82 | XL_ODR_952 // 952 Hz (0x6) | 
| jmar7 | 0:e8167f37725c | 83 | }; | 
| jmar7 | 0:e8167f37725c | 84 | |
| jmar7 | 0:e8167f37725c | 85 | // accel_abw defines all possible anti-aliasing filter rates of the accelerometer: | 
| jmar7 | 0:e8167f37725c | 86 | enum accel_abw | 
| jmar7 | 0:e8167f37725c | 87 | { | 
| jmar7 | 0:e8167f37725c | 88 | A_ABW_408, // 408 Hz (0x0) | 
| jmar7 | 0:e8167f37725c | 89 | A_ABW_211, // 211 Hz (0x1) | 
| jmar7 | 0:e8167f37725c | 90 | A_ABW_105, // 105 Hz (0x2) | 
| jmar7 | 0:e8167f37725c | 91 | A_ABW_50, // 50 Hz (0x3) | 
| jmar7 | 0:e8167f37725c | 92 | }; | 
| jmar7 | 0:e8167f37725c | 93 | |
| jmar7 | 0:e8167f37725c | 94 | |
| jmar7 | 0:e8167f37725c | 95 | // mag_odr defines all possible output data rates of the magnetometer: | 
| jmar7 | 0:e8167f37725c | 96 | enum mag_odr | 
| jmar7 | 0:e8167f37725c | 97 | { | 
| jmar7 | 0:e8167f37725c | 98 | M_ODR_0625, // 0.625 Hz (0) | 
| jmar7 | 0:e8167f37725c | 99 | M_ODR_125, // 1.25 Hz (1) | 
| jmar7 | 0:e8167f37725c | 100 | M_ODR_250, // 2.5 Hz (2) | 
| jmar7 | 0:e8167f37725c | 101 | M_ODR_5, // 5 Hz (3) | 
| jmar7 | 0:e8167f37725c | 102 | M_ODR_10, // 10 Hz (4) | 
| jmar7 | 0:e8167f37725c | 103 | M_ODR_20, // 20 Hz (5) | 
| jmar7 | 0:e8167f37725c | 104 | M_ODR_40, // 40 Hz (6) | 
| jmar7 | 0:e8167f37725c | 105 | M_ODR_80 // 80 Hz (7) | 
| jmar7 | 0:e8167f37725c | 106 | }; | 
| jmar7 | 0:e8167f37725c | 107 | |
| jmar7 | 0:e8167f37725c | 108 | enum interrupt_select | 
| jmar7 | 0:e8167f37725c | 109 | { | 
| jmar7 | 0:e8167f37725c | 110 | XG_INT1 = INT1_CTRL, | 
| jmar7 | 0:e8167f37725c | 111 | XG_INT2 = INT2_CTRL | 
| jmar7 | 0:e8167f37725c | 112 | }; | 
| jmar7 | 0:e8167f37725c | 113 | |
| jmar7 | 0:e8167f37725c | 114 | enum interrupt_generators | 
| jmar7 | 0:e8167f37725c | 115 | { | 
| jmar7 | 0:e8167f37725c | 116 | INT_DRDY_XL = (1<<0), // Accelerometer data ready (INT1 & INT2) | 
| jmar7 | 0:e8167f37725c | 117 | INT_DRDY_G = (1<<1), // Gyroscope data ready (INT1 & INT2) | 
| jmar7 | 0:e8167f37725c | 118 | INT1_BOOT = (1<<2), // Boot status (INT1) | 
| jmar7 | 0:e8167f37725c | 119 | INT2_DRDY_TEMP = (1<<2),// Temp data ready (INT2) | 
| jmar7 | 0:e8167f37725c | 120 | INT_FTH = (1<<3), // FIFO threshold interrupt (INT1 & INT2) | 
| jmar7 | 0:e8167f37725c | 121 | INT_OVR = (1<<4), // Overrun interrupt (INT1 & INT2) | 
| jmar7 | 0:e8167f37725c | 122 | INT_FSS5 = (1<<5), // FSS5 interrupt (INT1 & INT2) | 
| jmar7 | 0:e8167f37725c | 123 | INT_IG_XL = (1<<6), // Accel interrupt generator (INT1) | 
| jmar7 | 0:e8167f37725c | 124 | INT1_IG_G = (1<<7), // Gyro interrupt enable (INT1) | 
| jmar7 | 0:e8167f37725c | 125 | INT2_INACT = (1<<7), // Inactivity interrupt output (INT2) | 
| jmar7 | 0:e8167f37725c | 126 | }; | 
| jmar7 | 0:e8167f37725c | 127 | |
| jmar7 | 0:e8167f37725c | 128 | enum accel_interrupt_generator | 
| jmar7 | 0:e8167f37725c | 129 | { | 
| jmar7 | 0:e8167f37725c | 130 | XLIE_XL = (1<<0), | 
| jmar7 | 0:e8167f37725c | 131 | XHIE_XL = (1<<1), | 
| jmar7 | 0:e8167f37725c | 132 | YLIE_XL = (1<<2), | 
| jmar7 | 0:e8167f37725c | 133 | YHIE_XL = (1<<3), | 
| jmar7 | 0:e8167f37725c | 134 | ZLIE_XL = (1<<4), | 
| jmar7 | 0:e8167f37725c | 135 | ZHIE_XL = (1<<5), | 
| jmar7 | 0:e8167f37725c | 136 | GEN_6D = (1<<6) | 
| jmar7 | 0:e8167f37725c | 137 | }; | 
| jmar7 | 0:e8167f37725c | 138 | |
| jmar7 | 0:e8167f37725c | 139 | enum gyro_interrupt_generator | 
| jmar7 | 0:e8167f37725c | 140 | { | 
| jmar7 | 0:e8167f37725c | 141 | XLIE_G = (1<<0), | 
| jmar7 | 0:e8167f37725c | 142 | XHIE_G = (1<<1), | 
| jmar7 | 0:e8167f37725c | 143 | YLIE_G = (1<<2), | 
| jmar7 | 0:e8167f37725c | 144 | YHIE_G = (1<<3), | 
| jmar7 | 0:e8167f37725c | 145 | ZLIE_G = (1<<4), | 
| jmar7 | 0:e8167f37725c | 146 | ZHIE_G = (1<<5) | 
| jmar7 | 0:e8167f37725c | 147 | }; | 
| jmar7 | 0:e8167f37725c | 148 | |
| jmar7 | 0:e8167f37725c | 149 | enum mag_interrupt_generator | 
| jmar7 | 0:e8167f37725c | 150 | { | 
| jmar7 | 0:e8167f37725c | 151 | ZIEN = (1<<5), | 
| jmar7 | 0:e8167f37725c | 152 | YIEN = (1<<6), | 
| jmar7 | 0:e8167f37725c | 153 | XIEN = (1<<7) | 
| jmar7 | 0:e8167f37725c | 154 | }; | 
| jmar7 | 0:e8167f37725c | 155 | |
| jmar7 | 0:e8167f37725c | 156 | enum h_lactive | 
| jmar7 | 0:e8167f37725c | 157 | { | 
| jmar7 | 0:e8167f37725c | 158 | INT_ACTIVE_HIGH, | 
| jmar7 | 0:e8167f37725c | 159 | INT_ACTIVE_LOW | 
| jmar7 | 0:e8167f37725c | 160 | }; | 
| jmar7 | 0:e8167f37725c | 161 | |
| jmar7 | 0:e8167f37725c | 162 | enum pp_od | 
| jmar7 | 0:e8167f37725c | 163 | { | 
| jmar7 | 0:e8167f37725c | 164 | INT_PUSH_PULL, | 
| jmar7 | 0:e8167f37725c | 165 | INT_OPEN_DRAIN | 
| jmar7 | 0:e8167f37725c | 166 | }; | 
| jmar7 | 0:e8167f37725c | 167 | |
| jmar7 | 0:e8167f37725c | 168 | enum fifoMode_type | 
| jmar7 | 0:e8167f37725c | 169 | { | 
| jmar7 | 0:e8167f37725c | 170 | FIFO_OFF = 0, | 
| jmar7 | 0:e8167f37725c | 171 | FIFO_THS = 1, | 
| jmar7 | 0:e8167f37725c | 172 | FIFO_CONT_TRIGGER = 3, | 
| jmar7 | 0:e8167f37725c | 173 | FIFO_OFF_TRIGGER = 4, | 
| jmar7 | 0:e8167f37725c | 174 | FIFO_CONT = 5 | 
| jmar7 | 0:e8167f37725c | 175 | }; | 
| jmar7 | 0:e8167f37725c | 176 | |
| jmar7 | 0:e8167f37725c | 177 | struct gyroSettings | 
| jmar7 | 0:e8167f37725c | 178 | { | 
| jmar7 | 0:e8167f37725c | 179 | // Gyroscope settings: | 
| jmar7 | 0:e8167f37725c | 180 | uint8_t enabled; | 
| jmar7 | 0:e8167f37725c | 181 | uint16_t scale; // Changed this to 16-bit | 
| jmar7 | 0:e8167f37725c | 182 | uint8_t sampleRate; | 
| jmar7 | 0:e8167f37725c | 183 | // New gyro stuff: | 
| jmar7 | 0:e8167f37725c | 184 | uint8_t bandwidth; | 
| jmar7 | 0:e8167f37725c | 185 | uint8_t lowPowerEnable; | 
| jmar7 | 0:e8167f37725c | 186 | uint8_t HPFEnable; | 
| jmar7 | 0:e8167f37725c | 187 | uint8_t HPFCutoff; | 
| jmar7 | 0:e8167f37725c | 188 | uint8_t flipX; | 
| jmar7 | 0:e8167f37725c | 189 | uint8_t flipY; | 
| jmar7 | 0:e8167f37725c | 190 | uint8_t flipZ; | 
| jmar7 | 0:e8167f37725c | 191 | uint8_t orientation; | 
| jmar7 | 0:e8167f37725c | 192 | uint8_t enableX; | 
| jmar7 | 0:e8167f37725c | 193 | uint8_t enableY; | 
| jmar7 | 0:e8167f37725c | 194 | uint8_t enableZ; | 
| jmar7 | 0:e8167f37725c | 195 | uint8_t latchInterrupt; | 
| jmar7 | 0:e8167f37725c | 196 | }; | 
| jmar7 | 0:e8167f37725c | 197 | |
| jmar7 | 0:e8167f37725c | 198 | struct deviceSettings | 
| jmar7 | 0:e8167f37725c | 199 | { | 
| jmar7 | 0:e8167f37725c | 200 | uint8_t commInterface; // Can be I2C, SPI 4-wire or SPI 3-wire | 
| jmar7 | 0:e8167f37725c | 201 | uint8_t agAddress; // I2C address or SPI CS pin | 
| jmar7 | 0:e8167f37725c | 202 | uint8_t mAddress; // I2C address or SPI CS pin | 
| jmar7 | 0:e8167f37725c | 203 | }; | 
| jmar7 | 0:e8167f37725c | 204 | |
| jmar7 | 0:e8167f37725c | 205 | struct accelSettings | 
| jmar7 | 0:e8167f37725c | 206 | { | 
| jmar7 | 0:e8167f37725c | 207 | // Accelerometer settings: | 
| jmar7 | 0:e8167f37725c | 208 | uint8_t enabled; | 
| jmar7 | 0:e8167f37725c | 209 | uint8_t scale; | 
| jmar7 | 0:e8167f37725c | 210 | uint8_t sampleRate; | 
| jmar7 | 0:e8167f37725c | 211 | // New accel stuff: | 
| jmar7 | 0:e8167f37725c | 212 | uint8_t enableX; | 
| jmar7 | 0:e8167f37725c | 213 | uint8_t enableY; | 
| jmar7 | 0:e8167f37725c | 214 | uint8_t enableZ; | 
| jmar7 | 0:e8167f37725c | 215 | int8_t bandwidth; | 
| jmar7 | 0:e8167f37725c | 216 | uint8_t highResEnable; | 
| jmar7 | 0:e8167f37725c | 217 | uint8_t highResBandwidth; | 
| jmar7 | 0:e8167f37725c | 218 | }; | 
| jmar7 | 0:e8167f37725c | 219 | |
| jmar7 | 0:e8167f37725c | 220 | struct magSettings | 
| jmar7 | 0:e8167f37725c | 221 | { | 
| jmar7 | 0:e8167f37725c | 222 | // Magnetometer settings: | 
| jmar7 | 0:e8167f37725c | 223 | uint8_t enabled; | 
| jmar7 | 0:e8167f37725c | 224 | uint8_t scale; | 
| jmar7 | 0:e8167f37725c | 225 | uint8_t sampleRate; | 
| jmar7 | 0:e8167f37725c | 226 | // New mag stuff: | 
| jmar7 | 0:e8167f37725c | 227 | uint8_t tempCompensationEnable; | 
| jmar7 | 0:e8167f37725c | 228 | uint8_t XYPerformance; | 
| jmar7 | 0:e8167f37725c | 229 | uint8_t ZPerformance; | 
| jmar7 | 0:e8167f37725c | 230 | uint8_t lowPowerEnable; | 
| jmar7 | 0:e8167f37725c | 231 | uint8_t operatingMode; | 
| jmar7 | 0:e8167f37725c | 232 | }; | 
| jmar7 | 0:e8167f37725c | 233 | |
| jmar7 | 0:e8167f37725c | 234 | struct temperatureSettings | 
| jmar7 | 0:e8167f37725c | 235 | { | 
| jmar7 | 0:e8167f37725c | 236 | // Temperature settings | 
| jmar7 | 0:e8167f37725c | 237 | uint8_t enabled; | 
| jmar7 | 0:e8167f37725c | 238 | }; | 
| jmar7 | 0:e8167f37725c | 239 | |
| jmar7 | 0:e8167f37725c | 240 | struct IMUSettings | 
| jmar7 | 0:e8167f37725c | 241 | { | 
| jmar7 | 0:e8167f37725c | 242 | deviceSettings device; | 
| jmar7 | 0:e8167f37725c | 243 | |
| jmar7 | 0:e8167f37725c | 244 | gyroSettings gyro; | 
| jmar7 | 0:e8167f37725c | 245 | accelSettings accel; | 
| jmar7 | 0:e8167f37725c | 246 | magSettings mag; | 
| jmar7 | 0:e8167f37725c | 247 | |
| jmar7 | 0:e8167f37725c | 248 | temperatureSettings temp; | 
| jmar7 | 0:e8167f37725c | 249 | }; | 
| jmar7 | 0:e8167f37725c | 250 | |
| jmar7 | 0:e8167f37725c | 251 | #endif |