This repository was archived by the owner on Jul 29, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 4 files changed +12
-34
lines changed
Expand file tree Collapse file tree 4 files changed +12
-34
lines changed Original file line number Diff line number Diff line change 1717extern crate panic_halt;
1818
1919use core:: alloc:: Layout ;
20- use core:: fmt:: Write ;
2120
2221use alloc:: vec;
2322use alloc_cortex_m:: CortexMHeap ;
2423use cortex_m:: asm;
2524use cortex_m_rt:: entry;
26- use cortex_m_semihosting:: hio ;
25+ use cortex_m_semihosting:: hprintln ;
2726
2827// this is the allocator the application will use
2928#[ global_allocator]
@@ -39,8 +38,7 @@ fn main() -> ! {
3938 // Growable array allocated on the heap
4039 let xs = vec ! [ 0 , 1 , 2 ] ;
4140
42- let mut stdout = hio:: hstdout ( ) . unwrap ( ) ;
43- writeln ! ( stdout, "{:?}" , xs) . unwrap ( ) ;
41+ hprintln ! ( "{:?}" , xs) . unwrap ( ) ;
4442
4543 loop { }
4644}
Original file line number Diff line number Diff line change 2727#[ allow( unused_extern_crates) ]
2828extern crate panic_halt;
2929
30- use core:: fmt:: Write ;
31-
3230use cortex_m:: peripheral:: syst:: SystClkSource ;
3331use cortex_m_rt:: entry;
34- use cortex_m_semihosting:: hio :: { self , HStdout } ;
32+ use cortex_m_semihosting:: hprint ;
3533use stm32f30x:: { interrupt, Interrupt } ;
3634
3735#[ entry]
@@ -58,14 +56,8 @@ fn main() -> ! {
5856}
5957
6058// try commenting out this line: you'll end in `default_handler` instead of in `exti0`
61- interrupt ! ( EXTI0 , exti0, state: Option <HStdout > = None ) ;
62-
63- fn exti0 ( state : & mut Option < HStdout > ) {
64- if state. is_none ( ) {
65- * state = Some ( hio:: hstdout ( ) . unwrap ( ) ) ;
66- }
59+ interrupt ! ( EXTI0 , exti0) ;
6760
68- if let Some ( hstdout) = state. as_mut ( ) {
69- hstdout. write_str ( "." ) . unwrap ( ) ;
70- }
61+ fn exti0 ( ) {
62+ hprint ! ( "." ) . unwrap ( ) ;
7163}
Original file line number Diff line number Diff line change 1212
1313extern crate panic_halt;
1414
15- use core:: fmt:: Write ;
16-
1715use cortex_m:: peripheral:: syst:: SystClkSource ;
1816use cortex_m:: Peripherals ;
1917use cortex_m_rt:: { entry, exception} ;
20- use cortex_m_semihosting:: hio :: { self , HStdout } ;
18+ use cortex_m_semihosting:: hprint ;
2119
2220#[ entry]
2321fn main ( ) -> ! {
@@ -35,13 +33,5 @@ fn main() -> ! {
3533
3634#[ exception]
3735fn SysTick ( ) {
38- static mut STDOUT : Option < HStdout > = None ;
39-
40- if STDOUT . is_none ( ) {
41- * STDOUT = Some ( hio:: hstdout ( ) . unwrap ( ) ) ;
42- }
43-
44- if let Some ( hstdout) = STDOUT . as_mut ( ) {
45- hstdout. write_str ( "." ) . unwrap ( ) ;
46- }
36+ hprint ! ( "." ) . unwrap ( ) ;
4737}
Original file line number Diff line number Diff line change 55
66extern crate panic_halt;
77
8- use core:: fmt:: Write ;
9-
108use cortex_m_rt:: entry;
11- use cortex_m_semihosting:: { debug, hio } ;
9+ use cortex_m_semihosting:: { debug, hprintln } ;
1210
1311#[ entry]
1412fn main ( ) -> ! {
15- let mut stdout = hio:: hstdout ( ) . unwrap ( ) ;
16- writeln ! ( stdout, "Hello, world!" ) . unwrap ( ) ;
13+ hprintln ! ( "Hello, world!" ) . unwrap ( ) ;
1714
18- // exit QEMU or the debugger section
15+ // exit QEMU
16+ // NOTE do not run this on hardware; it can corrupt OpenOCD state
1917 debug:: exit ( debug:: EXIT_SUCCESS ) ;
2018
2119 loop { }
You can’t perform that action at this time.
0 commit comments