itm.rs 812 B

123456789101112131415161718192021222324252627282930313233
  1. //! Sends "Hello, world!" through the ITM port 0
  2. //!
  3. //! ITM is much faster than semihosting. Like 4 orders of magnitude or so.
  4. //!
  5. //! **NOTE** Cortex-M0 chips don't support ITM.
  6. //!
  7. //! You'll have to connect the microcontroller's SWO pin to the SWD interface. Note that some
  8. //! development boards don't provide this option.
  9. //!
  10. //! You'll need [`itmdump`] to receive the message on the host plus you'll need to uncomment two
  11. //! `monitor` commands in the `.gdbinit` file.
  12. //!
  13. //! [`itmdump`]: https://docs.rs/itm/0.2.1/itm/
  14. //!
  15. //! ---
  16. #![no_main]
  17. #![no_std]
  18. use panic_halt as _;
  19. use cortex_m::{iprintln, Peripherals};
  20. use cortex_m_rt::entry;
  21. #[entry]
  22. fn main() -> ! {
  23. let mut p = Peripherals::take().unwrap();
  24. let stim = &mut p.ITM.stim[0];
  25. iprintln!(stim, "Hello, world!");
  26. loop {}
  27. }