RTC library without debug statements

Fork of RTC-DS1307 by Steven .

Revision:
11:e795b18c05ac
Parent:
10:86d9e3549da6
--- a/Rtc_Ds1307.cpp	Wed Feb 19 13:30:05 2014 +0000
+++ b/Rtc_Ds1307.cpp	Fri Mar 20 19:48:57 2015 +0000
@@ -1,10 +1,10 @@
 #include "mbed.h"
 #include "Rtc_Ds1307.h"
 
-#ifndef DEBUG
+//#ifndef DEBUG
 //#define DEBUG
-#endif
-#include "debug.h"
+//#endif
+//#include "debug.h"
 
 const char *Rtc_Ds1307::m_weekDays[] = { "Saturday", "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday" };    
 
@@ -29,9 +29,9 @@
 bool Rtc_Ds1307::setTime(Time_rtc& time, bool start, bool thm)
 {
     char buffer[7];
-    INFO("reading clock registers to write the new time : %d:%d:%d\n", time.hour, time.min, time.sec);
+    //INFO("reading clock registers to write the new time : %d:%d:%d\n", time.hour, time.min, time.sec);
     if (!read(0,buffer,7)) {
-        ERR("Failed to read from RTC\n");
+        //ERR("Failed to read from RTC\n");
         return false;
     }
     //  Now update only the time part (saving the existing flags)
@@ -50,9 +50,9 @@
     buffer[4] = decimalToBcd(time.date);
     buffer[5] = decimalToBcd(time.mon);
     buffer[6] = decimalToBcd(time.year-2000);
-    INFO("Writing new time and date data to RTC\n");
+    //INFO("Writing new time and date data to RTC\n");
     if (!write(0, buffer, 7) ) {
-        ERR("Failed to write the data to RTC!\n");
+        //ERR("Failed to write the data to RTC!\n");
         return false;
     }
     return true;
@@ -63,10 +63,10 @@
     char buffer[7];
     bool thm = false;
     
-    INFO("Getting time from RTC\n");
+    //INFO("Getting time from RTC\n");
     if (!read(0, buffer, 7) ) {
         //  Failed to read
-        ERR("Failed to read from RTC\n");
+        //ERR("Failed to read from RTC\n");
         return false;
     }
     thm = ((buffer[2] & 64) == 64);
@@ -94,21 +94,21 @@
 {
     char strtStop;
     
-    INFO ("Reading clock start/stop register value\n");
+    //INFO ("Reading clock start/stop register value\n");
     if (!read(0, &strtStop, 1)) {
-        ERR("Failed to read clock start stop register !\n");
+        //ERR("Failed to read clock start stop register !\n");
         return false;
     }
     
     strtStop &= 0x7F;
     
-    INFO("Writing back start/stop register value\n");
+    //INFO("Writing back start/stop register value\n");
     if (!write(0, &strtStop, 1)) {
-        ERR("Failed to write the start stop register !\n");
+        //ERR("Failed to write the start stop register !\n");
         return false;
     }
     
-    INFO("Start/stop register value successfully written\n");
+    //INFO("Start/stop register value successfully written\n");
     return true;
 }
 
@@ -116,47 +116,47 @@
 {
     char strtStop;
     
-    INFO ("Reading clock start/stop register value\n");
+    //INFO ("Reading clock start/stop register value\n");
     if (!read(0, &strtStop, 1)) {
-        ERR("Failed to read clock start stop register !\n");
+        //ERR("Failed to read clock start stop register !\n");
         return false;
     }
     
     strtStop |= 0x80;
     
-    INFO("Writing back start/stop register value\n");
+    //INFO("Writing back start/stop register value\n");
     if (!write(0, &strtStop, 1)) {
-        ERR("Failed to write the start stop register !\n");
+        //ERR("Failed to write the start stop register !\n");
         return false;
     }
     
-    INFO("Start/stop register value successfully written\n");
+    //INFO("Start/stop register value successfully written\n");
     return true;
 }
 
 bool Rtc_Ds1307::setSquareWaveOutput(bool ena, SqwRateSelect_t rs)
 {
     char reg;
-    INFO("Reading register value first\n");
+    //INFO("Reading register value first\n");
     
     if (!read(7,&reg, 1)) {
-        ERR("Failed to read register value !\n");
+        //ERR("Failed to read register value !\n");
         return false;
     }
-    INFO("[Reg:0x07] = %02x\n", reg); 
+    //INFO("[Reg:0x07] = %02x\n", reg); 
     
     //  preserve the OUT control bit while writing the frequency and enable bits
     reg = (reg & 0x80) | (ena ? 0x10 : 0) | ((char)rs & 0x03);
 
-    INFO("Writing back register value\n");
-    INFO("[Reg:0x07] = %02x\n", reg); 
+    //INFO("Writing back register value\n");
+    //INFO("[Reg:0x07] = %02x\n", reg); 
     
     if (!write(7, &reg, 1)) {
-        ERR("Failed to write register value !\n");
+        //ERR("Failed to write register value !\n");
         return false;
     }
     
-    INFO("Successfully changed the square wave output.\n");
+    //INFO("Successfully changed the square wave output.\n");
     return true;
 }
 
@@ -168,17 +168,17 @@
     
 //    m_rtc->start();
     if (m_rtc->write(0xd0, buffer2, 1) != 0) {
-        ERR("Failed to write register address on rtv!\n");
+        //ERR("Failed to write register address on rtv!\n");
         m_rtc->stop();
         return false;
     }
     if (m_rtc->read(0xd0, buffer, len) != 0) {
-        ERR("Failed to read register !\n");
+        //ERR("Failed to read register !\n");
         return false;
     }
     m_rtc->stop();
     
-    INFO("Successfully read %d registers from RTC\n", len);
+    //INFO("Successfully read %d registers from RTC\n", len);
     return true;
 }
 
@@ -191,7 +191,7 @@
 
 //    m_rtc->start();        
     if (m_rtc->write(0xd0, buffer2, len+1) != 0) {
-        ERR("Failed to write data to rtc\n");
+        //ERR("Failed to write data to rtc\n");
         m_rtc->stop();
         return false;
     }
@@ -243,10 +243,10 @@
         getTime(t);
         struct tm now = {t.sec, t.min, t.hour, t.date, t.mon-1, t.year-1900};
         m_time = mktime(&now);
-        INFO("getting time %02d.%02d.%04d %02d:%02d:%02d Ticks=%08lx", t.date, t.mon, t.year, t.hour, t.min, t.sec, m_time);
+        //INFO("getting time %02d.%02d.%04d %02d:%02d:%02d Ticks=%08lx", t.date, t.mon, t.year, t.hour, t.min, t.sec, m_time);
     }
     else {
-        INFO("getting time Ticks=%08lx", m_time);
+        //INFO("getting time Ticks=%08lx", m_time);
     }
     return m_time;
 }