-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
99 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
#![no_std] | ||
#![no_main] | ||
#![feature(type_alias_impl_trait)] | ||
|
||
use defmt::info; | ||
use defmt_rtt as _; | ||
use embassy_executor::{main, task, Spawner}; | ||
use embassy_time::Timer; | ||
use panic_probe as _; | ||
use portenta_h7_async::{Uart0, Uart1}; | ||
|
||
const DATA: &[u8] = b"Hello world!"; | ||
|
||
#[main] | ||
async fn main(spawner: Spawner) { | ||
info!("Init"); | ||
let portenta_h7_async::Board { uart0, uart1, .. } = portenta_h7_async::Board::take(); | ||
|
||
spawner.spawn(uart_write(uart0)).unwrap(); | ||
spawner.spawn(uart_read(uart1)).unwrap(); | ||
|
||
loop { | ||
Timer::after_millis(100).await; | ||
} | ||
} | ||
|
||
#[task] | ||
async fn uart_write(mut uart: Uart0) { | ||
loop { | ||
uart.blocking_write(DATA).unwrap(); // TODO Use async version, it panics, fix it | ||
Timer::after_millis(1_000).await; | ||
} | ||
} | ||
|
||
#[task] | ||
async fn uart_read(mut uart: Uart1) { | ||
let rx_buf: &mut [u8] = &mut [0; DATA.len()]; | ||
loop { | ||
Timer::after_millis(1_000).await; | ||
uart.blocking_read(rx_buf).unwrap(); // TODO Use async version, it panics, fix it | ||
|
||
info!("{}", core::str::from_utf8(&rx_buf).unwrap()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.