Skip to content

Commit c65f57c

Browse files
committed
Improve docs.
1 parent 461a55f commit c65f57c

File tree

12 files changed

+69
-71
lines changed

12 files changed

+69
-71
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
4949
When changing into continuous mode the measurements are started and to stop one
5050
can simply change into one-shot mode. (This is how the hardware does it anyway).
5151
The one-shot mode is not affected.
52-
When changing the mode an I2C communication error can occur but the unchanged device
52+
When changing the mode an I²C communication error can occur but the unchanged device
5353
can now be retrieved.
5454

5555
## [0.1.0] - 2018-11-21

README.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ thermocouples.
4848
The devices operate either in continuous-conversion mode, or in a
4949
single-shot mode that automatically powers down after a conversion.
5050
Single-shot mode significantly reduces current consumption during idle
51-
periods. Data is transferred through I2C.
51+
periods. Data is transferred through I²C.
5252

5353
Here is a comparison of the caracteristics of the devices:
5454

@@ -70,8 +70,7 @@ Datasheets:
7070
To use this driver, import this crate and an `embedded_hal` implementation,
7171
then instantiate the appropriate device.
7272
In the following examples an instance of the device ADS1013 will be created
73-
as an example. Other devices can be created with similar methods like:
74-
`Ads1x1x::new_ads1114(...)`.
73+
as an example.
7574

7675
Please find additional examples using hardware in this repository: [driver-examples]
7776

src/channel.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
//! ADC input channels
1+
//! ADC input channels.
2+
23
use crate::{ic, Ads1x1x, BitFlags as BF, Config};
34

45
use private::ChannelSelection;

src/devices/common.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//! Common functions
1+
//! Common functions.
22
33
use crate::{devices::OperatingMode, Ads1x1x, BitFlags, Config, Error, Register};
44

@@ -30,7 +30,7 @@ where
3030
Ok(())
3131
}
3232

33-
/// Read whether a measurement is currently in progress.
33+
/// Checks whether a measurement is currently in progress.
3434
pub fn is_measurement_in_progress(&mut self) -> Result<bool, Error<E>> {
3535
let config = Config {
3636
bits: self.read_register(Register::CONFIG)?,

src/devices/features/mod.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
//! Implementation of IC features separated in tiers depending on the hardware
2-
//! support.
1+
//! Implementation of IC features separated in tiers depending on the hardware support.
32
43
mod tier1;
54
mod tier2;

src/devices/features/tier1.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
1-
//! Common functions
2-
31
use crate::{ic, Ads1x1x, BitFlags as BF, DataRate12Bit, DataRate16Bit, Error, Register};
42

53
impl<I2C, IC, MODE, E> Ads1x1x<I2C, IC, ic::Resolution12Bit, MODE>
64
where
75
I2C: embedded_hal::i2c::I2c<Error = E>,
86
{
9-
/// Set data rate
7+
/// Sets the data rate.
108
pub fn set_data_rate(&mut self, rate: DataRate12Bit) -> Result<(), Error<E>> {
119
use crate::DataRate12Bit as DR;
1210
let cfg = self.config.clone();
@@ -29,7 +27,7 @@ impl<I2C, IC, MODE, E> Ads1x1x<I2C, IC, ic::Resolution16Bit, MODE>
2927
where
3028
I2C: embedded_hal::i2c::I2c<Error = E>,
3129
{
32-
/// Set data rate
30+
/// Sets the data rate.
3331
pub fn set_data_rate(&mut self, rate: DataRate16Bit) -> Result<(), Error<E>> {
3432
use crate::DataRate16Bit as DR;
3533
let cfg = self.config.clone();

src/devices/features/tier2.rs

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
//! Tier 2 features.
2-
//!
3-
//! These are the features included only in ADS1x14, ADS1x15
1+
//! Features only included in ADS1x14, ADS1x15.
42
53
use crate::{
64
conversion, ic, Ads1x1x, BitFlags as BF, ComparatorLatching, ComparatorMode,
@@ -13,9 +11,9 @@ where
1311
IC: ic::Tier2Features,
1412
CONV: conversion::ConvertThreshold<E>,
1513
{
16-
/// Set the input voltage measurable range
14+
/// Sets the input voltage measurable range.
1715
///
18-
/// This configures the programmable gain amplifier and determines the measurable input voltage range.
16+
/// This configures the programmable gain amplifier (PGA) and determines the measurable input voltage range.
1917
pub fn set_full_scale_range(&mut self, range: FullScaleRange) -> Result<(), Error<E>> {
2018
use crate::FullScaleRange as FSR;
2119
let cfg = self.config.clone();
@@ -47,29 +45,31 @@ where
4745
Ok(())
4846
}
4947

50-
/// Set raw comparator lower threshold
48+
/// Sets the raw comparator lower threshold.
49+
///
50+
/// The voltage that these values correspond to must be calculated using the
51+
/// full-scale range ([`FullScaleRange`]) selected.
5152
///
5253
/// The input value must be within `[2047..-2048]` for 12-bit devices (`ADS101x`)
53-
/// and within `[32767..-32768]` for 16-bit devices (`ADS111x`). The voltage that
54-
/// these values correspond to must be calculated using the full-scale range
55-
/// selected. See [`FullScaleRange`](enum.FullScaleRange.html).
54+
/// and within `[32767..-32768]` for 16-bit devices (`ADS111x`).
5655
pub fn set_low_threshold_raw(&mut self, value: i16) -> Result<(), Error<E>> {
5756
let register_value = CONV::convert_threshold(value)?;
5857
self.write_register(Register::LOW_TH, register_value)
5958
}
6059

61-
/// Set raw comparator upper threshold
60+
/// Sets the raw comparator upper threshold.
61+
///
62+
/// The voltage that these values correspond to must be calculated using the
63+
/// full-scale range ([`FullScaleRange`]) selected.
6264
///
6365
/// The input value must be within `[2047..-2048]` for 12-bit devices (`ADS101x`)
64-
/// and within `[32767..-32768]` for 16-bit devices (`ADS111x`). The voltage that
65-
/// these values correspond to must be calculated using the full-scale range
66-
/// selected. See [`FullScaleRange`](enum.FullScaleRange.html).
66+
/// and within `[32767..-32768]` for 16-bit devices (`ADS111x`).
6767
pub fn set_high_threshold_raw(&mut self, value: i16) -> Result<(), Error<E>> {
6868
let register_value = CONV::convert_threshold(value)?;
6969
self.write_register(Register::HIGH_TH, register_value)
7070
}
7171

72-
/// Set comparator mode
72+
/// Sets the comparator mode.
7373
pub fn set_comparator_mode(&mut self, mode: ComparatorMode) -> Result<(), Error<E>> {
7474
let config = match mode {
7575
ComparatorMode::Traditional => self.config.with_low(BF::COMP_MODE),
@@ -80,7 +80,7 @@ where
8080
Ok(())
8181
}
8282

83-
/// Set comparator polarity
83+
/// Sets the comparator polarity.
8484
pub fn set_comparator_polarity(
8585
&mut self,
8686
polarity: ComparatorPolarity,
@@ -94,7 +94,7 @@ where
9494
Ok(())
9595
}
9696

97-
/// Set comparator latching
97+
/// Sets the comparator latching.
9898
pub fn set_comparator_latching(
9999
&mut self,
100100
latching: ComparatorLatching,
@@ -108,9 +108,9 @@ where
108108
Ok(())
109109
}
110110

111-
/// Activate comparator and set the alert queue
111+
/// Activates the comparator and sets the alert queue.
112112
///
113-
/// The comparator can be disabled with [`disable_comparator()`](struct.Ads1x1x.html#method.disable_comparator)
113+
/// The comparator can be disabled with [`disable_comparator`](Self::disable_comparator).
114114
pub fn set_comparator_queue(&mut self, queue: ComparatorQueue) -> Result<(), Error<E>> {
115115
let config = match queue {
116116
ComparatorQueue::One => self.config.with_low(BF::COMP_QUE1).with_low(BF::COMP_QUE0),
@@ -122,11 +122,12 @@ where
122122
Ok(())
123123
}
124124

125-
/// Disable comparator (default)
125+
/// Disables the comparator. (default)
126+
///
127+
/// This sets the ALERT/RDY pin to high-impedance.
126128
///
127-
/// This will set the ALERT/RDY pin to high-impedance.
128-
/// The comparator can be enabled by setting the comparator queue.
129-
/// See [`set_comparator_queue()`](struct.Ads1x1x.html#method.set_comparator_queue)
129+
/// The comparator can be enabled by setting the comparator queue using
130+
/// the [`set_comparator_queue`](Self::set_comparator_queue) method.
130131
pub fn disable_comparator(&mut self) -> Result<(), Error<E>> {
131132
let config = self
132133
.config
@@ -137,13 +138,12 @@ where
137138
Ok(())
138139
}
139140

140-
/// Use the ALERT/RDY pin as conversion-ready pin.
141+
/// Enables the ALERT/RDY pin as conversion-ready function.
141142
///
142-
/// This the ALERT/RDY pin outputs the OS bit when in OneShot mode, and
143-
/// provides a continuous-conversion ready pulse when in
144-
/// continuous-conversion mode.
143+
/// When in one-shot mode, this makes the ALERT/RDY pin output the OS bit,
144+
/// in continuous-conversion mode, provides a continuous-conversion ready pulse.
145145
///
146-
/// When calling this the comparator will be reset to default and the thresholds will be cleared.
146+
/// When calling this the comparator will be reset to default and any thresholds will be cleared.
147147
pub fn use_alert_rdy_pin_as_ready(&mut self) -> Result<(), Error<E>> {
148148
if self.config
149149
!= self

src/devices/mode/continuous.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//! Continuous measurement mode
1+
//! Continuous measurement mode.
22
33
use crate::{
44
conversion, devices::OperatingMode, mode, Ads1x1x, ChannelId, Error, ModeChangeError, Register,
@@ -10,7 +10,7 @@ where
1010
I2C: embedded_hal::i2c::I2c<Error = E>,
1111
CONV: conversion::ConvertMeasurement,
1212
{
13-
/// Change operating mode to OneShot
13+
/// Changes to one-shot operating mode.
1414
pub fn into_one_shot(
1515
mut self,
1616
) -> Result<Ads1x1x<I2C, IC, CONV, mode::OneShot>, ModeChangeError<E, Self>> {
@@ -29,13 +29,13 @@ where
2929
})
3030
}
3131

32-
/// Read the most recent measurement
32+
/// Reads the most recent measurement.
3333
pub fn read(&mut self) -> Result<i16, Error<E>> {
3434
let value = self.read_register(Register::CONVERSION)?;
3535
Ok(CONV::convert_measurement(value))
3636
}
3737

38-
/// Select the channel for measurements.
38+
/// Selects the channel for measurements.
3939
///
4040
/// Note that when changing the channel in continuous conversion mode, the
4141
/// ongoing conversion will be completed.

src/devices/mode/mod.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,2 @@
1-
//! Functions for all devices specific to each operating mode
2-
31
mod continuous;
42
mod oneshot;

src/devices/mode/oneshot.rs

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,20 @@
1-
//! Common functions
1+
//! One-shot measurement mode.
2+
3+
use core::marker::PhantomData;
4+
25
use crate::{
36
conversion, devices::OperatingMode, mode, Ads1x1x, BitFlags, ChannelId, Config, Error,
47
ModeChangeError, Register,
58
};
6-
use core::marker::PhantomData;
79

810
impl<I2C, IC, CONV, E> Ads1x1x<I2C, IC, CONV, mode::OneShot>
911
where
1012
I2C: embedded_hal::i2c::I2c<Error = E>,
1113
CONV: conversion::ConvertMeasurement,
1214
{
13-
/// Change operating mode to Continuous
15+
/// Changes to continuous operating mode.
16+
///
17+
/// On error, returns a pair of the error and the current instance.
1418
pub fn into_continuous(
1519
mut self,
1620
) -> Result<Ads1x1x<I2C, IC, CONV, mode::Continuous>, ModeChangeError<E, Self>> {
@@ -40,13 +44,12 @@ where
4044
I2C: embedded_hal::i2c::I2c<Error = E>,
4145
CONV: conversion::ConvertMeasurement,
4246
{
43-
/// Request that the ADC begin a conversion on the specified channel.
47+
/// Requests that the ADC begins a conversion on the specified channel.
4448
///
4549
/// The output value will be within `[2047..-2048]` for 12-bit devices
4650
/// (`ADS101x`) and within `[32767..-32768]` for 16-bit devices (`ADS111x`).
4751
/// The voltage that these values correspond to must be calculated using
48-
/// the full-scale range selected.
49-
/// See [`FullScaleRange`](enum.FullScaleRange.html).
52+
/// the full-scale range ([`FullScaleRange`](crate::FullScaleRange)) selected.
5053
///
5154
/// Returns `nb::Error::WouldBlock` while a measurement is in progress.
5255
///

0 commit comments

Comments
 (0)