Add missing + 'd
on unborrows.
This commit is contained in:
parent
550da471be
commit
a8bd3ab952
@ -62,11 +62,11 @@ fn calc_prescs(freq: u32) -> (u8, u8) {
|
|||||||
|
|
||||||
impl<'d, T: Instance> Spi<'d, T> {
|
impl<'d, T: Instance> Spi<'d, T> {
|
||||||
pub fn new(
|
pub fn new(
|
||||||
inner: impl Unborrow<Target = T>,
|
inner: impl Unborrow<Target = T> + 'd,
|
||||||
clk: impl Unborrow<Target = impl ClkPin<T>>,
|
clk: impl Unborrow<Target = impl ClkPin<T>> + 'd,
|
||||||
mosi: impl Unborrow<Target = impl MosiPin<T>>,
|
mosi: impl Unborrow<Target = impl MosiPin<T>> + 'd,
|
||||||
miso: impl Unborrow<Target = impl MisoPin<T>>,
|
miso: impl Unborrow<Target = impl MisoPin<T>> + 'd,
|
||||||
cs: impl Unborrow<Target = impl CsPin<T>>,
|
cs: impl Unborrow<Target = impl CsPin<T>> + 'd,
|
||||||
config: Config,
|
config: Config,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
unborrow!(inner, clk, mosi, miso, cs);
|
unborrow!(inner, clk, mosi, miso, cs);
|
||||||
|
@ -30,11 +30,11 @@ pub struct Uart<'d, T: Instance> {
|
|||||||
|
|
||||||
impl<'d, T: Instance> Uart<'d, T> {
|
impl<'d, T: Instance> Uart<'d, T> {
|
||||||
pub fn new(
|
pub fn new(
|
||||||
inner: impl Unborrow<Target = T>,
|
inner: impl Unborrow<Target = T> + 'd,
|
||||||
tx: impl Unborrow<Target = impl TxPin<T>>,
|
tx: impl Unborrow<Target = impl TxPin<T>> + 'd,
|
||||||
rx: impl Unborrow<Target = impl RxPin<T>>,
|
rx: impl Unborrow<Target = impl RxPin<T>> + 'd,
|
||||||
cts: impl Unborrow<Target = impl CtsPin<T>>,
|
cts: impl Unborrow<Target = impl CtsPin<T>> + 'd,
|
||||||
rts: impl Unborrow<Target = impl RtsPin<T>>,
|
rts: impl Unborrow<Target = impl RtsPin<T>> + 'd,
|
||||||
config: Config,
|
config: Config,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
unborrow!(inner, tx, rx, cts, rts);
|
unborrow!(inner, tx, rx, cts, rts);
|
||||||
|
@ -1,16 +1,19 @@
|
|||||||
|
use core::marker::PhantomData;
|
||||||
|
|
||||||
use crate::pac::CRC as PAC_CRC;
|
use crate::pac::CRC as PAC_CRC;
|
||||||
use crate::peripherals::CRC;
|
use crate::peripherals::CRC;
|
||||||
use crate::rcc::sealed::RccPeripheral;
|
use crate::rcc::sealed::RccPeripheral;
|
||||||
use embassy::util::Unborrow;
|
use embassy::util::Unborrow;
|
||||||
use embassy_hal_common::unborrow;
|
use embassy_hal_common::unborrow;
|
||||||
|
|
||||||
pub struct Crc {
|
pub struct Crc<'d> {
|
||||||
_peripheral: CRC,
|
_peripheral: CRC,
|
||||||
|
_phantom: PhantomData<&'d mut CRC>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Crc {
|
impl<'d> Crc<'d> {
|
||||||
/// Instantiates the CRC32 peripheral and initializes it to default values.
|
/// Instantiates the CRC32 peripheral and initializes it to default values.
|
||||||
pub fn new(peripheral: impl Unborrow<Target = CRC>) -> Self {
|
pub fn new(peripheral: impl Unborrow<Target = CRC> + 'd) -> Self {
|
||||||
// Note: enable and reset come from RccPeripheral.
|
// Note: enable and reset come from RccPeripheral.
|
||||||
// enable CRC clock in RCC.
|
// enable CRC clock in RCC.
|
||||||
CRC::enable();
|
CRC::enable();
|
||||||
@ -20,6 +23,7 @@ impl Crc {
|
|||||||
unborrow!(peripheral);
|
unborrow!(peripheral);
|
||||||
let mut instance = Self {
|
let mut instance = Self {
|
||||||
_peripheral: peripheral,
|
_peripheral: peripheral,
|
||||||
|
_phantom: PhantomData,
|
||||||
};
|
};
|
||||||
instance.reset();
|
instance.reset();
|
||||||
instance
|
instance
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
use core::marker::PhantomData;
|
||||||
|
|
||||||
use crate::pac::crc::vals;
|
use crate::pac::crc::vals;
|
||||||
use crate::pac::CRC as PAC_CRC;
|
use crate::pac::CRC as PAC_CRC;
|
||||||
use crate::peripherals::CRC;
|
use crate::peripherals::CRC;
|
||||||
@ -5,8 +7,9 @@ use crate::rcc::sealed::RccPeripheral;
|
|||||||
use embassy::util::Unborrow;
|
use embassy::util::Unborrow;
|
||||||
use embassy_hal_common::unborrow;
|
use embassy_hal_common::unborrow;
|
||||||
|
|
||||||
pub struct Crc {
|
pub struct Crc<'d> {
|
||||||
_peripheral: CRC,
|
_peripheral: CRC,
|
||||||
|
_phantom: PhantomData<&'d mut CRC>,
|
||||||
_config: Config,
|
_config: Config,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -64,9 +67,9 @@ pub enum PolySize {
|
|||||||
Width32,
|
Width32,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Crc {
|
impl<'d> Crc<'d> {
|
||||||
/// Instantiates the CRC32 peripheral and initializes it to default values.
|
/// Instantiates the CRC32 peripheral and initializes it to default values.
|
||||||
pub fn new(peripheral: impl Unborrow<Target = CRC>, config: Config) -> Self {
|
pub fn new(peripheral: impl Unborrow<Target = CRC> + 'd, config: Config) -> Self {
|
||||||
// Note: enable and reset come from RccPeripheral.
|
// Note: enable and reset come from RccPeripheral.
|
||||||
// enable CRC clock in RCC.
|
// enable CRC clock in RCC.
|
||||||
CRC::enable();
|
CRC::enable();
|
||||||
@ -75,6 +78,7 @@ impl Crc {
|
|||||||
unborrow!(peripheral);
|
unborrow!(peripheral);
|
||||||
let mut instance = Self {
|
let mut instance = Self {
|
||||||
_peripheral: peripheral,
|
_peripheral: peripheral,
|
||||||
|
_phantom: PhantomData,
|
||||||
_config: config,
|
_config: config,
|
||||||
};
|
};
|
||||||
CRC::reset();
|
CRC::reset();
|
||||||
|
@ -15,8 +15,8 @@ pub struct I2c<'d, T: Instance> {
|
|||||||
impl<'d, T: Instance> I2c<'d, T> {
|
impl<'d, T: Instance> I2c<'d, T> {
|
||||||
pub fn new<F>(
|
pub fn new<F>(
|
||||||
_peri: impl Unborrow<Target = T> + 'd,
|
_peri: impl Unborrow<Target = T> + 'd,
|
||||||
scl: impl Unborrow<Target = impl SclPin<T>>,
|
scl: impl Unborrow<Target = impl SclPin<T>> + 'd,
|
||||||
sda: impl Unborrow<Target = impl SdaPin<T>>,
|
sda: impl Unborrow<Target = impl SdaPin<T>> + 'd,
|
||||||
freq: F,
|
freq: F,
|
||||||
) -> Self
|
) -> Self
|
||||||
where
|
where
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
#![macro_use]
|
#![macro_use]
|
||||||
|
|
||||||
|
use core::marker::PhantomData;
|
||||||
use core::task::Poll;
|
use core::task::Poll;
|
||||||
use embassy::util::Unborrow;
|
use embassy::util::Unborrow;
|
||||||
use embassy::waitqueue::AtomicWaker;
|
use embassy::waitqueue::AtomicWaker;
|
||||||
@ -18,16 +19,20 @@ pub enum Error {
|
|||||||
ClockError,
|
ClockError,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct Rng<T: Instance> {
|
pub struct Rng<'d, T: Instance> {
|
||||||
_inner: T,
|
_inner: T,
|
||||||
|
_phantom: PhantomData<&'d mut T>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T: Instance> Rng<T> {
|
impl<'d, T: Instance> Rng<'d, T> {
|
||||||
pub fn new(inner: impl Unborrow<Target = T>) -> Self {
|
pub fn new(inner: impl Unborrow<Target = T> + 'd) -> Self {
|
||||||
T::enable();
|
T::enable();
|
||||||
T::reset();
|
T::reset();
|
||||||
unborrow!(inner);
|
unborrow!(inner);
|
||||||
let mut random = Self { _inner: inner };
|
let mut random = Self {
|
||||||
|
_inner: inner,
|
||||||
|
_phantom: PhantomData,
|
||||||
|
};
|
||||||
random.reset();
|
random.reset();
|
||||||
random
|
random
|
||||||
}
|
}
|
||||||
@ -88,7 +93,7 @@ impl<T: Instance> Rng<T> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T: Instance> RngCore for Rng<T> {
|
impl<'d, T: Instance> RngCore for Rng<'d, T> {
|
||||||
fn next_u32(&mut self) -> u32 {
|
fn next_u32(&mut self) -> u32 {
|
||||||
loop {
|
loop {
|
||||||
let bits = unsafe { T::regs().sr().read() };
|
let bits = unsafe { T::regs().sr().read() };
|
||||||
@ -119,7 +124,7 @@ impl<T: Instance> RngCore for Rng<T> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T: Instance> CryptoRng for Rng<T> {}
|
impl<'d, T: Instance> CryptoRng for Rng<'d, T> {}
|
||||||
|
|
||||||
pub(crate) mod sealed {
|
pub(crate) mod sealed {
|
||||||
use super::*;
|
use super::*;
|
||||||
|
@ -189,7 +189,7 @@ impl<'d, T: Instance, P: Pins<T>> Sdmmc<'d, T, P> {
|
|||||||
pub unsafe fn new(
|
pub unsafe fn new(
|
||||||
_peripheral: impl Unborrow<Target = T> + 'd,
|
_peripheral: impl Unborrow<Target = T> + 'd,
|
||||||
pins: impl Unborrow<Target = P> + 'd,
|
pins: impl Unborrow<Target = P> + 'd,
|
||||||
irq: impl Unborrow<Target = T::Interrupt>,
|
irq: impl Unborrow<Target = T::Interrupt> + 'd,
|
||||||
config: Config,
|
config: Config,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
unborrow!(irq, pins);
|
unborrow!(irq, pins);
|
||||||
|
@ -202,8 +202,8 @@ impl<'d, T: Instance, Tx, Rx> Spi<'d, T, Tx, Rx> {
|
|||||||
sck: Option<AnyPin>,
|
sck: Option<AnyPin>,
|
||||||
mosi: Option<AnyPin>,
|
mosi: Option<AnyPin>,
|
||||||
miso: Option<AnyPin>,
|
miso: Option<AnyPin>,
|
||||||
txdma: impl Unborrow<Target = Tx>,
|
txdma: impl Unborrow<Target = Tx> + 'd,
|
||||||
rxdma: impl Unborrow<Target = Rx>,
|
rxdma: impl Unborrow<Target = Rx> + 'd,
|
||||||
freq: F,
|
freq: F,
|
||||||
config: Config,
|
config: Config,
|
||||||
) -> Self
|
) -> Self
|
||||||
|
@ -81,11 +81,11 @@ pub struct Uart<'d, T: Instance, TxDma = NoDma, RxDma = NoDma> {
|
|||||||
|
|
||||||
impl<'d, T: Instance, TxDma, RxDma> Uart<'d, T, TxDma, RxDma> {
|
impl<'d, T: Instance, TxDma, RxDma> Uart<'d, T, TxDma, RxDma> {
|
||||||
pub fn new(
|
pub fn new(
|
||||||
inner: impl Unborrow<Target = T>,
|
inner: impl Unborrow<Target = T> + 'd,
|
||||||
rx: impl Unborrow<Target = impl RxPin<T>>,
|
rx: impl Unborrow<Target = impl RxPin<T>> + 'd,
|
||||||
tx: impl Unborrow<Target = impl TxPin<T>>,
|
tx: impl Unborrow<Target = impl TxPin<T>> + 'd,
|
||||||
tx_dma: impl Unborrow<Target = TxDma>,
|
tx_dma: impl Unborrow<Target = TxDma> + 'd,
|
||||||
rx_dma: impl Unborrow<Target = RxDma>,
|
rx_dma: impl Unborrow<Target = RxDma> + 'd,
|
||||||
config: Config,
|
config: Config,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
unborrow!(inner, rx, tx, tx_dma, rx_dma);
|
unborrow!(inner, rx, tx, tx_dma, rx_dma);
|
||||||
|
Loading…
Reference in New Issue
Block a user