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
Copy file name to clipboardExpand all lines: README.md
+4-15
Original file line number
Diff line number
Diff line change
@@ -4,6 +4,9 @@
4
4
5
5
This project is developed and maintained by the [HAL team](https://github.com/rust-embedded/wg#the-hal-team).
6
6
7
+
> [!IMPORTANT]
8
+
> 📣 `embedded-hal` v1.0 is now released! Check out the [announcement blog post](https://blog.rust-embedded.org/embedded-hal-v1/), the [API documentation](https://docs.rs/embedded-hal) and the [migration guide](docs/migrating-from-0.2-to-1.0.md).
9
+
7
10
## Scope
8
11
9
12
`embedded-hal` serves as a foundation for building an ecosystem of platform-agnostic drivers.
@@ -38,24 +41,10 @@ The main `embedded-hal` project is not tied to a specific execution model like
38
41
|[embedded-io-async](./embedded-io-async)|[](https://crates.io/crates/embedded-io-async)|[](https://docs.rs/embedded-io-async)| I/O traits, async version |
39
42
|[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`...) |
40
43
41
-
## Releases
42
-
43
-
At the moment we are working towards a `1.0.0` release (see [#177]). During this process we will
44
-
release alpha versions like `1.0.0-alpha.1` and `1.0.0-alpha.2`.
45
-
Alpha releases are **not guaranteed** to be compatible with each other.
46
-
They are provided as early previews for community testing and preparation for the final release.
47
-
If you use an alpha release, we recommend you choose an exact version specification in your
-[Supporting both 0.2 and 1.0 in the same HAL](#supporting-both-02-and-10-in-the-same-hal)
24
+
-[`embedded-hal-compat`](#embedded-hal-compat)
22
25
23
26
## Overview and reasoning
24
27
@@ -41,7 +44,7 @@ For `embedded-hal` 1.0, we decided to drop the first goal, targeting only the se
41
44
- 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
45
43
46
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)
47
+
-[Associated type compatibility](#removed-traits)
45
48
-[Trait fragmentation](#trait-organization)
46
49
-[Bus/device separation](#bus-device-separation)
47
50
-[Fallibility](#fallibility)
@@ -91,7 +94,7 @@ These traits have been removed in the 1.0.0 release, with no replacement for now
91
94
-[`watchdog::Watchdog`][watchdog]
92
95
93
96
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
97
+
whether and how to get these traits back in a future release.
95
98
96
99
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.
inner:&'aRefCell<KeypadInner<O, I, NCOLS, NROWS>>,
394
+
row:usize,
395
+
col:usize,
396
+
}
397
+
398
+
impl<'a, O:OutputPin, I:InputPin, constNCOLS:usize, constNROWS:usize> ErrorTypeforKeypadInput<'a, O, I, NCOLS, NROWS> {
399
+
typeError=core::convert::Infallible;
400
+
}
401
+
402
+
impl<'a, O:OutputPin, I:InputPin, constNCOLS:usize, constNROWS:usize> InputPinforKeypadInput<'a, O, I, NCOLS, NROWS> {
403
+
fnis_high(&mutself) ->Result<bool, Self::Error> {
404
+
Ok(!self.is_low()?)
405
+
}
406
+
407
+
fnis_low(&mutself) ->Result<bool, Self::Error> {
408
+
letinner=&mut*self.inner.borrow_mut();
409
+
letrow=&mutinner.rows[self.row];
410
+
letcol=&mutinner.cols[self.col];
411
+
412
+
// using unwrap for demo purposes, you should propagate errors up instead.
413
+
col.set_low().unwrap();
414
+
letout=row.is_low().unwrap();
415
+
col.set_high().unwrap();
416
+
417
+
Ok(out)
418
+
}
419
+
}
420
+
```
421
+
422
+
331
423
## Prelude
332
424
333
425
The prelude has been removed because it could make method calls ambiguous, since the method names are now
@@ -359,16 +451,76 @@ experiment externally, and merge when some kind of feasibility had been proven.
359
451
360
452
## Companion crates
361
453
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:
454
+
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.
455
+
456
+
Different crates are released independently. The main `embedded-hal-*` trait crates have reached 1.0 maturity, others will become 1.0 as time passes.
457
+
458
+
Here is the full listing of crates:
363
459
364
460
| Crate | crates.io | Docs ||
365
461
|-|-|-|-|
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`...) |
462
+
|[embedded-hal](../embedded-hal)|[](https://crates.io/crates/embedded-hal)|[](https://docs.rs/embedded-hal)| Core traits, blocking version |
463
+
|[embedded-hal-async](../embedded-hal-async)|[](https://crates.io/crates/embedded-hal-async)|[](https://docs.rs/embedded-hal-async)| Core traits, async version |
464
+
|[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 |
465
+
|[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 |
466
+
|[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 |
469
+
|[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`...) |
470
+
471
+
## Supporting both 0.2 and 1.0 in the same HAL
472
+
473
+
It is strongly recommended that HAL implementation crates provide implementations for both the `embedded-hal` v0.2 and v1.0 traits.
474
+
This allows users to use drivers using either version seamlessly.
475
+
476
+
The way you do it is adding a dependency on both versions in `Cargo.toml` like this:
477
+
478
+
```toml
479
+
[dependencies]
480
+
embedded-hal-02 = { package = "embedded-hal", version = "0.2.7", features = ["unproven"] }
481
+
embedded-hal-1 = { package = "embedded-hal", version = "1.0" }
482
+
```
483
+
484
+
This allows you to refer to the v0.2 traits under the `embedded_hal_02` name, and the v1.0 traits under
485
+
`embedded_hal_1`. Implement both versions on the same struct. For example, for an input pin:
/// ... and implement the v1.0 traits on the *same* struct.
505
+
implembedded_hal_1::digital::ErrorTypeforInput {
506
+
typeError=Infallible;
507
+
}
508
+
509
+
implembedded_hal_1::digital::InputPinforInput {
510
+
fnis_high(&mutself) ->Result<bool, Self::Error> {
511
+
...
512
+
}
513
+
514
+
fnis_low(&mutself) ->Result<bool, Self::Error> {
515
+
...
516
+
}
517
+
}
518
+
```
519
+
520
+
## `embedded-hal-compat`
521
+
522
+
For HAL implementation crates that haven't been updated yet, [embedded-hal-compat](https://github.com/ryankurte/embedded-hal-compat)
523
+
provides shims to support interoperability between `embedded-hal` v0.2 and v1.0.
374
524
525
+
This allows using a driver requiring v1.0 with a HAL crate implementing only v0.2 or vice-versa, (generally) without alteration.
526
+
See the [docs](https://docs.rs/embedded-hal-compat/) for examples.
0 commit comments