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:
2:aa39032bf778
Parent:
1:72ad3ee71812
Child:
3:d1beaf95d945
--- a/main.cpp	Sun Apr 07 07:43:15 2019 +0000
+++ b/main.cpp	Sun Apr 07 08:59:53 2019 +0000
@@ -64,7 +64,7 @@
 {
     uint32_t i;
     float temperature;
-    uint16_t cfg;
+    uint8_t cfg;
     DigitalOut rLED(LED1, LED_OFF);
     DigitalOut gLED(LED2, LED_OFF);
     DigitalOut bLED(LED3, LED_OFF);
@@ -75,15 +75,12 @@
     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
+    /* Configure for 9 bit resolution, fault filter 1, 
+       active low, comparator, continuous,
      */
-#if 0
-    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
+    temp_sensor.write_cfg(uint16_t(DS1775_CFG_RESOLUTION_9BIT |
+        DS1775_CFG_FAULT_FILTER_6 | DS1775_CFG_OS_POLARITY_ACT_LOW |
+        DS1775_CFG_COMPARATOR_MODE | DS1775_CFG_CONTINUOUS));
     for (i = 0; i < 10; i++) {
         wait(DS1775_WAIT_CONV_TIME_9BIT);
         temperature = temp_sensor.read_reg_as_temperature(DS1775_REG_TEMPERATURE);
@@ -93,10 +90,10 @@
     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));
+    temp_sensor.read_cfg_reg(&cfg);
+    printf("Configuration Register = 0x%02Xh \r\n", cfg);
+    
 #if 0
-    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(DS1775_REG_THYST_LOW_TRIP);
@@ -113,25 +110,33 @@
 
     printf("\r\n");
 
-    /* Configure for fault filter 4, interrupt, shutdown,
-     * extended format, 0.25 sps, 10 bit resolution, start one-shot
-     */
-    for (i = 0; i < 2; i++) {
-        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);
+
+    temp_sensor.read_cfg_reg(&cfg);
+    printf("Configuration Register = 0x%02Xh \r\n", cfg);
+    for (i = 0; i < 8; i++) {
+        /* Configure for 12 bit resolution, fault filter 2, 
+           active low, interrupt, continous,
+        */
+        temp_sensor.write_cfg(uint16_t(DS1775_CFG_RESOLUTION_12BIT |
+            DS1775_CFG_FAULT_FILTER_6 | DS1775_CFG_OS_POLARITY_ACT_LOW |
+            DS1775_CFG_INTERRUPT_MODE | DS1775_CFG_CONTINUOUS));
+        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));
+        temp_sensor.write_cfg(uint16_t(DS1775_CFG_RESOLUTION_12BIT |
+            DS1775_CFG_FAULT_FILTER_6 | DS1775_CFG_OS_POLARITY_ACT_LOW |
+            DS1775_CFG_INTERRUPT_MODE | DS1775_CFG_SHUTDOWN));
+        wait(2); /*  leave it in shutdown mode for a while */
     }
-    temp_sensor.read_reg(&cfg, DS1775_REG_CONFIGURATION);
-    printf("Configuration Register = 0x%04Xh \r\n", cfg);
+    temp_sensor.read_cfg_reg(&cfg);
+    printf("Configuration Register = 0x%02Xh \r\n", cfg);
 
     printf("\r\n\r\n");
 
 #if 0
+
+#if 0
     temp_sensor.write_trip_low(-127.9375);
     wait(0.03);
     temp_sensor.read_reg(&cfg, DS1775_REG_CONFIGURATION);