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.
IMU.h
00001 /* 00002 * IMU.h 00003 * Copyright (c) 2018, ZHAW 00004 * All rights reserved. 00005 */ 00006 00007 /* 00008 * Public variable for gain and offset of acc and gyro 00009 * 00010 * for the teststand with 2 IMUs 00011 */ 00012 00013 #ifndef IMU_H_ 00014 #define IMU_H_ 00015 00016 #include <cstdlib> 00017 #include <stdint.h> 00018 #include "mbed.h" 00019 00020 00021 /** 00022 * This is a device driver class for the ST LSM9DS1 inertial measurement unit. 00023 */ 00024 class IMU { 00025 00026 public: 00027 00028 IMU(SPI& spi, DigitalOut& csAG, DigitalOut& csM); 00029 virtual ~IMU(); 00030 float readGyroX(); 00031 float readGyroY(); 00032 float readGyroZ(); 00033 float readAccelerationX(); 00034 float readAccelerationY(); 00035 float readAccelerationZ(); 00036 float readMagnetometerX(); 00037 float readMagnetometerY(); 00038 float readMagnetometerZ(); 00039 00040 float gainAx; 00041 float gainAy; 00042 float gainAz; 00043 float gainGx; 00044 float gainGy; 00045 float gainGz; 00046 00047 float offsAx; 00048 float offsAy; 00049 float offsAz; 00050 float offsGx; 00051 float offsGy; 00052 float offsGz; 00053 00054 private: 00055 00056 static const uint8_t WHO_AM_I = 0x0F; 00057 static const uint8_t CTRL_REG1_G = 0x10; 00058 static const uint8_t CTRL_REG2_G = 0x11; 00059 static const uint8_t CTRL_REG3_G = 0x12; 00060 static const uint8_t OUT_X_L_G = 0x18; 00061 static const uint8_t OUT_X_H_G = 0x19; 00062 static const uint8_t OUT_Y_L_G = 0x1A; 00063 static const uint8_t OUT_Y_H_G = 0x1B; 00064 static const uint8_t OUT_Z_L_G = 0x1C; 00065 static const uint8_t OUT_Z_H_G = 0x1D; 00066 static const uint8_t CTRL_REG4 = 0x1E; 00067 static const uint8_t CTRL_REG5_XL = 0x1F; 00068 static const uint8_t CTRL_REG6_XL = 0x20; 00069 static const uint8_t CTRL_REG7_XL = 0x21; 00070 static const uint8_t CTRL_REG8 = 0x22; 00071 static const uint8_t CTRL_REG9 = 0x23; 00072 static const uint8_t CTRL_REG10 = 0x24; 00073 static const uint8_t OUT_X_L_XL = 0x28; 00074 static const uint8_t OUT_X_H_XL = 0x29; 00075 static const uint8_t OUT_Y_L_XL = 0x2A; 00076 static const uint8_t OUT_Y_H_XL = 0x2B; 00077 static const uint8_t OUT_Z_L_XL = 0x2C; 00078 static const uint8_t OUT_Z_H_XL = 0x2D; 00079 00080 static const uint8_t WHO_AM_I_M = 0x0F; 00081 static const uint8_t CTRL_REG1_M = 0x20; 00082 static const uint8_t CTRL_REG2_M = 0x21; 00083 static const uint8_t CTRL_REG3_M = 0x22; 00084 static const uint8_t CTRL_REG4_M = 0x23; 00085 static const uint8_t CTRL_REG5_M = 0x24; 00086 static const uint8_t OUT_X_L_M = 0x28; 00087 static const uint8_t OUT_X_H_M = 0x29; 00088 static const uint8_t OUT_Y_L_M = 0x2A; 00089 static const uint8_t OUT_Y_H_M = 0x2B; 00090 static const uint8_t OUT_Z_L_M = 0x2C; 00091 static const uint8_t OUT_Z_H_M = 0x2D; 00092 00093 static const float M_PI; 00094 static const float SAMPLE_TIME; 00095 static const float STD_ALPHA; 00096 static const float STD_OMEGA; 00097 static const uint32_t STACK_SIZE = 4096; // stack size of thread, given in [bytes] 00098 00099 SPI& spi; 00100 DigitalOut& csAG; 00101 DigitalOut& csM; 00102 00103 void writeRegister(DigitalOut& cs, uint8_t address, uint8_t value); 00104 uint8_t readRegister(DigitalOut& cs, uint8_t address); 00105 }; 00106 00107 #endif /* IMU_H_ */ 00108 00109 00110 00111 00112 00113
Generated on Tue Jul 26 2022 07:27:35 by
