Trait bme280_multibus::Bme280Bus
source · [−]pub trait Bme280Bus {
type Error;
fn read_regs(&mut self, reg: u8, buf: &mut [u8]) -> Result<(), Self::Error>;
fn write_reg(&mut self, reg: u8, data: u8) -> Result<(), Self::Error>;
fn calibration(&mut self) -> Result<Calibration, Self::Error> { ... }
}Expand description
BME280 bus, I2C or SPI.
Required Associated Types
Required Methods
Read from the BME280.
I2C
Read example (BME280 Datasheet Figure 10: I2C multiple byte read)
+-------+---------------+----+------+------------------+------+
| Start | Slave Address | RW | ACKS | Register Address | ACKS |
+-------+---------------+----+------+------------------+------+
| S | 111011x | 0 | | xxxxxxxx | |
+-------+---------------+----+------+------------------+------+
+-------+---------------+----+------+---------------+------+---------------+--------+------+
... | Start | Slave Address | RW | ACKS | Register Data | ACKM | Register Data | NOACKM | Stop |
+-------+---------------+----+------+---------------+------+---------------+--------+------+
... | S | 111011x | 1 | | xxxxxxxx | | xxxxxxxx | | P |
+-------+---------------+----+------+---------------+------+---------------+--------+------+SPI
Read example (BME280 Datasheet Figure 13: SPI multiple byte read)
+-------+----+------------------+---------------+
| Start | RW | Register Address | Register Data |
+-------+----+------------------+---------------+
| CSB=0 | 1 | xxxxxxx | xxxxxxxx |
+-------+----+------------------+---------------+
+---------------+-------+
... | Register Data | Stop |
+---------------+-------+
... | xxxxxxxx | CSB=0 |
+---------------+-------+Write a single register to the BME280.
I2C
Write example (BME280 Datasheet Figure 9: I2C multiple byte write)
+-------+---------------+----+------+------------------+------+---------------+------+
| Start | Slave Address | RW | ACKS | Register Address | ACKS | Register Data | ACKS |
+-------+---------------+----+------+------------------+------+---------------+------+
| S | 111011x | 0 | | xxxxxxxx | | xxxxxxxx | |
+-------+---------------+----+------+------------------+------+---------------+------+
+------------------+------+---------------+------+------+
... | Register Address | ACKS | Register Data | ACKS | Stop |
+------------------+------+---------------+------+------+
... | xxxxxxxx | | xxxxxxxx | | P |
+------------------+------+---------------+------+------+SPI
Write example (BME280 Datasheet Figure 12: SPI multiple byte write)
+-------+----+------------------+---------------+
| Start | RW | Register Address | Register Data |
+-------+----+------------------+---------------+
| CSB=0 | 0 | xxxxxxx | xxxxxxxx |
+-------+----+------------------+---------------+
+----+------------------+---------------+-------+
... | RW | Register Address | Register Data | Stop |
+----+------------------+---------------+-------+
... | 0 | xxxxxxx | xxxxxxxx | CSB=0 |
+----+------------------+---------------+-------+Provided Methods
fn calibration(&mut self) -> Result<Calibration, Self::Error>
fn calibration(&mut self) -> Result<Calibration, Self::Error>
Read the calibration from the chip.