From aff8b83ac3c7bf9d3fc45716359dfe4d11c98dbf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christoph=20Gro=C3=9F?= Date: Tue, 22 May 2018 12:02:03 +0200 Subject: [PATCH] updated version to v0.2 of embedded_hal, but broke f3 example --- Cargo.toml | 2 +- examples/embedded_linux/Cargo.toml | 7 ++++--- examples/embedded_linux/src/main.rs | 13 ++++++++----- examples/f3_stm32f30x/Cargo.toml | 9 +++++---- examples/f3_stm32f30x/src/main.rs | 6 +++--- 5 files changed, 21 insertions(+), 16 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index d22cdcb..03689f8 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -8,4 +8,4 @@ authors = ["Christoph Groß "] [dependencies.embedded-hal] features = ["unproven"] -version = "0.1.2" +version = "0.2.1" diff --git a/examples/embedded_linux/Cargo.toml b/examples/embedded_linux/Cargo.toml index 5566b89..cf4c28d 100644 --- a/examples/embedded_linux/Cargo.toml +++ b/examples/embedded_linux/Cargo.toml @@ -5,8 +5,9 @@ authors = ["Christoph Groß "] [dependencies] -eink_waveshare_rs = { git = "https://github.com/Caemor/eink-waveshare-rs"} +#eink_waveshare_rs = { git = "https://github.com/Caemor/eink-waveshare-rs"} +eink_waveshare_rs = { path = "../../"} -linux-embedded-hal = "0.1.1" +linux-embedded-hal = "0.2.0" -embedded-hal = { version = "0.1.2", features = ["unproven"] } +embedded-hal = { version = "0.2.1", features = ["unproven"] } diff --git a/examples/embedded_linux/src/main.rs b/examples/embedded_linux/src/main.rs index 4ef2114..c05a0a7 100644 --- a/examples/embedded_linux/src/main.rs +++ b/examples/embedded_linux/src/main.rs @@ -17,28 +17,31 @@ use lin_hal::Delay; // DigitalIn Hack as long as it's not in the linux_embedded_hal // from https://github.com/rudihorn/max31865/blob/extra_examples/examples/rpi.rs +// (slightly changed now as OutputPin doesn't provide is_high and is_low anymore) extern crate embedded_hal; -use embedded_hal::digital::{InputPin, OutputPin}; +use embedded_hal::digital::{InputPin}; struct HackInputPin<'a> { - pin: &'a OutputPin + pin: &'a Pin } impl<'a> HackInputPin<'a> { - fn new(p : &'a OutputPin) -> HackInputPin { + fn new(p : &'a Pin) -> HackInputPin { HackInputPin { pin: p } } } +//TODO: make it safer?? or handle the errors better? +// now it defaults to is_low if an error appears impl<'a> InputPin for HackInputPin<'a> { fn is_low(&self) -> bool { - self.pin.is_low() + self.pin.get_value().unwrap_or(0) == 0 } fn is_high(&self) -> bool { - self.pin.is_high() + self.pin.get_value().unwrap_or(0) == 1 } } diff --git a/examples/f3_stm32f30x/Cargo.toml b/examples/f3_stm32f30x/Cargo.toml index e371a8b..f8696af 100644 --- a/examples/f3_stm32f30x/Cargo.toml +++ b/examples/f3_stm32f30x/Cargo.toml @@ -4,13 +4,14 @@ version = "0.1.0" authors = ["Christoph Groß "] [dependencies] -f3 = "0.5.3" -cortex-m = {version = "0.4.3"} +f3 = "0.6.0" +cortex-m = {version = "0.5.2"} -eink_waveshare_rs = { git = "https://github.com/Caemor/eink-waveshare-rs"} +#eink_waveshare_rs = { git = "https://github.com/Caemor/eink-waveshare-rs"} +eink_waveshare_rs = { path = "../../"} # only temporary until Digital::InputPin has arrived in f3 -embedded-hal = { version = "0.1.2", features = ["unproven"] } +embedded-hal = { version = "0.2.1", features = ["unproven"] } # for #no_std panic-abort = "0.1.1" diff --git a/examples/f3_stm32f30x/src/main.rs b/examples/f3_stm32f30x/src/main.rs index 464cf2f..4a8cf87 100644 --- a/examples/f3_stm32f30x/src/main.rs +++ b/examples/f3_stm32f30x/src/main.rs @@ -26,11 +26,11 @@ use hal::digital::{InputPin, OutputPin}; //from https://github.com/rudihorn/max31865/tree/extra_examples/examples struct HackInputPin<'a> { - pin: &'a OutputPin + pin: &'a Pin } impl<'a> HackInputPin<'a> { - fn new(p : &'a OutputPin) -> HackInputPin { + fn new(p : &'a Pin) -> HackInputPin { HackInputPin { pin: p } @@ -75,7 +75,7 @@ fn main() { //TODO: Fix when f3::hal includes Digital::InputPin //using the hack from rudihorn that Digital::OutputPin basically //contains the needed functions for Digital::InputPin - let busy = gpioe.pe4.into_push_pull_output(&mut gpioe.moder, &mut gpioe.otyper); + let busy = gpioe.pe4.into_floating_input(&mut gpioe.moder, &mut gpioe.pupdr); let busy_in = HackInputPin::new(&busy); let dc = gpioe.pe5.into_push_pull_output(&mut gpioe.moder, &mut gpioe.otyper);