itm.rs 582 B

1234567891011121314151617181920212223242526272829303132
  1. #![deny(unsafe_code)]
  2. #![deny(warnings)]
  3. #![no_main]
  4. #![no_std]
  5. extern crate cortex_m_rt as rt;
  6. #[macro_use]
  7. extern crate cortex_m;
  8. extern crate panic_itm;
  9. extern crate stm32f1xx_hal;
  10. use rt::{entry, exception, ExceptionFrame};
  11. #[entry]
  12. fn main() -> ! {
  13. let p = cortex_m::Peripherals::take().unwrap();
  14. let mut itm = p.ITM;
  15. iprintln!(&mut itm.stim[0], "Hello, world!");
  16. loop {}
  17. }
  18. #[exception]
  19. fn HardFault(ef: &ExceptionFrame) -> ! {
  20. panic!("{:#?}", ef);
  21. }
  22. #[exception]
  23. fn DefaultHandler(irqn: i16) {
  24. panic!("Unhandled exception (IRQn = {})", irqn);
  25. }