ROME_P5
Dependencies: mbed
IMU.h@0:29be10cb0afc, 2018-04-27 (annotated)
- Committer:
- Inaueadr
- Date:
- Fri Apr 27 08:47:34 2018 +0000
- Revision:
- 0:29be10cb0afc
Hallo
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Inaueadr | 0:29be10cb0afc | 1 | /* |
Inaueadr | 0:29be10cb0afc | 2 | * IMU.h |
Inaueadr | 0:29be10cb0afc | 3 | * Copyright (c) 2018, ZHAW |
Inaueadr | 0:29be10cb0afc | 4 | * All rights reserved. |
Inaueadr | 0:29be10cb0afc | 5 | */ |
Inaueadr | 0:29be10cb0afc | 6 | |
Inaueadr | 0:29be10cb0afc | 7 | #ifndef IMU_H_ |
Inaueadr | 0:29be10cb0afc | 8 | #define IMU_H_ |
Inaueadr | 0:29be10cb0afc | 9 | |
Inaueadr | 0:29be10cb0afc | 10 | #include <cstdlib> |
Inaueadr | 0:29be10cb0afc | 11 | #include <mbed.h> |
Inaueadr | 0:29be10cb0afc | 12 | |
Inaueadr | 0:29be10cb0afc | 13 | /** |
Inaueadr | 0:29be10cb0afc | 14 | * This is a device driver class for the ST LSM9DS0 inertial measurement unit. |
Inaueadr | 0:29be10cb0afc | 15 | */ |
Inaueadr | 0:29be10cb0afc | 16 | class IMU { |
Inaueadr | 0:29be10cb0afc | 17 | |
Inaueadr | 0:29be10cb0afc | 18 | public: |
Inaueadr | 0:29be10cb0afc | 19 | |
Inaueadr | 0:29be10cb0afc | 20 | IMU(SPI& spi, DigitalOut& csG, DigitalOut& csXM); |
Inaueadr | 0:29be10cb0afc | 21 | virtual ~IMU(); |
Inaueadr | 0:29be10cb0afc | 22 | float readGyroX(); |
Inaueadr | 0:29be10cb0afc | 23 | float readGyroY(); |
Inaueadr | 0:29be10cb0afc | 24 | float readGyroZ(); |
Inaueadr | 0:29be10cb0afc | 25 | float readAccelerationX(); |
Inaueadr | 0:29be10cb0afc | 26 | float readAccelerationY(); |
Inaueadr | 0:29be10cb0afc | 27 | float readAccelerationZ(); |
Inaueadr | 0:29be10cb0afc | 28 | float readMagnetometerX(); |
Inaueadr | 0:29be10cb0afc | 29 | float readMagnetometerY(); |
Inaueadr | 0:29be10cb0afc | 30 | float readMagnetometerZ(); |
Inaueadr | 0:29be10cb0afc | 31 | float readHeading(); |
Inaueadr | 0:29be10cb0afc | 32 | |
Inaueadr | 0:29be10cb0afc | 33 | private: |
Inaueadr | 0:29be10cb0afc | 34 | |
Inaueadr | 0:29be10cb0afc | 35 | static const char WHO_AM_I_G = 0x0F; |
Inaueadr | 0:29be10cb0afc | 36 | static const char CTRL_REG1_G = 0x20; |
Inaueadr | 0:29be10cb0afc | 37 | static const char OUT_X_L_G = 0x28; |
Inaueadr | 0:29be10cb0afc | 38 | static const char OUT_X_H_G = 0x29; |
Inaueadr | 0:29be10cb0afc | 39 | static const char OUT_Y_L_G = 0x2A; |
Inaueadr | 0:29be10cb0afc | 40 | static const char OUT_Y_H_G = 0x2B; |
Inaueadr | 0:29be10cb0afc | 41 | static const char OUT_Z_L_G = 0x2C; |
Inaueadr | 0:29be10cb0afc | 42 | static const char OUT_Z_H_G = 0x2D; |
Inaueadr | 0:29be10cb0afc | 43 | |
Inaueadr | 0:29be10cb0afc | 44 | static const char WHO_AM_I_XM = 0x0F; |
Inaueadr | 0:29be10cb0afc | 45 | |
Inaueadr | 0:29be10cb0afc | 46 | static const char INT_CTRL_REG_M = 0x12; |
Inaueadr | 0:29be10cb0afc | 47 | static const char CTRL_REG0_XM = 0x1F; |
Inaueadr | 0:29be10cb0afc | 48 | static const char CTRL_REG1_XM = 0x20; |
Inaueadr | 0:29be10cb0afc | 49 | static const char CTRL_REG2_XM = 0x21; |
Inaueadr | 0:29be10cb0afc | 50 | static const char CTRL_REG3_XM = 0x22; |
Inaueadr | 0:29be10cb0afc | 51 | static const char CTRL_REG4_XM = 0x23; |
Inaueadr | 0:29be10cb0afc | 52 | static const char CTRL_REG5_XM = 0x24; |
Inaueadr | 0:29be10cb0afc | 53 | static const char CTRL_REG6_XM = 0x25; |
Inaueadr | 0:29be10cb0afc | 54 | static const char CTRL_REG7_XM = 0x26; |
Inaueadr | 0:29be10cb0afc | 55 | |
Inaueadr | 0:29be10cb0afc | 56 | static const char OUT_X_L_A = 0x28; |
Inaueadr | 0:29be10cb0afc | 57 | static const char OUT_X_H_A = 0x29; |
Inaueadr | 0:29be10cb0afc | 58 | static const char OUT_Y_L_A = 0x2A; |
Inaueadr | 0:29be10cb0afc | 59 | static const char OUT_Y_H_A = 0x2B; |
Inaueadr | 0:29be10cb0afc | 60 | static const char OUT_Z_L_A = 0x2C; |
Inaueadr | 0:29be10cb0afc | 61 | static const char OUT_Z_H_A = 0x2D; |
Inaueadr | 0:29be10cb0afc | 62 | |
Inaueadr | 0:29be10cb0afc | 63 | static const float PI; |
Inaueadr | 0:29be10cb0afc | 64 | |
Inaueadr | 0:29be10cb0afc | 65 | SPI& spi; |
Inaueadr | 0:29be10cb0afc | 66 | DigitalOut& csG; |
Inaueadr | 0:29be10cb0afc | 67 | DigitalOut& csXM; |
Inaueadr | 0:29be10cb0afc | 68 | |
Inaueadr | 0:29be10cb0afc | 69 | void writeRegister(DigitalOut& cs, char address, char value); |
Inaueadr | 0:29be10cb0afc | 70 | char readRegister(DigitalOut& cs, char address); |
Inaueadr | 0:29be10cb0afc | 71 | }; |
Inaueadr | 0:29be10cb0afc | 72 | |
Inaueadr | 0:29be10cb0afc | 73 | #endif /* IMU_H_ */ |
Inaueadr | 0:29be10cb0afc | 74 |