-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathpwm_input.rs.disabled
43 lines (32 loc) · 1.04 KB
/
pwm_input.rs.disabled
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
33
34
35
36
37
38
39
40
41
42
43
//! Testing PWM input
#![deny(unsafe_code)]
#![no_main]
#![no_std]
use panic_halt as _;
use cortex_m_rt::entry;
use stm32f1xx_hal::{pac, prelude::*, pwm_input::*, timer::Timer};
#[entry]
fn main() -> ! {
let p = pac::Peripherals::take().unwrap();
let mut flash = p.FLASH.constrain();
let mut rcc = p.RCC.constrain();
let clocks = rcc.cfgr.freeze(&mut flash.acr);
let mut afio = p.AFIO.constrain(&mut rcc.apb2);
let mut dbg = p.DBGMCU;
let gpioa = p.GPIOA.split(&mut rcc.apb2);
let gpiob = p.GPIOB.split(&mut rcc.apb2);
let (_pa15, _pb3, pb4) = afio.mapr.disable_jtag(gpioa.pa15, gpiob.pb3, gpiob.pb4);
let pb5 = gpiob.pb5;
let pwm_input = Timer::tim3(p.TIM3, &clocks, &mut rcc.apb1).pwm_input(
(pb4, pb5),
&mut afio.mapr,
&mut dbg,
Configuration::Frequency(10.khz()),
);
loop {
let _freq = pwm_input
.read_frequency(ReadMode::Instant, &clocks)
.unwrap();
let _duty_cycle = pwm_input.read_duty(ReadMode::Instant).unwrap();
}
}