44 #if defined(PX4_I2C_OBDEV_BMP388) || defined(PX4_I2C_EXT_OBDEV_BMP388) 46 class BMP388_I2C:
public device::I2C,
public IBMP388 49 BMP388_I2C(uint8_t bus, uint32_t
device);
50 virtual ~BMP388_I2C() =
default;
55 int get_reg_buf(uint8_t addr, uint8_t *buf, uint8_t len);
56 int set_reg(uint8_t value, uint8_t addr);
60 uint32_t
get_device_id()
const override {
return device::I2C::get_device_id(); }
69 return new BMP388_I2C(busnum, device);
72 BMP388_I2C::BMP388_I2C(uint8_t bus, uint32_t
device) :
73 I2C(
"BMP388_I2C", nullptr, bus, device, 100 * 1000)
82 uint8_t BMP388_I2C::get_reg(uint8_t addr)
84 uint8_t cmd[2] = { (uint8_t)(addr), 0};
85 transfer(&cmd[0], 1, &cmd[1], 1);
90 int BMP388_I2C::get_reg_buf(uint8_t addr, uint8_t *buf, uint8_t len)
92 const uint8_t cmd = (uint8_t)(addr);
93 return transfer(&cmd,
sizeof(cmd), buf, len);
96 int BMP388_I2C::set_reg(uint8_t value, uint8_t addr)
98 uint8_t cmd[2] = { (uint8_t)(addr), value};
99 return transfer(cmd,
sizeof(cmd),
nullptr, 0);
102 data_s *BMP388_I2C::get_data(uint8_t addr)
104 const uint8_t cmd = (uint8_t)(addr);
106 if (transfer(&cmd,
sizeof(cmd), (uint8_t *)&_data,
sizeof(
struct data_s)) ==
OK) {
116 const uint8_t cmd = (uint8_t)(addr);
118 if (transfer(&cmd,
sizeof(cmd), (uint8_t *)&_cal,
sizeof(
struct calibration_s)) ==
OK) {
virtual uint8_t get_reg(uint8_t addr)=0
Namespace encapsulating all device framework classes, functions and data.
void init()
Activates/configures the hardware registers.
virtual calibration_s * get_calibration(uint8_t addr)=0
virtual uint32_t get_device_id() const =0
virtual int get_reg_buf(uint8_t addr, uint8_t *buf, uint8_t len)=0
IBMP388 * bmp388_i2c_interface(uint8_t busnum, uint32_t device)
virtual int set_reg(uint8_t value, uint8_t addr)=0
virtual data_s * get_data(uint8_t addr)=0
Shared defines for the bmp388 driver.
static struct mpu9x50_data _data
IMU measurement data.
Base class for devices connected via I2C.