Rename Unborrowed -> PeripheralRef, Unborrow -> Peripheral

This commit is contained in:
Dario Nieuwenhuis
2022-07-23 14:00:19 +02:00
parent 8a9d2f59af
commit 4901c34d9c
62 changed files with 970 additions and 918 deletions

View File

@ -1,8 +1,8 @@
use embassy_hal_common::{unborrow, Unborrowed};
use embassy_hal_common::{into_ref, PeripheralRef};
use crate::dac::{DacPin, Instance};
use crate::pac::dac;
use crate::Unborrow;
use crate::Peripheral;
#[derive(Debug, Copy, Clone, Eq, PartialEq)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
@ -88,7 +88,7 @@ pub enum Value {
pub struct Dac<'d, T: Instance> {
channels: u8,
_peri: Unborrowed<'d, T>,
_peri: PeripheralRef<'d, T>,
}
macro_rules! enable {
@ -100,21 +100,21 @@ macro_rules! enable {
}
impl<'d, T: Instance> Dac<'d, T> {
pub fn new_1ch(peri: impl Unborrow<Target = T> + 'd, _ch1: impl Unborrow<Target = impl DacPin<T, 1>> + 'd) -> Self {
unborrow!(peri);
pub fn new_1ch(peri: impl Peripheral<P = T> + 'd, _ch1: impl Peripheral<P = impl DacPin<T, 1>> + 'd) -> Self {
into_ref!(peri);
Self::new_inner(peri, 1)
}
pub fn new_2ch(
peri: impl Unborrow<Target = T> + 'd,
_ch1: impl Unborrow<Target = impl DacPin<T, 1>> + 'd,
_ch2: impl Unborrow<Target = impl DacPin<T, 2>> + 'd,
peri: impl Peripheral<P = T> + 'd,
_ch1: impl Peripheral<P = impl DacPin<T, 1>> + 'd,
_ch2: impl Peripheral<P = impl DacPin<T, 2>> + 'd,
) -> Self {
unborrow!(peri);
into_ref!(peri);
Self::new_inner(peri, 2)
}
fn new_inner(peri: Unborrowed<'d, T>, channels: u8) -> Self {
fn new_inner(peri: PeripheralRef<'d, T>, channels: u8) -> Self {
unsafe {
// Sadly we cannot use `RccPeripheral::enable` since devices are quite inconsistent DAC clock
// configuration.