-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Temp commit for link script modification.
- Loading branch information
Showing
7 changed files
with
214 additions
and
127 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#![no_std] | ||
#![no_main] | ||
|
||
extern crate alloc; | ||
use hopter::{ | ||
debug::semihosting::{self, dbg_println}, | ||
task::{main, self}, | ||
time, | ||
}; | ||
|
||
// Attribute `#[main]` marks the function as the entry function for the main | ||
// task. The function name can be arbitrary. The main function should accept | ||
// one argument which is the Cortex-M core peripherals. | ||
#[main] | ||
fn main(_: cortex_m::Peripherals) { | ||
task::build_breathing() | ||
.set_init(|| {}) | ||
.set_wait(|_| time::sleep_ms(1000)) | ||
.set_work(|_, _| dbg_println!("Hello")) | ||
.spawn() | ||
.unwrap(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
#![no_std] | ||
#![no_main] | ||
|
||
extern crate alloc; | ||
use core::usize; | ||
|
||
use hopter::{ | ||
config, | ||
debug::semihosting::{self, dbg_println}, | ||
task::{self, main}, | ||
}; | ||
|
||
#[main] | ||
fn main(_: cortex_m::Peripherals) { | ||
task::build() | ||
.set_entry(test_task) | ||
.set_stack_limit(512) | ||
.spawn() | ||
.unwrap(); | ||
|
||
task::change_current_priority(config::UNWIND_PRIORITY + 1).unwrap(); | ||
|
||
semihosting::terminate(true); | ||
} | ||
|
||
fn test_task() { | ||
let print_on_drop = PrintOnDrop("Dropped during unwinding"); | ||
|
||
let val = fib(usize::MAX); | ||
|
||
core::mem::forget(print_on_drop); | ||
|
||
dbg_println!("{}", val); | ||
} | ||
|
||
fn fib(x: usize) -> usize { | ||
if x <= 1 { | ||
return x; | ||
} else { | ||
return fib(x - 1).overflowing_add(fib(x - 2)).0; | ||
} | ||
} | ||
|
||
struct PrintOnDrop(&'static str); | ||
|
||
impl Drop for PrintOnDrop { | ||
fn drop(&mut self) { | ||
dbg_println!("{}", self.0); | ||
} | ||
} |
Oops, something went wrong.