-
Notifications
You must be signed in to change notification settings - Fork 9
/
hello.rs
36 lines (30 loc) · 961 Bytes
/
hello.rs
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
#![no_std]
#![no_main]
#![feature(underscore_imports)]
// Link only imports, for panic implementation and interrupt vectors
// TODO: https://github.com/rust-lang/rust/issues/53128#issuecomment-414117024
#[allow(unused_imports)]
use {nrf51 as _, panic_abort as _};
use cortex_m_rt::{entry, exception, ExceptionFrame};
use embrio_nrf51::{interrupts, uart::BAUDRATEW, EmbrioNrf51};
#[entry]
fn main() -> ! {
let mut nrf51 = EmbrioNrf51::take().unwrap();
let mut txpin = nrf51.pins.9.output().push_pull();
let mut rxpin = nrf51.pins.11.input().floating();
let (tx, rx) =
nrf51
.uart
.init(&mut txpin, &mut rxpin, BAUDRATEW::BAUD115200);
unsafe { hello::main(rx, tx) }.unwrap();
unreachable!()
}
#[exception]
fn HardFault(ef: &ExceptionFrame) -> ! {
panic!("HardFault at {:#?}", ef);
}
#[exception]
fn DefaultHandler(irqn: i16) {
panic!("Unhandled exception (IRQn = {})", irqn);
}
interrupts!();