Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: StepOne (store accelerometer value)
max30100.h
00001 /* 00002 Library for the Maxim MAX30100 pulse oximetry system 00003 */ 00004 00005 /* Define to prevent recursive inclusion -------------------------------------*/ 00006 #ifndef __MAX30100_H 00007 #define __MAX30100_H 00008 00009 #include "mbed.h" 00010 00011 00012 /******************************************************************************/ 00013 /*********** PULSE OXIMETER AND HEART RATE REGISTER MAPPING **************/ 00014 /******************************************************************************/ 00015 00016 // status registers 00017 #define MAX30100_INT_STATUS 0x00 00018 #define MAX30100_INT_ENABLE 0x01 00019 00020 // FIFO registers 00021 #define MAX30100_FIFO_W_POINTER 0x02 00022 #define MAX30100_OVR_COUNTER 0x03 00023 #define MAX30100_FIFO_R_POINTER 0x04 00024 #define MAX30100_FIFO_DATA_REG 0x05 00025 00026 // configuration registers 00027 #define MAX30100_CONFIG 0x06 00028 #define MAX30100_SPO2_CONFIG 0x07 00029 #define MAX30100_LED_CONFIG 0x09 00030 00031 // temperature registers 00032 #define MAX30100_TEMP_INTEGER 0x16 00033 #define MAX30100_TEMP_FRACTION 0x17 00034 00035 // PART ID registers 00036 #define MAX30100_REVISION_ID 0xFE 00037 #define MAX30100_PART_ID 0xFF 00038 00039 #define I_AM_MAX30100 0x11 00040 00041 /************************************** REGISTERS VALUE *******************************************/ 00042 00043 // I2C address 00044 #define MAX30100_ADDRESS 0xAE 00045 00046 //Enable interrupts 00047 #define MAX30100_INT_ENB_A_FULL ((uint8_t)0x80) 00048 #define MAX30100_INT_ENB_TEMP_RDY ((uint8_t)0x40) 00049 #define MAX30100_INT_ENB_HR_RDY ((uint8_t)0x20) 00050 #define MAX30100_INT_ENB_SO2_RDY ((uint8_t)0x10) 00051 00052 //Mode configuration 00053 #define MAX30100_MODE_SHDN ((uint8_t)0x80) 00054 #define MAX30100_MODE_RESET ((uint8_t)0x40) 00055 #define MAX30100_MODE_TEMP_EN ((uint8_t)0x08) 00056 #define MAX30100_MODE_HR ((uint8_t)0x02) 00057 #define MAX30100_MODE_SPO2 ((uint8_t)0x03) 00058 00059 //SPO2 configuration 00060 #define MAX30100_SPO2_HI_RES_EN ((uint8_t)0x40) 00061 00062 typedef enum{ // This is the same for both LEDs 00063 pw200, // 200us pulse 00064 pw400, // 400us pulse 00065 pw800, // 800us pulse 00066 pw1600 // 1600us pulse 00067 }pulseWidth; 00068 00069 typedef enum{ 00070 sr50, // 50 samples per second 00071 sr100, // 100 samples per second 00072 sr167, // 167 samples per second 00073 sr200, // 200 samples per second 00074 sr400, // 400 samples per second 00075 sr600, // 600 samples per second 00076 sr800, // 800 samples per second 00077 sr1000 // 1000 samples per second 00078 }sampleRate; 00079 00080 typedef enum{ 00081 i0, // No current 00082 i4, // 4.4mA 00083 i8, // 7.6mA 00084 i11, // 11.0mA 00085 i14, // 14.2mA 00086 i17, // 17.4mA 00087 i21, // 20.8mA 00088 i27, // 27.1mA 00089 i31, // 30.6mA 00090 i34, // 33.8mA 00091 i37, // 37.0mA 00092 i40, // 40.2mA 00093 i44, // 43.6mA 00094 i47, // 46.8mA 00095 i50 // 50.0mA 00096 }ledCurrent; 00097 00098 typedef enum{ 00099 low, // low resolution SPO2 00100 high // high resolution SPO2 (16 bit with 1.6ms LED pulse width) 00101 }high_resolution; 00102 00103 typedef enum 00104 { 00105 OXIMETER_OK = 0, 00106 OXIMETER_ERROR = 1, 00107 OXIMETER_TIMEOUT = 2, 00108 OXIMETER_NOT_IMPLEMENTED = 3 00109 } OXIMETER_StatusTypeDef; 00110 00111 /** 00112 * @brief MAX30100 driver extended internal structure definition 00113 */ 00114 typedef struct 00115 { 00116 OXIMETER_StatusTypeDef (*Enable_Free_Fall_Detection) (void); 00117 OXIMETER_StatusTypeDef (*Disable_Free_Fall_Detection) (void); 00118 OXIMETER_StatusTypeDef (*Get_Status_Free_Fall_Detection) (uint8_t *); 00119 } MAX30100_DrvExtTypeDef; 00120 00121 class MAX30100 { 00122 public: 00123 00124 /* Public Methods */ 00125 00126 uint16_t HR; // Last heart rate datapoint 00127 uint16_t SPO2; // Last oximetry datapoint 00128 00129 void setLEDs(pulseWidth pw, ledCurrent red, ledCurrent ir); // Sets the LED state 00130 void setSPO2(sampleRate sr, high_resolution hi_res); // Setup the SPO2 sensor, disabled by default 00131 int getNumSamp(void); // Get number of samples 00132 void readSensor(void); // Updates the values 00133 void shutdown(void); // Instructs device to power-save 00134 void reset(void); // Resets the device 00135 void startup(void); // Leaves power-save 00136 char getRevID(void); // Gets revision ID 00137 char getPartID(void); // Gets part ID 00138 void begin(pulseWidth pw = pw1600, // Longest pulseWidth 00139 ledCurrent ir = i50, // Highest current 00140 sampleRate sr = sr100); // 2nd lowest sampleRate 00141 void init(pulseWidth pw, sampleRate sr, high_resolution hi_res, ledCurrent red, ledCurrent ir); 00142 void setTemp(void); 00143 int readTemp(void); 00144 void setSPO2mode(void); 00145 void setInterruptSPO2(void); 00146 void printRegisters(void); // Dumps contents of registers for debug 00147 }; 00148 00149 #endif /* __MAX30100_H */
Generated on Wed Jul 13 2022 12:35:26 by
1.7.2