#i2c #sensirion #sensors #crc-8

no-std sensirion-i2c

Common functionality for I2C based sensors from Sensirion

4 releases (2 breaking)

0.3.0 Feb 16, 2024
0.2.0 Nov 29, 2022
0.1.1 Sep 2, 2020
0.1.0 Aug 21, 2020

#109 in Hardware support

Download history 14/week @ 2024-01-22 12/week @ 2024-01-29 19/week @ 2024-02-05 164/week @ 2024-02-12 52/week @ 2024-02-19 56/week @ 2024-02-26 74/week @ 2024-03-04 137/week @ 2024-03-11 51/week @ 2024-03-18 30/week @ 2024-03-25 73/week @ 2024-04-01 63/week @ 2024-04-08 109/week @ 2024-04-15 140/week @ 2024-04-22 149/week @ 2024-04-29 175/week @ 2024-05-06

580 downloads per month
Used in 12 crates

BSD-3-Clause

10KB
146 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::eh1::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_u16(&mut i2c_mock, 0x12, 0x3456);
i2c_mock.done();

Dependencies

~56KB