nrf/gpio: Rename FlexPin to Flex.
FlexPin sounds like it's an owned pin singleton, like AnyPin or NoPin.
This commit is contained in:
parent
ecb4f8fb00
commit
3ca01cba8d
@ -37,12 +37,12 @@ pub enum Pull {
|
|||||||
|
|
||||||
/// GPIO input driver.
|
/// GPIO input driver.
|
||||||
pub struct Input<'d, T: Pin> {
|
pub struct Input<'d, T: Pin> {
|
||||||
pub(crate) pin: FlexPin<'d, T>,
|
pub(crate) pin: Flex<'d, T>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'d, T: Pin> Input<'d, T> {
|
impl<'d, T: Pin> Input<'d, T> {
|
||||||
pub fn new(pin: impl Unborrow<Target = T> + 'd, pull: Pull) -> Self {
|
pub fn new(pin: impl Unborrow<Target = T> + 'd, pull: Pull) -> Self {
|
||||||
let mut pin = FlexPin::new(pin);
|
let mut pin = Flex::new(pin);
|
||||||
pin.set_as_input(pull);
|
pin.set_as_input(pull);
|
||||||
|
|
||||||
Self { pin }
|
Self { pin }
|
||||||
@ -102,7 +102,7 @@ pub enum OutputDrive {
|
|||||||
|
|
||||||
/// GPIO output driver.
|
/// GPIO output driver.
|
||||||
pub struct Output<'d, T: Pin> {
|
pub struct Output<'d, T: Pin> {
|
||||||
pub(crate) pin: FlexPin<'d, T>,
|
pub(crate) pin: Flex<'d, T>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'d, T: Pin> Output<'d, T> {
|
impl<'d, T: Pin> Output<'d, T> {
|
||||||
@ -111,7 +111,7 @@ impl<'d, T: Pin> Output<'d, T> {
|
|||||||
initial_output: Level,
|
initial_output: Level,
|
||||||
drive: OutputDrive,
|
drive: OutputDrive,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
let mut pin = FlexPin::new(pin);
|
let mut pin = Flex::new(pin);
|
||||||
match initial_output {
|
match initial_output {
|
||||||
Level::High => pin.set_high(),
|
Level::High => pin.set_high(),
|
||||||
Level::Low => pin.set_low(),
|
Level::Low => pin.set_low(),
|
||||||
@ -169,13 +169,13 @@ impl<'d, T: Pin> StatefulOutputPin for Output<'d, T> {
|
|||||||
/// This pin can either be a disconnected, input, or output pin. The level register bit will remain
|
/// This pin can either be a disconnected, input, or output pin. The level register bit will remain
|
||||||
/// set while not in output mode, so the pin's level will be 'remembered' when it is not in output
|
/// set while not in output mode, so the pin's level will be 'remembered' when it is not in output
|
||||||
/// mode.
|
/// mode.
|
||||||
pub struct FlexPin<'d, T: Pin> {
|
pub struct Flex<'d, T: Pin> {
|
||||||
pub(crate) pin: T,
|
pub(crate) pin: T,
|
||||||
phantom: PhantomData<&'d mut T>,
|
phantom: PhantomData<&'d mut T>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'d, T: Pin> FlexPin<'d, T> {
|
impl<'d, T: Pin> Flex<'d, T> {
|
||||||
/// Wrap the pin in a `FlexPin`.
|
/// Wrap the pin in a `Flex`.
|
||||||
///
|
///
|
||||||
/// The pin remains disconnected. The initial output level is unspecified, but can be changed
|
/// The pin remains disconnected. The initial output level is unspecified, but can be changed
|
||||||
/// before the pin is put into output mode.
|
/// before the pin is put into output mode.
|
||||||
@ -270,16 +270,16 @@ impl<'d, T: Pin> FlexPin<'d, T> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'d, T: Pin> Drop for FlexPin<'d, T> {
|
impl<'d, T: Pin> Drop for Flex<'d, T> {
|
||||||
fn drop(&mut self) {
|
fn drop(&mut self) {
|
||||||
self.pin.conf().reset();
|
self.pin.conf().reset();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Implement [`InputPin`] for [`FlexPin`];
|
/// Implement [`InputPin`] for [`Flex`];
|
||||||
///
|
///
|
||||||
/// If the pin is not in input mode the result is unspecified.
|
/// If the pin is not in input mode the result is unspecified.
|
||||||
impl<'d, T: Pin> InputPin for FlexPin<'d, T> {
|
impl<'d, T: Pin> InputPin for Flex<'d, T> {
|
||||||
type Error = Infallible;
|
type Error = Infallible;
|
||||||
|
|
||||||
fn is_high(&self) -> Result<bool, Self::Error> {
|
fn is_high(&self) -> Result<bool, Self::Error> {
|
||||||
@ -291,7 +291,7 @@ impl<'d, T: Pin> InputPin for FlexPin<'d, T> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'d, T: Pin> OutputPin for FlexPin<'d, T> {
|
impl<'d, T: Pin> OutputPin for Flex<'d, T> {
|
||||||
type Error = Infallible;
|
type Error = Infallible;
|
||||||
|
|
||||||
fn set_high(&mut self) -> Result<(), Self::Error> {
|
fn set_high(&mut self) -> Result<(), Self::Error> {
|
||||||
@ -303,7 +303,7 @@ impl<'d, T: Pin> OutputPin for FlexPin<'d, T> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'d, T: Pin> StatefulOutputPin for FlexPin<'d, T> {
|
impl<'d, T: Pin> StatefulOutputPin for Flex<'d, T> {
|
||||||
fn is_set_high(&self) -> Result<bool, Self::Error> {
|
fn is_set_high(&self) -> Result<bool, Self::Error> {
|
||||||
Ok(self.is_set_high())
|
Ok(self.is_set_high())
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,7 @@ use embedded_hal::digital::v2::InputPin;
|
|||||||
use futures::future::poll_fn;
|
use futures::future::poll_fn;
|
||||||
|
|
||||||
use crate::gpio::sealed::Pin as _;
|
use crate::gpio::sealed::Pin as _;
|
||||||
use crate::gpio::{AnyPin, FlexPin, Input, Output, Pin as GpioPin};
|
use crate::gpio::{AnyPin, Flex, Input, Output, Pin as GpioPin};
|
||||||
use crate::pac;
|
use crate::pac;
|
||||||
use crate::ppi::{Event, Task};
|
use crate::ppi::{Event, Task};
|
||||||
use crate::{interrupt, peripherals};
|
use crate::{interrupt, peripherals};
|
||||||
@ -375,7 +375,7 @@ impl<'d, T: GpioPin> embassy::traits::gpio::WaitForAnyEdge for Input<'d, T> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'d, T: GpioPin> embassy::traits::gpio::WaitForHigh for FlexPin<'d, T> {
|
impl<'d, T: GpioPin> embassy::traits::gpio::WaitForHigh for Flex<'d, T> {
|
||||||
type Future<'a>
|
type Future<'a>
|
||||||
where
|
where
|
||||||
Self: 'a,
|
Self: 'a,
|
||||||
@ -391,7 +391,7 @@ impl<'d, T: GpioPin> embassy::traits::gpio::WaitForHigh for FlexPin<'d, T> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'d, T: GpioPin> embassy::traits::gpio::WaitForLow for FlexPin<'d, T> {
|
impl<'d, T: GpioPin> embassy::traits::gpio::WaitForLow for Flex<'d, T> {
|
||||||
type Future<'a>
|
type Future<'a>
|
||||||
where
|
where
|
||||||
Self: 'a,
|
Self: 'a,
|
||||||
@ -407,7 +407,7 @@ impl<'d, T: GpioPin> embassy::traits::gpio::WaitForLow for FlexPin<'d, T> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'d, T: GpioPin> embassy::traits::gpio::WaitForAnyEdge for FlexPin<'d, T> {
|
impl<'d, T: GpioPin> embassy::traits::gpio::WaitForAnyEdge for Flex<'d, T> {
|
||||||
type Future<'a>
|
type Future<'a>
|
||||||
where
|
where
|
||||||
Self: 'a,
|
Self: 'a,
|
||||||
|
Loading…
Reference in New Issue
Block a user