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.
main.cpp
00001 #include "mbed.h" 00002 #include "MAX14720.h" 00003 #include "MAX30205.h" 00004 #include "BMP280.h" 00005 #include "USBSerial.h" 00006 //#include "MAX30001.h" 00007 //#include "QuadSpiInterface.h" 00008 //#include "S25FS512.h" 00009 //#include "MAX30101.h" 00010 00011 //Define all I2C addresses 00012 #define MAX30205_I2C_SLAVE_ADDR_TOP (0x92) 00013 #define MAX30205_I2C_SLAVE_ADDR_BOTTOM (0x90) 00014 #define MAX14720_I2C_SLAVE_ADDR (0x54) 00015 #define BMP280_I2C_SLAVE_ADDR (0xEC) 00016 00017 00018 #define HVOUT_VOLTAGE 4500 // set to 4500 mV 00019 00020 // Define with Maxim VID and a Maxim assigned PID, set to version 0x0001 and non-blocking 00021 USBSerial usbSerial(0x0b6a, 0x0100, 0x0001, false); 00022 00023 // I2C Masters 00024 I2C i2c1(I2C1_SDA, I2C1_SCL); 00025 I2C i2c2(I2C2_SDA, I2C2_SCL); 00026 00027 // Top local Temperature Sensor 00028 MAX30205 MAX30205_top(&i2c1, MAX30205_I2C_SLAVE_ADDR_TOP); 00029 00030 // Botttom local Temperature Sensor 00031 MAX30205 MAX30205_bottom(&i2c1, MAX30205_I2C_SLAVE_ADDR_BOTTOM); 00032 00033 // Barometric Pressure Sensor 00034 BMP280 bmp280_pres(&i2c1, BMP280_I2C_SLAVE_ADDR); 00035 00036 //PMIC 00037 MAX14720 max14720(&i2c2,MAX14720_I2C_SLAVE_ADDR); 00038 00039 ///// External Flash 00040 //S25FS512 s25fs512(&quadSpiInterface); 00041 00042 /// PWM used as fclk for the MAX30001 00043 PwmOut pwmout(P1_7); 00044 00045 00046 DigitalOut led(LED1); 00047 00048 00049 void turnOff() 00050 { 00051 //write the power down command to PMIC 00052 max14720.shutdown(); 00053 } 00054 int main() 00055 { 00056 00057 // Override the default value of boostEn to BOOST_ENABLED 00058 max14720.boostEn = MAX14720::BOOST_ENABLED; 00059 // Note that writing the local value does directly affect the part 00060 // The buck-boost regulator will remain off until init is called 00061 max14720.init(); 00062 // Turn LED signal on to make buck-boost output visible 00063 max14720.boostSetVoltage(HVOUT_VOLTAGE); 00064 led = 0; 00065 00066 // Initialise the BMP280 00067 bmp280_pres.init(BMP280::OVERSAMPLING_X16_P, BMP280::OVERSAMPLING_X2_T, BMP280::FILT_4, BMP280::NORMAL_MODE, BMP280::T_62_5); 00068 00069 //Temperature sensor variables 00070 uint16_t rawTemp_top; 00071 uint16_t rawTemp_bottom ; 00072 float celsius_top, celsius_bottom; 00073 float fahrenheit_top, fahrenheit_bottom; 00074 00075 //barometric sensor variables 00076 char bmp280_rawData = 0; 00077 float Temp_degC, Press_Pa, Press_Bar; 00078 00079 00080 //Endless loop 00081 while(1) 00082 { 00083 /* Temperature Sensor Settings */ 00084 00085 //Read Temperature 00086 MAX30205_top.readTemperature(&rawTemp_top); 00087 MAX30205_bottom.readTemperature(&rawTemp_bottom); 00088 // Read BMP280 Temp. and Pressure 00089 bmp280_pres.ReadCompDataRaw(&bmp280_rawData); 00090 bmp280_pres.ToFloat(&bmp280_rawData, &Temp_degC, &Press_Pa); 00091 // Convert to Celsius 00092 celsius_top = MAX30205_top.toCelsius(rawTemp_top); 00093 celsius_bottom = MAX30205_bottom.toCelsius(rawTemp_bottom); 00094 00095 // Convert to Fahrenheit 00096 fahrenheit_top = MAX30205_top.toFahrenheit(celsius_top); 00097 fahrenheit_bottom = MAX30205_bottom.toFahrenheit(celsius_bottom); 00098 00099 /* Barometric Sensor Settings */ 00100 00101 Press_Bar = Press_Pa / 100000; 00102 00103 /* Printing various sensor values */ 00104 usbSerial.printf("***** MAX30205 Temperature Sensor Reading *****\n\r"); 00105 usbSerial.printf("Top Temperature: %.2f\370 C\n\rBottom Temperature: %.2f\370 C \n\rTop Temperature in Farenheit: %.2f\370 F\n\rBottom Temperature in Farenheit %.2f\370 F\n\n\r", celsius_top, celsius_bottom, fahrenheit_top, fahrenheit_bottom); 00106 00107 usbSerial.printf("***** BMP280 Barometric Sensor Reading *****\n\r"); 00108 usbSerial.printf("Temp_degC : %.2f , Press_Bar is %.2f , Press_pa is %.2f\n\n\r",Temp_degC, Press_Bar, Press_Pa); 00109 00110 usbSerial.printf("-------------------------------------------------\n\n\n\r"); 00111 00112 wait(0.2); 00113 00114 00115 00116 } 00117 }
Generated on Wed Jul 13 2022 02:29:55 by
1.7.2