2010-12-28 19:41:00 -04:00
|
|
|
// -*- tab-width: 4; Mode: C++; c-basic-offset: 4; indent-tabs-mode: t -*-
|
|
|
|
|
|
|
|
/// @file AP_IMU_Shim.h
|
|
|
|
/// @brief IMU shim driver, used when the IMU data is coming from somewhere else.
|
|
|
|
|
2010-12-28 20:36:08 -04:00
|
|
|
#ifndef AP_IMU_Shim_h
|
|
|
|
#define AP_IMU_Shim_h
|
|
|
|
|
2011-11-12 23:24:03 -04:00
|
|
|
#include "IMU.h"
|
|
|
|
|
2010-12-28 20:36:08 -04:00
|
|
|
class AP_IMU_Shim : public IMU
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
AP_IMU_Shim(void) {}
|
|
|
|
|
|
|
|
/// @name IMU protocol
|
|
|
|
//@{
|
2011-12-13 03:19:12 -04:00
|
|
|
virtual void init(Start_style style = COLD_START,
|
|
|
|
void (*callback)(unsigned long t) = delay,
|
|
|
|
void (*flash_leds_cb)(bool on) = NULL,
|
2011-11-13 02:16:35 -04:00
|
|
|
AP_PeriodicProcess *scheduler = NULL) {};
|
2011-12-13 03:19:12 -04:00
|
|
|
virtual void init_accel(void (*callback)(unsigned long t) = delay,
|
|
|
|
void (*flash_leds_cb)(bool on) = NULL) {};
|
|
|
|
virtual void init_gyro(void (*callback)(unsigned long t) = delay,
|
|
|
|
void (*flash_leds_cb)(bool on) = NULL) {};
|
2010-12-28 20:36:08 -04:00
|
|
|
virtual bool update(void) {
|
|
|
|
bool updated = _updated;
|
|
|
|
_updated = false;
|
2011-10-13 11:36:51 -03:00
|
|
|
|
|
|
|
// return number of microseconds since last call
|
|
|
|
uint32_t us = micros();
|
|
|
|
uint32_t ret = us - last_ch6_micros;
|
|
|
|
last_ch6_micros = us;
|
|
|
|
|
|
|
|
_sample_time = ret;
|
2010-12-28 20:36:08 -04:00
|
|
|
return updated;
|
|
|
|
}
|
|
|
|
//@}
|
2012-03-03 03:31:55 -04:00
|
|
|
|
|
|
|
virtual bool new_data_available(void) { return true; }
|
2011-02-21 19:16:57 -04:00
|
|
|
|
|
|
|
float gx() { return 0; }
|
|
|
|
float gy() { return 0; }
|
|
|
|
float gz() { return 0; }
|
|
|
|
float ax() { return 0; }
|
|
|
|
float ay() { return 0; }
|
|
|
|
float az() { return 0; }
|
|
|
|
|
|
|
|
void ax(const int v) { }
|
|
|
|
void ay(const int v) { }
|
|
|
|
void az(const int v) { }
|
2010-12-28 20:36:08 -04:00
|
|
|
|
|
|
|
/// Set the gyro vector. ::update will return
|
|
|
|
/// true once after this call.
|
|
|
|
///
|
|
|
|
/// @param v The new gyro vector.
|
|
|
|
///
|
|
|
|
void set_gyro(Vector3f v) { _gyro = v; _updated = true; }
|
|
|
|
|
|
|
|
/// Set the accelerometer vector. ::update will return
|
|
|
|
/// true once after this call.
|
|
|
|
///
|
|
|
|
/// @param v The new accelerometer vector.
|
|
|
|
///
|
|
|
|
void set_accel(Vector3f v) { _accel = v; _updated = true; }
|
|
|
|
|
2011-03-17 22:34:00 -03:00
|
|
|
// dummy save method
|
|
|
|
void save(void) { }
|
|
|
|
|
2010-12-28 20:36:08 -04:00
|
|
|
private:
|
|
|
|
/// set true when new data is delivered
|
|
|
|
bool _updated;
|
2011-10-13 11:36:51 -03:00
|
|
|
uint32_t last_ch6_micros;
|
2010-12-28 20:36:08 -04:00
|
|
|
};
|
2010-12-28 19:41:00 -04:00
|
|
|
|
|
|
|
#endif
|