Sample host software for the Maxim Integrated MAX31875 Low Power Small Package Temperature Sensor. Hosted on the MAX32630FTHR. The MAX31875 may be used in wearables, thermostats, thermometers, and hardware temperature supervisors.
Dependencies: MAX31875_Temperature_Sensor_Low_Power max32630fthr USBDevice
Diff: main.cpp
- Revision:
- 1:c5ac6967b6bf
- Parent:
- 0:77036686489d
- Child:
- 2:32c0d11d8c0d
--- a/main.cpp Sun Feb 03 23:56:45 2019 +0000 +++ b/main.cpp Mon Feb 04 23:39:11 2019 +0000 @@ -33,6 +33,7 @@ #include "mbed.h" #include "max32630fthr.h" #include "max31875.h" +#include "max31875_cpp.h" #include "USBSerial.h" MAX32630FTHR pegasus(MAX32630FTHR::VIO_1V8); @@ -47,7 +48,7 @@ // (note the calls to Thread::wait below for delays) /** * @brief Sample main program for MAX31875 -* @version 1.0000.0000 +* @version 1.0000.0001 * * @details Sample main program for MAX31875 * The prints are sent to the terminal window (9600, 8n1). @@ -123,6 +124,31 @@ temperature, temp_sensor.celsius_to_fahrenheit(temperature)); printf("\r\n\r\n"); #endif + + /*************************************************************************** + * Call the C code version of the driver + *************************************************************************** + */ +#include "max31875_c.h" + max31875_init(MAX31875_I2C_SLAVE_ADR_R0); + /* Configure for fault filter 1, comparator, continuous, + * normal format, 8 sps, 12 bit resolution + */ + max31875_write_cfg(uint16_t(MAX31875_CFG_FAULT_FILTER_1 | + MAX31875_CFG_COMPARATOR_MODE | MAX31875_CFG_CONTINUOUS | + MAX31875_CFG_NORMAL_FORMAT | MAX31875_CFG_CONV_RATE_8 | + MAX31875_CFG_RESOLUTION_12BIT), i2cBus); + for (i = 0; i < 10; i++) { + wait(MAX31875_WAIT_CONV_RATE_8); + temperature = max31875_read_reg_as_temperature(MAX31875_REG_TEMPERATURE, + i2cBus); + printf("Temperature = %3.4f Celsius, %3.4f Fahrenheit\r\n", + temperature, temp_sensor.celsius_to_fahrenheit(temperature)); + } + max31875_read_reg(&cfg, MAX31875_REG_CONFIGURATION, i2cBus); + printf("Configuration Register = 0x%04Xh \r\n", cfg); + + while (true) { // Blink the green LED gLED = !gLED; wait(0.5);