33#define SDP3X_SCALE_TEMPERATURE 200.0f
34#define SDP3X_RESET_ADDR 0x00
35#define SDP3X_RESET_CMD 0x06
37#define SDP3X_CONT_MEAS_AVG_MODE 0x3615
38#define SDP3X_CONT_NONE_MODE 0x361E
40#define SDP3X_SCALE_PRESSURE_SDP31 60
41#define SDP3X_SCALE_PRESSURE_SDP32 240
42#define SDP3X_SCALE_PRESSURE_SDP33 20
47#define SDP3X_I2C_ADDR 0x42
53#define SDP3X_MODE SDP3X_CONT_MEAS_AVG_MODE
58#ifndef SDP3X_PRESSURE_SCALE
59#define SDP3X_PRESSURE_SCALE SDP3X_SCALE_PRESSURE_SDP31
72 for (
unsigned i = 0; i < size; i++) {
73 crc_value ^= (data[i]);
75 for (
int bit = 8; bit > 0; --bit) {
76 if (crc_value & 0x80) {
77 crc_value = (crc_value << 1) ^ 0x31;
80 crc_value = (crc_value << 1);
92 sdp3x.temperature = 0.f;
94 sdp3x.initialized =
false;
105 if (
sdp3x.initialized) {
114 sdp3x.initialized =
true;
123 if (
sdp3x.initialized) {
125 for (
uint8_t i = 0; i < 6; i++) {
138 float p_out = (float)p_raw /
sdp3x.pressure_scale;
140 sdp3x.pressure = p_out;
Main include for ABI (AirBorneInterface).
#define TEMPERATURE_TYPE_DIFF
differential pressure (pitot) sensor
#define SDP3X_SCALE_TEMPERATURE
Commands and scales.
struct AirspeedSdp3x sdp3x
#define SDP3X_MODE
Default operation mode.
#define SDP3X_PRESSURE_SCALE
Default scale for SDP31.
void sdp3x_periodic(void)
static struct i2c_transaction sdp3x_trans
#define SDP3X_I2C_ADDR
Sensor I2C slave address (existing defaults 0x42, 0x44 and 0x46).
static bool sdp3x_crc(const uint8_t data[], unsigned size, uint8_t checksum)
Airspeed driver for the SDP3X pressure sensor via I2C.
uint32_t get_sys_time_usec(void)
Get the time in microseconds since startup.
bool i2c_transmit(struct i2c_periph *p, struct i2c_transaction *t, uint8_t s_addr, uint8_t len)
Submit a write only transaction.
bool i2c_receive(struct i2c_periph *p, struct i2c_transaction *t, uint8_t s_addr, uint16_t len)
Submit a read only transaction.
@ I2CTransSuccess
transaction successfully finished by I2C driver
@ I2CTransFailed
transaction failed
@ I2CTransDone
transaction set to done by user level
I2C transaction structure.
Architecture independent I2C (Inter-Integrated Circuit Bus) API.
PRINT_CONFIG_VAR(ONELOOP_ANDI_FILT_CUTOFF)
Architecture independent timing functions.
unsigned int uint32_t
Typedef defining 32 bit unsigned int type.
short int16_t
Typedef defining 16 bit short type.
unsigned char uint8_t
Typedef defining 8 bit unsigned char type.