#i2c #sensirion

no-std sensirion-i2c

Common functionality for I2C based sensors from Sensirion

2 releases

0.1.1 Sep 2, 2020
0.1.0 Aug 21, 2020

#250 in No standard library

Download history 14/week @ 2021-02-25 15/week @ 2021-03-04 25/week @ 2021-03-11 35/week @ 2021-03-18 24/week @ 2021-03-25 8/week @ 2021-04-01 12/week @ 2021-04-08 17/week @ 2021-04-15 12/week @ 2021-04-22 13/week @ 2021-04-29 5/week @ 2021-05-06 7/week @ 2021-05-13 8/week @ 2021-05-20 9/week @ 2021-05-27 5/week @ 2021-06-03 18/week @ 2021-06-10

69 downloads per month
Used in 5 crates

BSD-3-Clause

7KB
107 lines

sensirion-i2c-rs

CircleCI Crates.io Version Crates.io Downloads No Std

Rust library with common functionality for I2C based sensors from Sensirion.


lib.rs:

Library with common functionality for I2C based sensors from Sensirion, based on the embedded-hal traits.

Usage

CRC8 calculation / validation

use sensirion_i2c::crc8;

let data = [0xbe, 0xef];
let crc = crc8::calculate(&data);

let data = [0xbe, 0xef, crc];
assert_eq!(Ok(()), crc8::validate(&data));

I2C

The I2C helpers work with any embedded_hal::i2c implementation.

use embedded_hal_mock::i2c::{Mock as I2cMock, Transaction as I2cTransaction};
use sensirion_i2c::i2c;

let expectations = [I2cTransaction::write(0x12, vec![0x34, 0x56])];
let mut i2c_mock = I2cMock::new(&expectations);
i2c::write_command(&mut i2c_mock, 0x12, 0x3456);

Dependencies

~82KB