use hprint macros

This commit is contained in:
Jorge Aparicio
2018-11-09 23:51:11 +01:00
parent 7e2bec66b7
commit 9c6b290e12
4 changed files with 12 additions and 34 deletions

View File

@@ -27,11 +27,9 @@
#[allow(unused_extern_crates)]
extern crate panic_halt;
use core::fmt::Write;
use cortex_m::peripheral::syst::SystClkSource;
use cortex_m_rt::entry;
use cortex_m_semihosting::hio::{self, HStdout};
use cortex_m_semihosting::hprint;
use stm32f30x::{interrupt, Interrupt};
#[entry]
@@ -58,14 +56,8 @@ fn main() -> ! {
}
// try commenting out this line: you'll end in `default_handler` instead of in `exti0`
interrupt!(EXTI0, exti0, state: Option<HStdout> = None);
interrupt!(EXTI0, exti0);
fn exti0(state: &mut Option<HStdout>) {
if state.is_none() {
*state = Some(hio::hstdout().unwrap());
}
if let Some(hstdout) = state.as_mut() {
hstdout.write_str(".").unwrap();
}
fn exti0() {
hprint!(".").unwrap();
}