Mark clear_interrupt_flag as unsafe

This commit is contained in:
Nikita Strygin 2021-12-26 18:29:41 +03:00
parent 6b08c70273
commit a94932be02

View File

@ -483,17 +483,15 @@ fn sr(r: crate::pac::usart::Usart) -> crate::pac::common::Reg<regs::Sr, crate::p
} }
#[cfg(usart_v1)] #[cfg(usart_v1)]
fn clear_interrupt_flag(r: crate::pac::usart::Usart, _flag: InterruptFlag) { unsafe fn clear_interrupt_flag(r: crate::pac::usart::Usart, _flag: InterruptFlag) {
// This bit is set by hardware when noise is detected on a received frame. It is cleared by a // This bit is set by hardware when noise is detected on a received frame. It is cleared by a
// software sequence (an read to the USART_SR register followed by a read to the // software sequence (an read to the USART_SR register followed by a read to the
// USART_DR register). // USART_DR register).
// this is the same as what st's HAL does on v1 hardware // this is the same as what st's HAL does on v1 hardware
unsafe {
r.sr().read(); r.sr().read();
r.dr().read(); r.dr().read();
} }
}
#[cfg(usart_v2)] #[cfg(usart_v2)]
fn tdr(r: crate::pac::usart::Usart) -> *mut u8 { fn tdr(r: crate::pac::usart::Usart) -> *mut u8 {
@ -512,7 +510,7 @@ fn sr(r: crate::pac::usart::Usart) -> crate::pac::common::Reg<regs::Ixr, crate::
#[cfg(usart_v2)] #[cfg(usart_v2)]
#[inline] #[inline]
fn clear_interrupt_flag(r: crate::pac::usart::Usart, flag: InterruptFlag) { unsafe fn clear_interrupt_flag(r: crate::pac::usart::Usart, flag: InterruptFlag) {
// v2 has a separate register for clearing flags (nice) // v2 has a separate register for clearing flags (nice)
match flag { match flag {
InterruptFlag::PE => r.icr().write(|w| { InterruptFlag::PE => r.icr().write(|w| {