diff options
author | Diego Barrios Romero <eldruin@gmail.com> | 2018-11-10 09:40:36 +0100 |
---|---|---|
committer | Diego Barrios Romero <eldruin@gmail.com> | 2018-11-10 09:40:36 +0100 |
commit | 05bcf8a2c0aa4ae05b02c05aba9ab7177d8a68f3 (patch) | |
tree | ca11020b9777a481ee7716dbd5397c85fb0100a4 | |
parent | 4c184396d746bcb023b34568be9cf158bc9e9d02 (diff) | |
download | ads1x1x-async-05bcf8a2c0aa4ae05b02c05aba9ab7177d8a68f3.tar.gz ads1x1x-async-05bcf8a2c0aa4ae05b02c05aba9ab7177d8a68f3.tar.xz ads1x1x-async-05bcf8a2c0aa4ae05b02c05aba9ab7177d8a68f3.zip |
Add usage examples for ADS1013
-rw-r--r-- | src/lib.rs | 40 |
1 files changed, 40 insertions, 0 deletions
@@ -59,6 +59,46 @@ //! - [ADS111x](http://www.ti.com/lit/ds/symlink/ads1115.pdf) //! - [ADS1118](http://www.ti.com/lit/ds/symlink/ads1118.pdf) //! +//! ## Usage examples (see also examples folder) +//! +//! To use this driver, import this crate and an `embedded_hal` implementation, +//! then instantiate the appropriate device. +//! In the following examples an instance of the device ADS1013 will be created +//! as an example. Other devices can be created with similar methods like: +//! `Ads1x1x::new_ads1114(...)`. +//! +//! ### Create a driver instance for the ADS1013 +//! +//! ```no_run +//! extern crate linux_embedded_hal as hal; +//! extern crate ads1x1x; +//! use ads1x1x::{ Ads1x1x, SlaveAddr }; +//! +//! # fn main() { +//! let dev = hal::I2cdev::new("/dev/i2c-1").unwrap(); +//! let address = SlaveAddr::default(); +//! let rtc = Ads1x1x::new_ads1013(dev, address); +//! // do something... +//! +//! // get the I2C device back +//! let dev = rtc.destroy_ads1013(); +//! # } +//! ``` +//! +//! ### Create a driver instance for the ADS1013 with an alternative address +//! +//! ```no_run +//! extern crate linux_embedded_hal as hal; +//! extern crate ads1x1x; +//! use ads1x1x::{ Ads1x1x, SlaveAddr }; +//! +//! # fn main() { +//! let dev = hal::I2cdev::new("/dev/i2c-1").unwrap(); +//! let (a1, a0) = (true, false); +//! let address = SlaveAddr::Alternative(a1, a0); +//! let rtc = Ads1x1x::new_ads1013(dev, address); +//! # } +//! ``` #![deny(unsafe_code)] #![deny(missing_docs)] |