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 /******************************************************************************* 00002 * Copyright (C) 2018 Maxim Integrated Products, Inc., All Rights Reserved. 00003 * 00004 * Permission is hereby granted, free of charge, to any person obtaining a 00005 * copy of this software and associated documentation files (the "Software"), 00006 * to deal in the Software without restriction, including without limitation 00007 * the rights to use, copy, modify, merge, publish, distribute, sublicense, 00008 * and/or sell copies of the Software, and to permit persons to whom the 00009 * Software is furnished to do so, subject to the following conditions: 00010 * 00011 * The above copyright notice and this permission notice shall be included 00012 * in all copies or substantial portions of the Software. 00013 * 00014 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 00015 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 00016 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 00017 * IN NO EVENT SHALL MAXIM INTEGRATED BE LIABLE FOR ANY CLAIM, DAMAGES 00018 * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 00019 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 00020 * OTHER DEALINGS IN THE SOFTWARE. 00021 * 00022 * Except as contained in this notice, the name of Maxim Integrated 00023 * Products, Inc. shall not be used except as stated in the Maxim Integrated 00024 * Products, Inc. Branding Policy. 00025 * 00026 * The mere transfer of this software does not imply any licenses 00027 * of trade secrets, proprietary technology, copyrights, patents, 00028 * trademarks, maskwork rights, or any other form of intellectual 00029 * property whatsoever. Maxim Integrated Products, Inc. retains all 00030 * ownership rights. 00031 ******************************************************************************* 00032 */ 00033 #include "mbed.h" 00034 #include "max32630hsp.h" 00035 #include "USBSerial.h" 00036 #include "MAX30205.h" 00037 00038 MAX32630HSP icarus(MAX32630HSP::VIO_3V3); 00039 00040 Serial pc(USBTX,USBRX); 00041 00042 // Virtual serial port over USB 00043 USBSerial microUSB; 00044 00045 DigitalOut rLED(LED1); 00046 DigitalOut gLED(LED2); 00047 DigitalOut bLED(LED3); 00048 00049 //Get I2C instance 00050 I2C i2cBus(I2C1_SDA, I2C1_SCL); 00051 00052 //Enable pin to convert 3V3 to 3V for MAX30205: 00053 DigitalOut max30205_LDO_EN(P7_1,1); 00054 00055 //Get temp sensor instance 00056 MAX30205 bodyTempSensor(i2cBus, (0x90 >> 1)); 00057 00058 // main() runs in its own thread in the OS 00059 // (note the calls to Thread::wait below for delays) 00060 00061 /** 00062 * @brief Sample main program for MAX30205 00063 * @version 1.0000.0 00064 * 00065 * @details Sample main program for MAX30205. 00066 * The prints are sent to the terminal window (9600, 8n1). 00067 * The program initially flashes yellow once, then it 00068 * blinks green if it's able to communicate with 00069 * the MAX30205, otherwise, it blinks red. 00070 * The temperature is read out every half second. 00071 * To run the program, drag and drop the .bin file into the 00072 * DAPLINK folder. After it finishes flashing, cycle the power or 00073 * reset the Pegasus after flashing by pressing the button on 00074 * the Pegasus next to the battery connector or the button 00075 * on the MAXREFDES100HDK. 00076 */ 00077 00078 int main() 00079 { 00080 int32_t ret; 00081 uint16_t hystValue = 0; 00082 uint16_t temperatureValue; 00083 uint32_t expandTemperatureValue=0; 00084 float Celsius; 00085 00086 gLED = LED_ON; 00087 rLED = LED_ON; // init LED to yellow 00088 bLED = LED_OFF; 00089 wait(0.05); 00090 00091 pc.printf("Example program for MAX20305.\r\n"); 00092 ret = bodyTempSensor.readTHYST(hystValue); 00093 if (ret != 0) { 00094 pc.printf("Communications to MAX20305 Failed: ret=%d, Thyst=0x%04X\r\n",ret, hystValue); 00095 rLED = LED_ON; 00096 } 00097 00098 while(true) { 00099 ret=bodyTempSensor.readTemperature(temperatureValue); 00100 if(!ret) 00101 { 00102 expandTemperatureValue = (uint32_t)temperatureValue; 00103 Celsius = bodyTempSensor.toCelsius(expandTemperatureValue); 00104 pc.printf("The temperature is %f Celsius, ",Celsius); 00105 pc.printf("%f Fahrenheit\r\n",bodyTempSensor.toFahrenheit(Celsius)); 00106 00107 rLED = LED_OFF; 00108 gLED = !gLED; // blink the green red 00109 bLED = LED_OFF; 00110 } else { 00111 rLED = !rLED; // blink the LED red 00112 gLED = LED_OFF; 00113 bLED = LED_OFF; 00114 } 00115 wait(0.5); 00116 00117 } 00118 00119 } 00120
Generated on Sun Jul 17 2022 16:54:33 by
1.7.2