MCPcopy Create free account
hub / github.com/LibertyOS-Development/kernel / rtc

Method rtc

src/cmos.rs:90–122  ·  view source on GitHub ↗

Real-time (RTC)

(&mut self)

Source from the content-addressed store, hash-verified

88
89 // Real-time (RTC)
90 pub fn rtc(&mut self) -> RTC
91 {
92 let mut rtc;
93 loop
94 {
95 self.waitfor_update();
96 rtc = self.nocheck_rtc();
97 self.waitfor_update();
98 if rtc == self.nocheck_rtc()
99 {
100 break;
101 }
102 }
103
104 let b = self.readreg(Reg::B);
105 if b & 0x04 == 0
106 {
107 rtc.day = (rtc.day & 0x0F) + ((rtc.day / 16) * 10);
108 rtc.hour = ((rtc.hour & 0x0F) + (((rtc.hour & 0x70) / 16) * 10)) | (rtc.hour & 0x80);
109 rtc.minute = (rtc.minute & 0x0F) + ((rtc.minute / 16) * 10);
110 rtc.month = (rtc.month & 0x0F) + ((rtc.month / 16) * 10);
111 rtc.second = (rtc.second & 0x0F) + ((rtc.second / 16) * 10);
112 rtc.year = (rtc.year & 0x0F) + ((rtc.year / 16) * 10);
113 }
114
115 if (b & 0x02 == 0) && (rtc.hour & 0x80 == 0)
116 {
117 rtc.hour = ((rtc.hour & 0x7F) + 12) % 24;
118 }
119
120 rtc.year += 2000;
121 rtc
122 }
123
124
125 // Unchecked real-time (RTC)

Callers 1

realtimeFunction · 0.80

Calls 3

waitfor_updateMethod · 0.80
nocheck_rtcMethod · 0.80
readregMethod · 0.80

Tested by

no test coverage detected