aboutsummaryrefslogtreecommitdiff
path: root/src/lib.rs
diff options
context:
space:
mode:
authorFelipe Balbi <[email protected]>2025-11-13 13:17:44 -0800
committerGitHub <[email protected]>2025-11-13 13:17:44 -0800
commit77b2c602a60e41c7c977003a6d40367ac285930e (patch)
tree6a6490c883f84658c992af4351b8d8a8d8e1c1e4 /src/lib.rs
parentf4b8ae36bec40a15bedd3c0493e4822f9c5238dd (diff)
Move examples to a package of their own (#16)
* Move examples to a package of their own * cargo +nightly fmt * Add missing safety doc * cargo clippy examples * fmt again --------- Co-authored-by: Felipe Balbi <[email protected]>
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 9899564d8..4e5ac0109 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -62,29 +62,29 @@ pub fn init(cfg: crate::config::Config) -> Peripherals {
62 peripherals 62 peripherals
63} 63}
64 64
65/// Optional hook called by cortex-m-rt before RAM init. 65// /// Optional hook called by cortex-m-rt before RAM init.
66/// We proactively mask and clear all NVIC IRQs to avoid wedges from stale state 66// /// We proactively mask and clear all NVIC IRQs to avoid wedges from stale state
67/// left by soft resets/debug sessions. 67// /// left by soft resets/debug sessions.
68/// 68// ///
69/// NOTE: Manual VTOR setup is required for RAM execution. The cortex-m-rt 'set-vtor' 69// /// NOTE: Manual VTOR setup is required for RAM execution. The cortex-m-rt 'set-vtor'
70/// feature is incompatible with our setup because it expects __vector_table to be 70// /// feature is incompatible with our setup because it expects __vector_table to be
71/// defined differently than how our RAM-based linker script arranges it. 71// /// defined differently than how our RAM-based linker script arranges it.
72#[no_mangle] 72// #[no_mangle]
73pub unsafe extern "C" fn __pre_init() { 73// pub unsafe extern "C" fn __pre_init() {
74 // Set the VTOR to point to the interrupt vector table in RAM 74// // Set the VTOR to point to the interrupt vector table in RAM
75 // This is required since code runs from RAM on this MCU 75// // This is required since code runs from RAM on this MCU
76 crate::interrupt::vtor_set_ram_vector_base(0x2000_0000 as *const u32); 76// crate::interrupt::vtor_set_ram_vector_base(0x2000_0000 as *const u32);
77 77
78 // Mask and clear pending for all NVIC lines (0..127) to avoid stale state across runs. 78// // Mask and clear pending for all NVIC lines (0..127) to avoid stale state across runs.
79 let nvic = &*cortex_m::peripheral::NVIC::PTR; 79// let nvic = &*cortex_m::peripheral::NVIC::PTR;
80 for i in 0..4 { 80// for i in 0..4 {
81 // 4 words x 32 = 128 IRQs 81// // 4 words x 32 = 128 IRQs
82 nvic.icer[i].write(0xFFFF_FFFF); 82// nvic.icer[i].write(0xFFFF_FFFF);
83 nvic.icpr[i].write(0xFFFF_FFFF); 83// nvic.icpr[i].write(0xFFFF_FFFF);
84 } 84// }
85 // Do NOT touch peripheral registers here: clocks may be off and accesses can fault. 85// // Do NOT touch peripheral registers here: clocks may be off and accesses can fault.
86 crate::interrupt::clear_default_handler_snapshot(); 86// crate::interrupt::clear_default_handler_snapshot();
87} 87// }
88 88
89/// Internal helper to dispatch a type-level interrupt handler. 89/// Internal helper to dispatch a type-level interrupt handler.
90#[inline(always)] 90#[inline(always)]