Skip to content

Commit

Permalink
updates to cortex-m-semihosting
Browse files Browse the repository at this point in the history
  • Loading branch information
Hecatron committed Aug 1, 2024
1 parent 1120699 commit 2c8c13e
Show file tree
Hide file tree
Showing 10 changed files with 28 additions and 28 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ optional = true
version = "0.5.0"

[dev-dependencies]
cortex-m-semihosting = "0.3.7"
cortex-m-semihosting = "0.5.0"
panic-halt = "0.2.0"
panic-semihosting = "0.6.0"
embedded-graphics = "0.6.2"
Expand Down
2 changes: 1 addition & 1 deletion examples/flash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ fn main() -> ! {

// Compare the written data with the expected value.
if flash_data == DATA {
hprintln!("Flash programming successful").unwrap();
hprintln!("Flash programming successful");
}

loop {}
Expand Down
2 changes: 1 addition & 1 deletion examples/fmc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ fn main() -> ! {
}
}

hprintln!("Success!").unwrap();
hprintln!("Success!");

loop {}
}
2 changes: 1 addition & 1 deletion examples/hello.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ use cortex_m_semihosting::hprintln;

#[entry]
fn main() -> ! {
hprintln!("Hello, world!").unwrap();
hprintln!("Hello, world!");
loop {}
}
16 changes: 8 additions & 8 deletions examples/i2c_scanner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,26 +36,26 @@ fn main() -> ! {
50_000,
);

hprintln!("Start i2c scanning...").expect("Error using hprintln.");
hprintln!().unwrap();
hprintln!("Start i2c scanning...");
hprintln!();

for addr in 0x00_u8..0x80 {
// Write the empty array and check the slave response.
let byte: [u8; 1] = [0; 1];
if VALID_ADDR_RANGE.contains(&addr) && i2c.write(addr, &byte).is_ok() {
hprint!("{:02x}", addr).unwrap();
hprint!("{:02x}", addr);
} else {
hprint!("..").unwrap();
hprint!("..");
}
if addr % 0x10 == 0x0F {
hprintln!().unwrap();
hprintln!();
} else {
hprint!(" ").unwrap();
hprint!(" ");
}
}

hprintln!().unwrap();
hprintln!("Done!").unwrap();
hprintln!();
hprintln!("Done!");

loop {}
}
2 changes: 1 addition & 1 deletion examples/rng.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ fn main() -> ! {
let p = pac::Peripherals::take().unwrap();
let mut rng = p.RNG.init();
let val = rng.get_rand().unwrap();
hprintln!("random value {}", val).unwrap();
hprintln!("random value {}", val);
loop {
core::hint::spin_loop();
}
Expand Down
2 changes: 1 addition & 1 deletion examples/rtc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,6 @@ fn main() -> ! {
// rtc.set_minutes(59).unwrap();
// rtc.set_seconds(59).unwrap();
loop {
hprintln!("{}", rtc.get_datetime()).unwrap();
hprintln!("{}", rtc.get_datetime());
}
}
4 changes: 2 additions & 2 deletions examples/stm32f7disco-qspi-flash/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ fn memory_example_polling(mt25q: &mut mt25q::Mt25q) {
}
}

hprintln!("Flash device memory test successful!").unwrap();
hprintln!("Flash device memory test successful!");
}

fn memory_example_dma(
Expand Down Expand Up @@ -174,5 +174,5 @@ fn memory_example_dma(
}
}

hprintln!("Flash device memory DMA test successful!").unwrap();
hprintln!("Flash device memory DMA test successful!");
}
12 changes: 6 additions & 6 deletions examples/timer-periph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,32 +30,32 @@ fn main() -> ! {
let mut timer = dp.TIM1.counter_ms(&clocks);
timer.start(1.secs()).unwrap();

hprintln!("hello!").unwrap();
hprintln!("hello!");
// wait until timer expires
nb::block!(timer.wait()).unwrap();
hprintln!("timer expired 1").unwrap();
hprintln!("timer expired 1");

// the function counter_ms() creates a periodic timer, so it is automatically
// restarted
nb::block!(timer.wait()).unwrap();
hprintln!("timer expired 2").unwrap();
hprintln!("timer expired 2");

// cancel current timer
timer.cancel().unwrap();

// start it again
timer.start(1.secs()).unwrap();
nb::block!(timer.wait()).unwrap();
hprintln!("timer expired 3").unwrap();
hprintln!("timer expired 3");

timer.cancel().unwrap();
let cancel_outcome = timer.cancel();
assert_eq!(cancel_outcome, Err(Error::Disabled));
hprintln!("ehy, you cannot cancel a timer two times!").unwrap();
hprintln!("ehy, you cannot cancel a timer two times!");
// this time the timer was not restarted, therefore this function should
// wait forever
nb::block!(timer.wait()).unwrap();
// you should never see this print
hprintln!("if you see this there is something wrong").unwrap();
hprintln!("if you see this there is something wrong");
panic!();
}
12 changes: 6 additions & 6 deletions examples/timer-syst.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,32 +31,32 @@ fn main() -> ! {
let mut timer = cp.SYST.counter_us(&clocks);
timer.start(42.millis()).unwrap();

hprintln!("hello!").unwrap();
hprintln!("hello!");
// wait until timer expires
nb::block!(timer.wait()).unwrap();
hprintln!("timer expired 1").unwrap();
hprintln!("timer expired 1");

// the function syst() creates a periodic timer, so it is automatically
// restarted
nb::block!(timer.wait()).unwrap();
hprintln!("timer expired 2").unwrap();
hprintln!("timer expired 2");

// cancel current timer
timer.cancel().unwrap();

// start it again
timer.start(42.millis()).unwrap();
nb::block!(timer.wait()).unwrap();
hprintln!("timer expired 3").unwrap();
hprintln!("timer expired 3");

timer.cancel().unwrap();
let cancel_outcome = timer.cancel();
assert_eq!(cancel_outcome, Err(Error::Disabled));
hprintln!("ehy, you cannot cancel a timer two times!").unwrap();
hprintln!("ehy, you cannot cancel a timer two times!");
// this time the timer was not restarted, therefore this function should
// wait forever
nb::block!(timer.wait()).unwrap();
// you should never see this print
hprintln!("if you see this there is something wrong").unwrap();
hprintln!("if you see this there is something wrong");
panic!();
}

0 comments on commit 2c8c13e

Please sign in to comment.