-
Notifications
You must be signed in to change notification settings - Fork 7
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
Not working with stm32f3xx-hal #1
Comments
I think the issue here is that the I will look into the possibility of supporting both versions and I'll get back to you. |
Actually, scratch that. The problem is with the HAL implementation of F3 pins, that unfortunately does not implement the You can wrap the pin into a newtype and implement use stm32f3xx_hal::{
gpio::{gpiob::PB9, GpioExt, OpenDrain, Output},
hal::digital::v2::{InputPin, OutputPin},
rcc::RccExt,
stm32,
};
struct OpenDrainOutput(PB9<Output<OpenDrain>>);
impl InputPin for OpenDrainOutput {
type Error = ();
fn is_high(&self) -> Result<bool, Self::Error> {
self.is_low().map(|v| !v)
}
fn is_low(&self) -> Result<bool, Self::Error> {
Ok(unsafe { (*stm32::GPIOB::ptr()).idr.read().bits() & (1 << 9) == 0 })
}
}
impl OutputPin for OpenDrainOutput {
type Error = ();
fn set_low(&mut self) -> Result<(), Self::Error> {
self.0.set_low()
}
fn set_high(&mut self) -> Result<(), Self::Error> {
self.0.set_high()
}
} You can then wrap the pin returned by let mut dht11 = dht11::Dht11::new(OpenDrainOutput(pin)); The above example builds just fine, but I don't have an STM32F3 on my hands to test it. If the peripheral is the same as for the F4 family, this code should work. Give it a try and let me know, I could also include this example for future reference. |
Sadly this did not work out of the box. But after some more debugging I found out that my dht11 may be the problem. I will have to order another one and try again. Apart from that, I can confirm that with your workaround my code compiles for the stm32f3xx-hal. Thanks for your work btw. |
No problem, let me know if you need anything else. I'll close the issue for the time being, feel free to open a new one if the problem is still there with the new sensor. |
Example:
Error message:
The text was updated successfully, but these errors were encountered: