aboutsummaryrefslogtreecommitdiff
path: root/cortex-m-rt/examples/pre_init.rs
blob: d83af032e2dee39144410d3f5d4a56ed3c578bbc (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
//! `cortex-m-rt` based program with a function run before RAM is initialized.

#![deny(warnings)]
#![no_main]
#![no_std]

#[macro_use(entry, exception, pre_init)]
extern crate cortex_m_rt as rt;
extern crate panic_semihosting;

use rt::ExceptionFrame;

pre_init!(disable_watchdog);

unsafe fn disable_watchdog() {
    // Do what you need to disable the watchdog.
}

// the program entry point
entry!(main);

fn main() -> ! {
    loop {}
}

// the hard fault handler
exception!(HardFault, hard_fault);

fn hard_fault(_ef: &ExceptionFrame) -> ! {
    loop {}
}

// the default exception handler
exception!(*, default_handler);

fn default_handler(_irqn: i16) {}