Skip to content

Commit 5b01018

Browse files
committed
Start the clock ticking.
By default, the DS1307 comes with the clock halted, and we never told it to not be halted.
1 parent 4bf443c commit 5b01018

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

src/rtc.rs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,14 +139,24 @@ impl Rtc {
139139
driver.set_datetime(&new_time).map_err(|e| match e {
140140
ds1307::Error::I2C(bus_error) => Error::Bus(bus_error),
141141
ds1307::Error::InvalidInputData => Error::DriverBug,
142-
})
142+
})?;
143+
driver.set_running().map_err(|e| match e {
144+
ds1307::Error::I2C(bus_error) => Error::Bus(bus_error),
145+
ds1307::Error::InvalidInputData => Error::DriverBug,
146+
})?;
147+
Ok(())
143148
}
144149
Self::Mcp7940n => {
145150
let mut driver = mcp794xx::Mcp794xx::new_mcp7940n(bus);
146151
driver.set_datetime(&new_time).map_err(|e| match e {
147152
mcp794xx::Error::Comm(bus_error) => Error::Bus(bus_error),
148153
mcp794xx::Error::InvalidInputData => Error::DriverBug,
149-
})
154+
})?;
155+
driver.enable().map_err(|e| match e {
156+
mcp794xx::Error::Comm(bus_error) => Error::Bus(bus_error),
157+
mcp794xx::Error::InvalidInputData => Error::DriverBug,
158+
})?;
159+
Ok(())
150160
}
151161
Self::None => Err(Error::NoRtcFound),
152162
}

0 commit comments

Comments
 (0)