# iis2dlpc-rs **Repository Path**: mirrors_STMicroelectronics/iis2dlpc-rs ## Basic Information - **Project Name**: iis2dlpc-rs - **Description**: iis2dlpc platform independent driver based on Rust programming language - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: main - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2025-08-13 - **Last Updated**: 2026-02-14 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # iis2dlpc-rs [![Crates.io][crates-badge]][crates-url] [![BSD 3-Clause licensed][bsd-badge]][bsd-url] [crates-badge]: https://img.shields.io/crates/v/iis2dlpc-rs [crates-url]: https://crates.io/crates/iis2dlpc-rs [bsd-badge]: https://img.shields.io/crates/l/iis2dlpc-rs [bsd-url]: https://opensource.org/licenses/BSD-3-Clause Provides a platform-agnostic, no_std-compatible driver for the ST IIS2DLPC sensor, supporting both I2C and SPI communication interfaces. ## Sensor Overview The IIS2DLPC is an ultra-low-power high-performance three-axis linear accelerometer with digital I²C/SPI output interface which leverages on the robust and mature manufacturing processes already used for the production of micromachined accelerometers. The IIS2DLPC has user-selectable full scales of ±2g/±4g/±8g/±16g and is capable of measuring accelerations with output data rates from 1.6 Hz to 1600 Hz. The IIS2DLPC has one high-performance mode and 4 low-power modes which can be changed on the fly, providing outstanding versatility and adaptability to the requirements of the application. The IIS2DLPC has an integrated 32-level first-in, first-out (FIFO) buffer allowing the user to store data in order to limit intervention by the host processor. The embedded self-test capability allows the user to check the functioning of the sensor in the final application. The IIS2DLPC has a dedicated internal engine to process motion and acceleration detection including free-fall, wakeup, highly configurable single/double-tap recognition, activity/inactivity, stationary/motion detection, portrait/landscape detection and 6D/4D orientation. The IIS2DLPC is available in a small thin plastic land grid array package (LGA) and it is guaranteed to operate over an extended temperature range from -40 °C to +85 °C. For more info, please visit the device page at [https://www.st.com/en/mems-and-sensors/iis2dlpc.html](https://www.st.com/en/mems-and-sensors/iis2dlpc.html) ## Installation Add the driver to your `Cargo.toml` dependencies: ```toml [dependencies] iis2dlpc-rs = "2.0.0" ``` Or, add it directly from the terminal: ```sh cargo add iis2dlpc-rs ``` ## Usage By default, the create exposes the **asynchronous** API, and it could be included using: ```rust use iis2dlpc_rs::asynchronous as iis2dlpc; use iis2dlpc::*; use iis2dlpc::prelude::*; ``` ### Blocking API (optional feature) To use the **blocking** API instead of the asynchronous one, disable default features and enable the `blocking` feature in your Cargo.toml ```toml [dependencies] iis2dlpc-rs = { version = "2.0.0", default-features = false, features = ["blocking"] } ``` or from the terminal: ```sh cargo add iis2dlpc-rs --no-default-features --features blocking ``` Then import the blocking API: ```rust use iis2dlpc_rs::blocking as iis2dlpc; use iis2dlpc::*; use iis2dlpc::prelude::*; ``` ### Create an instance Create an instance of the driver with the `new_` associated function, by passing an I2C (`embedded_hal::i2c::I2c`) instance and I2C address, or an SPI (`embedded_hal::spi::SpiDevice`) instance, along with a timing peripheral. An example with I2C: ```rust let mut sensor = Iis2dlpc::new_i2c(i2c, I2CAddress::I2cAddH, delay); ``` ### Check "Who Am I" Register This step ensures correct communication with the sensor. It returns a unique ID to verify the sensor's identity. ```rust let whoami = sensor.device_id_get().unwrap(); if whoami != ID { panic!("Invalid sensor ID"); } ``` ### Configure See details in specific examples; the following are common api calls: ```rust // Restore default configuration sensor.reset_set().unwrap(); while sensor.reset_get().unwrap() == 1 {} // Enable Block Data Update sensor.block_data_update_set(PROPERTY_ENABLE).unwrap(); // Set Full scale sensor.full_scale_set(Fs::_8g).unwrap(); // Configure power mode sensor .power_mode_set(Mode::ContLowPwrLowNoise12bit) .unwrap(); // Set Output Data Rate sensor.data_rate_set(Odr::_25hz).unwrap(); ``` ## License Distributed under the BSD-3 Clause license. More Information: [http://www.st.com](http://st.com/MEMS). **Copyright (C) 2025 STMicroelectronics**