MAX30205EVSYS demo program designed for implementation with the MAX32630FTHR. The MAX30205 can be integrated to the MAX32630FTHR by fly-wires or integration of the MAX30101WING. The program output temperature data every second to a serial terminal.

Dependencies:   MAX30205 max32630fthr

Fork of MAX30205_Demo by John Greene

Revision:
0:6e28e543a11c
Child:
1:1cab60b84d7f
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Wed Aug 16 22:58:45 2017 +0000
@@ -0,0 +1,94 @@
+#include "mbed.h"
+#include "max32630fthr.h"
+#include "MAX30205.h"
+
+MAX32630FTHR pegasus(MAX32630FTHR::VIO_3V3);
+
+bool temp_sensor_config(MAX30205 &temp_sensor);
+
+
+// main() runs in its own thread in the OS
+// (note the calls to Thread::wait below for delays)
+int main()
+{
+    
+    Serial pc(USBTX, USBRX);
+    pc.baud(115200);
+        
+    DigitalOut rLed(LED1, LED_OFF);
+    DigitalOut gLed(LED2, LED_OFF);
+    DigitalOut bLed(LED3, LED_OFF);
+    
+    I2C i2cBus(I2C1_SDA, I2C1_SCL);    
+    
+    MAX30205 * temp_sensor;
+    temp_sensor = new MAX30205(i2cBus, 0x48);
+    int rc = temp_sensor_config(*temp_sensor);
+    
+    Timer temp_sensor_sampleTimer;
+    temp_sensor_sampleTimer.start();
+    
+    MAX30205::Configuration_u temp_cfg;
+    uint16_t rawTemperatureRead, temp_conversion_flag;
+    float temperature;
+    
+    while(1) {
+        
+        if( rc == 0 ) {
+        
+            /* Start a new temperature conversion */
+            if ( temp_sensor_sampleTimer.read() > 1.0 && !temp_conversion_flag){
+                
+                temp_cfg.bits.one_shot = 1;
+                rc = temp_sensor->writeConfiguration(temp_cfg);    
+                temp_conversion_flag = 1;
+                
+            } 
+            
+            /* Read the completed temperature conversion */
+            if ( temp_sensor_sampleTimer.read() > 1.05 && temp_conversion_flag ){
+                
+                temp_conversion_flag = 0;               
+                rc = temp_sensor->readTemperature(rawTemperatureRead); 
+                temperature = temp_sensor->toCelsius(rawTemperatureRead);
+                temp_sensor_sampleTimer.reset(); 
+                
+                pc.printf("Temperature is %2.3f deg. C \r\n", temperature);
+                  
+            }
+        
+        }else{
+            pc.printf("Something went wrong, check the I2C bus or power connections... \r\n");
+            bLed = LED_OFF;
+            gLed = LED_OFF;
+            while(1){
+                rLed = !rLed;
+                wait(0.5);   
+            }
+        }
+    }
+}
+
+
+bool temp_sensor_config(MAX30205 &temp_sensor){
+     
+    int rc = 0;
+    
+        MAX30205::Configuration_u temp_cfg;
+        if(rc == 0) 
+        {
+            temp_cfg.all = 0;
+            temp_cfg.bits.shutdown = 1;
+            temp_cfg.bits.comp_int = 1;
+            temp_cfg.bits.os_polarity = 0;
+            temp_cfg.bits.fault_queue = 1;
+            temp_cfg.bits.data_format = 0;
+            temp_cfg.bits.timeout = 0;
+            temp_cfg.bits.one_shot = 0;
+        
+            rc = temp_sensor.writeConfiguration(temp_cfg);    
+        
+        }
+    
+    return rc;
+}