Skip to content

Commit 42bb6ec

Browse files
jmgaoTheZoq2
authored andcommitted
Implement serial::{Tx,Rx}::{listen,unlisten}. (#72)
1 parent a60aeff commit 42bb6ec

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
1313
- Add ADC1 reading functions for channels 16 (temperature) and 17 (internal reference voltage)
1414
- Update existing ADC example according to ADC API changes
1515
- Add new ADC example to read ambient temperature using ADC1 CH16
16+
- Add `listen` and `unlisten` to `serial::Tx` and `serial::Rx`.
1617

1718

1819
### Breaking changes

src/serial.rs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -326,6 +326,26 @@ macro_rules! hal {
326326
}
327327
}
328328

329+
impl Tx<$USARTX> {
330+
pub fn listen(&mut self) {
331+
unsafe { (*$USARTX::ptr()).cr1.modify(|_, w| w.txeie().set_bit()) };
332+
}
333+
334+
pub fn unlisten(&mut self) {
335+
unsafe { (*$USARTX::ptr()).cr1.modify(|_, w| w.txeie().clear_bit()) };
336+
}
337+
}
338+
339+
impl Rx<$USARTX> {
340+
pub fn listen(&mut self) {
341+
unsafe { (*$USARTX::ptr()).cr1.modify(|_, w| w.rxneie().set_bit()) };
342+
}
343+
344+
pub fn unlisten(&mut self) {
345+
unsafe { (*$USARTX::ptr()).cr1.modify(|_, w| w.rxneie().clear_bit()) };
346+
}
347+
}
348+
329349
impl crate::hal::serial::Read<u8> for Rx<$USARTX> {
330350
type Error = Error;
331351

0 commit comments

Comments
 (0)