diff options
author | Em Shotton <matthewshotton88@gmail.com> | 2024-08-22 11:46:00 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-08-22 20:46:00 +0200 |
commit | d3af2b6074e8698b8b83f79758e23070a8b80002 (patch) | |
tree | ac89b6256ddbbe1ce4b5e3d5edcc4ae3b4165315 /src | |
parent | 256309063a39836e5c30b3e9eb2c3bcd3246bdec (diff) | |
download | ads1x1x-async-d3af2b6074e8698b8b83f79758e23070a8b80002.tar.gz ads1x1x-async-d3af2b6074e8698b8b83f79758e23070a8b80002.tar.xz ads1x1x-async-d3af2b6074e8698b8b83f79758e23070a8b80002.zip |
Update the terms "master/slave" to "controller/target" (#29)
* Update the terms "master/slave" to "controller/target" throughout to align with the i2c bus specification v.7
* Updated Changelog
* Change word casing
---------
Co-authored-by: Em Shotton <matthewfshotton@gmail.com>
Co-authored-by: Diego Barrios Romero <eldruin@gmail.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/construction.rs | 4 | ||||
-rw-r--r-- | src/lib.rs | 28 | ||||
-rw-r--r-- | src/types.rs | 28 |
3 files changed, 30 insertions, 30 deletions
diff --git a/src/construction.rs b/src/construction.rs index 13a2350..84ee8ad 100644 --- a/src/construction.rs +++ b/src/construction.rs @@ -1,6 +1,6 @@ //! Constructor/destructor functions. -use crate::{ic, mode, Ads1x1x, Config, FullScaleRange, SlaveAddr}; +use crate::{ic, mode, Ads1x1x, Config, FullScaleRange, TargetAddr}; use core::marker::PhantomData; macro_rules! impl_new_destroy { @@ -10,7 +10,7 @@ macro_rules! impl_new_destroy { I2C: embedded_hal::i2c::I2c<Error = E>, { /// Create a new instance of the device in OneShot mode. - pub fn $create(i2c: I2C, address: SlaveAddr) -> Self { + pub fn $create(i2c: I2C, address: TargetAddr) -> Self { Ads1x1x { i2c, address: address.bits(), @@ -88,10 +88,10 @@ //! //! ```no_run //! use linux_embedded_hal::I2cdev; -//! use ads1x1x::{Ads1x1x, SlaveAddr}; +//! use ads1x1x::{Ads1x1x, TargetAddr}; //! //! let dev = I2cdev::new("/dev/i2c-1").unwrap(); -//! let adc = Ads1x1x::new_ads1013(dev, SlaveAddr::default()); +//! let adc = Ads1x1x::new_ads1013(dev, TargetAddr::default()); //! // do something... //! //! // get the I2C device back @@ -102,20 +102,20 @@ //! //! ```no_run //! use linux_embedded_hal::I2cdev; -//! use ads1x1x::{Ads1x1x, SlaveAddr}; +//! use ads1x1x::{Ads1x1x, TargetAddr}; //! //! let dev = I2cdev::new("/dev/i2c-1").unwrap(); -//! let adc = Ads1x1x::new_ads1013(dev, SlaveAddr::Sda); +//! let adc = Ads1x1x::new_ads1013(dev, TargetAddr::Sda); //! ``` //! //! ### Make a one-shot measurement //! ```no_run -//! use ads1x1x::{channel, Ads1x1x, SlaveAddr}; +//! use ads1x1x::{channel, Ads1x1x, TargetAddr}; //! use linux_embedded_hal::I2cdev; //! use nb::block; //! //! let dev = I2cdev::new("/dev/i2c-1").unwrap(); -//! let mut adc = Ads1x1x::new_ads1013(dev, SlaveAddr::default()); +//! let mut adc = Ads1x1x::new_ads1013(dev, TargetAddr::default()); //! let measurement = block!(adc.read(channel::DifferentialA0A1)).unwrap(); //! println!("Measurement: {}", measurement); //! let _dev = adc.destroy_ads1013(); // get I2C device back @@ -128,10 +128,10 @@ //! //! ```no_run //! use linux_embedded_hal::I2cdev; -//! use ads1x1x::{Ads1x1x, ModeChangeError, SlaveAddr}; +//! use ads1x1x::{Ads1x1x, ModeChangeError, TargetAddr}; //! //! let dev = I2cdev::new("/dev/i2c-1").unwrap(); -//! let adc = Ads1x1x::new_ads1013(dev, SlaveAddr::default()); +//! let adc = Ads1x1x::new_ads1013(dev, TargetAddr::default()); //! match adc.into_continuous() { //! Err(ModeChangeError::I2C(e, adc)) => /* mode change failed handling */ panic!(), //! Ok(mut adc) => { @@ -148,10 +148,10 @@ //! //! ```no_run //! use linux_embedded_hal::I2cdev; -//! use ads1x1x::{Ads1x1x, DataRate16Bit, SlaveAddr}; +//! use ads1x1x::{Ads1x1x, DataRate16Bit, TargetAddr}; //! //! let dev = I2cdev::new("/dev/i2c-1").unwrap(); -//! let mut adc = Ads1x1x::new_ads1115(dev, SlaveAddr::default()); +//! let mut adc = Ads1x1x::new_ads1115(dev, TargetAddr::default()); //! adc.set_data_rate(DataRate16Bit::Sps860).unwrap(); //! ``` //! @@ -160,17 +160,17 @@ //! or goes above 1.5V in at least two consecutive conversions. Then the //! ALERT/RDY pin will be set high and it will be kept so until the //! measurement is read or an appropriate SMBus alert response is sent by -//! the master. +//! the controller. //! //! ```no_run //! use linux_embedded_hal::I2cdev; //! use ads1x1x::{ -//! Ads1x1x, SlaveAddr, ComparatorQueue, ComparatorPolarity, +//! Ads1x1x, TargetAddr, ComparatorQueue, ComparatorPolarity, //! ComparatorMode, ComparatorLatching, FullScaleRange //! }; //! //! let dev = I2cdev::new("/dev/i2c-1").unwrap(); -//! let address = SlaveAddr::default(); +//! let address = TargetAddr::default(); //! let mut adc = Ads1x1x::new_ads1015(dev, address); //! adc.set_comparator_queue(ComparatorQueue::Two).unwrap(); //! adc.set_comparator_polarity(ComparatorPolarity::ActiveHigh).unwrap(); @@ -224,7 +224,7 @@ mod types; use crate::types::Config; pub use crate::types::{ mode, Ads1x1x, ComparatorLatching, ComparatorMode, ComparatorPolarity, ComparatorQueue, - DataRate12Bit, DataRate16Bit, Error, FullScaleRange, ModeChangeError, SlaveAddr, + DataRate12Bit, DataRate16Bit, Error, FullScaleRange, ModeChangeError, TargetAddr, }; mod private { diff --git a/src/types.rs b/src/types.rs index 6edddd5..1e4b075 100644 --- a/src/types.rs +++ b/src/types.rs @@ -117,9 +117,9 @@ pub enum ComparatorLatching { /// Latching /// /// The asserted ALERT/RDY pin remains latched until conversion data are - /// read by the master or an appropriate SMBus alert response is sent by - /// the master. The device responds with its address, and it is the lowest - /// address currently asserting the ALERT/RDY bus line. + /// read by the controller or an appropriate SMBus alert response is sent by + /// the controller. The device responds with its address, and it is the + /// lowest address currently asserting the ALERT/RDY bus line. Latching, } @@ -160,11 +160,11 @@ pub enum FullScaleRange { Within0_256V, } -/// A slave address. +/// A target address. /// /// See [Table 4 in the datasheet](https://www.ti.com/lit/ds/symlink/ads1115.pdf#%5B%7B%22num%22%3A716%2C%22gen%22%3A0%7D%2C%7B%22name%22%3A%22XYZ%22%7D%2C0%2C602.2%2C0%5D). #[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Ord, PartialOrd, Hash)] -pub enum SlaveAddr { +pub enum TargetAddr { /// Address when the ADDR pin is connected to GND. (default) #[default] Gnd, @@ -180,7 +180,7 @@ pub enum SlaveAddr { Scl, } -impl SlaveAddr { +impl TargetAddr { pub(crate) const fn bits(self) -> u8 { match self { Self::Gnd => 0b1001000, @@ -235,19 +235,19 @@ pub struct Ads1x1x<I2C, IC, CONV, MODE> { #[cfg(test)] mod tests { - use crate::{FullScaleRange, SlaveAddr}; + use crate::{FullScaleRange, TargetAddr}; #[test] - fn slave_addr_default() { - assert_eq!(0b100_1000, SlaveAddr::default().bits()); + fn target_addr_default() { + assert_eq!(0b100_1000, TargetAddr::default().bits()); } #[test] - fn slave_addr_bits() { - assert_eq!(0b100_1000, SlaveAddr::Gnd.bits()); - assert_eq!(0b100_1001, SlaveAddr::Vdd.bits()); - assert_eq!(0b100_1010, SlaveAddr::Sda.bits()); - assert_eq!(0b100_1011, SlaveAddr::Scl.bits()); + fn target_addr_bits() { + assert_eq!(0b100_1000, TargetAddr::Gnd.bits()); + assert_eq!(0b100_1001, TargetAddr::Vdd.bits()); + assert_eq!(0b100_1010, TargetAddr::Sda.bits()); + assert_eq!(0b100_1011, TargetAddr::Scl.bits()); } #[test] |