MAX30001G  1.2.0
Arduino library for MAX30001G ECG and BIOZ AFE
MAX30001G Class Reference

MAX30001G device driver class used by Arduino sketches. More...

#include <max30001g.h>

Public Types

typedef void(* InterruptCallback) (MAX30001G *device, uint32_t status, void *context)
 
enum  InterruptEvent : uint8_t {
  IRQ_ECG_FIFO = 0 , IRQ_ECG_OVF , IRQ_ECG_FAST , IRQ_ECG_LEADOFF ,
  IRQ_BIOZ_FIFO , IRQ_BIOZ_OVF , IRQ_BIOZ_OVER , IRQ_BIOZ_UNDER ,
  IRQ_BIOZ_CGMON , IRQ_LEADS_ON , IRQ_RTOR , IRQ_PLL_UNLOCK ,
  IRQ_EVENT_COUNT
}
 

Public Member Functions

void begin (void)
 
void clearAllInterruptCallbacks (void)
 Clear all registered interrupt callbacks for this instance. More...
 
void clearInterruptAggregateCallback (void)
 Clear aggregate interrupt callback. More...
 
void clearInterruptEventCallback (InterruptEvent event)
 Clear callback for one interrupt event. More...
 
void clearLatchedStatusFlags (void)
 Clear software-latched interrupt/fault flags. More...
 
void enableAFE (bool ECG, bool BIOZ, bool RtoR)
 Enable or disable ECG, BIOZ, and R-to-R engines. More...
 
void end (void)
 
void FIFOReset (void)
 Reset ECG and BIOZ FIFOs. Does not affect data already transferred to RingBuffer. More...
 
void handleBIOZFifoInterrupt (bool reportRaw=false)
 Convenience callback handler: read BIOZ FIFO. More...
 
void handleECGFifoInterrupt (bool reportRaw=false)
 Convenience callback handler: read ECG FIFO. More...
 
void handleRtoRInterrupt (void)
 Convenience callback handler: read RTOR data. More...
 
HealthCheckResult healthCheck (void)
 Run basic health checks and return a summary result. More...
 
 MAX30001G (uint8_t csPin, int intPin1=-1, int intPin2=-1)
 Construct a MAX30001G device instance. More...
 
void printAllRegisters (void)
 
void printBiozDiagnosticRegisters (const char *context=nullptr)
 
void printConfig (void)
 
void printInfo (void)
 
void printStatus (void)
 
void readAllRegisters (void)
 
void readAndClearFaults (void)
 Read and clear fault-related status conditions. More...
 
float readBIOZ (bool reportRaw)
 Read one BIOZ FIFO sample. More...
 
void readBIOZ_FIFO (bool reportRaw)
 Burst-read BIOZ FIFO samples. More...
 
float readECG (bool reportRaw)
 Read one ECG FIFO sample. More...
 
void readECG_FIFO (bool reportRaw)
 Burst-read ECG FIFO samples. More...
 
void readInfo (void)
 
void readRTOR (void)
 Read RTOR result and update RR-interval globals/buffer. More...
 
void readStatusRegisters (void)
 
void restoreConfig (void)
 
void saveConfig (void)
 
void serviceAllInterrupts (void)
 Read STATUS and update interrupt-driven global flags. More...
 
bool servicePendingInterrupts (void)
 Service interrupts only when ISR software flags indicate pending work. More...
 
void setBIOZCurrentMonitor (bool enable)
 Enable/disable BIOZ current monitor. More...
 
void setBIOZfilter (uint8_t ahpf, uint8_t lpf, uint8_t hpf)
 Configure BIOZ analog and digital filters. More...
 
void setBIOZgain (uint8_t gain, bool lowNoise)
 Set BIOZ gain and front-end power/noise mode. More...
 
void setBIOZmag (uint32_t current_nA)
 Set BIOZ current magnitude. More...
 
void setBIOZmodulation (uint8_t mode)
 Set BIOZ current-generator modulation mode. More...
 
void setBIOZModulationFrequencyByFrequency (uint32_t frequency_hz)
 Set BIOZ modulation frequency by target Hz. More...
 
void setBIOZModulationFrequencybyIndex (uint8_t frequency_selector)
 Set BIOZ modulation frequency by FCGEN index. More...
 
void setBIOZPhaseOffsetbyIndex (uint8_t selector)
 Set BIOZ demodulation phase by selector. More...
 
void setBIOZPhaseOffsetbyPhase (float phase_deg)
 Set BIOZ demodulation phase by degree request. More...
 
void setBIOZPhaseOffsetbyPhase (uint32_t frequency_hz, float phase_deg)
 Set BIOZ demodulation phase by explicit frequency and phase. More...
 
void setBIOZSamplingRate (uint8_t speed_select)
 Set BIOZ sample-rate selector. More...
 
void setBIOZTestImpedance (bool enable, bool useHighResistance, bool enableModulation, uint8_t rnomValue, uint8_t rmodValue, uint8_t modFreq)
 Configure BIOZ test impedance and optional modulation. More...
 
void setDefaultBIOZTestImpedance (void)
 Apply default internal BIOZ test impedance settings. More...
 
void setDefaultBIOZTestSignal (void)
 Apply default BIOZ voltage calibration signal settings. More...
 
void setDefaultECGandBIOZTestSignal (void)
 Apply default voltage calibration settings to ECG and BIOZ. More...
 
void setDefaultECGTestSignal (void)
 Apply default ECG voltage calibration signal settings. More...
 
void setDefaultInterruptClearing (void)
 Configure default interrupt-clear, clears on RR read, fast recovery read, and sample read. More...
 
void setDefaultNoBIOZTestImpedance (void)
 Disable internal BIOZ test impedance path. More...
 
void setDefaultNoRtoR (void)
 Apply default RTOR settings with RTOR disabled. More...
 
void setDefaultNoTestSignal (void)
 Disable ECG/BIOZ voltage calibration source routing. More...
 
void setDefaultRtoR (void)
 Apply default RTOR settings and enable RTOR detection. More...
 
void setECGAutoRecovery (int threshold_voltage)
 Enable automatic ECG fast-recovery mode. More...
 
void setECGfilter (uint8_t lpf, uint8_t hpf)
 Configure ECG digital filters. More...
 
void setECGgain (uint8_t gain)
 Set ECG PGA gain. More...
 
void setECGLeadPolarity (bool inverted, bool open)
 Configure ECG polarity and input switch state. More...
 
void setECGNormalRecovery (void)
 
void setECGSamplingRate (uint8_t ECG)
 Set ECG sample-rate selector. More...
 
void setFIFOInterruptThreshold (uint8_t ecg, uint8_t bioz)
 Set FIFO threshold that triggers ECG/BIOZ FIFO interrupts. More...
 
void setFMSTR (uint8_t fmstr)
 Set master clock selector and recompute timing globals. More...
 
bool setInterrupt1 (bool ecg, bool bioz, bool rtor, bool leadon, bool leadoff, bool bioz_fourwire=false)
 Configure interrupt line INT1 event enables. More...
 
bool setInterrupt2 (bool ecg, bool bioz, bool rtor, bool leadon, bool leadoff, bool bioz_fourwire=false)
 Configure interrupt line INT2 event enables. More...
 
bool setInterruptAggregateCallback (InterruptCallback cb, void *context=nullptr, uint32_t statusMask=0x00FFFFFFUL)
 Register aggregate callback invoked for status bits matching a mask. More...
 
bool setInterruptEventCallback (InterruptEvent event, InterruptCallback cb, void *context=nullptr)
 Register callback for one specific interrupt event. More...
 
void setLeadsBias (bool enable, uint8_t resistance)
 Configure lead-bias mode and resistance. More...
 
void setLeadsOffDetection (bool enable, bool bioz_4, uint8_t electrode_impedance)
 Configure lead-off detection behavior. More...
 
void setLeadsOnDetection (bool enable)
 Enable/disable ultra-low-power lead-on detection. More...
 
void setRtoR (bool enable, uint8_t ptsf, uint8_t pavg, uint8_t gain, uint8_t wndw, uint8_t hoff, uint8_t ravg, uint8_t rhsf)
 Configure RTOR algorithm parameters. More...
 
void setTestSignal (bool enableECGCalSignal, bool enableBIOZCalSignal, bool unipolar, bool cal_vmag, uint8_t freq, uint8_t dutycycle)
 Configure calibration voltage source and waveform settings. More...
 
void setupBIOZ (uint8_t speed=0, uint8_t gain=1, uint8_t ahpf=1, uint8_t dlpf=1, uint8_t dhpf=0, uint32_t frequency=40000, uint32_t current=8000, float phase=0.0f, bool leadbias=true, bool leadsoffdetect=false, bool fourleads=false)
 Configure a ready-to-use BIOZ profile. More...
 
void setupBIOZExternalImpedanceCalibration (uint32_t frequency=40000, float phase=0.0f)
 Configure external impedance calibration path. More...
 
void setupBIOZImpedanceCalibration (uint8_t speed=0, uint8_t gain=1, uint8_t ahpf=1, uint8_t dlpf=1, uint8_t dhpf=0, uint32_t frequency=40000, uint32_t current=8000, float phase=0.0f, uint32_t resistance=5000, uint8_t modulation=0, uint8_t modulation_frequency=3)
 Configure internal BIOZ impedance calibration/test path. More...
 
void setupBIOZScan (const BIOZScanConfig &config=BIOZScanConfig(), bool reuseCurrents=false)
 Configure lifecycle-driven BIOZ scan flow. More...
 
void setupBIOZScan (uint8_t avg, bool fast, bool fourleads, bool fullRange)
 Configure lifecycle-driven BIOZ scan flow. More...
 
void setupBIOZSignalCalibration (uint8_t speed=0, uint8_t gain=1)
 Configure BIOZ voltage calibration signal path. More...
 
void setupECG (uint8_t speed=1, uint8_t gain=2, bool threeleads=true)
 Configure a ready-to-use ECG profile. More...
 
void setupECGandBIOZ (uint8_t ecg_speed=1, uint8_t ecg_gain=2, bool ecg_threeleads=true, uint8_t bioz_speed=0, uint8_t bioz_gain=1, uint8_t bioz_dlpf=1, uint8_t bioz_dhpf=0, uint32_t bioz_frequency=8000, uint32_t bioz_current=8000, float bioz_phase=0.0f, bool leadbias=true, bool leadsoffdetect=false, bool bioz_fourleads=false)
 Configure simultaneous ECG and BIOZ operation. More...
 
void setupECGSignalCalibration (uint8_t speed=1, uint8_t gain=2)
 Configure ECG voltage calibration signal path. More...
 
void start (void)
 Start measurement engines according to the most recent setup profile. More...
 
void startBIOZScan (void)
 Start state-machine style BIOZ scan flow. More...
 
void startECGManualRecovery (void)
 
void stepBIOZScan (void)
 Advance state-machine style BIOZ scan flow by one step. More...
 
void stop (void)
 Stop active measurement engines. More...
 
void stopBIOZScan (void)
 Stop state-machine style BIOZ scan flow. More...
 
void stopECGManualRecovery (void)
 
void swReset (void)
 
void synch (void)
 
bool update (bool reportRaw=false)
 Service pending IRQ work and drain enabled FIFOs. More...
 
bool updateRaw (void)
 Alias for raw-code update cycle. More...
 

Detailed Description

MAX30001G device driver class used by Arduino sketches.

Member Typedef Documentation

◆ InterruptCallback

typedef void(* MAX30001G::InterruptCallback) (MAX30001G *device, uint32_t status, void *context)

Member Enumeration Documentation

◆ InterruptEvent

enum MAX30001G::InterruptEvent : uint8_t
Enumerator
IRQ_ECG_FIFO 
IRQ_ECG_OVF 
IRQ_ECG_FAST 
IRQ_ECG_LEADOFF 
IRQ_BIOZ_FIFO 
IRQ_BIOZ_OVF 
IRQ_BIOZ_OVER 
IRQ_BIOZ_UNDER 
IRQ_BIOZ_CGMON 
IRQ_LEADS_ON 
IRQ_RTOR 
IRQ_PLL_UNLOCK 
IRQ_EVENT_COUNT 

Constructor & Destructor Documentation

◆ MAX30001G()

MAX30001G::MAX30001G ( uint8_t  csPin,
int  intPin1 = -1,
int  intPin2 = -1 
)

Construct a MAX30001G device instance.

Parameters
csPinSPI chip-select pin.
intPin1Optional INTB pin number. Use -1 when not connected.
intPin2Optional INT2B pin number. Use -1 when not connected.

Member Function Documentation

◆ begin()

void MAX30001G::begin ( void  )

◆ clearAllInterruptCallbacks()

void MAX30001G::clearAllInterruptCallbacks ( void  )

Clear all registered interrupt callbacks for this instance.

◆ clearInterruptAggregateCallback()

void MAX30001G::clearInterruptAggregateCallback ( void  )

Clear aggregate interrupt callback.

◆ clearInterruptEventCallback()

void MAX30001G::clearInterruptEventCallback ( InterruptEvent  event)

Clear callback for one interrupt event.

event must be one value from InterruptEvent.

Parameters
eventInterrupt event selector.

◆ clearLatchedStatusFlags()

void MAX30001G::clearLatchedStatusFlags ( void  )

Clear software-latched interrupt/fault flags.

This does not read/write device registers; it only resets library globals that are latched by STATUS/FIFO parsing.

◆ enableAFE()

void MAX30001G::enableAFE ( bool  ECG,
bool  BIOZ,
bool  RtoR 
)

Enable or disable ECG, BIOZ, and R-to-R engines.

Parameters
ECGTrue to enable ECG path.
BIOZTrue to enable BIOZ path.
RtoRTrue to enable R-to-R detection.

◆ end()

void MAX30001G::end ( void  )

◆ FIFOReset()

void MAX30001G::FIFOReset ( void  )

Reset ECG and BIOZ FIFOs. Does not affect data already transferred to RingBuffer.

◆ handleBIOZFifoInterrupt()

void MAX30001G::handleBIOZFifoInterrupt ( bool  reportRaw = false)

Convenience callback handler: read BIOZ FIFO.

Parameters
reportRawTrue to keep ADC codes; false to convert.

◆ handleECGFifoInterrupt()

void MAX30001G::handleECGFifoInterrupt ( bool  reportRaw = false)

Convenience callback handler: read ECG FIFO.

Parameters
reportRawTrue to keep ADC codes; false to convert.

◆ handleRtoRInterrupt()

void MAX30001G::handleRtoRInterrupt ( void  )

Convenience callback handler: read RTOR data.

◆ healthCheck()

HealthCheckResult MAX30001G::healthCheck ( void  )

Run basic health checks and return a summary result.

Returns
HealthCheckResult with SPI, INFO, STATUS, and fault summary fields.

◆ printAllRegisters()

void MAX30001G::printAllRegisters ( void  )

◆ printBiozDiagnosticRegisters()

void MAX30001G::printBiozDiagnosticRegisters ( const char *  context = nullptr)

◆ printConfig()

void MAX30001G::printConfig ( void  )

◆ printInfo()

void MAX30001G::printInfo ( void  )

◆ printStatus()

void MAX30001G::printStatus ( void  )

◆ readAllRegisters()

void MAX30001G::readAllRegisters ( void  )

◆ readAndClearFaults()

void MAX30001G::readAndClearFaults ( void  )

Read and clear fault-related status conditions.

◆ readBIOZ()

float MAX30001G::readBIOZ ( bool  reportRaw)

Read one BIOZ FIFO sample.

Parameters
reportRawTrue to keep ADC code; false to convert to ohms.
Returns
Sample value or sentinel for invalid/empty cases.

◆ readBIOZ_FIFO()

void MAX30001G::readBIOZ_FIFO ( bool  reportRaw)

Burst-read BIOZ FIFO samples.

Parameters
reportRawTrue to keep ADC codes; false to convert to engineering units.

◆ readECG()

float MAX30001G::readECG ( bool  reportRaw)

Read one ECG FIFO sample.

Parameters
reportRawTrue to keep ADC code; false to convert to mV.
Returns
Sample value or sentinel for invalid/empty cases.

◆ readECG_FIFO()

void MAX30001G::readECG_FIFO ( bool  reportRaw)

Burst-read ECG FIFO samples.

Parameters
reportRawTrue to keep ADC codes; false to convert to engineering units.

◆ readInfo()

void MAX30001G::readInfo ( void  )

◆ readRTOR()

void MAX30001G::readRTOR ( void  )

Read RTOR result and update RR-interval globals/buffer.

◆ readStatusRegisters()

void MAX30001G::readStatusRegisters ( void  )

◆ restoreConfig()

void MAX30001G::restoreConfig ( void  )

◆ saveConfig()

void MAX30001G::saveConfig ( void  )

◆ serviceAllInterrupts()

void MAX30001G::serviceAllInterrupts ( void  )

Read STATUS and update interrupt-driven global flags.

◆ servicePendingInterrupts()

bool MAX30001G::servicePendingInterrupts ( void  )

Service interrupts only when ISR software flags indicate pending work.

Uses Arduino-core critical-section calls (noInterrupts() / interrupts()) to atomically snapshot and clear software pending flags.

Returns
True if an interrupt service pass was performed.

◆ setBIOZCurrentMonitor()

void MAX30001G::setBIOZCurrentMonitor ( bool  enable)

Enable/disable BIOZ current monitor.

Parameters
enableTrue to enable current monitor path.

◆ setBIOZfilter()

void MAX30001G::setBIOZfilter ( uint8_t  ahpf,
uint8_t  lpf,
uint8_t  hpf 
)

Configure BIOZ analog and digital filters.

ahpf (should be lower than selected modulation frequency)

0 60 Hz

1 150 Hz

2 500 Hz

3 1000 Hz

4 2000 Hz

5 4000 Hz

>=6 bypass

dlpf (set higher for fast changing signals, but more noise)

0 bypass

1 4 Hz **

2 8 Hz

3 16 Hz

dhpf (bypass or filter out static content to visualize cardiac induced changes)

0 bypass **

1 0.05Hz

2 0.5Hz

Parameters
ahpfAnalog HPF selector (0..7). 0:60Hz 1:150Hz 2:500Hz* 3:1000Hz 4:2000Hz 5:4000Hz 6/7:bypass
lpfDigital LPF selector (0..3). 0:bypass 1:~4Hz* 2:~8Hz 3:~16Hz
hpfDigital HPF selector (0..3). 0:bypass* 1:0.05Hz 2/3:0.5Hz

◆ setBIOZgain()

void MAX30001G::setBIOZgain ( uint8_t  gain,
bool  lowNoise 
)

Set BIOZ gain and front-end power/noise mode.

0 10 V/V

1 20 V/V **

2 40 V/V

3 80 V/V

Parameters
gainGain selector (0..3 => 10, 20**, 40, 80 V/V).
lowNoiseTrue for low-noise mode, false for low-power mode.

◆ setBIOZmag()

void MAX30001G::setBIOZmag ( uint32_t  current_nA)

Set BIOZ current magnitude.

current in nanoAmps (8uA works with all settings, higher current is better for measuring low impedance)

55..96,000 nano Amps

8,000 **

Parameters
current_nARequested current in nA (mapped/clamped to valid table values). High-current (8uA..96uA) Low-current range (55nA..1100nA)

◆ setBIOZmodulation()

void MAX30001G::setBIOZmodulation ( uint8_t  mode)

Set BIOZ current-generator modulation mode.

0 = Unchopped with LPF * (higher noise, excellent 50/60 rejection, recommended for ECG, BIOZ applications)

1 = Chopped without LPF (low noise, poor 50/60Hz rejection, recommended for BIOZ applications, possibly battery powered ECG))

2 = Chopped with LPF (low noise, excellent 50/60Hz rejection)

3 = Chopped with resistive CM (Not recommended to be used for drive currents >32µA, low noise, excellent 50/60Hz rejection, lower input impedance)

Datasheet note: use mode 0 when BIOZ_HI_LOB=0 (low-current range).

Parameters
modeBMUX_CG_MODE selector (0..3).

◆ setBIOZModulationFrequencyByFrequency()

void MAX30001G::setBIOZModulationFrequencyByFrequency ( uint32_t  frequency_hz)

Set BIOZ modulation frequency by target Hz.

frequency (historically data was recorded at 50KHz, any frequency from 125Hz to 128kHz is available)

128,000

80,000

40,000 **

18,000

8,000

4,000

2,000

1,000

500 might have 60/50Hz interference

250 might have 60/50Hz interference

125 might have 60/50Hz interference

Parameters
frequency_hzRequested frequency in Hz (mapped to nearest valid FCGEN).

◆ setBIOZModulationFrequencybyIndex()

void MAX30001G::setBIOZModulationFrequencybyIndex ( uint8_t  frequency_selector)

Set BIOZ modulation frequency by FCGEN index.

selector to frequency mapping:

0=128000Hz, 1=80000Hz, 2=40000Hz, 3=18000Hz, 4=8000Hz,

5=4000Hz, 6=2000Hz, 7=1000Hz, 8=500Hz, 9=250Hz, 10=125Hz.

Parameters
frequency_selectorFCGEN selector (0..10 valid).

◆ setBIOZPhaseOffsetbyIndex()

void MAX30001G::setBIOZPhaseOffsetbyIndex ( uint8_t  selector)

Set BIOZ demodulation phase by selector.

FCGEN=0000: selector 0..3 (45.00deg steps) (128kHz)

FCGEN=0001: selector 0..7 (22.50deg steps) (80kHz)

FCGEN>=0010: selector 0..15 (11.25deg steps) (40kHz and lower)

Parameters
selectorPhase index (range depends on FCGEN).

◆ setBIOZPhaseOffsetbyPhase() [1/2]

void MAX30001G::setBIOZPhaseOffsetbyPhase ( float  phase_deg)

Set BIOZ demodulation phase by degree request.

phase delay between current and voltage measurement

for accurate phase and impedance reading at least two phase settings

need to be measured, default is no phase shift, just measure real component

phase in degrees

<80kHz 80kHz 128kHz

0 0.00 0.0 0.0 **

1 11.25 22.5 45.0

2 22.50 45.0 90.0

3 33.75 67.5 135.0

4 45.00 90.0

5 56.25 112.5

6 67.50 135.0

7 78.75 157.5

8 90.00

9 101.25

10 112.50

11 123.75

12 135.00

13 146.25

14 157.50

15 168.75

Parameters
phase_degRequested phase in degrees.

◆ setBIOZPhaseOffsetbyPhase() [2/2]

void MAX30001G::setBIOZPhaseOffsetbyPhase ( uint32_t  frequency_hz,
float  phase_deg 
)

Set BIOZ demodulation phase by explicit frequency and phase.

Phase-index resolution depends on frequency band:

128kHz uses 4 phases (45deg steps), 80kHz uses 8 phases (22.5deg steps),

40kHz and below use 16 phases (11.25deg steps).

Parameters
frequency_hzFrequency context in Hz.
phase_degRequested phase in degrees.

Freq FCGEN Phase Phase selector. lower other 0.. 11.25 ..168.75 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15 80kHz 0b0001 0.. 22.5 ..157.50 0,1,2,3,4,5,6,7 128kHz 0b0000 0.. 45.0 ..135 0,1,2,3

BIOZ_phase is a global variable representing current phase setting

For quadrature measurement we want phase at 0 and 90deg magnitude is sqrt(R_0^2 + R_90^2) phase is atan(R_90/R_0)

If we measure multiple phases we need to fit curve measured R(offset) = mag*cos(phase+offset)

◆ setBIOZSamplingRate()

void MAX30001G::setBIOZSamplingRate ( uint8_t  speed_select)

Set BIOZ sample-rate selector.

0 approx 30 sps (25-32) depending on FMSTR

1 approx 60 sps (50-64) depending on FMSTR *

Parameters
speed_select0 low-rate mode (25-32sps), 1 high-rate mode (50..64sps)

◆ setBIOZTestImpedance()

void MAX30001G::setBIOZTestImpedance ( bool  enable,
bool  useHighResistance,
bool  enableModulation,
uint8_t  rnomValue,
uint8_t  rmodValue,
uint8_t  modFreq 
)

Configure BIOZ test impedance and optional modulation.

Parameters
enableTrue to enable test impedance.
useHighResistanceTrue for high-resistance RNOM table.
enableModulationTrue to enable RMOD modulation.
rnomValueRNOM selector.
rmodValueRMOD selector.
modFreqModulation frequency selector (0..3).

useHighResistance=true, rnomValue 0..3 -> 27k,108k,487k,1029k

0 00 = 27 kΩ

1 01 = 108 kΩ

2 10 = 487 kΩ

3 11 = 1029 kΩ

useHighResistance=false, rnomValue 0..7 -> 5k..625ohm

0 000 = 5 kΩ

1 001 = 2.5 kΩ

2 010 = 1.667 kΩ

3 011 = 1.25 kΩ

4 100 = 1 kΩ

5 101 = 0.833 kΩ

6 110 = 0.714 kΩ

7 111 = 0.625 kΩ

enableModulation=true enables RMOD with rmodValue and modFreq.

For low resistance values between 625Ω and 5kΩ, the resistance can be modulated.

Resistance will switch between RNOM (resistance) and (RNOM - RMOD) at the selected modulation rate.

  • rmodValue: Modulated resistance setting (0 to 7, RMOD). Only applicable when using low resistance.
  • modFreq: resistance modulation frequency (0 to 3). Only applicable when using low resistance.

0=4Hz, 1=1Hz, 2=0.25Hz, 3=0.0625Hz

BMUX_RNOM[2:0] BMUX_RMOD[2:0] NOMINAL RESISTANCE (Ω) MODULATED RESISTANCE (mΩ)

000 000 5000 2960

001 980.5

010 247.5

1xx none

001 000 2500 740.4

001 245.2

010 61.9

1xx none

010 000 1667 329.1

001 109.0

010 27.5

1xx none

011 000 1250 185.1

001 61.3

010 none

1xx none

100 000 1000 118.5

001 39.2

010 none

1xx none

101 000 833 82.3

001 27.2

010 none

1xx none

110 000 714 60.5

001 20.0

010 none

1xx none

111 000 625 46.3

001 15.3

010 none

1xx none

◆ setDefaultBIOZTestImpedance()

void MAX30001G::setDefaultBIOZTestImpedance ( void  )

Apply default internal BIOZ test impedance settings.

◆ setDefaultBIOZTestSignal()

void MAX30001G::setDefaultBIOZTestSignal ( void  )

Apply default BIOZ voltage calibration signal settings.

◆ setDefaultECGandBIOZTestSignal()

void MAX30001G::setDefaultECGandBIOZTestSignal ( void  )

Apply default voltage calibration settings to ECG and BIOZ.

◆ setDefaultECGTestSignal()

void MAX30001G::setDefaultECGTestSignal ( void  )

Apply default ECG voltage calibration signal settings.

◆ setDefaultInterruptClearing()

void MAX30001G::setDefaultInterruptClearing ( void  )

Configure default interrupt-clear, clears on RR read, fast recovery read, and sample read.

◆ setDefaultNoBIOZTestImpedance()

void MAX30001G::setDefaultNoBIOZTestImpedance ( void  )

Disable internal BIOZ test impedance path.

◆ setDefaultNoRtoR()

void MAX30001G::setDefaultNoRtoR ( void  )

Apply default RTOR settings with RTOR disabled.

Default RtoR parameters are:

  • enable: true
  • ptsf: 0b0011 (4/16)

This is the fraction of the Peak Average value used in the Threshold computation.

  • ptsf: 0b0101 (6/16) is also a common value for the threshold.
  • pavg: 0b10 (8) default but 2 might also be used, how many past peak values are used to update peak thershold

This is the weighting factor for the current R-to-R peak observation vs. past peak observations when determining peak thresholds.

  • gain: 0b1111 (Auto-Scale)
  • wndw: 0b0011 12xRTOR_RES (~96ms)
  • hoff: 0b100000 (32)
  • ravg: 0b10 (8)
  • rhsf: 0b100 (4/8)

◆ setDefaultNoTestSignal()

void MAX30001G::setDefaultNoTestSignal ( void  )

Disable ECG/BIOZ voltage calibration source routing.

◆ setDefaultRtoR()

void MAX30001G::setDefaultRtoR ( void  )

Apply default RTOR settings and enable RTOR detection.

◆ setECGAutoRecovery()

void MAX30001G::setECGAutoRecovery ( int  threshold_voltage)

Enable automatic ECG fast-recovery mode.

Parameters
threshold_voltageThreshold in mV used to compute FAST_TH.

◆ setECGfilter()

void MAX30001G::setECGfilter ( uint8_t  lpf,
uint8_t  hpf 
)

Configure ECG digital filters.

digital lpf for the AFE

0 bypass ~ 0 Hz

1 low ~ 40 Hz

2 medium ~100 Hz

3 high ~150 Hz

digital hpf for the AFE

0 bypass * default for all speeds

1 0.5 Hz

fixed external analog HPF on C_HPF:

0.1 uF 5.00 Hz (best motion artifact suppression)

1.0 uF 0.50 Hz

10.0 uF 0.05 Hz (MediBrick, highest signal quality preference)

Parameters
lpfLPF selector (0 bypass, 1 low, 2 medium, 3 high).
hpfHPF selector (0 bypass, 1 enable 0.5Hz class).

◆ setECGgain()

void MAX30001G::setECGgain ( uint8_t  gain)

Set ECG PGA gain.

0 20 V/V

1 40 V/V

2 80 V/V * default

3 160 V/V

Parameters
gainGain selector (0..3 => 20, 40, 80, 160 V/V).

◆ setECGLeadPolarity()

void MAX30001G::setECGLeadPolarity ( bool  inverted,
bool  open 
)

Configure ECG polarity and input switch state.

Parameters
invertedTrue to swap ECG polarity.
openTrue to open inputs for calibration routing.

◆ setECGNormalRecovery()

void MAX30001G::setECGNormalRecovery ( void  )

◆ setECGSamplingRate()

void MAX30001G::setECGSamplingRate ( uint8_t  ECG)

Set ECG sample-rate selector.

0 low ~125sps

1 medium ~256sps

2 high ~512sps * default

Parameters
ECGRate selector (0 low, 1 medium, 2 high; constrained by FMSTR).

◆ setFIFOInterruptThreshold()

void MAX30001G::setFIFOInterruptThreshold ( uint8_t  ecg,
uint8_t  bioz 
)

Set FIFO threshold that triggers ECG/BIOZ FIFO interrupts.

Parameters
ecgECG threshold in samples (device supports 1..32).
biozBIOZ threshold in samples (device supports 1..8).

◆ setFMSTR()

void MAX30001G::setFMSTR ( uint8_t  fmstr)

Set master clock selector and recompute timing globals.

0 0b00 = 32768 Hz = FCLK

1 0b01 = 32000 Hz = FCLK*625/640

2 0b10 = 32000 Hz = FCLK*625/640

3 0b11 = 31968.78 Hz = FCLK*640/656

Parameters
fmstrFMSTR selector (0..3)(32768, 32000, 32000, 31968.78 Hz)

◆ setInterrupt1()

bool MAX30001G::setInterrupt1 ( bool  ecg,
bool  bioz,
bool  rtor,
bool  leadon,
bool  leadoff,
bool  bioz_fourwire = false 
)
inline

Configure interrupt line INT1 event enables.

Parameters
ecgEnable ECG-related interrupt bits.
biozEnable BIOZ-related interrupt bits.
rtorEnable RTOR interrupt bit.
leadonEnable lead-on interrupt bit.
leadoffEnable lead-off interrupt bit.
bioz_fourwireEnable 4-wire BIOZ current monitor interrupt behavior.
Returns
True when register write/verify succeeds.

◆ setInterrupt2()

bool MAX30001G::setInterrupt2 ( bool  ecg,
bool  bioz,
bool  rtor,
bool  leadon,
bool  leadoff,
bool  bioz_fourwire = false 
)
inline

Configure interrupt line INT2 event enables.

Parameters
ecgEnable ECG-related interrupt bits.
biozEnable BIOZ-related interrupt bits.
rtorEnable RTOR interrupt bit.
leadonEnable lead-on interrupt bit.
leadoffEnable lead-off interrupt bit.
bioz_fourwireEnable 4-wire BIOZ current monitor interrupt behavior.
Returns
True when register write/verify succeeds.

◆ setInterruptAggregateCallback()

bool MAX30001G::setInterruptAggregateCallback ( InterruptCallback  cb,
void *  context = nullptr,
uint32_t  statusMask = 0x00FFFFFFUL 
)

Register aggregate callback invoked for status bits matching a mask.

Parameters
cbCallback function pointer.
contextUser context pointer passed to callback.
statusMaskSTATUS bit mask used for callback gating.
Returns
True when registration succeeds.

◆ setInterruptEventCallback()

bool MAX30001G::setInterruptEventCallback ( InterruptEvent  event,
InterruptCallback  cb,
void *  context = nullptr 
)

Register callback for one specific interrupt event.

device - MAX30001G instance

status - STATUS register snapshot captured by serviceAllInterrupts()

context - user pointer passed at registration time

event - one value from InterruptEvent (for example IRQ_ECG_FIFO, IRQ_BIOZ_FIFO, IRQ_RTOR).

Parameters
eventInterrupt event selector.
cbCallback function pointer.
contextUser context pointer passed to callback.
Returns
True when registration succeeds.

◆ setLeadsBias()

void MAX30001G::setLeadsBias ( bool  enable,
uint8_t  resistance 
)

Configure lead-bias mode and resistance.

resistance:

0 use external lead bias (in BIOZ mode, only available for high current mode)

>=150 internal lead bias 200M Ohm

> 75 internal lead bias 100M Ohm default

else internal lead bias 50M Ohm

Parameters
enableTrue to enable lead-bias path.
resistanceResistance selector value (mapped to internal/external options).

◆ setLeadsOffDetection()

void MAX30001G::setLeadsOffDetection ( bool  enable,
bool  bioz_4,
uint8_t  electrode_impedance 
)

Configure lead-off detection behavior.

Configure leads off detection for the ECG or BioZ channels.

The correct leads off detection features are automaticaly enabled (DC, Current and AC leads off)

Before running this routine

  • Make sure that ecg or bioz is active.
  • Lead polarity is set

electrode_impedance:

  • 0-2, 2-4, 4-10, 10-20, >20 MOhm
  • used to determine current magnitude, wet electrodes need higher current for lead-off detection
    Parameters
    enableTrue to enable lead-off detection.
    bioz_4True for 4-wire BIOZ assumptions, false for 2-wire.
    electrode_impedanceElectrode impedance estimate in MOhm.

◆ setLeadsOnDetection()

void MAX30001G::setLeadsOnDetection ( bool  enable)

Enable/disable ultra-low-power lead-on detection.

Lead on is used in low power mode to assert interrupt when leads are

attached so that the device can automatically power on

Parameters
enableTrue to enable ULP lead-on detection.

◆ setRtoR()

void MAX30001G::setRtoR ( bool  enable,
uint8_t  ptsf,
uint8_t  pavg,
uint8_t  gain,
uint8_t  wndw,
uint8_t  hoff,
uint8_t  ravg,
uint8_t  rhsf 
)

Configure RTOR algorithm parameters.

ptsf: 0..15 maps to threshold scale 1/16..16/16.

pavg: 0..3 maps to peak averaging depth {2,4,8,16}.

gain: 0..15 maps to RTOR gain table (15 is auto-scale).

wndw: 0..11 valid QRS windows, 12..15 reserved.

hoff: 0..63 hold-off counts.

ravg: 0..3 maps to interval averaging depth {2,4,8,16}.

rhsf: 0..7 maps to dynamic hold-off scale 0/8..7/8.

Parameters
enableTrue to enable RTOR detection.
ptsfPeak threshold scaling factor selector (0..15).
pavgPeak averaging selector (0..3).
gainRTOR gain selector (0..15).
wndwQRS averaging window selector (0..11 valid, 12..15 reserved).
hoffMinimum hold-off selector (0..63).
ravgInterval averaging selector (0..3).
rhsfDynamic hold-off scaling selector (0..7).

◆ setTestSignal()

void MAX30001G::setTestSignal ( bool  enableECGCalSignal,
bool  enableBIOZCalSignal,
bool  unipolar,
bool  cal_vmag,
uint8_t  freq,
uint8_t  dutycycle 
)

Configure calibration voltage source and waveform settings.

freq (FCAL): 0..7 maps to FMSTR/{128,512,2048,8192,32768,131072,524288,2097152}.

Example at FMSTR=32768Hz: {256,64,16,4,1,0.25,0.0625,0.015625}Hz.

dutycycle: 1..99% valid, 50% uses the dedicated CALP_SEL path.

Parameters
enableECGCalSignalTrue to route VCAL to ECG path.
enableBIOZCalSignalTrue to route VCAL to BIOZ path.
unipolarTrue for unipolar waveform, false for bipolar waveform.
cal_vmagFalse for 0.25mV class, true for 0.5mV class.
freqFCAL selector (0..7).
dutycycleDuty cycle in percent (1..99, 50 uses dedicated mode).

◆ setupBIOZ()

void MAX30001G::setupBIOZ ( uint8_t  speed = 0,
uint8_t  gain = 1,
uint8_t  ahpf = 1,
uint8_t  dlpf = 1,
uint8_t  dhpf = 0,
uint32_t  frequency = 40000,
uint32_t  current = 8000,
float  phase = 0.0f,
bool  leadbias = true,
bool  leadsoffdetect = false,
bool  fourleads = false 
)

Configure a ready-to-use BIOZ profile.

speed: 0=low-rate (~25..32sps), 1=high-rate (~50..64sps).

gain: 0=10V/V, 1=20V/V, 2=40V/V, 3=80V/V.

ahpf: 0=60Hz, 1=150Hz, 2=500Hz, 3=1kHz, 4=2kHz, 5=4kHz, 6/7=bypass.

dlpf: 0=bypass, 1=~4Hz, 2=~8Hz, 3=~16Hz.

dhpf: 0=bypass, 1=0.05Hz, 2/3=0.5Hz class.

Parameters
speedBIOZ sample-rate selector (0 low, 1 high).
gainBIOZ gain selector (0..3 => 10, 20, 40, 80 V/V).
ahpfBIOZ analog HPF selector (0..7).
dlpfBIOZ digital LPF selector (0..3).
dhpfBIOZ digital HPF selector (0..3).
frequencyTarget modulation frequency in Hz (mapped to nearest valid FCGEN).
currentTarget drive current in nA (mapped/clamped to valid settings).
phaseDemodulation phase offset in degrees.
leadbiasTrue to enable lead-bias configuration in setup.
leadsoffdetectTrue to configure lead-off detection in setup.
fourleadsTrue for 4-wire BIOZ assumptions, false for 2-wire.

◆ setupBIOZExternalImpedanceCalibration()

void MAX30001G::setupBIOZExternalImpedanceCalibration ( uint32_t  frequency = 40000,
float  phase = 0.0f 
)

Configure external impedance calibration path.

Parameters
frequencyBIOZ modulation frequency target in Hz.
phaseDemodulation phase offset in degrees.

◆ setupBIOZImpedanceCalibration()

void MAX30001G::setupBIOZImpedanceCalibration ( uint8_t  speed = 0,
uint8_t  gain = 1,
uint8_t  ahpf = 1,
uint8_t  dlpf = 1,
uint8_t  dhpf = 0,
uint32_t  frequency = 40000,
uint32_t  current = 8000,
float  phase = 0.0f,
uint32_t  resistance = 5000,
uint8_t  modulation = 0,
uint8_t  modulation_frequency = 3 
)

Configure internal BIOZ impedance calibration/test path.

speed: 0=low-rate (~25..32sps), 1=high-rate (~50..64sps).

gain: 0=10V/V, 1=20V/V, 2=40V/V, 3=80V/V.

ahpf: 0=60Hz, 1=150Hz, 2=500Hz, 3=1kHz, 4=2kHz, 5=4kHz, 6/7=bypass.

dlpf: 0=bypass, 1=~4Hz, 2=~8Hz, 3=~16Hz.

dhpf: 0=bypass, 1=0.05Hz, 2/3=0.5Hz class.

modulation: 0=unchopped+LPF, 1=chopped no-LPF, 2=chopped+LPF, 3=chopped+resistive-CM.

modulation_frequency: 0=4Hz, 1=1Hz, 2=0.25Hz, 3=0.0625Hz.

Parameters
speedBIOZ sample-rate selector (0..1).
gainBIOZ gain selector (0..3).
ahpfBIOZ analog HPF selector (0..7).
dlpfBIOZ digital LPF selector (0..3).
dhpfBIOZ digital HPF selector (0..3).
frequencyBIOZ modulation frequency target in Hz.
currentBIOZ drive current target in nA.
phaseDemodulation phase offset in degrees.
resistanceNominal internal test impedance value.
modulationCalibration modulation mode selector.
modulation_frequencyCalibration modulation frequency selector.

◆ setupBIOZScan() [1/2]

void MAX30001G::setupBIOZScan ( const BIOZScanConfig config = BIOZScanConfig(),
bool  reuseCurrents = false 
)

Configure lifecycle-driven BIOZ scan flow.

This does not start scanning immediately. Call start(), then drive with update().

Parameters
configScan configuration parameters.
reuseCurrentsTrue to reuse previously optimized current profile.

◆ setupBIOZScan() [2/2]

void MAX30001G::setupBIOZScan ( uint8_t  avg,
bool  fast,
bool  fourleads,
bool  fullRange 
)

Configure lifecycle-driven BIOZ scan flow.

This does not start scanning immediately. Call start(), then drive with update().

Parameters
avgBIOZ FIFO average depth used per point.
fastTrue for high-rate BIOZ sampling.
fourleadsTrue for 4-wire BIOZ assumptions.
fullRangeTrue to include lowest available frequency bins.

◆ setupBIOZSignalCalibration()

void MAX30001G::setupBIOZSignalCalibration ( uint8_t  speed = 0,
uint8_t  gain = 1 
)

Configure BIOZ voltage calibration signal path.

speed: 0=low-rate (~25..32sps), 1=high-rate (~50..64sps).

gain: 0=10V/V, 1=20V/V, 2=40V/V, 3=80V/V.

Parameters
speedBIOZ sample-rate selector (0..1).
gainBIOZ gain selector (0..3).

◆ setupECG()

void MAX30001G::setupECG ( uint8_t  speed = 1,
uint8_t  gain = 2,
bool  threeleads = true 
)

Configure a ready-to-use ECG profile.

speed

0 ~125 sps

1 ~256 sps * default

2 ~512 sps

gain

0 20 V/V

1 40 V/V

2 80 V/V * default

3 160 V/V

three leads

true 3 lead ECG (with ground on RL or LL) * default

false 2 lead ECG (with RA and LA only), should use internal leads bias

Parameters
speedECG sample-rate selector (0 low, 1 medium, 2 high).
gainECG gain selector (0..3 => 20, 40, 80, 160 V/V).
threeleadsTrue for 3-lead operation, false for 2-lead operation.

◆ setupECGandBIOZ()

void MAX30001G::setupECGandBIOZ ( uint8_t  ecg_speed = 1,
uint8_t  ecg_gain = 2,
bool  ecg_threeleads = true,
uint8_t  bioz_speed = 0,
uint8_t  bioz_gain = 1,
uint8_t  bioz_dlpf = 1,
uint8_t  bioz_dhpf = 0,
uint32_t  bioz_frequency = 8000,
uint32_t  bioz_current = 8000,
float  bioz_phase = 0.0f,
bool  leadbias = true,
bool  leadsoffdetect = false,
bool  bioz_fourleads = false 
)

Configure simultaneous ECG and BIOZ operation.

ecg_speed: 0=~125sps, 1=~256sps, 2=~512sps.

ecg_gain: 0=20V/V, 1=40V/V, 2=80V/V, 3=160V/V.

bioz_speed: 0=~25..32sps, 1=~50..64sps.

bioz_gain: 0=10V/V, 1=20V/V, 2=40V/V, 3=80V/V.

bioz_dlpf: 0=bypass, 1=~4Hz, 2=~8Hz, 3=~16Hz.

bioz_dhpf: 0=bypass, 1=0.05Hz, 2/3=0.5Hz class.

Parameters
ecg_speedECG sample-rate selector (0..2).
ecg_gainECG gain selector (0..3).
ecg_threeleadsTrue for 3-lead ECG mode.
bioz_speedBIOZ sample-rate selector (0..1).
bioz_gainBIOZ gain selector (0..3).
bioz_dlpfBIOZ digital LPF selector (0..3).
bioz_dhpfBIOZ digital HPF selector (0..3).
bioz_frequencyBIOZ modulation frequency target in Hz.
bioz_currentBIOZ drive current target in nA.
bioz_phaseBIOZ phase offset target in degrees.
leadbiasTrue to configure lead bias.
leadsoffdetectTrue to configure lead-off detection.
bioz_fourleadsTrue for 4-wire BIOZ assumptions.

◆ setupECGSignalCalibration()

void MAX30001G::setupECGSignalCalibration ( uint8_t  speed = 1,
uint8_t  gain = 2 
)

Configure ECG voltage calibration signal path.

speed: 0=~125sps, 1=~256sps, 2=~512sps.

gain: 0=20V/V, 1=40V/V, 2=80V/V, 3=160V/V.

Parameters
speedECG sample-rate selector (0..2).
gainECG gain selector (0..3).

◆ start()

void MAX30001G::start ( void  )

Start measurement engines according to the most recent setup profile.

◆ startBIOZScan()

void MAX30001G::startBIOZScan ( void  )

Start state-machine style BIOZ scan flow.

Arms non-blocking scan execution; each update() call advances scan steps.

◆ startECGManualRecovery()

void MAX30001G::startECGManualRecovery ( void  )

◆ stepBIOZScan()

void MAX30001G::stepBIOZScan ( void  )

Advance state-machine style BIOZ scan flow by one step.

Executes one non-blocking scan state transition per call.

◆ stop()

void MAX30001G::stop ( void  )

Stop active measurement engines.

◆ stopBIOZScan()

void MAX30001G::stopBIOZScan ( void  )

Stop state-machine style BIOZ scan flow.

Stops scan flow and powers down AFE engines.

◆ stopECGManualRecovery()

void MAX30001G::stopECGManualRecovery ( void  )

◆ swReset()

void MAX30001G::swReset ( void  )

◆ synch()

void MAX30001G::synch ( void  )

◆ update()

bool MAX30001G::update ( bool  reportRaw = false)

Service pending IRQ work and drain enabled FIFOs.

Parameters
reportRawTrue to keep raw ADC codes, false to convert to engineering units.
Returns
True if update handled any interrupt/data/fault work.

◆ updateRaw()

bool MAX30001G::updateRaw ( void  )
inline

Alias for raw-code update cycle.

Returns
True if update handled any interrupt/data/fault work.

The documentation for this class was generated from the following files: