libscd/lib.rs
1#![no_std]
2#![deny(unsafe_code)]
3#![deny(warnings)]
4#![deny(unused_must_use)]
5#![deny(unexpected_cfgs)]
6
7//! LibSCD is a crate providing both synchronous and asynchronous driver
8//! implementations for SCD30 and SCD4x CO2 sensors using the
9//! [embedded-hal](https://crates.io/crates/embedded-hal) and
10//! [embedded-hal-async](https://crates.io/crates/embedded-hal-async)
11//! interfaces
12//!
13//! ## Feature Flags
14//!
15//! - `defmt`: Derive `defmt::Format` for the error type
16//! - `sync`: Enable the blocking driver implementation for the selected sensors
17//! - `async`: Enable the async driver implementation for the selected sensors
18//! - `scd30`: Enable the driver for the SCD30 sensor
19//! - `scd4x`: Enable the driver for the SCD4x family of sensors
20//! - `scd41`: Enable additional features of the SCD4x driver that available only on SCD41 sensors
21
22/// Error type used by the library
23pub mod error;
24
25/// Shared measurement type used by the various sensors
26pub mod measurement;
27
28/// Synchronous (blocking) driver implementations using embedded-hal. This
29/// module needs to be enabled via the `sync` feature flag
30#[cfg(feature = "sync")]
31pub mod synchronous;
32
33/// Asynchronous driver implementations using embedded-hal-async. This
34/// module needs to be enabled via the `async` feature flag
35#[cfg(feature = "async")]
36pub mod asynchronous;
37
38/// Shared code across the sync/async implementations
39#[doc(hidden)]
40pub(crate) mod internal;
41
42/// SCD4x sensor variant.
43#[cfg(any(feature = "scd4x", feature = "scd41"))]
44#[cfg_attr(feature = "defmt", derive(defmt::Format))]
45#[derive(Copy, Clone, Debug, Eq, PartialEq, Hash)]
46#[non_exhaustive]
47pub enum SensorVariant {
48 Scd40,
49 Scd41,
50 Scd43,
51}
52
53#[cfg(not(all(
54 any(feature = "sync", feature = "async"),
55 any(feature = "scd30", feature = "scd4x", feature = "scd41")
56)))]
57compile_error!("You must select at least one sensor (scd30/scd4x/scd41) and at least one mode of operation (sync/async)");