EXTI experiment

This commit is contained in:
Jörn-Michael Miehe 2024-03-22 12:45:36 +00:00
parent e3b9f7ceb0
commit decf910b55

View file

@ -31,7 +31,8 @@ mod app {
#[local] #[local]
struct Local { struct Local {
dmx: DMX<DMX_LEN>, dmx: DMX<DMX_LEN>,
led: gpio::gpioc::PC13<gpio::Output>, led: gpio::gpioc::PC13<gpio::Output<gpio::PushPull>>,
int_led: gpio::gpiob::PB0<gpio::Output<gpio::OpenDrain>>,
} }
#[init] #[init]
@ -56,11 +57,16 @@ mod app {
// Acquire the peripherals // Acquire the peripherals
let mut gpioa = cx.device.GPIOA.split(); let mut gpioa = cx.device.GPIOA.split();
let mut gpiob = cx.device.GPIOB.split();
let mut gpioc = cx.device.GPIOC.split(); let mut gpioc = cx.device.GPIOC.split();
let mut afio = cx.device.AFIO.constrain(); let mut afio = cx.device.AFIO.constrain();
let dma1 = cx.device.DMA1.split(); 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 // Serial config
let serial = serial::Serial::new( let serial = serial::Serial::new(
cx.device.USART1, cx.device.USART1,
@ -91,6 +97,10 @@ mod app {
led: gpioc led: gpioc
.pc13 .pc13
.into_push_pull_output_with_state(&mut gpioc.crh, gpio::PinState::High), .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), init::Monotonics(mono),
) )
@ -113,4 +123,10 @@ mod app {
// cx.local.dmx.wait(); // cx.local.dmx.wait();
foo::spawn().unwrap(); 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()));
}
} }