26 #define SDP3X_SCALE_TEMPERATURE 200.0f 28 #define SDP3XD0_I2C_ADDR 0x21 29 #define SDP3XD1_I2C_ADDR 0x22 30 #define SDP3XD2_I2C_ADDR 0x23 32 #define SDP3X_CONT_MEAS_AVG_MODE 0x3615 33 #define SDP3X_CONT_MEAS_STOP 0x3FF9 35 #define SDP3X_SCALE_PRESSURE_SDP31 60 36 #define SDP3X_SCALE_PRESSURE_SDP32 240 37 #define SDP3X_SCALE_PRESSURE_SDP33 20 51 uint8_t b[2] {uint8_t(cmd >> 8), uint8_t(cmd & 0xFF)};
65 for (uint8_t i=0; i<
ARRAY_SIZE(addresses) && !found; i++) {
112 if (!
_crc(&val[0], 2, val[2]) || !
_crc(&val[3], 2, val[5]) || !
_crc(&val[6], 2, val[8])) {
117 _scale = (((uint16_t)val[6]) << 8) | val[7];
135 hal.
console->
printf(
"SDP3%c: Found on bus %u address 0x%02x scale=%u\n",
163 int ret =
_dev->
transfer(
nullptr, 0, &val[0],
sizeof(val));
173 if (!
_crc(&val[0], 2, val[2]) || !
_crc(&val[3], 2, val[5])) {
177 int16_t P = (((int16_t)val[0]) << 8) | val[1];
178 int16_t temp = (((int16_t)val[3]) << 8) | val[4];
180 float diff_press_pa = float(P) / float(
_scale);
203 if (baro ==
nullptr) {
211 switch (tube_order) {
249 float flow_SDP3X = (300.805f - 300.878f / (0.00344205f * (float)powf(press, 0.68698
f) + 1)) * 1.29f / rho_air;
250 if (flow_SDP3X < 0.0
f) {
255 float dp_pitot = 28557670.0f - 28557670.0f / (1 + (float)powf((flow_SDP3X / 5027611.0
f), 1.227924f));
261 float dv = 0.0331582 * flow_SDP3X;
270 float press_correction =
sq(sqrtf(press_uncorrected*ratio)+dv)/ratio - press_uncorrected;
272 return (press_uncorrected + press_correction) * sign;
317 uint8_t crc_value = 0xff;
320 for (uint8_t i = 0; i < size; i++) {
321 crc_value ^= data[i];
322 for (uint8_t bit = 8; bit > 0; --bit) {
323 if (crc_value & 0x80) {
324 crc_value = (crc_value << 1) ^ 0x31;
326 crc_value = (crc_value << 1);
331 return (crc_value == checksum);
uint32_t _last_sample_time_ms
AP_Airspeed_SDP3X(AP_Airspeed &frontend, uint8_t _instance)
virtual Device::PeriodicHandle register_periodic_callback(uint32_t period_usec, Device::PeriodicCb) override=0
#define SDP3X_SCALE_PRESSURE_SDP33
bool _send_command(uint16_t cmd)
AP_HAL::UARTDriver * console
float get_airspeed_ratio(void) const
Interface definition for the various Ground Control System.
float _correct_pressure(float press)
virtual void set_retries(uint8_t retries)
virtual Semaphore * get_semaphore() override=0
static AP_Baro * get_instance(void)
#define HAL_SEMAPHORE_BLOCK_FOREVER
virtual bool take(uint32_t timeout_ms) WARN_IF_UNUSED=0
#define SDP3X_SCALE_PRESSURE_SDP32
bool get_differential_pressure(float &pressure) override
AP_HAL::OwnPtr< AP_HAL::I2CDevice > _dev
virtual void printf(const char *,...) FMT_PRINTF(2
void set_offset(float ofs)
void set_use_zero_offset(void)
bool _crc(const uint8_t data[], unsigned size, uint8_t checksum)
virtual bool transfer(const uint8_t *send, uint32_t send_len, uint8_t *recv, uint32_t recv_len) override=0
float get_pressure(void) const
#define SDP3X_SCALE_TEMPERATURE
AP_HAL::I2CDeviceManager * i2c_mgr
#define SDP3X_CONT_MEAS_STOP
uint8_t get_bus(void) const
#define SDP3X_SCALE_PRESSURE_SDP31
virtual void delay_microseconds(uint16_t us)=0
#define SDP3X_CONT_MEAS_AVG_MODE
#define FUNCTOR_BIND_MEMBER(func, rettype,...)
bool get_temperature(float &temperature) override
AP_Airspeed::pitot_tube_order get_tube_order(void) const
virtual OwnPtr< AP_HAL::I2CDevice > get_device(uint8_t bus, uint8_t address, uint32_t bus_clock=400000, bool use_smbus=false, uint32_t timeout_ms=4)=0
AP_HAL::Scheduler * scheduler