diff options
| author | Nikita Strygin <[email protected]> | 2021-12-26 18:29:41 +0300 |
|---|---|---|
| committer | Nikita Strygin <[email protected]> | 2021-12-26 18:29:41 +0300 |
| commit | a94932be0281926211bdb7a4de1f71a8e34cd745 (patch) | |
| tree | 7289524b94c8f26d9fd53aeb0b5ccf7764739c96 | |
| parent | 6b08c70273b977b9e2d025281c051830307d0902 (diff) | |
Mark clear_interrupt_flag as unsafe
| -rw-r--r-- | embassy-stm32/src/usart/mod.rs | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/embassy-stm32/src/usart/mod.rs b/embassy-stm32/src/usart/mod.rs index a93bd2daf..3567746cf 100644 --- a/embassy-stm32/src/usart/mod.rs +++ b/embassy-stm32/src/usart/mod.rs | |||
| @@ -483,16 +483,14 @@ fn sr(r: crate::pac::usart::Usart) -> crate::pac::common::Reg<regs::Sr, crate::p | |||
| 483 | } | 483 | } |
| 484 | 484 | ||
| 485 | #[cfg(usart_v1)] | 485 | #[cfg(usart_v1)] |
| 486 | fn clear_interrupt_flag(r: crate::pac::usart::Usart, _flag: InterruptFlag) { | 486 | unsafe fn clear_interrupt_flag(r: crate::pac::usart::Usart, _flag: InterruptFlag) { |
| 487 | // This bit is set by hardware when noise is detected on a received frame. It is cleared by a | 487 | // This bit is set by hardware when noise is detected on a received frame. It is cleared by a |
| 488 | // software sequence (an read to the USART_SR register followed by a read to the | 488 | // software sequence (an read to the USART_SR register followed by a read to the |
| 489 | // USART_DR register). | 489 | // USART_DR register). |
| 490 | 490 | ||
| 491 | // this is the same as what st's HAL does on v1 hardware | 491 | // this is the same as what st's HAL does on v1 hardware |
| 492 | unsafe { | 492 | r.sr().read(); |
| 493 | r.sr().read(); | 493 | r.dr().read(); |
| 494 | r.dr().read(); | ||
| 495 | } | ||
| 496 | } | 494 | } |
| 497 | 495 | ||
| 498 | #[cfg(usart_v2)] | 496 | #[cfg(usart_v2)] |
| @@ -512,7 +510,7 @@ fn sr(r: crate::pac::usart::Usart) -> crate::pac::common::Reg<regs::Ixr, crate:: | |||
| 512 | 510 | ||
| 513 | #[cfg(usart_v2)] | 511 | #[cfg(usart_v2)] |
| 514 | #[inline] | 512 | #[inline] |
| 515 | fn clear_interrupt_flag(r: crate::pac::usart::Usart, flag: InterruptFlag) { | 513 | unsafe fn clear_interrupt_flag(r: crate::pac::usart::Usart, flag: InterruptFlag) { |
| 516 | // v2 has a separate register for clearing flags (nice) | 514 | // v2 has a separate register for clearing flags (nice) |
| 517 | match flag { | 515 | match flag { |
| 518 | InterruptFlag::PE => r.icr().write(|w| { | 516 | InterruptFlag::PE => r.icr().write(|w| { |
