/// Initialize the LIS3DH accelerometer using the correct pins and
// peripherals. Use the driver's default settings.
Initialize the LIS3DH accelerometer using the correct pins and
peripherals. Use the driver's default settings.
Initialize the LIS3DH accelerometer using the correct pins and peripherals . Use the driver ' s default settings .
pub fn init(
        self,
        clocks: &mut GenericClockController,
        sercom4: SERCOM4,
        mclk: &mut MCLK,
    ) -> Lis3dh<i2c::I2c<i2c::Config<I2cPads>>> {
        // The accelerometer is connected to the Wio Terminal's `I2C0` bus, so
        // based on the possible padouts listed in the datasheet it must use
        // `SERCOM4`.
        let gclk0 = clocks.gclk0();
        let clock = &clocks.sercom4_core(&gclk0).unwrap();
        let freq = clock.freq();
        let (sda, scl): (I2c0Sda, I2c0Scl) = (self.sda.into(), self.scl.into());
        let pads: I2cPads = i2c::Pads::new(sda, scl);
        let i2c = i2c::Config::new(mclk, sercom4, pads, freq)
            .baud(400.khz())
            .enable();
        // The schematic states that the alternate I2C address `0x19` is used,
        // but that doesn't appear to work!
        Lis3dh::new(i2c, SlaveAddr::Default).unwrap()
    }
pub fn init ( self , clocks : & mut GenericClockController , sercom4 : SERCOM4 , mclk : & mut MCLK , ) -> Lis3dh < i2c :: I2c < i2c :: Config < I2cPads > > > { // The accelerometer is connected to the Wio Terminal's `I2C0` bus, so // based on the possible padouts listed in the datasheet it must use // `SERCOM4`. let gclk0 = clocks . gclk0 ( ) ; let clock = & clocks . sercom4_core ( & gclk0 ) . unwrap ( ) ; let freq = clock . freq ( ) ; let ( sda , scl ) : ( I2c0Sda , I2c0Scl ) = ( self . sda . into ( ) , self . scl . into ( ) ) ; let pads : I2cPads = i2c :: Pads :: new ( sda , scl ) ; let i2c = i2c :: Config :: new ( mclk , sercom4 , pads , freq ) . baud ( 400 . khz ( ) ) . enable ( ) ; // The schematic states that the alternate I2C address `0x19` is used, // but that doesn't appear to work! Lis3dh :: new ( i2c , SlaveAddr :: Default ) . unwrap ( ) }
Initialize the LIS3DH accelerometer using the correct pins and
peripherals.
Initialize the LIS3DH accelerometer using the correct pins and peripherals .
self
clocks
&mut GenericClockController
sercom4
SERCOM4
mclk
&mut MCLK