Closed falloutkid closed 1 year ago
Sure, for the second issue, the pin you pass must implement both InputPin
and OutputPin
from embedded-hal
(i.e. you don't need to convert anything, InputOutputPin
is automatically implemented given the first two impls).
For example with stm32l0xx-hal, PA1<Output<_>>
implements OutputPin
but also InputPin
, same with stm32-l4xx-hal. Unfortunately, for stm32l4xx-hal
this is missing. It's almost certainly possible with l4xx
chips because you can read the state of the pin just like with the other chips, but should be added upstream. Of course, until then you could manually create such a wrapper type.
Here's the PR that added support to stm32f4xx-hal, for example.
I'm not sure where the first error is coming from, can you post your Cargo.toml
? The only other requirement is that the associated Error
type for InputPin
and OutputPin
is the same, but that seems to be the case for stm32l4xx-hal
anyway. Nothing in dht-sensor
constrains the error type to be ()
... :thinking:
The second error is the biggest issue I think.
@michaelbeaumont Thank you for quick reply!
for stm32l4xx-hal this is missing.
Oh... I'll try a wrapper type. When I check this advice, I'll report.
can you post your Cargo.toml?
My Cargo.toml is here
[dependencies]
cortex-m = "0.6.0"
cortex-m-rt = "0.6.10"
cortex-m-semihosting = "0.3.3"
panic-halt = "0.2.0"
nb = "1.0.0"
heapless = "0.6.1"
dht-sensor = "0.2.1"
# Uncomment for the panic example.
# panic-itm = "0.4.1"
# Uncomment for the allocator example.
# alloc-cortex-m = "0.4.0"
# Uncomment for the device example.
# Update `memory.x`, set target to `thumbv7em-none-eabihf` in `.cargo/config`,
# and then use `cargo build --examples device` to build it.
[dependencies.stm32l4]
version = "0.13.0"
features = ["stm32l4x6", "rt"]
[dependencies.stm32l4xx-hal]
version = "0.6.0"
features = ["stm32l4x6", "rt"]
[[bin]]
name = "nucleo_l476rg_sample"
test = false
bench = false
[profile.release]
codegen-units = 1 # better optimizations
debug = true # symbols are nice and they don't increase the size on Flash
lto = true # better optimizations
I could build this code and check behavior.
But I could not get a value. It happened Error Timeout
I'll change data pin.
Thanks!!
Closing this since the correct traits have been available in stm32-l4xx-hal
since v0.7.0
. Definitely open an issue if you want to look at the Timeout
error further!
I implement following code with reference to the sample code for STM32L 476RG.
But there are some error.
I think it could not convert to InputOutputPin from Output. Could you give some advice.