1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
//! 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();
//! ```

#![deny(unsafe_code)]
#![cfg_attr(not(test), no_std)]

pub mod crc8;
pub mod i2c;