Fresh McD
/
rtc_class3
rtc class
Fork of rtc_class by
Date.cpp@3:c6081814064d, 2015-04-20 (annotated)
- Committer:
- bulmecisco
- Date:
- Mon Apr 20 05:53:40 2015 +0000
- Revision:
- 3:c6081814064d
- Child:
- 4:a4d39c018c65
class Date inherited from class RTC8563; Example methode GetDay implemented
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
bulmecisco | 3:c6081814064d | 1 | #include "mbed.h" |
bulmecisco | 3:c6081814064d | 2 | #include "const.h" |
bulmecisco | 3:c6081814064d | 3 | #include "Date.h" |
bulmecisco | 3:c6081814064d | 4 | |
bulmecisco | 3:c6081814064d | 5 | // http://developer.mbed.org/teams/HIMBED_3AHELI/code/rtc_func/wiki/Homepage |
bulmecisco | 3:c6081814064d | 6 | uint8_t Date::bcdToUint(uint8_t const nybbles) |
bulmecisco | 3:c6081814064d | 7 | { |
bulmecisco | 3:c6081814064d | 8 | uint8_t result; |
bulmecisco | 3:c6081814064d | 9 | result = (nybbles>>4)*10 + (nybbles & 0x0F); |
bulmecisco | 3:c6081814064d | 10 | return result; |
bulmecisco | 3:c6081814064d | 11 | } |
bulmecisco | 3:c6081814064d | 12 | |
bulmecisco | 3:c6081814064d | 13 | uint8_t Date::GetDay() |
bulmecisco | 3:c6081814064d | 14 | { |
bulmecisco | 3:c6081814064d | 15 | uint8_t day = rtc_read(DAYS); |
bulmecisco | 3:c6081814064d | 16 | return bcdToUint(day & 0x3F); |
bulmecisco | 3:c6081814064d | 17 | } |