tmp108/
lib.rs

1//! This is a platform-agnostic Rust driver for the TMP108 temperature sensor
2//! based on the [`embedded-hal`] traits.
3//!
4//! [`embedded-hal`]: https://docs.rs/embedded-hal
5//!
6//! For further details of the device architecture and operation, please refer
7//! to the official [`Datasheet`].
8//!
9//! [`Datasheet`]: https://www.ti.com/lit/gpn/tmp108
10
11#![doc(html_root_url = "https://docs.rs/tmp108/latest")]
12#![doc = include_str!("../README.md")]
13#![cfg_attr(not(test), no_std)]
14
15mod registers;
16pub use registers::*;
17
18#[cfg(feature = "async")]
19pub mod asynchronous;
20
21pub mod blocking;
22
23/// A0 pin logic level representation.
24#[derive(Debug)]
25pub enum A0 {
26    /// A0 tied to GND (default).
27    Gnd,
28    /// A0 tied to V+.
29    Vplus,
30    /// A0 tied to SDA.
31    Sda,
32    /// A0 tied to SCL.
33    Scl,
34}
35
36impl Default for A0 {
37    fn default() -> Self {
38        Self::Gnd
39    }
40}
41
42impl From<A0> for u8 {
43    fn from(connection: A0) -> Self {
44        match connection {
45            A0::Gnd => 0b100_1000,
46            A0::Vplus => 0b100_1001,
47            A0::Sda => 0b100_1010,
48            A0::Scl => 0b100_1011,
49        }
50    }
51}