-
I am a newbie in the Rust Embedded world. As a starter, I am using Microbit:V2 while following the book. Because Rust Embedded-Hal 1.0.0 is out, I have decided to use it. The first hitch was a failure because some modules were rearranged etc. (my guess). I have made some progress and then, am stuck! The [dependencies.microbit-v2]
version = "0.12.0"
optional = true
[dependencies.microbit]
version = "0.12.0"
optional = true
[dependencies]
cortex-m = "0.7.3"
cortex-m-rt = "0.7.0"
rtt-target = { version = "0.3.1", features = ["cortex-m"] }
panic-rtt-target = { version = "0.1.2", features = ["cortex-m"] }
nb = "1.0.0"
heapless = "0.7.10"
embedded-hal = "1.0.0"
embedded-hal-nb = "1.0.0"
[features]
v2 = ["microbit-v2"]
v1 = ["microbit"] After a bit of deeper exploration and modifying the source code, I have made some progress but finally I am stuck here: error: could not compile `uart` (bin "uart") due to 5 previous errors
error[E0437]: type `Error` is not a member of trait `serial::Write`
--> src/07-uart/src/serial_setup.rs:27:5
|
27 | type Error = MicroError;
| ^^^^^^^^^^^^^^^^^^^^^^^^ not a member of trait `serial::Write`
error[E0437]: type `Error` is not a member of trait `serial::Read`
--> src/07-uart/src/serial_setup.rs:41:5
|
41 | type Error = Error;
| ^^^^^^^^^^^^^^^^^^^ not a member of trait `serial::Read`
error[E0405]: cannot find trait `Default` in trait `bserial::Write`
--> src/07-uart/src/serial_setup.rs:38:35
|
38 | impl<T: Instance> bserial::Write::Default<u8> for UartePort<T> {}
| ^^^^^^^ not found in `bserial::Write`
|
help: consider importing one of these items
|
1 + use core::default::Default;
|
1 + use crate::toggleable::Default;
|
help: if you import `Default`, refer to it directly
|
38 - impl<T: Instance> bserial::Write::Default<u8> for UartePort<T> {}
38 + impl<T: Instance> Default<u8> for UartePort<T> {}
|
error[E0412]: cannot find type `Error` in this scope
--> src/07-uart/src/serial_setup.rs:41:18
|
41 | type Error = Error;
| ^^^^^ not found in this scope
|
help: consider importing one of these items
|
1 + use core::error::Error;
|
1 + use core::fmt::Error;
|
1 + use crate::serial_setup::bserial::Error;
|
1 + use crate::serial_setup::fmt::Error;
|
and 8 other candidates
error: aborting due to 4 previous errors
Some errors have detailed explanations: E0405, E0412, E0437.
For more information about an error, try `rustc --explain E0405`.
Error Failed to run cargo build: exit code = Some(101). The use core::fmt;
use embedded_hal_nb::serial as bserial; // changed by me
use embedded_hal_nb::serial; // changed by me
use microbit::hal::uarte::{Error as MicroError /* introduced by me*/, Instance, Uarte, UarteRx, UarteTx};
static mut TX_BUF: [u8; 1] = [0; 1];
static mut RX_BUF: [u8; 1] = [0; 1];
pub struct UartePort<T: Instance>(UarteTx<T>, UarteRx<T>);
impl<T: Instance> UartePort<T> {
pub fn new(serial: Uarte<T>) -> UartePort<T> {
let (tx, rx) = serial
.split(unsafe { &mut TX_BUF }, unsafe { &mut RX_BUF })
.unwrap();
UartePort(tx, rx)
}
}
impl<T: Instance> fmt::Write for UartePort<T> {
fn write_str(&mut self, s: &str) -> fmt::Result {
self.0.write_str(s)
}
}
impl<T: Instance> serial::Write<u8> for UartePort<T> {
type Error = MicroError;
fn write(&mut self, b: u8) -> nb::Result<(), Self::Error> {
self.0.write(b)
}
fn flush(&mut self) -> nb::Result<(), Self::Error> {
self.0.flush()
}
}
impl<T: Instance> bserial::Write::Default<u8> for UartePort<T> {}
impl<T: Instance> serial::Read<u8> for UartePort<T> {
type Error = Error;
fn read(&mut self) -> nb::Result<u8, Self::Error> {
self.1.read()
}
} At the moment, I am not very sure what the next step(s) should be. Any tip will help me. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
Hi, |
Beta Was this translation helpful? Give feedback.
-
Understood. Thank you, @eldruin for the clarification. |
Beta Was this translation helpful? Give feedback.
Hi,
At the moment it is not possible to use
embedded-hal
1.0 for the examples here until the dependencies are ported.A first step would be porting the microbit crate.
Please continue using the
embedded-hal
0.2 version for now as is done in the book.