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
00001 /* 00002 * IMU.h 00003 * Copyright (c) 2018, ZHAW 00004 * All rights reserved. 00005 */ 00006 00007 #ifndef IMU_H_ 00008 #define IMU_H_ 00009 00010 #include <cstdlib> 00011 #include <mbed.h> 00012 00013 /** 00014 * This is a device driver class for the ST LSM9DS0 inertial measurement unit. 00015 */ 00016 class IMU { 00017 00018 public: 00019 00020 IMU(SPI& spi, DigitalOut& csG, DigitalOut& csXM); 00021 virtual ~IMU(); 00022 float readGyroX(); 00023 float readGyroY(); 00024 float readGyroZ(); 00025 float readAccelerationX(); 00026 float readAccelerationY(); 00027 float readAccelerationZ(); 00028 float readMagnetometerX(); 00029 float readMagnetometerY(); 00030 float readMagnetometerZ(); 00031 float readHeading(); 00032 00033 private: 00034 00035 static const char WHO_AM_I_G = 0x0F; 00036 static const char CTRL_REG1_G = 0x20; 00037 static const char OUT_X_L_G = 0x28; 00038 static const char OUT_X_H_G = 0x29; 00039 static const char OUT_Y_L_G = 0x2A; 00040 static const char OUT_Y_H_G = 0x2B; 00041 static const char OUT_Z_L_G = 0x2C; 00042 static const char OUT_Z_H_G = 0x2D; 00043 00044 static const char WHO_AM_I_XM = 0x0F; 00045 00046 static const char INT_CTRL_REG_M = 0x12; 00047 static const char CTRL_REG0_XM = 0x1F; 00048 static const char CTRL_REG1_XM = 0x20; 00049 static const char CTRL_REG2_XM = 0x21; 00050 static const char CTRL_REG3_XM = 0x22; 00051 static const char CTRL_REG4_XM = 0x23; 00052 static const char CTRL_REG5_XM = 0x24; 00053 static const char CTRL_REG6_XM = 0x25; 00054 static const char CTRL_REG7_XM = 0x26; 00055 00056 static const char OUT_X_L_A = 0x28; 00057 static const char OUT_X_H_A = 0x29; 00058 static const char OUT_Y_L_A = 0x2A; 00059 static const char OUT_Y_H_A = 0x2B; 00060 static const char OUT_Z_L_A = 0x2C; 00061 static const char OUT_Z_H_A = 0x2D; 00062 00063 static const float PI; 00064 00065 SPI& spi; 00066 DigitalOut& csG; 00067 DigitalOut& csXM; 00068 00069 void writeRegister(DigitalOut& cs, char address, char value); 00070 char readRegister(DigitalOut& cs, char address); 00071 }; 00072 00073 #endif /* IMU_H_ */ 00074
Generated on Thu Jul 14 2022 22:37:02 by
