From 52e156b429417bde59d0ea67d11256866f1dcec9 Mon Sep 17 00:00:00 2001 From: Dario Nieuwenhuis Date: Fri, 14 Jan 2022 21:05:48 +0100 Subject: [PATCH] stm32: use critical_section instead of cortex_m::interrupt --- embassy-stm32/src/exti.rs | 4 ++-- embassy-stm32/src/gpio.rs | 12 ++++++------ embassy-stm32/src/sdmmc/v2.rs | 8 ++++---- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/embassy-stm32/src/exti.rs b/embassy-stm32/src/exti.rs index 5af51cd1..552433b8 100644 --- a/embassy-stm32/src/exti.rs +++ b/embassy-stm32/src/exti.rs @@ -148,7 +148,7 @@ pub struct ExtiInputFuture<'a> { impl<'a> ExtiInputFuture<'a> { fn new(pin: u8, port: u8, rising: bool, falling: bool) -> Self { - cortex_m::interrupt::free(|_| unsafe { + critical_section::with(|_| unsafe { let pin = pin as usize; exticr_regs() .exticr(pin / 4) @@ -177,7 +177,7 @@ impl<'a> ExtiInputFuture<'a> { impl<'a> Drop for ExtiInputFuture<'a> { fn drop(&mut self) { - cortex_m::interrupt::free(|_| unsafe { + critical_section::with(|_| unsafe { let pin = self.pin as _; cpu_regs().imr(0).modify(|w| w.set_line(pin, false)); }); diff --git a/embassy-stm32/src/gpio.rs b/embassy-stm32/src/gpio.rs index 1b257c38..6b4a9285 100644 --- a/embassy-stm32/src/gpio.rs +++ b/embassy-stm32/src/gpio.rs @@ -80,7 +80,7 @@ impl<'d, T: Pin> Input<'d, T> { pub fn new(pin: impl Unborrow + 'd, pull: Pull) -> Self { unborrow!(pin); - cortex_m::interrupt::free(|_| unsafe { + critical_section::with(|_| unsafe { let r = pin.block(); let n = pin.pin() as usize; #[cfg(gpio_v1)] @@ -117,7 +117,7 @@ impl<'d, T: Pin> Input<'d, T> { impl<'d, T: Pin> Drop for Input<'d, T> { fn drop(&mut self) { - cortex_m::interrupt::free(|_| unsafe { + critical_section::with(|_| unsafe { let r = self.pin.block(); let n = self.pin.pin() as usize; #[cfg(gpio_v1)] @@ -168,7 +168,7 @@ impl<'d, T: Pin> Output<'d, T> { Level::Low => pin.set_low(), } - cortex_m::interrupt::free(|_| unsafe { + critical_section::with(|_| unsafe { let r = pin.block(); let n = pin.pin() as usize; #[cfg(gpio_v1)] @@ -195,7 +195,7 @@ impl<'d, T: Pin> Output<'d, T> { impl<'d, T: Pin> Drop for Output<'d, T> { fn drop(&mut self) { - cortex_m::interrupt::free(|_| unsafe { + critical_section::with(|_| unsafe { let r = self.pin.block(); let n = self.pin.pin() as usize; #[cfg(gpio_v1)] @@ -265,7 +265,7 @@ impl<'d, T: Pin> OutputOpenDrain<'d, T> { Level::Low => pin.set_low(), } - cortex_m::interrupt::free(|_| unsafe { + critical_section::with(|_| unsafe { let r = pin.block(); let n = pin.pin() as usize; #[cfg(gpio_v1)] @@ -298,7 +298,7 @@ impl<'d, T: Pin> OutputOpenDrain<'d, T> { impl<'d, T: Pin> Drop for OutputOpenDrain<'d, T> { fn drop(&mut self) { - cortex_m::interrupt::free(|_| unsafe { + critical_section::with(|_| unsafe { let r = self.pin.block(); let n = self.pin.pin() as usize; #[cfg(gpio_v1)] diff --git a/embassy-stm32/src/sdmmc/v2.rs b/embassy-stm32/src/sdmmc/v2.rs index 5914f92f..74382ce6 100644 --- a/embassy-stm32/src/sdmmc/v2.rs +++ b/embassy-stm32/src/sdmmc/v2.rs @@ -1254,7 +1254,7 @@ where fn configure(&mut self) { let (clk_pin, cmd_pin, d0_pin, d1_pin, d2_pin, d3_pin) = self; - cortex_m::interrupt::free(|_| unsafe { + critical_section::with(|_| unsafe { // clk let block = clk_pin.block(); let n = clk_pin.pin() as usize; @@ -1298,7 +1298,7 @@ where let (clk_pin, cmd_pin, d0_pin, d1_pin, d2_pin, d3_pin) = self; - cortex_m::interrupt::free(|_| unsafe { + critical_section::with(|_| unsafe { // clk let n = clk_pin.pin().into(); clk_pin @@ -1400,7 +1400,7 @@ where fn configure(&mut self) { let (clk_pin, cmd_pin, d0_pin) = self; - cortex_m::interrupt::free(|_| unsafe { + critical_section::with(|_| unsafe { // clk let block = clk_pin.block(); let n = clk_pin.pin() as usize; @@ -1426,7 +1426,7 @@ where let (clk_pin, cmd_pin, d0_pin) = self; - cortex_m::interrupt::free(|_| unsafe { + critical_section::with(|_| unsafe { // clk let n = clk_pin.pin().into(); clk_pin