Driver crate for the Texas Instruments ADS1292 24-bit 2-channel low-power analog front end for ECG applications.
This initial version supports the ADS1292 (for the most part), but it's a goal to support the ADS1291 and ADS1292R as well.
Contributions welcome!
```rust // spi: spi interface // ncs: not-Chip-Select pin // timer: timer, 500kHz timeout.
let spidevice = SpiDevice::new(spi, ncs, timer)?; let mut ads = Ads1292::init(spidevice)?;
// start conversions ads.cmd(ads129xx::Command::START).unwrap(); ads.wait(200)?; // Wait a while in between sending commands ads.cmd(ads129xx::Command::RDATAC).unwrap(); ads.wait(200)?;
let mut stream = ads.intodatastream()?;
let mut buf = [[ChannelData::default(); 2]; 10];
// Opens stream, sends RDATAC command to ads let datastream = ads1292.intodata_stream()?; ads.wait(200)?;
// A buffer to read data into let mut buf = [[Ads1292Data::default(); 2]; 2000];
for i in buf.itermut() { // some way of finding out NDRDY has been low since last read (preferably by an interrupt-set flag) while !dataready() {} // datastream always returns data (for now), so we can unwrap here *i = datastream.next().unwrap()?; } // Don't forget to close; this will send the SDATAC command to the ads datastream.intoinner(); ```
rust
ads1292.cmd(Command::START)?;
rust
ads1292.write_register(Register::CONFIG1, 0b001)?;
rust
let lead_off_status = ads1292.read_register(Register::LOFF_STAT)?;
rust
let data = ads1292.read_data()?;
let mut buf = [[Ads1292Data::default(); 2]; 2000];
for i in buf.itermut() { while !dataready() {} *i = datastream.next().unwrap().unwrap(); } // Don't forget to close; this will send the SDATAC command to the ads datastream.into_inner(); ```