42 #define MPL3115A2_ADDRESS 0x60 53 virtual int read(
unsigned offset,
void *
data,
unsigned count);
54 virtual int ioctl(
unsigned operation,
unsigned &arg);
68 int reg_read(uint8_t reg,
void *data,
unsigned count = 1);
81 I2C(
"MPL3115A2_I2C", nullptr, bus, 0, 400000)
106 return ret == 1 ? PX4_OK : ret;
117 ret =
reg_read(offset, data, count);
123 } *cvt = (_cvt *)data;
129 uint8_t reg = (uint8_t) offset;
131 ret = transfer(®, 1, &b[0],
sizeof(b));
134 cvt->reading.pressure.q = ((uint32_t)b[0]) << 18 | ((uint32_t) b[1]) << 10 | (((uint32_t)b[2]) & 0xc0) << 2 | ((
136 cvt->reading.temperature.w = ((uint16_t) b[3]) << 8 | (b[4] >> 4);
193 return reg_write((addr >> 8) & 0xff, addr & 0xff);
200 int ret = transfer(&cmd, 1, (uint8_t *)data, count);
201 return ret == PX4_OK ? count : ret;
206 uint8_t buf[2] = { reg, data};
207 int ret = transfer(buf,
sizeof(buf), NULL, 0);
208 return ret == PX4_OK ? 2 : ret;
int reg_read(uint8_t reg, void *data, unsigned count=1)
#define MPL3115A2_WHO_AM_I
virtual int ioctl(unsigned operation, unsigned &arg)
Shared defines for the mpl3115a2 driver.
MPL3115A2_I2C(uint8_t bus)
int _measure(unsigned addr)
Send a measure command to the MPL3115A2.
virtual int read(unsigned offset, void *data, unsigned count)
#define MPL3115A2_REG_WHO_AM_I
void init()
Activates/configures the hardware registers.
#define MPL3115A2_CTRL_REG1
#define MPL3115A2_ADDRESS
int reg_write(uint8_t reg, uint8_t data)
device::Device * MPL3115A2_i2c_interface(uint8_t busnum)
constexpr _Tp max(_Tp a, _Tp b)
Fundamental base class for all physical drivers (I2C, SPI).
virtual ~MPL3115A2_I2C()=default