MCPcopy Create free account
hub / github.com/CE-Programming/CEmu / rtc_event

Function rtc_event

core/realclock.c:12–61  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

10rtc_state_t rtc;
11
12static void rtc_event(enum sched_item_id id) {
13 /* Update exactly once a second */
14 sched_repeat(id, 32768);
15
16 if (rtc.control & 64) { /* (Bit 6) -- Load time */
17 rtc.readSec = rtc.writeSec;
18 rtc.readMin = rtc.writeMin;
19 rtc.readHour = rtc.writeHour;
20 rtc.readDay = rtc.writeDay;
21 rtc.control &= ~64;
22 rtc.interrupt |= 32; /* Load operation complete */
23 intrpt_set(INT_RTC, true);
24 }
25
26 rtc.readSec++;
27 if (rtc.control & 2) {
28 rtc.interrupt |= 1;
29 intrpt_set(INT_RTC, true);
30 }
31 if (rtc.readSec > 59) {
32 rtc.readSec = 0;
33 if (rtc.control & 4) {
34 rtc.interrupt |= 2;
35 intrpt_set(INT_RTC, true);
36 }
37 rtc.readMin++;
38 if (rtc.readMin > 59) {
39 rtc.readMin = 0;
40 if (rtc.control & 8) {
41 rtc.interrupt |= 4;
42 intrpt_set(INT_RTC, true);
43 }
44 rtc.readHour++;
45 if (rtc.readHour > 23) {
46 rtc.readHour = 0;
47 if (rtc.control & 16) {
48 rtc.interrupt |= 8;
49 intrpt_set(INT_RTC, true);
50 }
51 rtc.readDay++;
52 }
53 }
54 }
55
56 if ((rtc.control & 32) && (rtc.readSec == rtc.alarmSec) &&
57 (rtc.readMin == rtc.alarmMin) && (rtc.readHour == rtc.alarmHour)) {
58 rtc.interrupt |= 16;
59 intrpt_set(INT_RTC, true);
60 }
61}
62
63static void hold_read(void) {
64 rtc.holdSec = rtc.readSec;

Callers

nothing calls this directly

Calls 2

sched_repeatFunction · 0.85
intrpt_setFunction · 0.85

Tested by

no test coverage detected