mirror of
https://github.com/embassy-rs/embassy.git
synced 2024-11-21 22:32:29 +00:00
rustfmt example
This commit is contained in:
parent
af2aedb588
commit
d6b67abefa
@ -1,14 +1,13 @@
|
|||||||
|
|
||||||
#![no_std]
|
#![no_std]
|
||||||
#![no_main]
|
#![no_main]
|
||||||
|
|
||||||
use {defmt_rtt as _, panic_probe as _};
|
use defmt::{debug, error, info};
|
||||||
|
|
||||||
use embassy_time::Timer;
|
|
||||||
use embassy_executor::Spawner;
|
use embassy_executor::Spawner;
|
||||||
use embassy_stm32::{bind_interrupts, peripherals, usart::{self, Uart}};
|
use embassy_stm32::usart::{self, Uart};
|
||||||
use defmt::{debug, info, error};
|
use embassy_stm32::{bind_interrupts, peripherals};
|
||||||
|
use embassy_time::Timer;
|
||||||
use static_cell::StaticCell;
|
use static_cell::StaticCell;
|
||||||
|
use {defmt_rtt as _, panic_probe as _};
|
||||||
|
|
||||||
/*--- Main ---------------------------------------------------------------------------------------*/
|
/*--- Main ---------------------------------------------------------------------------------------*/
|
||||||
|
|
||||||
@ -28,15 +27,15 @@ async fn main(_spawner: Spawner) {
|
|||||||
info!("debug uart baudrate: {}", config.baudrate);
|
info!("debug uart baudrate: {}", config.baudrate);
|
||||||
|
|
||||||
let port = Uart::new(
|
let port = Uart::new(
|
||||||
p.USART3, // periph
|
p.USART3, // periph
|
||||||
p.PD9, // rx,
|
p.PD9, // rx,
|
||||||
p.PD8, // tx,
|
p.PD8, // tx,
|
||||||
Irqs, // prove irq bound
|
Irqs, // prove irq bound
|
||||||
p.GPDMA2_CH0, // tx_dma
|
p.GPDMA2_CH0, // tx_dma
|
||||||
p.GPDMA2_CH1, // rx_dma
|
p.GPDMA2_CH1, // rx_dma
|
||||||
config,
|
config,
|
||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
const S: usize = 2000;
|
const S: usize = 2000;
|
||||||
static BUFF: StaticCell<[u8; S]> = StaticCell::new();
|
static BUFF: StaticCell<[u8; S]> = StaticCell::new();
|
||||||
@ -51,18 +50,12 @@ async fn main(_spawner: Spawner) {
|
|||||||
let mut count = 0;
|
let mut count = 0;
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
if let Ok(c) = port_rx.read(&mut read_buff)
|
if let Ok(c) = port_rx.read(&mut read_buff).await.map_err(|e| {
|
||||||
.await
|
error!("read error: {}", e);
|
||||||
.map_err(|e| {
|
}) {
|
||||||
error!("read error: {}", e);
|
if let Ok(s) = core::str::from_utf8(&read_buff).map_err(|e| {
|
||||||
})
|
error!("str parse error: {}", defmt::Debug2Format(&e));
|
||||||
|
}) {
|
||||||
{
|
|
||||||
if let Ok(s) = core::str::from_utf8(&read_buff)
|
|
||||||
.map_err(|e| {
|
|
||||||
error!("str parse error: {}", defmt::Debug2Format(&e));
|
|
||||||
})
|
|
||||||
{
|
|
||||||
count += c;
|
count += c;
|
||||||
|
|
||||||
debug!("total_rx: {} delta: {} -- rx: {}", count, c, s);
|
debug!("total_rx: {} delta: {} -- rx: {}", count, c, s);
|
||||||
|
Loading…
Reference in New Issue
Block a user