annotate target-utils/pirexplore/rtc.c @ 693:59f088f893a5

cc_ffk.c compiles
author Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
date Tue, 30 Sep 2014 01:56:15 +0000
parents c54c6ad1c66f
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
72
92c1ed6b4b67 pirexplore: RTC read implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
1 #include "types.h"
92c1ed6b4b67 pirexplore: RTC read implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
2 #include "rtc.h"
92c1ed6b4b67 pirexplore: RTC read implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
3
92c1ed6b4b67 pirexplore: RTC read implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
4 static void
92c1ed6b4b67 pirexplore: RTC read implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
5 read_time(tm)
92c1ed6b4b67 pirexplore: RTC read implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
6 struct rtctime *tm;
92c1ed6b4b67 pirexplore: RTC read implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
7 {
92c1ed6b4b67 pirexplore: RTC read implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
8 tm->year = RTC_REGS.rtc_cur.year;
92c1ed6b4b67 pirexplore: RTC read implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
9 tm->month = RTC_REGS.rtc_cur.month;
92c1ed6b4b67 pirexplore: RTC read implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
10 tm->day_of_month = RTC_REGS.rtc_cur.day_of_month;
92c1ed6b4b67 pirexplore: RTC read implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
11 tm->day_of_week = RTC_REGS.rtc_cur.day_of_week;
92c1ed6b4b67 pirexplore: RTC read implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
12 tm->hours = RTC_REGS.rtc_cur.hours;
92c1ed6b4b67 pirexplore: RTC read implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
13 tm->minutes = RTC_REGS.rtc_cur.minutes;
92c1ed6b4b67 pirexplore: RTC read implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
14 tm->seconds = RTC_REGS.rtc_cur.seconds;
92c1ed6b4b67 pirexplore: RTC read implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
15 }
92c1ed6b4b67 pirexplore: RTC read implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
16
92c1ed6b4b67 pirexplore: RTC read implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
17 void
92c1ed6b4b67 pirexplore: RTC read implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
18 cmd_rtc()
92c1ed6b4b67 pirexplore: RTC read implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
19 {
92c1ed6b4b67 pirexplore: RTC read implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
20 u8 ctrl;
92c1ed6b4b67 pirexplore: RTC read implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
21 struct rtctime time1, time2;
92c1ed6b4b67 pirexplore: RTC read implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
22 int c;
92c1ed6b4b67 pirexplore: RTC read implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
23
92c1ed6b4b67 pirexplore: RTC read implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
24 ctrl = RTC_REGS.rtc_ctrl_reg;
92c1ed6b4b67 pirexplore: RTC read implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
25 printf("RTC_CTRL_REG = %02X ", ctrl);
92c1ed6b4b67 pirexplore: RTC read implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
26 switch (ctrl) {
92c1ed6b4b67 pirexplore: RTC read implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
27 case 0x00:
92c1ed6b4b67 pirexplore: RTC read implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
28 printf("(frozen)\n");
92c1ed6b4b67 pirexplore: RTC read implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
29 break;
92c1ed6b4b67 pirexplore: RTC read implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
30 case 0x01:
92c1ed6b4b67 pirexplore: RTC read implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
31 printf("(running)\n");
92c1ed6b4b67 pirexplore: RTC read implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
32 break;
92c1ed6b4b67 pirexplore: RTC read implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
33 default:
92c1ed6b4b67 pirexplore: RTC read implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
34 printf("(unexpected)\n");
92c1ed6b4b67 pirexplore: RTC read implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
35 return;
92c1ed6b4b67 pirexplore: RTC read implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
36 }
92c1ed6b4b67 pirexplore: RTC read implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
37 printf("Reading RTC time");
92c1ed6b4b67 pirexplore: RTC read implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
38 for (;;) {
92c1ed6b4b67 pirexplore: RTC read implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
39 c = serial_in_poll();
92c1ed6b4b67 pirexplore: RTC read implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
40 if (c >= 0) {
92c1ed6b4b67 pirexplore: RTC read implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
41 printf("<INTERRUPT>\n");
92c1ed6b4b67 pirexplore: RTC read implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
42 return;
92c1ed6b4b67 pirexplore: RTC read implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
43 }
92c1ed6b4b67 pirexplore: RTC read implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
44 read_time(&time1);
92c1ed6b4b67 pirexplore: RTC read implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
45 read_time(&time2);
92c1ed6b4b67 pirexplore: RTC read implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
46 if (!bcmp(&time1.minutes, &time2.minutes, 6))
92c1ed6b4b67 pirexplore: RTC read implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
47 break;
92c1ed6b4b67 pirexplore: RTC read implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
48 }
92c1ed6b4b67 pirexplore: RTC read implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
49 printf("\nDATE %02X-%02X-%02X DOW %02X TIME %02X:%02X:%02X\n",
92c1ed6b4b67 pirexplore: RTC read implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
50 time2.year, time2.month, time2.day_of_month, time2.day_of_week,
92c1ed6b4b67 pirexplore: RTC read implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
51 time2.hours, time2.minutes, time2.seconds);
92c1ed6b4b67 pirexplore: RTC read implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
52 }
73
c54c6ad1c66f pirexplore: added rtccomp command to read RTC compensation registers
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 72
diff changeset
53
c54c6ad1c66f pirexplore: added rtccomp command to read RTC compensation registers
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 72
diff changeset
54 void
c54c6ad1c66f pirexplore: added rtccomp command to read RTC compensation registers
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 72
diff changeset
55 cmd_rtccomp()
c54c6ad1c66f pirexplore: added rtccomp command to read RTC compensation registers
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 72
diff changeset
56 {
c54c6ad1c66f pirexplore: added rtccomp command to read RTC compensation registers
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 72
diff changeset
57 printf("%04X\n", (RTC_REGS.rtc_comp_msb_reg << 8) |
c54c6ad1c66f pirexplore: added rtccomp command to read RTC compensation registers
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 72
diff changeset
58 RTC_REGS.rtc_comp_lsb_reg);
c54c6ad1c66f pirexplore: added rtccomp command to read RTC compensation registers
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 72
diff changeset
59 }