File tree Expand file tree Collapse file tree 13 files changed +517
-281
lines changed Expand file tree Collapse file tree 13 files changed +517
-281
lines changed Original file line number Diff line number Diff line change 1
1
** /* .rs.bk
2
+ . # *
2
3
Cargo.lock
3
4
bin /* .after
4
5
bin /* .before
Original file line number Diff line number Diff line change @@ -12,6 +12,7 @@ version = "0.5.3"
12
12
13
13
[dependencies ]
14
14
r0 = " 0.2.1"
15
+ cortex-m-rt-macros = { path = " macros" , version = " 0.1.0" }
15
16
16
17
[dev-dependencies ]
17
18
panic-semihosting = " 0.3.0"
Original file line number Diff line number Diff line change 5
5
6
6
cargo check --target $TARGET --features device
7
7
8
+ ( cd macros && cargo check && cargo test )
9
+
8
10
local examples=(
9
11
alignment
10
12
minimal
Original file line number Diff line number Diff line change 4
4
#![ no_main]
5
5
#![ no_std]
6
6
7
- #[ macro_use( entry) ]
8
7
extern crate cortex_m_rt as rt;
9
8
extern crate panic_abort;
10
9
11
10
use core:: ptr;
12
11
13
- entry ! ( main ) ;
12
+ use rt :: entry;
14
13
15
14
static mut BSS1 : u16 = 0 ;
16
15
static mut BSS2 : u8 = 0 ;
@@ -19,6 +18,7 @@ static mut DATA2: u16 = 1;
19
18
static RODATA1 : & [ u8 ; 3 ] = b"012" ;
20
19
static RODATA2 : & [ u8 ; 2 ] = b"34" ;
21
20
21
+ #[ entry]
22
22
fn main ( ) -> ! {
23
23
unsafe {
24
24
let _bss1 = ptr:: read_volatile ( & BSS1 ) ;
Original file line number Diff line number Diff line change 5
5
#![ no_main]
6
6
#![ no_std]
7
7
8
- #[ macro_use( entry) ]
9
8
extern crate cortex_m_rt as rt;
10
9
extern crate panic_abort;
11
10
12
11
use core:: ptr;
13
12
14
- entry ! ( main ) ;
13
+ use rt :: entry;
15
14
16
15
// This large static array uses most of .rodata
17
16
static RODATA : [ u8 ; 48 * 1024 ] = [ 1u8 ; 48 * 1024 ] ;
@@ -20,6 +19,7 @@ static RODATA: [u8; 48*1024] = [1u8; 48*1024];
20
19
// without also overflowing RAM.
21
20
static mut DATA : [ u8 ; 16 * 1024 ] = [ 1u8 ; 16 * 1024 ] ;
22
21
22
+ #[ entry]
23
23
fn main ( ) -> ! {
24
24
unsafe {
25
25
let _bigdata = ptr:: read_volatile ( & RODATA as * const u8 ) ;
Original file line number Diff line number Diff line change 5
5
#![ no_main]
6
6
#![ no_std]
7
7
8
- #[ macro_use( entry) ]
9
8
extern crate cortex_m_rt as rt;
10
9
extern crate panic_semihosting;
11
10
12
- // the program entry point
13
- entry ! ( main) ;
11
+ use rt:: entry;
14
12
13
+ #[ entry]
15
14
fn main ( ) -> ! {
16
15
loop { }
17
16
}
Original file line number Diff line number Diff line change 5
5
#![ no_main]
6
6
#![ no_std]
7
7
8
- #[ macro_use( entry) ]
9
8
extern crate cortex_m_rt as rt;
10
9
extern crate panic_semihosting;
11
10
12
- // the program entry point
13
- entry ! ( main) ;
11
+ use rt:: entry;
14
12
13
+ // the program entry point
14
+ #[ entry]
15
15
fn main ( ) -> ! {
16
16
loop { }
17
17
}
Original file line number Diff line number Diff line change 6
6
#![ no_std]
7
7
8
8
extern crate cortex_m;
9
- #[ macro_use( entry, exception) ]
10
9
extern crate cortex_m_rt as rt;
11
10
extern crate panic_semihosting;
12
11
13
12
use cortex_m:: asm;
14
- use rt:: ExceptionFrame ;
15
-
16
- // the program entry point
17
- entry ! ( main) ;
13
+ use rt:: { entry, exception, ExceptionFrame } ;
18
14
15
+ #[ entry]
19
16
fn main ( ) -> ! {
20
17
loop { }
21
18
}
22
19
23
- exception ! ( * , default_handler) ;
24
-
20
+ #[ exception( DefaultHandler ) ]
25
21
fn default_handler ( _irqn : i16 ) {
26
22
asm:: bkpt ( ) ;
27
23
}
28
24
29
- exception ! ( HardFault , hard_fault) ;
30
-
25
+ #[ exception( HardFault ) ]
31
26
fn hard_fault ( _ef : & ExceptionFrame ) -> ! {
32
27
asm:: bkpt ( ) ;
33
28
Original file line number Diff line number Diff line change 4
4
#![ no_main]
5
5
#![ no_std]
6
6
7
- #[ macro_use( entry, pre_init) ]
8
7
extern crate cortex_m_rt as rt;
9
8
extern crate panic_semihosting;
10
9
11
- pre_init ! ( disable_watchdog ) ;
10
+ use rt :: { entry , pre_init} ;
12
11
12
+ #[ pre_init]
13
13
unsafe fn disable_watchdog ( ) {
14
14
// Do what you need to disable the watchdog.
15
15
}
16
16
17
- // the program entry point
18
- entry ! ( main) ;
19
-
17
+ #[ entry]
20
18
fn main ( ) -> ! {
21
19
loop { }
22
20
}
Original file line number Diff line number Diff line change 5
5
#![ no_main]
6
6
#![ no_std]
7
7
8
- #[ macro_use( entry, exception) ]
9
8
extern crate cortex_m_rt as rt;
10
9
extern crate panic_semihosting;
11
10
12
- // the program entry point
13
- entry ! ( main) ;
11
+ use rt:: { entry, exception} ;
14
12
13
+ #[ entry]
15
14
fn main ( ) -> ! {
16
15
loop { }
17
16
}
18
17
19
18
// exception handler with state
20
- exception ! ( SysTick , sys_tick, state: u32 = 0 ) ;
21
-
22
- fn sys_tick ( state : & mut u32 ) {
23
- * state += 1 ;
19
+ #[ exception( SysTick , static STATE : u32 = 0 ) ]
20
+ fn sys_tick ( ) {
21
+ * STATE += 1 ;
24
22
}
Original file line number Diff line number Diff line change
1
+ [package ]
2
+ name = " cortex-m-rt-macros"
3
+ version = " 0.1.0"
4
+ authors = [" Jorge Aparicio <jorge@japaric.io>" ]
5
+
6
+ [lib ]
7
+ proc-macro = true
8
+
9
+ [dependencies ]
10
+ quote = " 0.6.6"
11
+
12
+ [dependencies .syn ]
13
+ features = [" extra-traits" , " full" ]
14
+ version = " 0.14.8"
15
+
16
+ [dev-dependencies ]
17
+ cortex-m-rt = { path = " .." }
You can’t perform that action at this time.
0 commit comments