Documentation
#![no_std]
use embedded_hal::{delay::DelayNs, i2c::I2c};
#[cfg(feature = "async")]
use embedded_hal_async::{delay::DelayNs as DelayNsAsync, i2c::I2c as I2cAsync};

pub fn crc8(data: &[u8]) -> u8 {
    let polynomial = 0x31u8; // x^8 + x^5 + x^4 + 1
    let mut crc = 0xFFu8;
    for &byte in data {
        crc ^= byte;
        for _ in 0..8 {
            if crc & 0x80 != 0 {
                crc = (crc << 1) ^ polynomial;
            } else {
                crc <<= 1;
            }
        }
    }
    crc
}

/// - [DHT20产品规格书(中文版) A3-202409.pdf](https://www.aosong.com/uploadfiles/2025/02/20250228161634702.pdf)
/// - [AHT20温湿度传感器说明书中文版C0-202407.pdf](https://www.aosong.com/uploadfiles/2025/05/20250526104654866.pdf)
/// - [AHT30温湿度传感器说明书(中)A4-202505.pdf](https://www.aosong.com/uploadfiles/2025/05/20250528154400146.pdf)
/// - [AHT40温湿度传感器说明书 A2-202506.pdf](https://www.aosong.com/uploadfiles/2025/09/20250901145507216.pdf)
/// - [AHT20-F温湿度传感器说明书中文版 A3-202407.pdf](https://www.aosong.com/uploadfiles/2025/04/20250425154457582.pdf)
/// - [AHT25产品规格书中文版 A3.pdf](https://www.aosong.com/uploadfiles/2025/07/20250724093156529.pdf)
/// - [DHT11温湿度传感器说明书(中) A0-1208.pdf](https://www.aosong.com/uploadfiles/2025/03/20250305165717988.pdf)
/// - [AHT2系列温湿度传感器IIC例程.zip](https://www.aosong.com/uploadfiles/2025/02/20250211143151669.zip) - 适用AHT2系列,AHT3系列,DHT20,DHT30,AM2315C,AM2301B
#[cfg(test)]
mod tests {
    use super::*;
    #[test]
    fn it_works() {
        let result = add(2, 2);
        assert_eq!(result, 4);
    }
}