forked from stm32-rs/stm32f1xx-hal
-
Notifications
You must be signed in to change notification settings - Fork 0
/
nojtag.rs
32 lines (24 loc) · 783 Bytes
/
nojtag.rs
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
//! Disables the JTAG ports to give access to pb3, pb4 and PA15
#![deny(unsafe_code)]
#![no_main]
#![no_std]
use panic_halt as _;
use cortex_m_rt::entry;
use stm32f1xx_hal::{pac, prelude::*};
#[entry]
fn main() -> ! {
let p = pac::Peripherals::take().unwrap();
let mut gpioa = p.GPIOA.split();
let mut gpiob = p.GPIOB.split();
let mut afio = p.AFIO.constrain();
let (pa15, pb3, pb4) = afio.mapr.disable_jtag(gpioa.pa15, gpiob.pb3, gpiob.pb4);
let mut pa15 = pa15.into_push_pull_output(&mut gpioa.crh);
let mut pb3 = pb3.into_push_pull_output(&mut gpiob.crl);
let mut pb4 = pb4.into_push_pull_output(&mut gpiob.crl);
loop {
pa15.toggle();
pb3.toggle();
pb4.toggle();
cortex_m::asm::delay(8_000_000);
}
}