From d6dc25ef93be24d1c4f0bcd430eda95352fb7086 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Wed, 6 Nov 2019 08:32:45 +0100 Subject: [PATCH 1/2] Simplify trait --- src/wkt.rs | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/wkt.rs b/src/wkt.rs index 82c99eb72..952d28ee3 100644 --- a/src/wkt.rs +++ b/src/wkt.rs @@ -128,9 +128,10 @@ impl WKT { /// /// [`wkt::Clock`]: trait.Clock.html pub fn select_clock(&mut self) where C: Clock { - self.wkt.ctrl.modify(|_, w| - C::select(w) - ); + self.wkt.ctrl.modify(|_, w| { + C::select(w); + w + }); } } @@ -187,20 +188,20 @@ 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 Clock for IoscDerivedClock { - fn select<'w>(w: &'w mut ctrl::W) -> &'w mut ctrl::W { + fn select(w: &mut ctrl::W) { // TODO svd bug, wrong value name for lpc845, add switch - w.sel_extclk().internal().clksel().divided_irc_clock() + w.sel_extclk().internal().clksel().divided_irc_clock(); } } impl Clock for LowPowerClock { - 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(); } } From 65dbdd4eefdf571d79c615fd2dd1870e3f424516 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Wed, 6 Nov 2019 08:34:56 +0100 Subject: [PATCH 2/2] Upgrade `lpc845-pac` --- Cargo.toml | 2 +- src/wkt.rs | 19 +++++++++++++++++-- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index e9194e427..35dd52e8a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -38,7 +38,7 @@ version = "0.7" [dependencies.lpc845-pac] optional = true -version = "0.2" +version = "0.3.0" [dev-dependencies] diff --git a/src/wkt.rs b/src/wkt.rs index 952d28ee3..abd550d69 100644 --- a/src/wkt.rs +++ b/src/wkt.rs @@ -193,8 +193,8 @@ pub trait Clock { impl Clock for IoscDerivedClock { fn select(w: &mut ctrl::W) { - // TODO svd bug, wrong value name for lpc845, add switch - w.sel_extclk().internal().clksel().divided_irc_clock(); + w.sel_extclk().internal(); + target::select_internal_oscillator(w); } } @@ -205,3 +205,18 @@ impl Clock for LowPowerClock { .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(); + } +}