aboutsummaryrefslogtreecommitdiff
path: root/embassy-mcxa/src/lib.rs
diff options
context:
space:
mode:
Diffstat (limited to 'embassy-mcxa/src/lib.rs')
-rw-r--r--embassy-mcxa/src/lib.rs47
1 files changed, 12 insertions, 35 deletions
diff --git a/embassy-mcxa/src/lib.rs b/embassy-mcxa/src/lib.rs
index 64eeb4012..1bbdffa06 100644
--- a/embassy-mcxa/src/lib.rs
+++ b/embassy-mcxa/src/lib.rs
@@ -6,6 +6,7 @@
6// #![doc = document_features::document_features!(feature_label = r#"<span class="stab portability"><code>{feature}</code></span>"#)] 6// #![doc = document_features::document_features!(feature_label = r#"<span class="stab portability"><code>{feature}</code></span>"#)]
7 7
8pub mod clocks; // still provide clock helpers 8pub mod clocks; // still provide clock helpers
9pub mod dma;
9pub mod gpio; 10pub mod gpio;
10pub mod pins; // pin mux helpers 11pub mod pins; // pin mux helpers
11 12
@@ -52,6 +53,14 @@ embassy_hal_internal::peripherals!(
52 53
53 DBGMAILBOX, 54 DBGMAILBOX,
54 DMA0, 55 DMA0,
56 DMA_CH0,
57 DMA_CH1,
58 DMA_CH2,
59 DMA_CH3,
60 DMA_CH4,
61 DMA_CH5,
62 DMA_CH6,
63 DMA_CH7,
55 EDMA0_TCD0, 64 EDMA0_TCD0,
56 EIM0, 65 EIM0,
57 EQDC0, 66 EQDC0,
@@ -364,6 +373,9 @@ pub fn init(cfg: crate::config::Config) -> Peripherals {
364 crate::gpio::init(); 373 crate::gpio::init();
365 } 374 }
366 375
376 // Initialize DMA controller (clock, reset, configuration)
377 crate::dma::init();
378
367 // Initialize embassy-time global driver backed by OSTIMER0 379 // Initialize embassy-time global driver backed by OSTIMER0
368 #[cfg(feature = "time")] 380 #[cfg(feature = "time")]
369 crate::ostimer::time_driver::init(crate::config::Config::default().time_interrupt_priority, 1_000_000); 381 crate::ostimer::time_driver::init(crate::config::Config::default().time_interrupt_priority, 1_000_000);
@@ -389,41 +401,6 @@ pub fn init(cfg: crate::config::Config) -> Peripherals {
389 peripherals 401 peripherals
390} 402}
391 403
392// /// Optional hook called by cortex-m-rt before RAM init.
393// /// We proactively mask and clear all NVIC IRQs to avoid wedges from stale state
394// /// left by soft resets/debug sessions.
395// ///
396// /// NOTE: Manual VTOR setup is required for RAM execution. The cortex-m-rt 'set-vtor'
397// /// feature is incompatible with our setup because it expects __vector_table to be
398// /// defined differently than how our RAM-based linker script arranges it.
399// #[no_mangle]
400// pub unsafe extern "C" fn __pre_init() {
401// // Set the VTOR to point to the interrupt vector table in RAM
402// // This is required since code runs from RAM on this MCU
403// crate::interrupt::vtor_set_ram_vector_base(0x2000_0000 as *const u32);
404
405// // Mask and clear pending for all NVIC lines (0..127) to avoid stale state across runs.
406// let nvic = &*cortex_m::peripheral::NVIC::PTR;
407// for i in 0..4 {
408// // 4 words x 32 = 128 IRQs
409// nvic.icer[i].write(0xFFFF_FFFF);
410// nvic.icpr[i].write(0xFFFF_FFFF);
411// }
412// // Do NOT touch peripheral registers here: clocks may be off and accesses can fault.
413// crate::interrupt::clear_default_handler_snapshot();
414// }
415
416/// Internal helper to dispatch a type-level interrupt handler.
417#[inline(always)]
418#[doc(hidden)]
419pub unsafe fn __handle_interrupt<T, H>()
420where
421 T: crate::interrupt::typelevel::Interrupt,
422 H: crate::interrupt::typelevel::Handler<T>,
423{
424 H::on_interrupt();
425}
426
427/// Macro to bind interrupts to handlers, similar to embassy-imxrt. 404/// Macro to bind interrupts to handlers, similar to embassy-imxrt.
428/// 405///
429/// Example: 406/// Example: