X-Git-Url: http://cloudbase.mooo.com/gitweb/z180-stamp.git/blobdiff_plain/61b0cfe9df810db4fbca78e5f880d61c5063f324..7f552300815ccadd45ebb3e7f0ae72a3b2e0c4e5:/avr/pcf8583.c diff --git a/avr/pcf8583.c b/avr/pcf8583.c index d33c9b0..af1331d 100644 --- a/avr/pcf8583.c +++ b/avr/pcf8583.c @@ -2,8 +2,6 @@ * Date & Time support for Philips PCF8583 RTC */ -/* #define DEBUG */ - #include "common.h" #include #include "debug.h" @@ -11,6 +9,11 @@ #include "rtc.h" #include "i2c.h" +#define DEBUG_RTC 0 + +#define debug_rtc(fmt, args...) \ + debug_cond(DEBUG_RTC, fmt, ##args) + #define REG_CS 0x00 /* control/status */ #define REG_CSEC 0x01 /* hundredth of a second */ #define REG_SEC 0x02 /* seconds */ @@ -45,7 +48,7 @@ int rtc_get (struct rtc_time *tmp) i2c_read(CONFIG_SYS_I2C_RTC_ADDR, 0, 1, rtcbuf, NR_OF_REGS); i2c_read(CONFIG_SYS_I2C_RTC_ADDR, 0x10, 1, (uint8_t *) &year, 2); - debug("Get RTC year: %u, year/date: %02x, wdays/month: %02x, " + debug_rtc("Get RTC year: %u, year/date: %02x, wdays/month: %02x, " "hour: %02x, min: %02x, sec: %02x, (stat: %02x)\n", year, rtcbuf[6], rtcbuf[5], rtcbuf[4], rtcbuf[3], rtcbuf[2], rtcbuf[0]); @@ -64,7 +67,7 @@ int rtc_get (struct rtc_time *tmp) tmp->tm_isdst= 0; - debug ( "Get DATE: %4d-%02d-%02d (wday=%d) TIME: %2d:%02d:%02d\n", + debug_rtc( "Get DATE: %4d-%02d-%02d (wday=%d) TIME: %2d:%02d:%02d\n", tmp->tm_year, tmp->tm_mon, tmp->tm_mday, tmp->tm_wday, tmp->tm_hour, tmp->tm_min, tmp->tm_sec); @@ -75,7 +78,7 @@ int rtc_set (struct rtc_time *tmp) { uint8_t rtcbuf[NR_OF_REGS]; - debug ( "Set DATE: %4d-%02d-%02d (wday=%d) TIME: %2d:%02d:%02d\n", + debug_rtc("Set DATE: %4d-%02d-%02d (wday=%d) TIME: %2d:%02d:%02d\n", tmp->tm_year, tmp->tm_mon, tmp->tm_mday, tmp->tm_wday, tmp->tm_hour, tmp->tm_min, tmp->tm_sec); @@ -95,12 +98,3 @@ int rtc_set (struct rtc_time *tmp) return 0; } - -void rtc_reset (void) -{ - uint8_t c = 0; - - i2c_write(CONFIG_SYS_I2C_RTC_ADDR, 0, 1, &c, 1); -} - -