aboutsummaryrefslogtreecommitdiff
path: root/cortex-m-rt/examples
diff options
context:
space:
mode:
authorGravatar Jorge Aparicio <jorge@japaric.io> 2018-08-18 22:45:13 +0200
committerGravatar Jorge Aparicio <jorge@japaric.io> 2018-08-31 00:38:10 +0200
commitf2a155a0715cb99cbace2eca7ab5fcfa93d106d2 (patch)
tree2066fedfc4218770521dac35337073088c1a6759 /cortex-m-rt/examples
parent0fb051055a0340ad6c5b59d18183c260468e455f (diff)
downloadcortex-m-f2a155a0715cb99cbace2eca7ab5fcfa93d106d2.tar.gz
cortex-m-f2a155a0715cb99cbace2eca7ab5fcfa93d106d2.tar.zst
cortex-m-f2a155a0715cb99cbace2eca7ab5fcfa93d106d2.zip
turn macros into attributes
Diffstat (limited to 'cortex-m-rt/examples')
-rw-r--r--cortex-m-rt/examples/alignment.rs4
-rw-r--r--cortex-m-rt/examples/data_overflow.rs4
-rw-r--r--cortex-m-rt/examples/device.rs5
-rw-r--r--cortex-m-rt/examples/minimal.rs6
-rw-r--r--cortex-m-rt/examples/override-exception.rs13
-rw-r--r--cortex-m-rt/examples/pre_init.rs8
-rw-r--r--cortex-m-rt/examples/state.rs12
7 files changed, 21 insertions, 31 deletions
diff --git a/cortex-m-rt/examples/alignment.rs b/cortex-m-rt/examples/alignment.rs
index 5635851..25d755d 100644
--- a/cortex-m-rt/examples/alignment.rs
+++ b/cortex-m-rt/examples/alignment.rs
@@ -4,13 +4,12 @@
#![no_main]
#![no_std]
-#[macro_use(entry)]
extern crate cortex_m_rt as rt;
extern crate panic_abort;
use core::ptr;
-entry!(main);
+use rt::entry;
static mut BSS1: u16 = 0;
static mut BSS2: u8 = 0;
@@ -19,6 +18,7 @@ static mut DATA2: u16 = 1;
static RODATA1: &[u8; 3] = b"012";
static RODATA2: &[u8; 2] = b"34";
+#[entry]
fn main() -> ! {
unsafe {
let _bss1 = ptr::read_volatile(&BSS1);
diff --git a/cortex-m-rt/examples/data_overflow.rs b/cortex-m-rt/examples/data_overflow.rs
index 396f1c8..ceec18b 100644
--- a/cortex-m-rt/examples/data_overflow.rs
+++ b/cortex-m-rt/examples/data_overflow.rs
@@ -5,13 +5,12 @@
#![no_main]
#![no_std]
-#[macro_use(entry)]
extern crate cortex_m_rt as rt;
extern crate panic_abort;
use core::ptr;
-entry!(main);
+use rt::entry;
// This large static array uses most of .rodata
static RODATA: [u8; 48*1024] = [1u8; 48*1024];
@@ -20,6 +19,7 @@ static RODATA: [u8; 48*1024] = [1u8; 48*1024];
// without also overflowing RAM.
static mut DATA: [u8; 16*1024] = [1u8; 16*1024];
+#[entry]
fn main() -> ! {
unsafe {
let _bigdata = ptr::read_volatile(&RODATA as *const u8);
diff --git a/cortex-m-rt/examples/device.rs b/cortex-m-rt/examples/device.rs
index 4395db2..950a564 100644
--- a/cortex-m-rt/examples/device.rs
+++ b/cortex-m-rt/examples/device.rs
@@ -5,13 +5,12 @@
#![no_main]
#![no_std]
-#[macro_use(entry)]
extern crate cortex_m_rt as rt;
extern crate panic_semihosting;
-// the program entry point
-entry!(main);
+use rt::entry;
+#[entry]
fn main() -> ! {
loop {}
}
diff --git a/cortex-m-rt/examples/minimal.rs b/cortex-m-rt/examples/minimal.rs
index a036046..6f60180 100644
--- a/cortex-m-rt/examples/minimal.rs
+++ b/cortex-m-rt/examples/minimal.rs
@@ -5,13 +5,13 @@
#![no_main]
#![no_std]
-#[macro_use(entry)]
extern crate cortex_m_rt as rt;
extern crate panic_semihosting;
-// the program entry point
-entry!(main);
+use rt::entry;
+// the program entry point
+#[entry]
fn main() -> ! {
loop {}
}
diff --git a/cortex-m-rt/examples/override-exception.rs b/cortex-m-rt/examples/override-exception.rs
index 2f100a2..dca31e6 100644
--- a/cortex-m-rt/examples/override-exception.rs
+++ b/cortex-m-rt/examples/override-exception.rs
@@ -6,28 +6,23 @@
#![no_std]
extern crate cortex_m;
-#[macro_use(entry, exception)]
extern crate cortex_m_rt as rt;
extern crate panic_semihosting;
use cortex_m::asm;
-use rt::ExceptionFrame;
-
-// the program entry point
-entry!(main);
+use rt::{entry, exception, ExceptionFrame};
+#[entry]
fn main() -> ! {
loop {}
}
-exception!(*, default_handler);
-
+#[exception(DefaultHandler)]
fn default_handler(_irqn: i16) {
asm::bkpt();
}
-exception!(HardFault, hard_fault);
-
+#[exception(HardFault)]
fn hard_fault(_ef: &ExceptionFrame) -> ! {
asm::bkpt();
diff --git a/cortex-m-rt/examples/pre_init.rs b/cortex-m-rt/examples/pre_init.rs
index 7258936..00e2f2c 100644
--- a/cortex-m-rt/examples/pre_init.rs
+++ b/cortex-m-rt/examples/pre_init.rs
@@ -4,19 +4,17 @@
#![no_main]
#![no_std]
-#[macro_use(entry, pre_init)]
extern crate cortex_m_rt as rt;
extern crate panic_semihosting;
-pre_init!(disable_watchdog);
+use rt::{entry, pre_init};
+#[pre_init]
unsafe fn disable_watchdog() {
// Do what you need to disable the watchdog.
}
-// the program entry point
-entry!(main);
-
+#[entry]
fn main() -> ! {
loop {}
}
diff --git a/cortex-m-rt/examples/state.rs b/cortex-m-rt/examples/state.rs
index dbacdaf..72ca194 100644
--- a/cortex-m-rt/examples/state.rs
+++ b/cortex-m-rt/examples/state.rs
@@ -5,20 +5,18 @@
#![no_main]
#![no_std]
-#[macro_use(entry, exception)]
extern crate cortex_m_rt as rt;
extern crate panic_semihosting;
-// the program entry point
-entry!(main);
+use rt::{entry, exception};
+#[entry]
fn main() -> ! {
loop {}
}
// exception handler with state
-exception!(SysTick, sys_tick, state: u32 = 0);
-
-fn sys_tick(state: &mut u32) {
- *state += 1;
+#[exception(SysTick, static STATE: u32 = 0)]
+fn sys_tick() {
+ *STATE += 1;
}