diff --git a/embassy-stm32f4/src/serial.rs b/embassy-stm32f4/src/serial.rs index 0ea635dd4..dcd71958d 100644 --- a/embassy-stm32f4/src/serial.rs +++ b/embassy-stm32f4/src/serial.rs @@ -127,7 +127,10 @@ impl Uarte { /// `tx_buffer` is marked as static as per `embedded-dma` requirements. /// It it safe to use a buffer with a non static lifetime if memory is not /// reused until the future has finished. - pub fn send<'a, B>(&'a mut self, tx_buffer: B) -> SendFuture<'a, B> + pub fn send<'a, B>( + &'a mut self, + tx_buffer: B, + ) -> SendFuture<'a, B, USART1, Stream7, Channel4> where B: WriteBuffer + 'static, { @@ -165,7 +168,7 @@ impl Uarte { pub fn receive<'a, B>( &'a mut self, rx_buffer: B, - ) -> ReceiveFuture<'a, B, Stream2, Channel4> + ) -> ReceiveFuture<'a, B, USART1, Stream2, Channel4> where B: WriteBuffer + 'static, { @@ -191,19 +194,25 @@ impl Uarte { } /// Future for the [`LowPowerUarte::send()`] method. -pub struct SendFuture<'a, B: WriteBuffer + 'static> { - uarte: &'a mut Uarte, - tx_transfer: Option, Channel4, USART1, MemoryToPeripheral, B>>, -} - -impl<'a, B> Drop for SendFuture<'a, B> -where +pub struct SendFuture< + 'a, B: WriteBuffer + 'static, -{ - fn drop(self: &mut Self) {} + USART: PeriAddress, + STREAM: Stream, + CHANNEL, +> { + uarte: &'a mut Uarte, + tx_transfer: Option>, } -impl<'a, B> Future for SendFuture<'a, B> +// impl<'a, B> Drop for SendFuture<'a, B> +// where +// B: WriteBuffer + 'static, +// { +// fn drop(self: &mut Self) {} +// } + +impl<'a, B> Future for SendFuture<'a, B, USART1, Stream7, Channel4> where B: WriteBuffer + 'static, { @@ -230,9 +239,15 @@ where } /// Future for the [`Uarte::receive()`] method. -pub struct ReceiveFuture<'a, B: WriteBuffer + 'static, STREAM: Stream, CHANNEL> { +pub struct ReceiveFuture< + 'a, + B: WriteBuffer + 'static, + USART: PeriAddress, + STREAM: Stream, + CHANNEL, +> { uarte: &'a mut Uarte, - rx_transfer: Option>, + rx_transfer: Option>, } // pub struct ReceiveFuture<'a, B: WriteBuffer + 'static, DMA, STREAM, CHANNEL> { @@ -247,7 +262,7 @@ pub struct ReceiveFuture<'a, B: WriteBuffer + 'static, STREAM: Stream // fn drop(self: &mut Self) {} // } -impl<'a, B> Future for ReceiveFuture<'a, B, Stream2, Channel4> +impl<'a, B> Future for ReceiveFuture<'a, B, USART1, Stream2, Channel4> where B: WriteBuffer + 'static + Unpin, {