1#![no_std]
8
9pub mod ble;
11pub mod cachectrl;
12pub mod chip;
13pub mod clkgen;
14pub mod flashctrl;
15pub mod gpio;
16pub mod iom;
17pub mod ios;
18pub mod mcuctrl;
19pub mod nvic;
20pub mod pwrctrl;
21pub mod stimer;
22pub mod uart;
23
24use cortexm4f::{initialize_ram_jump_to_main, scb, unhandled_interrupt, CortexM4F, CortexMVariant};
25
26extern "C" {
27 fn _estack();
30}
31
32#[cfg_attr(
33 all(target_arch = "arm", target_os = "none"),
34 link_section = ".vectors"
35)]
36#[cfg_attr(all(target_arch = "arm", target_os = "none"), used)]
38pub static BASE_VECTORS: [unsafe extern "C" fn(); 16] = [
39 _estack,
40 initialize_ram_jump_to_main,
41 unhandled_interrupt, CortexM4F::HARD_FAULT_HANDLER, unhandled_interrupt, unhandled_interrupt, unhandled_interrupt, unhandled_interrupt,
47 unhandled_interrupt,
48 unhandled_interrupt,
49 unhandled_interrupt,
50 CortexM4F::SVC_HANDLER, unhandled_interrupt, unhandled_interrupt,
53 unhandled_interrupt, CortexM4F::SYSTICK_HANDLER, ];
56
57#[cfg_attr(
58 all(target_arch = "arm", target_os = "none"),
59 link_section = ".vectors"
60)]
61#[cfg_attr(all(target_arch = "arm", target_os = "none"), used)]
63pub static IRQS: [unsafe extern "C" fn(); 32] = [CortexM4F::GENERIC_ISR; 32];
64
65#[cfg_attr(
70 all(target_arch = "arm", target_os = "none"),
71 link_section = ".vectors"
72)]
73#[cfg_attr(all(target_arch = "arm", target_os = "none"), used)]
75pub static PATCH: [unsafe extern "C" fn(); 16] = [unhandled_interrupt; 16];
76
77#[cfg(any(doc, all(target_arch = "arm", target_os = "none")))]
80#[inline(always)]
81pub unsafe fn init() {
82 use core::arch::asm;
83 let cache_ctrl = crate::cachectrl::CacheCtrl::new();
84 cache_ctrl.enable_cache();
85
86 scb::set_vector_table_offset(BASE_VECTORS.as_ptr() as *const ());
93
94 scb::disable_fpca();
96
97 asm!("svc 0xff", out("r0") _, out("r1") _, out("r2") _, out("r3") _, out("r12") _);
99
100 cortexm4f::nvic::disable_all();
101 cortexm4f::nvic::clear_all_pending();
102 cortexm4f::nvic::enable_all();
103}
104
105#[cfg(not(any(doc, all(target_arch = "arm", target_os = "none"))))]
107pub unsafe fn init() {
108 scb::disable_fpca();
110
111 unimplemented!()
112}