Device driver interface for the MPU-9X50 (MPU9150 and MPU9250)  
More...
Device driver interface for the MPU-9X50 (MPU9150 and MPU9250) 
This driver provides [S]ensor [A]ctuator [U]ber [L]ayer capabilities. 
 | 
| file   | mpu9x50.h | 
|   | Device driver interface for the MPU-9X50 (MPU9150 and MPU9250) 
  | 
|   | 
| file   | mpu9x50_internal.h | 
|   | Internal config for the MPU-9X50 (MPU9150 and MPU9250) 
  | 
|   | 
| file   | mpu9x50_params.h | 
|   | Default configuration for MPU9X50 (MPU9150 and MPU9250) devices. 
  | 
|   | 
| file   | mpu9x50_regs.h | 
|   | Register and bit definitions for the MPU-9X50 (MPU9150 and MPU9250) 9-Axis Motion Sensor. 
  | 
|   | 
 | 
| enum   | mpu9x50_pwr_t { MPU9X50_SENSOR_PWR_OFF = 0x00
, MPU9X50_SENSOR_PWR_ON = 0x01
 } | 
|   | Power enum values. 
  | 
|   | 
| enum   | mpu9x50_hw_addr_t { MPU9X50_HW_ADDR_HEX_68 = 0x68
, MPU9X50_HW_ADDR_HEX_69 = 0x69
 } | 
|   | Possible MPU-9X50 hardware addresses (wiring specific) 
  | 
|   | 
| enum   | mpu9x50_comp_addr_t { MPU9X50_COMP_ADDR_HEX_0C = 0x0C
, MPU9X50_COMP_ADDR_HEX_0D = 0x0D
, MPU9X50_COMP_ADDR_HEX_0E = 0x0E
, MPU9X50_COMP_ADDR_HEX_0F = 0x0F
 } | 
|   | Possible compass addresses (wiring specific) 
  | 
|   | 
| enum   | mpu9x50_gyro_ranges_t { MPU9X50_GYRO_FSR_250DPS = 0x00
, MPU9X50_GYRO_FSR_500DPS = 0x01
, MPU9X50_GYRO_FSR_1000DPS = 0x02
, MPU9X50_GYRO_FSR_2000DPS = 0x03
 } | 
|   | Possible full scale ranges for the gyroscope. 
  | 
|   | 
| enum   | mpu9x50_accel_ranges_t { MPU9X50_ACCEL_FSR_2G = 0x00
, MPU9X50_ACCEL_FSR_4G = 0x01
, MPU9X50_ACCEL_FSR_8G = 0x02
, MPU9X50_ACCEL_FSR_16G = 0x03
 } | 
|   | Possible full scale ranges for the accelerometer. 
  | 
|   | 
| enum   | mpu9x50_lpf_t {  
  MPU9X50_FILTER_188HZ = 0x01
, MPU9X50_FILTER_98HZ = 0x02
, MPU9X50_FILTER_42HZ = 0x03
, MPU9X50_FILTER_20HZ = 0x04
,  
  MPU9X50_FILTER_10HZ = 0x05
, MPU9X50_FILTER_5HZ = 0x06
 
 } | 
|   | Possible low pass filter values. 
  | 
|   | 
 | 
| int  | mpu9x50_init (mpu9x50_t *dev, const mpu9x50_params_t *params) | 
|   | Initialize the given MPU9X50 device.  More...
  | 
|   | 
| int  | mpu9x50_set_accel_power (mpu9x50_t *dev, mpu9x50_pwr_t pwr_conf) | 
|   | Enable or disable accelerometer power.  More...
  | 
|   | 
| int  | mpu9x50_set_gyro_power (mpu9x50_t *dev, mpu9x50_pwr_t pwr_conf) | 
|   | Enable or disable gyroscope power.  More...
  | 
|   | 
| int  | mpu9x50_set_compass_power (mpu9x50_t *dev, mpu9x50_pwr_t pwr_conf) | 
|   | Enable or disable compass power.  More...
  | 
|   | 
| int  | mpu9x50_read_gyro (const mpu9x50_t *dev, mpu9x50_results_t *output) | 
|   | Read angular speed values from the given MPU9X50 device, returned in dps.  More...
  | 
|   | 
| int  | mpu9x50_read_accel (const mpu9x50_t *dev, mpu9x50_results_t *output) | 
|   | Read acceleration values from the given MPU9X50 device, returned in mG.  More...
  | 
|   | 
| int  | mpu9x50_read_compass (const mpu9x50_t *dev, mpu9x50_results_t *output) | 
|   | Read magnetic field values from the given MPU9X50 device, returned in mikroT.  More...
  | 
|   | 
| int  | mpu9x50_read_temperature (const mpu9x50_t *dev, int32_t *output) | 
|   | Read temperature value from the given MPU9X50 device, returned in m°C.  More...
  | 
|   | 
| int  | mpu9x50_set_gyro_fsr (mpu9x50_t *dev, mpu9x50_gyro_ranges_t fsr) | 
|   | Set the full-scale range for raw gyroscope data.  More...
  | 
|   | 
| int  | mpu9x50_set_accel_fsr (mpu9x50_t *dev, mpu9x50_accel_ranges_t fsr) | 
|   | Set the full-scale range for raw accelerometer data.  More...
  | 
|   | 
| int  | mpu9x50_set_sample_rate (mpu9x50_t *dev, uint16_t rate) | 
|   | Set the rate at which the gyroscope and accelerometer data is sampled.  More...
  | 
|   | 
| int  | mpu9x50_set_compass_sample_rate (mpu9x50_t *dev, uint8_t rate) | 
|   | Set the rate at which the compass data is sampled.  More...
  | 
|   | 
 | 
| 
#define  | MPU9X50_MIN_SAMPLE_RATE   (4) | 
|   | 
| 
#define  | MPU9X50_MAX_SAMPLE_RATE   (1000) | 
|   | 
| 
#define  | MPU9X50_DEFAULT_SAMPLE_RATE   (50) | 
|   | 
| 
#define  | MPU9X50_MIN_COMP_SMPL_RATE   (1) | 
|   | 
| 
#define  | MPU9X50_MAX_COMP_SMPL_RATE   (100) | 
|   | 
◆ mpu9x50_init()
Initialize the given MPU9X50 device. 
- Parameters
 - 
  
    | [out] | dev | Initialized device descriptor of MPU9X50 device  | 
    | [in] | params | Initialization parameters | 
  
   
- Returns
 - 0 on success 
 
- 
-1 if given I2C is not enabled in board config 
 
 
 
◆ mpu9x50_read_accel()
Read acceleration values from the given MPU9X50 device, returned in mG. 
The raw acceleration data is read from the sensor and normalized with respect to the configured accelerometer full-scale range.
- Parameters
 - 
  
    | [in] | dev | Device descriptor of MPU9X50 device to read from  | 
    | [out] | output | Result vector in mG per axis | 
  
   
- Returns
 - 0 on success 
 
- 
-1 if device's I2C is not enabled in board config 
 
- 
-2 if accel full-scale range is configured wrong 
 
 
 
◆ mpu9x50_read_compass()
Read magnetic field values from the given MPU9X50 device, returned in mikroT. 
The raw compass data is read from the sensor and normalized with respect to the compass full-scale range (which can not be configured).
- Parameters
 - 
  
    | [in] | dev | Device descriptor of MPU9X50 device to read from  | 
    | [out] | output | Result vector in mikroT per axis | 
  
   
- Returns
 - 0 on success 
 
- 
-1 if device's I2C is not enabled in board config 
 
 
 
◆ mpu9x50_read_gyro()
Read angular speed values from the given MPU9X50 device, returned in dps. 
The raw gyroscope data is read from the sensor and normalized with respect to the configured gyroscope full-scale range.
- Parameters
 - 
  
    | [in] | dev | Device descriptor of MPU9X50 device to read from  | 
    | [out] | output | Result vector in dps per axis | 
  
   
- Returns
 - 0 on success 
 
- 
-1 if device's I2C is not enabled in board config 
 
- 
-2 if gyro full-scale range is configured wrong 
 
 
 
◆ mpu9x50_read_temperature()
      
        
          | int mpu9x50_read_temperature  | 
          ( | 
          const mpu9x50_t *  | 
          dev,  | 
        
        
           | 
           | 
          int32_t *  | 
          output  | 
        
        
           | 
          ) | 
           |  | 
        
      
 
Read temperature value from the given MPU9X50 device, returned in m°C. 
- Note
 - The measured temperature is slightly higher than the real room temperature. Tests showed that the offset varied around 2-3 °C (but no warranties here).
 
- Parameters
 - 
  
    | [in] | dev | Device descriptor of MPU9X50 device to read from  | 
    | [out] | output | Temperature in m°C | 
  
   
- Returns
 - 0 on success 
 
- 
-1 if device's I2C is not enabled in board config 
 
 
 
◆ mpu9x50_set_accel_fsr()
Set the full-scale range for raw accelerometer data. 
- Parameters
 - 
  
    | [in] | dev | Device descriptor of MPU9X50 device  | 
    | [in] | fsr | Target full-scale range | 
  
   
- Returns
 - 0 on success 
 
- 
-1 if device's I2C is not enabled in board config 
 
- 
-2 if given full-scale target value is not valid 
 
 
 
◆ mpu9x50_set_accel_power()
Enable or disable accelerometer power. 
- Parameters
 - 
  
    | [in] | dev | Device descriptor of MPU9X50 device  | 
    | [in] | pwr_conf | Target power setting: PWR_ON or PWR_OFF | 
  
   
- Returns
 - 0 on success 
 
- 
-1 if given I2C is not enabled in board config 
 
 
 
◆ mpu9x50_set_compass_power()
Enable or disable compass power. 
- Parameters
 - 
  
    | [in] | dev | Device descriptor of MPU9X50 device  | 
    | [in] | pwr_conf | Target power setting: PWR_ON or PWR_OFF | 
  
   
- Returns
 - 0 on success 
 
- 
-1 if given I2C is not enabled in board config 
 
 
 
◆ mpu9x50_set_compass_sample_rate()
      
        
          | int mpu9x50_set_compass_sample_rate  | 
          ( | 
          mpu9x50_t *  | 
          dev,  | 
        
        
           | 
           | 
          uint8_t  | 
          rate  | 
        
        
           | 
          ) | 
           |  | 
        
      
 
Set the rate at which the compass data is sampled. 
Sample rate can be chosen between 1 Hz and 100 Hz but has to be a fraction of the configured accel/gyro sample rate. The actual set value might slightly differ. If necessary, check the actual set value in the device's config member afterwards.
- Parameters
 - 
  
    | [in] | dev | Device descriptor of MPU9X50 device  | 
    | [in] | rate | Target sample rate in Hz | 
  
   
- Returns
 - 0 on success 
 
- 
-1 if device's I2C is not enabled in board config 
 
- 
-2 if given target sample rate is not valid 
 
 
 
◆ mpu9x50_set_gyro_fsr()
Set the full-scale range for raw gyroscope data. 
- Parameters
 - 
  
    | [in] | dev | Device descriptor of MPU9X50 device  | 
    | [in] | fsr | Target full-scale range | 
  
   
- Returns
 - 0 on success 
 
- 
-1 if device's I2C is not enabled in board config 
 
- 
-2 if given full-scale target value is not valid 
 
 
 
◆ mpu9x50_set_gyro_power()
Enable or disable gyroscope power. 
- Parameters
 - 
  
    | [in] | dev | Device descriptor of MPU9X50 device  | 
    | [in] | pwr_conf | Target power setting: PWR_ON or PWR_OFF | 
  
   
- Returns
 - 0 on success 
 
- 
-1 if given I2C is not enabled in board config 
 
 
 
◆ mpu9x50_set_sample_rate()
      
        
          | int mpu9x50_set_sample_rate  | 
          ( | 
          mpu9x50_t *  | 
          dev,  | 
        
        
           | 
           | 
          uint16_t  | 
          rate  | 
        
        
           | 
          ) | 
           |  | 
        
      
 
Set the rate at which the gyroscope and accelerometer data is sampled. 
Sample rate can be chosen between 4 Hz and 1kHz. The actual set value might slightly differ. If necessary, check the actual set value in the device's config member afterwards.
- Parameters
 - 
  
    | [in] | dev | Device descriptor of MPU9X50 device  | 
    | [in] | rate | Target sample rate in Hz | 
  
   
- Returns
 - 0 on success 
 
- 
-1 if device's I2C is not enabled in board config 
 
- 
-2 if given target sample rate is not valid