MCPcopy Create free account
hub / github.com/F-Stack/f-stack / mv_rtc_gettime

Function mv_rtc_gettime

freebsd/arm/mv/rtc.c:130–154  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

128}
129
130static int
131mv_rtc_gettime(device_t dev, struct timespec *ts)
132{
133 struct clocktime ct;
134 struct mv_rtc_softc *sc;
135 uint32_t val;
136
137 sc = device_get_softc(dev);
138
139 val = mv_rtc_reg_read(sc, MV_RTC_TIME_REG);
140
141 ct.nsec = 0;
142 ct.sec = FROMBCD(val & 0x7f);
143 ct.min = FROMBCD((val & 0x7f00) >> 8);
144 ct.hour = FROMBCD((val & 0x3f0000) >> 16);
145 ct.dow = FROMBCD((val & 0x7000000) >> 24) - 1;
146
147 val = mv_rtc_reg_read(sc, MV_RTC_DATE_REG);
148
149 ct.day = FROMBCD(val & 0x7f);
150 ct.mon = FROMBCD((val & 0x1f00) >> 8);
151 ct.year = YEAR_BASE + FROMBCD((val & 0xff0000) >> 16);
152
153 return (clock_ct_to_ts(&ct, ts));
154}
155
156static int
157mv_rtc_settime(device_t dev, struct timespec *ts)

Callers

nothing calls this directly

Calls 3

device_get_softcFunction · 0.85
clock_ct_to_tsFunction · 0.85
mv_rtc_reg_readFunction · 0.70

Tested by

no test coverage detected