M41T62 is a serial real-time clock (RTC) made by STMicroelectronics.

Dependents:   LPC1114_data_logger Check_external_RTC LPC1114_barometer_with_data_logging

Revision:
2:c58da9ec9ae3
Parent:
1:9d7702a887d3
Child:
3:41c351da2fdf
--- a/m41t62_rtc.h	Sun Jun 22 01:45:49 2014 +0000
+++ b/m41t62_rtc.h	Sun Jun 22 06:08:15 2014 +0000
@@ -49,7 +49,6 @@
 #define RTC_SQW_2HZ         ((uint8_t)0xe)
 #define RTC_SQW_1HZ         ((uint8_t)0xf)
 
-
 typedef struct {    // BCD format
   uint8_t rtc_seconds;    
   uint8_t rtc_minutes;
@@ -61,15 +60,75 @@
   uint16_t rtc_year;
 }rtc_time;
 
+/** Interface for RTC (I2C Interface)  STMicroelectronics M41T62
+ *
+ *  Standalone type RTC via I2C interface
+ *
+ * @code
+ * #include "mbed.h"
+ *
+ * // I2C Communication
+ *  M41T62      m41t62(dp5,dp27);   // STmicro RTC(M41T62) SDA, SCL
+ * // If you connected I2C line not only this device but also other devices,
+ * //     you need to declare following method.
+ *  I2C         i2c(dp5,dp27);      // SDA, SCL
+ *  M41T62      m41t62(i2c);        // STmicro RTC(M41T62)
+ *
+ * int main() {
+ * tm t;
+ * time_t seconds;
+ * char buf[40];
+ *
+ *   m41t62.set_sq_wave(RTC_SQW_NONE);      // Stop output for more low current 
+ *
+ *   m41t62.read_rtc_std(&t);   // read RTC data
+ *   seconds = mktime(&t);
+ *   strftime(buf, 40, "%I:%M:%S %p (%Y/%m/%d)", localtime(&seconds));
+ *   printf("Date: %s\r\n", buf);
+ * }
+ * @endcode
+ */
+ 
 class M41T62 {
 public:
+    /** Configure data pin
+      * @param data SDA and SCL pins
+      */
     M41T62(PinName p_sda, PinName p_scl);
+
+    /** Configure data pin (with other devices on I2C line)
+      * @param I2C previous definition
+      */
     M41T62(I2C& p_i2c);
 
+    /** Read RTC data with Standard C "struct tm" format
+      * @param tm (data save area)
+      * @return none but all data in tm
+      */
     void read_rtc_std(tm *);
+
+    /** Write data to RTC data with Standard C "struct tm" format
+      * @param tm (save writing data)
+      * @return none but all data in tm
+      */
     void write_rtc_std(tm *);
+
+    /** Read RTC data with own format
+      * @param tm (data save area)
+      * @return none but all data in tm
+      */
     void read_rtc_direct(rtc_time *);
+
+    /** Read RTC data with own format
+      * @param tm (save writing data)
+      * @return none but all data in tm
+      */
     void write_rtc_direct(rtc_time *);
+
+    /** Control Square wave output port
+      * @param output_mode
+      * @return none
+      */
     void set_sq_wave(uint8_t );
 
 protected:
@@ -85,4 +144,4 @@
     uint8_t rtc_buf[8 + 2];   // buffer for RTC
 };
 
-#endif      // M41T62_H
\ No newline at end of file
+#endif      // M41T62_H