|
MAX30001G
1.2.0
Arduino library for MAX30001G ECG and BIOZ AFE
|
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... | |
MAX30001G device driver class used by Arduino sketches.
| enum MAX30001G::InterruptEvent : uint8_t |
| MAX30001G::MAX30001G | ( | uint8_t | csPin, |
| int | intPin1 = -1, |
||
| int | intPin2 = -1 |
||
| ) |
Construct a MAX30001G device instance.
| csPin | SPI chip-select pin. |
| intPin1 | Optional INTB pin number. Use -1 when not connected. |
| intPin2 | Optional INT2B pin number. Use -1 when not connected. |
| void MAX30001G::begin | ( | void | ) |
| void MAX30001G::clearAllInterruptCallbacks | ( | void | ) |
Clear all registered interrupt callbacks for this instance.
| void MAX30001G::clearInterruptAggregateCallback | ( | void | ) |
Clear aggregate interrupt callback.
| void MAX30001G::clearInterruptEventCallback | ( | InterruptEvent | event | ) |
Clear callback for one interrupt event.
event must be one value from InterruptEvent.
| event | Interrupt event selector. |
| 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.
| void MAX30001G::enableAFE | ( | bool | ECG, |
| bool | BIOZ, | ||
| bool | RtoR | ||
| ) |
Enable or disable ECG, BIOZ, and R-to-R engines.
| ECG | True to enable ECG path. |
| BIOZ | True to enable BIOZ path. |
| RtoR | True to enable R-to-R detection. |
| void MAX30001G::end | ( | void | ) |
| void MAX30001G::FIFOReset | ( | void | ) |
Reset ECG and BIOZ FIFOs. Does not affect data already transferred to RingBuffer.
| void MAX30001G::handleBIOZFifoInterrupt | ( | bool | reportRaw = false | ) |
Convenience callback handler: read BIOZ FIFO.
| reportRaw | True to keep ADC codes; false to convert. |
| void MAX30001G::handleECGFifoInterrupt | ( | bool | reportRaw = false | ) |
Convenience callback handler: read ECG FIFO.
| reportRaw | True to keep ADC codes; false to convert. |
| void MAX30001G::handleRtoRInterrupt | ( | void | ) |
Convenience callback handler: read RTOR data.
| HealthCheckResult MAX30001G::healthCheck | ( | void | ) |
Run basic health checks and return a summary result.
| void MAX30001G::printAllRegisters | ( | void | ) |
| void MAX30001G::printBiozDiagnosticRegisters | ( | const char * | context = nullptr | ) |
| void MAX30001G::printConfig | ( | void | ) |
| void MAX30001G::printInfo | ( | void | ) |
| void MAX30001G::printStatus | ( | void | ) |
| void MAX30001G::readAllRegisters | ( | void | ) |
| void MAX30001G::readAndClearFaults | ( | void | ) |
Read and clear fault-related status conditions.
| float MAX30001G::readBIOZ | ( | bool | reportRaw | ) |
Read one BIOZ FIFO sample.
| reportRaw | True to keep ADC code; false to convert to ohms. |
| void MAX30001G::readBIOZ_FIFO | ( | bool | reportRaw | ) |
Burst-read BIOZ FIFO samples.
| reportRaw | True to keep ADC codes; false to convert to engineering units. |
| float MAX30001G::readECG | ( | bool | reportRaw | ) |
Read one ECG FIFO sample.
| reportRaw | True to keep ADC code; false to convert to mV. |
| void MAX30001G::readECG_FIFO | ( | bool | reportRaw | ) |
Burst-read ECG FIFO samples.
| reportRaw | True to keep ADC codes; false to convert to engineering units. |
| void MAX30001G::readInfo | ( | void | ) |
| void MAX30001G::readRTOR | ( | void | ) |
Read RTOR result and update RR-interval globals/buffer.
| void MAX30001G::readStatusRegisters | ( | void | ) |
| void MAX30001G::restoreConfig | ( | void | ) |
| void MAX30001G::saveConfig | ( | void | ) |
| void MAX30001G::serviceAllInterrupts | ( | void | ) |
Read STATUS and update interrupt-driven global flags.
| 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.
| void MAX30001G::setBIOZCurrentMonitor | ( | bool | enable | ) |
Enable/disable BIOZ current monitor.
| enable | True to enable current monitor path. |
| 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
| ahpf | Analog HPF selector (0..7). 0:60Hz 1:150Hz 2:500Hz* 3:1000Hz 4:2000Hz 5:4000Hz 6/7:bypass |
| lpf | Digital LPF selector (0..3). 0:bypass 1:~4Hz* 2:~8Hz 3:~16Hz |
| hpf | Digital HPF selector (0..3). 0:bypass* 1:0.05Hz 2/3:0.5Hz |
| 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
| gain | Gain selector (0..3 => 10, 20**, 40, 80 V/V). |
| lowNoise | True for low-noise mode, false for low-power mode. |
| 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 **
| current_nA | Requested current in nA (mapped/clamped to valid table values). High-current (8uA..96uA) Low-current range (55nA..1100nA) |
| 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).
| mode | BMUX_CG_MODE selector (0..3). |
| 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
| frequency_hz | Requested frequency in Hz (mapped to nearest valid FCGEN). |
| 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.
| frequency_selector | FCGEN selector (0..10 valid). |
| 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)
| selector | Phase index (range depends on FCGEN). |
| 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
| phase_deg | Requested phase in degrees. |
| 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).
| frequency_hz | Frequency context in Hz. |
| phase_deg | Requested 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)
| 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 *
| speed_select | 0 low-rate mode (25-32sps), 1 high-rate mode (50..64sps) |
| 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.
| enable | True to enable test impedance. |
| useHighResistance | True for high-resistance RNOM table. |
| enableModulation | True to enable RMOD modulation. |
| rnomValue | RNOM selector. |
| rmodValue | RMOD selector. |
| modFreq | Modulation 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.
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
| void MAX30001G::setDefaultBIOZTestImpedance | ( | void | ) |
Apply default internal BIOZ test impedance settings.
| void MAX30001G::setDefaultBIOZTestSignal | ( | void | ) |
Apply default BIOZ voltage calibration signal settings.
| void MAX30001G::setDefaultECGandBIOZTestSignal | ( | void | ) |
Apply default voltage calibration settings to ECG and BIOZ.
| void MAX30001G::setDefaultECGTestSignal | ( | void | ) |
Apply default ECG voltage calibration signal settings.
| void MAX30001G::setDefaultInterruptClearing | ( | void | ) |
Configure default interrupt-clear, clears on RR read, fast recovery read, and sample read.
| void MAX30001G::setDefaultNoBIOZTestImpedance | ( | void | ) |
Disable internal BIOZ test impedance path.
| void MAX30001G::setDefaultNoRtoR | ( | void | ) |
Apply default RTOR settings with RTOR disabled.
Default RtoR parameters are:
This is the fraction of the Peak Average value used in the Threshold computation.
This is the weighting factor for the current R-to-R peak observation vs. past peak observations when determining peak thresholds.
| void MAX30001G::setDefaultNoTestSignal | ( | void | ) |
Disable ECG/BIOZ voltage calibration source routing.
| void MAX30001G::setDefaultRtoR | ( | void | ) |
Apply default RTOR settings and enable RTOR detection.
| void MAX30001G::setECGAutoRecovery | ( | int | threshold_voltage | ) |
Enable automatic ECG fast-recovery mode.
| threshold_voltage | Threshold in mV used to compute FAST_TH. |
| 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)
| lpf | LPF selector (0 bypass, 1 low, 2 medium, 3 high). |
| hpf | HPF selector (0 bypass, 1 enable 0.5Hz class). |
| 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
| gain | Gain selector (0..3 => 20, 40, 80, 160 V/V). |
| void MAX30001G::setECGLeadPolarity | ( | bool | inverted, |
| bool | open | ||
| ) |
Configure ECG polarity and input switch state.
| inverted | True to swap ECG polarity. |
| open | True to open inputs for calibration routing. |
| void MAX30001G::setECGNormalRecovery | ( | void | ) |
| void MAX30001G::setECGSamplingRate | ( | uint8_t | ECG | ) |
Set ECG sample-rate selector.
0 low ~125sps
1 medium ~256sps
2 high ~512sps * default
| ECG | Rate selector (0 low, 1 medium, 2 high; constrained by FMSTR). |
| void MAX30001G::setFIFOInterruptThreshold | ( | uint8_t | ecg, |
| uint8_t | bioz | ||
| ) |
Set FIFO threshold that triggers ECG/BIOZ FIFO interrupts.
| ecg | ECG threshold in samples (device supports 1..32). |
| bioz | BIOZ threshold in samples (device supports 1..8). |
| 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
| fmstr | FMSTR selector (0..3)(32768, 32000, 32000, 31968.78 Hz) |
|
inline |
Configure interrupt line INT1 event enables.
| ecg | Enable ECG-related interrupt bits. |
| bioz | Enable BIOZ-related interrupt bits. |
| rtor | Enable RTOR interrupt bit. |
| leadon | Enable lead-on interrupt bit. |
| leadoff | Enable lead-off interrupt bit. |
| bioz_fourwire | Enable 4-wire BIOZ current monitor interrupt behavior. |
|
inline |
Configure interrupt line INT2 event enables.
| ecg | Enable ECG-related interrupt bits. |
| bioz | Enable BIOZ-related interrupt bits. |
| rtor | Enable RTOR interrupt bit. |
| leadon | Enable lead-on interrupt bit. |
| leadoff | Enable lead-off interrupt bit. |
| bioz_fourwire | Enable 4-wire BIOZ current monitor interrupt behavior. |
| bool MAX30001G::setInterruptAggregateCallback | ( | InterruptCallback | cb, |
| void * | context = nullptr, |
||
| uint32_t | statusMask = 0x00FFFFFFUL |
||
| ) |
Register aggregate callback invoked for status bits matching a mask.
| cb | Callback function pointer. |
| context | User context pointer passed to callback. |
| statusMask | STATUS bit mask used for callback gating. |
| 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).
| event | Interrupt event selector. |
| cb | Callback function pointer. |
| context | User context pointer passed to callback. |
| 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
| enable | True to enable lead-bias path. |
| resistance | Resistance selector value (mapped to internal/external options). |
| 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
electrode_impedance:
| enable | True to enable lead-off detection. |
| bioz_4 | True for 4-wire BIOZ assumptions, false for 2-wire. |
| electrode_impedance | Electrode impedance estimate in MOhm. |
| 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
| enable | True to enable ULP lead-on detection. |
| 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.
| enable | True to enable RTOR detection. |
| ptsf | Peak threshold scaling factor selector (0..15). |
| pavg | Peak averaging selector (0..3). |
| gain | RTOR gain selector (0..15). |
| wndw | QRS averaging window selector (0..11 valid, 12..15 reserved). |
| hoff | Minimum hold-off selector (0..63). |
| ravg | Interval averaging selector (0..3). |
| rhsf | Dynamic hold-off scaling selector (0..7). |
| 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.
| enableECGCalSignal | True to route VCAL to ECG path. |
| enableBIOZCalSignal | True to route VCAL to BIOZ path. |
| unipolar | True for unipolar waveform, false for bipolar waveform. |
| cal_vmag | False for 0.25mV class, true for 0.5mV class. |
| freq | FCAL selector (0..7). |
| dutycycle | Duty cycle in percent (1..99, 50 uses dedicated mode). |
| 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.
| speed | BIOZ sample-rate selector (0 low, 1 high). |
| gain | BIOZ gain selector (0..3 => 10, 20, 40, 80 V/V). |
| ahpf | BIOZ analog HPF selector (0..7). |
| dlpf | BIOZ digital LPF selector (0..3). |
| dhpf | BIOZ digital HPF selector (0..3). |
| frequency | Target modulation frequency in Hz (mapped to nearest valid FCGEN). |
| current | Target drive current in nA (mapped/clamped to valid settings). |
| phase | Demodulation phase offset in degrees. |
| leadbias | True to enable lead-bias configuration in setup. |
| leadsoffdetect | True to configure lead-off detection in setup. |
| fourleads | True for 4-wire BIOZ assumptions, false for 2-wire. |
| void MAX30001G::setupBIOZExternalImpedanceCalibration | ( | uint32_t | frequency = 40000, |
| float | phase = 0.0f |
||
| ) |
Configure external impedance calibration path.
| frequency | BIOZ modulation frequency target in Hz. |
| phase | Demodulation phase offset in degrees. |
| 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.
| speed | BIOZ sample-rate selector (0..1). |
| gain | BIOZ gain selector (0..3). |
| ahpf | BIOZ analog HPF selector (0..7). |
| dlpf | BIOZ digital LPF selector (0..3). |
| dhpf | BIOZ digital HPF selector (0..3). |
| frequency | BIOZ modulation frequency target in Hz. |
| current | BIOZ drive current target in nA. |
| phase | Demodulation phase offset in degrees. |
| resistance | Nominal internal test impedance value. |
| modulation | Calibration modulation mode selector. |
| modulation_frequency | Calibration modulation frequency selector. |
| void MAX30001G::setupBIOZScan | ( | const BIOZScanConfig & | config = BIOZScanConfig(), |
| bool | reuseCurrents = false |
||
| ) |
| 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().
| avg | BIOZ FIFO average depth used per point. |
| fast | True for high-rate BIOZ sampling. |
| fourleads | True for 4-wire BIOZ assumptions. |
| fullRange | True to include lowest available frequency bins. |
| 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.
| speed | BIOZ sample-rate selector (0..1). |
| gain | BIOZ gain selector (0..3). |
| 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
| speed | ECG sample-rate selector (0 low, 1 medium, 2 high). |
| gain | ECG gain selector (0..3 => 20, 40, 80, 160 V/V). |
| threeleads | True for 3-lead operation, false for 2-lead operation. |
| 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.
| ecg_speed | ECG sample-rate selector (0..2). |
| ecg_gain | ECG gain selector (0..3). |
| ecg_threeleads | True for 3-lead ECG mode. |
| bioz_speed | BIOZ sample-rate selector (0..1). |
| bioz_gain | BIOZ gain selector (0..3). |
| bioz_dlpf | BIOZ digital LPF selector (0..3). |
| bioz_dhpf | BIOZ digital HPF selector (0..3). |
| bioz_frequency | BIOZ modulation frequency target in Hz. |
| bioz_current | BIOZ drive current target in nA. |
| bioz_phase | BIOZ phase offset target in degrees. |
| leadbias | True to configure lead bias. |
| leadsoffdetect | True to configure lead-off detection. |
| bioz_fourleads | True for 4-wire BIOZ assumptions. |
| 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.
| speed | ECG sample-rate selector (0..2). |
| gain | ECG gain selector (0..3). |
| void MAX30001G::start | ( | void | ) |
Start measurement engines according to the most recent setup profile.
| void MAX30001G::startBIOZScan | ( | void | ) |
Start state-machine style BIOZ scan flow.
Arms non-blocking scan execution; each update() call advances scan steps.
| void MAX30001G::startECGManualRecovery | ( | void | ) |
| void MAX30001G::stepBIOZScan | ( | void | ) |
Advance state-machine style BIOZ scan flow by one step.
Executes one non-blocking scan state transition per call.
| void MAX30001G::stop | ( | void | ) |
Stop active measurement engines.
| void MAX30001G::stopBIOZScan | ( | void | ) |
Stop state-machine style BIOZ scan flow.
Stops scan flow and powers down AFE engines.
| void MAX30001G::stopECGManualRecovery | ( | void | ) |
| void MAX30001G::swReset | ( | void | ) |
| void MAX30001G::synch | ( | void | ) |
| bool MAX30001G::update | ( | bool | reportRaw = false | ) |
Service pending IRQ work and drain enabled FIFOs.
| reportRaw | True to keep raw ADC codes, false to convert to engineering units. |
|
inline |
Alias for raw-code update cycle.