add second ADC pin
This commit is contained in:
parent
885c7746b3
commit
8c88456fcb
1 changed files with 11 additions and 3 deletions
|
|
@ -293,7 +293,9 @@ fn app_main(mut p: hal::Peripherals, mut delay: Delay) -> ! {
|
|||
let led1_ch = hal::timer::Channel::Ch1;
|
||||
|
||||
// LED2 output setup
|
||||
|
||||
let led2_pin = PwmPin::new_ch2::<0>(p.PA1);
|
||||
let led2_ch = hal::timer::Channel::Ch2;
|
||||
|
||||
// DAC output setup
|
||||
let dac_pin = PwmPin::new_ch4::<0>(p.PC4);
|
||||
// let dac_ch = hal::timer::Channel::Ch4;
|
||||
|
|
@ -302,10 +304,10 @@ fn app_main(mut p: hal::Peripherals, mut delay: Delay) -> ! {
|
|||
let mut pwm = SimplePwm::new(
|
||||
p.TIM1,
|
||||
Some(led1_pin),
|
||||
None,
|
||||
Some(led2_pin),
|
||||
Some(led0_pin),
|
||||
Some(dac_pin),
|
||||
Hertz::khz(100),
|
||||
Hertz::khz(200),
|
||||
CountingMode::default(),
|
||||
);
|
||||
|
||||
|
|
@ -323,6 +325,11 @@ fn app_main(mut p: hal::Peripherals, mut delay: Delay) -> ! {
|
|||
// adc
|
||||
let mut adc = hal::adc::Adc::new(p.ADC1, Default::default());
|
||||
let mut adc_pin = p.PD4;
|
||||
|
||||
// adc2
|
||||
// let mut usb_detect_dc = hal::adc::Adc::new(p.ADC1, Default::default());
|
||||
let mut usb_adc_pin = p.PD5;
|
||||
|
||||
// println!("ADC_PIN CHANNEL: {}", adc_pin.channel().channel());
|
||||
delay.delay_ms(1000);
|
||||
let adc_cal = adc.calibrate();
|
||||
|
|
@ -519,6 +526,7 @@ fn app_main(mut p: hal::Peripherals, mut delay: Delay) -> ! {
|
|||
|
||||
if adc1_timer.need_service() {
|
||||
let val = adc.convert(&mut adc_pin, hal::adc::SampleTime::CYCLES241);
|
||||
let val = adc.convert(&mut usb_adc_pin, hal::adc::SampleTime::CYCLES241);
|
||||
#[cfg(feature="enable_print")]
|
||||
println!("ADC value: {}", val);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue