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

Function as3722_rtc_settime

freebsd/arm/nvidia/as3722_rtc.c:70–97  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

68}
69
70int
71as3722_rtc_settime(device_t dev, struct timespec *ts)
72{
73 struct as3722_softc *sc;
74 struct clocktime ct;
75 uint8_t buf[6];
76 int rv;
77
78 sc = device_get_softc(dev);
79 clock_ts_to_ct(ts, &ct);
80
81 if (ct.year < AS3722_RTC_START_YEAR)
82 return (EINVAL);
83
84 buf[0] = bin2bcd(ct.sec);
85 buf[1] = bin2bcd(ct.min);
86 buf[2] = bin2bcd(ct.hour);
87 buf[3] = bin2bcd(ct.day);
88 buf[4] = bin2bcd(ct.mon);
89 buf[5] = bin2bcd(ct.year - AS3722_RTC_START_YEAR);
90
91 rv = as3722_write_buf(sc, AS3722_RTC_SECOND, buf, 6);
92 if (rv != 0) {
93 device_printf(sc->dev, "Failed to write RTC data\n");
94 return (rv);
95 }
96 return (0);
97}
98
99int
100as3722_rtc_attach(struct as3722_softc *sc, phandle_t node)

Callers

nothing calls this directly

Calls 5

device_get_softcFunction · 0.85
clock_ts_to_ctFunction · 0.85
as3722_write_bufFunction · 0.85
device_printfFunction · 0.85
bin2bcdFunction · 0.50

Tested by

no test coverage detected