A class library development test using TMP102 (I2C temperature sensor).

Files at this revision

API Documentation at this revision

Comitter:
yasubumi
Date:
Sun Nov 26 01:01:05 2017 +0000
Parent:
1:c9c43b132ed7
Commit message:
add comment

Changed in this revision

test_TMP102.h Show annotated file Show diff for this revision Revisions of this file
diff -r c9c43b132ed7 -r 494a328aed3e test_TMP102.h
--- a/test_TMP102.h	Sun Nov 26 00:05:12 2017 +0000
+++ b/test_TMP102.h	Sun Nov 26 01:01:05 2017 +0000
@@ -1,22 +1,94 @@
+/** A practice code for class library development
+ *
+ *  @author  Yasubumi KANAZAWA
+ *  @version 1.0
+ *  @date    26-Nov-2017
+ *
+ *  This code is plactice of the class code development.
+ *  The sample is a I2C temperature sensor TMP102.
+ *
+ *  Reference page
+ *      https://os.mbed.com/users/okano/notebook/mbed-library-study-meeting-2014-nov-07/"
+ *
+ *  About TMP102:
+ *      http://www.sparkfun.com/datasheets/Sensors/Temperature/tmp102.pdf
+ */
+
 #include "mbed.h"
 
-// TMP102 I2C slave address(ADD0 connected to GND)
+/** Default slave address(ADD0 connected to GND) */
 #define ADDR_TMP102     0x90
 
-// TMP102 registers
+/** TMP102 register names and addresses */
 #define TMP102_Temp     0x00
 #define TMP102_Conf     0x01
 #define TMP102_Tlow     0x02
 #define TMP102_Thigh    0x03
 
+/** test_TMP102 Class Library
+ * to provide very simple interface for mbed
+ *
+ * Example:
+ * @code
+ * #include "mbed.h"
+ * #include "test_TMP102.h"
+ *
+ * // make test_TMP102 instance using GPIO pin name.
+ * test_TMP102 temp0(dp4,dp5);
+ *
+ * // make test_TMP102 instance using I2C object.
+ * I2C i2c(dp4,dp5);
+ * test_TMP102 temp1(i2c);
+ *
+ * int main()
+ * {
+ *     float t0,t1;
+ *
+ *     i2c.frequency(400*1000);
+ *
+ *     while(1) {
+ *         t0=temp0;
+ *         t1=temp1;
+ *         printf("Temp: %7.3f, %7.3f\r\n", t0, t1);
+ *         wait(1.0);
+ *     }
+ * }
+ * @endcode
+ */
 class test_TMP102
 {
 public:
+    /** Create a test_TMP102 instance connected to specified I2C pins with specified address
+     *
+     * @param sda I2C-bus SDA pin
+     * @param scl I2C-bus SCL pin
+     * @param address (option) I2C-bus slave address (default: 0x90)
+     */
     test_TMP102(PinName sda, PinName scl, char address = ADDR_TMP102);
+
+    /** Create a test_TMP102 instance connected to specified I2C pins with specified address
+     *
+     * @param i2c_obj I2C object (instance)
+     * @param address (option) I2C-bus slave address (default: 0x90)
+     */
     test_TMP102(I2C &i2c_obj, char address = ADDR_TMP102);
+
+    /** Destractor */
     ~test_TMP102();
+
+    /** Initialization */
     void init(void);
+
+    /** Read temperature
+     *
+     *  @return value of degree Celsius (in float)
+     */
     float read(void);
+
+    /** Read temperature
+     *
+     *  @return the object returns the read value
+     */
     operator float(void);
 private:
     I2C *i2c_p;