diff options
| author | xoviat <[email protected]> | 2021-03-05 23:04:20 -0600 |
|---|---|---|
| committer | xoviat <[email protected]> | 2021-03-05 23:04:20 -0600 |
| commit | 9956cffb2d45f899fd0583aec06d2aee0163fa1c (patch) | |
| tree | ecae0f6faffdb40eaaf134a88d69e0d637582da8 | |
| parent | 7234c5e509f5dd26d084dbfe6ad978d73ffab2f9 (diff) | |
cleanup imports
| -rw-r--r-- | embassy-stm32f4/src/serial.rs | 38 |
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 | ||
| 7 | use core::future::Future; | 7 | use core::future::Future; |
| 8 | use core::marker::PhantomData; | ||
| 8 | use core::ptr; | 9 | use core::ptr; |
| 9 | use core::sync::atomic::{self, Ordering}; | 10 | use core::sync::atomic::{self, Ordering}; |
| 10 | 11 | ||
| @@ -12,15 +13,16 @@ use embassy::interrupt::{Interrupt, InterruptExt}; | |||
| 12 | use embassy::traits::uart::{Error, Uart}; | 13 | use embassy::traits::uart::{Error, Uart}; |
| 13 | use embassy::util::InterruptFuture; | 14 | use embassy::util::InterruptFuture; |
| 14 | 15 | ||
| 15 | use crate::hal::dma; | 16 | use crate::hal::{ |
| 16 | use crate::hal::dma::config::DmaConfig; | 17 | dma, |
| 17 | use crate::hal::dma::traits::{PeriAddress, Stream}; | 18 | dma::config::DmaConfig, |
| 18 | use crate::hal::dma::{MemoryToPeripheral, PeripheralToMemory, Transfer}; | 19 | dma::traits::{Channel, DMASet, PeriAddress, Stream}, |
| 19 | use crate::hal::rcc::Clocks; | 20 | dma::{MemoryToPeripheral, PeripheralToMemory, Transfer}, |
| 20 | use crate::hal::serial; | 21 | rcc::Clocks, |
| 21 | use crate::hal::serial::config::{Config as SerialConfig, DmaConfig as SerialDmaConfig}; | 22 | serial, |
| 22 | use crate::hal::serial::Pins; | 23 | serial::config::{Config as SerialConfig, DmaConfig as SerialDmaConfig}, |
| 23 | use crate::hal::serial::{Event as SerialEvent, Serial as HalSerial}; | 24 | serial::{Event as SerialEvent, Pins, Serial as HalSerial}, |
| 25 | }; | ||
| 24 | use crate::interrupt; | 26 | use crate::interrupt; |
| 25 | use crate::pac; | 27 | use 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< | |||
| 45 | impl<USART, TSTREAM, RSTREAM, CHANNEL> Serial<USART, TSTREAM, RSTREAM, CHANNEL> | 47 | impl<USART, TSTREAM, RSTREAM, CHANNEL> Serial<USART, TSTREAM, RSTREAM, CHANNEL> |
| 46 | where | 48 | where |
| 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 | |||
| 92 | impl<USART, TSTREAM, RSTREAM, CHANNEL> Uart for Serial<USART, TSTREAM, RSTREAM, CHANNEL> | 94 | impl<USART, TSTREAM, RSTREAM, CHANNEL> Uart for Serial<USART, TSTREAM, RSTREAM, CHANNEL> |
| 93 | where | 95 | where |
| 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; |
