Rename GpioteInput -> PortInput

This commit is contained in:
Dario Nieuwenhuis 2021-03-21 21:01:06 +01:00
parent c0876187dd
commit 95218bf8d4
2 changed files with 12 additions and 12 deletions

View File

@ -8,7 +8,7 @@
mod example_common; mod example_common;
use embassy_nrf::gpio::{AnyPin, Input, Pin as _, Pull}; use embassy_nrf::gpio::{AnyPin, Input, Pin as _, Pull};
use example_common::*; use example_common::*;
use gpiote::GpioteInput; use gpiote::PortInput;
use core::pin::Pin; use core::pin::Pin;
use cortex_m_rt::entry; use cortex_m_rt::entry;
@ -21,7 +21,7 @@ use embassy::util::Forever;
use embassy_nrf::gpiote; use embassy_nrf::gpiote;
use embassy_nrf::interrupt; use embassy_nrf::interrupt;
async fn button(n: usize, mut pin: GpioteInput<AnyPin>) { async fn button(n: usize, mut pin: PortInput<AnyPin>) {
loop { loop {
Pin::new(&mut pin).wait_for_low().await; Pin::new(&mut pin).wait_for_low().await;
info!("Button {:?} pressed!", n); info!("Button {:?} pressed!", n);
@ -38,19 +38,19 @@ async fn run() {
let button1 = button( let button1 = button(
1, 1,
GpioteInput::new(g, Input::new(p.p0_11.degrade(), Pull::Up)), PortInput::new(g, Input::new(p.p0_11.degrade(), Pull::Up)),
); );
let button2 = button( let button2 = button(
2, 2,
GpioteInput::new(g, Input::new(p.p0_12.degrade(), Pull::Up)), PortInput::new(g, Input::new(p.p0_12.degrade(), Pull::Up)),
); );
let button3 = button( let button3 = button(
3, 3,
GpioteInput::new(g, Input::new(p.p0_24.degrade(), Pull::Up)), PortInput::new(g, Input::new(p.p0_24.degrade(), Pull::Up)),
); );
let button4 = button( let button4 = button(
4, 4,
GpioteInput::new(g, Input::new(p.p0_25.degrade(), Pull::Up)), PortInput::new(g, Input::new(p.p0_25.degrade(), Pull::Up)),
); );
futures::join!(button1, button2, button3, button4); futures::join!(button1, button2, button3, button4);
} }

View File

@ -338,18 +338,18 @@ impl<C: ChannelID, T> OutputChannel<C, T> {
*/ */
/// GPIO input driver with support /// GPIO input driver with support
pub struct GpioteInput<T: GpioPin> { pub struct PortInput<T: GpioPin> {
pin: Input<T>, pin: Input<T>,
} }
impl<T: GpioPin> Unpin for GpioteInput<T> {} impl<T: GpioPin> Unpin for PortInput<T> {}
impl<T: GpioPin> GpioteInput<T> { impl<T: GpioPin> PortInput<T> {
pub fn new(_init: Initialized, pin: Input<T>) -> Self { pub fn new(_init: Initialized, pin: Input<T>) -> Self {
Self { pin } Self { pin }
} }
} }
impl<T: GpioPin> InputPin for GpioteInput<T> { impl<T: GpioPin> InputPin for PortInput<T> {
type Error = Infallible; type Error = Infallible;
fn is_high(&self) -> Result<bool, Self::Error> { fn is_high(&self) -> Result<bool, Self::Error> {
@ -361,7 +361,7 @@ impl<T: GpioPin> InputPin for GpioteInput<T> {
} }
} }
impl<T: GpioPin> WaitForHigh for GpioteInput<T> { impl<T: GpioPin> WaitForHigh for PortInput<T> {
type Future<'a> = PortInputFuture<'a>; type Future<'a> = PortInputFuture<'a>;
fn wait_for_high<'a>(self: Pin<&'a mut Self>) -> Self::Future<'a> { fn wait_for_high<'a>(self: Pin<&'a mut Self>) -> Self::Future<'a> {
@ -374,7 +374,7 @@ impl<T: GpioPin> WaitForHigh for GpioteInput<T> {
} }
} }
impl<T: GpioPin> WaitForLow for GpioteInput<T> { impl<T: GpioPin> WaitForLow for PortInput<T> {
type Future<'a> = PortInputFuture<'a>; type Future<'a> = PortInputFuture<'a>;
fn wait_for_low<'a>(self: Pin<&'a mut Self>) -> Self::Future<'a> { fn wait_for_low<'a>(self: Pin<&'a mut Self>) -> Self::Future<'a> {