A feature complete driver for the LM75B temperature sensor from NXP.

Fork of LM75B by Neil Thiessen

Revision:
9:74b44a27fa40
Parent:
8:2b797c309258
Child:
10:51d149fa47bd
--- a/LM75B.h	Wed Aug 14 04:33:25 2013 +0000
+++ b/LM75B.h	Wed Aug 28 17:17:24 2013 +0000
@@ -29,16 +29,25 @@
  *
  * LM75B sensor(p28, p27, LM75B::ADDRESS_0);
  *
- * int main() {
- *     while (1) {
- *         //Read the temperature
- *         float temp = sensor.temp();
+ * int main()
+ * {
+ *     //Try to open the LM75B
+ *     if (sensor.open()) {
+ *         printf("Device detected!\n");
+ *
+ *         while (1) {
+ *             //Read the temperature
+ *             float temp = sensor.temp();
  *
- *         //Print the temperature
- *         printf("Temp = %.3f\n", temp);
+ *             //Print the temperature
+ *             printf("Temp = %.3f\n", temp);
  *
- *         //Sleep for 0.5 seconds
- *         wait(0.5);
+ *             //Sleep for 0.5 seconds
+ *             wait(0.5);
+ *         }
+ *     } else {
+ *         printf("Device not detected!\n");
+ *         while (1);
  *     }
  * }
  * @endcode
@@ -97,6 +106,14 @@
      */
     LM75B(PinName sda, PinName scl, Address addr);
 
+    /** Probes for the LM75B and resets it to default configuration if present
+     *
+     * @returns
+     *   'true' if the device exists on the bus,
+     *   'false' if the device doesn't exist on the bus.
+     */
+    bool open(void);
+
     /** Get the current power mode of the LM75B
      *
      * @returns The current power mode as a PowerMode enum.