Skip to content

Commit cc69b8e

Browse files
authored
Merge pull request #18 from YuhanLiin/pre-entry-interrupt
Allow enabling interrupts before entry and pre-interrupt init functions
2 parents 0f018b6 + d2ea644 commit cc69b8e

31 files changed

+539
-168
lines changed

macros/src/lib.rs

Lines changed: 255 additions & 67 deletions
Large diffs are not rendered by default.

macros/tests/ui/entry_args.stderr

Lines changed: 0 additions & 7 deletions
This file was deleted.
File renamed without changes.

macros/tests/ui/entry_bad_arg.stderr

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
error: expected `interrupt_enable` or no arguments at all
2+
--> tests/ui/entry_bad_arg.rs:5:9
3+
|
4+
5 | #[entry(arg)]
5+
| ^^^
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#![no_main]
2+
3+
use msp430::interrupt::CriticalSection;
4+
use msp430_rt_macros::entry;
5+
6+
fn init(cs: CriticalSection) -> u32 {
7+
32
8+
}
9+
10+
#[entry(interrupt_enable(pre_interrupt = init))]
11+
fn main(_i: bool) -> ! {
12+
loop {}
13+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
error[E0308]: mismatched types
2+
--> tests/ui/entry_preinterrupt_mismatch.rs:10:1
3+
|
4+
10 | #[entry(interrupt_enable(pre_interrupt = init))]
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `bool`, found `u32`
6+
|
7+
= note: this error originates in the attribute macro `entry` (in Nightly builds, run with -Z macro-backtrace for more info)
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#![no_main]
2+
3+
use msp430_rt_macros::entry;
4+
5+
fn init() {}
6+
7+
#[entry(interrupt_enable(pre_interrupt = init))]
8+
fn main() -> ! {
9+
loop {}
10+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
error[E0061]: this function takes 0 arguments but 1 argument was supplied
2+
--> tests/ui/entry_preinterrupt_no_arg.rs:7:42
3+
|
4+
7 | #[entry(interrupt_enable(pre_interrupt = init))]
5+
| -----------------------------------------^^^^---
6+
| | |
7+
| | expected 0 arguments
8+
| supplied 1 argument
9+
|
10+
note: function defined here
11+
--> tests/ui/entry_preinterrupt_no_arg.rs:5:4
12+
|
13+
5 | fn init() {}
14+
| ^^^^
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#![no_main]
2+
3+
use msp430::interrupt::CriticalSection;
4+
use msp430_rt_macros::entry;
5+
6+
fn init<'a>(cs: CriticalSection<'a>) -> CriticalSection<'a> {
7+
cs
8+
}
9+
10+
#[entry(interrupt_enable(pre_interrupt = init))]
11+
fn main(_cs: CriticalSection) -> ! {
12+
loop {}
13+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
error[E0597]: `cs` does not live long enough
2+
--> tests/ui/entry_preinterrupt_return_cs.rs:10:1
3+
|
4+
10 | #[entry(interrupt_enable(pre_interrupt = init))]
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-
6+
| | |
7+
| | `cs` dropped here while still borrowed
8+
| borrowed value does not live long enough
9+
| borrow later stored here
10+
|
11+
= note: this error originates in the attribute macro `entry` (in Nightly builds, run with -Z macro-backtrace for more info)

0 commit comments

Comments
 (0)