Skip to content

Commit 0e2ec97

Browse files
committed
make the hello example work
1 parent f6988f1 commit 0e2ec97

File tree

2 files changed

+20
-13
lines changed

2 files changed

+20
-13
lines changed

Cargo.toml

+4-1
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,16 @@ version = "0.2.7"
1212
# cortex-m = "0.4.0"
1313
# cortex-m-rt = "0.4.0"
1414
cortex-m-rt = { git = "https://github.com/japaric/cortex-m-rt", branch = "stable" }
15-
# cortex-m-semihosting = "0.2.0"
1615
# panic-loop = { path = "../panic-loop" }
1716
panic-abort = "0.1.1"
1817
# panic-semihosting = "0.1.0"
1918
# Uncomment for the allocator example.
2019
#alloc-cortex-m = "0.3.3"
2120

21+
[dependencies.cortex-m-semihosting]
22+
default-features = false
23+
version = "0.2.1"
24+
2225
# Uncomment for the device example.
2326
# [dependencies.stm32f103xx]
2427
# features = ["rt"]

examples/hello.rs

+16-12
Original file line numberDiff line numberDiff line change
@@ -2,29 +2,33 @@
22
//!
33
//! ---
44
5-
#![feature(used)]
5+
#![feature(asm)]
6+
#![no_main]
67
#![no_std]
78

8-
extern crate cortex_m;
9+
#[macro_use]
910
extern crate cortex_m_rt;
10-
extern crate cortex_m_semihosting;
11+
extern crate cortex_m_semihosting as sh;
1112
extern crate panic_abort; // panicking behavior
1213

1314
use core::fmt::Write;
1415

15-
use cortex_m::asm;
16-
use cortex_m_semihosting::hio;
16+
use sh::hio;
1717

18-
fn main() {
18+
main!(main);
19+
20+
fn main() -> ! {
1921
let mut stdout = hio::hstdout().unwrap();
2022
writeln!(stdout, "Hello, world!").unwrap();
23+
24+
loop {}
2125
}
2226

23-
// As we are not using interrupts, we just register a dummy catch all handler
24-
#[link_section = ".vector_table.interrupts"]
25-
#[used]
26-
static INTERRUPTS: [extern "C" fn(); 240] = [default_handler; 240];
27+
exception!(DefaultHandler, dh);
2728

28-
extern "C" fn default_handler() {
29-
asm::bkpt();
29+
fn dh(_nr: u8) -> ! {
30+
loop {}
3031
}
32+
33+
// As we are not using interrupts, we just bind them all to the `DefaultHandler` exception handler
34+
interrupts!(DefaultHandler);

0 commit comments

Comments
 (0)