Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions cortex-m-rt/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).

## [Unreleased]

- Mark `pre_init` as deprecated
- Add `set_msplim` feature to conditionally set the MSPLIM register at device
reset ([#580]).

Expand Down
13 changes: 9 additions & 4 deletions cortex-m-rt/examples/pre_init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,16 @@
extern crate cortex_m_rt as rt;
extern crate panic_halt;

use rt::{entry, pre_init};
use rt::entry;

#[pre_init]
unsafe fn disable_watchdog() {
// Do what you need to disable the watchdog.
// This function is called before the RAM is initialized.
// For example, it can be used to disable the watchdog.
core::arch::global_asm! {
r#"
__pre_init:
// Do what you need to do before RAM is initialized.
bx lr
"#
}

#[entry]
Expand Down
1 change: 1 addition & 0 deletions cortex-m-rt/macros/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -628,6 +628,7 @@ pub fn interrupt(args: TokenStream, input: TokenStream) -> TokenStream {
}

#[proc_macro_attribute]
#[deprecated(note = "Use core::arch::global_asm! to define the __pre_init function instead")]
pub fn pre_init(args: TokenStream, input: TokenStream) -> TokenStream {
let f = parse_macro_input!(input as ItemFn);

Expand Down
1 change: 1 addition & 0 deletions cortex-m-rt/tests/compile-fail/pre-init-args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ extern crate panic_halt;
use cortex_m_rt::{entry, pre_init};

#[pre_init(foo)] //~ ERROR This attribute accepts no arguments
//~^ WARNING Use core::arch::global_asm! to define the __pre_init function instead
unsafe fn foo() {}

#[entry]
Expand Down
2 changes: 1 addition & 1 deletion cortex-m-rt/tests/compile-fail/pre-init-bad-signature-1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ extern crate panic_halt;

use cortex_m_rt::{entry, pre_init};

#[pre_init]
#[pre_init] //~ WARNING Use core::arch::global_asm! to define the __pre_init function instead
fn foo() {}
//~^ ERROR `#[pre_init]` function must have signature `unsafe fn()`

Expand Down
2 changes: 1 addition & 1 deletion cortex-m-rt/tests/compile-fail/pre-init-bad-signature-2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ extern crate panic_halt;

use cortex_m_rt::{entry, pre_init};

#[pre_init]
#[pre_init] //~ WARNING Use core::arch::global_asm! to define the __pre_init function instead
unsafe fn foo(undef: i32) {}
//~^ ERROR `#[pre_init]` function must have signature `unsafe fn()`

Expand Down
3 changes: 2 additions & 1 deletion cortex-m-rt/tests/compile-fail/pre-init-twice.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@ extern crate panic_halt;

use cortex_m_rt::{entry, pre_init};

#[pre_init]
#[pre_init] //~ WARNING Use core::arch::global_asm! to define the __pre_init function instead
unsafe fn foo() {}

#[pre_init] //~ ERROR symbol `__pre_init` is already defined
//~^ WARNING Use core::arch::global_asm! to define the __pre_init function instead
unsafe fn bar() {}

#[entry]
Expand Down