Sample host software for the Maxim Integrated DS1775, DS75 Digital Thermometer Thermostat IC hosted on the MAX32630FTHR. The DS1775 is suitable for PCs, cell phones, and other thermally sensitive systems.

Dependencies:   max32630fthr DS1775_Digitial_Thermometer_Thermostat USBDevice

Revision:
1:72ad3ee71812
Parent:
0:252077cb2ac5
Child:
2:aa39032bf778
--- a/main.cpp	Sun Apr 07 07:33:09 2019 +0000
+++ b/main.cpp	Sun Apr 07 07:43:15 2019 +0000
@@ -32,8 +32,8 @@
 */
 #include "mbed.h"
 #include "max32630fthr.h"
-#include "max31875.h"
-#include "max31875_cpp.h"
+#include "ds1775.h"
+#include "ds1775_cpp.h"
 #include "USBSerial.h"
  
 MAX32630FTHR pegasus(MAX32630FTHR::VIO_3V3); 
@@ -47,12 +47,12 @@
 // main() runs in its own thread in the OS
 // (note the calls to Thread::wait below for delays)
 /**
-* @brief Sample main program for MAX31875
+* @brief Sample main program for DS1775
 * @version 1.0000.0000
 *
-* @details Sample main program for MAX31875
+* @details Sample main program for DS1775
 * The prints are sent to the terminal window (9600, 8n1).
-* The program sets the GPIOs to 1.8V and the program
+* The program sets the GPIOs to 3.3V and the program
 * configures the chip and reads temperatures.
 * To run the program, drag and drop the .bin file into the 
 * DAPLINK folder. After it finishes flashing, cycle the power or 
@@ -69,43 +69,43 @@
     DigitalOut gLED(LED2, LED_OFF);
     DigitalOut bLED(LED3, LED_OFF);
     gLED = LED_ON;
-    printf("MAX31875 Small Package Temperature Sensor example source code.\r\n");
+    printf("DS1775 DS75 Digital Thermometer and Thermostat example source code.\r\n");
     printf("\r\n");
 
-    MAX31875 temp_sensor(i2cBus, MAX31875_I2C_SLAVE_ADR_R0);
+    DS1775 temp_sensor(i2cBus, DS1775_I2C_SLAVE_ADR_R0);
     i2cBus.frequency(400000);
    
     /* Configure for fault filter 1, comparator, continuous,
      * normal format, 8 sps, 12 bit resolution
      */
 #if 0
-    temp_sensor.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));
+    temp_sensor.write_cfg(uint16_t(DS1775_CFG_FAULT_FILTER_1 | 
+        DS1775_CFG_COMPARATOR_MODE | DS1775_CFG_CONTINUOUS | 
+        DS1775_CFG_NORMAL_FORMAT | DS1775_CFG_CONV_RATE_8 | 
+        DS1775_CFG_RESOLUTION_12BIT));
 #endif
     for (i = 0; i < 10; i++) {
-        wait(MAX31875_WAIT_CONV_TIME_9BIT);
-        temperature = temp_sensor.read_reg_as_temperature(MAX31875_REG_TEMPERATURE);
+        wait(DS1775_WAIT_CONV_TIME_9BIT);
+        temperature = temp_sensor.read_reg_as_temperature(DS1775_REG_TEMPERATURE);
         printf("Temperature = %3.4f Celsius, %3.4f Fahrenheit\r\n", 
             temperature, temp_sensor.celsius_to_fahrenheit(temperature));
     }
-    temperature = temp_sensor.read_reg_as_temperature(MAX31875_REG_TOS_HIGH_TRIP);
+    temperature = temp_sensor.read_reg_as_temperature(DS1775_REG_TOS_HIGH_TRIP);
         printf("TOS Temperature = %3.4f Celsius, %3.4f Fahrenheit\r\n", 
             temperature, temp_sensor.celsius_to_fahrenheit(temperature));
 #if 0
-    temp_sensor.read_reg(&cfg, MAX31875_REG_CONFIGURATION);
+    temp_sensor.read_reg(&cfg, DS1775_REG_CONFIGURATION);
     printf("Configuration Register = 0x%04Xh \r\n", cfg);
   #if 0
     temp_sensor.write_trip_low(-63.9375);
     wait(0.03);
-    temperature = temp_sensor.read_reg_as_temperature(MAX31875_REG_THYST_LOW_TRIP);
+    temperature = temp_sensor.read_reg_as_temperature(DS1775_REG_THYST_LOW_TRIP);
     printf("Thyst Temperature = %3.4f Celsius, %3.4f Fahrenheit\r\n", 
             temperature, temp_sensor.celsius_to_fahrenheit(temperature));
 
     temp_sensor.write_trip_high(64.0625f);
     wait(0.03);
-    temperature = temp_sensor.read_reg_as_temperature(MAX31875_REG_TOS_HIGH_TRIP);
+    temperature = temp_sensor.read_reg_as_temperature(DS1775_REG_TOS_HIGH_TRIP);
     printf("TOS Temperature = %3.4f Celsius, %3.4f Fahrenheit\r\n", 
             temperature, temp_sensor.celsius_to_fahrenheit(temperature));
     printf("\r\n\r\n");
@@ -117,16 +117,16 @@
      * extended format, 0.25 sps, 10 bit resolution, start one-shot
      */
     for (i = 0; i < 2; i++) {
-        temp_sensor.write_cfg(uint16_t(MAX31875_CFG_FAULT_FILTER_4 | 
-            MAX31875_CFG_INTERRUPT_MODE | MAX31875_CFG_SHUTDOWN |
-            MAX31875_CFG_EXTENDED_FORMAT| MAX31875_CFG_CONV_RATE_0_25 | 
-            MAX31875_CFG_RESOLUTION_10BIT | MAX31875_CFG_ONE_SHOT_START));
-        wait(MAX31875_WAIT_CONV_RATE_0_25);
-        temperature = temp_sensor.read_reg_as_temperature(MAX31875_REG_TEMPERATURE);
+        temp_sensor.write_cfg(uint16_t(DS1775_CFG_FAULT_FILTER_4 | 
+            DS1775_CFG_INTERRUPT_MODE | DS1775_CFG_SHUTDOWN |
+            DS1775_CFG_EXTENDED_FORMAT| DS1775_CFG_CONV_RATE_0_25 | 
+            DS1775_CFG_RESOLUTION_10BIT | DS1775_CFG_ONE_SHOT_START));
+        wait(DS1775_WAIT_CONV_RATE_0_25);
+        temperature = temp_sensor.read_reg_as_temperature(DS1775_REG_TEMPERATURE);
         printf("Temperature = %3.4f Celsius, %3.4f Fahrenheit\r\n", 
             temperature, temp_sensor.celsius_to_fahrenheit(temperature));
     }
-    temp_sensor.read_reg(&cfg, MAX31875_REG_CONFIGURATION);
+    temp_sensor.read_reg(&cfg, DS1775_REG_CONFIGURATION);
     printf("Configuration Register = 0x%04Xh \r\n", cfg);
 
     printf("\r\n\r\n");
@@ -134,14 +134,14 @@
 #if 0
     temp_sensor.write_trip_low(-127.9375);
     wait(0.03);
-    temp_sensor.read_reg(&cfg, MAX31875_REG_CONFIGURATION);
-    temperature = temp_sensor.read_reg_as_temperature(MAX31875_REG_THYST_LOW_TRIP);
+    temp_sensor.read_reg(&cfg, DS1775_REG_CONFIGURATION);
+    temperature = temp_sensor.read_reg_as_temperature(DS1775_REG_THYST_LOW_TRIP);
     printf("Thyst Temperature = %3.4f Celsius, %3.4f Fahrenheit\r\n", 
             temperature, temp_sensor.celsius_to_fahrenheit(temperature));
 
     temp_sensor.write_trip_high(129.0625f);
     wait(0.03);
-    temperature = temp_sensor.read_reg_as_temperature(MAX31875_REG_TOS_HIGH_TRIP);
+    temperature = temp_sensor.read_reg_as_temperature(DS1775_REG_TOS_HIGH_TRIP);
     printf("TOS Temperature = %3.4f Celsius, %3.4f Fahrenheit\r\n", 
             temperature, temp_sensor.celsius_to_fahrenheit(temperature));
     printf("\r\n\r\n");
@@ -151,69 +151,69 @@
      * Call the C code version of the driver
      ***************************************************************************
      */
-#include "max31875_c.h"
+#include "ds1775_c.h"
     printf("C implementation of the code\r\n");
-    max31875_init(MAX31875_I2C_SLAVE_ADR_R0);
+    ds1775_init(DS1775_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);
+    ds1775_write_cfg(uint16_t(DS1775_CFG_FAULT_FILTER_1 | 
+        DS1775_CFG_COMPARATOR_MODE | DS1775_CFG_CONTINUOUS | 
+        DS1775_CFG_NORMAL_FORMAT | DS1775_CFG_CONV_RATE_8 | 
+        DS1775_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,
+        wait(DS1775_WAIT_CONV_RATE_8);
+        temperature = ds1775_read_reg_as_temperature(DS1775_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);
+    ds1775_read_reg(&cfg, DS1775_REG_CONFIGURATION, i2cBus);
     printf("Configuration Register = 0x%04Xh \r\n", cfg);
 
 #if 0
-    max31875_write_trip_low(-63.9375, i2cBus);
+    ds1775_write_trip_low(-63.9375, i2cBus);
     wait(0.03);
-    temperature = max31875_read_reg_as_temperature(MAX31875_REG_THYST_LOW_TRIP, i2cBus);
+    temperature = ds1775_read_reg_as_temperature(DS1775_REG_THYST_LOW_TRIP, i2cBus);
     printf("Thyst Temperature = %3.4f Celsius, %3.4f Fahrenheit\r\n", 
-            temperature, max31875_celsius_to_fahrenheit(temperature));
+            temperature, ds1775_celsius_to_fahrenheit(temperature));
 
-    max31875_write_trip_high(64.0625f, i2cBus);
+    ds1775_write_trip_high(64.0625f, i2cBus);
     wait(0.03);
-    temperature = max31875_read_reg_as_temperature(MAX31875_REG_TOS_HIGH_TRIP, i2cBus);
+    temperature = ds1775_read_reg_as_temperature(DS1775_REG_TOS_HIGH_TRIP, i2cBus);
     printf("TOS Temperature = %3.4f Celsius, %3.4f Fahrenheit\r\n", 
-            temperature, max31875_celsius_to_fahrenheit(temperature));
+            temperature, ds1775_celsius_to_fahrenheit(temperature));
 #endif
 
     printf("\r\n");
     for (i = 0; i < 2; i++) {
-        max31875_write_cfg(uint16_t(MAX31875_CFG_FAULT_FILTER_4 | 
-            MAX31875_CFG_INTERRUPT_MODE | MAX31875_CFG_SHUTDOWN |
-            MAX31875_CFG_EXTENDED_FORMAT| MAX31875_CFG_CONV_RATE_0_25 | 
-            MAX31875_CFG_RESOLUTION_10BIT | MAX31875_CFG_ONE_SHOT_START),
+        ds1775_write_cfg(uint16_t(DS1775_CFG_FAULT_FILTER_4 | 
+            DS1775_CFG_INTERRUPT_MODE | DS1775_CFG_SHUTDOWN |
+            DS1775_CFG_EXTENDED_FORMAT| DS1775_CFG_CONV_RATE_0_25 | 
+            DS1775_CFG_RESOLUTION_10BIT | DS1775_CFG_ONE_SHOT_START),
             i2cBus);
-        wait(MAX31875_WAIT_CONV_RATE_0_25);
-        temperature = max31875_read_reg_as_temperature(MAX31875_REG_TEMPERATURE,
+        wait(DS1775_WAIT_CONV_RATE_0_25);
+        temperature = ds1775_read_reg_as_temperature(DS1775_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);
+    ds1775_read_reg(&cfg, DS1775_REG_CONFIGURATION, i2cBus);
     printf("Configuration Register = 0x%04Xh \r\n", cfg);
 
 #if 0
     temp_sensor.write_trip_low(-127.9375);
-    max31875_write_trip_low(-127.9375, i2cBus);
+    ds1775_write_trip_low(-127.9375, i2cBus);
     wait(0.03);
-    temperature = max31875_read_reg_as_temperature(MAX31875_REG_THYST_LOW_TRIP, i2cBus);
+    temperature = ds1775_read_reg_as_temperature(DS1775_REG_THYST_LOW_TRIP, i2cBus);
     printf("Thyst Temperature = %3.4f Celsius, %3.4f Fahrenheit\r\n", 
-            temperature, max31875_celsius_to_fahrenheit(temperature));
+            temperature, ds1775_celsius_to_fahrenheit(temperature));
 
-    max31875_write_trip_high(129.0625f, i2cBus);
+    ds1775_write_trip_high(129.0625f, i2cBus);
     wait(0.03);
-    temperature = max31875_read_reg_as_temperature(MAX31875_REG_TOS_HIGH_TRIP, i2cBus);
+    temperature = ds1775_read_reg_as_temperature(DS1775_REG_TOS_HIGH_TRIP, i2cBus);
     printf("TOS Temperature = %3.4f Celsius, %3.4f Fahrenheit\r\n", 
-            temperature, max31875_celsius_to_fahrenheit(temperature));
+            temperature, ds1775_celsius_to_fahrenheit(temperature));
 #endif
   #endif 
     printf("\r\n\r\n\r\n");