A cut-down version of https://os.mbed.com/users/Sissors/code/DS1820/ tweaked for use with the STM32F103. It is all generic Mbed operations though, so should be usable anywhere. Non-essential functions have been removed, as this is intended for use within a tutorial.

Dependencies:   LinkedList

Dependents:   STM32F103C8T6_DS18B20 stm32f103c8t6-ds18b20

Fork of DS1820 by Erik -

Revision:
1:6a427f54e82c
Parent:
0:61d83318f2d6
Child:
2:ee820a991b95
diff -r 61d83318f2d6 -r 6a427f54e82c DS1820.h
--- a/DS1820.h	Sun Dec 19 05:40:28 2010 +0000
+++ b/DS1820.h	Wed Dec 14 20:22:16 2011 +0000
@@ -106,6 +106,10 @@
       * ROM[7] is the device CRC
       */
     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
@@ -189,11 +193,19 @@
       */
     bool RAM_checksum_error();
 
-    /** This funtion returns the values stored in the temperature
+    /** This function returns the values stored in the temperature
       * 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.
@@ -217,7 +229,7 @@
     /** This function will copy the stored values from the EEPROM
       * into the DS1820's RAM locations for TH and TL.
       *
-      * @param allows the fnction to apply to a specific device or
+      * @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);