44 ret = transfer(&cmd, 1,
nullptr, 0);
66 int ret = transfer(&cmd, 1,
nullptr, 0);
83 for (uint8_t i = 0; i < 8; i++) {
87 ret = transfer(&cmd, 1,
nullptr, 0);
96 ret = transfer(
nullptr, 0, &val[0], 2);
99 prom[i] = (val[0] << 8) | val[1];
109 const uint8_t onboard_crc = prom[7] & 0xF;
111 if (crc == onboard_crc) {
126 PX4_ERR(
"CRC mismatch");
137 unsigned int n_rem = 0x00;
140 unsigned int crc_read = n_prom[7];
141 n_prom[7] = (0xFF00 & (n_prom[7]));
144 for (
int cnt = 0; cnt < 16; cnt++) {
147 n_rem ^= (
unsigned short)((n_prom[cnt >> 1]) & 0x00FF);
150 n_rem ^= (
unsigned short)(n_prom[cnt >> 1] >> 8);
153 for (uint8_t n_bit = 8; n_bit > 0; n_bit--) {
154 if (n_rem & (0x8000)) {
155 n_rem = (n_rem << 1) ^ 0x3000;
158 n_rem = (n_rem << 1);
163 n_rem = (0x000F & (n_rem >> 12));
164 n_prom[7] = crc_read;
166 return (n_rem ^ 0x00);
176 int ret = transfer(&cmd, 1,
nullptr, 0);
185 ret = transfer(
nullptr, 0, &val[0], 3);
192 uint32_t adc = (val[0] << 16) | (val[1] << 8) | val[2];
221 if (
D1 == 0 ||
D2 == 0) {
227 const int64_t dT =
D2 -
Tref;
231 const int64_t TEMP = 2000 + (dT * int64_t(
C6)) / (1UL <<
Q6);
235 const int64_t OFF = int64_t(
C2) * (1UL <<
Q2) + (int64_t(
C4) * dT) / (1UL <<
Q4);
239 const int64_t SENS = int64_t(
C1) * (1UL <<
Q1) + (int64_t(
C3) * dT) / (1UL <<
Q3);
243 const int64_t
P = (
D1 * SENS / (1UL << 21) - OFF) / (1UL << 15);
245 const float diff_press_PSI = P * 0.0001f;
248 static constexpr
float PSI_to_Pa = 6894.757f;
249 const float diff_press_pa_raw = diff_press_PSI * PSI_to_Pa;
251 const float temperature_c = TEMP * 0.01f;
258 .temperature = temperature_c,
259 .device_id = _device_id.devid
orb_advert_t _airspeed_pub
#define CONVERSION_INTERVAL
static constexpr uint8_t Q3
static constexpr uint8_t CMD_ADC_READ
math::LowPassFilter2p _filter
static constexpr uint8_t Q5
#define ORB_ID(_name)
Generates a pointer to the uORB metadata structure for a given topic.
static constexpr uint8_t CMD_CONVERT_TEMP
static constexpr uint8_t CMD_PROM_START
static constexpr uint8_t Q2
void perf_count(perf_counter_t handle)
Count a performance event.
void Run() override
Perform a poll cycle; collect from the previous measurement and start a new one.
uint8_t prom_crc4(uint16_t n_prom[]) const
static constexpr uint8_t CMD_RESET
perf_counter_t _sample_perf
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)
#define DRV_DIFF_PRESS_DEVTYPE_MS5525
static constexpr uint8_t CMD_CONVERT_PRES
float apply(float sample)
Add a new raw value to the filter.
static constexpr uint8_t Q6
static constexpr uint8_t Q1
uint64_t perf_event_count(perf_counter_t handle)
Return current event_count.
void perf_begin(perf_counter_t handle)
Begin a performance event.
#define DEVICE_DEBUG(FMT,...)
perf_counter_t _comms_errors
__EXPORT hrt_abstime hrt_absolute_time(void)
Get absolute time in [us] (does not wrap).
static constexpr uint8_t Q4
void start()
Initialise the automatic measurement state machine and start it.