Dallas / Maxim DS1820 1-Wire library. For communication with multiple DS1820 on a single 1-Wire bus. Also supports DS18S20 and DS18B20.

Revision:
3:3e89eafb60c2
Parent:
2:ee820a991b95
--- a/DS1820.h	Thu Dec 15 19:07:36 2011 +0000
+++ b/DS1820.h	Mon Jan 29 03:39:38 2018 +0000
@@ -15,23 +15,23 @@
  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FRom,
  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  * THE SOFTWARE.
  */
-
+ 
 #ifndef MBED_DS1820_H
 #define MBED_DS1820_H
-
+ 
 #include "mbed.h"
-
+ 
 // ****** THIS GLOBAL VARIABLES MUST BE DEFINED IN main.cpp
-
+ 
 // Global variables shared between all DS1820 objects
 //bool DS1820_done_flag;
 //int  DS1820_last_descrepancy;
-//char DS1820_search_ROM[8];
-
+//char DS1820_search_RomM[8];
+ 
 /** DS1820 Dallas 1-Wire Temperature Probe
  *
  * Example:
@@ -53,15 +53,15 @@
  *     for (i = 0; i < MAX_PROBES; i++)
  *         probe[i] = new DS1820(p27);
  *     // Initialize global state variables
- *     probe[0]->search_ROM_setup();
+ *     probe[0]->search_RomMM_setup();
  *     // Loop to find all devices on the data line
- *     while (probe[devices_found]->search_ROM() and devices_found<MAX_PROBES-1)
+ *     while (probe[devices_found]->search_RomM() and devices_found<MAX_PROBES-1)
  *         devices_found++;
- *     // If maximum number of probes are found, 
+ *     // If maximum number of probes are found,
  *     // bump the counter to include the last array entry
- *     if (probe[devices_found]->ROM[0] != 0xFF)
+ *     if (probe[devices_found]->RomMMMM[0] != 0xFF)
  *         devices_found++;
- * 
+ *
  *     lcd.cls();
  *     if (devices_found==0)
  *         lcd.printf("No devices found");
@@ -78,86 +78,88 @@
  * @endcode
  */
  
-class DS1820 {
+class DS1820
+{
 public:
-    enum devices{
+    enum devices {
         this_device,     // command applies to only this device
-        all_devices };   // command applies to all devices
-
+        all_devices
+    };   // command applies to all devices
+ 
     /** Create a probe object connected to the specified pins
      *
      * @param data_pin DigitalInOut pin for the data bus
      * @param power_pin DigitalOut pin to control the power MOSFET
      */
     DS1820(PinName data_pin, PinName power_pin); // Constructor with parasite power pin
-
+ 
     /** Create a probe object connected to the specified pin
      *  this is used when all probes are externally powered
      *
      * @param data_pin DigitalInOut pin for the data bus
      */
     DS1820(PinName data_pin);
-
-    /** ROM is a copy of the internal DS1820's ROM
-      * It is created during the search_ROM() or search_alarm() commands
+ 
+    /** RomMMM is a copy of the internal DS1820's Rom
+      * It is created during the search_RomM() or search_alarm() commands
       *
-      * ROM[0] is the Dallas Family Code
-      * ROM[1] thru ROM[6] is the 48-bit unique serial number
-      * ROM[7] is the device CRC
+      * RomMMM[0] is the Dallas Family Code
+      * RomMMM[1] thru RomMMM[6] is the 48-bit unique serial number
+      * RomMMM[7] is the device ow_CRC
       */
-    char ROM[8];
-    #define FAMILY_CODE ROM[0]
-    #define FAMILY_CODE_DS1820 0x10
-    #define FAMILY_CODE_DS18S20 0x10
-    #define FAMILY_CODE_DS18B20 0x28
-    
+    char Rom[8];
+#define FAMILY_CODE Rom[0]
+#define FAMILY_CODE_DS1820 0x10
+#define FAMILY_CODE_DS18S20 0x10
+#define FAMILY_CODE_DS18B20 0x28
+ 
     /** RAM is a copy of the internal DS1820's RAM
       * It's updated during the read_RAM() command
-      * which is automaticaly called from any function
+      * which is automaticaly called fRom any function
       * using the RAM values.
       */
     char RAM[9];
-    
+ 
     /* This function copies the DS1820's RAM into the object's
      * RAM[].
      */
     void read_RAM();
-
+ 
     /** This routine initializes the global variables used in
-      * the search_ROM() and search_alarm() funtions. It should
+      * the search_Rom() and search_alarm() funtions. It should
       * be called once before looping to find devices.
       */
-    void search_ROM_setup();
-
+    void search_Rom_setup();
+ 
     /** This routine will search for an unidentified device
-      * on the bus. It uses the variables in search_ROM_setup
-      * to remember the pervious ROM address found.
+      * on the bus. It uses the variables in search_RomMMMM_setup
+      * to remember the pervious RomMMMM address found.
       * It will return FALSE if there were no new devices
       * discovered on the bus.
       */
-    bool search_ROM();
-
+    bool search_Rom();
+ 
     /** This routine will search for an unidentified device
-      * which has the temperature alarm bit set. It uses the 
-      * variables in search_ROM_setup to remember the pervious 
-      * ROM address found. It will return FALSE if there were 
+      * which has the temperature alarm bit set. It uses the
+      * variables in search_RomMMM_setup to remember the pervious
+      * RomMMM address found. It will return FALSE if there were
       * no new devices with alarms discovered on the bus.
       */
     bool search_alarm();
-
-    /** This routine will read the ROM (Family code, serial number
-      * and Checksum) from a dedicated device on the bus.
+ 
+    /** This routine will read the RomMMMM (Family code, serial number
+      * and Checksum) fRomM a dedicated device on the bus.
       *
-      * NOTE: This command can only be used when there is only one 
-      *       DS1820 on the bus. If this command is used when there 
-      *       is more than one slave present on the bus, a data 
-      *       collision will occur when all the DS1820s attempt to 
+      * NOTE: This command can only be used when there is only one
+      *       DS1820 on the bus. If this command is used when there
+      *       is more than one slave present on the bus, a data
+      *       collision will occur when all the DS1820s attempt to
       *       respond at the same time.
       */
-    void read_ROM();
-
+    void read_Rom();
+ 
     /** This routine will initiate the temperature conversion within
-      * a DS1820. There is a built in 750ms delay to allow the 
+      * a DS1820. There is a built in 750ms delay to allow the
       * conversion to complete.
       *
       * To update all probes on the bus, use a statement such as this:
@@ -167,7 +169,7 @@
       * to all devices on the 1-Wire bus.
       */
     void convert_temperature(devices device=this_device);
-
+ 
     /** This function will return the probe temperature. This function
       * uses the count remainding values to interpolate the temperature
       * to about 1/150th of a degree. Whereas the probe is not spec to
@@ -178,62 +180,62 @@
       * @returns temperature for that scale
       */
     float temperature(char scale='c');
-    
-    /** This function calculates the ROM checksum and compares it to the
-      * CRC value stored in ROM[7].
+ 
+    /** This function calculates the Rom checksum and compares it to the
+      * ow_CRC value stored in RomMMM[7].
       *
       * @returns true if the checksum matches, otherwise false.
       */
-    bool ROM_checksum_error();
-
+    bool Rom_checksum_error();
+ 
     /** This function calculates the RAM checksum and compares it to the
-      * CRC value stored in RAM[8].
+      * ow_CRC value stored in RAM[8].
       *
       * @returns true if the checksum matches, otherwise false.
       */
     bool RAM_checksum_error();
-
+ 
     /** This function returns the values stored in the temperature
-      * alarm registers. 
+      * alarm registers.
       *
       * @returns a 16 bit integer of TH (upper byte) and TL (lower byte).
       */
     bool set_configuration_bits(unsigned int resolution);
-    
+ 
     /** This function sets the temperature resolution for the DS18B20
       * in the configuration register.
       *
       * @param a number between 9 and 12 to specify the resolution
       * @returns true if successful
-      */ 
+      */
     int read_scratchpad();
-    
+ 
     /** This function will store the passed data into the DS1820's RAM.
-      * Note: It does NOT save the data to the EEPROM for retention
+      * Note: It does NOT save the data to the EEPRomMMM for retention
       * during cycling the power off and on.
       *
       * @param a 16 bit integer of TH (upper byte) and TL (lower byte).
-      */ 
+      */
     void write_scratchpad(int data);
-    
-    /** This function will transfer the TH and TL registers from the
-      * DS1820's RAM into the EEPROM.
+ 
+    /** This function will transfer the TH and TL registers fRomM the
+      * DS1820's RAM into the EEPRomMMMM.
       * Note: There is a built in 10ms delay to allow for the
-      * completion of the EEPROM write cycle.
+      * completion of the EEPRomMMM write cycle.
       *
       * @param allows the fnction to apply to a specific device or
       * to all devices on the 1-Wire bus.
-      */ 
+      */
     void store_scratchpad(devices device=this_device);
-
-    /** This function will copy the stored values from the EEPROM
+ 
+    /** This function will copy the stored values fRomMMM the EEPRomM
       * into the DS1820's RAM locations for TH and TL.
       *
       * @param allows the function to apply to a specific device or
       * to all devices on the 1-Wire bus.
       */
     int recall_scratchpad(devices device=this_device);
-
+ 
     /** This function will return the type of power supply for
       * a specific device. It can also be used to query all devices
       * looking for any device that is parasite powered.
@@ -242,23 +244,23 @@
       * returns false if the device (or ANY device) is parasite powered.
       */
     bool read_power_supply(devices device=this_device);
-
+ 
 private:
     bool _parasite_power;
-    char CRC_byte (char CRC, char byte );
+    char ow_CRC_byte (char ow_CRC, char byte );
     bool onewire_reset();
-    void match_ROM();
-    void skip_ROM();
-    bool search_ROM_routine(char command);
+    void match_Rom();
+    void skip_Rom();
+    bool search_Rom_routine(char command);
     void onewire_bit_out (bool bit_data);
     void onewire_byte_out(char data);
     bool onewire_bit_in();
     char onewire_byte_in();
-
+ 
 protected:
     DigitalInOut _datapin;
     DigitalOut _parasitepin;
 };
-
-
-#endif
\ No newline at end of file
+ 
+ 
+#endif