rome2_p6 imported
Dependencies: mbed
IMU.h@5:957580f33e52, 2018-05-18 (annotated)
- Committer:
- Appalco
- Date:
- Fri May 18 13:54:25 2018 +0000
- Revision:
- 5:957580f33e52
- Parent:
- 0:351a2fb21235
fixed tolerance and wayponts
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Appalco | 0:351a2fb21235 | 1 | /* |
Appalco | 0:351a2fb21235 | 2 | * IMU.h |
Appalco | 0:351a2fb21235 | 3 | * Copyright (c) 2018, ZHAW |
Appalco | 0:351a2fb21235 | 4 | * All rights reserved. |
Appalco | 0:351a2fb21235 | 5 | */ |
Appalco | 0:351a2fb21235 | 6 | |
Appalco | 0:351a2fb21235 | 7 | #ifndef IMU_H_ |
Appalco | 0:351a2fb21235 | 8 | #define IMU_H_ |
Appalco | 0:351a2fb21235 | 9 | |
Appalco | 0:351a2fb21235 | 10 | #include <cstdlib> |
Appalco | 0:351a2fb21235 | 11 | #include <mbed.h> |
Appalco | 0:351a2fb21235 | 12 | #include "LowpassFilter.h" |
Appalco | 0:351a2fb21235 | 13 | |
Appalco | 0:351a2fb21235 | 14 | /** |
Appalco | 0:351a2fb21235 | 15 | * This is a device driver class for the ST LSM9DS0 inertial measurement unit. |
Appalco | 0:351a2fb21235 | 16 | */ |
Appalco | 0:351a2fb21235 | 17 | class IMU { |
Appalco | 0:351a2fb21235 | 18 | |
Appalco | 0:351a2fb21235 | 19 | public: |
Appalco | 0:351a2fb21235 | 20 | |
Appalco | 0:351a2fb21235 | 21 | IMU(SPI& spi, DigitalOut& csG, DigitalOut& csXM); |
Appalco | 0:351a2fb21235 | 22 | virtual ~IMU(); |
Appalco | 0:351a2fb21235 | 23 | float readGyroX(); |
Appalco | 0:351a2fb21235 | 24 | float readGyroY(); |
Appalco | 0:351a2fb21235 | 25 | float readGyroZ(); |
Appalco | 0:351a2fb21235 | 26 | float readAccelerationX(); |
Appalco | 0:351a2fb21235 | 27 | float readAccelerationY(); |
Appalco | 0:351a2fb21235 | 28 | float readAccelerationZ(); |
Appalco | 0:351a2fb21235 | 29 | float readMagnetometerX(); |
Appalco | 0:351a2fb21235 | 30 | float readMagnetometerY(); |
Appalco | 0:351a2fb21235 | 31 | float readMagnetometerZ(); |
Appalco | 0:351a2fb21235 | 32 | float readHeading(); |
Appalco | 0:351a2fb21235 | 33 | |
Appalco | 0:351a2fb21235 | 34 | private: |
Appalco | 0:351a2fb21235 | 35 | |
Appalco | 0:351a2fb21235 | 36 | static const char WHO_AM_I_G = 0x0F; |
Appalco | 0:351a2fb21235 | 37 | static const char CTRL_REG1_G = 0x20; |
Appalco | 0:351a2fb21235 | 38 | static const char OUT_X_L_G = 0x28; |
Appalco | 0:351a2fb21235 | 39 | static const char OUT_X_H_G = 0x29; |
Appalco | 0:351a2fb21235 | 40 | static const char OUT_Y_L_G = 0x2A; |
Appalco | 0:351a2fb21235 | 41 | static const char OUT_Y_H_G = 0x2B; |
Appalco | 0:351a2fb21235 | 42 | static const char OUT_Z_L_G = 0x2C; |
Appalco | 0:351a2fb21235 | 43 | static const char OUT_Z_H_G = 0x2D; |
Appalco | 0:351a2fb21235 | 44 | |
Appalco | 0:351a2fb21235 | 45 | static const char OUT_X_L_M = 0x08; |
Appalco | 0:351a2fb21235 | 46 | static const char OUT_X_H_M = 0x09; |
Appalco | 0:351a2fb21235 | 47 | static const char OUT_Y_L_M = 0x0A; |
Appalco | 0:351a2fb21235 | 48 | static const char OUT_Y_H_M = 0x0B; |
Appalco | 0:351a2fb21235 | 49 | static const char OUT_Z_L_M = 0x0C; |
Appalco | 0:351a2fb21235 | 50 | static const char OUT_Z_H_M = 0x0D; |
Appalco | 0:351a2fb21235 | 51 | static const char WHO_AM_I_XM = 0x0F; |
Appalco | 0:351a2fb21235 | 52 | |
Appalco | 0:351a2fb21235 | 53 | static const char INT_CTRL_REG_M = 0x12; |
Appalco | 0:351a2fb21235 | 54 | static const char CTRL_REG0_XM = 0x1F; |
Appalco | 0:351a2fb21235 | 55 | static const char CTRL_REG1_XM = 0x20; |
Appalco | 0:351a2fb21235 | 56 | static const char CTRL_REG2_XM = 0x21; |
Appalco | 0:351a2fb21235 | 57 | static const char CTRL_REG3_XM = 0x22; |
Appalco | 0:351a2fb21235 | 58 | static const char CTRL_REG4_XM = 0x23; |
Appalco | 0:351a2fb21235 | 59 | static const char CTRL_REG5_XM = 0x24; |
Appalco | 0:351a2fb21235 | 60 | static const char CTRL_REG6_XM = 0x25; |
Appalco | 0:351a2fb21235 | 61 | static const char CTRL_REG7_XM = 0x26; |
Appalco | 0:351a2fb21235 | 62 | |
Appalco | 0:351a2fb21235 | 63 | static const char OUT_X_L_A = 0x28; |
Appalco | 0:351a2fb21235 | 64 | static const char OUT_X_H_A = 0x29; |
Appalco | 0:351a2fb21235 | 65 | static const char OUT_Y_L_A = 0x2A; |
Appalco | 0:351a2fb21235 | 66 | static const char OUT_Y_H_A = 0x2B; |
Appalco | 0:351a2fb21235 | 67 | static const char OUT_Z_L_A = 0x2C; |
Appalco | 0:351a2fb21235 | 68 | static const char OUT_Z_H_A = 0x2D; |
Appalco | 0:351a2fb21235 | 69 | |
Appalco | 0:351a2fb21235 | 70 | static const float PERIOD; |
Appalco | 0:351a2fb21235 | 71 | static const float PI; |
Appalco | 0:351a2fb21235 | 72 | static const float LOWPASS_FILTER_FREQUENCY; |
Appalco | 0:351a2fb21235 | 73 | |
Appalco | 0:351a2fb21235 | 74 | SPI& spi; |
Appalco | 0:351a2fb21235 | 75 | DigitalOut& csG; |
Appalco | 0:351a2fb21235 | 76 | DigitalOut& csXM; |
Appalco | 0:351a2fb21235 | 77 | |
Appalco | 0:351a2fb21235 | 78 | float magnetometerXMin; |
Appalco | 0:351a2fb21235 | 79 | float magnetometerXMax; |
Appalco | 0:351a2fb21235 | 80 | float magnetometerYMin; |
Appalco | 0:351a2fb21235 | 81 | float magnetometerYMax; |
Appalco | 0:351a2fb21235 | 82 | LowpassFilter magnetometerXFilter; |
Appalco | 0:351a2fb21235 | 83 | LowpassFilter magnetometerYFilter; |
Appalco | 0:351a2fb21235 | 84 | float heading; |
Appalco | 0:351a2fb21235 | 85 | Ticker ticker; |
Appalco | 0:351a2fb21235 | 86 | |
Appalco | 0:351a2fb21235 | 87 | void writeRegister(DigitalOut& cs, char address, char value); |
Appalco | 0:351a2fb21235 | 88 | char readRegister(DigitalOut& cs, char address); |
Appalco | 0:351a2fb21235 | 89 | void run(); |
Appalco | 0:351a2fb21235 | 90 | }; |
Appalco | 0:351a2fb21235 | 91 | |
Appalco | 0:351a2fb21235 | 92 | #endif /* IMU_H_ */ |
Appalco | 0:351a2fb21235 | 93 |