RTC on M0 and class design without rtc and target
Quote:
Example for training purposes only!!!
RTC/I2C data for target LPC11U24 Humer M0-Board and no data for others!!!
See RTC WIKI
Time.cpp@0:397b5462e6d7, 2018-11-15 (annotated)
- Committer:
- fpucher
- Date:
- Thu Nov 15 06:55:25 2018 +0000
- Revision:
- 0:397b5462e6d7
ifdef target
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
fpucher | 0:397b5462e6d7 | 1 | #include "Time.h" |
fpucher | 0:397b5462e6d7 | 2 | |
fpucher | 0:397b5462e6d7 | 3 | uint8_t Time :: GetHours() |
fpucher | 0:397b5462e6d7 | 4 | { |
fpucher | 0:397b5462e6d7 | 5 | uint8_t h = rtc_read(HOURS); |
fpucher | 0:397b5462e6d7 | 6 | return bcdToUint(h&0x3F); |
fpucher | 0:397b5462e6d7 | 7 | } |
fpucher | 0:397b5462e6d7 | 8 | |
fpucher | 0:397b5462e6d7 | 9 | uint8_t Time :: GetMinutes() |
fpucher | 0:397b5462e6d7 | 10 | { |
fpucher | 0:397b5462e6d7 | 11 | uint8_t m = rtc_read(MINUTES); |
fpucher | 0:397b5462e6d7 | 12 | return bcdToUint(m&0x7F); |
fpucher | 0:397b5462e6d7 | 13 | } |
fpucher | 0:397b5462e6d7 | 14 | |
fpucher | 0:397b5462e6d7 | 15 | uint8_t Time :: GetSeconds() |
fpucher | 0:397b5462e6d7 | 16 | { |
fpucher | 0:397b5462e6d7 | 17 | uint8_t s = rtc_read(SECONDS); |
fpucher | 0:397b5462e6d7 | 18 | return bcdToUint(s&0x7F); |
fpucher | 0:397b5462e6d7 | 19 | } |
fpucher | 0:397b5462e6d7 | 20 | |
fpucher | 0:397b5462e6d7 | 21 | uint8_t Time::bcdToUint(uint8_t const nybbles) |
fpucher | 0:397b5462e6d7 | 22 | { |
fpucher | 0:397b5462e6d7 | 23 | uint8_t result; |
fpucher | 0:397b5462e6d7 | 24 | result = (nybbles >> 4) * 10 + (nybbles & 0x0F); |
fpucher | 0:397b5462e6d7 | 25 | return result; |
fpucher | 0:397b5462e6d7 | 26 | } |