Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not enable UART DMA flags unconditionally #336

Merged
merged 3 commits into from Jul 13, 2021
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 4 additions & 1 deletion CHANGELOG.md
Expand Up @@ -20,10 +20,13 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
- Fix > 2 byte i2c reads
- Send stop after acknowledge errors on i2c
- Fix i2c interactions after errors
- Fix SPI3 alternate function remapping.
- Fix SPI3 alternate function remapping
- Do not enable UART DMA flags unconditionally

### Changed
- Use `cortex-m-rtic` instead of `cortex-m-rtfm` in the examples
- Renamed `serial`'s `RxDma`/`TxDma`'s `split` method into `release`
- Renamed I2C's `free` method into `release`

## [v0.7.0]- 2020-10-17

Expand Down
7 changes: 6 additions & 1 deletion src/i2c.rs
Expand Up @@ -385,9 +385,14 @@ where
}

/// Releases the I2C peripheral and associated pins
pub fn free(self) -> (I2C, PINS) {
pub fn release(self) -> (I2C, PINS) {
(self.i2c, self.pins)
}

#[deprecated(since = "0.7.1", note = "Please use release instead")]
pub fn free(self) -> (I2C, PINS) {
self.release()
}
}

impl<I2C, PINS> BlockingI2c<I2C, PINS>
Expand Down
15 changes: 12 additions & 3 deletions src/serial.rs
Expand Up @@ -308,9 +308,6 @@ macro_rules! hal {
w.$usartX_remap().$bit(($closure)(PINS::REMAP))
});

// enable DMA transfers
usart.cr3.write(|w| w.dmat().set_bit().dmar().set_bit());

// Configure baud rate
let brr = <$USARTX as RccBus>::Bus::get_frequency(&clocks).0 / config.baudrate.0;
assert!(brr >= 16, "impossible baud rate");
Expand Down Expand Up @@ -547,6 +544,7 @@ macro_rules! serialdma {

impl Rx<$USARTX> {
pub fn with_dma(self, channel: $dmarxch) -> $rxdma {
unsafe { (*$USARTX::ptr()).cr3.write(|w| w.dmar().set_bit()); }
RxDma {
payload: self,
channel,
Expand All @@ -556,6 +554,7 @@ macro_rules! serialdma {

impl Tx<$USARTX> {
pub fn with_dma(self, channel: $dmatxch) -> $txdma {
unsafe { (*$USARTX::ptr()).cr3.write(|w| w.dmat().set_bit()); }
TxDma {
payload: self,
channel,
Expand All @@ -564,8 +563,13 @@ macro_rules! serialdma {
}

impl $rxdma {
#[deprecated(since = "0.7.1", note = "Please use release instead")]
pub fn split(mut self) -> (Rx<$USARTX>, $dmarxch) {
Windfisch marked this conversation as resolved.
Show resolved Hide resolved
self.release()
}
pub fn release(mut self) -> (Rx<$USARTX>, $dmarxch) {
self.stop();
unsafe { (*$USARTX::ptr()).cr3.write(|w| w.dmar().clear_bit()); }
let RxDma {payload, channel} = self;
(
payload,
Expand All @@ -575,8 +579,13 @@ macro_rules! serialdma {
}

impl $txdma {
#[deprecated(since = "0.7.1", note = "Please use release instead")]
pub fn split(mut self) -> (Tx<$USARTX>, $dmatxch) {
Windfisch marked this conversation as resolved.
Show resolved Hide resolved
self.release()
}
pub fn release(mut self) -> (Tx<$USARTX>, $dmatxch) {
self.stop();
unsafe { (*$USARTX::ptr()).cr3.write(|w| w.dmat().clear_bit()); }
let TxDma {payload, channel} = self;
(
payload,
Expand Down