pub fn new(
    i2c: &mut I2C,
    delay: &mut Delay,
    config: super::config::BMI160Config,
  ) -> Result<Self, E> {
    let mut buf: [u8; 1] = [0; 1];
    hprintln!("BMI160: Reading chip id").unwrap();
    i2c.write_read(I2C_ADDRESS_PRIMARY, &[Register::ChipId.addr()], &mut buf)?;
    hprintln!(
      "BMI160: Read Chip ID -> {:?} <> Expected {}",
      buf,
      BMI160_CHIP_ID
    )
    .unwrap();
    let sensor = BMI160 {
      i2c: PhantomData,
      delay: PhantomData,
      addr: I2C_ADDRESS_PRIMARY,
      config: config,
    };
    // Perform a soft reset of the device
    hprintln!("BMI160: Soft reset").unwrap();
    i2c.write(
      sensor.addr,
      &[Register::Command.addr(), Command::SoftReset.val()],
    )?;
    delay.delay_ms(2);
    sensor.configure(i2c, delay)?;
    Ok(sensor)
  }
/// Creates a new driver from a I2C peripheral
/// Reads the chip id from register 0x00
Creates a new driver from a I2C peripheral
Reads the chip id from register 0x00
Creates a new driver from a I2C peripheral Reads the chip id from register 0x00
pub fn new(
    i2c: &mut I2C,
    delay: &mut Delay,
    config: super::config::BMI160Config,
  ) -> Result<Self, E> {
    let mut buf: [u8; 1] = [0; 1];
    hprintln!("BMI160: Reading chip id").unwrap();
    i2c.write_read(I2C_ADDRESS_PRIMARY, &[Register::ChipId.addr()], &mut buf)?;
    hprintln!(
      "BMI160: Read Chip ID -> {:?} <> Expected {}",
      buf,
      BMI160_CHIP_ID
    )
    .unwrap();
    let sensor = BMI160 {
      i2c: PhantomData,
      delay: PhantomData,
      addr: I2C_ADDRESS_PRIMARY,
      config: config,
    };
    // Perform a soft reset of the device
    hprintln!("BMI160: Soft reset").unwrap();
    i2c.write(
      sensor.addr,
      &[Register::Command.addr(), Command::SoftReset.val()],
    )?;
    delay.delay_ms(2);
    sensor.configure(i2c, delay)?;
    Ok(sensor)
  }
pub fn new ( i2c : & mut I2C , delay : & mut Delay , config : super :: config :: BMI160Config , ) -> Result < Self , E > { let mut buf : [ u8 ; 1 ] = [ 0 ; 1 ] ; hprintln ! ( " " ) . unwrap ( ) ; i2c . write_read ( I2C_ADDRESS_PRIMARY , & [ Register :: ChipId . addr ( ) ] , & mut buf ) ? ; hprintln ! ( " " buf BMI160_CHIP_ID ) . unwrap ( ) ; let sensor = BMI160 { i2c : PhantomData , delay : PhantomData , addr : I2C_ADDRESS_PRIMARY , config : config , } ; // Perform a soft reset of the device hprintln ! ( " " ) . unwrap ( ) ; i2c . write ( sensor . addr , & [ Register :: Command . addr ( ) , Command :: SoftReset . val ( ) ] , ) ? ; delay . delay_ms ( 2 ) ; sensor . configure ( i2c , delay ) ? ; Ok ( sensor ) }
Creates a new driver from a I2C peripheral
Reads the chip id from register 0x00
Creates a new driver from a I2C peripheral Reads the chip id from register 0x00
i2c
&mut I2C
delay
&mut Delay
config
super::config::BMI160Config
i2c
&mut I2C
delay
&mut Delay
config
super::config::BMI160Config