Changeset View
Changeset View
Standalone View
Standalone View
sys/dev/iicbus/ds3231.c
Show First 20 Lines • Show All 546 Lines • ▼ Show 20 Lines | ds3231_settime(device_t dev, struct timespec *ts) | ||||
sc = device_get_softc(dev); | sc = device_get_softc(dev); | ||||
/* | /* | ||||
* We request a timespec with no resolution-adjustment. That also | * We request a timespec with no resolution-adjustment. That also | ||||
* disables utc adjustment, so apply that ourselves. | * disables utc adjustment, so apply that ourselves. | ||||
*/ | */ | ||||
ts->tv_sec -= utc_offset(); | ts->tv_sec -= utc_offset(); | ||||
clock_ts_to_bcd(ts, &bct, sc->sc_use_ampm); | error = clock_ts_to_bcd(ts, &bct, sc->sc_use_ampm); | ||||
if (error) | |||||
return (error); | |||||
clock_dbgprint_bcd(sc->sc_dev, CLOCK_DBG_WRITE, &bct); | clock_dbgprint_bcd(sc->sc_dev, CLOCK_DBG_WRITE, &bct); | ||||
/* If the chip is in AM/PM mode, adjust hour and set flags as needed. */ | /* If the chip is in AM/PM mode, adjust hour and set flags as needed. */ | ||||
if (sc->sc_use_ampm) { | if (sc->sc_use_ampm) { | ||||
pmflags = DS3231_HOUR_USE_AMPM; | pmflags = DS3231_HOUR_USE_AMPM; | ||||
if (bct.ispm) | if (bct.ispm) | ||||
pmflags |= DS3231_HOUR_IS_PM; | pmflags |= DS3231_HOUR_IS_PM; | ||||
} else | } else | ||||
▲ Show 20 Lines • Show All 59 Lines • Show Last 20 Lines |