Skip to content

Commit

Permalink
Adjustments for v1 and v2
Browse files Browse the repository at this point in the history
  • Loading branch information
A-Young-Git committed Oct 27, 2024
1 parent aea4e64 commit 64e7bb0
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions microbit/src/07-uart/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ fn main() -> ! {

#[cfg(feature = "v1")]
let mut serial = {
// Set up UART for microbit v1
let serial = uart::Uart::new(
board.UART0,
board.uart.into(),
Expand All @@ -48,6 +49,7 @@ fn main() -> ! {

#[cfg(feature = "v2")]
let mut serial = {
// Set up UARTE for microbit v2 using UartePort wrapper
let serial = uarte::Uarte::new(
board.UARTE0,
board.uart.into(),
Expand All @@ -57,12 +59,15 @@ fn main() -> ! {
UartePort::new(serial)
};

// Write a byte and flush for `v1`
// Write a byte and flush
#[cfg(feature = "v1")]
nb::block!(serial.write(&[b'X'])).unwrap();
serial.write(&[b'X']).unwrap(); // Adjusted for UART on v1, no need for nb::block!

#[cfg(feature = "v2")]
nb::block!(serial.flush()).unwrap();
{
nb::block!(serial.write(b'X')).unwrap();
nb::block!(serial.flush()).unwrap();
}

loop {}
}

0 comments on commit 64e7bb0

Please sign in to comment.