2011-12-21 00:30:22 -04:00
|
|
|
/// -*- tab-width: 4; Mode: C++; c-basic-offset: 4; indent-tabs-mode: nil -*-
|
2011-11-12 23:20:25 -04:00
|
|
|
|
|
|
|
#ifndef __AP_INERTIAL_SENSOR_MPU6000_H__
|
|
|
|
#define __AP_INERTIAL_SENSOR_MPU6000_H__
|
|
|
|
|
|
|
|
#include <string.h>
|
|
|
|
#include <stdint.h>
|
|
|
|
|
|
|
|
#include "../AP_PeriodicProcess/AP_PeriodicProcess.h"
|
|
|
|
#include "../AP_Math/AP_Math.h"
|
|
|
|
#include "AP_InertialSensor.h"
|
|
|
|
|
|
|
|
class AP_InertialSensor_MPU6000 : public AP_InertialSensor
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
2011-12-26 16:34:18 -04:00
|
|
|
AP_InertialSensor_MPU6000( uint8_t cs_pin );
|
2011-11-12 23:20:25 -04:00
|
|
|
|
|
|
|
void init( AP_PeriodicProcess * scheduler );
|
|
|
|
|
|
|
|
/* Concrete implementation of AP_InertialSensor functions: */
|
|
|
|
bool update();
|
2012-03-03 03:31:31 -04:00
|
|
|
bool new_data_available();
|
2011-11-12 23:20:25 -04:00
|
|
|
float gx();
|
|
|
|
float gy();
|
|
|
|
float gz();
|
|
|
|
void get_gyros( float * );
|
|
|
|
float ax();
|
|
|
|
float ay();
|
|
|
|
float az();
|
|
|
|
void get_accels( float * );
|
|
|
|
void get_sensors( float * );
|
|
|
|
float temperature();
|
|
|
|
uint32_t sample_time();
|
|
|
|
void reset_sample_time();
|
|
|
|
|
2011-12-26 16:34:18 -04:00
|
|
|
private:
|
|
|
|
|
2011-12-21 08:22:07 -04:00
|
|
|
static void read(uint32_t);
|
2011-12-25 05:37:50 -04:00
|
|
|
static void data_interrupt(void);
|
2011-11-12 23:20:25 -04:00
|
|
|
static uint8_t register_read( uint8_t reg );
|
|
|
|
static void register_write( uint8_t reg, uint8_t val );
|
|
|
|
static void hardware_init();
|
|
|
|
|
|
|
|
Vector3f _gyro;
|
|
|
|
Vector3f _accel;
|
|
|
|
float _temp;
|
|
|
|
|
|
|
|
uint32_t _last_sample_micros;
|
|
|
|
|
|
|
|
float _temp_to_celsius( uint16_t );
|
|
|
|
|
|
|
|
static const float _accel_scale;
|
|
|
|
static const float _gyro_scale;
|
|
|
|
|
|
|
|
static const uint8_t _gyro_data_index[3];
|
|
|
|
static const int8_t _gyro_data_sign[3];
|
|
|
|
|
|
|
|
static const uint8_t _accel_data_index[3];
|
|
|
|
static const int8_t _accel_data_sign[3];
|
|
|
|
|
|
|
|
static const uint8_t _temp_data_index;
|
|
|
|
|
|
|
|
static int16_t _data[7];
|
|
|
|
|
|
|
|
/* TODO deprecate _cs_pin */
|
2011-12-26 16:34:18 -04:00
|
|
|
static uint8_t _cs_pin;
|
2011-12-26 16:38:36 -04:00
|
|
|
|
|
|
|
// ensure we can't initialise twice
|
|
|
|
unsigned _initialised:1;
|
2011-11-12 23:20:25 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // __AP_INERTIAL_SENSOR_MPU6000_H__
|