Fork of TMP102 by Craig Evans

Files at this revision

API Documentation at this revision

Comitter:
andreykotov91
Date:
Sun May 08 17:36:52 2016 +0000
Parent:
1:1b601445b336
Commit message:
Library edited for use with project

Changed in this revision

TMP102.cpp Show annotated file Show diff for this revision Revisions of this file
TMP102.h Show annotated file Show diff for this revision Revisions of this file
diff -r 1b601445b336 -r 3df27241f9b3 TMP102.cpp
--- a/TMP102.cpp	Mon Feb 15 11:18:04 2016 +0000
+++ b/TMP102.cpp	Sun May 08 17:36:52 2016 +0000
@@ -1,4 +1,9 @@
-// library implemtation file
+/**
+@file TMP102.cpp
+
+@brief Member functions implementations
+
+*/
 
 // obviously need to include the header
 #include "TMP102.h"
diff -r 1b601445b336 -r 3df27241f9b3 TMP102.h
--- a/TMP102.h	Mon Feb 15 11:18:04 2016 +0000
+++ b/TMP102.h	Sun May 08 17:36:52 2016 +0000
@@ -1,73 +1,84 @@
-// it is good practice to put a comment block on the top, with the name and details of the library
-// you can also include version numbers to keep track of changes/additions
-
-/* TMP102
+/** 
+@file TMP102.h
 
-Simple library to get the temperature data from a TMP102 sensor over I2C.
-
-v 1.0 - initial release
-
-(c) Craig A. Evans, University of Leeds, Jan 2016
+@brief Header file containing member functions and variables
 
 */
 
-// this is called a header guard and prevents a library from being included more than once
-// if it is not already defined, it is defined. If it it already defined, it won't be defined again
-// the header guard is closed at the end of the file
+// header guard
 #ifndef TMP102_H
 #define TMP102_H
 
-// the next thing in a library is usually any required defines
-// addresses for ADD0 connected to GND
+// addresses
 #define TMP102_ADD      0x48
 #define TMP102_R_ADD    0x91
 #define TMP102_W_ADD    0x90
 
-// register addresses
+// registers
 #define TEMP_REG    0x00
 #define CONFIG_REG  0x01
 #define TLOW_REG   0x02
 #define THIGH_REG    0x03
 
-// we need to include the mbed header (this will also have a header guard to prevent it being included more than once)
 #include "mbed.h"
 
-// a library is actually just a C++ class, we will create an instance of this class (an object) in our main code
+/**
+@brief Library for interfacing with TMP102 sensor in I2C
+
+@brief v 1.0 - initial release
+
+@author Craig A. Evans
+
+@date January 2016
+
+*/
+
 class TMP102
 {
-    // we define the methods that are 'public' i.e. able to be used by the user
+
 public:
     
-    // this is a 'constructor' and is used to create the object
+    /** Create a TMP102 object connected to the specified I2C pins
+    *
+    * @param sda - mbed SDA pin 
+    * @param scl - mbed SCL pin
+    * 
+    */
+    
     TMP102(PinName sda, PinName scl);
     
-    // we will also create an initialisation method
+    /** Initialise the object
+    */
     void init();
     
-    // and a method to get the temperature - note the return type
+    /** Retrieve the temperature
+    *
+    * @returns temperature in degrees Celsius (°C)
+    *
+    */
     float get_temperature();
     
-    // we also have 'private' methods that can be used in the library itself, but not called directly by the user
-private:
-
-    // called in event of error - flashes LED and hangs 
-    void error();
-    // reads temperature from the sensor
-    void read_temperature();
-    
-
-    // we also do the same for any variables
-public:
-    // don't generally allow direct access to variables, instead use 'accessor' and 'mutator' methods
-    
 private:
 
-    // class data member names often have a trailing underscore to make them easily identifiable
+    /** Called in event of error - flashes LED and hangs
+    */
+    void error();
+    /** Reads temperature from the sensor
+    */
+    void read_temperature();
+    
+    
+public:
+    
+    
+private:
+
+    /**Class data member names often have a trailing underscore to make them easily identifiable
+    */
     I2C* i2c_;
     DigitalOut* led_;
     float temperature_;
 
 };
 
-// end of the header guard
 #endif
\ No newline at end of file