C++ driver software code for Maxim Integrated MAX31723/MAX31722 device temperature sensor. The MAX31723 provides 9 to 12 bits of resolution.

Dependents:   MAX31723_Thermostat_Thermometer_Sensor

Files at this revision

API Documentation at this revision

Comitter:
phonemacro
Date:
Sun Jan 27 07:26:37 2019 +0000
Parent:
1:bb6f11be119f
Child:
3:f39791139435
Commit message:
Correct configuration register not being updating.

Changed in this revision

max31723.cpp Show annotated file Show diff for this revision Revisions of this file
max31723.h Show annotated file Show diff for this revision Revisions of this file
--- a/max31723.cpp	Sun Jan 27 02:49:07 2019 +0000
+++ b/max31723.cpp	Sun Jan 27 07:26:37 2019 +0000
@@ -55,12 +55,14 @@
     return MAX31723_NO_ERROR;
 }
 
-int MAX31723::perform_one_shot(uint8_t resolution)
+int MAX31723::perform_one_shot_int(uint8_t resolution)
 {
-    if (resolution <= MAX31723_CFG_RESOLUTION_12BIT)
-        write_reg(resolution | MAX31723_CFG_1SHOT | MAX31723_CFG_STANDBY,
+    if (resolution <= MAX31723_CFG_RESOLUTION_12BIT) {
+        write_reg(0, MAX31723_REG_CFG | MAX31723_WRITE_MASK);
+        write_reg(MAX31723_CFG_TM_MODE_INTERRUPT | MAX31723_CFG_1SHOT |
+            resolution | MAX31723_CFG_STANDBY,
             MAX31723_REG_CFG | MAX31723_WRITE_MASK);
-    else
+    } else
         return MAX31723_ERROR;
     return MAX31723_NO_ERROR;
 }
@@ -70,10 +72,9 @@
     uint8_t lsb, msb;
     uint16_t raw_temp;
     float temperature;
-    
+    wait(0.2);
     read_reg(lsb, MAX31723_REG_TEMP_LSB);
     read_reg(msb, MAX31723_REG_TEMP_MSB);
-
     raw_temp =  int16_t((msb << 8) | (lsb));
     raw_temp =  raw_temp >> 4;
     temperature = raw_temp * 0.0625 ;
--- a/max31723.h	Sun Jan 27 02:49:07 2019 +0000
+++ b/max31723.h	Sun Jan 27 07:26:37 2019 +0000
@@ -68,7 +68,7 @@
 /**
 * @brief 9-bit to 12bit device temperature sensor with digital-to-analog converters (DACs)
 *        for the MAX31723, MAX5214.
-* @version 1.0000.0000
+* @version 1.0000.0001
 *
 * @details The MAX31722/MAX31723 provides device temperature readings
 * for thermostats and thermometers. Communications may be either SPI or
@@ -126,11 +126,11 @@
 
     /** 
      * @brief Configures the device to perform a one-shot temperature reading
-     *        and places the device in standby mode.
+     *        and places the device in standby mode, interrupt mode.
      * @param resolution - the resolution of the calculation is set to this
      * @return 0 on success, negative number on failure
      */
-    int perform_one_shot(uint8_t resolution);
+    int perform_one_shot_int(uint8_t resolution);
 
     /** 
      * @brief Converts Celcius degrees to Fahrenheit