aboutsummaryrefslogtreecommitdiff
path: root/src/lib.rs
diff options
context:
space:
mode:
authorJames Munns <[email protected]>2025-11-14 19:03:26 +0100
committerJames Munns <[email protected]>2025-11-14 19:03:26 +0100
commit0bae6aa5aaab5d0f3a3e7e1ec83a0cee909de115 (patch)
tree1740876a3af2f06bcc129b62e3a6e87f4472d5f3 /src/lib.rs
parent8cdccae3c6c4a805cf5003b1a859734c105d76e8 (diff)
parent77b2c602a60e41c7c977003a6d40367ac285930e (diff)
Merge remote-tracking branch 'origin/main' into james/impl-clocks
Diffstat (limited to 'src/lib.rs')
-rw-r--r--src/lib.rs44
1 files changed, 22 insertions, 22 deletions
diff --git a/src/lib.rs b/src/lib.rs
index ec2cb31e7..1bf54a98b 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -59,29 +59,29 @@ pub fn init(cfg: crate::config::Config) -> Peripherals {
59 peripherals 59 peripherals
60} 60}
61 61
62/// Optional hook called by cortex-m-rt before RAM init. 62// /// Optional hook called by cortex-m-rt before RAM init.
63/// We proactively mask and clear all NVIC IRQs to avoid wedges from stale state 63// /// We proactively mask and clear all NVIC IRQs to avoid wedges from stale state
64/// left by soft resets/debug sessions. 64// /// left by soft resets/debug sessions.
65/// 65// ///
66/// NOTE: Manual VTOR setup is required for RAM execution. The cortex-m-rt 'set-vtor' 66// /// NOTE: Manual VTOR setup is required for RAM execution. The cortex-m-rt 'set-vtor'
67/// feature is incompatible with our setup because it expects __vector_table to be 67// /// feature is incompatible with our setup because it expects __vector_table to be
68/// defined differently than how our RAM-based linker script arranges it. 68// /// defined differently than how our RAM-based linker script arranges it.
69#[no_mangle] 69// #[no_mangle]
70pub unsafe extern "C" fn __pre_init() { 70// pub unsafe extern "C" fn __pre_init() {
71 // Set the VTOR to point to the interrupt vector table in RAM 71// // Set the VTOR to point to the interrupt vector table in RAM
72 // This is required since code runs from RAM on this MCU 72// // This is required since code runs from RAM on this MCU
73 crate::interrupt::vtor_set_ram_vector_base(0x2000_0000 as *const u32); 73// crate::interrupt::vtor_set_ram_vector_base(0x2000_0000 as *const u32);
74 74
75 // Mask and clear pending for all NVIC lines (0..127) to avoid stale state across runs. 75// // Mask and clear pending for all NVIC lines (0..127) to avoid stale state across runs.
76 let nvic = &*cortex_m::peripheral::NVIC::PTR; 76// let nvic = &*cortex_m::peripheral::NVIC::PTR;
77 for i in 0..4 { 77// for i in 0..4 {
78 // 4 words x 32 = 128 IRQs 78// // 4 words x 32 = 128 IRQs
79 nvic.icer[i].write(0xFFFF_FFFF); 79// nvic.icer[i].write(0xFFFF_FFFF);
80 nvic.icpr[i].write(0xFFFF_FFFF); 80// nvic.icpr[i].write(0xFFFF_FFFF);
81 } 81// }
82 // Do NOT touch peripheral registers here: clocks may be off and accesses can fault. 82// // Do NOT touch peripheral registers here: clocks may be off and accesses can fault.
83 crate::interrupt::clear_default_handler_snapshot(); 83// crate::interrupt::clear_default_handler_snapshot();
84} 84// }
85 85
86/// Internal helper to dispatch a type-level interrupt handler. 86/// Internal helper to dispatch a type-level interrupt handler.
87#[inline(always)] 87#[inline(always)]