Greg Steiert / MAX30105

Dependents:   Temp_Prox_Demo

Embed: (wiki syntax)

« Back to documentation index

MAX30105 Class Reference

MAX30105 Class Reference

MAX30105 Optical Sensor. More...

#include <MAX30105.h>

Public Types

enum  registers_t {
  REG_INTR_STATUS_1 = 0x00, REG_INTR_STATUS_2 = 0x01, REG_INTR_ENABLE_1 = 0x02, REG_INTR_ENABLE_2 = 0x03,
  REG_FIFO_WR_PTR = 0x04, REG_OVF_COUNTER = 0x05, REG_FIFO_RD_PTR = 0x06, REG_FIFO_DATA = 0x07,
  REG_FIFO_CONFIG = 0x08, REG_MODE_CONFIG = 0x09, REG_SPO2_CONFIG = 0x0A, REG_RSVD_0B = 0x0B,
  REG_LED1_PA = 0x0C, REG_LED2_PA = 0x0D, REG_LED3_PA = 0x0E, REG_RSVD_0F = 0x0F,
  REG_PILOT_PA = 0x10, REG_MULTI_LED_CTRL1 = 0x11, REG_MULTI_LED_CTRL2 = 0x12, REG_TEMP_INT = 0x1F,
  REG_TEMP_FRAC = 0x20, REG_TEMP_CONFIG = 0x21, REG_PROX_INTR_THRESH = 0x30, REG_REV_ID = 0xFE,
  REG_PART_ID = 0xFF
}
 

Register Addresses.

More...
enum  smp_ave_t {
  SMP_AVE_1 = (0 << 5), SMP_AVE_2 = (1 << 5), SMP_AVE_4 = (2 << 5), SMP_AVE_8 = (3 << 5),
  SMP_AVE_16 = (4 << 5), SMP_AVE_32 = (5 << 5)
}
 

Sample Averaging.

More...
enum  fifo_a_full_t {
  FIFO_A_FULL_0 = 0x0, FIFO_A_FULL_1 = 0x1, FIFO_A_FULL_2 = 0x2, FIFO_A_FULL_3 = 0x3,
  FIFO_A_FULL_4 = 0x4, FIFO_A_FULL_5 = 0x5, FIFO_A_FULL_6 = 0x6, FIFO_A_FULL_7 = 0x7,
  FIFO_A_FULL_8 = 0x8, FIFO_A_FULL_9 = 0x9, FIFO_A_FULL_A = 0xA, FIFO_A_FULL_B = 0xB,
  FIFO_A_FULL_C = 0xC, FIFO_A_FULL_D = 0xD, FIFO_A_FULL_E = 0xE, FIFO_A_FULL_F = 0xF
}
 

FIFO Almost Full Value.

More...
enum  mode_t { MODE_1LED = 0x2, MODE_2LED = 0x3, MODE_MULTI = 0x7 }
 

Mode Control.

More...
enum  adc_rge_t { ADC_RGE_00 = (0 << 5), ADC_RGE_01 = (1 << 5), ADC_RGE_10 = (2 << 5), ADC_RGE_11 = (3 << 5) }
 

ADC Range.

More...
enum  smp_rt_t {
  SMP_RT_50 = (0 << 2), SMP_RT_100 = (1 << 2), SMP_RT_200 = (2 << 2), SMP_RT_400 = (3 << 2),
  SMP_RT_800 = (4 << 2), SMP_RT_1000 = (5 << 2), SMP_RT_1600 = (6 << 2), SMP_RT_3200 = (7 << 2)
}
 

Sample Rate.

More...
enum  led_pw_t { LED_PW_15BIT = 0, LED_PW_16BIT = 1, LED_PW_17BIT = 2, LED_PW_18BIT = 3 }
 

Pulse Width.

More...
enum  slot_t {
  SLOT_DISABLED = 0, SLOT_RED_LED1 = 1, SLOT_IR_LED2 = 2, SLOT_GREEN_LED3 = 3,
  SLOT_NONE = 4, SLOT_RED_PILOT = 5, SLOT_IR_PILOT = 6, SLOT_GREEN_PILOT = 7
}
 

Slot Control.

More...

Public Member Functions

 MAX30105 (I2C &i2c)
 MAX30105 constructor.
 ~MAX30105 ()
 MAX30105 destructor.
int getIntr1 ()
 Get Interrupt 1.
int getIntr2 ()
 Get Interrupt 2.
int enableIntr (char intrBits)
 Enable Interrupt.
int disableIntr (char intrBits)
 Disable Interrupt.
int setProx (char proxAmp, char proxThresh)
 Configure Proximity Function.
int setSingleLED (smp_ave_t smpAve=SMP_AVE_1, bool fifoRollOver=false, fifo_a_full_t fifoAFull=FIFO_A_FULL_F, adc_rge_t adcRange=ADC_RGE_01, smp_rt_t smpRate=SMP_RT_100, led_pw_t ledPW=LED_PW_18BIT, char led1PA=MAX30105_DEFAULT_LED_PA)
 Configure Single LED Mode.
int setDualLED (smp_ave_t smpAve=SMP_AVE_1, bool fifoRollOver=false, fifo_a_full_t fifoAFull=FIFO_A_FULL_F, adc_rge_t adcRange=ADC_RGE_01, smp_rt_t smpRate=SMP_RT_100, led_pw_t ledPW=LED_PW_18BIT, char led1PA=MAX30105_DEFAULT_LED_PA, char led2PA=MAX30105_DEFAULT_LED_PA)
 Configure Dual LED Mode.
int setMultiLED (smp_ave_t smpAve=SMP_AVE_1, bool fifoRollOver=false, fifo_a_full_t fifoAFull=FIFO_A_FULL_F, adc_rge_t adcRange=ADC_RGE_01, smp_rt_t smpRate=SMP_RT_100, led_pw_t ledPW=LED_PW_18BIT, char led1PA=MAX30105_DEFAULT_LED_PA, char led2PA=MAX30105_DEFAULT_LED_PA, char led3PA=MAX30105_DEFAULT_LED_PA, char pilotPA=MAX30105_DEFAULT_PILOT_PA, slot_t slot1=SLOT_RED_LED1, slot_t slot2=SLOT_IR_LED2, slot_t slot3=SLOT_GREEN_LED3, slot_t slot4=SLOT_DISABLED)
 Configure Multi LED Mode.
int init ()
 Initialize MAX30105.
int readFIFO (uint32_t *redLED, uint32_t *irLED)
 Read FIFOs.
float readTemperature ()
 Read Temperature.
int softReset ()
 Reset MAX30105.
int shutDown ()
 Shutdown MAX30105.
int wakeUp ()
 Wake Up MAX30105.
int writeReg (registers_t reg, char value)
 Write Register.
int readReg (registers_t reg, char *value)
 Read Register.

Detailed Description

MAX30105 Optical Sensor.

 #include "mbed.h"
 #include "MAX30105.h"

 I2C i2c(I2C_SDA, I2C_SCL);
 MAX30105 max30105(&i2c);

 int main(void) {
     int lastPrx = 0;    

     max30105.softReset(); // reset the MAX30105
     max30105.shutDown();  // shut down while configuring
     max30105.enableIntr(MAX30105::INTR_PROX);  // enable proximity interrupt
     max30105.setProx(0x40, 0x10);   // set proximity pulse amplitude and threshold
     max30105.setSingleLED();  // configure single LED mode to initiate proximity detection
     max30105.wakeUp();        // exit shutdown to start sensing

     while(1) {
         if (max30105.getIntr1() & MAX30105::INTR_PROX) { // if the proximity interrupt occurs
             if (!lastPrx) {
                 printf("Temperature = %02f\n", max30105.readTemperature());
             }
             max30105.writeReg(MAX30105::REG_MODE_CONFIG, MAX30105::MODE_1LED); // go back into proximity detection
             lastPrx = 1;
         } else {
             lastPrx = 0;
         }
         wait_ms(100);
     }
 }

Definition at line 90 of file MAX30105.h.


Member Enumeration Documentation

enum adc_rge_t

ADC Range.

Sets the full scale range of the ADC

Enumerator:
ADC_RGE_00 

2048nA full scale, 7.81pA LSB

ADC_RGE_01 

4096nA full scale, 15.63pA LSB

ADC_RGE_10 

8192nA full scale, 31.25pA LSB

ADC_RGE_11 

16384nA full scale, 62.5pA LSB

Definition at line 176 of file MAX30105.h.

FIFO Almost Full Value.

Number of empty spaces that triggers FIFO_A_FULL interrupt

Enumerator:
FIFO_A_FULL_0 

0 samples remaining, 32 used

FIFO_A_FULL_1 

1 samples remaining, 31 used

FIFO_A_FULL_2 

2 samples remaining, 30 used

FIFO_A_FULL_3 

3 samples remaining, 29 used

FIFO_A_FULL_4 

4 samples remaining, 28 used

FIFO_A_FULL_5 

5 samples remaining, 27 used

FIFO_A_FULL_6 

6 samples remaining, 26 used

FIFO_A_FULL_7 

7 samples remaining, 25 used

FIFO_A_FULL_8 

8 samples remaining, 24 used

FIFO_A_FULL_9 

9 samples remaining, 23 used

FIFO_A_FULL_A 

10 samples remaining, 22 used

FIFO_A_FULL_B 

11 samples remaining, 21 used

FIFO_A_FULL_C 

12 samples remaining, 20 used

FIFO_A_FULL_D 

13 samples remaining, 19 used

FIFO_A_FULL_E 

14 samples remaining, 18 used

FIFO_A_FULL_F 

15 samples remaining, 17 used

Definition at line 143 of file MAX30105.h.

enum led_pw_t

Pulse Width.

Sets the pulse width for the channel

Enumerator:
LED_PW_15BIT 

69us, 15 bit resolution

LED_PW_16BIT 

118us, 16 bit resolution

LED_PW_17BIT 

215us, 17 bit resolution

LED_PW_18BIT 

411us, 18 bit resolution

Definition at line 202 of file MAX30105.h.

enum mode_t

Mode Control.

Operating mode

Enumerator:
MODE_1LED 

Single Red LED mode.

MODE_2LED 

Red and IR LED mode.

MODE_MULTI 

Multi LED mode Red, IR, and/or Green.

Definition at line 166 of file MAX30105.h.

Register Addresses.

Enumerated MAX30105 register addresses

Enumerator:
REG_INTR_STATUS_1 

Interrupt Status 1.

REG_INTR_STATUS_2 

Interrupt Status 2.

REG_INTR_ENABLE_1 

Interrupt Enable 1.

REG_INTR_ENABLE_2 

Interrupt Enable 2.

REG_FIFO_WR_PTR 

FIFO Write Pointer.

REG_OVF_COUNTER 

Overflow Counter.

REG_FIFO_RD_PTR 

FIFO Read Pointer.

REG_FIFO_DATA 

FIFO Data Register.

REG_FIFO_CONFIG 

FIFO Configuration.

REG_MODE_CONFIG 

Mode Configuration.

REG_SPO2_CONFIG 

Sensing Configuration.

REG_RSVD_0B 

Reserved 0x0B.

REG_LED1_PA 

LED1 Pulse Amplitude.

REG_LED2_PA 

LED2 Pulse Amplitude.

REG_LED3_PA 

LED3 Pulse Amplitude.

REG_RSVD_0F 

Reserved 0x0F.

REG_PILOT_PA 

Proximity Mode LED Pulse Amplitude.

REG_MULTI_LED_CTRL1 

LED Slots 1 and 2.

REG_MULTI_LED_CTRL2 

LED Slots 3 and 4.

REG_TEMP_INT 

Die Temperature Ingteger.

REG_TEMP_FRAC 

Die Temperature Fraction.

REG_TEMP_CONFIG 

Die Temperature Configuration.

REG_PROX_INTR_THRESH 

Proximity Interrupt Threshold.

REG_REV_ID 

Part Revision.

REG_PART_ID 

Part ID Code.

Definition at line 98 of file MAX30105.h.

enum slot_t

Slot Control.

Sets the active LED and pulse amplitude for the slot

Enumerator:
SLOT_DISABLED 

No LED active.

SLOT_RED_LED1 

Red, LED1_PA.

SLOT_IR_LED2 

IR, LED3_PA.

SLOT_GREEN_LED3 

Green, LED3_PA.

SLOT_NONE 

No LED active.

SLOT_RED_PILOT 

Red, PILOT_PA.

SLOT_IR_PILOT 

IR, PILOT_PA.

SLOT_GREEN_PILOT 

Green, PILOT_PA.

Definition at line 213 of file MAX30105.h.

enum smp_ave_t

Sample Averaging.

Number of samples to be averaged and decimated

Enumerator:
SMP_AVE_1 

1 (no averaging)

SMP_AVE_2 

2

SMP_AVE_4 

4

SMP_AVE_8 

8

SMP_AVE_16 

16

SMP_AVE_32 

32

Definition at line 130 of file MAX30105.h.

enum smp_rt_t

Sample Rate.

Sets the sample rate of the pulses for each enabled LED

Enumerator:
SMP_RT_50 

50 Samples per second

SMP_RT_100 

100 Samples per second

SMP_RT_200 

200 Samples per second

SMP_RT_400 

400 Samples per second

SMP_RT_800 

800 Samples per second

SMP_RT_1000 

1000 Samples per second

SMP_RT_1600 

1600 Samples per second

SMP_RT_3200 

3200 Samples per second

Definition at line 187 of file MAX30105.h.


Constructor & Destructor Documentation

MAX30105 ( I2C &  i2c )

MAX30105 constructor.

Parameters:
i2cI2C object to use.

Definition at line 44 of file MAX30105.cpp.

~MAX30105 (  )

MAX30105 destructor.

Definition at line 49 of file MAX30105.cpp.


Member Function Documentation

int disableIntr ( char  intrBits )

Disable Interrupt.

Disables any interrupt whos bit is set

Parameters:
intrBitsbit mask of interrupts to disable
Returns:
0 if no errors, -1 if error.

Definition at line 281 of file MAX30105.cpp.

int enableIntr ( char  intrBits )

Enable Interrupt.

Enables any interrupt whos bit is set

Parameters:
intrBitsbit mask of interrupts to enable
Returns:
0 if no errors, -1 if error.

Definition at line 269 of file MAX30105.cpp.

int getIntr1 (  )

Get Interrupt 1.

Reads Interrupt 1

Returns:
contents of REG_INTR_STATUS_1, or -1 if error.

Definition at line 253 of file MAX30105.cpp.

int getIntr2 (  )

Get Interrupt 2.

Reads Temp Interrupt

Returns:
contents of REG_INTR_STATUS_2, or -1 if error.

Definition at line 261 of file MAX30105.cpp.

int init (  )

Initialize MAX30105.

Intializes settings for the MAX30105

Returns:
0 if no errors, -1 if error.

Definition at line 182 of file MAX30105.cpp.

int readFIFO ( uint32_t *  redLED,
uint32_t *  irLED 
)

Read FIFOs.

Reads from the red and IR FIFOs

Parameters:
redLEDPointer for where to store red LED data
irLEDPointer for where to store IR LED data
Returns:
0 if no errors, -1 if error.

Definition at line 209 of file MAX30105.cpp.

int readReg ( registers_t  reg,
char *  value 
)

Read Register.

Reads from the specified register

Parameters:
regThe register to be read
valuePointer for where to store the data
Returns:
0 if no errors, -1 if error.

Definition at line 66 of file MAX30105.cpp.

float readTemperature (  )

Read Temperature.

Read the die temperature of the MAX30105

Returns:
Temperature in degrees C, or -999.0 if error

Definition at line 302 of file MAX30105.cpp.

int setDualLED ( smp_ave_t  smpAve = SMP_AVE_1,
bool  fifoRollOver = false,
fifo_a_full_t  fifoAFull = FIFO_A_FULL_F,
adc_rge_t  adcRange = ADC_RGE_01,
smp_rt_t  smpRate = SMP_RT_100,
led_pw_t  ledPW = LED_PW_18BIT,
char  led1PA = MAX30105_DEFAULT_LED_PA,
char  led2PA = MAX30105_DEFAULT_LED_PA 
)

Configure Dual LED Mode.

Configures part for dual LED mode.

Parameters:
smpAvenumber of samples to average
fifoRollOverenables FIFO to roll over when full
fifoAFullsets FIFO almost full level
adcRangesets ADC range
smpRatesets sample rate
ledPWsets LED pulse width
led1PAsets pulse amplitude for LED1
led2PAsets pulse amplitude for LED2
Returns:
0 if no errors, -1 if error.

Definition at line 108 of file MAX30105.cpp.

int setMultiLED ( smp_ave_t  smpAve = SMP_AVE_1,
bool  fifoRollOver = false,
fifo_a_full_t  fifoAFull = FIFO_A_FULL_F,
adc_rge_t  adcRange = ADC_RGE_01,
smp_rt_t  smpRate = SMP_RT_100,
led_pw_t  ledPW = LED_PW_18BIT,
char  led1PA = MAX30105_DEFAULT_LED_PA,
char  led2PA = MAX30105_DEFAULT_LED_PA,
char  led3PA = MAX30105_DEFAULT_LED_PA,
char  pilotPA = MAX30105_DEFAULT_PILOT_PA,
slot_t  slot1 = SLOT_RED_LED1,
slot_t  slot2 = SLOT_IR_LED2,
slot_t  slot3 = SLOT_GREEN_LED3,
slot_t  slot4 = SLOT_DISABLED 
)

Configure Multi LED Mode.

Configures part for multi LED mode.

Parameters:
smpAvenumber of samples to average
fifoRollOverenables FIFO to roll over when full
fifoAFullsets FIFO almost full level
adcRangesets ADC range
smpRatesets sample rate
ledPWsets LED pulse width
led1PAsets pulse amplitude for LED1
led2PAsets pulse amplitude for LED2
led3PAsets pulse amplitude for LED3
pilotPAsets pulse amplitude for pilot
slot1assigns LED and amplitude to slot 1
slot2assigns LED and amplitude to slot 2
slot3assigns LED and amplitude to slot 3
slot4assigns LED and amplitude to slot 4
Returns:
0 if no errors, -1 if error.

Definition at line 137 of file MAX30105.cpp.

int setProx ( char  proxAmp,
char  proxThresh 
)

Configure Proximity Function.

Sets amplitude and threshold for proximity detector Set threshold to 0x00 to disable proximity detecotr

Parameters:
proxAmpThe amplitude of the proximity pulse 50mA/255 steps
proxThreshThe detect threshold to start sensing
Returns:
0 if no errors, -1 if error.

Definition at line 293 of file MAX30105.cpp.

int setSingleLED ( smp_ave_t  smpAve = SMP_AVE_1,
bool  fifoRollOver = false,
fifo_a_full_t  fifoAFull = FIFO_A_FULL_F,
adc_rge_t  adcRange = ADC_RGE_01,
smp_rt_t  smpRate = SMP_RT_100,
led_pw_t  ledPW = LED_PW_18BIT,
char  led1PA = MAX30105_DEFAULT_LED_PA 
)

Configure Single LED Mode.

Configures part for single LED mode.

Parameters:
smpAvenumber of samples to average
fifoRollOverenables FIFO to roll over when full
fifoAFullsets FIFO almost full level
adcRangesets ADC range
smpRatesets sample rate
ledPWsets LED pulse width
led1PAsets pulse amplitude for LED1
Returns:
0 if no errors, -1 if error.

Definition at line 82 of file MAX30105.cpp.

int shutDown (  )

Shutdown MAX30105.

Puts MAX30105 in power-save mode, retaining regsiter settings

Returns:
0 if no errors, -1 if error.

Definition at line 322 of file MAX30105.cpp.

int softReset (  )

Reset MAX30105.

Resets regsisters to their power on defaults

Returns:
0 if no errors, -1 if error.

Definition at line 338 of file MAX30105.cpp.

int wakeUp (  )

Wake Up MAX30105.

Wakes MAX30105 from power-save mode

Returns:
0 if no errors, -1 if error.

Definition at line 330 of file MAX30105.cpp.

int writeReg ( registers_t  reg,
char  value 
)

Write Register.

Writes the given value to the specified register.

Parameters:
regThe register to be written
valueThe data to be written
Returns:
0 if no errors, -1 if error.

Definition at line 54 of file MAX30105.cpp.