Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
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.
| enum fifo_a_full_t |
FIFO Almost Full Value.
Number of empty spaces that triggers FIFO_A_FULL interrupt
- Enumerator:
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.
| enum registers_t |
Register Addresses.
Enumerated MAX30105 register addresses
- Enumerator:
Definition at line 98 of file MAX30105.h.
| enum slot_t |
Slot Control.
Sets the active LED and pulse amplitude for the slot
- Enumerator:
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:
Definition at line 187 of file MAX30105.h.
Constructor & Destructor Documentation
| MAX30105 | ( | I2C & | i2c ) |
| ~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:
-
intrBits bit 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:
-
intrBits bit 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:
-
redLED Pointer for where to store red LED data irLED Pointer 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:
-
reg The register to be read value Pointer 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:
-
smpAve number of samples to average fifoRollOver enables FIFO to roll over when full fifoAFull sets FIFO almost full level adcRange sets ADC range smpRate sets sample rate ledPW sets LED pulse width led1PA sets pulse amplitude for LED1 led2PA sets 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:
-
smpAve number of samples to average fifoRollOver enables FIFO to roll over when full fifoAFull sets FIFO almost full level adcRange sets ADC range smpRate sets sample rate ledPW sets LED pulse width led1PA sets pulse amplitude for LED1 led2PA sets pulse amplitude for LED2 led3PA sets pulse amplitude for LED3 pilotPA sets pulse amplitude for pilot slot1 assigns LED and amplitude to slot 1 slot2 assigns LED and amplitude to slot 2 slot3 assigns LED and amplitude to slot 3 slot4 assigns 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:
-
proxAmp The amplitude of the proximity pulse 50mA/255 steps proxThresh The 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:
-
smpAve number of samples to average fifoRollOver enables FIFO to roll over when full fifoAFull sets FIFO almost full level adcRange sets ADC range smpRate sets sample rate ledPW sets LED pulse width led1PA sets 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:
-
reg The register to be written value The data to be written
- Returns:
- 0 if no errors, -1 if error.
Definition at line 54 of file MAX30105.cpp.
Generated on Wed Jul 13 2022 16:12:09 by
1.7.2