no comment

Dependents:   MAX30100_FirstTry MAX30100_V04

Fork of MAX30100 by TESIS SATUROMETRICA

Committer:
Ferszt
Date:
Tue Mar 28 23:16:21 2017 +0000
Revision:
1:e96604eb8062
Parent:
0:c8da8e2afe09
no change;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Ferszt 0:c8da8e2afe09 1 /*
Ferszt 0:c8da8e2afe09 2 Library for the Maxim MAX30100 pulse oximetry system
Ferszt 0:c8da8e2afe09 3 Connor Huffine/Kontakt
Ferszt 0:c8da8e2afe09 4 February 2016
Ferszt 0:c8da8e2afe09 5 */
Ferszt 0:c8da8e2afe09 6
Ferszt 0:c8da8e2afe09 7 // Registers
Ferszt 0:c8da8e2afe09 8 #define MAX30100_INT_STATUS 0x00 // Which interrupts are tripped
Ferszt 0:c8da8e2afe09 9 #define MAX30100_INT_ENABLE 0x01 // Which interrupts are active
Ferszt 0:c8da8e2afe09 10 #define MAX30100_FIFO_WR_PTR 0x02 // Where data is being written
Ferszt 0:c8da8e2afe09 11 #define MAX30100_OVRFLOW_CTR 0x03 // Number of lost samples
Ferszt 0:c8da8e2afe09 12 #define MAX30100_FIFO_RD_PTR 0x04 // Where to read from
Ferszt 0:c8da8e2afe09 13 #define MAX30100_FIFO_DATA 0x05 // Ouput data buffer
Ferszt 0:c8da8e2afe09 14 #define MAX30100_MODE_CONFIG 0x06 // Control register
Ferszt 0:c8da8e2afe09 15 #define MAX30100_SPO2_CONFIG 0x07 // Oximetry settings
Ferszt 0:c8da8e2afe09 16 #define MAX30100_LED_CONFIG 0x09 // Pulse width and power of LEDs
Ferszt 0:c8da8e2afe09 17 #define MAX30100_TEMP_INTG 0x16 // Temperature value, whole number
Ferszt 0:c8da8e2afe09 18 #define MAX30100_TEMP_FRAC 0x17 // Temperature value, fraction
Ferszt 0:c8da8e2afe09 19 #define MAX30100_REV_ID 0xFE // Part revision
Ferszt 0:c8da8e2afe09 20 #define MAX30100_PART_ID 0xFF // Part ID, normally 0x11
Ferszt 0:c8da8e2afe09 21
Ferszt 0:c8da8e2afe09 22 #define MAX30100_ADDRESS 0x57 // 8bit address converted to 7bit
Ferszt 0:c8da8e2afe09 23
Ferszt 0:c8da8e2afe09 24 //typedef unsigned char uint8_t;
Ferszt 0:c8da8e2afe09 25 //typedef unsigned int uint16_t;
Ferszt 0:c8da8e2afe09 26 typedef enum{ // This is the same for both LEDs
Ferszt 0:c8da8e2afe09 27 pw200, // 200us pulse
Ferszt 0:c8da8e2afe09 28 pw400, // 400us pulse
Ferszt 0:c8da8e2afe09 29 pw800, // 800us pulse
Ferszt 0:c8da8e2afe09 30 pw1600 // 1600us pulse
Ferszt 0:c8da8e2afe09 31 }pulseWidth;
Ferszt 0:c8da8e2afe09 32
Ferszt 0:c8da8e2afe09 33 typedef enum{
Ferszt 0:c8da8e2afe09 34 sr50, // 50 samples per second
Ferszt 0:c8da8e2afe09 35 sr100, // 100 samples per second
Ferszt 0:c8da8e2afe09 36 sr167, // 167 samples per second
Ferszt 0:c8da8e2afe09 37 sr200, // 200 samples per second
Ferszt 0:c8da8e2afe09 38 sr400, // 400 samples per second
Ferszt 0:c8da8e2afe09 39 sr600, // 600 samples per second
Ferszt 0:c8da8e2afe09 40 sr800, // 800 samples per second
Ferszt 0:c8da8e2afe09 41 sr1000 // 1000 samples per second
Ferszt 0:c8da8e2afe09 42 }sampleRate;
Ferszt 0:c8da8e2afe09 43
Ferszt 0:c8da8e2afe09 44 typedef enum{
Ferszt 0:c8da8e2afe09 45 i0, // No current
Ferszt 0:c8da8e2afe09 46 i4, // 4.4mA
Ferszt 0:c8da8e2afe09 47 i8, // 7.6mA
Ferszt 0:c8da8e2afe09 48 i11, // 11.0mA
Ferszt 0:c8da8e2afe09 49 i14, // 14.2mA
Ferszt 0:c8da8e2afe09 50 i17, // 17.4mA
Ferszt 0:c8da8e2afe09 51 i21, // 20.8mA
Ferszt 0:c8da8e2afe09 52 i27, // 27.1mA
Ferszt 0:c8da8e2afe09 53 i31, // 30.6mA
Ferszt 0:c8da8e2afe09 54 i34, // 33.8mA
Ferszt 0:c8da8e2afe09 55 i37, // 37.0mA
Ferszt 0:c8da8e2afe09 56 i40, // 40.2mA
Ferszt 0:c8da8e2afe09 57 i44, // 43.6mA
Ferszt 0:c8da8e2afe09 58 i47, // 46.8mA
Ferszt 0:c8da8e2afe09 59 i50 // 50.0mA
Ferszt 0:c8da8e2afe09 60 }ledCurrent;
Ferszt 0:c8da8e2afe09 61
Ferszt 0:c8da8e2afe09 62 class MAX30100 {
Ferszt 0:c8da8e2afe09 63 public:
Ferszt 0:c8da8e2afe09 64 uint16_t IR; // Last IR reflectance datapoint 0 defoult
Ferszt 0:c8da8e2afe09 65 uint16_t RED; // Last Red reflectance datapoint 0 defoult
Ferszt 0:c8da8e2afe09 66
Ferszt 0:c8da8e2afe09 67 MAX30100();
Ferszt 0:c8da8e2afe09 68 void setLEDs(pulseWidth pw, ledCurrent red, ledCurrent ir); // Sets the LED state
Ferszt 0:c8da8e2afe09 69 void setSPO2(sampleRate sr); // Setup the SPO2 sensor, disabled by default
Ferszt 0:c8da8e2afe09 70 int getNumSamp(void); // Get number of samples
Ferszt 0:c8da8e2afe09 71 void readSensor(void); // Updates the values
Ferszt 0:c8da8e2afe09 72 void shutdown(void); // Instructs device to power-save
Ferszt 0:c8da8e2afe09 73 void reset(void); // Resets the device
Ferszt 0:c8da8e2afe09 74 void startup(void); // Leaves power-save
Ferszt 0:c8da8e2afe09 75 int getRevID(void); // Gets revision ID
Ferszt 0:c8da8e2afe09 76 int getPartID(void); // Gets part ID
Ferszt 0:c8da8e2afe09 77 void begin(pulseWidth pw = pw1600, // Longest pulseWidth
Ferszt 0:c8da8e2afe09 78 ledCurrent ir = i50, // Highest current
Ferszt 0:c8da8e2afe09 79 sampleRate sr = sr100); // 2nd lowest sampleRate
Ferszt 0:c8da8e2afe09 80 void printRegisters(void); // Dumps contents of registers for debug
Ferszt 0:c8da8e2afe09 81
Ferszt 0:c8da8e2afe09 82 private:
Ferszt 0:c8da8e2afe09 83 void I2CwriteByte(uint8_t address, uint8_t subAddress, uint8_t data);
Ferszt 0:c8da8e2afe09 84 uint8_t I2CreadByte(uint8_t address, uint8_t subAddress);
Ferszt 0:c8da8e2afe09 85 void I2CreadBytes(uint8_t address, uint8_t subAddress, uint8_t * dest, uint8_t count);
Ferszt 0:c8da8e2afe09 86 };