hts221-async 0.2.0

Async driver for the HTS221 temperature sensor.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#![allow(dead_code)]
use super::super::I2cAddress;
use embedded_hal_async::i2c::*;

const WHO_AM_I: u8 = 0x0F;

pub(crate) struct WhoAmI;

impl WhoAmI {
    pub async fn read<I: I2c>(address: I2cAddress, i2c: &mut I) -> Result<I2cAddress, I::Error> {
        let mut buf = [0; 1];
        let _ = i2c
            .write_read(address.into(), &[WHO_AM_I], &mut buf)
            .await?;
        Ok(buf[0].into())
    }
}