RTC Lib & Output
Dependencies: LM75B RTC8563 mbed
main.cpp@3:08812f743fea, 2015-04-23 (annotated)
- Committer:
- EmilMcDuck
- Date:
- Thu Apr 23 09:37:34 2015 +0000
- Revision:
- 3:08812f743fea
- Parent:
- 2:101ad0c50fe1
Publish
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
EmilMcDuck | 1:9d545a2abf32 | 1 | #include "RTC8563.h" |
EmilMcDuck | 0:b2c29eef3ac4 | 2 | #include "mbed.h" |
EmilMcDuck | 1:9d545a2abf32 | 3 | #include "const.h" |
EmilMcDuck | 2:101ad0c50fe1 | 4 | #include "Date.h" |
EmilMcDuck | 2:101ad0c50fe1 | 5 | #include "string.h" |
EmilMcDuck | 0:b2c29eef3ac4 | 6 | |
EmilMcDuck | 2:101ad0c50fe1 | 7 | char day_a, hour_a, minute_a, week_a; |
EmilMcDuck | 0:b2c29eef3ac4 | 8 | char week_chr[7][4] = {"MON","TUE","WED","THU","FRI","SAT","SUN"}; |
EmilMcDuck | 0:b2c29eef3ac4 | 9 | |
EmilMcDuck | 0:b2c29eef3ac4 | 10 | Serial pc(USBTX, USBRX); |
EmilMcDuck | 2:101ad0c50fe1 | 11 | RTC8563 rtc(p28, p27); |
EmilMcDuck | 3:08812f743fea | 12 | Date date; |
EmilMcDuck | 3:08812f743fea | 13 | |
EmilMcDuck | 0:b2c29eef3ac4 | 14 | int main() |
EmilMcDuck | 0:b2c29eef3ac4 | 15 | { |
EmilMcDuck | 2:101ad0c50fe1 | 16 | rtc.init(15, 4, 16, 12, 16, 0, 4); // years, months, days, hours, minutes, seconds, weekday (1 == Monday) |
EmilMcDuck | 2:101ad0c50fe1 | 17 | rtc.alarm(16, 12, 10, 4); // day, hour, min, weekday |
EmilMcDuck | 0:b2c29eef3ac4 | 18 | |
EmilMcDuck | 0:b2c29eef3ac4 | 19 | while(1) { |
EmilMcDuck | 3:08812f743fea | 20 | |
EmilMcDuck | 2:101ad0c50fe1 | 21 | // RTC Zeit Ausgabe |
EmilMcDuck | 2:101ad0c50fe1 | 22 | pc.printf("RTC8563 TIME AND DATE:\n" ); |
EmilMcDuck | 3:08812f743fea | 23 | pc.printf("%02d.%02d.20%02d | %s\n", date.getDay(), date.getMonth(), date.getYear(), week_chr[date.getWeekday()]); // Date |
EmilMcDuck | 3:08812f743fea | 24 | pc.printf("%02d:%02d:%02d\n", date.getHours(), date.getMinutes(), date.getSeconds()); // Time |
EmilMcDuck | 2:101ad0c50fe1 | 25 | |
EmilMcDuck | 2:101ad0c50fe1 | 26 | // RTC Alarm |
EmilMcDuck | 2:101ad0c50fe1 | 27 | day_a = rtc.read(DAY_ALARM); |
EmilMcDuck | 2:101ad0c50fe1 | 28 | hour_a = rtc.read(HOUR_ALARM); |
EmilMcDuck | 2:101ad0c50fe1 | 29 | minute_a = rtc.read(MINUTE_ALARM); |
EmilMcDuck | 2:101ad0c50fe1 | 30 | week_a = rtc.read(WEEKDAY_ALARM); |
EmilMcDuck | 2:101ad0c50fe1 | 31 | |
EmilMcDuck | 2:101ad0c50fe1 | 32 | pc.printf("RTC8563 ALARM:\n" ); |
EmilMcDuck | 2:101ad0c50fe1 | 33 | pc.printf("DAY: %02dth | %02d:%02d %s\n", day_a, hour_a, minute_a, week_chr[week_a]); // Alarm |
EmilMcDuck | 3:08812f743fea | 34 | |
EmilMcDuck | 3:08812f743fea | 35 | pc.printf("##############################################\n" ); |
EmilMcDuck | 2:101ad0c50fe1 | 36 | wait(0.5); |
EmilMcDuck | 0:b2c29eef3ac4 | 37 | } |
EmilMcDuck | 0:b2c29eef3ac4 | 38 | } |