Library for MAX30101 SpO2 and heart rate sensor

Dependents:   HeartRate HeartRate proj final_project_ee119 ... more

Revision:
3:a2effad05c99
Parent:
2:0db1f3bec727
Child:
4:d1b50bd4065a
--- a/MAX30101.h	Mon May 01 21:00:34 2017 +0000
+++ b/MAX30101.h	Thu May 04 23:44:48 2017 +0000
@@ -68,6 +68,10 @@
     static const uint8_t I2C_W_ADRS = 0xAE;
     ///8-bit read address
     static const uint8_t I2C_R_ADRS = 0xAF;
+    ///Max # Bytes in FIFO
+    static const uint16_t MAX_FIFO_BYTES = 288;
+    ///# of bytes per LED channel
+    static const uint8_t BYTES_PER_CH = 3;
     
     ///MAX30101 Register Map
     enum Registers_e
@@ -97,6 +101,14 @@
         PartID             = 0xFF
     };
     
+    ///MAX30101 Operational Modes
+    enum OpModes_e
+    {
+        HeartRateMode = 2,
+        SpO2Mode      = 3,
+        MultiLedMode  = 7
+    };
+    
     ///Interrupt Status/Enable BitField
     union InterruptBitField_u
     {
@@ -323,6 +335,17 @@
     * @return 0 on success, non 0 otherwise
     */
     int32_t getProxIntThreshold(uint8_t &data);
+    
+    /** 
+    * @brief Attempts to read numBytes of data from FIFO
+    *
+    * @param numLeds - Number of LED channels used; 0 < numLeds < 4
+    * @param data - pointer to buffer for holding read data
+    * @param[out] readBytes - number of bytes read from fifo
+    *
+    * @return 0 on success, non 0 otherwise
+    */
+    int32_t readFIFO(uint8_t numLeds, uint8_t *data, uint16_t &readBytes);
 
 protected:
 
@@ -345,6 +368,8 @@
 private:
 
     I2C m_i2cBus;
+    uint8_t m_fifoReadPtr, m_fifoWritePtr, m_fifoNumBytes;
+    
 
 };