nrf/gpiote: expose all functionality as inherent methods.
This commit is contained in:
parent
3ca01cba8d
commit
c432d036c7
@ -350,17 +350,13 @@ pub(crate) mod sealed {
|
|||||||
/// Set the output as high.
|
/// Set the output as high.
|
||||||
#[inline]
|
#[inline]
|
||||||
fn set_high(&self) {
|
fn set_high(&self) {
|
||||||
unsafe {
|
unsafe { self.block().outset.write(|w| w.bits(1u32 << self._pin())) }
|
||||||
self.block().outset.write(|w| w.bits(1u32 << self._pin()));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Set the output as low.
|
/// Set the output as low.
|
||||||
#[inline]
|
#[inline]
|
||||||
fn set_low(&self) {
|
fn set_low(&self) {
|
||||||
unsafe {
|
unsafe { self.block().outclr.write(|w| w.bits(1u32 << self._pin())) }
|
||||||
self.block().outclr.write(|w| w.bits(1u32 << self._pin()));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -342,78 +342,60 @@ impl<'a> Future for PortInputFuture<'a> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'d, T: GpioPin> embassy::traits::gpio::WaitForHigh for Input<'d, T> {
|
impl<'d, T: GpioPin> Input<'d, T> {
|
||||||
type Future<'a>
|
pub async fn wait_for_high(&mut self) {
|
||||||
where
|
self.pin.wait_for_high().await
|
||||||
Self: 'a,
|
}
|
||||||
= impl Future<Output = ()> + Unpin + 'a;
|
|
||||||
|
|
||||||
fn wait_for_high<'a>(&'a mut self) -> Self::Future<'a> {
|
pub async fn wait_for_low(&mut self) {
|
||||||
self.pin.wait_for_high()
|
self.pin.wait_for_low().await
|
||||||
|
}
|
||||||
|
|
||||||
|
pub async fn wait_for_rising_edge(&mut self) {
|
||||||
|
self.pin.wait_for_rising_edge().await
|
||||||
|
}
|
||||||
|
|
||||||
|
pub async fn wait_for_falling_edge(&mut self) {
|
||||||
|
self.pin.wait_for_falling_edge().await
|
||||||
|
}
|
||||||
|
|
||||||
|
pub async fn wait_for_any_edge(&mut self) {
|
||||||
|
self.pin.wait_for_any_edge().await
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'d, T: GpioPin> embassy::traits::gpio::WaitForLow for Input<'d, T> {
|
impl<'d, T: GpioPin> Flex<'d, T> {
|
||||||
type Future<'a>
|
pub async fn wait_for_high(&mut self) {
|
||||||
where
|
|
||||||
Self: 'a,
|
|
||||||
= impl Future<Output = ()> + Unpin + 'a;
|
|
||||||
|
|
||||||
fn wait_for_low<'a>(&'a mut self) -> Self::Future<'a> {
|
|
||||||
self.pin.wait_for_low()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<'d, T: GpioPin> embassy::traits::gpio::WaitForAnyEdge for Input<'d, T> {
|
|
||||||
type Future<'a>
|
|
||||||
where
|
|
||||||
Self: 'a,
|
|
||||||
= impl Future<Output = ()> + Unpin + 'a;
|
|
||||||
|
|
||||||
fn wait_for_any_edge<'a>(&'a mut self) -> Self::Future<'a> {
|
|
||||||
self.pin.wait_for_any_edge()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<'d, T: GpioPin> embassy::traits::gpio::WaitForHigh for Flex<'d, T> {
|
|
||||||
type Future<'a>
|
|
||||||
where
|
|
||||||
Self: 'a,
|
|
||||||
= impl Future<Output = ()> + Unpin + 'a;
|
|
||||||
|
|
||||||
fn wait_for_high<'a>(&'a mut self) -> Self::Future<'a> {
|
|
||||||
self.pin.conf().modify(|_, w| w.sense().high());
|
self.pin.conf().modify(|_, w| w.sense().high());
|
||||||
|
|
||||||
PortInputFuture {
|
PortInputFuture {
|
||||||
pin_port: self.pin.pin_port(),
|
pin_port: self.pin.pin_port(),
|
||||||
phantom: PhantomData,
|
phantom: PhantomData,
|
||||||
}
|
}
|
||||||
}
|
.await
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'d, T: GpioPin> embassy::traits::gpio::WaitForLow for Flex<'d, T> {
|
pub async fn wait_for_low(&mut self) {
|
||||||
type Future<'a>
|
|
||||||
where
|
|
||||||
Self: 'a,
|
|
||||||
= impl Future<Output = ()> + Unpin + 'a;
|
|
||||||
|
|
||||||
fn wait_for_low<'a>(&'a mut self) -> Self::Future<'a> {
|
|
||||||
self.pin.conf().modify(|_, w| w.sense().low());
|
self.pin.conf().modify(|_, w| w.sense().low());
|
||||||
|
|
||||||
PortInputFuture {
|
PortInputFuture {
|
||||||
pin_port: self.pin.pin_port(),
|
pin_port: self.pin.pin_port(),
|
||||||
phantom: PhantomData,
|
phantom: PhantomData,
|
||||||
}
|
}
|
||||||
}
|
.await
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'d, T: GpioPin> embassy::traits::gpio::WaitForAnyEdge for Flex<'d, T> {
|
pub async fn wait_for_rising_edge(&mut self) {
|
||||||
type Future<'a>
|
self.wait_for_low().await;
|
||||||
where
|
self.wait_for_high().await;
|
||||||
Self: 'a,
|
}
|
||||||
= impl Future<Output = ()> + Unpin + 'a;
|
|
||||||
|
|
||||||
fn wait_for_any_edge<'a>(&'a mut self) -> Self::Future<'a> {
|
pub async fn wait_for_falling_edge(&mut self) {
|
||||||
|
self.wait_for_high().await;
|
||||||
|
self.wait_for_low().await;
|
||||||
|
}
|
||||||
|
|
||||||
|
pub async fn wait_for_any_edge(&mut self) {
|
||||||
if self.is_high() {
|
if self.is_high() {
|
||||||
self.pin.conf().modify(|_, w| w.sense().low());
|
self.pin.conf().modify(|_, w| w.sense().low());
|
||||||
} else {
|
} else {
|
||||||
@ -423,6 +405,7 @@ impl<'d, T: GpioPin> embassy::traits::gpio::WaitForAnyEdge for Flex<'d, T> {
|
|||||||
pin_port: self.pin.pin_port(),
|
pin_port: self.pin.pin_port(),
|
||||||
phantom: PhantomData,
|
phantom: PhantomData,
|
||||||
}
|
}
|
||||||
|
.await
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,7 +6,6 @@
|
|||||||
mod example_common;
|
mod example_common;
|
||||||
|
|
||||||
use embassy::executor::Spawner;
|
use embassy::executor::Spawner;
|
||||||
use embassy::traits::gpio::{WaitForHigh, WaitForLow};
|
|
||||||
use embassy_nrf::gpio::{AnyPin, Input, Pin as _, Pull};
|
use embassy_nrf::gpio::{AnyPin, Input, Pin as _, Pull};
|
||||||
use embassy_nrf::Peripherals;
|
use embassy_nrf::Peripherals;
|
||||||
use example_common::*;
|
use example_common::*;
|
||||||
|
@ -10,7 +10,6 @@ use embassy::executor::Spawner;
|
|||||||
use embassy_nrf::gpio::{Input, Pull};
|
use embassy_nrf::gpio::{Input, Pull};
|
||||||
use embassy_nrf::wdt::{Config, Watchdog};
|
use embassy_nrf::wdt::{Config, Watchdog};
|
||||||
use embassy_nrf::Peripherals;
|
use embassy_nrf::Peripherals;
|
||||||
use embassy_traits::gpio::{WaitForHigh, WaitForLow};
|
|
||||||
|
|
||||||
#[embassy::main]
|
#[embassy::main]
|
||||||
async fn main(_spawner: Spawner, p: Peripherals) {
|
async fn main(_spawner: Spawner, p: Peripherals) {
|
||||||
|
Loading…
Reference in New Issue
Block a user