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 11, 2019
1 parent a60aeff commit 7b2cf23
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
- Add ADC1 reading functions for channels 16 (temperature) and 17 (internal reference voltage)
- Update existing ADC example according to ADC API changes
- Add new ADC example to read ambient temperature using ADC1 CH16
- Add `listen` and `unlisten` to `serial::Tx` and `serial::Rx`.


### Breaking changes
Expand Down
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 7b2cf23

Please sign in to comment.