Skip to content

Commit f1e0c83

Browse files
committed
Sort serial functions
1 parent 45678eb commit f1e0c83

File tree

1 file changed

+50
-50
lines changed

1 file changed

+50
-50
lines changed

src/serial.rs

Lines changed: 50 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -685,6 +685,18 @@ where
685685
<Usart as Instance>::INTERRUPT
686686
}
687687

688+
/// Enable the interrupt for the specified [`Event`].
689+
#[inline]
690+
pub fn enable_interrupt(&mut self, event: Event) {
691+
self.configure_interrupt(event, Toggle::On);
692+
}
693+
694+
/// Disable the interrupt for the specified [`Event`].
695+
#[inline]
696+
pub fn disable_interrupt(&mut self, event: Event) {
697+
self.configure_interrupt(event, Toggle::Off);
698+
}
699+
688700
/// Enable or disable the interrupt for the specified [`Event`].
689701
#[inline]
690702
pub fn configure_interrupt(&mut self, event: Event, enable: impl Into<Toggle>) -> &mut Self {
@@ -712,18 +724,6 @@ where
712724
self
713725
}
714726

715-
/// Enable the interrupt for the specified [`Event`].
716-
#[inline]
717-
pub fn enable_interrupt(&mut self, event: Event) {
718-
self.configure_interrupt(event, Toggle::On);
719-
}
720-
721-
/// Disable the interrupt for the specified [`Event`].
722-
#[inline]
723-
pub fn disable_interrupt(&mut self, event: Event) {
724-
self.configure_interrupt(event, Toggle::Off);
725-
}
726-
727727
/// Enable or disable interrupt for the specified [`Event`]s.
728728
///
729729
/// Like [`Serial::configure_interrupt`], but instead using an enumset. The corresponding
@@ -742,19 +742,26 @@ where
742742
self
743743
}
744744

745-
/// Enable or disable overrun detection
746-
///
747-
/// When overrun detection is disabled and new data is received while the
748-
/// [`Event::ReceiveDataRegisterNotEmpty`] flag is still set,
749-
/// the [`Event::OverrunError`] flag is not set and the new received data overwrites the
750-
/// previous content of the RDR register.
751-
#[doc(alias = "OVRDIS")]
745+
/// Check if an interrupt event happend.
752746
#[inline]
753-
pub fn detect_overrun(&mut self, enable: bool) {
754-
let uart_enabled = self.usart.cr1.read().ue().bit();
755-
self.usart.cr1.modify(|_, w| w.ue().disabled());
756-
self.usart.cr3.modify(|_, w| w.ovrdis().bit(!enable));
757-
self.usart.cr1.modify(|_, w| w.ue().bit(uart_enabled));
747+
pub fn is_event_triggered(&self, event: Event) -> bool {
748+
let isr = self.usart.isr.read();
749+
match event {
750+
Event::TransmitDataRegisterEmtpy => isr.txe().bit(),
751+
Event::CtsInterrupt => isr.ctsif().bit(),
752+
Event::TransmissionComplete => isr.tc().bit(),
753+
Event::ReceiveDataRegisterNotEmpty => isr.rxne().bit(),
754+
Event::OverrunError => isr.ore().bit(),
755+
Event::Idle => isr.idle().bit(),
756+
Event::ParityError => isr.pe().bit(),
757+
Event::LinBreak => isr.lbdf().bit(),
758+
Event::NoiseError => isr.nf().bit(),
759+
Event::FramingError => isr.fe().bit(),
760+
Event::CharacterMatch => isr.cmf().bit(),
761+
Event::ReceiverTimeout => isr.rtof().bit(),
762+
// Event::EndOfBlock => isr.eobf().bit(),
763+
// Event::WakeupFromStopMode => isr.wuf().bit(),
764+
}
758765
}
759766

760767
/// Get an [`EnumSet`] of all fired interrupt events.
@@ -782,13 +789,6 @@ where
782789
events
783790
}
784791

785-
/// Clear **all** interrupt events.
786-
#[inline]
787-
pub fn clear_events(&mut self) {
788-
// SAFETY: This atomic write clears all flags and ignores the reserverd bit fields.
789-
self.usart.icr.write(|w| unsafe { w.bits(u32::MAX) });
790-
}
791-
792792
/// Clear the given interrupt event flag.
793793
#[inline]
794794
pub fn clear_event(&mut self, event: Event) {
@@ -816,26 +816,26 @@ where
816816
});
817817
}
818818

819-
/// Check if an interrupt event happend.
819+
/// Clear **all** interrupt events.
820820
#[inline]
821-
pub fn is_event_triggered(&self, event: Event) -> bool {
822-
let isr = self.usart.isr.read();
823-
match event {
824-
Event::TransmitDataRegisterEmtpy => isr.txe().bit(),
825-
Event::CtsInterrupt => isr.ctsif().bit(),
826-
Event::TransmissionComplete => isr.tc().bit(),
827-
Event::ReceiveDataRegisterNotEmpty => isr.rxne().bit(),
828-
Event::OverrunError => isr.ore().bit(),
829-
Event::Idle => isr.idle().bit(),
830-
Event::ParityError => isr.pe().bit(),
831-
Event::LinBreak => isr.lbdf().bit(),
832-
Event::NoiseError => isr.nf().bit(),
833-
Event::FramingError => isr.fe().bit(),
834-
Event::CharacterMatch => isr.cmf().bit(),
835-
Event::ReceiverTimeout => isr.rtof().bit(),
836-
// Event::EndOfBlock => isr.eobf().bit(),
837-
// Event::WakeupFromStopMode => isr.wuf().bit(),
838-
}
821+
pub fn clear_events(&mut self) {
822+
// SAFETY: This atomic write clears all flags and ignores the reserverd bit fields.
823+
self.usart.icr.write(|w| unsafe { w.bits(u32::MAX) });
824+
}
825+
826+
/// Enable or disable overrun detection
827+
///
828+
/// When overrun detection is disabled and new data is received while the
829+
/// [`Event::ReceiveDataRegisterNotEmpty`] flag is still set,
830+
/// the [`Event::OverrunError`] flag is not set and the new received data overwrites the
831+
/// previous content of the RDR register.
832+
#[doc(alias = "OVRDIS")]
833+
#[inline]
834+
pub fn detect_overrun(&mut self, enable: bool) {
835+
let uart_enabled = self.usart.cr1.read().ue().bit();
836+
self.usart.cr1.modify(|_, w| w.ue().disabled());
837+
self.usart.cr3.modify(|_, w| w.ovrdis().bit(!enable));
838+
self.usart.cr1.modify(|_, w| w.ue().bit(uart_enabled));
839839
}
840840

841841
/// Configuring the UART to match each received character,

0 commit comments

Comments
 (0)