DS3231 driver with timestamp string function

Dependents:   swimate_v2

Fork of DS3231 by Robert Fischer

Files at this revision

API Documentation at this revision

Comitter:
paulbartell
Date:
Wed May 28 22:56:11 2014 +0000
Parent:
4:b5736355af3a
Commit message:
minor changes to loss of power detection;

Changed in this revision

DS3231.cpp Show annotated file Show diff for this revision Revisions of this file
DS3231.h Show annotated file Show diff for this revision Revisions of this file
diff -r b5736355af3a -r 71aad49938bc DS3231.cpp
--- a/DS3231.cpp	Tue May 27 23:53:24 2014 +0000
+++ b/DS3231.cpp	Wed May 28 22:56:11 2014 +0000
@@ -2,6 +2,9 @@
 
 DS3231::DS3231(PinName sda, PinName scl) : i2c(sda, scl)
     {
+        
+        powerFailure = OSF();
+        
     } 
     
     
@@ -139,6 +142,7 @@
     {int reg=readRegister(DS3231_Control_Status);
      reg=reg&0x7F;
      writeRegister(DS3231_Control_Status,reg);
+     powerFailure = false;
     }     
     
 bool DS3231::OSF()
@@ -148,6 +152,5 @@
 
 bool DS3231::checkClockIntegrity()
 {
-    int reg=readRegister(DS3231_Control_Status);
-    return(!(reg&DS3231_bit_OSF));
+    return !powerFailure;
 }
\ No newline at end of file
diff -r b5736355af3a -r 71aad49938bc DS3231.h
--- a/DS3231.h	Tue May 27 23:53:24 2014 +0000
+++ b/DS3231.h	Wed May 28 22:56:11 2014 +0000
@@ -231,6 +231,7 @@
      void decodeTime(int regHours, int regMinutes, int regSeconds,int *Hours, int *Minutes, int *Seconds);
      void decodeDate(int regDate,int regMonth, int regYear, int *date, int *month, int *year);
      char charbuf[20];
+     bool powerFailure;
     };