diff --git a/CHANGELOG.md b/CHANGELOG.md index 0f5b17252..23f11071a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/). - SPI support for reclock after initialization ([#98](https://github.com/stm32-rs/stm32f3xx-hal/pull/98)) - Support for `stm32f302x6` and `stm32f302x8` devices ([#132](https://github.com/stm32-rs/stm32f3xx-hal/pull/132)) - Support for the onboard real-time clock (RTC) ([#136](https://github.com/stm32-rs/stm32f3xx-hal/pull/136)) +- Enable DMA for USART on `stm32f302` devices ([#139](https://github.com/stm32-rs/stm32f3xx-hal/pull/139)) ## [v0.5.0] - 2020-07-21 diff --git a/src/dma.rs b/src/dma.rs index 9523c3ced..15ce3621d 100644 --- a/src/dma.rs +++ b/src/dma.rs @@ -494,10 +494,14 @@ dma!( ); #[cfg(any( + feature = "stm32f302xb", + feature = "stm32f302xc", + feature = "stm32f302xd", + feature = "stm32f302xe", feature = "stm32f303xb", feature = "stm32f303xc", feature = "stm32f303xd", - feature = "stm32f303xe" + feature = "stm32f303xe", ))] dma!( DMA2, dma2, dma2en, @@ -527,7 +531,6 @@ macro_rules! on_channel { }; } -#[cfg(feature = "stm32f303")] on_channel!(dma1, serial::Rx => C5, serial::Tx => C4, diff --git a/src/lib.rs b/src/lib.rs index f20697460..07b3250ce 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -116,7 +116,7 @@ pub use crate::pac::interrupt; pub mod adc; #[cfg(feature = "device-selected")] pub mod delay; -#[cfg(feature = "stm32f303")] +#[cfg(any(feature = "stm32f302", feature = "stm32f303"))] pub mod dma; #[cfg(feature = "device-selected")] pub mod flash; diff --git a/src/prelude.rs b/src/prelude.rs index fa17f9449..02ca404ab 100644 --- a/src/prelude.rs +++ b/src/prelude.rs @@ -1,6 +1,6 @@ //! Prelude -#[cfg(feature = "stm32f303")] +#[cfg(any(feature = "stm32f302", feature = "stm32f303"))] pub use crate::dma::DmaExt as _stm32f3xx_hal_dma_DmaExt; pub use crate::flash::FlashExt as _stm32f3xx_hal_flash_FlashExt; pub use crate::gpio::GpioExt as _stm32f3xx_hal_gpio_GpioExt; diff --git a/src/serial.rs b/src/serial.rs index 3597c1e27..6f0740677 100644 --- a/src/serial.rs +++ b/src/serial.rs @@ -37,9 +37,9 @@ use crate::gpio::gpiod; ))] use crate::gpio::gpioe; -#[cfg(feature = "stm32f303")] +#[cfg(any(feature = "stm32f302", feature = "stm32f303"))] use crate::dma; -#[cfg(feature = "stm32f303")] +#[cfg(any(feature = "stm32f302", feature = "stm32f303"))] use cortex_m::interrupt; /// Interrupt event @@ -363,7 +363,7 @@ macro_rules! hal { impl blocking::serial::write::Default for Tx<$USARTX> {} - #[cfg(feature = "stm32f303")] + #[cfg(any(feature = "stm32f302", feature = "stm32f303"))] impl Rx<$USARTX> { /// Fill the buffer with received data using DMA. pub fn read_exact( @@ -384,7 +384,7 @@ macro_rules! hal { } } - #[cfg(feature = "stm32f303")] + #[cfg(any(feature = "stm32f302", feature = "stm32f303"))] impl Tx<$USARTX> { /// Transmit all data in the buffer using DMA. pub fn write_all( @@ -405,7 +405,7 @@ macro_rules! hal { } } - #[cfg(feature = "stm32f303")] + #[cfg(any(feature = "stm32f302", feature = "stm32f303"))] impl dma::Target for Rx<$USARTX> { fn enable_dma(&mut self) { // NOTE(unsafe) critical section prevents races @@ -424,7 +424,7 @@ macro_rules! hal { } } - #[cfg(feature = "stm32f303")] + #[cfg(any(feature = "stm32f302", feature = "stm32f303"))] impl dma::Target for Tx<$USARTX> { fn enable_dma(&mut self) { // NOTE(unsafe) critical section prevents races @@ -446,24 +446,8 @@ macro_rules! hal { } } -#[cfg(any( - feature = "stm32f301", - feature = "stm32f318", - feature = "stm32f303", - feature = "stm32f373", - feature = "stm32f378", - feature = "stm32f328", - feature = "stm32f358", - feature = "stm32f398" -))] hal! { USART1: (usart1, APB2, usart1en, usart1rst, pclk2), USART2: (usart2, APB1, usart2en, usart2rst, pclk1), USART3: (usart3, APB1, usart3en, usart3rst, pclk1), } - -#[cfg(any(feature = "stm32f302", feature = "stm32f334"))] -hal! { - USART1: (usart1, APB2, usart1en, usart1rst, pclk2), - USART2: (usart2, APB1, usart2en, usart2rst, pclk1), -}