diff options
| author | everdrone <[email protected]> | 2025-09-21 17:23:39 +0200 |
|---|---|---|
| committer | everdrone <[email protected]> | 2025-09-21 17:23:39 +0200 |
| commit | ea4e7bc3d23c3deb44fa6029f70ddcd72dfa4d35 (patch) | |
| tree | 1b60c366ea73a575b6c8500d3495fdeaa6eab9c7 /embassy-stm32/src/exti.rs | |
| parent | 7b9116957a439a5e8488aa9d6f47bbb7b8a306a1 (diff) | |
Use `PinNumber` to accomodate chips with more than 256 pins
Diffstat (limited to 'embassy-stm32/src/exti.rs')
| -rw-r--r-- | embassy-stm32/src/exti.rs | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/embassy-stm32/src/exti.rs b/embassy-stm32/src/exti.rs index 376fdccb8..bc4ecd1cc 100644 --- a/embassy-stm32/src/exti.rs +++ b/embassy-stm32/src/exti.rs | |||
| @@ -8,7 +8,7 @@ use core::task::{Context, Poll}; | |||
| 8 | use embassy_hal_internal::{impl_peripheral, PeripheralType}; | 8 | use embassy_hal_internal::{impl_peripheral, PeripheralType}; |
| 9 | use embassy_sync::waitqueue::AtomicWaker; | 9 | use embassy_sync::waitqueue::AtomicWaker; |
| 10 | 10 | ||
| 11 | use crate::gpio::{AnyPin, Input, Level, Pin as GpioPin, Pull}; | 11 | use crate::gpio::{AnyPin, Input, Level, Pin as GpioPin, PinNumber, Pull}; |
| 12 | use crate::pac::exti::regs::Lines; | 12 | use crate::pac::exti::regs::Lines; |
| 13 | use crate::pac::EXTI; | 13 | use crate::pac::EXTI; |
| 14 | use crate::{interrupt, pac, peripherals, Peri}; | 14 | use crate::{interrupt, pac, peripherals, Peri}; |
| @@ -226,12 +226,12 @@ impl<'d> embedded_hal_async::digital::Wait for ExtiInput<'d> { | |||
| 226 | 226 | ||
| 227 | #[must_use = "futures do nothing unless you `.await` or poll them"] | 227 | #[must_use = "futures do nothing unless you `.await` or poll them"] |
| 228 | struct ExtiInputFuture<'a> { | 228 | struct ExtiInputFuture<'a> { |
| 229 | pin: u8, | 229 | pin: PinNumber, |
| 230 | phantom: PhantomData<&'a mut AnyPin>, | 230 | phantom: PhantomData<&'a mut AnyPin>, |
| 231 | } | 231 | } |
| 232 | 232 | ||
| 233 | impl<'a> ExtiInputFuture<'a> { | 233 | impl<'a> ExtiInputFuture<'a> { |
| 234 | fn new(pin: u8, port: u8, rising: bool, falling: bool) -> Self { | 234 | fn new(pin: PinNumber, port: PinNumber, rising: bool, falling: bool) -> Self { |
| 235 | critical_section::with(|_| { | 235 | critical_section::with(|_| { |
| 236 | let pin = pin as usize; | 236 | let pin = pin as usize; |
| 237 | exticr_regs().exticr(pin / 4).modify(|w| w.set_exti(pin % 4, port)); | 237 | exticr_regs().exticr(pin / 4).modify(|w| w.set_exti(pin % 4, port)); |
| @@ -334,20 +334,20 @@ trait SealedChannel {} | |||
| 334 | #[allow(private_bounds)] | 334 | #[allow(private_bounds)] |
| 335 | pub trait Channel: PeripheralType + SealedChannel + Sized { | 335 | pub trait Channel: PeripheralType + SealedChannel + Sized { |
| 336 | /// Get the EXTI channel number. | 336 | /// Get the EXTI channel number. |
| 337 | fn number(&self) -> u8; | 337 | fn number(&self) -> PinNumber; |
| 338 | } | 338 | } |
| 339 | 339 | ||
| 340 | /// Type-erased EXTI channel. | 340 | /// Type-erased EXTI channel. |
| 341 | /// | 341 | /// |
| 342 | /// This represents ownership over any EXTI channel, known at runtime. | 342 | /// This represents ownership over any EXTI channel, known at runtime. |
| 343 | pub struct AnyChannel { | 343 | pub struct AnyChannel { |
| 344 | number: u8, | 344 | number: PinNumber, |
| 345 | } | 345 | } |
| 346 | 346 | ||
| 347 | impl_peripheral!(AnyChannel); | 347 | impl_peripheral!(AnyChannel); |
| 348 | impl SealedChannel for AnyChannel {} | 348 | impl SealedChannel for AnyChannel {} |
| 349 | impl Channel for AnyChannel { | 349 | impl Channel for AnyChannel { |
| 350 | fn number(&self) -> u8 { | 350 | fn number(&self) -> PinNumber { |
| 351 | self.number | 351 | self.number |
| 352 | } | 352 | } |
| 353 | } | 353 | } |
| @@ -356,7 +356,7 @@ macro_rules! impl_exti { | |||
| 356 | ($type:ident, $number:expr) => { | 356 | ($type:ident, $number:expr) => { |
| 357 | impl SealedChannel for peripherals::$type {} | 357 | impl SealedChannel for peripherals::$type {} |
| 358 | impl Channel for peripherals::$type { | 358 | impl Channel for peripherals::$type { |
| 359 | fn number(&self) -> u8 { | 359 | fn number(&self) -> PinNumber { |
| 360 | $number | 360 | $number |
| 361 | } | 361 | } |
| 362 | } | 362 | } |
| @@ -364,7 +364,7 @@ macro_rules! impl_exti { | |||
| 364 | impl From<peripherals::$type> for AnyChannel { | 364 | impl From<peripherals::$type> for AnyChannel { |
| 365 | fn from(val: peripherals::$type) -> Self { | 365 | fn from(val: peripherals::$type) -> Self { |
| 366 | Self { | 366 | Self { |
| 367 | number: val.number() as u8, | 367 | number: val.number() as PinNumber, |
| 368 | } | 368 | } |
| 369 | } | 369 | } |
| 370 | } | 370 | } |
