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

Implement InputPin trait for PA1<Output<OpenDrain>> #84

Closed
peter-wilkins opened this issue Apr 2, 2020 · 6 comments · Fixed by #114
Closed

Implement InputPin trait for PA1<Output<OpenDrain>> #84

peter-wilkins opened this issue Apr 2, 2020 · 6 comments · Fixed by #114
Labels
enhancement New feature or request

Comments

@peter-wilkins
Copy link

I'm trying to read a dht11 humidity sensor with a stm32f303 discovery board

the example in the dht11 crate is for stmf0xx boards:
https://github.com/michaelbeaumont/dht-sensor/blob/master/examples/stm32f042.rs#L30

Rather than give in and just buy an stm32f0xx board I'd like to have a crack at adding this trait. If anyone knows that it is futile (eg Output<OpenDrain> is not both InputPin and OutputPin for the f3) or not useful in anyway please say so.

Part-converted example: https://gist.github.com/peter-wilkins/b5c914b1f8f5b4098b198133b4280472

I'm just starting out with embedded but will attempt to put together an PR, it may take some time. Any advice appreciated.

@Sh3Rm4n Sh3Rm4n added the enhancement New feature or request label Apr 4, 2020
@Sh3Rm4n
Copy link
Member

Sh3Rm4n commented Apr 4, 2020

The hardware design of the gpio's from the stm32fx-line should all be the same, so nothing speaks against adding the InputPin trait to Output<OpenDrain>. And it is clearly missing right now in this HAL. Seems like that besides stm32f0xx, stm32f1xx and stm32f4xx have these traits as well.

So if you are willing to put together a PR, go for it. I appreciate every contribution. :)

You could take the implementation from the stm32f4xx-hal.

stm32f1xx-hal has a similar solution, but only implements it for OpenDrain. I don't know if we should limit the Trait to Output<OpenDrain>. I tend towards the more generic solution from the stm32f4xx-hal :)

@David-OConnor
Copy link
Contributor

I think I'm running into this as well, in an attempt to get the DS18B20 temp sensor working.

@David-OConnor
Copy link
Contributor

#105

@therealprof
Copy link
Member

You could take the implementation from the stm32f4xx-hal.

The problem with that is that it will raise wrong expectations and potentially cause hardware failure through incorrect use. You cannot safely do this with a pin in push-pull mode, guess we should have been more careful in the review of that change. 😅

@David-OConnor
Copy link
Contributor

David-OConnor commented Jun 19, 2020

So... How can we get the one wire protocol working? Is this an issue of needing to work off of a fork? (Note that even with my PR fork above, I'm unable to get it working, perhaps due to the OneWire lib rather than this, or perhaps something else is required)

It's notable, in that in Python/Raspberry Pi land, getting a DS1820B sensor working is hardware 101, but here is seems difficult compared to SPI, I2C, and GPIO.

@David-OConnor
Copy link
Contributor

David-OConnor commented Jun 22, 2020

The onewire crate released an unrelated patch on Github, which now works for me... if you use my Open PR.

Re reluctance to merge this: What alternate do you suggest to get protocols like this working? This one in particular is popular, due to use in the DS18B20 temperature sensor.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
4 participants