Date Library

Dependents:   rtc_func

Committer:
wolpra98
Date:
Thu Apr 23 09:38:00 2015 +0000
Revision:
0:d2f9a55f0e6d
Date library;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
wolpra98 0:d2f9a55f0e6d 1 #include "mbed.h"
wolpra98 0:d2f9a55f0e6d 2 #include "const.h"
wolpra98 0:d2f9a55f0e6d 3 #include "Date.h"
wolpra98 0:d2f9a55f0e6d 4 uint8_t Date::bcdToUint(uint8_t const nybbles)
wolpra98 0:d2f9a55f0e6d 5 {
wolpra98 0:d2f9a55f0e6d 6 uint8_t result;
wolpra98 0:d2f9a55f0e6d 7 result = (nybbles>>4)*10 + (nybbles&&0x0F);
wolpra98 0:d2f9a55f0e6d 8 return result;
wolpra98 0:d2f9a55f0e6d 9 }
wolpra98 0:d2f9a55f0e6d 10 uint8_t Date::GetDay()
wolpra98 0:d2f9a55f0e6d 11 {
wolpra98 0:d2f9a55f0e6d 12 uint8_t day = rtc_read(DAYS);
wolpra98 0:d2f9a55f0e6d 13 return bcdToUint(day);
wolpra98 0:d2f9a55f0e6d 14 }
wolpra98 0:d2f9a55f0e6d 15 uint8_t Date::GetMonth()
wolpra98 0:d2f9a55f0e6d 16 {
wolpra98 0:d2f9a55f0e6d 17 uint8_t months = rtc_read(MONTHS);
wolpra98 0:d2f9a55f0e6d 18 return bcdToUint(months);
wolpra98 0:d2f9a55f0e6d 19 }
wolpra98 0:d2f9a55f0e6d 20 uint8_t Date::GetYear()
wolpra98 0:d2f9a55f0e6d 21 {
wolpra98 0:d2f9a55f0e6d 22 uint8_t year = rtc_read(YEARS);
wolpra98 0:d2f9a55f0e6d 23 return bcdToUint(year);
wolpra98 0:d2f9a55f0e6d 24 }