aboutsummaryrefslogtreecommitdiff
path: root/embassy-nxp/src/pint.rs
diff options
context:
space:
mode:
authorDario Nieuwenhuis <[email protected]>2025-03-26 16:01:37 +0100
committerDario Nieuwenhuis <[email protected]>2025-03-27 15:18:06 +0100
commitd41eeeae79388f219bf6a84e2f7bde9f6b532516 (patch)
tree678b6fc732216e529dc38e6f65b72a309917ac32 /embassy-nxp/src/pint.rs
parent9edf5b7f049f95742b60b041e4443967d8a6b708 (diff)
Remove Peripheral trait, rename PeripheralRef->Peri.
Diffstat (limited to 'embassy-nxp/src/pint.rs')
-rw-r--r--embassy-nxp/src/pint.rs18
1 files changed, 9 insertions, 9 deletions
diff --git a/embassy-nxp/src/pint.rs b/embassy-nxp/src/pint.rs
index 809be4bff..8d6dc1277 100644
--- a/embassy-nxp/src/pint.rs
+++ b/embassy-nxp/src/pint.rs
@@ -5,12 +5,12 @@ use core::pin::Pin as FuturePin;
5use core::task::{Context, Poll}; 5use core::task::{Context, Poll};
6 6
7use critical_section::Mutex; 7use critical_section::Mutex;
8use embassy_hal_internal::{Peripheral, PeripheralRef};
9use embassy_sync::waitqueue::AtomicWaker; 8use embassy_sync::waitqueue::AtomicWaker;
10 9
11use crate::gpio::{self, AnyPin, Level, SealedPin}; 10use crate::gpio::{self, AnyPin, Level, SealedPin};
12use crate::pac::interrupt; 11use crate::pac::interrupt;
13use crate::pac_utils::*; 12use crate::pac_utils::*;
13use crate::Peri;
14 14
15struct PinInterrupt { 15struct PinInterrupt {
16 assigned: bool, 16 assigned: bool,
@@ -107,14 +107,14 @@ pub(crate) fn init() {
107#[must_use = "futures do nothing unless you `.await` or poll them"] 107#[must_use = "futures do nothing unless you `.await` or poll them"]
108struct InputFuture<'d> { 108struct InputFuture<'d> {
109 #[allow(dead_code)] 109 #[allow(dead_code)]
110 pin: PeripheralRef<'d, AnyPin>, 110 pin: Peri<'d, AnyPin>,
111 interrupt_number: usize, 111 interrupt_number: usize,
112} 112}
113 113
114impl<'d> InputFuture<'d> { 114impl<'d> InputFuture<'d> {
115 /// Create a new input future. Returns None if all interrupts are in use. 115 /// Create a new input future. Returns None if all interrupts are in use.
116 fn new(pin: impl Peripheral<P = impl gpio::Pin> + 'd, interrupt_on: InterruptOn) -> Option<Self> { 116 fn new(pin: Peri<'d, impl gpio::Pin>, interrupt_on: InterruptOn) -> Option<Self> {
117 let pin = pin.into_ref().map_into(); 117 let pin = pin.into();
118 let interrupt_number = next_available_interrupt()?; 118 let interrupt_number = next_available_interrupt()?;
119 119
120 // Clear interrupt, just in case 120 // Clear interrupt, just in case
@@ -344,35 +344,35 @@ impl gpio::Flex<'_> {
344 /// Wait for a falling or rising edge on the pin. You can have at most 8 pins waiting. If you 344 /// Wait for a falling or rising edge on the pin. You can have at most 8 pins waiting. If you
345 /// try to wait for more than 8 pins, this function will return `None`. 345 /// try to wait for more than 8 pins, this function will return `None`.
346 pub async fn wait_for_any_edge(&mut self) -> Option<()> { 346 pub async fn wait_for_any_edge(&mut self) -> Option<()> {
347 InputFuture::new(&mut self.pin, InterruptOn::Edge(Edge::Both))?.await; 347 InputFuture::new(self.pin.reborrow(), InterruptOn::Edge(Edge::Both))?.await;
348 Some(()) 348 Some(())
349 } 349 }
350 350
351 /// Wait for a falling edge on the pin. You can have at most 8 pins waiting. If you try to wait 351 /// Wait for a falling edge on the pin. You can have at most 8 pins waiting. If you try to wait
352 /// for more than 8 pins, this function will return `None`. 352 /// for more than 8 pins, this function will return `None`.
353 pub async fn wait_for_falling_edge(&mut self) -> Option<()> { 353 pub async fn wait_for_falling_edge(&mut self) -> Option<()> {
354 InputFuture::new(&mut self.pin, InterruptOn::Edge(Edge::Falling))?.await; 354 InputFuture::new(self.pin.reborrow(), InterruptOn::Edge(Edge::Falling))?.await;
355 Some(()) 355 Some(())
356 } 356 }
357 357
358 /// Wait for a rising edge on the pin. You can have at most 8 pins waiting. If you try to wait 358 /// Wait for a rising edge on the pin. You can have at most 8 pins waiting. If you try to wait
359 /// for more than 8 pins, this function will return `None`. 359 /// for more than 8 pins, this function will return `None`.
360 pub async fn wait_for_rising_edge(&mut self) -> Option<()> { 360 pub async fn wait_for_rising_edge(&mut self) -> Option<()> {
361 InputFuture::new(&mut self.pin, InterruptOn::Edge(Edge::Rising))?.await; 361 InputFuture::new(self.pin.reborrow(), InterruptOn::Edge(Edge::Rising))?.await;
362 Some(()) 362 Some(())
363 } 363 }
364 364
365 /// Wait for a low level on the pin. You can have at most 8 pins waiting. If you try to wait for 365 /// Wait for a low level on the pin. You can have at most 8 pins waiting. If you try to wait for
366 /// more than 8 pins, this function will return `None`. 366 /// more than 8 pins, this function will return `None`.
367 pub async fn wait_for_low(&mut self) -> Option<()> { 367 pub async fn wait_for_low(&mut self) -> Option<()> {
368 InputFuture::new(&mut self.pin, InterruptOn::Level(Level::Low))?.await; 368 InputFuture::new(self.pin.reborrow(), InterruptOn::Level(Level::Low))?.await;
369 Some(()) 369 Some(())
370 } 370 }
371 371
372 /// Wait for a high level on the pin. You can have at most 8 pins waiting. If you try to wait for 372 /// Wait for a high level on the pin. You can have at most 8 pins waiting. If you try to wait for
373 /// more than 8 pins, this function will return `None`. 373 /// more than 8 pins, this function will return `None`.
374 pub async fn wait_for_high(&mut self) -> Option<()> { 374 pub async fn wait_for_high(&mut self) -> Option<()> {
375 InputFuture::new(&mut self.pin, InterruptOn::Level(Level::High))?.await; 375 InputFuture::new(self.pin.reborrow(), InterruptOn::Level(Level::High))?.await;
376 Some(()) 376 Some(())
377 } 377 }
378} 378}