2015-12-09 17:48:25 -04:00
|
|
|
/// -*- tab-width: 4; Mode: C++; c-basic-offset: 4; indent-tabs-mode: nil -*-
|
|
|
|
#pragma once
|
|
|
|
|
2016-01-19 21:26:31 -04:00
|
|
|
#include <AP_HAL/AP_HAL.h>
|
2015-12-09 17:48:25 -04:00
|
|
|
#if CONFIG_HAL_BOARD == HAL_BOARD_QURT
|
2016-01-19 21:26:31 -04:00
|
|
|
|
|
|
|
#include "AP_InertialSensor.h"
|
|
|
|
#include "AP_InertialSensor_Backend.h"
|
|
|
|
|
2015-12-09 17:48:25 -04:00
|
|
|
extern "C" {
|
|
|
|
#undef DEG_TO_RAD
|
2016-01-19 21:26:31 -04:00
|
|
|
#include <mpu9x50.h>
|
2015-12-09 17:48:25 -04:00
|
|
|
}
|
|
|
|
#include <AP_HAL/utility/RingBuffer.h>
|
|
|
|
|
|
|
|
extern ObjectBuffer<mpu9x50_data> *mpu9250_mag_buffer;
|
|
|
|
|
|
|
|
class AP_InertialSensor_QURT : public AP_InertialSensor_Backend
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
AP_InertialSensor_QURT(AP_InertialSensor &imu);
|
|
|
|
|
|
|
|
/* update accel and gyro state */
|
|
|
|
bool update() override;
|
|
|
|
void accumulate(void) override;
|
2016-01-19 21:26:31 -04:00
|
|
|
|
2015-12-09 17:48:25 -04:00
|
|
|
// detect the sensor
|
|
|
|
static AP_InertialSensor_Backend *detect(AP_InertialSensor &imu);
|
|
|
|
|
|
|
|
void data_ready(void);
|
2016-01-19 21:26:31 -04:00
|
|
|
|
2015-12-09 17:48:25 -04:00
|
|
|
private:
|
|
|
|
bool init_sensor();
|
|
|
|
void init_mpu9250();
|
|
|
|
|
|
|
|
uint64_t last_timestamp;
|
|
|
|
uint32_t start_time_ms;
|
2016-01-19 21:26:31 -04:00
|
|
|
|
2015-12-09 17:48:25 -04:00
|
|
|
uint8_t gyro_instance;
|
|
|
|
uint8_t accel_instance;
|
|
|
|
|
|
|
|
ObjectBuffer<mpu9x50_data> buf{100};
|
|
|
|
};
|
|
|
|
|
2016-01-19 21:26:31 -04:00
|
|
|
#endif
|