1313: (embassy-stm32): rework bufferedUart to get rid of PeripheralMutex r=Dirbaio a=MathiasKoch

New implementation is very similar to the implementation of embassy-nrf & embassy-rp. 

Also adds embedded-hal traits to bufferedUart.

**NB**: Still needs testing on actual hardware

Co-authored-by: Mathias <mk@blackbird.online>
This commit is contained in:
bors[bot]
2023-04-04 15:14:07 +00:00
committed by GitHub
4 changed files with 475 additions and 314 deletions

View File

@ -5,7 +5,7 @@
use defmt::*;
use embassy_executor::Spawner;
use embassy_stm32::interrupt;
use embassy_stm32::usart::{BufferedUart, Config, State};
use embassy_stm32::usart::{BufferedUart, Config};
use embedded_io::asynch::BufRead;
use {defmt_rtt as _, panic_probe as _};
@ -16,20 +16,10 @@ async fn main(_spawner: Spawner) {
let config = Config::default();
let mut state = State::new();
let irq = interrupt::take!(USART3);
let mut tx_buf = [0u8; 32];
let mut rx_buf = [0u8; 32];
let mut buf_usart = BufferedUart::new(
&mut state,
p.USART3,
p.PD9,
p.PD8,
irq,
&mut tx_buf,
&mut rx_buf,
config,
);
let mut buf_usart = BufferedUart::new(p.USART3, irq, p.PD9, p.PD8, &mut tx_buf, &mut rx_buf, config);
loop {
let buf = buf_usart.fill_buf().await.unwrap();