Skip to content

Commit a03ad00

Browse files
author
Jorge Aparicio
committed
adapt to changes in cortex-m-srp
1 parent b83ad5a commit a03ad00

File tree

7 files changed

+83
-111
lines changed

7 files changed

+83
-111
lines changed

.gdbinit

+2-1
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,6 @@ monitor arm semihosting enable
44
# monitor tpiu config internal itm.fifo uart off 8000000
55
# monitor itm port 0 on
66
load
7-
tbreak start
7+
tbreak cortex_m_rt::reset_handler
8+
monitor reset halt
89
continue

Cargo.toml

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ name = "cortex-m-quickstart"
44
version = "0.0.0"
55

66
[dependencies]
7-
cortex-m = "0.2.1"
7+
cortex-m = "0.2.2"
88
cortex-m-rt = { git = "https://github.com/japaric/cortex-m-rt" }
9-
cortex-m-srp = { git = "https://github.com/japaric/cortex-m-srp" }
9+
cortex-m-srp = { git = "https://github.com/japaric/cortex-m-srp", branch = "next" }
1010
{{name}} = "*"
1111

1212
[features]

examples/blinky.rs

-82
This file was deleted.

examples/hello.rs

+5-7
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,21 @@
11
//! Prints "Hello, world!" on the OpenOCD console using semihosting
22
3+
#![feature(used)]
34
#![no_std]
45

56
#[macro_use]
67
extern crate cortex_m;
78
extern crate cortex_m_rt;
89
extern crate {{name}};
910

10-
use cortex_m::exception;
1111
use {{name}}::interrupt;
1212

1313
fn main() {
1414
hprintln!("Hello, world!");
1515
}
1616

17-
#[no_mangle]
18-
pub static _INTERRUPTS: interrupt::Handlers =
17+
#[allow(dead_code)]
18+
#[used]
19+
#[link_section = ".rodata.interrupts"]
20+
static INTERRUPTS: interrupt::Handlers =
1921
interrupt::Handlers { ..interrupt::DEFAULT_HANDLERS };
20-
21-
#[no_mangle]
22-
pub static _EXCEPTIONS: exception::Handlers =
23-
exception::Handlers { ..exception::DEFAULT_HANDLERS };

examples/itm.rs

+12-11
Original file line numberDiff line numberDiff line change
@@ -5,28 +5,29 @@
55
//!
66
//! [`itmdump`]: https://docs.rs/itm/0.1.1/itm/
77
8+
#![feature(used)]
89
#![no_std]
910

1011
#[macro_use]
1112
extern crate cortex_m;
1213
extern crate cortex_m_rt;
1314
extern crate {{name}};
1415

15-
use cortex_m::{exception, peripheral};
16+
use cortex_m::peripheral;
1617
use {{name}}::interrupt;
1718

1819
fn main() {
19-
cortex_m::interrupt::free(|cs| {
20-
let itm = peripheral::ITM.borrow(&cs);
20+
cortex_m::interrupt::free(
21+
|cs| {
22+
let itm = peripheral::ITM.borrow(&cs);
2123

22-
iprintln!(&itm.stim[0], "Hello, world!");
23-
});
24+
iprintln!(&itm.stim[0], "Hello, world!");
25+
},
26+
);
2427
}
2528

26-
#[no_mangle]
27-
pub static _INTERRUPTS: interrupt::Handlers =
29+
#[allow(dead_code)]
30+
#[used]
31+
#[link_section = ".rodata.interrupts"]
32+
static INTERRUPTS: interrupt::Handlers =
2833
interrupt::Handlers { ..interrupt::DEFAULT_HANDLERS };
29-
30-
#[no_mangle]
31-
pub static _EXCEPTIONS: exception::Handlers =
32-
exception::Handlers { ..exception::DEFAULT_HANDLERS };

examples/minimal.rs

+5-8
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,17 @@
11
//! Minimal application
22
3+
#![feature(used)]
34
#![no_std]
45

5-
extern crate cortex_m;
66
extern crate cortex_m_rt;
77
extern crate {{name}};
88

9-
use cortex_m::exception;
109
use {{name}}::interrupt;
1110

1211
fn main() {}
1312

14-
#[no_mangle]
15-
pub static _INTERRUPTS: interrupt::Handlers =
13+
#[allow(dead_code)]
14+
#[used]
15+
#[link_section = ".rodata.interrupts"]
16+
static INTERRUPTS: interrupt::Handlers =
1617
interrupt::Handlers { ..interrupt::DEFAULT_HANDLERS };
17-
18-
#[no_mangle]
19-
pub static _EXCEPTIONS: exception::Handlers =
20-
exception::Handlers { ..exception::DEFAULT_HANDLERS };

examples/srp.rs

+57
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
#![feature(const_fn)]
2+
#![feature(used)]
3+
#![no_std]
4+
5+
#[macro_use]
6+
extern crate cortex_m;
7+
extern crate cortex_m_rt;
8+
#[macro_use]
9+
extern crate cortex_m_srp as rtfm;
10+
extern crate {{name}};
11+
12+
use rtfm::{C2, C4, C16, P0, P1, P3, Resource};
13+
use {{name}}::interrupt::{Exti0Irq, Exti1Irq};
14+
15+
static R1: Resource<(), C4> = Resource::new(());
16+
static R2: Resource<(), C2> = Resource::new(());
17+
18+
fn init(_ceil: C16) {}
19+
20+
fn idle(_prio: P0) {
21+
hprintln!("IDLE");
22+
23+
rtfm::request(j1);
24+
}
25+
26+
tasks!({{name}}, {
27+
j1: (Exti0Irq, P1),
28+
j2: (Exti1Irq, P3),
29+
});
30+
31+
fn j1(_task: Exti0Irq, prio: P1) {
32+
hprintln!("J1: enter");
33+
R2.lock(
34+
&prio, |_, _| {
35+
rtfm::request(j2);
36+
hprintln!("J1: after requesting J2");
37+
R1.lock(
38+
&prio, |_, _| {
39+
hprintln!("J1(R1): before requesting J2");
40+
rtfm::request(j2);
41+
hprintln!("J1(R1): after requesting J2");
42+
}
43+
);
44+
}
45+
);
46+
hprintln!("J1: exit");
47+
}
48+
49+
fn j2(_task: Exti1Irq, prio: P3) {
50+
hprintln!("J2: enter");
51+
R1.lock(
52+
&prio, |_, _| {
53+
hprintln!("J2(R1)");
54+
}
55+
);
56+
hprintln!("J2: exit");
57+
}

0 commit comments

Comments
 (0)