1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58
//! Sends "Hello, world!" through the ITM port 0 //! //! ITM is much faster than semihosting. Like 4 orders of magnitude or so. //! //! **NOTE** Cortex-M0 chips don't support ITM. //! //! You'll have to connect the microcontroller's SWO pin to the SWD interface. Note that some //! development boards don't provide this option. //! //! You'll need [`itmdump`] to receive the message on the host plus you'll need to uncomment two //! `monitor` commands in the `.gdbinit` file. //! //! [`itmdump`]: https://docs.rs/itm/0.2.1/itm/ //! //! --- //! //! ``` //! //! #![no_main] //! #![no_std] //! //! #[macro_use] //! extern crate cortex_m; //! #[macro_use] //! extern crate cortex_m_rt as rt; //! extern crate panic_semihosting; //! //! use cortex_m::{asm, Peripherals}; //! use rt::ExceptionFrame; //! //! entry!(main); //! //! fn main() -> ! { //! let mut p = Peripherals::take().unwrap(); //! let stim = &mut p.ITM.stim[0]; //! //! iprintln!(stim, "Hello, world!"); //! //! loop { //! asm::bkpt(); //! } //! } //! //! // define the hard fault handler //! exception!(HardFault, hard_fault); //! //! fn hard_fault(ef: &ExceptionFrame) -> ! { //! panic!("HardFault at {:#?}", ef); //! } //! //! // define the default exception handler //! exception!(*, default_handler); //! //! fn default_handler(irqn: i16) { //! panic!("Unhandled exception (IRQn = {})", irqn); //! } //! ``` // Auto-generated. Do not modify.