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