|
7 | 7 | - [Trait organization](#trait-organization)
|
8 | 8 | - [Fallibility](#fallibility)
|
9 | 9 | - [Method renaming](#method-renaming)
|
| 10 | + - [SPI transfer return type](#spi-transfer-return-type) |
| 11 | + - [Error type bounds](#error-type-bounds) |
10 | 12 | - [`nb` dependency](#nb-dependency)
|
11 | 13 | - [Prelude](#prelude)
|
12 | 14 | - [`rng` module](#rng-module)
|
| 15 | + - [Removed blanket implementations](#removed-blanket-implementations) |
13 | 16 | - [Features](#features)
|
14 | 17 | - [Use-case-specific help](#use-case-specific-help)
|
15 | 18 | - [For driver authors](#for-driver-authors)
|
|
19 | 22 |
|
20 | 23 | ## Trait organization
|
21 | 24 |
|
22 |
| -All traits have been organized in modules depending on their execution model. That includes `blocking` and `nb` for |
| 25 | +All traits have been organized in modules for each feature, each of these containing sub-modules depending on their execution model. That includes `blocking` and `nb` for |
23 | 26 | non-blocking. In the future when we add asynchronous traits, we envision adding a `futures` (or similarly-named) module.
|
24 | 27 |
|
| 28 | +Execution-model-independent definitions have been moved into the feature module. For example, SPI `Phase` is now defined in `embedded_hal::spi::Phase`. For convenience, these definitions are reexported in both of its blocking and non-blocking submodules. |
| 29 | + |
25 | 30 | ## Fallibility
|
26 | 31 |
|
27 | 32 | All trait methods are now fallible so that they can be used in any possible situation.
|
@@ -76,6 +81,38 @@ into the relevant scope. This is the reason why we have removed the prelude.
|
76 | 81 |
|
77 | 82 | For more on this, see [Prelude](#prelude).
|
78 | 83 |
|
| 84 | +## SPI transfer return type |
| 85 | + |
| 86 | +The `transfer()` method in the trait `spi::blocking::Transfer` previously returned |
| 87 | +a slice of the output data. |
| 88 | +This slice is the same as the output buffer which is passed to the method, though, thus redundant and potentially confusing. |
| 89 | +The `transfer()` method now returns `Result<(), Self::Error>`. |
| 90 | +If you were using this return value, adapting the code should be straight forward by simply using the reception buffer which is passed. |
| 91 | +See an example: |
| 92 | +```rust |
| 93 | +let tx_data = [1, 2, 3, 4]; |
| 94 | +let mut rx_data = [0; 4]; |
| 95 | +let data = spi.transfer(&tx_data, &mut rx_data)?; |
| 96 | +println!("{:?}", data); |
| 97 | +// There is no need to do `let data = `, since we already have the data in `rx_data`. |
| 98 | +// Do this instead: |
| 99 | +spi.transfer(&tx_data, &mut rx_data)?; |
| 100 | +println!("{:?}", rx_data); |
| 101 | +``` |
| 102 | + |
| 103 | +## Error type bounds |
| 104 | + |
| 105 | +All associated error types are now required to implement `core::fmt::Debug`. |
| 106 | +Usually it is enough to add a `#[derive(Debug)]` clause to your error types. For example: |
| 107 | + |
| 108 | +```diff |
| 109 | ++ #[derive(Debug)] |
| 110 | +pub enum MyError { |
| 111 | + InvalidInputData, |
| 112 | + // ... |
| 113 | +} |
| 114 | +``` |
| 115 | + |
79 | 116 | ## `nb` dependency
|
80 | 117 |
|
81 | 118 | The `Result` type and `block!` macro from the [`nb`] crate are now reexported in `embeddeh_hal::nb`.
|
@@ -116,6 +153,13 @@ The `rng` module and its traits have been removed in favor of the [`rand_core`]
|
116 | 153 |
|
117 | 154 | [`rand_core`]: https://crates.io/crates/rand_core
|
118 | 155 |
|
| 156 | +## Removed blanket implementations |
| 157 | + |
| 158 | +There were several blanket implementations of blocking traits using the non-blocking |
| 159 | +traits as a base. |
| 160 | +Due to their relative simplicity and some technical concerns, these have been removed. |
| 161 | +Implementing them yourself is now necessary. This should be straight-forward. |
| 162 | + |
119 | 163 | ## Features
|
120 | 164 |
|
121 | 165 | The `unproven` feature has been removed and the traits have been marked as proven.
|
|
0 commit comments