1#![crate_name = "apollo3"]
8#![crate_type = "rlib"]
9#![no_std]
10
11pub mod ble;
13pub mod cachectrl;
14pub mod chip;
15pub mod clkgen;
16pub mod flashctrl;
17pub mod gpio;
18pub mod iom;
19pub mod ios;
20pub mod mcuctrl;
21pub mod nvic;
22pub mod pwrctrl;
23pub mod stimer;
24pub mod uart;
25
26use cortexm4f::{initialize_ram_jump_to_main, scb, unhandled_interrupt, CortexM4F, CortexMVariant};
27
28extern "C" {
29 fn _estack();
32}
33
34#[cfg_attr(
35 all(target_arch = "arm", target_os = "none"),
36 link_section = ".vectors"
37)]
38#[cfg_attr(all(target_arch = "arm", target_os = "none"), used)]
40pub static BASE_VECTORS: [unsafe extern "C" fn(); 16] = [
41 _estack,
42 initialize_ram_jump_to_main,
43 unhandled_interrupt, CortexM4F::HARD_FAULT_HANDLER, unhandled_interrupt, unhandled_interrupt, unhandled_interrupt, unhandled_interrupt,
49 unhandled_interrupt,
50 unhandled_interrupt,
51 unhandled_interrupt,
52 CortexM4F::SVC_HANDLER, unhandled_interrupt, unhandled_interrupt,
55 unhandled_interrupt, CortexM4F::SYSTICK_HANDLER, ];
58
59#[cfg_attr(
60 all(target_arch = "arm", target_os = "none"),
61 link_section = ".vectors"
62)]
63#[cfg_attr(all(target_arch = "arm", target_os = "none"), used)]
65pub static IRQS: [unsafe extern "C" fn(); 32] = [CortexM4F::GENERIC_ISR; 32];
66
67#[cfg_attr(
72 all(target_arch = "arm", target_os = "none"),
73 link_section = ".vectors"
74)]
75#[cfg_attr(all(target_arch = "arm", target_os = "none"), used)]
77pub static PATCH: [unsafe extern "C" fn(); 16] = [unhandled_interrupt; 16];
78
79#[cfg(any(doc, all(target_arch = "arm", target_os = "none")))]
82#[inline(always)]
83pub unsafe fn init() {
84 use core::arch::asm;
85 let cache_ctrl = crate::cachectrl::CacheCtrl::new();
86 cache_ctrl.enable_cache();
87
88 scb::set_vector_table_offset(BASE_VECTORS.as_ptr() as *const ());
95
96 scb::disable_fpca();
98
99 asm!("svc 0xff", out("r0") _, out("r1") _, out("r2") _, out("r3") _, out("r12") _);
101
102 cortexm4f::nvic::disable_all();
103 cortexm4f::nvic::clear_all_pending();
104 cortexm4f::nvic::enable_all();
105}
106
107#[cfg(not(any(doc, all(target_arch = "arm", target_os = "none"))))]
109pub unsafe fn init() {
110 scb::disable_fpca();
112
113 unimplemented!()
114}