Functions from rtc_func are programmed in a class

Dependencies:   RTC8563 mbed

Fork of rtc_class by Johannes Mayerhofer

Revision:
0:1df9d38ebe29
diff -r 000000000000 -r 1df9d38ebe29 Date.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Date.cpp	Wed Apr 22 19:46:49 2015 +0000
@@ -0,0 +1,45 @@
+#include "mbed.h"
+#include "const.h"
+#include "Date.h"
+
+uint8_t Date::bcdToUint(uint8_t const nybbles)
+{
+    uint8_t result;
+    result = (nybbles>>4)*10 + (nybbles & 0x0F);
+    return result;
+}
+uint8_t Date::GetDay()
+{
+    uint8_t day = rtc_read(DAYS);
+    return bcdToUint(day & 0x3F);
+}
+uint8_t Date::GetMonth()
+{
+    uint8_t month = rtc_read(MONTHS);
+    return bcdToUint(month & 0x1F);
+}
+uint8_t Date::GetYear()
+{
+    uint8_t year = rtc_read(YEARS);
+    return bcdToUint(year & 0x3F);
+}
+uint8_t Date::GetSecond()
+{
+    uint8_t second = rtc_read(SECONDS);
+    return bcdToUint(second & 0x7F);
+}
+uint8_t Date::GetMinute()
+{
+    uint8_t minute = rtc_read(MINUTES);
+    return bcdToUint(minute & 0x7F);
+}
+uint8_t Date::GetHour()
+{
+    uint8_t hour = rtc_read(HOURS);
+    return bcdToUint(hour & 0x3F);
+}
+uint8_t Date::GetWeek()
+{
+    uint8_t week = rtc_read(WEEKDAYS);
+    return bcdToUint(week & 0x07);
+}
\ No newline at end of file