Struct Bme280Bus

Source
pub struct Bme280Bus<SPI, CS> { /* private fields */ }
Expand description

BME280 bus.

Implementations§

Source§

impl<SPI, CS, SpiError, PinError> Bme280Bus<SPI, CS>
where SPI: Transfer<u8, Error = SpiError> + Write<u8, Error = SpiError>, CS: OutputPin<Error = PinError>,

Source

pub fn new(bus: SPI, cs: CS) -> Self

Creates a new Bme280Bus from a SPI peripheral and a chip select digital I/O pin.

§Safety

The chip select pin must be high before being passed to this function.

§Example
use bme280_multibus::spi0::Bme280Bus;
use eh0::digital::v2::OutputPin;

pin.set_high()?;
let mut bme: Bme280Bus<_, _> = Bme280Bus::new(spi, pin);
Source

pub fn free(self) -> (SPI, CS)

Free the SPI bus and CS pin from the BME280.

§Example
use bme280_multibus::spi0::Bme280Bus;
use eh0::digital::v2::OutputPin;

pin.set_high()?;
let mut bme: Bme280Bus<_, _> = Bme280Bus::new(spi, pin);
let (mut spi, mut pin) = bme.free();

Trait Implementations§

Source§

impl<SPI, CS, SpiError, PinError> Bme280Bus for Bme280Bus<SPI, CS>
where SPI: Transfer<u8, Error = SpiError> + Write<u8, Error = SpiError>, CS: OutputPin<Error = PinError>,

Source§

type Error = Error<SpiError, PinError>

BME280 bus error.
Source§

fn read_regs(&mut self, reg: u8, buf: &mut [u8]) -> Result<(), Self::Error>

Read from the BME280. Read more
Source§

fn write_reg(&mut self, reg: u8, data: u8) -> Result<(), Self::Error>

Write a single register to the BME280. Read more
Source§

fn calibration(&mut self) -> Result<Calibration, Self::Error>

Read the calibration from the chip.
Source§

impl<SPI: Debug, CS: Debug> Debug for Bme280Bus<SPI, CS>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<SPI, CS> Freeze for Bme280Bus<SPI, CS>
where SPI: Freeze, CS: Freeze,

§

impl<SPI, CS> RefUnwindSafe for Bme280Bus<SPI, CS>
where SPI: RefUnwindSafe, CS: RefUnwindSafe,

§

impl<SPI, CS> Send for Bme280Bus<SPI, CS>
where SPI: Send, CS: Send,

§

impl<SPI, CS> Sync for Bme280Bus<SPI, CS>
where SPI: Sync, CS: Sync,

§

impl<SPI, CS> Unpin for Bme280Bus<SPI, CS>
where SPI: Unpin, CS: Unpin,

§

impl<SPI, CS> UnwindSafe for Bme280Bus<SPI, CS>
where SPI: UnwindSafe, CS: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.