42 #include <px4_platform_common/px4_config.h> 45 #if defined(PX4_SPIDEV_BARO) || defined(PX4_SPIDEV_EXT_BARO) 48 #define DIR_READ (1<<7) //for set 49 #define DIR_WRITE ~(1<<7) //for clear 57 struct spi_calibration_s {
66 BMP280_SPI(uint8_t bus, uint32_t
device);
67 virtual ~BMP280_SPI()
override =
default;
71 uint8_t get_reg(uint8_t addr)
override;
72 int set_reg(uint8_t value, uint8_t addr)
override;
77 uint32_t get_device_id()
const override {
return device::SPI::get_device_id(); }
80 spi_calibration_s _cal{};
87 return new BMP280_SPI(busnum, device);
90 BMP280_SPI::BMP280_SPI(uint8_t bus, uint32_t
device) :
91 SPI(
"BMP280_SPI", nullptr, bus, device,
SPIDEV_MODE3, 10 * 1000 * 1000)
96 BMP280_SPI::get_reg(uint8_t addr)
98 uint8_t cmd[2] = { (uint8_t)(addr |
DIR_READ), 0};
99 transfer(&cmd[0], &cmd[0], 2);
105 BMP280_SPI::set_reg(uint8_t value, uint8_t addr)
107 uint8_t cmd[2] = { (uint8_t)(addr &
DIR_WRITE), value};
108 return transfer(&cmd[0],
nullptr, 2);
112 BMP280_SPI::get_data(uint8_t addr)
116 if (transfer((uint8_t *)&
_data, (uint8_t *)&_data,
sizeof(spi_data_s)) ==
OK) {
117 return &(_data.data);
125 BMP280_SPI::get_calibration(uint8_t addr)
129 if (transfer((uint8_t *)&_cal, (uint8_t *)&_cal,
sizeof(spi_calibration_s)) ==
OK) {
bmp280::IBMP280 * bmp280_spi_interface(uint8_t busnum, uint32_t device)
Shared defines for the bmp280 driver.
Namespace encapsulating all device framework classes, functions and data.
void init()
Activates/configures the hardware registers.
static struct mpu9x50_data _data
IMU measurement data.