diff options
| author | Dario Nieuwenhuis <[email protected]> | 2022-02-10 16:06:42 +0100 |
|---|---|---|
| committer | Dario Nieuwenhuis <[email protected]> | 2022-02-10 16:06:42 +0100 |
| commit | a8bd3ab9521fc2c3c4a409c40648068af3d63d97 (patch) | |
| tree | fda3c3af254733ecd9e1804b79383b648ccd806f | |
| parent | 550da471be7b56927b50b5955a6de0916ebe6b1f (diff) | |
Add missing `+ 'd` on unborrows.
| -rw-r--r-- | embassy-rp/src/spi.rs | 10 | ||||
| -rw-r--r-- | embassy-rp/src/uart.rs | 10 | ||||
| -rw-r--r-- | embassy-stm32/src/crc/v1.rs | 10 | ||||
| -rw-r--r-- | embassy-stm32/src/crc/v2v3.rs | 10 | ||||
| -rw-r--r-- | embassy-stm32/src/i2c/v1.rs | 4 | ||||
| -rw-r--r-- | embassy-stm32/src/rng.rs | 17 | ||||
| -rw-r--r-- | embassy-stm32/src/sdmmc/v2.rs | 2 | ||||
| -rw-r--r-- | embassy-stm32/src/spi/mod.rs | 4 | ||||
| -rw-r--r-- | embassy-stm32/src/usart/mod.rs | 10 |
9 files changed, 45 insertions, 32 deletions
diff --git a/embassy-rp/src/spi.rs b/embassy-rp/src/spi.rs index 906fa23e9..491082188 100644 --- a/embassy-rp/src/spi.rs +++ b/embassy-rp/src/spi.rs | |||
| @@ -62,11 +62,11 @@ fn calc_prescs(freq: u32) -> (u8, u8) { | |||
| 62 | 62 | ||
| 63 | impl<'d, T: Instance> Spi<'d, T> { | 63 | impl<'d, T: Instance> Spi<'d, T> { |
| 64 | pub fn new( | 64 | pub fn new( |
| 65 | inner: impl Unborrow<Target = T>, | 65 | inner: impl Unborrow<Target = T> + 'd, |
| 66 | clk: impl Unborrow<Target = impl ClkPin<T>>, | 66 | clk: impl Unborrow<Target = impl ClkPin<T>> + 'd, |
| 67 | mosi: impl Unborrow<Target = impl MosiPin<T>>, | 67 | mosi: impl Unborrow<Target = impl MosiPin<T>> + 'd, |
| 68 | miso: impl Unborrow<Target = impl MisoPin<T>>, | 68 | miso: impl Unborrow<Target = impl MisoPin<T>> + 'd, |
| 69 | cs: impl Unborrow<Target = impl CsPin<T>>, | 69 | cs: impl Unborrow<Target = impl CsPin<T>> + 'd, |
| 70 | config: Config, | 70 | config: Config, |
| 71 | ) -> Self { | 71 | ) -> Self { |
| 72 | unborrow!(inner, clk, mosi, miso, cs); | 72 | unborrow!(inner, clk, mosi, miso, cs); |
diff --git a/embassy-rp/src/uart.rs b/embassy-rp/src/uart.rs index 3f5c49079..0d85be860 100644 --- a/embassy-rp/src/uart.rs +++ b/embassy-rp/src/uart.rs | |||
| @@ -30,11 +30,11 @@ pub struct Uart<'d, T: Instance> { | |||
| 30 | 30 | ||
| 31 | impl<'d, T: Instance> Uart<'d, T> { | 31 | impl<'d, T: Instance> Uart<'d, T> { |
| 32 | pub fn new( | 32 | pub fn new( |
| 33 | inner: impl Unborrow<Target = T>, | 33 | inner: impl Unborrow<Target = T> + 'd, |
| 34 | tx: impl Unborrow<Target = impl TxPin<T>>, | 34 | tx: impl Unborrow<Target = impl TxPin<T>> + 'd, |
| 35 | rx: impl Unborrow<Target = impl RxPin<T>>, | 35 | rx: impl Unborrow<Target = impl RxPin<T>> + 'd, |
| 36 | cts: impl Unborrow<Target = impl CtsPin<T>>, | 36 | cts: impl Unborrow<Target = impl CtsPin<T>> + 'd, |
| 37 | rts: impl Unborrow<Target = impl RtsPin<T>>, | 37 | rts: impl Unborrow<Target = impl RtsPin<T>> + 'd, |
| 38 | config: Config, | 38 | config: Config, |
| 39 | ) -> Self { | 39 | ) -> Self { |
| 40 | unborrow!(inner, tx, rx, cts, rts); | 40 | unborrow!(inner, tx, rx, cts, rts); |
diff --git a/embassy-stm32/src/crc/v1.rs b/embassy-stm32/src/crc/v1.rs index c33eea316..c657192e2 100644 --- a/embassy-stm32/src/crc/v1.rs +++ b/embassy-stm32/src/crc/v1.rs | |||
| @@ -1,16 +1,19 @@ | |||
| 1 | use core::marker::PhantomData; | ||
| 2 | |||
| 1 | use crate::pac::CRC as PAC_CRC; | 3 | use crate::pac::CRC as PAC_CRC; |
| 2 | use crate::peripherals::CRC; | 4 | use crate::peripherals::CRC; |
| 3 | use crate::rcc::sealed::RccPeripheral; | 5 | use crate::rcc::sealed::RccPeripheral; |
| 4 | use embassy::util::Unborrow; | 6 | use embassy::util::Unborrow; |
| 5 | use embassy_hal_common::unborrow; | 7 | use embassy_hal_common::unborrow; |
| 6 | 8 | ||
| 7 | pub struct Crc { | 9 | pub struct Crc<'d> { |
| 8 | _peripheral: CRC, | 10 | _peripheral: CRC, |
| 11 | _phantom: PhantomData<&'d mut CRC>, | ||
| 9 | } | 12 | } |
| 10 | 13 | ||
| 11 | impl Crc { | 14 | impl<'d> Crc<'d> { |
| 12 | /// Instantiates the CRC32 peripheral and initializes it to default values. | 15 | /// Instantiates the CRC32 peripheral and initializes it to default values. |
| 13 | pub fn new(peripheral: impl Unborrow<Target = CRC>) -> Self { | 16 | pub fn new(peripheral: impl Unborrow<Target = CRC> + 'd) -> Self { |
| 14 | // Note: enable and reset come from RccPeripheral. | 17 | // Note: enable and reset come from RccPeripheral. |
| 15 | // enable CRC clock in RCC. | 18 | // enable CRC clock in RCC. |
| 16 | CRC::enable(); | 19 | CRC::enable(); |
| @@ -20,6 +23,7 @@ impl Crc { | |||
| 20 | unborrow!(peripheral); | 23 | unborrow!(peripheral); |
| 21 | let mut instance = Self { | 24 | let mut instance = Self { |
| 22 | _peripheral: peripheral, | 25 | _peripheral: peripheral, |
| 26 | _phantom: PhantomData, | ||
| 23 | }; | 27 | }; |
| 24 | instance.reset(); | 28 | instance.reset(); |
| 25 | instance | 29 | instance |
diff --git a/embassy-stm32/src/crc/v2v3.rs b/embassy-stm32/src/crc/v2v3.rs index 1ca529568..77cd3da1a 100644 --- a/embassy-stm32/src/crc/v2v3.rs +++ b/embassy-stm32/src/crc/v2v3.rs | |||
| @@ -1,3 +1,5 @@ | |||
| 1 | use core::marker::PhantomData; | ||
| 2 | |||
| 1 | use crate::pac::crc::vals; | 3 | use crate::pac::crc::vals; |
| 2 | use crate::pac::CRC as PAC_CRC; | 4 | use crate::pac::CRC as PAC_CRC; |
| 3 | use crate::peripherals::CRC; | 5 | use crate::peripherals::CRC; |
| @@ -5,8 +7,9 @@ use crate::rcc::sealed::RccPeripheral; | |||
| 5 | use embassy::util::Unborrow; | 7 | use embassy::util::Unborrow; |
| 6 | use embassy_hal_common::unborrow; | 8 | use embassy_hal_common::unborrow; |
| 7 | 9 | ||
| 8 | pub struct Crc { | 10 | pub struct Crc<'d> { |
| 9 | _peripheral: CRC, | 11 | _peripheral: CRC, |
| 12 | _phantom: PhantomData<&'d mut CRC>, | ||
| 10 | _config: Config, | 13 | _config: Config, |
| 11 | } | 14 | } |
| 12 | 15 | ||
| @@ -64,9 +67,9 @@ pub enum PolySize { | |||
| 64 | Width32, | 67 | Width32, |
| 65 | } | 68 | } |
| 66 | 69 | ||
| 67 | impl Crc { | 70 | impl<'d> Crc<'d> { |
| 68 | /// Instantiates the CRC32 peripheral and initializes it to default values. | 71 | /// Instantiates the CRC32 peripheral and initializes it to default values. |
| 69 | pub fn new(peripheral: impl Unborrow<Target = CRC>, config: Config) -> Self { | 72 | pub fn new(peripheral: impl Unborrow<Target = CRC> + 'd, config: Config) -> Self { |
| 70 | // Note: enable and reset come from RccPeripheral. | 73 | // Note: enable and reset come from RccPeripheral. |
| 71 | // enable CRC clock in RCC. | 74 | // enable CRC clock in RCC. |
| 72 | CRC::enable(); | 75 | CRC::enable(); |
| @@ -75,6 +78,7 @@ impl Crc { | |||
| 75 | unborrow!(peripheral); | 78 | unborrow!(peripheral); |
| 76 | let mut instance = Self { | 79 | let mut instance = Self { |
| 77 | _peripheral: peripheral, | 80 | _peripheral: peripheral, |
| 81 | _phantom: PhantomData, | ||
| 78 | _config: config, | 82 | _config: config, |
| 79 | }; | 83 | }; |
| 80 | CRC::reset(); | 84 | CRC::reset(); |
diff --git a/embassy-stm32/src/i2c/v1.rs b/embassy-stm32/src/i2c/v1.rs index aa5268987..922c1c7e8 100644 --- a/embassy-stm32/src/i2c/v1.rs +++ b/embassy-stm32/src/i2c/v1.rs | |||
| @@ -15,8 +15,8 @@ pub struct I2c<'d, T: Instance> { | |||
| 15 | impl<'d, T: Instance> I2c<'d, T> { | 15 | impl<'d, T: Instance> I2c<'d, T> { |
| 16 | pub fn new<F>( | 16 | pub fn new<F>( |
| 17 | _peri: impl Unborrow<Target = T> + 'd, | 17 | _peri: impl Unborrow<Target = T> + 'd, |
| 18 | scl: impl Unborrow<Target = impl SclPin<T>>, | 18 | scl: impl Unborrow<Target = impl SclPin<T>> + 'd, |
| 19 | sda: impl Unborrow<Target = impl SdaPin<T>>, | 19 | sda: impl Unborrow<Target = impl SdaPin<T>> + 'd, |
| 20 | freq: F, | 20 | freq: F, |
| 21 | ) -> Self | 21 | ) -> Self |
| 22 | where | 22 | where |
diff --git a/embassy-stm32/src/rng.rs b/embassy-stm32/src/rng.rs index bfacdeefa..032fee011 100644 --- a/embassy-stm32/src/rng.rs +++ b/embassy-stm32/src/rng.rs | |||
| @@ -1,5 +1,6 @@ | |||
| 1 | #![macro_use] | 1 | #![macro_use] |
| 2 | 2 | ||
| 3 | use core::marker::PhantomData; | ||
| 3 | use core::task::Poll; | 4 | use core::task::Poll; |
| 4 | use embassy::util::Unborrow; | 5 | use embassy::util::Unborrow; |
| 5 | use embassy::waitqueue::AtomicWaker; | 6 | use embassy::waitqueue::AtomicWaker; |
| @@ -18,16 +19,20 @@ pub enum Error { | |||
| 18 | ClockError, | 19 | ClockError, |
| 19 | } | 20 | } |
| 20 | 21 | ||
| 21 | pub struct Rng<T: Instance> { | 22 | pub struct Rng<'d, T: Instance> { |
| 22 | _inner: T, | 23 | _inner: T, |
| 24 | _phantom: PhantomData<&'d mut T>, | ||
| 23 | } | 25 | } |
| 24 | 26 | ||
| 25 | impl<T: Instance> Rng<T> { | 27 | impl<'d, T: Instance> Rng<'d, T> { |
| 26 | pub fn new(inner: impl Unborrow<Target = T>) -> Self { | 28 | pub fn new(inner: impl Unborrow<Target = T> + 'd) -> Self { |
| 27 | T::enable(); | 29 | T::enable(); |
| 28 | T::reset(); | 30 | T::reset(); |
| 29 | unborrow!(inner); | 31 | unborrow!(inner); |
| 30 | let mut random = Self { _inner: inner }; | 32 | let mut random = Self { |
| 33 | _inner: inner, | ||
| 34 | _phantom: PhantomData, | ||
| 35 | }; | ||
| 31 | random.reset(); | 36 | random.reset(); |
| 32 | random | 37 | random |
| 33 | } | 38 | } |
| @@ -88,7 +93,7 @@ impl<T: Instance> Rng<T> { | |||
| 88 | } | 93 | } |
| 89 | } | 94 | } |
| 90 | 95 | ||
| 91 | impl<T: Instance> RngCore for Rng<T> { | 96 | impl<'d, T: Instance> RngCore for Rng<'d, T> { |
| 92 | fn next_u32(&mut self) -> u32 { | 97 | fn next_u32(&mut self) -> u32 { |
| 93 | loop { | 98 | loop { |
| 94 | let bits = unsafe { T::regs().sr().read() }; | 99 | let bits = unsafe { T::regs().sr().read() }; |
| @@ -119,7 +124,7 @@ impl<T: Instance> RngCore for Rng<T> { | |||
| 119 | } | 124 | } |
| 120 | } | 125 | } |
| 121 | 126 | ||
| 122 | impl<T: Instance> CryptoRng for Rng<T> {} | 127 | impl<'d, T: Instance> CryptoRng for Rng<'d, T> {} |
| 123 | 128 | ||
| 124 | pub(crate) mod sealed { | 129 | pub(crate) mod sealed { |
| 125 | use super::*; | 130 | use super::*; |
diff --git a/embassy-stm32/src/sdmmc/v2.rs b/embassy-stm32/src/sdmmc/v2.rs index 74382ce64..784a07f5b 100644 --- a/embassy-stm32/src/sdmmc/v2.rs +++ b/embassy-stm32/src/sdmmc/v2.rs | |||
| @@ -189,7 +189,7 @@ impl<'d, T: Instance, P: Pins<T>> Sdmmc<'d, T, P> { | |||
| 189 | pub unsafe fn new( | 189 | pub unsafe fn new( |
| 190 | _peripheral: impl Unborrow<Target = T> + 'd, | 190 | _peripheral: impl Unborrow<Target = T> + 'd, |
| 191 | pins: impl Unborrow<Target = P> + 'd, | 191 | pins: impl Unborrow<Target = P> + 'd, |
| 192 | irq: impl Unborrow<Target = T::Interrupt>, | 192 | irq: impl Unborrow<Target = T::Interrupt> + 'd, |
| 193 | config: Config, | 193 | config: Config, |
| 194 | ) -> Self { | 194 | ) -> Self { |
| 195 | unborrow!(irq, pins); | 195 | unborrow!(irq, pins); |
diff --git a/embassy-stm32/src/spi/mod.rs b/embassy-stm32/src/spi/mod.rs index 469216236..c0cd56fc3 100644 --- a/embassy-stm32/src/spi/mod.rs +++ b/embassy-stm32/src/spi/mod.rs | |||
| @@ -202,8 +202,8 @@ impl<'d, T: Instance, Tx, Rx> Spi<'d, T, Tx, Rx> { | |||
| 202 | sck: Option<AnyPin>, | 202 | sck: Option<AnyPin>, |
| 203 | mosi: Option<AnyPin>, | 203 | mosi: Option<AnyPin>, |
| 204 | miso: Option<AnyPin>, | 204 | miso: Option<AnyPin>, |
| 205 | txdma: impl Unborrow<Target = Tx>, | 205 | txdma: impl Unborrow<Target = Tx> + 'd, |
| 206 | rxdma: impl Unborrow<Target = Rx>, | 206 | rxdma: impl Unborrow<Target = Rx> + 'd, |
| 207 | freq: F, | 207 | freq: F, |
| 208 | config: Config, | 208 | config: Config, |
| 209 | ) -> Self | 209 | ) -> Self |
diff --git a/embassy-stm32/src/usart/mod.rs b/embassy-stm32/src/usart/mod.rs index a391379c8..5f0281f46 100644 --- a/embassy-stm32/src/usart/mod.rs +++ b/embassy-stm32/src/usart/mod.rs | |||
| @@ -81,11 +81,11 @@ pub struct Uart<'d, T: Instance, TxDma = NoDma, RxDma = NoDma> { | |||
| 81 | 81 | ||
| 82 | impl<'d, T: Instance, TxDma, RxDma> Uart<'d, T, TxDma, RxDma> { | 82 | impl<'d, T: Instance, TxDma, RxDma> Uart<'d, T, TxDma, RxDma> { |
| 83 | pub fn new( | 83 | pub fn new( |
| 84 | inner: impl Unborrow<Target = T>, | 84 | inner: impl Unborrow<Target = T> + 'd, |
| 85 | rx: impl Unborrow<Target = impl RxPin<T>>, | 85 | rx: impl Unborrow<Target = impl RxPin<T>> + 'd, |
| 86 | tx: impl Unborrow<Target = impl TxPin<T>>, | 86 | tx: impl Unborrow<Target = impl TxPin<T>> + 'd, |
| 87 | tx_dma: impl Unborrow<Target = TxDma>, | 87 | tx_dma: impl Unborrow<Target = TxDma> + 'd, |
| 88 | rx_dma: impl Unborrow<Target = RxDma>, | 88 | rx_dma: impl Unborrow<Target = RxDma> + 'd, |
| 89 | config: Config, | 89 | config: Config, |
| 90 | ) -> Self { | 90 | ) -> Self { |
| 91 | unborrow!(inner, rx, tx, tx_dma, rx_dma); | 91 | unborrow!(inner, rx, tx, tx_dma, rx_dma); |
