Skip to content

Commit

Permalink
Merge pull request #174 from braun-embedded/lpc845-pac
Browse files Browse the repository at this point in the history
Upgrade to latest `lpc845-pac` release
  • Loading branch information
hannobraun authored Nov 6, 2019
2 parents 9a30146 + 65dbdd4 commit 969b67d
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 10 deletions.
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();
}
}

0 comments on commit 969b67d

Please sign in to comment.