debug

Dependencies:   mbed mbed-rtos PinDetect X_NUCLEO_53L0A1

Committer:
astovall21
Date:
Wed Apr 28 17:44:45 2021 +0000
Revision:
0:ea1c50666fc2
debug;

Who changed what in which revision?

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