Date Library

Dependents:   rtc_func

Files at this revision

API Documentation at this revision

Comitter:
wolpra98
Date:
Thu Apr 23 09:38:00 2015 +0000
Commit message:
Date library;

Changed in this revision

Date.cpp Show annotated file Show diff for this revision Revisions of this file
Date.h Show annotated file Show diff for this revision Revisions of this file
diff -r 000000000000 -r d2f9a55f0e6d Date.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Date.cpp	Thu Apr 23 09:38:00 2015 +0000
@@ -0,0 +1,24 @@
+#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);
+}
+uint8_t Date::GetMonth()
+{
+    uint8_t months = rtc_read(MONTHS);
+    return bcdToUint(months);
+}
+uint8_t Date::GetYear()
+{
+    uint8_t year = rtc_read(YEARS);
+    return bcdToUint(year);
+}
\ No newline at end of file
diff -r 000000000000 -r d2f9a55f0e6d Date.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Date.h	Thu Apr 23 09:38:00 2015 +0000
@@ -0,0 +1,20 @@
+#include "mbed.h"
+#include "const.h"
+#include "RTC8563.h"
+
+#ifndef DATE_H
+#define DATE_H
+class Date : public RTC8563
+{
+private:
+    uint8_t bcdToUint(uint8_t const nybbles);
+public:
+    uint8_t GetDay();
+public:
+    uint8_t GetMonth();
+public:
+    uint8_t GetYear();
+};
+
+
+#endif
\ No newline at end of file