Rename Unborrowed -> PeripheralRef, Unborrow -> Peripheral
This commit is contained in:
@ -1,10 +1,10 @@
|
||||
use embassy_embedded_hal::SetConfig;
|
||||
use embassy_hal_common::{unborrow, Unborrowed};
|
||||
use embassy_hal_common::{into_ref, PeripheralRef};
|
||||
pub use embedded_hal_02::spi::{Phase, Polarity};
|
||||
|
||||
use crate::gpio::sealed::Pin as _;
|
||||
use crate::gpio::{AnyPin, Pin as GpioPin};
|
||||
use crate::{pac, peripherals, Unborrow};
|
||||
use crate::{pac, peripherals, Peripheral};
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
|
||||
@ -31,7 +31,7 @@ impl Default for Config {
|
||||
}
|
||||
|
||||
pub struct Spi<'d, T: Instance> {
|
||||
inner: Unborrowed<'d, T>,
|
||||
inner: PeripheralRef<'d, T>,
|
||||
}
|
||||
|
||||
fn div_roundup(a: u32, b: u32) -> u32 {
|
||||
@ -59,45 +59,45 @@ fn calc_prescs(freq: u32) -> (u8, u8) {
|
||||
|
||||
impl<'d, T: Instance> Spi<'d, T> {
|
||||
pub fn new(
|
||||
inner: impl Unborrow<Target = T> + 'd,
|
||||
clk: impl Unborrow<Target = impl ClkPin<T> + 'd> + 'd,
|
||||
mosi: impl Unborrow<Target = impl MosiPin<T> + 'd> + 'd,
|
||||
miso: impl Unborrow<Target = impl MisoPin<T> + 'd> + 'd,
|
||||
inner: impl Peripheral<P = T> + 'd,
|
||||
clk: impl Peripheral<P = impl ClkPin<T> + 'd> + 'd,
|
||||
mosi: impl Peripheral<P = impl MosiPin<T> + 'd> + 'd,
|
||||
miso: impl Peripheral<P = impl MisoPin<T> + 'd> + 'd,
|
||||
config: Config,
|
||||
) -> Self {
|
||||
unborrow_and_degrade!(clk, mosi, miso);
|
||||
into_degraded_ref!(clk, mosi, miso);
|
||||
Self::new_inner(inner, Some(clk), Some(mosi), Some(miso), None, config)
|
||||
}
|
||||
|
||||
pub fn new_txonly(
|
||||
inner: impl Unborrow<Target = T> + 'd,
|
||||
clk: impl Unborrow<Target = impl ClkPin<T> + 'd> + 'd,
|
||||
mosi: impl Unborrow<Target = impl MosiPin<T> + 'd> + 'd,
|
||||
inner: impl Peripheral<P = T> + 'd,
|
||||
clk: impl Peripheral<P = impl ClkPin<T> + 'd> + 'd,
|
||||
mosi: impl Peripheral<P = impl MosiPin<T> + 'd> + 'd,
|
||||
config: Config,
|
||||
) -> Self {
|
||||
unborrow_and_degrade!(clk, mosi);
|
||||
into_degraded_ref!(clk, mosi);
|
||||
Self::new_inner(inner, Some(clk), Some(mosi), None, None, config)
|
||||
}
|
||||
|
||||
pub fn new_rxonly(
|
||||
inner: impl Unborrow<Target = T> + 'd,
|
||||
clk: impl Unborrow<Target = impl ClkPin<T> + 'd> + 'd,
|
||||
miso: impl Unborrow<Target = impl MisoPin<T> + 'd> + 'd,
|
||||
inner: impl Peripheral<P = T> + 'd,
|
||||
clk: impl Peripheral<P = impl ClkPin<T> + 'd> + 'd,
|
||||
miso: impl Peripheral<P = impl MisoPin<T> + 'd> + 'd,
|
||||
config: Config,
|
||||
) -> Self {
|
||||
unborrow_and_degrade!(clk, miso);
|
||||
into_degraded_ref!(clk, miso);
|
||||
Self::new_inner(inner, Some(clk), None, Some(miso), None, config)
|
||||
}
|
||||
|
||||
fn new_inner(
|
||||
inner: impl Unborrow<Target = T> + 'd,
|
||||
clk: Option<Unborrowed<'d, AnyPin>>,
|
||||
mosi: Option<Unborrowed<'d, AnyPin>>,
|
||||
miso: Option<Unborrowed<'d, AnyPin>>,
|
||||
cs: Option<Unborrowed<'d, AnyPin>>,
|
||||
inner: impl Peripheral<P = T> + 'd,
|
||||
clk: Option<PeripheralRef<'d, AnyPin>>,
|
||||
mosi: Option<PeripheralRef<'d, AnyPin>>,
|
||||
miso: Option<PeripheralRef<'d, AnyPin>>,
|
||||
cs: Option<PeripheralRef<'d, AnyPin>>,
|
||||
config: Config,
|
||||
) -> Self {
|
||||
unborrow!(inner);
|
||||
into_ref!(inner);
|
||||
|
||||
unsafe {
|
||||
let p = inner.regs();
|
||||
|
Reference in New Issue
Block a user