Skip to content

Commit

Permalink
Temp commit for link script modification.
Browse files Browse the repository at this point in the history
  • Loading branch information
zyma98 committed Sep 2, 2024
1 parent d5cc263 commit 1e66d75
Show file tree
Hide file tree
Showing 7 changed files with 214 additions and 127 deletions.
7 changes: 4 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,10 @@ features = ["nightly"]
nb = "1.1"

[dev-dependencies.stm32f4xx-hal]
git = "https://github.com/ZhiyaoMa98/stm32f4xx-hal.git"
branch = "dependency"
default-features = false
# git = "https://github.com/ZhiyaoMa98/stm32f4xx-hal.git"
# branch = "dependency"
# default-features = false
version = "0.21.0"
features = ["stm32f405"]

# *** Tests for sync - mailbox ***
Expand Down
22 changes: 22 additions & 0 deletions examples/breathing_task.rs
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();
}
50 changes: 50 additions & 0 deletions examples/over_limit_dynamic_stack.rs
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);
}
}
Loading

0 comments on commit 1e66d75

Please sign in to comment.