Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove Can::configure #36

Merged
merged 1 commit into from
Jun 19, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 0 additions & 27 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -321,33 +321,6 @@ where
self.instance
}

/// Configure bit timings and silent/loop-back mode.
///
/// Acutal configuration happens on the `CanConfig` that is passed to the
/// closure. It must be done this way because those configuration bits can
/// only be set if the CAN controller is in a special init mode.
/// Puts the peripheral in sleep mode afterwards. `Can::enable()` must be
/// called to exit sleep mode and start reception and transmission.
pub fn configure<F>(&mut self, f: F)
where
F: FnOnce(&mut CanConfig<I>),
{
let can = self.registers();

// Enter init mode.
can.mcr
.modify(|_, w| w.sleep().clear_bit().inrq().set_bit());
loop {
let msr = can.msr.read();
if msr.slak().bit_is_clear() && msr.inak().bit_is_set() {
break;
}
}

let mut config = CanConfig { _can: PhantomData };
f(&mut config);
}

/// Configure bit timings and silent/loop-back mode.
pub fn modify_config(&mut self) -> CanConfig<'_, I> {
let can = self.registers();
Expand Down