A forward compatibility layer to smooth the transition between different versions of embedded-hal (specifically 0.2.x
and 1.0.0-alpha.X
series).
This resolves the problem where a HAL implementation (ie. the implementation for your processor) is still published at 0.2.x
, and a driver expects 1.0.0-alpha.x
. In the opposite situation, please fork and update the driver.
Work in progress, blocking
objects implemented, missing nb
things as well as any reasonable documentation.
embedded-hal-compat
to your dependenciesuse embedded_hal_compat::IntoCompat;
.compat()
on any embedded-hal
outstanding type errorsType errors. Lots of type errors.
(and cargo tree -i embedded-hal
returns two versions)
Yes. You're gonna end up with lots of cursed errors but at least you can compile things?
Because you'll have symbols with the same name you'll end up with errors like:
``
error[E0599]: no method named
delay_msfound for mutable reference
&mut Compatin the current scope
--> src/main.rs:351:27
|
351 | tlv.inner_delay().delay_ms(10u32);
| ^^^^^^^^ method not found in
&mut Compat
warning: unused import: embedded_hal::blocking::delay::DelayMs
--> src/main.rs:22:5
|
22 | use embedded_hal::blocking::delay::DelayMs;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
```
Suggesting you're missing an import that's obviously there, because you have the 0.2.x
imports not the 1.0.0-alpha.x
imports, and the method is called try_delay_ms
in the updated HAL (a fairly common renaming).
You can fix this by importing the correct trait with something like: use embedded_hal_compat::eh1_0::blocking::delay::{DelayMs as _};
(this must be renamed with as
/ you can't use the prelude because the names overlap), and by swapping the method to use the correct try_
name.