diff options
Diffstat (limited to 'embassy-nxp/src/dma')
| -rw-r--r-- | embassy-nxp/src/dma/lpc55.rs | 51 |
1 files changed, 17 insertions, 34 deletions
diff --git a/embassy-nxp/src/dma/lpc55.rs b/embassy-nxp/src/dma/lpc55.rs index 578d1fd88..623644bf1 100644 --- a/embassy-nxp/src/dma/lpc55.rs +++ b/embassy-nxp/src/dma/lpc55.rs | |||
| @@ -1,17 +1,22 @@ | |||
| 1 | #![macro_use] | ||
| 2 | |||
| 1 | use core::cell::RefCell; | 3 | use core::cell::RefCell; |
| 2 | use core::future::Future; | 4 | use core::future::Future; |
| 3 | use core::pin::Pin; | 5 | use core::pin::Pin; |
| 4 | use core::sync::atomic::{compiler_fence, Ordering}; | 6 | use core::sync::atomic::{Ordering, compiler_fence}; |
| 5 | use core::task::{Context, Poll}; | 7 | use core::task::{Context, Poll}; |
| 6 | 8 | ||
| 7 | use critical_section::Mutex; | 9 | use critical_section::Mutex; |
| 8 | use embassy_hal_internal::interrupt::InterruptExt; | 10 | use embassy_hal_internal::interrupt::InterruptExt; |
| 9 | use embassy_hal_internal::{impl_peripheral, PeripheralType}; | 11 | use embassy_hal_internal::{PeripheralType, impl_peripheral}; |
| 10 | use embassy_sync::waitqueue::AtomicWaker; | 12 | use embassy_sync::waitqueue::AtomicWaker; |
| 11 | 13 | ||
| 12 | use crate::pac::{DMA0, SYSCON, *}; | 14 | use crate::Peri; |
| 13 | use crate::{peripherals, Peri}; | 15 | #[cfg(feature = "rt")] |
| 16 | use crate::pac::interrupt; | ||
| 17 | use crate::pac::{SYSCON, *}; | ||
| 14 | 18 | ||
| 19 | #[cfg(feature = "rt")] | ||
| 15 | #[interrupt] | 20 | #[interrupt] |
| 16 | fn DMA0() { | 21 | fn DMA0() { |
| 17 | let inta = DMA0.inta0().read().ia(); | 22 | let inta = DMA0.inta0().read().ia(); |
| @@ -278,7 +283,7 @@ static DMA_DESCRIPTORS: Mutex<RefCell<DmaDescriptorTable>> = Mutex::new(RefCell: | |||
| 278 | }; CHANNEL_COUNT], | 283 | }; CHANNEL_COUNT], |
| 279 | })); | 284 | })); |
| 280 | 285 | ||
| 281 | trait SealedChannel {} | 286 | pub(crate) trait SealedChannel {} |
| 282 | trait SealedWord {} | 287 | trait SealedWord {} |
| 283 | 288 | ||
| 284 | /// DMA channel interface. | 289 | /// DMA channel interface. |
| @@ -323,7 +328,7 @@ impl Word for u32 { | |||
| 323 | 328 | ||
| 324 | /// Type erased DMA channel. | 329 | /// Type erased DMA channel. |
| 325 | pub struct AnyChannel { | 330 | pub struct AnyChannel { |
| 326 | number: u8, | 331 | pub(crate) number: u8, |
| 327 | } | 332 | } |
| 328 | 333 | ||
| 329 | impl_peripheral!(AnyChannel); | 334 | impl_peripheral!(AnyChannel); |
| @@ -335,10 +340,10 @@ impl Channel for AnyChannel { | |||
| 335 | } | 340 | } |
| 336 | } | 341 | } |
| 337 | 342 | ||
| 338 | macro_rules! channel { | 343 | macro_rules! impl_dma_channel { |
| 339 | ($name:ident, $num:expr) => { | 344 | ($instance:ident, $name:ident, $num:expr) => { |
| 340 | impl SealedChannel for peripherals::$name {} | 345 | impl crate::dma::SealedChannel for crate::peripherals::$name {} |
| 341 | impl Channel for peripherals::$name { | 346 | impl crate::dma::Channel for crate::peripherals::$name { |
| 342 | fn number(&self) -> u8 { | 347 | fn number(&self) -> u8 { |
| 343 | $num | 348 | $num |
| 344 | } | 349 | } |
| @@ -346,32 +351,10 @@ macro_rules! channel { | |||
| 346 | 351 | ||
| 347 | impl From<peripherals::$name> for crate::dma::AnyChannel { | 352 | impl From<peripherals::$name> for crate::dma::AnyChannel { |
| 348 | fn from(val: peripherals::$name) -> Self { | 353 | fn from(val: peripherals::$name) -> Self { |
| 354 | use crate::dma::Channel; | ||
| 355 | |||
| 349 | Self { number: val.number() } | 356 | Self { number: val.number() } |
| 350 | } | 357 | } |
| 351 | } | 358 | } |
| 352 | }; | 359 | }; |
| 353 | } | 360 | } |
| 354 | |||
| 355 | channel!(DMA_CH0, 0); | ||
| 356 | channel!(DMA_CH1, 1); | ||
| 357 | channel!(DMA_CH2, 2); | ||
| 358 | channel!(DMA_CH3, 3); | ||
| 359 | channel!(DMA_CH4, 4); | ||
| 360 | channel!(DMA_CH5, 5); | ||
| 361 | channel!(DMA_CH6, 6); | ||
| 362 | channel!(DMA_CH7, 7); | ||
| 363 | channel!(DMA_CH8, 8); | ||
| 364 | channel!(DMA_CH9, 9); | ||
| 365 | channel!(DMA_CH10, 10); | ||
| 366 | channel!(DMA_CH11, 11); | ||
| 367 | channel!(DMA_CH12, 12); | ||
| 368 | channel!(DMA_CH13, 13); | ||
| 369 | channel!(DMA_CH14, 14); | ||
| 370 | channel!(DMA_CH15, 15); | ||
| 371 | channel!(DMA_CH16, 16); | ||
| 372 | channel!(DMA_CH17, 17); | ||
| 373 | channel!(DMA_CH18, 18); | ||
| 374 | channel!(DMA_CH19, 19); | ||
| 375 | channel!(DMA_CH20, 20); | ||
| 376 | channel!(DMA_CH21, 21); | ||
| 377 | channel!(DMA_CH22, 22); | ||
