Skip to content

Commit

Permalink
Implement serial::{Tx,Rx}::{listen,unlisten}.
Browse files Browse the repository at this point in the history
  • Loading branch information
jmgao committed Jun 8, 2019
1 parent 5ad17fc commit 97be11b
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/serial.rs
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,26 @@ macro_rules! hal {
}
}

impl Tx<$USARTX> {
pub fn listen(&mut self) {
unsafe { (*$USARTX::ptr()).cr1.modify(|_, w| w.txeie().set_bit()) };
}

pub fn unlisten(&mut self) {
unsafe { (*$USARTX::ptr()).cr1.modify(|_, w| w.txeie().clear_bit()) };
}
}

impl Rx<$USARTX> {
pub fn listen(&mut self) {
unsafe { (*$USARTX::ptr()).cr1.modify(|_, w| w.rxneie().set_bit()) };
}

pub fn unlisten(&mut self) {
unsafe { (*$USARTX::ptr()).cr1.modify(|_, w| w.rxneie().clear_bit()) };
}
}

impl crate::hal::serial::Read<u8> for Rx<$USARTX> {
type Error = Error;

Expand Down

0 comments on commit 97be11b

Please sign in to comment.