the Tx is finished
This commit is contained in:
@@ -10,7 +10,6 @@ use embassy_time::{Duration, Timer};
|
||||
use {defmt_rtt as _, panic_probe as _};
|
||||
|
||||
use embassy_stm32::{
|
||||
dma::Request,
|
||||
gpio::{Level, Output, Speed},
|
||||
peripherals::{GPDMA1_CH0, TIM6},
|
||||
rcc,
|
||||
@@ -18,7 +17,9 @@ use embassy_stm32::{
|
||||
};
|
||||
use embassy_stm32::Peri;
|
||||
|
||||
use dma_gpio::gpio_dma_uart::{encode_uart_byte, write_uart_frames_to_pipe, GpioDmaBsrrTx, TIM6_UP_REQ};
|
||||
use dma_gpio::gpio_dma_uart::{
|
||||
write_uart_frames_to_pipe, GpioDmaBsrrTx, Parity, StopBits, UartConfig, TIM6_UP_REQ,
|
||||
};
|
||||
|
||||
static PIPE: Pipe<CriticalSectionRawMutex, 256> = Pipe::new();
|
||||
|
||||
@@ -26,10 +27,16 @@ static PIPE: Pipe<CriticalSectionRawMutex, 256> = Pipe::new();
|
||||
const BAUD: u32 = 115_200;
|
||||
const TX_PIN_BIT: u8 = 2; // PA2
|
||||
|
||||
const UART_CFG: UartConfig = UartConfig {
|
||||
data_bits: 8,
|
||||
parity: Parity::None,
|
||||
stop_bits: StopBits::One,
|
||||
};
|
||||
|
||||
#[embassy_executor::main]
|
||||
async fn main(spawner: Spawner) {
|
||||
let p = embassy_stm32::init(Default::default());
|
||||
info!("DMA Pipe -> GPIO UART-like TX (safe wrapper)");
|
||||
info!("DMA Pipe -> GPIO UART-like TX");
|
||||
|
||||
// PA2 is the TX "wire"
|
||||
let _pa2 = Output::new(p.PA2, Level::High, Speed::VeryHigh);
|
||||
@@ -51,7 +58,12 @@ async fn main(spawner: Spawner) {
|
||||
|
||||
// Example: transmit a string as UART frames via the Pipe
|
||||
loop {
|
||||
write_uart_frames_to_pipe(&PIPE, TX_PIN_BIT, b"Hello, DMA UART!\r\n").await;
|
||||
write_uart_frames_to_pipe(
|
||||
&PIPE,
|
||||
TX_PIN_BIT,
|
||||
b"Hello, DMA UART (configurable)!\r\n",
|
||||
&UART_CFG,
|
||||
).await;
|
||||
Timer::after(Duration::from_secs(2)).await;
|
||||
}
|
||||
}
|
||||
@@ -70,7 +82,6 @@ async fn dma_tx_task(ch: Peri<'static, GPDMA1_CH0>) {
|
||||
}
|
||||
let w = u32::from_le_bytes(b);
|
||||
|
||||
// Log + send via DMA (timer-paced, 1 beat per bit time)
|
||||
info!("DMA write 0x{:08X} -> GPIOA.BSRR", w);
|
||||
tx.write_word(w).await;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user