[][src]Crate max3010x

This is a platform agnostic Rust driver for the MAX3010x high-sensitivity pulse oximeter and heart-rate sensor for wearable health, based on the embedded-hal traits.

This driver allows you to:

The device

The MAX30102 is an integrated pulse oximetry and heart-rate monitor module. It includes internal LEDs, photodetectors, optical elements, and low-noise electronics with ambient light rejection. The MAX30102 provides a complete system solution to ease the design-in process for mobile and wearable devices.

The MAX30102 operates on a single 1.8V power supply and a separate 3.3V power supply for the internal LEDs. Communication is through a standard I2C-compatible interface. The module can be shut down through software with zero standby current, allowing the power rails to remain powered at all times.

Datasheet:

Usage examples (see also examples folder)

To use this driver, import this crate and an embedded_hal implementation, then instantiate the device.

Please find additional examples using hardware in this repository: driver-examples

Read samples in heart-rate mode

extern crate linux_embedded_hal as hal;
extern crate max3010x;
use max3010x::{Max3010x, Led, SampleAveraging};

let dev = hal::I2cdev::new("/dev/i2c-1").unwrap();
let mut sensor = Max3010x::new_max30102(dev);
let mut sensor = sensor.into_heart_rate().unwrap();
sensor.set_sample_averaging(SampleAveraging::Sa4).unwrap();
sensor.set_pulse_amplitude(Led::All, 15).unwrap();
sensor.enable_fifo_rollover().unwrap();
let mut data = [0; 3];
let samples_read = sensor.read_fifo(&mut data).unwrap();

// get the I2C device back
let dev = sensor.destroy();

Set led slots in multi-led mode

extern crate linux_embedded_hal as hal;
extern crate max3010x;
use max3010x::{ Max3010x, Led, TimeSlot };

let dev = hal::I2cdev::new("/dev/i2c-1").unwrap();
let mut max30102 = Max3010x::new_max30102(dev);
let mut max30102 = max30102.into_multi_led().unwrap();
max30102.set_pulse_amplitude(Led::All, 15).unwrap();
max30102.set_led_time_slots([
    TimeSlot::Led1,
    TimeSlot::Led2,
    TimeSlot::Led1,
    TimeSlot::Disabled
]).unwrap();
max30102.enable_fifo_rollover().unwrap();
let mut data = [0; 2];
let samples_read = max30102.read_fifo(&mut data).unwrap();

// get the I2C device back
let dev = max30102.destroy();

Structs

InterruptStatus

Interrupt status flags

Max3010x

MAX3010x device driver.

Enums

AdcRange

ADC range

Error

All possible errors in this crate

FifoAlmostFullLevelInterrupt

Number of empty data samples when the FIFO almost full interrupt is issued.

Led

LEDs

LedPulseWidth

LED pulse width (determines ADC resolution)

SampleAveraging

Sample averaging

SamplingRate

Sampling rate

TimeSlot

Multi-LED mode sample time slot configuration