Skip to content

Commit

Permalink
Improve docs.
Browse files Browse the repository at this point in the history
  • Loading branch information
reitermarkus committed Jan 19, 2024
1 parent a49cba8 commit f52e787
Show file tree
Hide file tree
Showing 9 changed files with 23 additions and 28 deletions.
4 changes: 2 additions & 2 deletions src/devices/common.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//! Common functions
//! Common functions.

use crate::{register::Config, Ads1013, Ads1014, Ads1015, Ads1113, Ads1114, Ads1115, Error};

Expand All @@ -8,7 +8,7 @@ macro_rules! impl_common_features {
where
I2C: embedded_hal::i2c::I2c<Error = E>,
{
/// Read whether a measurement is currently in progress.
/// Checks whether a measurement is currently in progress.
pub fn is_measurement_in_progress(&mut self) -> Result<bool, Error<E>> {
let config = self.read_reg_u16::<Config>()?;
Ok(!config.contains(Config::OS))
Expand Down
3 changes: 1 addition & 2 deletions src/devices/features/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
//! Implementation of IC features separated in tiers depending on the hardware
//! support.
//! Implementation of IC features separated in tiers depending on the hardware support.

mod tier1;
mod tier2;
2 changes: 0 additions & 2 deletions src/devices/features/tier1.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
//! Common functions

use crate::{
Ads1013, Ads1014, Ads1015, Ads1113, Ads1114, Ads1115, DataRate12Bit, DataRate16Bit, Error,
};
Expand Down
13 changes: 5 additions & 8 deletions src/devices/features/tier2.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
//! Tier 2 features.
//!
//! These are the features included only in ADS1x14, ADS1x15
//! Features only included in ADS1x14, ADS1x15.

use crate::{
register::{Config, Conversion12, Conversion16, HiThresh, LoThresh},
Expand Down Expand Up @@ -140,13 +138,12 @@ macro_rules! impl_tier2_features {
Ok(())
}

/// Sets the ALERT/RDY pin as conversion-ready pin.
/// Enables the ALERT/RDY pin as conversion-ready function.
///
/// This the ALERT/RDY pin outputs the OS bit when in OneShot mode, and
/// provides a continuous-conversion ready pulse when in
/// continuous-conversion mode.
/// When in one-shot mode, this makes the ALERT/RDY pin output the OS bit,
/// in continuous-conversion mode, provides a continuous-conversion ready pulse.
///
/// When calling this the comparator will be disabled and the thresholds will be cleared.
/// When calling this the comparator will be disabled and any thresholds will be cleared.
pub fn use_alert_rdy_pin_as_ready(&mut self) -> Result<(), Error<E>> {
if !self.config.contains(Config::COMP_QUE)
{
Expand Down
4 changes: 2 additions & 2 deletions src/devices/mode/continuous.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//! Continuous measurement mode
//! Continuous measurement mode.

use crate::{
mode,
Expand All @@ -13,7 +13,7 @@ macro_rules! impl_continuous {
where
I2C: embedded_hal::i2c::I2c<Error = E>,
{
/// Changes operating mode to `OneShot`.
/// Changes to one-shot operating mode.
///
/// On error, returns a pair of the error and the current instance.
pub fn into_one_shot(mut self) -> Result<$Ads<I2C, mode::OneShot>, (Error<E>, Self)> {
Expand Down
2 changes: 0 additions & 2 deletions src/devices/mode/mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@
//! Functions for all devices specific to each operating mode

mod continuous;
mod oneshot;
5 changes: 3 additions & 2 deletions src/devices/mode/oneshot.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
//! Common functions
//! One-shot measurement mode.

use core::marker::PhantomData;

use crate::{
Expand All @@ -13,7 +14,7 @@ macro_rules! impl_one_shot {
where
I2C: embedded_hal::i2c::I2c<Error = E>,
{
/// Change operating mode to Continuous
/// Changes to continuous operating mode.
///
/// On error, returns a pair of the error and the current instance.
pub fn into_continuous(
Expand Down
4 changes: 3 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,9 @@
//! let i2c = I2cdev::new("/dev/i2c-1").unwrap();
//! let adc = Ads1013::new(i2c, SlaveAddr::default());
//! match adc.into_continuous() {
//! Err((e, adc)) => /* mode change failed handling */ panic!(),
//! Err((e, adc)) => {
//! panic!("Mode change failed: {e}")
//! },
//! Ok(mut adc) => {
//! let measurement = adc.read().unwrap();
//! // ...
Expand Down
14 changes: 7 additions & 7 deletions src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ pub enum Error<E> {
InvalidInputData,
}

/// Data rate for ADS1013, ADS1014, ADS1015
/// Data rate for ADS101x.
#[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Ord, PartialOrd, Hash)]
pub enum DataRate12Bit {
/// 128 SPS
Expand Down Expand Up @@ -66,7 +66,7 @@ impl DataRate12Bit {
}
}

/// Data rate for ADS1113, ADS1114, ADS1115
/// Data rate for ADS111x.
#[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Ord, PartialOrd, Hash)]
pub enum DataRate16Bit {
/// 8 SPS
Expand Down Expand Up @@ -124,7 +124,7 @@ impl DataRate16Bit {
}
}

/// Comparator mode (only for ADS1x14, ADS1x15)
/// Comparator mode (only for ADS1x14, ADS1x15).
#[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Ord, PartialOrd, Hash)]
pub enum ComparatorMode {
#[default]
Expand All @@ -143,7 +143,7 @@ pub enum ComparatorMode {
Window,
}

/// Comparator polarity (only for ADS1x14, ADS1x15)
/// Comparator polarity (only for ADS1x14, ADS1x15).
#[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Ord, PartialOrd, Hash)]
pub enum ComparatorPolarity {
#[default]
Expand All @@ -153,7 +153,7 @@ pub enum ComparatorPolarity {
ActiveHigh,
}

/// Comparator polarity (only for ADS1x14, ADS1x15)
/// Comparator latching (only for ADS1x14, ADS1x15).
///
/// Select whether the ALERT/RDY pin latches after being asserted or clears
/// after conversions are within the margin of the upper and lower
Expand All @@ -174,7 +174,7 @@ pub enum ComparatorLatching {
Latching,
}

/// Comparator alert queue (only for ADS1x14, ADS1x15)
/// Comparator alert queue (only for ADS1x14, ADS1x15).
///
/// The default state of the comparator is deactivated. It can be activated by setting
/// the comparator queue.
Expand All @@ -189,7 +189,7 @@ pub enum ComparatorQueue {
Four,
}

/// Full-scale range configuration for the programmable gain amplifier (PGA) (only for ADS1x14, ADS1x15)
/// Full-scale range configuration for the programmable gain amplifier (PGA) (only for ADS1x14, ADS1x15).
///
/// This sets the input voltage measurable range.
/// The FSR is fixed at ±2.048 V in the ADS1x13.
Expand Down

0 comments on commit f52e787

Please sign in to comment.