![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
added GetDay() GetYear() GetWeek()
Fork of rtc_class by
Diff: Date.cpp
- Revision:
- 2:ce174a86d215
- Child:
- 3:75f5352b387d
diff -r 554eb6675279 -r ce174a86d215 Date.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Date.cpp Thu Apr 23 09:42:34 2015 +0000 @@ -0,0 +1,32 @@ +#include "mbed.h" +#include "const.h" +#include "Date.h" + + +uint8_t 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 & 0x07F); +} +uint8_t Date::GetYear() +{ + uint8_t year = rtc_read(YEARS); + return bcdToUint(year & 0x3F); +} +uint8_t Date::GetWEEK() +{ + uint8_t week = rtc_read(WEEKDAYS); + return bcdToUint(week & 0x07); +} \ No newline at end of file