• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

eldruin / tmp1x2-rs / 14848527695

05 May 2025 11:45PM UTC coverage: 85.638% (+2.4%) from 83.24%
14848527695

Pull #4

github

web-flow
Merge ab27dc263 into a957da873
Pull Request #4: Add async support

49 of 58 new or added lines in 3 files covered. (84.48%)

16 existing lines in 4 files now uncovered.

161 of 188 relevant lines covered (85.64%)

2.38 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

88.89
/src/interface.rs
1
use crate::RegisterU16;
2
use crate::{Config, Error, Register, Tmp1x2};
3
#[cfg(feature="is_sync")]
4
use embedded_hal::i2c;
5
#[cfg(not(feature="is_sync"))]
6
use embedded_hal_async::i2c;
7

8
#[maybe_async::maybe_async]
9
impl<I2C, E, MODE> Tmp1x2<I2C, MODE>
10
where
11
    I2C: i2c::I2c<Error = E>,
12
{
13
    pub(crate) async fn write_config(&mut self, data: Config) -> Result<(), Error<E>> {
12✔
14
        self.write_register(Register::CONFIG, data.clone()).await?;
6✔
15
        self.config = data;
3✔
16
        Ok(())
3✔
17
    }
18

19
    pub(crate) async fn write_register(
4✔
20
        &mut self,
21
        register: u8,
22
        data: RegisterU16,
23
    ) -> Result<(), Error<E>> {
24
        self.i2c
20✔
25
            .write(self.address, &[register, data.msb, data.lsb])
8✔
26
            .await
12✔
UNCOV
27
            .map_err(Error::I2C)
×
28
    }
29

30
    pub(crate) async fn read_register_u16(&mut self, register: u8) -> Result<RegisterU16, Error<E>> {
8✔
31
        let mut data = [0; 2];
2✔
32
        self.i2c
10✔
33
            .write_read(self.address, &[register], &mut data)
4✔
34
            .await
6✔
UNCOV
35
            .map_err(Error::I2C)?;
×
36
        Ok(RegisterU16 {
2✔
37
            msb: data[0],
4✔
38
            lsb: data[1],
2✔
39
        })
40
    }
41
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc