You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
-[Supporting both 0.2 and 1.0 in the same HAL](#supporting-both-02-and-10-in-the-same-hal)
23
+
-[`embedded-hal-compat`](#embedded-hal-compat)
22
24
23
25
## Overview and reasoning
24
26
@@ -41,7 +43,7 @@ For `embedded-hal` 1.0, we decided to drop the first goal, targeting only the se
41
43
- The second goal delivers much more value. Being able to use any driver together with any HAL crate, out of the box, and across the entire Rust Embedded ecosystem, is just plain awesome.
42
44
43
45
This refocusing on drivers is the root cause of many of the changes between `embedded-hal` 0.2 and 1.0:
44
-
-[Associated type compatibiilty](#removed-traits)
46
+
-[Associated type compatibility](#removed-traits)
45
47
-[Trait fragmentation](#trait-organization)
46
48
-[Bus/device separation](#bus-device-separation)
47
49
-[Fallibility](#fallibility)
@@ -91,7 +93,7 @@ These traits have been removed in the 1.0.0 release, with no replacement for now
91
93
-[`watchdog::Watchdog`][watchdog]
92
94
93
95
Please find a general [roadmap with further guidance here][roadmap-rm-traits] about
94
-
whether and how to get these traits back in a future release
96
+
whether and how to get these traits back in a future release.
95
97
96
98
If you are a generic driver author and need one of them, we would like to hear from you. Please add your use case to the appropriate issue for the trait affected.
97
99
@@ -359,16 +361,76 @@ experiment externally, and merge when some kind of feasibility had been proven.
359
361
360
362
## Companion crates
361
363
362
-
The `embedded-hal` project now spans several crates, where some functionality has been moved out from the main `embedded-hal` crate to separate crates as detailed above. Here is the full listing of crates:
364
+
The `embedded-hal` project now spans several crates, where some functionality has been moved out from the main `embedded-hal` crate to separate crates as detailed above.
365
+
366
+
Different crates are released independently. The main `embedded-hal-*` trait crates have reached 1.0 maturity, others will become 1.0 as time passes.
367
+
368
+
Here is the full listing of crates:
363
369
364
370
| Crate | crates.io | Docs ||
365
371
|-|-|-|-|
366
-
|[embedded-hal](./embedded-hal)|[](https://crates.io/crates/embedded-hal)|[](https://docs.rs/embedded-hal)| Core traits, blocking version |
367
-
|[embedded-hal-async](./embedded-hal-async)|[](https://crates.io/crates/embedded-hal-async)|[](https://docs.rs/embedded-hal-async)| Core traits, async version |
368
-
|[embedded-hal-nb](./embedded-hal-nb)|[](https://crates.io/crates/embedded-hal-nb)|[](https://docs.rs/embedded-hal-nb)| Core traits, polling version using the `nb` crate |
369
-
|[embedded-hal-bus](./embedded-hal-bus)|[](https://crates.io/crates/embedded-hal-bus)|[](https://docs.rs/embedded-hal-bus)| Utilities for sharing SPI and I2C buses |
370
-
|[embedded-can](./embedded-can)|[](https://crates.io/crates/embedded-can)|[](https://docs.rs/embedded-can)| Controller Area Network (CAN) traits |
|[embedded-io-async](./embedded-io-async)|[](https://crates.io/crates/embedded-io-async)|[](https://docs.rs/embedded-io-async)| I/O traits, async version |
373
-
|[embedded-io-adapters](./embedded-io-adapters)|[](https://crates.io/crates/embedded-io-adapters)|[](https://docs.rs/embedded-io-adapters)| Adapters between the [`embedded-io`](https://crates.io/crates/embedded-io) and [`embedded-io-async`](https://crates.io/crates/embedded-io-async) traits and other IO traits (`std`, `tokio`, `futures`...) |
372
+
|[embedded-hal](../embedded-hal)|[](https://crates.io/crates/embedded-hal)|[](https://docs.rs/embedded-hal)| Core traits, blocking version |
373
+
|[embedded-hal-async](../embedded-hal-async)|[](https://crates.io/crates/embedded-hal-async)|[](https://docs.rs/embedded-hal-async)| Core traits, async version |
374
+
|[embedded-hal-nb](../embedded-hal-nb)|[](https://crates.io/crates/embedded-hal-nb)|[](https://docs.rs/embedded-hal-nb)| Core traits, polling version using the `nb` crate |
375
+
|[embedded-hal-bus](../embedded-hal-bus)|[](https://crates.io/crates/embedded-hal-bus)|[](https://docs.rs/embedded-hal-bus)| Utilities for sharing SPI and I2C buses |
376
+
|[embedded-can](../embedded-can)|[](https://crates.io/crates/embedded-can)|[](https://docs.rs/embedded-can)| Controller Area Network (CAN) traits |
|[embedded-io-async](../embedded-io-async)|[](https://crates.io/crates/embedded-io-async)|[](https://docs.rs/embedded-io-async)| I/O traits, async version |
379
+
|[embedded-io-adapters](../embedded-io-adapters)|[](https://crates.io/crates/embedded-io-adapters)|[](https://docs.rs/embedded-io-adapters)| Adapters between the [`embedded-io`](https://crates.io/crates/embedded-io) and [`embedded-io-async`](https://crates.io/crates/embedded-io-async) traits and other IO traits (`std`, `tokio`, `futures`...) |
380
+
381
+
## Supporting both 0.2 and 1.0 in the same HAL
382
+
383
+
It is strongly recommended that HAL implementation crates provide implementations for both the `embedded-hal` v0.2 and v1.0 traits.
384
+
This allows users to use drivers using either version seamlessly.
385
+
386
+
The way you do it is adding a dependency on both versions in `Cargo.toml` like this:
387
+
388
+
```toml
389
+
[dependencies]
390
+
embedded-hal-02 = { package = "embedded-hal", version = "0.2.7", features = ["unproven"] }
391
+
embedded-hal-1 = { package = "embedded-hal", version = "1.0" }
392
+
```
393
+
394
+
This allows you to refer to the v0.2 traits under the `embedded_hal_02` name, and the v1.0 traits under
395
+
`embedded_hal_1`. Implement both versions on the same struct. For example, for an input pin:
0 commit comments