46 #define DIR_READ (1<<7) //for set 47 #define DIR_WRITE ~(1<<7) //for clear 49 #if defined(PX4_SPIDEV_BARO) || defined(PX4_SPIDEV_EXT_BARO) 57 struct spi_calibration_s {
63 class BMP388_SPI:
public device::SPI,
public IBMP388 66 BMP388_SPI(uint8_t bus, uint32_t
device);
67 virtual ~BMP388_SPI() =
default;
71 uint8_t get_reg(uint8_t addr);
72 int get_reg_buf(uint8_t addr, uint8_t *buf, uint8_t len);
73 int set_reg(uint8_t value, uint8_t addr);
74 data_s *get_data(uint8_t addr);
77 uint32_t get_device_id()
const override {
return device::SPI::get_device_id(); }
80 spi_calibration_s _cal;
86 return new BMP388_SPI(busnum, device);
89 BMP388_SPI::BMP388_SPI(uint8_t bus, uint32_t
device) :
99 uint8_t BMP388_SPI::get_reg(uint8_t addr)
101 uint8_t cmd[2] = { (uint8_t)(addr |
DIR_READ), 0};
102 transfer(&cmd[0], &cmd[0], 2);
107 int BMP388_SPI::get_reg_buf(uint8_t addr, uint8_t *buf, uint8_t len)
109 uint8_t cmd[1] = {(uint8_t)(addr |
DIR_READ)};
110 return transfer(&cmd[0], buf, len);
113 int BMP388_SPI::set_reg(uint8_t value, uint8_t addr)
115 uint8_t cmd[2] = { (uint8_t)(addr &
DIR_WRITE), value};
116 return transfer(&cmd[0],
nullptr, 2);
119 data_s *BMP388_SPI::get_data(uint8_t addr)
123 if (transfer((uint8_t *)&
_data, (uint8_t *)&_data,
sizeof(
struct spi_data_s)) ==
OK) {
124 return &(_data.data);
135 if (transfer((uint8_t *)&_cal, (uint8_t *)&_cal,
sizeof(
struct spi_calibration_s)) ==
OK) {
Namespace encapsulating all device framework classes, functions and data.
void init()
Activates/configures the hardware registers.
Shared defines for the bmp388 driver.
IBMP388 * bmp388_spi_interface(uint8_t busnum, uint32_t device)
static struct mpu9x50_data _data
IMU measurement data.