nojtag.rs 553 B

1234567891011121314151617181920212223242526272829
  1. //! Disables the JTAG ports to give access to pb3, pb4 and PA15
  2. #![deny(unsafe_code)]
  3. #![deny(warnings)]
  4. #![no_main]
  5. #![no_std]
  6. extern crate panic_halt;
  7. use stm32f1xx_hal::{
  8. prelude::*,
  9. pac,
  10. };
  11. use cortex_m_rt::entry;
  12. #[entry]
  13. fn main() -> ! {
  14. let p = pac::Peripherals::take().unwrap();
  15. let mut rcc = p.RCC.constrain();
  16. let mut gpiob = p.GPIOB.split(&mut rcc.apb2);
  17. let mut afio = p.AFIO.constrain(&mut rcc.apb2);
  18. afio.mapr.disable_jtag();
  19. gpiob.pb4.into_push_pull_output(&mut gpiob.crl).set_low();
  20. loop {}
  21. }