blob: 1ae62b40caad12845036586e69f3cc8f3f5a62a0 (
plain)
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
37
38
39
40
|
//! Slowly blink an LED while blocking on a timer.
//!
//! Use this as the minimum-viable runtime support. You don't
//! need MCU-specific interrupts for this example.
//!
//! This example demonstrates how to register an exception
//! handler. See the API documentation for more information.
#![no_std]
#![no_main]
const PIT_PERIOD_US: u32 = 1_000_000;
#[imxrt_rt::entry]
fn main() -> ! {
let board::Resources { mut pit, led, .. } = board::prepare(PIT_PERIOD_US).unwrap();
loop {
led.toggle();
pit.blocking_delay();
}
}
use imxrt_rt::exception;
#[exception]
unsafe fn DefaultHandler(_irqn: i16) {
uh_oh()
}
#[exception]
unsafe fn HardFault(_: &imxrt_rt::ExceptionFrame) -> ! {
uh_oh()
}
#[inline(never)]
fn uh_oh() -> ! {
loop {
core::sync::atomic::fence(core::sync::atomic::Ordering::SeqCst)
}
}
|