A multifunctional and modular Firmware for Multitech's mDot based on ARM mBed provides a widerange of functionality for several Sensors such as MAX44009, BME280, MPU9250, SI1143 and uBlox. It allows you to quickly build a Sensornode that measures specific data with its sensors and sends it via LoRaWAN.

Dependencies:   mDot_LoRa_Sensornode_Flowmeter_impl mbed-rtos mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers MPU9250Config.h Source File

MPU9250Config.h

Go to the documentation of this file.
00001 /**
00002  * @file MPU9250Config.h
00003  *
00004  * @author Adrian
00005  * @date 23.05.2016
00006  *
00007  */
00008 
00009 #include <stdint.h>
00010 
00011 #ifndef APP_MPU9250CONFIG_H_
00012 #define APP_MPU9250CONFIG_H_
00013 
00014 #define MPU9250_GYRO_FULL_SCALE_250DPS  0b00
00015 #define MPU9250_GYRO_FULL_SCALE_500DPS  0b01
00016 #define MPU9250_GYRO_FULL_SCALE_1000DPS 0b10
00017 #define MPU9250_GYRO_FULL_SCALE_2000DPS 0b11
00018 
00019 #define MPU9250_FULL_SCALE_2G           0b00
00020 #define MPU9250_FULL_SCALE_4G           0b01
00021 #define MPU9250_FULL_SCALE_8G           0b10
00022 #define MPU9250_FULL_SCALE_16G          0b11
00023 
00024 #define MPU9250_MAG_16_BIT              0b1
00025 #define MPU9250_MAG_14_BIT              0b0
00026 
00027 #define MPU9250_MAG_SINGLE_MEASUREMENT          0b0001
00028 #define MPU9250_MAG_CONTINUOUS_MEASUREMENT_1    0b0010
00029 #define MPU9250_MAG_CONTINUOUS_MEASUREMENT_2    0b0110
00030 
00031 //INT_PIN_CFG register masks
00032 #define MPU9250_ACTL_MASK               0x80
00033 #define MPU9250_OPEN_MASK               0x40
00034 #define MPU9250_LATCH_INT_EN_MASK       0x20
00035 #define MPU9250_INT_ANYRD_2CLEAR_MASK   0x10
00036 #define MPU9250_ACTL_FSYNC_MASK         0x08
00037 #define MPU9250_FSYNC_INT_MODE_EN_MASK  0x04
00038 #define MPU9250_BYPASS_EN_MASK          0x02
00039 
00040 //INT_ENABLE register masks
00041 #define MPU9250_WOM_EN_MASK             0x40
00042 #define MPU9250_FIFO_OFLOW_EN_MASK      0x10
00043 #define MPU9250_FSYNC_INT_EN_MASK       0x08
00044 #define MPU9250_RAW_RDY_EN_MASK         0x01
00045 
00046 #define MPU9250_WOM_THRESHOLD_1020_MG   0xFF
00047 #define MPU9250_WOM_THRESHOLD_500_MG    0x7D
00048 #define MPU9250_WOM_THRESHOLD_250_MG    0xFA
00049 
00050 /**
00051  * MPU9250 Modes. Modes define Sensor functionality
00052  */
00053 enum MPU9250_MODE{
00054     MPU9250_MODE_1,//!< MPU9250_MODE_1
00055     MPU9250_MODE_2,//!< MPU9250_MODE_2
00056     MPU9250_MODE_3,//!< MPU9250_MODE_3
00057     MPU9250_MODE_4 //!< MPU9250_MODE_4
00058 };
00059 
00060 /**
00061  * @class MPU9250Config
00062  * @brief A configuration container for the MPU9250 Sensor.
00063  * All its configuration values are stored an held inside
00064  * this Class. Depending on the MPU9250_MODE it sets all the configuration values.
00065  */
00066 class MPU9250Config {
00067 public:
00068     MPU9250Config();
00069     virtual ~MPU9250Config();
00070 
00071     /**
00072      * @brief Generates a configuration according to the chosen MPU9250_MODE
00073      * @param desiredMode the mode to build the configuration according to
00074      */
00075     void build(MPU9250_MODE desiredMode);
00076 
00077 
00078     /**
00079      * @brief Gets the Accelerometer Scale from the actual configuration
00080      * @return accelerometer scale
00081      */
00082     uint8_t getAccelerometerScale();
00083 
00084     /**
00085      * @brief Gets the Gyroscope Scale from the actual configuration
00086      * @return gyroscope scale
00087      */
00088     uint8_t getGyroscopeScale();
00089 
00090     /**
00091      * @brief Gets the Magnetometer bit resolution from the actual configuration
00092      * @return magnetometer bit resolution
00093      */
00094     uint8_t getMagnetometerBitResolution();
00095 
00096     /**
00097      * @brief Gets the Magnetometer measure mode  from the actual configuration
00098      * @return magnetometer bit resolution
00099      */
00100     uint8_t getMagnetometerMeasureMode();
00101 
00102     /**
00103      * @brief Gets the Acceleration Divider from the actual configuration
00104      * @return acceleration divider
00105      */
00106     float getAccelerationDivider();
00107 
00108     /**
00109      * @brief Gets the Gyroscope Divider from the actual configuration
00110      * @return gyroscope divider
00111      */
00112     float getGyroDivider();
00113 
00114     /**
00115      * @brief Gets the Tesla Divider from the actual configuration
00116      * @return
00117      */
00118     float getTeslaDivider();
00119 
00120 
00121     /**
00122      * @brief Gets the Interrupt Pin configuration from the actual configuration
00123      * @return interrupt pin configuration
00124      */
00125     uint8_t getInterruptPinConfiguration();
00126 
00127     /**
00128      * @brief Gets the Interrupt Enable configuration from the actual configuration
00129      * @return interrupt enable configuration
00130      */
00131     uint8_t getInterruptEnableConfiguration();
00132 
00133     /**
00134      * @brief Gets the wake on motion threshold value from the actual configuration
00135      * @return wake on motion threshold value
00136      */
00137     uint8_t getWakeOnMotionThreshold();
00138 
00139 private:
00140     uint8_t gyroscopeScale;
00141     uint8_t accelerometerScale;
00142     uint8_t magnetometerBitResolution;
00143     uint8_t magnetometerMeasureMode;
00144 
00145     uint8_t interruptPinConfiguration;
00146     uint8_t interruptEnableConfiguration;
00147 
00148     uint8_t wakeOnMotionThreshold;
00149 
00150 
00151     /**
00152      * @brief Sets the accelerometer scale of the actual configuration
00153      * @param accelerometerScale
00154      */
00155     void setAccelerometerScale(uint8_t accelerometerScale);
00156 
00157     /**
00158      * @brief Sets the gyroscope scale of the actual configuration
00159      * @param gyroscopeScale
00160      */
00161     void setGyroscopeScale(uint8_t gyroscopeScale);
00162 
00163     /**
00164      * @brief Sets the magnetometer bit resolution of the actual configuration
00165      * @param magnetometerBitResolution
00166      */
00167     void setMagnetometerBitResolution(uint8_t magnetometerBitResolution);
00168 
00169     /**
00170      * @brief Sets the magnetometer measure mode of the actual configuration
00171      * @param magnetometerMeasureMode
00172      */
00173     void setMagnetometerMeasureMode(uint8_t meagnetometerMeasureMode);
00174 
00175 
00176     /**
00177      * @brief Sets the interrupt pin configuration of the actual configuration
00178      * @param interruptPinConfiguration
00179      */
00180     void setInterruptPinConfiguration(uint8_t interruptPinConfiguration);
00181 
00182     /**
00183      * @brief Sets the interrupt enable configuration of the actual configuration
00184      * @param interruptEnableConfiguration
00185      */
00186     void setInterruptEnableConfiguration(uint8_t interruptEnableConfiguration);
00187 
00188 
00189     /**
00190      * @brief Sets the wake on motion threshold of the actual configuration
00191      * @param wakeOnMotionThreshold
00192      */
00193     void setWakeOnMotionThreshold(uint8_t wakeOnMotionThreshold);
00194 };
00195 
00196 #endif /* APP_MPU9250CONFIG_H_ */