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

Upgrade to latest lpc845-pac release #174

Merged
merged 2 commits into from
Nov 6, 2019
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ version = "0.7"

[dependencies.lpc845-pac]
optional = true
version = "0.2"
version = "0.3.0"


[dev-dependencies]
Expand Down
34 changes: 25 additions & 9 deletions src/wkt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,9 +128,10 @@ impl WKT<init_state::Enabled> {
///
/// [`wkt::Clock`]: trait.Clock.html
pub fn select_clock<C>(&mut self) where C: Clock {
self.wkt.ctrl.modify(|_, w|
C::select(w)
);
self.wkt.ctrl.modify(|_, w| {
C::select(w);
w
});
}
}

Expand Down Expand Up @@ -187,20 +188,35 @@ pub trait Clock {
/// This is an internal method, to be called by the WKT API. Users generally
/// shouldn't need to call this. This method is exempt from any guarantees
/// of API stability.
fn select<'w>(w: &'w mut ctrl::W) -> &'w mut ctrl::W;
fn select(w: &mut ctrl::W);
}

impl<State> Clock for IoscDerivedClock<State> {
fn select<'w>(w: &'w mut ctrl::W) -> &'w mut ctrl::W {
// TODO svd bug, wrong value name for lpc845, add switch
w.sel_extclk().internal().clksel().divided_irc_clock()
fn select(w: &mut ctrl::W) {
w.sel_extclk().internal();
target::select_internal_oscillator(w);
}
}

impl<State> Clock for LowPowerClock<State> {
fn select<'w>(w: &'w mut ctrl::W) -> &'w mut ctrl::W {
fn select(w: &mut ctrl::W) {
w
.sel_extclk().internal()
.clksel().low_power_clock()
.clksel().low_power_clock();
}
}


#[cfg(feature = "82x")]
mod target {
pub fn select_internal_oscillator(w: &mut crate::pac::wkt::ctrl::W) {
w.clksel().divided_irc_clock();
}
}

#[cfg(feature = "845")]
mod target {
pub fn select_internal_oscillator(w: &mut crate::pac::wkt::ctrl::W) {
w.clksel().divided_fro_clock();
}
}