diff options
| -rw-r--r-- | embassy-hal-common/src/macros.rs | 2 | ||||
| -rw-r--r-- | embassy-hal-common/src/peripheral.rs | 12 | ||||
| -rw-r--r-- | embassy-nrf/src/buffered_uarte.rs | 2 | ||||
| -rw-r--r-- | embassy-nrf/src/saadc.rs | 2 | ||||
| -rw-r--r-- | embassy-nrf/src/timer.rs | 2 | ||||
| -rw-r--r-- | embassy-nrf/src/uarte.rs | 2 | ||||
| -rw-r--r-- | embassy-nrf/src/usb/mod.rs | 2 | ||||
| -rw-r--r-- | embassy-stm32/build.rs | 2 | ||||
| -rw-r--r-- | embassy-stm32/src/flash/common.rs | 3 | ||||
| -rw-r--r-- | embassy-stm32/src/flash/f4.rs | 2 | ||||
| -rw-r--r-- | embassy-stm32/src/gpio.rs | 2 |
11 files changed, 16 insertions, 17 deletions
diff --git a/embassy-hal-common/src/macros.rs b/embassy-hal-common/src/macros.rs index da7913136..5e62e048a 100644 --- a/embassy-hal-common/src/macros.rs +++ b/embassy-hal-common/src/macros.rs | |||
| @@ -92,7 +92,7 @@ macro_rules! impl_peripheral { | |||
| 92 | type P = $type; | 92 | type P = $type; |
| 93 | 93 | ||
| 94 | #[inline] | 94 | #[inline] |
| 95 | unsafe fn clone_unchecked(&mut self) -> Self::P { | 95 | unsafe fn clone_unchecked(&self) -> Self::P { |
| 96 | $type { ..*self } | 96 | $type { ..*self } |
| 97 | } | 97 | } |
| 98 | } | 98 | } |
diff --git a/embassy-hal-common/src/peripheral.rs b/embassy-hal-common/src/peripheral.rs index 4a6b6a600..c7133bac6 100644 --- a/embassy-hal-common/src/peripheral.rs +++ b/embassy-hal-common/src/peripheral.rs | |||
| @@ -39,7 +39,7 @@ impl<'a, T> PeripheralRef<'a, T> { | |||
| 39 | /// You should strongly prefer using `reborrow()` instead. It returns a | 39 | /// You should strongly prefer using `reborrow()` instead. It returns a |
| 40 | /// `PeripheralRef` that borrows `self`, which allows the borrow checker | 40 | /// `PeripheralRef` that borrows `self`, which allows the borrow checker |
| 41 | /// to enforce this at compile time. | 41 | /// to enforce this at compile time. |
| 42 | pub unsafe fn clone_unchecked(&mut self) -> PeripheralRef<'a, T> | 42 | pub unsafe fn clone_unchecked(&self) -> PeripheralRef<'a, T> |
| 43 | where | 43 | where |
| 44 | T: Peripheral<P = T>, | 44 | T: Peripheral<P = T>, |
| 45 | { | 45 | { |
| @@ -146,14 +146,14 @@ pub trait Peripheral: Sized { | |||
| 146 | /// | 146 | /// |
| 147 | /// You should strongly prefer using `into_ref()` instead. It returns a | 147 | /// You should strongly prefer using `into_ref()` instead. It returns a |
| 148 | /// `PeripheralRef`, which allows the borrow checker to enforce this at compile time. | 148 | /// `PeripheralRef`, which allows the borrow checker to enforce this at compile time. |
| 149 | unsafe fn clone_unchecked(&mut self) -> Self::P; | 149 | unsafe fn clone_unchecked(&self) -> Self::P; |
| 150 | 150 | ||
| 151 | /// Convert a value into a `PeripheralRef`. | 151 | /// Convert a value into a `PeripheralRef`. |
| 152 | /// | 152 | /// |
| 153 | /// When called on an owned `T`, yields a `PeripheralRef<'static, T>`. | 153 | /// When called on an owned `T`, yields a `PeripheralRef<'static, T>`. |
| 154 | /// When called on an `&'a mut T`, yields a `PeripheralRef<'a, T>`. | 154 | /// When called on an `&'a mut T`, yields a `PeripheralRef<'a, T>`. |
| 155 | #[inline] | 155 | #[inline] |
| 156 | fn into_ref<'a>(mut self) -> PeripheralRef<'a, Self::P> | 156 | fn into_ref<'a>(self) -> PeripheralRef<'a, Self::P> |
| 157 | where | 157 | where |
| 158 | Self: 'a, | 158 | Self: 'a, |
| 159 | { | 159 | { |
| @@ -161,14 +161,14 @@ pub trait Peripheral: Sized { | |||
| 161 | } | 161 | } |
| 162 | } | 162 | } |
| 163 | 163 | ||
| 164 | impl<'b, T: DerefMut> Peripheral for T | 164 | impl<'b, T: Deref> Peripheral for T |
| 165 | where | 165 | where |
| 166 | T::Target: Peripheral, | 166 | T::Target: Peripheral, |
| 167 | { | 167 | { |
| 168 | type P = <T::Target as Peripheral>::P; | 168 | type P = <T::Target as Peripheral>::P; |
| 169 | 169 | ||
| 170 | #[inline] | 170 | #[inline] |
| 171 | unsafe fn clone_unchecked(&mut self) -> Self::P { | 171 | unsafe fn clone_unchecked(&self) -> Self::P { |
| 172 | self.deref_mut().clone_unchecked() | 172 | self.deref().clone_unchecked() |
| 173 | } | 173 | } |
| 174 | } | 174 | } |
diff --git a/embassy-nrf/src/buffered_uarte.rs b/embassy-nrf/src/buffered_uarte.rs index 75f93f904..c41d8398c 100644 --- a/embassy-nrf/src/buffered_uarte.rs +++ b/embassy-nrf/src/buffered_uarte.rs | |||
| @@ -342,7 +342,7 @@ impl<'d, U: UarteInstance, T: TimerInstance> BufferedUarte<'d, U, T> { | |||
| 342 | r.enable.write(|w| w.enable().enabled()); | 342 | r.enable.write(|w| w.enable().enabled()); |
| 343 | 343 | ||
| 344 | // Configure byte counter. | 344 | // Configure byte counter. |
| 345 | let mut timer = Timer::new_counter(timer); | 345 | let timer = Timer::new_counter(timer); |
| 346 | timer.cc(1).write(rx_buffer.len() as u32 * 2); | 346 | timer.cc(1).write(rx_buffer.len() as u32 * 2); |
| 347 | timer.cc(1).short_compare_clear(); | 347 | timer.cc(1).short_compare_clear(); |
| 348 | timer.clear(); | 348 | timer.clear(); |
diff --git a/embassy-nrf/src/saadc.rs b/embassy-nrf/src/saadc.rs index af952f03d..8aff7df16 100644 --- a/embassy-nrf/src/saadc.rs +++ b/embassy-nrf/src/saadc.rs | |||
| @@ -315,7 +315,7 @@ impl<'d, const N: usize> Saadc<'d, N> { | |||
| 315 | Ppi::new_one_to_one(ppi_ch1, Event::from_reg(&r.events_end), Task::from_reg(&r.tasks_start)); | 315 | Ppi::new_one_to_one(ppi_ch1, Event::from_reg(&r.events_end), Task::from_reg(&r.tasks_start)); |
| 316 | start_ppi.enable(); | 316 | start_ppi.enable(); |
| 317 | 317 | ||
| 318 | let mut timer = Timer::new(timer); | 318 | let timer = Timer::new(timer); |
| 319 | timer.set_frequency(frequency); | 319 | timer.set_frequency(frequency); |
| 320 | timer.cc(0).write(sample_counter); | 320 | timer.cc(0).write(sample_counter); |
| 321 | timer.cc(0).short_compare_clear(); | 321 | timer.cc(0).short_compare_clear(); |
diff --git a/embassy-nrf/src/timer.rs b/embassy-nrf/src/timer.rs index a9487a9fd..48b4f1b55 100644 --- a/embassy-nrf/src/timer.rs +++ b/embassy-nrf/src/timer.rs | |||
| @@ -117,7 +117,7 @@ impl<'d, T: Instance> Timer<'d, T> { | |||
| 117 | 117 | ||
| 118 | let regs = T::regs(); | 118 | let regs = T::regs(); |
| 119 | 119 | ||
| 120 | let mut this = Self { _p: timer }; | 120 | let this = Self { _p: timer }; |
| 121 | 121 | ||
| 122 | // Stop the timer before doing anything else, | 122 | // Stop the timer before doing anything else, |
| 123 | // since changing BITMODE while running can cause 'unpredictable behaviour' according to the specification. | 123 | // since changing BITMODE while running can cause 'unpredictable behaviour' according to the specification. |
diff --git a/embassy-nrf/src/uarte.rs b/embassy-nrf/src/uarte.rs index 3934d1b55..e59b2332a 100644 --- a/embassy-nrf/src/uarte.rs +++ b/embassy-nrf/src/uarte.rs | |||
| @@ -205,7 +205,7 @@ impl<'d, T: Instance> Uarte<'d, T> { | |||
| 205 | ppi_ch1: impl Peripheral<P = impl ConfigurableChannel + 'd> + 'd, | 205 | ppi_ch1: impl Peripheral<P = impl ConfigurableChannel + 'd> + 'd, |
| 206 | ppi_ch2: impl Peripheral<P = impl ConfigurableChannel + 'd> + 'd, | 206 | ppi_ch2: impl Peripheral<P = impl ConfigurableChannel + 'd> + 'd, |
| 207 | ) -> (UarteTx<'d, T>, UarteRxWithIdle<'d, T, U>) { | 207 | ) -> (UarteTx<'d, T>, UarteRxWithIdle<'d, T, U>) { |
| 208 | let mut timer = Timer::new(timer); | 208 | let timer = Timer::new(timer); |
| 209 | 209 | ||
| 210 | into_ref!(ppi_ch1, ppi_ch2); | 210 | into_ref!(ppi_ch1, ppi_ch2); |
| 211 | 211 | ||
diff --git a/embassy-nrf/src/usb/mod.rs b/embassy-nrf/src/usb/mod.rs index 56de511df..c1f3f48cb 100644 --- a/embassy-nrf/src/usb/mod.rs +++ b/embassy-nrf/src/usb/mod.rs | |||
| @@ -153,7 +153,7 @@ impl<'d, T: Instance, V: VbusDetect + 'd> driver::Driver<'d> for Driver<'d, T, V | |||
| 153 | })) | 153 | })) |
| 154 | } | 154 | } |
| 155 | 155 | ||
| 156 | fn start(mut self, control_max_packet_size: u16) -> (Self::Bus, Self::ControlPipe) { | 156 | fn start(self, control_max_packet_size: u16) -> (Self::Bus, Self::ControlPipe) { |
| 157 | ( | 157 | ( |
| 158 | Bus { | 158 | Bus { |
| 159 | _p: unsafe { self._p.clone_unchecked() }, | 159 | _p: unsafe { self._p.clone_unchecked() }, |
diff --git a/embassy-stm32/build.rs b/embassy-stm32/build.rs index b01e8ba45..73bd29fcf 100644 --- a/embassy-stm32/build.rs +++ b/embassy-stm32/build.rs | |||
| @@ -180,7 +180,7 @@ fn main() { | |||
| 180 | 180 | ||
| 181 | #[cfg(flash)] | 181 | #[cfg(flash)] |
| 182 | impl<'d> FlashLayout<'d> { | 182 | impl<'d> FlashLayout<'d> { |
| 183 | pub(crate) fn new(mut p: embassy_hal_common::PeripheralRef<'d, crate::peripherals::FLASH>) -> Self { | 183 | pub(crate) fn new(p: embassy_hal_common::PeripheralRef<'d, crate::peripherals::FLASH>) -> Self { |
| 184 | Self { | 184 | Self { |
| 185 | #(#inits),* | 185 | #(#inits),* |
| 186 | } | 186 | } |
diff --git a/embassy-stm32/src/flash/common.rs b/embassy-stm32/src/flash/common.rs index 8235d6f08..1189e447e 100644 --- a/embassy-stm32/src/flash/common.rs +++ b/embassy-stm32/src/flash/common.rs | |||
| @@ -33,8 +33,7 @@ impl<'d> Flash<'d> { | |||
| 33 | } | 33 | } |
| 34 | 34 | ||
| 35 | pub(crate) fn release(self) -> PeripheralRef<'d, crate::peripherals::FLASH> { | 35 | pub(crate) fn release(self) -> PeripheralRef<'d, crate::peripherals::FLASH> { |
| 36 | let mut flash = self; | 36 | unsafe { self.inner.clone_unchecked() } |
| 37 | unsafe { flash.inner.clone_unchecked() } | ||
| 38 | } | 37 | } |
| 39 | } | 38 | } |
| 40 | 39 | ||
diff --git a/embassy-stm32/src/flash/f4.rs b/embassy-stm32/src/flash/f4.rs index 2ce9df69f..60ac62c17 100644 --- a/embassy-stm32/src/flash/f4.rs +++ b/embassy-stm32/src/flash/f4.rs | |||
| @@ -67,7 +67,7 @@ mod alt_regions { | |||
| 67 | 67 | ||
| 68 | // SAFETY: We never expose the cloned peripheral references, and their instance is not public. | 68 | // SAFETY: We never expose the cloned peripheral references, and their instance is not public. |
| 69 | // Also, all flash region operations are protected with a cs. | 69 | // Also, all flash region operations are protected with a cs. |
| 70 | let mut p = self.release(); | 70 | let p = self.release(); |
| 71 | AltFlashLayout { | 71 | AltFlashLayout { |
| 72 | bank1_region1: Bank1Region1(&BANK1_REGION1, unsafe { p.clone_unchecked() }), | 72 | bank1_region1: Bank1Region1(&BANK1_REGION1, unsafe { p.clone_unchecked() }), |
| 73 | bank1_region2: Bank1Region2(&BANK1_REGION2, unsafe { p.clone_unchecked() }), | 73 | bank1_region2: Bank1Region2(&BANK1_REGION2, unsafe { p.clone_unchecked() }), |
diff --git a/embassy-stm32/src/gpio.rs b/embassy-stm32/src/gpio.rs index 3024f1ffa..4895684e0 100644 --- a/embassy-stm32/src/gpio.rs +++ b/embassy-stm32/src/gpio.rs | |||
| @@ -29,7 +29,7 @@ impl<'d, T: Pin> Flex<'d, T> { | |||
| 29 | } | 29 | } |
| 30 | 30 | ||
| 31 | #[inline] | 31 | #[inline] |
| 32 | pub fn degrade(mut self) -> Flex<'d, AnyPin> { | 32 | pub fn degrade(self) -> Flex<'d, AnyPin> { |
| 33 | // Safety: We are about to drop the other copy of this pin, so | 33 | // Safety: We are about to drop the other copy of this pin, so |
| 34 | // this clone is safe. | 34 | // this clone is safe. |
| 35 | let pin = unsafe { self.pin.clone_unchecked() }; | 35 | let pin = unsafe { self.pin.clone_unchecked() }; |
