|
MAX30001G
1.3.0
Arduino library for MAX30001G ECG and BIOZ AFE
|
The driver keeps default behavior in serviceAllInterrupts() (updates global flags), and also supports user callbacks. For most sketches, prefer update() in loop(). It services pending IRQs, drains enabled FIFOs, reads RTOR when configured, and falls back to serviceAllInterrupts() when needed. Use servicePendingInterrupts() directly only in lower-level custom loops where you want interrupt servicing without the rest of the normal update() data-path work.
Wire MAX30001G INTB (and optional INT2B) to interrupt-capable GPIO pins and pass those pins to the constructor.
servicePendingInterrupts() uses Arduino core APIs noInterrupts() and interrupts() to atomically read/clear the software pending flags. These APIs are available on AVR, SAMD, ESP8266, and ESP32 Arduino cores, so no API change is needed for ESP-type boards.
If your board does not wire interrupt pins, update() falls back to serviceAllInterrupts(). If you are not using update(), call serviceAllInterrupts() periodically instead. If you provide your own ISR, set library globals afe_irq_pending and afe_irq1_pending/afe_irq2_pending (do not use a separate local pending flag). If you use latched event/fault globals, clear them explicitly with clearLatchedStatusFlags() after handling.
setInterrupt1(...) and setInterrupt2(...) program MAX30001G EN_INT1 and EN_INT2.
Example:
MAX30001G::IRQ_ECG_FIFO -> MAX30001_STATUS_EINTMAX30001G::IRQ_ECG_OVF -> MAX30001_STATUS_EOVFMAX30001G::IRQ_ECG_FAST -> MAX30001_STATUS_FSTINTMAX30001G::IRQ_ECG_LEADOFF -> MAX30001_STATUS_DCLOFFINTMAX30001G::IRQ_BIOZ_FIFO -> MAX30001_STATUS_BINTMAX30001G::IRQ_BIOZ_OVF -> MAX30001_STATUS_BOVFMAX30001G::IRQ_BIOZ_OVER -> MAX30001_STATUS_BOVERMAX30001G::IRQ_BIOZ_UNDER -> MAX30001_STATUS_BUNDRMAX30001G::IRQ_BIOZ_CGMON -> MAX30001_STATUS_BCGMONMAX30001G::IRQ_LEADS_ON -> MAX30001_STATUS_LONINTMAX30001G::IRQ_RTOR -> MAX30001_STATUS_RRINTMAX30001G::IRQ_PLL_UNLOCK -> MAX30001_STATUS_PLLINTIf aggregate and individual callbacks are both registered, aggregate runs first.
setInterruptEventCallback(event, cb, context)clearInterruptEventCallback(event)setInterruptAggregateCallback(cb, context, statusMask)clearInterruptAggregateCallback()clearAllInterruptCallbacks()clearLatchedStatusFlags()