#spi-interface #ads1292 #ecg #ads1291 #ads1292-r

no-std ads129xx

德州仪器ADS1292 24位2通道低功耗模拟前端ECG应用驱动程序包

3个不稳定版本

0.2.1 2020年1月30日
0.2.0 2020年1月30日
0.1.1 2019年11月14日
0.1.0 2019年10月25日

#1463 in 嵌入式开发

自定义许可证

32KB
662

ADS129xx

德州仪器ADS1292 24位2通道低功耗模拟前端ECG应用驱动程序包。

此初始版本主要支持ADS1292,但目标是同时支持ADS1291和ADS1292R。

欢迎贡献!

使用示例

// spi: spi interface
// ncs: not-Chip-Select pin
// timer: timer, 500kHz timeout.

let spi_device = SpiDevice::new(spi, ncs, timer)?;
let mut ads = Ads1292::init(spi_device)?;

// 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.into_data_stream()?;

let mut buf = [[ChannelData::default(); 2]; 10];

// Opens stream, sends RDATAC command to ads
let data_stream = ads1292.into_data_stream()?;
ads.wait(200)?;

// A buffer to read data into
let mut buf = [[Ads1292Data::default(); 2]; 2000];

for i in buf.iter_mut() {
    // some way of finding out NDRDY has been low since last read (preferably by an interrupt-set flag)
    while !data_ready() {} 
    // data_stream always returns data (for now), so we can unwrap here
    *i = data_stream.next().unwrap()?;
}
// Don't forget to close; this will send the SDATAC command to the ads
data_stream.into_inner();

功能

  • 发送命令
ads1292.cmd(Command::START)?;
  • 写入寄存器
ads1292.write_register(Register::CONFIG1, 0b001)?;
  • 从寄存器读取
let lead_off_status = ads1292.read_register(Register::LOFF_STAT)?;
  • 读取数据
let data = ads1292.read_data()?;
  • 持续读取数据
// Opens stream, sends RDATAC command to ads
let data_stream = ads1292.into_data_stream()?;

let mut buf = [[Ads1292Data::default(); 2]; 2000];

for i in buf.iter_mut() {
    while !data_ready() {}
    *i = data_stream.next().unwrap().unwrap();
}
// Don't forget to close; this will send the SDATAC command to the ads
data_stream.into_inner();

待办事项

  • 支持ADS1292R
  • 支持ADS1291
  • 发送SPI命令后非阻塞等待
  • 文档
  • 分离设备特定和通用代码

依赖项

~110KB