aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--embassy-stm32f4/src/serial.rs38
1 files changed, 20 insertions, 18 deletions
diff --git a/embassy-stm32f4/src/serial.rs b/embassy-stm32f4/src/serial.rs
index f050e0e20..2ca82ac50 100644
--- a/embassy-stm32f4/src/serial.rs
+++ b/embassy-stm32f4/src/serial.rs
@@ -5,6 +5,7 @@
5//! are dropped correctly (e.g. not using `mem::forget()`). 5//! are dropped correctly (e.g. not using `mem::forget()`).
6 6
7use core::future::Future; 7use core::future::Future;
8use core::marker::PhantomData;
8use core::ptr; 9use core::ptr;
9use core::sync::atomic::{self, Ordering}; 10use core::sync::atomic::{self, Ordering};
10 11
@@ -12,15 +13,16 @@ use embassy::interrupt::{Interrupt, InterruptExt};
12use embassy::traits::uart::{Error, Uart}; 13use embassy::traits::uart::{Error, Uart};
13use embassy::util::InterruptFuture; 14use embassy::util::InterruptFuture;
14 15
15use crate::hal::dma; 16use crate::hal::{
16use crate::hal::dma::config::DmaConfig; 17 dma,
17use crate::hal::dma::traits::{PeriAddress, Stream}; 18 dma::config::DmaConfig,
18use crate::hal::dma::{MemoryToPeripheral, PeripheralToMemory, Transfer}; 19 dma::traits::{Channel, DMASet, PeriAddress, Stream},
19use crate::hal::rcc::Clocks; 20 dma::{MemoryToPeripheral, PeripheralToMemory, Transfer},
20use crate::hal::serial; 21 rcc::Clocks,
21use crate::hal::serial::config::{Config as SerialConfig, DmaConfig as SerialDmaConfig}; 22 serial,
22use crate::hal::serial::Pins; 23 serial::config::{Config as SerialConfig, DmaConfig as SerialDmaConfig},
23use crate::hal::serial::{Event as SerialEvent, Serial as HalSerial}; 24 serial::{Event as SerialEvent, Pins, Serial as HalSerial},
25};
24use crate::interrupt; 26use crate::interrupt;
25use crate::pac; 27use crate::pac;
26 28
@@ -37,7 +39,7 @@ pub struct Serial<
37 tx_int: TSTREAM::Interrupt, 39 tx_int: TSTREAM::Interrupt,
38 rx_int: RSTREAM::Interrupt, 40 rx_int: RSTREAM::Interrupt,
39 usart_int: USART::Interrupt, 41 usart_int: USART::Interrupt,
40 channel: core::marker::PhantomData<CHANNEL>, 42 channel: PhantomData<CHANNEL>,
41} 43}
42 44
43// static mut INSTANCE: *const Serial<USART1, Stream7<DMA2>, Stream2<DMA2>> = ptr::null_mut(); 45// static mut INSTANCE: *const Serial<USART1, Stream7<DMA2>, Stream2<DMA2>> = ptr::null_mut();
@@ -45,13 +47,13 @@ pub struct Serial<
45impl<USART, TSTREAM, RSTREAM, CHANNEL> Serial<USART, TSTREAM, RSTREAM, CHANNEL> 47impl<USART, TSTREAM, RSTREAM, CHANNEL> Serial<USART, TSTREAM, RSTREAM, CHANNEL>
46where 48where
47 USART: serial::Instance 49 USART: serial::Instance
48 + dma::traits::PeriAddress<MemSize = u8> 50 + PeriAddress<MemSize = u8>
49 + dma::traits::DMASet<TSTREAM, CHANNEL, MemoryToPeripheral> 51 + DMASet<TSTREAM, CHANNEL, MemoryToPeripheral>
50 + dma::traits::DMASet<RSTREAM, CHANNEL, PeripheralToMemory> 52 + DMASet<RSTREAM, CHANNEL, PeripheralToMemory>
51 + WithInterrupt, 53 + WithInterrupt,
52 TSTREAM: Stream + WithInterrupt, 54 TSTREAM: Stream + WithInterrupt,
53 RSTREAM: Stream + WithInterrupt, 55 RSTREAM: Stream + WithInterrupt,
54 CHANNEL: dma::traits::Channel, 56 CHANNEL: Channel,
55{ 57{
56 // Leaking futures is forbidden! 58 // Leaking futures is forbidden!
57 pub unsafe fn new<PINS>( 59 pub unsafe fn new<PINS>(
@@ -92,14 +94,14 @@ where
92impl<USART, TSTREAM, RSTREAM, CHANNEL> Uart for Serial<USART, TSTREAM, RSTREAM, CHANNEL> 94impl<USART, TSTREAM, RSTREAM, CHANNEL> Uart for Serial<USART, TSTREAM, RSTREAM, CHANNEL>
93where 95where
94 USART: serial::Instance 96 USART: serial::Instance
95 + dma::traits::PeriAddress<MemSize = u8> 97 + PeriAddress<MemSize = u8>
96 + dma::traits::DMASet<TSTREAM, CHANNEL, MemoryToPeripheral> 98 + DMASet<TSTREAM, CHANNEL, MemoryToPeripheral>
97 + dma::traits::DMASet<RSTREAM, CHANNEL, PeripheralToMemory> 99 + DMASet<RSTREAM, CHANNEL, PeripheralToMemory>
98 + WithInterrupt 100 + WithInterrupt
99 + 'static, 101 + 'static,
100 TSTREAM: Stream + WithInterrupt + 'static, 102 TSTREAM: Stream + WithInterrupt + 'static,
101 RSTREAM: Stream + WithInterrupt + 'static, 103 RSTREAM: Stream + WithInterrupt + 'static,
102 CHANNEL: dma::traits::Channel + 'static, 104 CHANNEL: Channel + 'static,
103{ 105{
104 type SendFuture<'a> = impl Future<Output = Result<(), Error>> + 'a; 106 type SendFuture<'a> = impl Future<Output = Result<(), Error>> + 'a;
105 type ReceiveFuture<'a> = impl Future<Output = Result<(), Error>> + 'a; 107 type ReceiveFuture<'a> = impl Future<Output = Result<(), Error>> + 'a;