Skip to content

Commit 6f6ff68

Browse files
authored
Fix and improve EIC Event control (#944)
* Fix EIC Event system enable bit setting * Add EIC Event system disable method
1 parent 2d890f0 commit 6f6ff68

File tree

2 files changed

+24
-2
lines changed

2 files changed

+24
-2
lines changed

hal/src/peripherals/eic/d11/pin.rs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,18 @@ where
5959
pub fn enable_event(&mut self) {
6060
self.chan.with_disable(|e| {
6161
e.evctrl()
62-
.modify(|_, w| unsafe { w.bits(1 << P::ChId::ID) });
62+
.modify(|r, w| unsafe { w.bits(r.bits() | 1 << P::ChId::ID) });
63+
});
64+
}
65+
66+
/// Disables the event output of the channel for the event system.
67+
///
68+
/// Note that whilst this function is executed, the EIC peripheral is disabled
69+
/// in order to write to the evctrl register
70+
pub fn disable_event(&mut self) {
71+
self.chan.with_disable(|e| {
72+
e.evctrl()
73+
.modify(|r, w| unsafe { w.bits(r.bits() & !(1 << P::ChId::ID)) });
6374
});
6475
}
6576

hal/src/peripherals/eic/d5x/pin.rs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,18 @@ where
6565
pub fn enable_event(&mut self) {
6666
self.chan.with_disable(|e| {
6767
e.evctrl()
68-
.modify(|_, w| unsafe { w.bits(1 << P::ChId::ID) });
68+
.modify(|r, w| unsafe { w.bits(r.bits() | 1 << P::ChId::ID) });
69+
});
70+
}
71+
72+
/// Disables the event output of the channel for the event system.
73+
///
74+
/// Note that whilst this function is executed, the EIC peripheral is disabled
75+
/// in order to write to the evctrl register
76+
pub fn disable_event(&mut self) {
77+
self.chan.with_disable(|e| {
78+
e.evctrl()
79+
.modify(|r, w| unsafe { w.bits(r.bits() & !(1 << P::ChId::ID)) });
6980
});
7081
}
7182

0 commit comments

Comments
 (0)