diff options
| author | Dario Nieuwenhuis <[email protected]> | 2022-01-14 21:05:48 +0100 |
|---|---|---|
| committer | Dario Nieuwenhuis <[email protected]> | 2022-01-19 17:59:55 +0100 |
| commit | 52e156b429417bde59d0ea67d11256866f1dcec9 (patch) | |
| tree | 5ecbc7fefef1fd4bc28caa701a2370e1baeb4a80 | |
| parent | ecda57dff17dcbcfb2b4000e8cd3efdfe0bd4cf2 (diff) | |
stm32: use critical_section instead of cortex_m::interrupt
| -rw-r--r-- | embassy-stm32/src/exti.rs | 4 | ||||
| -rw-r--r-- | embassy-stm32/src/gpio.rs | 12 | ||||
| -rw-r--r-- | 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 5af51cd11..552433b87 100644 --- a/embassy-stm32/src/exti.rs +++ b/embassy-stm32/src/exti.rs | |||
| @@ -148,7 +148,7 @@ pub struct ExtiInputFuture<'a> { | |||
| 148 | 148 | ||
| 149 | impl<'a> ExtiInputFuture<'a> { | 149 | impl<'a> ExtiInputFuture<'a> { |
| 150 | fn new(pin: u8, port: u8, rising: bool, falling: bool) -> Self { | 150 | fn new(pin: u8, port: u8, rising: bool, falling: bool) -> Self { |
| 151 | cortex_m::interrupt::free(|_| unsafe { | 151 | critical_section::with(|_| unsafe { |
| 152 | let pin = pin as usize; | 152 | let pin = pin as usize; |
| 153 | exticr_regs() | 153 | exticr_regs() |
| 154 | .exticr(pin / 4) | 154 | .exticr(pin / 4) |
| @@ -177,7 +177,7 @@ impl<'a> ExtiInputFuture<'a> { | |||
| 177 | 177 | ||
| 178 | impl<'a> Drop for ExtiInputFuture<'a> { | 178 | impl<'a> Drop for ExtiInputFuture<'a> { |
| 179 | fn drop(&mut self) { | 179 | fn drop(&mut self) { |
| 180 | cortex_m::interrupt::free(|_| unsafe { | 180 | critical_section::with(|_| unsafe { |
| 181 | let pin = self.pin as _; | 181 | let pin = self.pin as _; |
| 182 | cpu_regs().imr(0).modify(|w| w.set_line(pin, false)); | 182 | cpu_regs().imr(0).modify(|w| w.set_line(pin, false)); |
| 183 | }); | 183 | }); |
diff --git a/embassy-stm32/src/gpio.rs b/embassy-stm32/src/gpio.rs index 1b257c386..6b4a9285f 100644 --- a/embassy-stm32/src/gpio.rs +++ b/embassy-stm32/src/gpio.rs | |||
| @@ -80,7 +80,7 @@ impl<'d, T: Pin> Input<'d, T> { | |||
| 80 | pub fn new(pin: impl Unborrow<Target = T> + 'd, pull: Pull) -> Self { | 80 | pub fn new(pin: impl Unborrow<Target = T> + 'd, pull: Pull) -> Self { |
| 81 | unborrow!(pin); | 81 | unborrow!(pin); |
| 82 | 82 | ||
| 83 | cortex_m::interrupt::free(|_| unsafe { | 83 | critical_section::with(|_| unsafe { |
| 84 | let r = pin.block(); | 84 | let r = pin.block(); |
| 85 | let n = pin.pin() as usize; | 85 | let n = pin.pin() as usize; |
| 86 | #[cfg(gpio_v1)] | 86 | #[cfg(gpio_v1)] |
| @@ -117,7 +117,7 @@ impl<'d, T: Pin> Input<'d, T> { | |||
| 117 | 117 | ||
| 118 | impl<'d, T: Pin> Drop for Input<'d, T> { | 118 | impl<'d, T: Pin> Drop for Input<'d, T> { |
| 119 | fn drop(&mut self) { | 119 | fn drop(&mut self) { |
| 120 | cortex_m::interrupt::free(|_| unsafe { | 120 | critical_section::with(|_| unsafe { |
| 121 | let r = self.pin.block(); | 121 | let r = self.pin.block(); |
| 122 | let n = self.pin.pin() as usize; | 122 | let n = self.pin.pin() as usize; |
| 123 | #[cfg(gpio_v1)] | 123 | #[cfg(gpio_v1)] |
| @@ -168,7 +168,7 @@ impl<'d, T: Pin> Output<'d, T> { | |||
| 168 | Level::Low => pin.set_low(), | 168 | Level::Low => pin.set_low(), |
| 169 | } | 169 | } |
| 170 | 170 | ||
| 171 | cortex_m::interrupt::free(|_| unsafe { | 171 | critical_section::with(|_| unsafe { |
| 172 | let r = pin.block(); | 172 | let r = pin.block(); |
| 173 | let n = pin.pin() as usize; | 173 | let n = pin.pin() as usize; |
| 174 | #[cfg(gpio_v1)] | 174 | #[cfg(gpio_v1)] |
| @@ -195,7 +195,7 @@ impl<'d, T: Pin> Output<'d, T> { | |||
| 195 | 195 | ||
| 196 | impl<'d, T: Pin> Drop for Output<'d, T> { | 196 | impl<'d, T: Pin> Drop for Output<'d, T> { |
| 197 | fn drop(&mut self) { | 197 | fn drop(&mut self) { |
| 198 | cortex_m::interrupt::free(|_| unsafe { | 198 | critical_section::with(|_| unsafe { |
| 199 | let r = self.pin.block(); | 199 | let r = self.pin.block(); |
| 200 | let n = self.pin.pin() as usize; | 200 | let n = self.pin.pin() as usize; |
| 201 | #[cfg(gpio_v1)] | 201 | #[cfg(gpio_v1)] |
| @@ -265,7 +265,7 @@ impl<'d, T: Pin> OutputOpenDrain<'d, T> { | |||
| 265 | Level::Low => pin.set_low(), | 265 | Level::Low => pin.set_low(), |
| 266 | } | 266 | } |
| 267 | 267 | ||
| 268 | cortex_m::interrupt::free(|_| unsafe { | 268 | critical_section::with(|_| unsafe { |
| 269 | let r = pin.block(); | 269 | let r = pin.block(); |
| 270 | let n = pin.pin() as usize; | 270 | let n = pin.pin() as usize; |
| 271 | #[cfg(gpio_v1)] | 271 | #[cfg(gpio_v1)] |
| @@ -298,7 +298,7 @@ impl<'d, T: Pin> OutputOpenDrain<'d, T> { | |||
| 298 | 298 | ||
| 299 | impl<'d, T: Pin> Drop for OutputOpenDrain<'d, T> { | 299 | impl<'d, T: Pin> Drop for OutputOpenDrain<'d, T> { |
| 300 | fn drop(&mut self) { | 300 | fn drop(&mut self) { |
| 301 | cortex_m::interrupt::free(|_| unsafe { | 301 | critical_section::with(|_| unsafe { |
| 302 | let r = self.pin.block(); | 302 | let r = self.pin.block(); |
| 303 | let n = self.pin.pin() as usize; | 303 | let n = self.pin.pin() as usize; |
| 304 | #[cfg(gpio_v1)] | 304 | #[cfg(gpio_v1)] |
diff --git a/embassy-stm32/src/sdmmc/v2.rs b/embassy-stm32/src/sdmmc/v2.rs index 5914f92f5..74382ce64 100644 --- a/embassy-stm32/src/sdmmc/v2.rs +++ b/embassy-stm32/src/sdmmc/v2.rs | |||
| @@ -1254,7 +1254,7 @@ where | |||
| 1254 | fn configure(&mut self) { | 1254 | fn configure(&mut self) { |
| 1255 | let (clk_pin, cmd_pin, d0_pin, d1_pin, d2_pin, d3_pin) = self; | 1255 | let (clk_pin, cmd_pin, d0_pin, d1_pin, d2_pin, d3_pin) = self; |
| 1256 | 1256 | ||
| 1257 | cortex_m::interrupt::free(|_| unsafe { | 1257 | critical_section::with(|_| unsafe { |
| 1258 | // clk | 1258 | // clk |
| 1259 | let block = clk_pin.block(); | 1259 | let block = clk_pin.block(); |
| 1260 | let n = clk_pin.pin() as usize; | 1260 | let n = clk_pin.pin() as usize; |
| @@ -1298,7 +1298,7 @@ where | |||
| 1298 | 1298 | ||
| 1299 | let (clk_pin, cmd_pin, d0_pin, d1_pin, d2_pin, d3_pin) = self; | 1299 | let (clk_pin, cmd_pin, d0_pin, d1_pin, d2_pin, d3_pin) = self; |
| 1300 | 1300 | ||
| 1301 | cortex_m::interrupt::free(|_| unsafe { | 1301 | critical_section::with(|_| unsafe { |
| 1302 | // clk | 1302 | // clk |
| 1303 | let n = clk_pin.pin().into(); | 1303 | let n = clk_pin.pin().into(); |
| 1304 | clk_pin | 1304 | clk_pin |
| @@ -1400,7 +1400,7 @@ where | |||
| 1400 | fn configure(&mut self) { | 1400 | fn configure(&mut self) { |
| 1401 | let (clk_pin, cmd_pin, d0_pin) = self; | 1401 | let (clk_pin, cmd_pin, d0_pin) = self; |
| 1402 | 1402 | ||
| 1403 | cortex_m::interrupt::free(|_| unsafe { | 1403 | critical_section::with(|_| unsafe { |
| 1404 | // clk | 1404 | // clk |
| 1405 | let block = clk_pin.block(); | 1405 | let block = clk_pin.block(); |
| 1406 | let n = clk_pin.pin() as usize; | 1406 | let n = clk_pin.pin() as usize; |
| @@ -1426,7 +1426,7 @@ where | |||
| 1426 | 1426 | ||
| 1427 | let (clk_pin, cmd_pin, d0_pin) = self; | 1427 | let (clk_pin, cmd_pin, d0_pin) = self; |
| 1428 | 1428 | ||
| 1429 | cortex_m::interrupt::free(|_| unsafe { | 1429 | critical_section::with(|_| unsafe { |
| 1430 | // clk | 1430 | // clk |
| 1431 | let n = clk_pin.pin().into(); | 1431 | let n = clk_pin.pin().into(); |
| 1432 | clk_pin | 1432 | clk_pin |
