David Jung / Mbed OS DS1775_Digital_Thermostat_Temperature

Dependencies:   max32630fthr DS1775_Digitial_Thermometer_Thermostat USBDevice

Revision:
4:d3171636a86b
Parent:
3:d1beaf95d945
Child:
5:af38bfffd6d3
--- a/main.cpp	Sun Apr 07 09:40:04 2019 +0000
+++ b/main.cpp	Sun Apr 07 09:55:34 2019 +0000
@@ -74,7 +74,7 @@
 
     DS1775 temp_sensor(i2cBus, DS1775_I2C_SLAVE_ADR_R0);
     i2cBus.frequency(400000);
-   
+  #if 0   
     /* Configure for 9 bit resolution, fault filter 1, 
        active low, comparator, continuous,
      */
@@ -135,7 +135,7 @@
     printf("\r\n\r\n");
 
 
-#if 1
+#if 0
     temp_sensor.write_trip_low(-55.0f);
     wait(0.03);
     temperature = temp_sensor.read_reg_as_temperature(DS1775_REG_THYST_LOW_TRIP);
@@ -149,8 +149,7 @@
             temperature, temp_sensor.celsius_to_fahrenheit(temperature));
     printf("\r\n\r\n");
 #endif
-#if 0
-
+  #endif
     /***************************************************************************
      * Call the C code version of the driver
      ***************************************************************************
@@ -158,22 +157,23 @@
 #include "ds1775_c.h"
     printf("C implementation of the code\r\n");
     ds1775_init(DS1775_I2C_SLAVE_ADR_R0);
-    /* 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,
      */
-    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);
+    ds1775_write_cfg_reg(uint8_t(DS1775_CFG_RESOLUTION_9BIT |
+        DS1775_CFG_FAULT_FILTER_6 | DS1775_CFG_OS_POLARITY_ACT_LOW |
+        DS1775_CFG_COMPARATOR_MODE | DS1775_CFG_CONTINUOUS), i2cBus);
     for (i = 0; i < 10; i++) {
-        wait(DS1775_WAIT_CONV_RATE_8);
+        wait(DS1775_WAIT_CONV_TIME_9BIT);
         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));
     }
-    ds1775_read_reg(&cfg, DS1775_REG_CONFIGURATION, i2cBus);
+
+    ds1775_read_cfg_reg(&cfg, i2cBus);
     printf("Configuration Register = 0x%04Xh \r\n", cfg);
+#if 0
 
 #if 0
     ds1775_write_trip_low(-63.9375, i2cBus);