Sample main.c/cpp code for the Maxim Integrated MAX31725, MAX31726 high temperature sensor with accuracy of to +-0.5°C. Hosted on the MAX32630FTHR. Typical applications are for thermometers, thermostat and over-temperature monitoring.
Dependencies: MAX31725_Accurate_Temperature_Sensor max32630fthr USBDevice
main.cpp@3:597971685e65, 2019-04-11 (annotated)
- Committer:
- phonemacro
- Date:
- Thu Apr 11 07:10:00 2019 +0000
- Revision:
- 3:597971685e65
- Parent:
- 2:1890f1449f7c
- Child:
- 4:ca90e528fe79
Modified one-shot to print dots while in shutdown.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
phonemacro | 0:08830daf46a0 | 1 | /******************************************************************************* |
phonemacro | 0:08830daf46a0 | 2 | * Copyright (C) 2019 Maxim Integrated Products, Inc., All Rights Reserved. |
phonemacro | 0:08830daf46a0 | 3 | * |
phonemacro | 0:08830daf46a0 | 4 | * Permission is hereby granted, free of charge, to any person obtaining a |
phonemacro | 0:08830daf46a0 | 5 | * copy of this software and associated documentation files (the "Software"), |
phonemacro | 0:08830daf46a0 | 6 | * to deal in the Software without restriction, including without limitation |
phonemacro | 0:08830daf46a0 | 7 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, |
phonemacro | 0:08830daf46a0 | 8 | * and/or sell copies of the Software, and to permit persons to whom the |
phonemacro | 0:08830daf46a0 | 9 | * Software is furnished to do so, subject to the following conditions: |
phonemacro | 0:08830daf46a0 | 10 | * |
phonemacro | 0:08830daf46a0 | 11 | * The above copyright notice and this permission notice shall be included |
phonemacro | 0:08830daf46a0 | 12 | * in all copies or substantial portions of the Software. |
phonemacro | 0:08830daf46a0 | 13 | * |
phonemacro | 0:08830daf46a0 | 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS |
phonemacro | 0:08830daf46a0 | 15 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
phonemacro | 0:08830daf46a0 | 16 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. |
phonemacro | 0:08830daf46a0 | 17 | * IN NO EVENT SHALL MAXIM INTEGRATED BE LIABLE FOR ANY CLAIM, DAMAGES |
phonemacro | 0:08830daf46a0 | 18 | * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, |
phonemacro | 0:08830daf46a0 | 19 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR |
phonemacro | 0:08830daf46a0 | 20 | * OTHER DEALINGS IN THE SOFTWARE. |
phonemacro | 0:08830daf46a0 | 21 | * |
phonemacro | 0:08830daf46a0 | 22 | * Except as contained in this notice, the name of Maxim Integrated |
phonemacro | 0:08830daf46a0 | 23 | * Products, Inc. shall not be used except as stated in the Maxim Integrated |
phonemacro | 0:08830daf46a0 | 24 | * Products, Inc. Branding Policy. |
phonemacro | 0:08830daf46a0 | 25 | * |
phonemacro | 0:08830daf46a0 | 26 | * The mere transfer of this software does not imply any licenses |
phonemacro | 0:08830daf46a0 | 27 | * of trade secrets, proprietary technology, copyrights, patents, |
phonemacro | 0:08830daf46a0 | 28 | * trademarks, maskwork rights, or any other form of intellectual |
phonemacro | 0:08830daf46a0 | 29 | * property whatsoever. Maxim Integrated Products, Inc. retains all |
phonemacro | 0:08830daf46a0 | 30 | * ownership rights. |
phonemacro | 0:08830daf46a0 | 31 | ******************************************************************************* |
phonemacro | 0:08830daf46a0 | 32 | */ |
phonemacro | 0:08830daf46a0 | 33 | #include "mbed.h" |
phonemacro | 0:08830daf46a0 | 34 | #include "max32630fthr.h" |
phonemacro | 0:08830daf46a0 | 35 | #include "max31725.h" |
phonemacro | 0:08830daf46a0 | 36 | #include "max31725_cpp.h" |
phonemacro | 0:08830daf46a0 | 37 | #include "USBSerial.h" |
phonemacro | 2:1890f1449f7c | 38 | |
phonemacro | 2:1890f1449f7c | 39 | Serial pc(USBTX, USBRX); // Use USB debug probe for serial link |
phonemacro | 2:1890f1449f7c | 40 | Serial uart(P2_1, P2_0); |
phonemacro | 2:1890f1449f7c | 41 | void wait_sec_prompt(uint8_t time) |
phonemacro | 2:1890f1449f7c | 42 | { |
phonemacro | 2:1890f1449f7c | 43 | // Ports and serial connections |
phonemacro | 2:1890f1449f7c | 44 | uint32_t i; |
phonemacro | 2:1890f1449f7c | 45 | for (i = 0; i < time; i++) { |
phonemacro | 2:1890f1449f7c | 46 | pc.printf("."); |
phonemacro | 2:1890f1449f7c | 47 | wait(1); |
phonemacro | 2:1890f1449f7c | 48 | } |
phonemacro | 2:1890f1449f7c | 49 | pc.printf("\r\n"); |
phonemacro | 2:1890f1449f7c | 50 | } |
phonemacro | 2:1890f1449f7c | 51 | |
phonemacro | 2:1890f1449f7c | 52 | |
phonemacro | 0:08830daf46a0 | 53 | MAX32630FTHR pegasus(MAX32630FTHR::VIO_3V3); |
phonemacro | 0:08830daf46a0 | 54 | |
phonemacro | 0:08830daf46a0 | 55 | DigitalOut rLED(LED1); |
phonemacro | 0:08830daf46a0 | 56 | DigitalOut gLED(LED2); |
phonemacro | 0:08830daf46a0 | 57 | DigitalOut bLED(LED3); |
phonemacro | 0:08830daf46a0 | 58 | |
phonemacro | 0:08830daf46a0 | 59 | I2C i2cBus(P3_4, P3_5); |
phonemacro | 0:08830daf46a0 | 60 | |
phonemacro | 0:08830daf46a0 | 61 | // main() runs in its own thread in the OS |
phonemacro | 0:08830daf46a0 | 62 | // (note the calls to Thread::wait below for delays) |
phonemacro | 0:08830daf46a0 | 63 | /** |
phonemacro | 0:08830daf46a0 | 64 | * @brief Sample main program for MAX31725 |
phonemacro | 0:08830daf46a0 | 65 | * @version 1.0000.0002 |
phonemacro | 0:08830daf46a0 | 66 | * |
phonemacro | 0:08830daf46a0 | 67 | * @details Sample main program for MAX31725 |
phonemacro | 0:08830daf46a0 | 68 | * The prints are sent to the terminal window (9600, 8n1). |
phonemacro | 0:08830daf46a0 | 69 | * The program sets the GPIOs to 3.3V and the program |
phonemacro | 0:08830daf46a0 | 70 | * configures the chip and reads temperatures. |
phonemacro | 0:08830daf46a0 | 71 | * To run the program, drag and drop the .bin file into the |
phonemacro | 0:08830daf46a0 | 72 | * DAPLINK folder. After it finishes flashing, cycle the power or |
phonemacro | 0:08830daf46a0 | 73 | * reset the Pegasus (MAX32630FTHR) after flashing by pressing the button on |
phonemacro | 0:08830daf46a0 | 74 | * the Pegasus next to the battery connector or the button |
phonemacro | 0:08830daf46a0 | 75 | * on the MAXREFDES100HDK. |
phonemacro | 0:08830daf46a0 | 76 | */ |
phonemacro | 0:08830daf46a0 | 77 | int main() |
phonemacro | 0:08830daf46a0 | 78 | { |
phonemacro | 0:08830daf46a0 | 79 | uint32_t i; |
phonemacro | 0:08830daf46a0 | 80 | float temperature; |
phonemacro | 0:08830daf46a0 | 81 | uint8_t cfg; |
phonemacro | 0:08830daf46a0 | 82 | DigitalOut rLED(LED1, LED_OFF); |
phonemacro | 0:08830daf46a0 | 83 | DigitalOut gLED(LED2, LED_OFF); |
phonemacro | 0:08830daf46a0 | 84 | DigitalOut bLED(LED3, LED_OFF); |
phonemacro | 0:08830daf46a0 | 85 | gLED = LED_ON; |
phonemacro | 2:1890f1449f7c | 86 | pc.baud(9600); // Baud rate = 115200 |
phonemacro | 2:1890f1449f7c | 87 | pc.printf("MAX31725 Digital Thermometer and " |
phonemacro | 0:08830daf46a0 | 88 | "Thermostat example source code.\r\n"); |
phonemacro | 2:1890f1449f7c | 89 | pc.printf("\r\n"); |
phonemacro | 3:597971685e65 | 90 | uint8_t i2c_addr = MAX31725_I2C_SLAVE_ADR_00; |
phonemacro | 1:5d32aeb8387e | 91 | MAX31725 temp_sensor(i2cBus, i2c_addr); |
phonemacro | 0:08830daf46a0 | 92 | i2cBus.frequency(400000); |
phonemacro | 0:08830daf46a0 | 93 | /* Configure for time out enabled, normal format, fault filter 6, |
phonemacro | 0:08830daf46a0 | 94 | active low polarity, comparator mode, continuous |
phonemacro | 0:08830daf46a0 | 95 | */ |
phonemacro | 0:08830daf46a0 | 96 | temp_sensor.write_cfg_reg(uint8_t(MAX31725_CFG_TIMEOUT_ENABLE | |
phonemacro | 0:08830daf46a0 | 97 | MAX31725_CFG_NORMAL_FORMAT| MAX31725_CFG_FAULT_FILTER_6 | |
phonemacro | 0:08830daf46a0 | 98 | MAX31725_CFG_OS_POLARITY_ACT_LOW | MAX31725_CFG_COMPARATOR_MODE | |
phonemacro | 0:08830daf46a0 | 99 | MAX31725_CFG_CONTINUOUS)); |
phonemacro | 0:08830daf46a0 | 100 | for (i = 0; i < 10; i++) { |
phonemacro | 0:08830daf46a0 | 101 | wait(MAX31725_WAIT_CONV_TIME); |
phonemacro | 0:08830daf46a0 | 102 | temperature = |
phonemacro | 0:08830daf46a0 | 103 | temp_sensor.read_reg_as_temperature(MAX31725_REG_TEMPERATURE); |
phonemacro | 2:1890f1449f7c | 104 | pc.printf("Temperature = %3.4f Celsius, %3.4f Fahrenheit\r\n", |
phonemacro | 0:08830daf46a0 | 105 | temperature, temp_sensor.celsius_to_fahrenheit(temperature)); |
phonemacro | 0:08830daf46a0 | 106 | } |
phonemacro | 0:08830daf46a0 | 107 | temp_sensor.read_cfg_reg(&cfg); |
phonemacro | 2:1890f1449f7c | 108 | pc.printf("Configuration Register = 0x%02Xh \r\n", cfg); |
phonemacro | 0:08830daf46a0 | 109 | #if 0 |
phonemacro | 0:08830daf46a0 | 110 | temp_sensor.write_trip_low_thyst(-63.9375); |
phonemacro | 0:08830daf46a0 | 111 | temperature = |
phonemacro | 0:08830daf46a0 | 112 | temp_sensor.read_reg_as_temperature(MAX31725_REG_THYST_LOW_TRIP); |
phonemacro | 2:1890f1449f7c | 113 | pc.printf("Thyst Temperature = %3.4f Celsius, %3.4f Fahrenheit\r\n", |
phonemacro | 0:08830daf46a0 | 114 | temperature, temp_sensor.celsius_to_fahrenheit(temperature)); |
phonemacro | 0:08830daf46a0 | 115 | |
phonemacro | 0:08830daf46a0 | 116 | temp_sensor.write_trip_high_tos(64.0625f); |
phonemacro | 0:08830daf46a0 | 117 | temperature = temp_sensor.read_reg_as_temperature(MAX31725_REG_TOS_HIGH_TRIP); |
phonemacro | 2:1890f1449f7c | 118 | pc.printf("TOS Temperature = %3.4f Celsius, %3.4f Fahrenheit\r\n", |
phonemacro | 0:08830daf46a0 | 119 | temperature, temp_sensor.celsius_to_fahrenheit(temperature)); |
phonemacro | 2:1890f1449f7c | 120 | pc.printf("\r\n\r\n"); |
phonemacro | 0:08830daf46a0 | 121 | #endif |
phonemacro | 0:08830daf46a0 | 122 | |
phonemacro | 2:1890f1449f7c | 123 | pc.printf("\r\n"); |
phonemacro | 2:1890f1449f7c | 124 | temp_sensor.write_cfg_reg(uint8_t(MAX31725_CFG_ONE_SHOT_START | |
phonemacro | 2:1890f1449f7c | 125 | MAX31725_CFG_TIMEOUT_DISABLE | MAX31725_CFG_EXTENDED_FORMAT | |
phonemacro | 2:1890f1449f7c | 126 | MAX31725_CFG_FAULT_FILTER_4 | MAX31725_CFG_OS_POLARITY_ACT_LOW | |
phonemacro | 2:1890f1449f7c | 127 | MAX31725_CFG_COMPARATOR_MODE | MAX31725_CFG_SHUTDOWN)); |
phonemacro | 0:08830daf46a0 | 128 | for (i = 0; i < 8; i++) { |
phonemacro | 2:1890f1449f7c | 129 | wait_sec_prompt(10); /* leave it in shutdown mode for a while */ |
phonemacro | 0:08830daf46a0 | 130 | /* Configure for one shot, time out disabled, extended format, fault filter 4, |
phonemacro | 0:08830daf46a0 | 131 | active low polarity, comparator mode, shutdown |
phonemacro | 0:08830daf46a0 | 132 | */ |
phonemacro | 0:08830daf46a0 | 133 | temp_sensor.write_cfg_reg(uint8_t(MAX31725_CFG_ONE_SHOT_START | |
phonemacro | 0:08830daf46a0 | 134 | MAX31725_CFG_TIMEOUT_DISABLE | MAX31725_CFG_EXTENDED_FORMAT | |
phonemacro | 0:08830daf46a0 | 135 | MAX31725_CFG_FAULT_FILTER_4 | MAX31725_CFG_OS_POLARITY_ACT_LOW | |
phonemacro | 0:08830daf46a0 | 136 | MAX31725_CFG_COMPARATOR_MODE | MAX31725_CFG_SHUTDOWN)); |
phonemacro | 0:08830daf46a0 | 137 | wait(MAX31725_WAIT_CONV_TIME); |
phonemacro | 0:08830daf46a0 | 138 | temperature = |
phonemacro | 0:08830daf46a0 | 139 | temp_sensor.read_reg_as_temperature(MAX31725_REG_TEMPERATURE); |
phonemacro | 2:1890f1449f7c | 140 | pc.printf("Temperature = %3.4f Celsius, %3.4f Fahrenheit\r\n", |
phonemacro | 0:08830daf46a0 | 141 | temperature, temp_sensor.celsius_to_fahrenheit(temperature)); |
phonemacro | 0:08830daf46a0 | 142 | } |
phonemacro | 0:08830daf46a0 | 143 | temp_sensor.read_cfg_reg(&cfg); |
phonemacro | 2:1890f1449f7c | 144 | pc.printf("Configuration Register = 0x%02Xh \r\n", cfg); |
phonemacro | 0:08830daf46a0 | 145 | |
phonemacro | 2:1890f1449f7c | 146 | pc.printf("\r\n\r\n"); |
phonemacro | 0:08830daf46a0 | 147 | |
phonemacro | 0:08830daf46a0 | 148 | #if 0 |
phonemacro | 0:08830daf46a0 | 149 | temp_sensor.write_trip_low_thyst(-55.0f); |
phonemacro | 0:08830daf46a0 | 150 | temperature = |
phonemacro | 0:08830daf46a0 | 151 | temp_sensor.read_reg_as_temperature(MAX31725_REG_THYST_LOW_TRIP); |
phonemacro | 2:1890f1449f7c | 152 | pc.printf("Thyst Temperature = %3.4f Celsius, %3.4f Fahrenheit\r\n", |
phonemacro | 0:08830daf46a0 | 153 | temperature, temp_sensor.celsius_to_fahrenheit(temperature)); |
phonemacro | 0:08830daf46a0 | 154 | |
phonemacro | 0:08830daf46a0 | 155 | temp_sensor.write_trip_high_tos(125.0f); |
phonemacro | 0:08830daf46a0 | 156 | temperature = temp_sensor.read_reg_as_temperature(MAX31725_REG_TOS_HIGH_TRIP); |
phonemacro | 2:1890f1449f7c | 157 | pc.printf("TOS Temperature = %3.4f Celsius, %3.4f Fahrenheit\r\n", |
phonemacro | 0:08830daf46a0 | 158 | temperature, temp_sensor.celsius_to_fahrenheit(temperature)); |
phonemacro | 2:1890f1449f7c | 159 | pc.printf("\r\n\r\n"); |
phonemacro | 0:08830daf46a0 | 160 | #endif |
phonemacro | 0:08830daf46a0 | 161 | |
phonemacro | 0:08830daf46a0 | 162 | /*************************************************************************** |
phonemacro | 0:08830daf46a0 | 163 | * Call the C code version of the driver |
phonemacro | 0:08830daf46a0 | 164 | *************************************************************************** |
phonemacro | 0:08830daf46a0 | 165 | */ |
phonemacro | 0:08830daf46a0 | 166 | #include "max31725_c.h" |
phonemacro | 2:1890f1449f7c | 167 | pc.printf("C implementation of the code\r\n"); |
phonemacro | 1:5d32aeb8387e | 168 | max31725_init(i2c_addr); |
phonemacro | 0:08830daf46a0 | 169 | /* Configure for time out enabled, normal format, fault filter 6, |
phonemacro | 0:08830daf46a0 | 170 | active low polarity, comparator mode, continuous |
phonemacro | 0:08830daf46a0 | 171 | */ |
phonemacro | 0:08830daf46a0 | 172 | max31725_write_cfg_reg(uint8_t(MAX31725_CFG_TIMEOUT_ENABLE | |
phonemacro | 0:08830daf46a0 | 173 | MAX31725_CFG_NORMAL_FORMAT | MAX31725_CFG_FAULT_FILTER_6 | |
phonemacro | 0:08830daf46a0 | 174 | MAX31725_CFG_OS_POLARITY_ACT_LOW | MAX31725_CFG_COMPARATOR_MODE | |
phonemacro | 0:08830daf46a0 | 175 | MAX31725_CFG_CONTINUOUS), i2cBus); |
phonemacro | 0:08830daf46a0 | 176 | /* Configure for 9 bit resolution, fault filter 1, |
phonemacro | 0:08830daf46a0 | 177 | active low, comparator, continuous, |
phonemacro | 0:08830daf46a0 | 178 | */ |
phonemacro | 0:08830daf46a0 | 179 | for (i = 0; i < 10; i++) { |
phonemacro | 0:08830daf46a0 | 180 | wait(MAX31725_WAIT_CONV_TIME); |
phonemacro | 0:08830daf46a0 | 181 | temperature = max31725_read_reg_as_temperature(MAX31725_REG_TEMPERATURE, |
phonemacro | 0:08830daf46a0 | 182 | i2cBus); |
phonemacro | 2:1890f1449f7c | 183 | pc.printf("Temperature = %3.4f Celsius, %3.4f Fahrenheit\r\n", |
phonemacro | 0:08830daf46a0 | 184 | temperature, temp_sensor.celsius_to_fahrenheit(temperature)); |
phonemacro | 0:08830daf46a0 | 185 | } |
phonemacro | 0:08830daf46a0 | 186 | |
phonemacro | 0:08830daf46a0 | 187 | max31725_read_cfg_reg(&cfg, i2cBus); |
phonemacro | 2:1890f1449f7c | 188 | pc.printf("Configuration Register = 0x%02Xh \r\n", cfg); |
phonemacro | 0:08830daf46a0 | 189 | |
phonemacro | 0:08830daf46a0 | 190 | #if 0 |
phonemacro | 0:08830daf46a0 | 191 | max31725_write_trip_low_thyst(-63.9375, i2cBus); |
phonemacro | 0:08830daf46a0 | 192 | temperature = max31725_read_reg_as_temperature(MAX31725_REG_THYST_LOW_TRIP, |
phonemacro | 0:08830daf46a0 | 193 | i2cBus); |
phonemacro | 2:1890f1449f7c | 194 | pc.printf("Thyst Temperature = %3.4f Celsius, %3.4f Fahrenheit\r\n", |
phonemacro | 0:08830daf46a0 | 195 | temperature, max31725_celsius_to_fahrenheit(temperature)); |
phonemacro | 0:08830daf46a0 | 196 | |
phonemacro | 0:08830daf46a0 | 197 | max31725_write_trip_high_tos(64.0625f, i2cBus); |
phonemacro | 0:08830daf46a0 | 198 | temperature = max31725_read_reg_as_temperature(MAX31725_REG_TOS_HIGH_TRIP, |
phonemacro | 0:08830daf46a0 | 199 | i2cBus); |
phonemacro | 2:1890f1449f7c | 200 | pc.printf("TOS Temperature = %3.4f Celsius, %3.4f Fahrenheit\r\n", |
phonemacro | 0:08830daf46a0 | 201 | temperature, max31725_celsius_to_fahrenheit(temperature)); |
phonemacro | 0:08830daf46a0 | 202 | #endif |
phonemacro | 0:08830daf46a0 | 203 | |
phonemacro | 2:1890f1449f7c | 204 | pc.printf("\r\n"); |
phonemacro | 2:1890f1449f7c | 205 | max31725_write_cfg_reg(uint8_t(MAX31725_CFG_ONE_SHOT_START | |
phonemacro | 2:1890f1449f7c | 206 | MAX31725_CFG_TIMEOUT_DISABLE | MAX31725_CFG_EXTENDED_FORMAT | |
phonemacro | 2:1890f1449f7c | 207 | MAX31725_CFG_FAULT_FILTER_4 | MAX31725_CFG_OS_POLARITY_ACT_LOW | |
phonemacro | 2:1890f1449f7c | 208 | MAX31725_CFG_COMPARATOR_MODE | MAX31725_CFG_SHUTDOWN), i2cBus); |
phonemacro | 0:08830daf46a0 | 209 | for (i = 0; i < 8; i++) { |
phonemacro | 2:1890f1449f7c | 210 | wait_sec_prompt(10); /* leave it in shutdown mode for a while */ |
phonemacro | 0:08830daf46a0 | 211 | /* Configure for one shot, time out disabled, extended format, fault filter 4, |
phonemacro | 0:08830daf46a0 | 212 | active low polarity, comparator mode, shutdown |
phonemacro | 0:08830daf46a0 | 213 | */ |
phonemacro | 0:08830daf46a0 | 214 | max31725_write_cfg_reg(uint8_t(MAX31725_CFG_ONE_SHOT_START | |
phonemacro | 0:08830daf46a0 | 215 | MAX31725_CFG_TIMEOUT_DISABLE | MAX31725_CFG_EXTENDED_FORMAT | |
phonemacro | 0:08830daf46a0 | 216 | MAX31725_CFG_FAULT_FILTER_4 | MAX31725_CFG_OS_POLARITY_ACT_LOW | |
phonemacro | 0:08830daf46a0 | 217 | MAX31725_CFG_COMPARATOR_MODE | MAX31725_CFG_SHUTDOWN), i2cBus); |
phonemacro | 0:08830daf46a0 | 218 | wait(MAX31725_WAIT_CONV_TIME); |
phonemacro | 0:08830daf46a0 | 219 | temperature = max31725_read_reg_as_temperature(MAX31725_REG_TEMPERATURE, |
phonemacro | 0:08830daf46a0 | 220 | i2cBus); |
phonemacro | 2:1890f1449f7c | 221 | pc.printf("Temperature = %3.4f Celsius, %3.4f Fahrenheit\r\n", |
phonemacro | 0:08830daf46a0 | 222 | temperature, temp_sensor.celsius_to_fahrenheit(temperature)); |
phonemacro | 0:08830daf46a0 | 223 | } |
phonemacro | 0:08830daf46a0 | 224 | max31725_read_cfg_reg(&cfg, i2cBus); |
phonemacro | 2:1890f1449f7c | 225 | pc.printf("Configuration Register = 0x%02Xh \r\n", cfg); |
phonemacro | 0:08830daf46a0 | 226 | |
phonemacro | 0:08830daf46a0 | 227 | #if 0 |
phonemacro | 0:08830daf46a0 | 228 | max31725_write_trip_low_thyst(-55, i2cBus); |
phonemacro | 0:08830daf46a0 | 229 | temperature = max31725_read_reg_as_temperature(MAX31725_REG_THYST_LOW_TRIP, |
phonemacro | 0:08830daf46a0 | 230 | i2cBus); |
phonemacro | 2:1890f1449f7c | 231 | pc.printf("Thyst Temperature = %3.4f Celsius, %3.4f Fahrenheit\r\n", |
phonemacro | 0:08830daf46a0 | 232 | temperature, max31725_celsius_to_fahrenheit(temperature)); |
phonemacro | 0:08830daf46a0 | 233 | |
phonemacro | 0:08830daf46a0 | 234 | max31725_write_trip_high_tos(125.0f, i2cBus); |
phonemacro | 0:08830daf46a0 | 235 | temperature = max31725_read_reg_as_temperature(MAX31725_REG_TOS_HIGH_TRIP, |
phonemacro | 0:08830daf46a0 | 236 | i2cBus); |
phonemacro | 2:1890f1449f7c | 237 | pc.printf("TOS Temperature = %3.4f Celsius, %3.4f Fahrenheit\r\n", |
phonemacro | 0:08830daf46a0 | 238 | temperature, max31725_celsius_to_fahrenheit(temperature)); |
phonemacro | 0:08830daf46a0 | 239 | #endif |
phonemacro | 2:1890f1449f7c | 240 | pc.printf("\r\n\r\n\r\n"); |
phonemacro | 0:08830daf46a0 | 241 | |
phonemacro | 0:08830daf46a0 | 242 | |
phonemacro | 0:08830daf46a0 | 243 | while (true) { // Blink the green LED |
phonemacro | 0:08830daf46a0 | 244 | gLED = !gLED; |
phonemacro | 0:08830daf46a0 | 245 | wait(0.5); |
phonemacro | 0:08830daf46a0 | 246 | } |
phonemacro | 0:08830daf46a0 | 247 | } |
phonemacro | 0:08830daf46a0 | 248 | |
phonemacro | 0:08830daf46a0 | 249 |