diff options
| author | xoviat <[email protected]> | 2021-01-13 17:40:32 -0600 |
|---|---|---|
| committer | xoviat <[email protected]> | 2021-01-13 17:40:32 -0600 |
| commit | 7adf99eff3cf5f8c407168ad618bbe354a4f28eb (patch) | |
| tree | a6e48cf29ffcf898e05ec7114c96a1cae812c501 | |
| parent | c07f7467a084d1d25d896d6cc2552eb3b3205908 (diff) | |
implement changes
| -rw-r--r-- | embassy-stm32f4/src/serial.rs | 10 |
1 files changed, 1 insertions, 9 deletions
diff --git a/embassy-stm32f4/src/serial.rs b/embassy-stm32f4/src/serial.rs index c430ee95f..7590fe65a 100644 --- a/embassy-stm32f4/src/serial.rs +++ b/embassy-stm32f4/src/serial.rs | |||
| @@ -144,14 +144,10 @@ impl Uart for Serial<USART1, Stream7<DMA2>, Stream2<DMA2>> { | |||
| 144 | type ReceiveFuture<'a> = impl Future<Output = Result<(), Error>> + 'a; | 144 | type ReceiveFuture<'a> = impl Future<Output = Result<(), Error>> + 'a; |
| 145 | 145 | ||
| 146 | /// Sends serial data. | 146 | /// Sends serial data. |
| 147 | /// | ||
| 148 | /// `tx_buffer` is marked as static as per `embedded-dma` requirements. | ||
| 149 | /// It it safe to use a buffer with a non static lifetime if memory is not | ||
| 150 | /// reused until the future has finished. | ||
| 151 | #[allow(mutable_transmutes)] | ||
| 152 | fn send<'a>(&'a mut self, buf: &'a [u8]) -> Self::SendFuture<'a> { | 147 | fn send<'a>(&'a mut self, buf: &'a [u8]) -> Self::SendFuture<'a> { |
| 153 | unsafe { INSTANCE = self }; | 148 | unsafe { INSTANCE = self }; |
| 154 | 149 | ||
| 150 | #[allow(mutable_transmutes)] | ||
| 155 | let static_buf = unsafe { core::mem::transmute::<&'a [u8], &'static mut [u8]>(buf) }; | 151 | let static_buf = unsafe { core::mem::transmute::<&'a [u8], &'static mut [u8]>(buf) }; |
| 156 | 152 | ||
| 157 | let tx_stream = self.tx_stream.take().unwrap(); | 153 | let tx_stream = self.tx_stream.take().unwrap(); |
| @@ -190,10 +186,6 @@ impl Uart for Serial<USART1, Stream7<DMA2>, Stream2<DMA2>> { | |||
| 190 | /// A common pattern is to use [`stop()`](ReceiveFuture::stop) to cancel | 186 | /// A common pattern is to use [`stop()`](ReceiveFuture::stop) to cancel |
| 191 | /// unfinished transfers after a timeout to prevent lockup when no more data | 187 | /// unfinished transfers after a timeout to prevent lockup when no more data |
| 192 | /// is incoming. | 188 | /// is incoming. |
| 193 | /// | ||
| 194 | /// `rx_buffer` is marked as static as per `embedded-dma` requirements. | ||
| 195 | /// It it safe to use a buffer with a non static lifetime if memory is not | ||
| 196 | /// reused until the future has finished. | ||
| 197 | fn receive<'a>(&'a mut self, buf: &'a mut [u8]) -> Self::ReceiveFuture<'a> { | 189 | fn receive<'a>(&'a mut self, buf: &'a mut [u8]) -> Self::ReceiveFuture<'a> { |
| 198 | unsafe { INSTANCE = self }; | 190 | unsafe { INSTANCE = self }; |
| 199 | 191 | ||
