Date Library
Diff: Date.cpp
- Revision:
- 0:d2f9a55f0e6d
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