From decf910b55fffca83c251504b16dc88d8b2088b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rn-Michael?= <40151420+ldericher@users.noreply.github.com> Date: Fri, 22 Mar 2024 12:45:36 +0000 Subject: [PATCH] EXTI experiment --- bluepill-rs/src/main.rs | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/bluepill-rs/src/main.rs b/bluepill-rs/src/main.rs index 6bc79c0..0b67776 100644 --- a/bluepill-rs/src/main.rs +++ b/bluepill-rs/src/main.rs @@ -31,7 +31,8 @@ mod app { #[local] struct Local { dmx: DMX, - led: gpio::gpioc::PC13, + led: gpio::gpioc::PC13>, + int_led: gpio::gpiob::PB0>, } #[init] @@ -56,11 +57,16 @@ mod app { // Acquire the peripherals let mut gpioa = cx.device.GPIOA.split(); + let mut gpiob = cx.device.GPIOB.split(); let mut gpioc = cx.device.GPIOC.split(); let mut afio = cx.device.AFIO.constrain(); let dma1 = cx.device.DMA1.split(); + cx.device.EXTI.imr.write(|w| w.mr1().set_bit()); + + let _ = gpiob.pb10.into_pull_up_input(&mut gpiob.crh); + // Serial config let serial = serial::Serial::new( cx.device.USART1, @@ -91,6 +97,10 @@ mod app { led: gpioc .pc13 .into_push_pull_output_with_state(&mut gpioc.crh, gpio::PinState::High), + + int_led: gpiob + .pb0 + .into_open_drain_output_with_state(&mut gpiob.crl, gpio::PinState::Low), }, init::Monotonics(mono), ) @@ -113,4 +123,10 @@ mod app { // cx.local.dmx.wait(); foo::spawn().unwrap(); } + + #[task(binds=EXTI0, local = [int_led], shared = [delay_us])] + fn bar(mut cx: bar::Context) { + cx.local.int_led.toggle(); + cx.shared.delay_us.lock(|d| d.delay(1.secs())); + } }