M5Unit-HEART 0.1.0 git rev:05c3b01
Loading...
Searching...
No Matches
m5::unit::UnitMAX30100 Class Reference

Pulse oximetry and heart-rate sensor. More...

#include <unit_MAX30100.hpp>

Inheritance diagram for m5::unit::UnitMAX30100:

Classes

struct  config_t
 Settings for begin. More...
 

Public Member Functions

 UnitMAX30100 (const uint8_t addr=DEFAULT_ADDRESS)
 
virtual bool begin () override
 
virtual void update (const bool force=false) override
 
uint32_t caluculateSamplingRate ()
 Calculate the sampling rate from the current settings.
 
bool reset ()
 Reset.
 
bool readRevisionID (uint8_t &rev)
 Read the revision ID.
 
Settings for begin
config_t config ()
 Gets the configration.
 
void config (const config_t &cfg)
 Set the configration.
 
Measurement data by periodic
uint16_t ir () const
 Oldest IR.
 
uint16_t red () const
 Oldest Red.
 
uint8_t retrived () const
 Number of data last retrieved.
 
uint8_t overflow () const
 The number of samples lost.
 
Periodic measurement
bool startPeriodicMeasurement ()
 Start periodic measurement in the current settings.
 
bool startPeriodicMeasurement (const max30100::Mode mode, const max30100::Sampling rate, const max30100::LEDPulse width, const max30100::LED ir_current, const bool high_resolution=false, const max30100::LED red_current=max30100::LED::Current0_0)
 Start periodic measurement.
 
bool stopPeriodicMeasurement ()
 Stop periodic measurement.
 
Mode Configuration
bool readMode (max30100::Mode &mode)
 Read the operation mode.
 
bool writeMode (const max30100::Mode mode)
 Write the operation mode.
 
bool readShutdownControl (bool &shdn)
 Read the shutdown control.
 
bool writeShutdownControl (const bool shdn)
 Write the shutdown control.
 
SpO2 Configuration
Note
Note that there are different combinations that can be set depending on the mode
  • Mode:SPO2
    Sampling\LEDPulseWidth 200 400 800 1600
    50 o o o o
    100 o o o o
    167 o o o x
    200 o o o x
    400 o o x x
    600 o x x x
    800 o x x x
    1000 o x x x
  • Mode:HROnly
    Sampling\LEDPulseWidth 200 400 800 1600
    50 o o o o
    100 o o o o
    167 o o o x
    200 o o o x
    400 o o x x
    600 o o x x
    800 o o x x
    1000 o o x x
bool readSpO2Configuration (bool &resolution, max30100::Sampling &rate, max30100::LEDPulse &width)
 Read the SpO2 configuration.
 
bool writeSpO2Configuration (const bool resolution, const max30100::Sampling rate, const max30100::LEDPulse width)
 Write the SpO2 configuration.
 
bool readSpO2HighResolution (bool &enabled)
 Read the SpO2 resolution mode.
 
bool writeSpO2HighResolution (const bool enabled)
 Write the SpO2 resolution mode.
 
bool writeSpO2HighResolutionEnable ()
 Write the SpO2 high resolution mode to enable.
 
bool writeSpO2HighResolutionDisable ()
 Write the SpO2 high resolution mode to disable.
 
bool readSpO2SamplingRate (max30100::Sampling &rate)
 Read the sampling rate.
 
bool writeSpO2SamplingRate (const max30100::Sampling rate)
 Write the sampling rate.
 
bool readSpO2LEDPulseWidth (max30100::LEDPulse &width)
 Write LED pulse width.
 
bool writeSpO2LEDPulseWidth (const max30100::LEDPulse width)
 Write LED pulse width.
 
LED Configuration
Warning
In the heart-rate only mode, the red LED is inactive
bool readLEDCurrent (max30100::LED &ir_current, max30100::LED &red_current)
 Read the LED curremt.
 
bool writeLEDCurrent (const max30100::LED ir_current, const max30100::LED red_current)
 Write the LED current.
 
Measurement temperature
bool measureTemperatureSingleshot (max30100::TemperatureData &td)
 Measure tempeature single shot.
 
FIFO
bool readFIFOReadPointer (uint8_t &rptr)
 Read the FIFO read pointer.
 
bool writeFIFOReadPointer (const uint8_t rptr)
 Write the FIFO read pointer.
 
bool readFIFOWritePointer (uint8_t &wptr)
 Read the FIFO write pointer.
 
bool writeFIFOWritePointer (const uint8_t wptr)
 Write the FIFO write pointer.
 
bool readFIFOOverflowCounter (uint8_t &cnt)
 Read the FIFO overflow counter.
 
bool writeFIFOOverflowCounter (const uint8_t cnt)
 Write the FIFO overflow counter.
 
bool resetFIFO ()
 Reset FIFO pointer and counter.
 

Protected Member Functions

bool read_register (const uint8_t reg, uint8_t *buf, const size_t len)
 
bool read_register8 (const uint8_t reg, uint8_t &v)
 
bool start_periodic_measurement ()
 
bool start_periodic_measurement (const max30100::Mode mode, const max30100::Sampling rate, const max30100::LEDPulse width, const max30100::LED ir_current, const bool resolution, const max30100::LED red_current)
 
bool stop_periodic_measurement ()
 
bool read_FIFO ()
 
bool read_measurement_temperature (max30100::TemperatureData &td)
 
bool write_spo2_configuration (const max30100::SpO2Configuration &sc)
 
 M5_UNIT_COMPONENT_PERIODIC_MEASUREMENT_ADAPTER_HPP_BUILDER (UnitMAX30100, max30100::Data)
 

Protected Attributes

max30100::Mode _mode {max30100::Mode::None}
 
uint8_t _retrived {}
 
uint8_t _overflow {}
 
std::unique_ptr< m5::container::CircularBuffer< max30100::Data > > _data {}
 
config_t _cfg {}
 

Detailed Description

Pulse oximetry and heart-rate sensor.

Note
The only single measurement is temperature; other data is constantly measured and stored

Member Function Documentation

◆ caluculateSamplingRate()

uint32_t m5::unit::UnitMAX30100::caluculateSamplingRate ( )

Calculate the sampling rate from the current settings.

Returns
>= 0 Sampling rate
Note
Calculate by SpO2 sampling rate

◆ measureTemperatureSingleshot()

bool m5::unit::UnitMAX30100::measureTemperatureSingleshot ( max30100::TemperatureData & td)

Measure tempeature single shot.

Parameters
[out]tdTemperatureData
Returns
True if successful
Warning
Blocking until measured about 29 ms
Does not work in power-save mode
See also
m5::unit::MAX30100::readShutdownControl

◆ overflow()

uint8_t m5::unit::UnitMAX30100::overflow ( ) const
inline

The number of samples lost.

Note
It saturates at (MAX_FIFO_DEPTH - 1)

◆ readLEDCurrent()

bool m5::unit::UnitMAX30100::readLEDCurrent ( max30100::LED & ir_current,
max30100::LED & red_current )

Read the LED curremt.

Parameters
[out]ir_currentIR current
[out]red_currentRed current
Returns
True if successful

◆ readMode()

bool m5::unit::UnitMAX30100::readMode ( max30100::Mode & mode)

Read the operation mode.

Parameters
[out]modeMode
Returns
True if successful

◆ readRevisionID()

bool m5::unit::UnitMAX30100::readRevisionID ( uint8_t & rev)

Read the revision ID.

Parameters
[out]revRevision
Returns
True if successful
Note
2-digit hexadecimal number (00 to FF) for part revision identification
Contact Maxim Integrated for the revision ID number assigned for your product

◆ readShutdownControl()

bool m5::unit::UnitMAX30100::readShutdownControl ( bool & shdn)

Read the shutdown control.

Parameters
[out]shdnShutdown control state (true:Power-save mode)
Returns
True if successful

◆ readSpO2Configuration()

bool m5::unit::UnitMAX30100::readSpO2Configuration ( bool & resolution,
max30100::Sampling & rate,
max30100::LEDPulse & width )

Read the SpO2 configuration.

Parameters
[out]resolutionSpO2 ADC resolution (true; high)
[out]rateSampling rate
[out]widthLED pulse width
Returns
True if successful

◆ reset()

bool m5::unit::UnitMAX30100::reset ( )

Reset.

Returns
True if successful
Warning
Blocked until the reset process is completed

◆ retrived()

uint8_t m5::unit::UnitMAX30100::retrived ( ) const
inline

Number of data last retrieved.

Note
The number of data retrieved by the latest update, not all data accumulated
See also
available()

◆ startPeriodicMeasurement() [1/2]

bool m5::unit::UnitMAX30100::startPeriodicMeasurement ( )
inline

Start periodic measurement in the current settings.

Returns
True if successful

◆ startPeriodicMeasurement() [2/2]

bool m5::unit::UnitMAX30100::startPeriodicMeasurement ( const max30100::Mode mode,
const max30100::Sampling rate,
const max30100::LEDPulse width,
const max30100::LED ir_current,
const bool high_resolution = false,
const max30100::LED red_current = max30100::LED::Current0_0 )
inline

Start periodic measurement.

Parameters
modeOperation mode
rateSampling rate
widthPulse width
ir_currentIR Led control
high_resolution(only SpO2)
red_currentRED Led control (only SpO2)
Returns
True if successful
Warning
Note that some combinations of rate and width are invalid. See also datasheet

◆ stopPeriodicMeasurement()

bool m5::unit::UnitMAX30100::stopPeriodicMeasurement ( )
inline

Stop periodic measurement.

Returns
True if successful

◆ writeLEDCurrent()

bool m5::unit::UnitMAX30100::writeLEDCurrent ( const max30100::LED ir_current,
const max30100::LED red_current )

Write the LED current.

Parameters
ir_currentIR current
red_currentRed current
Returns
True if successful

◆ writeMode()

bool m5::unit::UnitMAX30100::writeMode ( const max30100::Mode mode)

Write the operation mode.

Parameters
modeMode
Returns
True if successful
Warning
During periodic detection runs, an error is returned

◆ writeShutdownControl()

bool m5::unit::UnitMAX30100::writeShutdownControl ( const bool shdn)

Write the shutdown control.

Parameters
shdnShutdown control state (true:Power-save mode)
Returns
True if successful
Warning
During periodic detection runs, an error is returned

◆ writeSpO2Configuration()

bool m5::unit::UnitMAX30100::writeSpO2Configuration ( const bool resolution,
const max30100::Sampling rate,
const max30100::LEDPulse width )

Write the SpO2 configuration.

Parameters
resolutionSpO2 ADC resolution (true; high)
rateSampling rate
widthLED pulse width
Returns
True if successful