Library for MAX30101, read/write functions for registers implemented.

Dependents:   test_MAX30101 testSensor

Committer:
Rhyme
Date:
Mon Mar 27 05:30:28 2017 +0000
Revision:
2:c465a8d44b9a
Parent:
1:fc677d82d0f1
Child:
3:d28dcc8fe74d
First commit

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Rhyme 0:4ad9373787e8 1 /**
Rhyme 0:4ad9373787e8 2 * MAX30101
Rhyme 0:4ad9373787e8 3 * High-Sensitivity Pulse Oximeter and
Rhyme 0:4ad9373787e8 4 * Heart-Rate Sensor for Wearable Health
Rhyme 0:4ad9373787e8 5 */
Rhyme 0:4ad9373787e8 6 #ifndef _MAX30101_H_
Rhyme 0:4ad9373787e8 7 #define _MAX30101_H_
Rhyme 0:4ad9373787e8 8
Rhyme 0:4ad9373787e8 9 class MAX30101
Rhyme 0:4ad9373787e8 10 {
Rhyme 0:4ad9373787e8 11 public:
Rhyme 0:4ad9373787e8 12 /**
Rhyme 0:4ad9373787e8 13 * MAX30101 constructor
Rhyme 0:4ad9373787e8 14 *
Rhyme 0:4ad9373787e8 15 * @param sda SDA pin
Rhyme 0:4ad9373787e8 16 * @param scl SCL pin
Rhyme 0:4ad9373787e8 17 * @param addr 7bit address of the I2C peripheral
Rhyme 0:4ad9373787e8 18 */
Rhyme 0:4ad9373787e8 19 MAX30101(PinName sda, PinName scl, int addr) ;
Rhyme 0:4ad9373787e8 20
Rhyme 0:4ad9373787e8 21 ~MAX30101() ;
Rhyme 0:4ad9373787e8 22
Rhyme 1:fc677d82d0f1 23 uint8_t getID(void) ;
Rhyme 1:fc677d82d0f1 24 uint8_t getRev(void) ;
Rhyme 1:fc677d82d0f1 25 uint16_t getIntStatus(void) ;
Rhyme 2:c465a8d44b9a 26 uint16_t getIntEnable(void) ;
Rhyme 1:fc677d82d0f1 27 void setIntEnable(uint16_t mask) ;
Rhyme 1:fc677d82d0f1 28 uint8_t getFIFO_WR_PTR(void) ;
Rhyme 1:fc677d82d0f1 29 void setFIFO_WR_PTR(uint8_t data) ;
Rhyme 1:fc677d82d0f1 30 uint8_t getOVF_COUNTER(void) ;
Rhyme 1:fc677d82d0f1 31 void setOVF_COUNTER(uint8_t data) ;
Rhyme 1:fc677d82d0f1 32 uint8_t getFIFO_RD_PTR(void) ;
Rhyme 1:fc677d82d0f1 33 void setFIFO_RD_PTR(uint8_t data) ;
Rhyme 1:fc677d82d0f1 34 uint8_t getFIFO_DATA(void) ;
Rhyme 1:fc677d82d0f1 35 void setFIFO_DATA(uint8_t data) ;
Rhyme 1:fc677d82d0f1 36 uint8_t getFIFO_CONFIG(void) ;
Rhyme 1:fc677d82d0f1 37 void setFIFO_CONFIG(uint8_t data) ;
Rhyme 1:fc677d82d0f1 38 uint8_t getMODE_CONFIG(void) ;
Rhyme 1:fc677d82d0f1 39 void setMODE_CONFIG(uint8_t data) ;
Rhyme 1:fc677d82d0f1 40 uint8_t getSPO2_CONFIG(void) ;
Rhyme 1:fc677d82d0f1 41 void setSPO2_CONFIG(uint8_t data) ;
Rhyme 1:fc677d82d0f1 42 uint8_t getLED1_PA(void) ;
Rhyme 1:fc677d82d0f1 43 void setLED1_PA(uint8_t data) ;
Rhyme 1:fc677d82d0f1 44 uint8_t getLED2_PA(void) ;
Rhyme 1:fc677d82d0f1 45 void setLED2_PA(uint8_t data) ;
Rhyme 1:fc677d82d0f1 46 uint8_t getLED3_PA(void) ;
Rhyme 1:fc677d82d0f1 47 void setLED3_PA(uint8_t data) ;
Rhyme 1:fc677d82d0f1 48 uint8_t getPILOT_PA(void) ;
Rhyme 1:fc677d82d0f1 49 void setPILOT_PA(uint8_t data) ;
Rhyme 1:fc677d82d0f1 50 uint16_t getSLOT(void) ;
Rhyme 1:fc677d82d0f1 51 void setSLOT(uint16_t data) ;
Rhyme 1:fc677d82d0f1 52 uint8_t getTEMP_INT(void) ;
Rhyme 2:c465a8d44b9a 53 uint8_t getTEMP_FRAC(void) ;
Rhyme 1:fc677d82d0f1 54 uint8_t getTEMP_EN(void) ; /* ? */
Rhyme 2:c465a8d44b9a 55 void setTEMP_EN(void) ;
Rhyme 2:c465a8d44b9a 56 float getTEMP(void) ;
Rhyme 1:fc677d82d0f1 57 uint8_t getPROX_INT_THR(void) ;
Rhyme 1:fc677d82d0f1 58 void setPROX_INT_THR(uint8_t data) ;
Rhyme 2:c465a8d44b9a 59 void clearFIFO(void) ;
Rhyme 2:c465a8d44b9a 60 uint32_t readFIFO(void) ;
Rhyme 2:c465a8d44b9a 61 void reset(void) ;
Rhyme 0:4ad9373787e8 62
Rhyme 0:4ad9373787e8 63 /*
Rhyme 0:4ad9373787e8 64 * some member functions here (yet to be written)
Rhyme 0:4ad9373787e8 65 */
Rhyme 0:4ad9373787e8 66
Rhyme 0:4ad9373787e8 67 private:
Rhyme 0:4ad9373787e8 68 I2C m_i2c;
Rhyme 0:4ad9373787e8 69 int m_addr;
Rhyme 0:4ad9373787e8 70 void readRegs(int addr, uint8_t *data, int len) ;
Rhyme 0:4ad9373787e8 71 void writeRegs(uint8_t *data, int len) ;
Rhyme 0:4ad9373787e8 72 } ;
Rhyme 2:c465a8d44b9a 73
Rhyme 2:c465a8d44b9a 74 /* bits of Interrupt Status register */
Rhyme 2:c465a8d44b9a 75 /* In this class Interrupt Status 1 and
Rhyme 2:c465a8d44b9a 76 * Interrupt Status 2 are combined to be a uint16_t
Rhyme 2:c465a8d44b9a 77 */
Rhyme 2:c465a8d44b9a 78 #define INT_ST_A_FULL 0x8000 /* FIFO Almost Full Flag */
Rhyme 2:c465a8d44b9a 79 #define INT_ST_PPG_RGY 0x4000 /* New FIFO Data Ready */
Rhyme 2:c465a8d44b9a 80 #define INT_ST_ALC_OVF 0x2000 /* Ambient Light Cancellation Overflow */
Rhyme 2:c465a8d44b9a 81 #define INT_ST_PROX_INT 0x1000 /* Proximity Threshold Triggered */
Rhyme 2:c465a8d44b9a 82 #define INT_ST_PWR_RDY 0x0100 /* Power Ready Flag */
Rhyme 2:c465a8d44b9a 83 #define INT_ST_DIE_TEMP_RDY 0x0002 /* Internal Temperature Ready Flag */
Rhyme 2:c465a8d44b9a 84 /* bits of Interrupt Enable register */
Rhyme 2:c465a8d44b9a 85 #define INT_EN_A_FULL 0x8000 /* FIFO Almost Full Flag */
Rhyme 2:c465a8d44b9a 86 #define INT_EN_PPG_RGY 0x4000 /* New FIFO Data Ready */
Rhyme 2:c465a8d44b9a 87 #define INT_EN_ALC_OVF 0x2000 /* Ambient Light Cancellation Overflow */
Rhyme 2:c465a8d44b9a 88 #define INT_EN_PROX_INT 0x1000 /* Proximity Threshold Triggered */
Rhyme 2:c465a8d44b9a 89 #define INT_EN_DIE_TEMP_RDY 0x0002 /* Internal Temperature Ready Flag */
Rhyme 2:c465a8d44b9a 90 /* Mode configuration bits */
Rhyme 2:c465a8d44b9a 91 #define MODE_HR 0x02 /* Heart Rate mode */
Rhyme 2:c465a8d44b9a 92 #define MODE_SPO2 0x03 /* SpO2 mode */
Rhyme 2:c465a8d44b9a 93 #define MODE_MULTI_LED 0x07 /* Multi-LED mode */
Rhyme 2:c465a8d44b9a 94 #define MODE_RESET 0x40 /* Reset Control, this bit is auto clear */
Rhyme 2:c465a8d44b9a 95 #define MODE_SHDN 0x80 /* Shutdown Control */
Rhyme 2:c465a8d44b9a 96
Rhyme 2:c465a8d44b9a 97
Rhyme 0:4ad9373787e8 98 #endif /* _MAX30101_H_ */