diff options
author | Markus Reiter <me@reitermark.us> | 2024-02-13 09:38:01 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-02-13 09:38:01 +0100 |
commit | 0ff4c7b448fd388015d4903b774c63991356b954 (patch) | |
tree | efadd00a0534ed0c86e456c9b65d67e6c63c5fae /src/lib.rs | |
parent | 3c2805fdb499202d4f52d0775de8837cded97131 (diff) | |
download | ads1x1x-async-0ff4c7b448fd388015d4903b774c63991356b954.tar.gz ads1x1x-async-0ff4c7b448fd388015d4903b774c63991356b954.tar.xz ads1x1x-async-0ff4c7b448fd388015d4903b774c63991356b954.zip |
Simplify `SlaveAddr`. (#21)
* Simplify `SlaveAddr`.
* Update changelog.
* Update CHANGELOG.md
---------
Co-authored-by: Diego Barrios Romero <eldruin@gmail.com>
Diffstat (limited to 'src/lib.rs')
-rw-r--r-- | src/lib.rs | 34 |
1 files changed, 6 insertions, 28 deletions
@@ -84,46 +84,28 @@ //! //! [driver-examples]: https://github.com/eldruin/driver-examples //! -//! ### Create a driver instance for the ADS1013 +//! ### Create a driver instance for an ADS1013 with the default address. //! //! ```no_run //! use linux_embedded_hal::I2cdev; //! use ads1x1x::{Ads1x1x, SlaveAddr}; //! //! let dev = I2cdev::new("/dev/i2c-1").unwrap(); -//! let address = SlaveAddr::default(); -//! let adc = Ads1x1x::new_ads1013(dev, address); +//! let adc = Ads1x1x::new_ads1013(dev, SlaveAddr::default()); //! // do something... //! //! // get the I2C device back //! let dev = adc.destroy_ads1013(); //! ``` //! -//! ### Create a driver instance for the ADS1013 with an alternative address (method 1) +//! ### Create a driver instance for an ADS1013 with the ADDR pin connected to SDA. //! //! ```no_run //! use linux_embedded_hal::I2cdev; //! use ads1x1x::{Ads1x1x, SlaveAddr}; //! //! let dev = I2cdev::new("/dev/i2c-1").unwrap(); -//! let (bit1, bit0) = (true, false); // last two bits of address -//! let address = SlaveAddr::Alternative(bit1, bit0); -//! let adc = Ads1x1x::new_ads1013(dev, address); -//! ``` - -//! ### Create a driver instance for the ADS1013 with an alternative address (method 2) -//! -//! Using helper `SlaveAddr` creation method depending on the connection of -//! the `ADDR` pin. -//! -//! ```no_run -//! use linux_embedded_hal::I2cdev; -//! use ads1x1x::{Ads1x1x, SlaveAddr}; -//! -//! let dev = I2cdev::new("/dev/i2c-1").unwrap(); -//! // `ADDR` pin connected to SDA results in the 0x4A effective address -//! let address = SlaveAddr::new_sda(); -//! let adc = Ads1x1x::new_ads1013(dev, address); +//! let adc = Ads1x1x::new_ads1013(dev, SlaveAddr::Sda); //! ``` //! //! ### Make a one-shot measurement @@ -149,8 +131,7 @@ //! use ads1x1x::{Ads1x1x, ModeChangeError, SlaveAddr}; //! //! let dev = I2cdev::new("/dev/i2c-1").unwrap(); -//! let address = SlaveAddr::default(); -//! let adc = Ads1x1x::new_ads1013(dev, address); +//! let adc = Ads1x1x::new_ads1013(dev, SlaveAddr::default()); //! match adc.into_continuous() { //! Err(ModeChangeError::I2C(e, adc)) => /* mode change failed handling */ panic!(), //! Ok(mut adc) => { @@ -170,8 +151,7 @@ //! use ads1x1x::{Ads1x1x, DataRate16Bit, SlaveAddr}; //! //! let dev = I2cdev::new("/dev/i2c-1").unwrap(); -//! let address = SlaveAddr::default(); -//! let mut adc = Ads1x1x::new_ads1115(dev, address); +//! let mut adc = Ads1x1x::new_ads1115(dev, SlaveAddr::default()); //! adc.set_data_rate(DataRate16Bit::Sps860).unwrap(); //! ``` //! @@ -204,8 +184,6 @@ #![deny(missing_docs)] #![no_std] -const DEVICE_BASE_ADDRESS: u8 = 0b100_1000; - struct Register; impl Register { const CONVERSION: u8 = 0x00; |