A library to read/write the various registers of the PCF8583 Real Time Clock/Calendar including the 240 bytes of non-volatile ram. Includes a printf like date/time formatting routine.

Dependents:   NixieClock800Max

Files at this revision

API Documentation at this revision

Comitter:
dennyem
Date:
Tue Feb 25 23:41:08 2014 +0000
Parent:
1:eaba89d6e5d8
Commit message:
Moved config functions to public

Changed in this revision

PCF8583_rtc.cpp Show annotated file Show diff for this revision Revisions of this file
PCF8583_rtc.h Show annotated file Show diff for this revision Revisions of this file
--- a/PCF8583_rtc.cpp	Sun Feb 23 21:27:24 2014 +0000
+++ b/PCF8583_rtc.cpp	Tue Feb 25 23:41:08 2014 +0000
@@ -30,8 +30,6 @@
    _i2c = i2c;
    _I2cAddress = I2cAddress;
    
-  configureControlReg(0);
-      
   ShortDateFormat = "d,m,yy";
   LongDateFormat  = "dddd dd mmmm yyyy";
   ShortTimeFormat = "d:m:yy";
@@ -359,7 +357,7 @@
 
     buf[0] = address;
     buf[1] = d;
-    _i2c->write(_I2cAddress, buf, 2);                              // Address PCF8583, see PCF8583 datasheet
+    _i2c->write(_I2cAddress, buf, 2);
     _i2c->stop();
 }
 
--- a/PCF8583_rtc.h	Sun Feb 23 21:27:24 2014 +0000
+++ b/PCF8583_rtc.h	Tue Feb 25 23:41:08 2014 +0000
@@ -136,18 +136,21 @@
 * @param address "TIME" = read the time, "ALARM" = read the alarm 
 * @param dti a DateTime_t structure containing the time or alarm data 
 */
-  void   write(const char address, DateTime_t dti);
+  void write(const char address, DateTime_t dti);
 
-  void   FormatDateTime(char *dest, char *format);
+  void FormatDateTime(char *dest, char *format);
 
-  bool   WriteNVram(char address, char * value, char num);
+  bool WriteNVram(char address, char * value, char num);
 
-  bool   ReadNVram(char address, char * dest, char num);
+  bool ReadNVram(char address, char * dest, char num);
 
-  void   SetDateTime(DateTime_t dti);
+  void SetDateTime(DateTime_t dti);
 
   char bin2bcd(char value);
   
+  void configureAlarmReg(char alarm);
+  void configureControlReg(char control);
+
 private:
   struct DateTime_t dt;
   char   _I2cAddress;
@@ -157,8 +160,6 @@
   void pauseCounting(void);
   char readByte(char address);
   void writeByte(char address, char d);
-  void configureAlarmReg(char alarm);
-  void configureControlReg(char control);
 };
 
 /** PCF8583_rtc class.