Rename Unborrowed -> PeripheralRef, Unborrow -> Peripheral
This commit is contained in:
@ -5,7 +5,7 @@ use core::sync::atomic::{compiler_fence, Ordering};
|
||||
use core::task::Poll;
|
||||
|
||||
use embassy_embedded_hal::SetConfig;
|
||||
use embassy_hal_common::{unborrow, Unborrowed};
|
||||
use embassy_hal_common::{into_ref, PeripheralRef};
|
||||
pub use embedded_hal_02::spi::{Mode, Phase, Polarity, MODE_0, MODE_1, MODE_2, MODE_3};
|
||||
use futures::future::poll_fn;
|
||||
pub use pac::spim0::frequency::FREQUENCY_A as Frequency;
|
||||
@ -15,7 +15,7 @@ use crate::gpio::sealed::Pin as _;
|
||||
use crate::gpio::{self, AnyPin, Pin as GpioPin, PselBits};
|
||||
use crate::interrupt::{Interrupt, InterruptExt};
|
||||
use crate::util::{slice_in_ram_or, slice_ptr_parts, slice_ptr_parts_mut};
|
||||
use crate::{pac, Unborrow};
|
||||
use crate::{pac, Peripheral};
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
|
||||
@ -53,48 +53,48 @@ impl Default for Config {
|
||||
|
||||
impl<'d, T: Instance> Spim<'d, T> {
|
||||
pub fn new(
|
||||
spim: impl Unborrow<Target = T> + 'd,
|
||||
irq: impl Unborrow<Target = T::Interrupt> + 'd,
|
||||
sck: impl Unborrow<Target = impl GpioPin> + 'd,
|
||||
miso: impl Unborrow<Target = impl GpioPin> + 'd,
|
||||
mosi: impl Unborrow<Target = impl GpioPin> + 'd,
|
||||
spim: impl Peripheral<P = T> + 'd,
|
||||
irq: impl Peripheral<P = T::Interrupt> + 'd,
|
||||
sck: impl Peripheral<P = impl GpioPin> + 'd,
|
||||
miso: impl Peripheral<P = impl GpioPin> + 'd,
|
||||
mosi: impl Peripheral<P = impl GpioPin> + 'd,
|
||||
config: Config,
|
||||
) -> Self {
|
||||
unborrow_and_degrade!(sck, miso, mosi);
|
||||
into_degraded_ref!(sck, miso, mosi);
|
||||
Self::new_inner(spim, irq, sck, Some(miso), Some(mosi), config)
|
||||
}
|
||||
|
||||
pub fn new_txonly(
|
||||
spim: impl Unborrow<Target = T> + 'd,
|
||||
irq: impl Unborrow<Target = T::Interrupt> + 'd,
|
||||
sck: impl Unborrow<Target = impl GpioPin> + 'd,
|
||||
mosi: impl Unborrow<Target = impl GpioPin> + 'd,
|
||||
spim: impl Peripheral<P = T> + 'd,
|
||||
irq: impl Peripheral<P = T::Interrupt> + 'd,
|
||||
sck: impl Peripheral<P = impl GpioPin> + 'd,
|
||||
mosi: impl Peripheral<P = impl GpioPin> + 'd,
|
||||
config: Config,
|
||||
) -> Self {
|
||||
unborrow_and_degrade!(sck, mosi);
|
||||
into_degraded_ref!(sck, mosi);
|
||||
Self::new_inner(spim, irq, sck, None, Some(mosi), config)
|
||||
}
|
||||
|
||||
pub fn new_rxonly(
|
||||
spim: impl Unborrow<Target = T> + 'd,
|
||||
irq: impl Unborrow<Target = T::Interrupt> + 'd,
|
||||
sck: impl Unborrow<Target = impl GpioPin> + 'd,
|
||||
miso: impl Unborrow<Target = impl GpioPin> + 'd,
|
||||
spim: impl Peripheral<P = T> + 'd,
|
||||
irq: impl Peripheral<P = T::Interrupt> + 'd,
|
||||
sck: impl Peripheral<P = impl GpioPin> + 'd,
|
||||
miso: impl Peripheral<P = impl GpioPin> + 'd,
|
||||
config: Config,
|
||||
) -> Self {
|
||||
unborrow_and_degrade!(sck, miso);
|
||||
into_degraded_ref!(sck, miso);
|
||||
Self::new_inner(spim, irq, sck, Some(miso), None, config)
|
||||
}
|
||||
|
||||
fn new_inner(
|
||||
_spim: impl Unborrow<Target = T> + 'd,
|
||||
irq: impl Unborrow<Target = T::Interrupt> + 'd,
|
||||
sck: Unborrowed<'d, AnyPin>,
|
||||
miso: Option<Unborrowed<'d, AnyPin>>,
|
||||
mosi: Option<Unborrowed<'d, AnyPin>>,
|
||||
_spim: impl Peripheral<P = T> + 'd,
|
||||
irq: impl Peripheral<P = T::Interrupt> + 'd,
|
||||
sck: PeripheralRef<'d, AnyPin>,
|
||||
miso: Option<PeripheralRef<'d, AnyPin>>,
|
||||
mosi: Option<PeripheralRef<'d, AnyPin>>,
|
||||
config: Config,
|
||||
) -> Self {
|
||||
unborrow!(irq);
|
||||
into_ref!(irq);
|
||||
|
||||
let r = T::regs();
|
||||
|
||||
@ -379,7 +379,7 @@ pub(crate) mod sealed {
|
||||
}
|
||||
}
|
||||
|
||||
pub trait Instance: Unborrow<Target = Self> + sealed::Instance + 'static {
|
||||
pub trait Instance: Peripheral<P = Self> + sealed::Instance + 'static {
|
||||
type Interrupt: Interrupt;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user