52 cmd[0] =
static_cast<uint8_t
>(command >> 8);
53 cmd[1] =
static_cast<uint8_t
>(command & 0xff);
54 return transfer(&cmd[0], 2,
nullptr, 0);
61 uint16_t prev_addr = get_device_address();
64 int ret = transfer(&reset_cmd, 1,
nullptr, 0);
65 set_device_address(prev_addr);
80 PX4_ERR(
"config failed");
88 ret = transfer(
nullptr, 0, &val[0],
sizeof(val));
92 PX4_ERR(
"get scale failed");
97 if (!
crc(&val[0], 2, val[2]) || !
crc(&val[3], 2, val[5]) || !
crc(&val[6], 2, val[8])) {
102 _scale = (((uint16_t)val[6]) << 8) | val[7];
128 int ret = transfer(
nullptr, 0, &val[0],
sizeof(val));
136 if (!
crc(&val[0], 2, val[2]) || !
crc(&val[3], 2, val[5])) {
144 int16_t
P = (((int16_t)val[0]) << 8) | val[1];
145 int16_t temp = (((int16_t)val[3]) << 8) | val[4];
147 float diff_press_pa_raw =
static_cast<float>(
P) / static_cast<float>(
_scale);
189 uint8_t crc_value = 0xff;
192 for (
unsigned i = 0; i < size; i++) {
193 crc_value ^= (data[i]);
195 for (
int bit = 8; bit > 0; --bit) {
196 if (crc_value & 0x80) {
197 crc_value = (crc_value << 1) ^ 0x31;
200 crc_value = (crc_value << 1);
206 return (crc_value == checksum);
orb_advert_t _airspeed_pub
#define SDP3X_SCALE_PRESSURE_SDP32
float differential_pressure_raw_pa
#define CONVERSION_INTERVAL
#define DRV_DIFF_PRESS_DEVTYPE_SDP33
#define SDP3X_CONT_MEAS_AVG_MODE
#define DRV_DIFF_PRESS_DEVTYPE_SDP31
#define SDP3X_SCALE_TEMPERATURE
int write_command(uint16_t command)
Write a command in Sensirion specific logic.
#define ORB_ID(_name)
Generates a pointer to the uORB metadata structure for a given topic.
void perf_count(perf_counter_t handle)
Count a performance event.
bool crc(const uint8_t data[], unsigned size, uint8_t checksum)
Calculate the CRC8 for the sensor payload data.
perf_counter_t _sample_perf
Driver for Sensirion SDP3X Differential Pressure Sensor.
void perf_end(perf_counter_t handle)
End a performance event.
int orb_publish(const struct orb_metadata *meta, orb_advert_t handle, const void *data)
float apply(float sample)
Add a new raw value to the filter.
#define SDP3X_SCALE_PRESSURE_SDP31
uint64_t perf_event_count(perf_counter_t handle)
Return current event_count.
math::LowPassFilter2p _filter
float differential_pressure_filtered_pa
void perf_begin(perf_counter_t handle)
Begin a performance event.
#define SDP3X_SCALE_PRESSURE_SDP33
#define DEVICE_DEBUG(FMT,...)
perf_counter_t _comms_errors
__EXPORT hrt_abstime hrt_absolute_time(void)
Get absolute time in [us] (does not wrap).
void Run() override
Perform a poll cycle; collect from the previous measurement and start a new one.
#define DRV_DIFF_PRESS_DEVTYPE_SDP32