RTC Lib & Output

Dependencies:   LM75B RTC8563 mbed

Committer:
EmilMcDuck
Date:
Thu Apr 16 10:19:43 2015 +0000
Revision:
1:9d545a2abf32
Parent:
0:b2c29eef3ac4
Child:
2:101ad0c50fe1
RTC lib added

Who changed what in which revision?

UserRevisionLine numberNew 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 0:b2c29eef3ac4 4
EmilMcDuck 0:b2c29eef3ac4 5 char year, month, day, week;
EmilMcDuck 0:b2c29eef3ac4 6 char hour, minute, sec;
EmilMcDuck 0:b2c29eef3ac4 7
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 1:9d545a2abf32 11 RTC8563 rtc(p27, p28);
EmilMcDuck 0:b2c29eef3ac4 12
EmilMcDuck 0:b2c29eef3ac4 13 int main()
EmilMcDuck 0:b2c29eef3ac4 14 {
EmilMcDuck 1:9d545a2abf32 15 rtc.init(15, 4, 16, 12, 16, 0, 4);
EmilMcDuck 0:b2c29eef3ac4 16
EmilMcDuck 0:b2c29eef3ac4 17 while(1) {
EmilMcDuck 1:9d545a2abf32 18 year = rtc.read(YEARS);
EmilMcDuck 1:9d545a2abf32 19 month = rtc.read(MONTHS);
EmilMcDuck 1:9d545a2abf32 20 day = rtc.read(DAYS);
EmilMcDuck 1:9d545a2abf32 21 week = rtc.read(WEEKDAYS);
EmilMcDuck 1:9d545a2abf32 22 hour = rtc.read(HOURS);
EmilMcDuck 1:9d545a2abf32 23 minute = rtc.read(MINUTES);
EmilMcDuck 1:9d545a2abf32 24 sec = rtc.read(SECONDS);
EmilMcDuck 1:9d545a2abf32 25
EmilMcDuck 1:9d545a2abf32 26 pc.printf("20%d/%02d/%02d %s\n", year, month, day, week_chr[week]); // Date
EmilMcDuck 1:9d545a2abf32 27 pc.printf("%02d:%02d:%02d\n", hour, minute, sec); // Time
EmilMcDuck 0:b2c29eef3ac4 28 wait(0.2);
EmilMcDuck 0:b2c29eef3ac4 29 }
EmilMcDuck 0:b2c29eef3ac4 30 }