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