led.rs 701 B

123456789101112131415161718192021222324252627282930313233343536
  1. //! Turns the user LED on
  2. #![deny(unsafe_code)]
  3. #![deny(warnings)]
  4. #![no_main]
  5. #![no_std]
  6. extern crate cortex_m_rt as rt;
  7. extern crate panic_semihosting;
  8. extern crate stm32f1xx_hal as hal;
  9. use hal::prelude::*;
  10. use hal::stm32f103xx;
  11. use rt::{entry, exception, ExceptionFrame};
  12. #[entry]
  13. fn main() -> ! {
  14. let p = stm32f103xx::Peripherals::take().unwrap();
  15. let mut rcc = p.RCC.constrain();
  16. let mut gpioc = p.GPIOC.split(&mut rcc.apb2);
  17. gpioc.pc13.into_push_pull_output(&mut gpioc.crh);
  18. loop {}
  19. }
  20. #[exception]
  21. fn HardFault(ef: &ExceptionFrame) -> ! {
  22. panic!("{:#?}", ef);
  23. }
  24. #[exception]
  25. fn DefaultHandler(irqn: i16) {
  26. panic!("Unhandled exception (IRQn = {})", irqn);
  27. }