Skip to content

Commit

Permalink
add any
Browse files Browse the repository at this point in the history
  • Loading branch information
pythcoiner committed Feb 22, 2024
1 parent b0cead1 commit e8259d5
Showing 1 changed file with 25 additions and 1 deletion.
26 changes: 25 additions & 1 deletion src/serial.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,8 @@ pub enum Event {
// /// [`Serial::set_wakeup_from_stopmode_reason()`]
// #[doc(alias = "WUF")]
// WakeupFromStopMode,
/// Any of the above events occurred
Any,
}

/// Serial error
Expand Down Expand Up @@ -490,7 +492,8 @@ where
self.configure_interrupt(event, Switch::Off);
}

/// Enable or disable the interrupt for the specified [`Event`].
/// Enable or disable the interrupt for the specified [`Event`], if passing [`Event::Any`]
/// , it will be apply to all events.
#[inline]
pub fn configure_interrupt(&mut self, event: Event, enable: impl Into<Switch>) {
// Do a round way trip to be convert Into<Switch> -> bool
Expand All @@ -513,7 +516,28 @@ where
Event::ReceiverTimeout => self.usart.cr1.modify(|_, w| w.rtoie().bit(enable)),
// Event::EndOfBlock => self.usart.cr1.modify(|_, w| w.eobie().bit(enable)),
// Event::WakeupFromStopMode => self.usart.cr3.modify(|_, w| w.wufie().bit(enable)),
Event::Any => {
self.usart.cr1.modify(|_, w| {
w.txeie().bit(enable);
w.tcie().bit(enable);
w.rxneie().bit(enable);
w.peie().bit(enable);
w.idleie().bit(enable);
w.cmie().bit(enable);
w.rtoie().bit(enable);
// w.eobie().bit(enable);
});
self.usart.cr2.modify(|_, w| {
w.lbdie().bit(enable);
});
self.usart.cr3.modify(|_, w| {
w.ctsie().bit(enable);
w.eie().bit(enable);
// w.wufie().bit(enable);
})
}
};

}

/// Enable or disable interrupt for the specified [`Event`]s.
Expand Down

0 comments on commit e8259d5

Please sign in to comment.