2011-11-05 22:11:25 -03:00
|
|
|
|
2011-11-27 01:49:17 -04:00
|
|
|
#ifndef __AP_BARO_MS5611_H__
|
|
|
|
#define __AP_BARO_MS5611_H__
|
2011-11-05 22:11:25 -03:00
|
|
|
|
2011-11-30 00:31:10 -04:00
|
|
|
#include "AP_Baro.h"
|
2011-11-05 22:11:25 -03:00
|
|
|
|
2011-11-30 00:31:10 -04:00
|
|
|
class AP_Baro_MS5611 : public AP_Baro
|
2011-11-27 01:43:34 -04:00
|
|
|
{
|
2011-11-27 01:49:17 -04:00
|
|
|
public:
|
|
|
|
AP_Baro_MS5611() {} // Constructor
|
2011-11-30 00:31:10 -04:00
|
|
|
|
|
|
|
/* AP_Baro public interface: */
|
2011-12-09 02:35:40 -04:00
|
|
|
void init(AP_PeriodicProcess *scheduler);
|
2011-11-27 01:49:17 -04:00
|
|
|
uint8_t read();
|
2011-11-30 00:31:10 -04:00
|
|
|
int32_t get_pressure(); // in mbar*100 units
|
|
|
|
int16_t get_temperature(); // in celsius degrees * 100 units
|
2011-11-27 01:49:17 -04:00
|
|
|
float get_altitude(); // in meter units
|
|
|
|
|
2011-11-30 00:31:10 -04:00
|
|
|
int32_t get_raw_pressure();
|
|
|
|
int32_t get_raw_temp();
|
|
|
|
|
2011-11-27 01:43:34 -04:00
|
|
|
private:
|
2011-12-09 02:35:40 -04:00
|
|
|
/* Asynchronous handler functions: */
|
2011-12-21 08:22:37 -04:00
|
|
|
static void _update(uint32_t );
|
2011-12-09 02:35:40 -04:00
|
|
|
/* Asynchronous state: */
|
|
|
|
static bool _updated;
|
|
|
|
static uint32_t _s_D1, _s_D2;
|
|
|
|
static uint8_t _state;
|
|
|
|
static long _timer;
|
|
|
|
/* Gates access to asynchronous state: */
|
|
|
|
static bool _sync_access;
|
|
|
|
|
|
|
|
/* Serial wrapper functions: */
|
|
|
|
static uint8_t _spi_read(uint8_t reg);
|
|
|
|
static uint16_t _spi_read_16bits(uint8_t reg);
|
|
|
|
static uint32_t _spi_read_adc();
|
|
|
|
static void _spi_write(uint8_t reg);
|
|
|
|
|
|
|
|
void _calculate();
|
2011-11-27 01:43:34 -04:00
|
|
|
|
2011-11-27 01:49:17 -04:00
|
|
|
int16_t Temp;
|
|
|
|
int32_t Press;
|
|
|
|
int32_t Alt;
|
|
|
|
|
2011-11-30 00:31:10 -04:00
|
|
|
int32_t _raw_press;
|
|
|
|
int32_t _raw_temp;
|
2011-11-27 01:49:17 -04:00
|
|
|
// Internal calibration registers
|
|
|
|
uint16_t C1,C2,C3,C4,C5,C6;
|
|
|
|
uint32_t D1,D2;
|
2011-11-05 22:11:25 -03:00
|
|
|
};
|
|
|
|
|
2011-11-27 01:49:17 -04:00
|
|
|
#endif // __AP_BARO_MS5611_H__
|