summaryrefslogtreecommitdiffstats
path: root/src/lib.rs
diff options
context:
space:
mode:
authorDiego Barrios Romero <eldruin@gmail.com>2018-11-10 09:40:36 +0100
committerDiego Barrios Romero <eldruin@gmail.com>2018-11-10 09:40:36 +0100
commit05bcf8a2c0aa4ae05b02c05aba9ab7177d8a68f3 (patch)
treeca11020b9777a481ee7716dbd5397c85fb0100a4 /src/lib.rs
parent4c184396d746bcb023b34568be9cf158bc9e9d02 (diff)
downloadads1x1x-async-05bcf8a2c0aa4ae05b02c05aba9ab7177d8a68f3.tar.gz
ads1x1x-async-05bcf8a2c0aa4ae05b02c05aba9ab7177d8a68f3.tar.xz
ads1x1x-async-05bcf8a2c0aa4ae05b02c05aba9ab7177d8a68f3.zip
Add usage examples for ADS1013
Diffstat (limited to 'src/lib.rs')
-rw-r--r--src/lib.rs40
1 files changed, 40 insertions, 0 deletions
diff --git a/src/lib.rs b/src/lib.rs
index 1766264..780efea 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -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)]