Struct stm32wlxx_hal::dma::AllDma
source · pub struct AllDma {
pub d1: Dma1,
pub d2: Dma2,
}
Expand description
All DMA channels.
Fields§
§d1: Dma1
DMA controller 1.
d2: Dma2
DMA controller 2.
Implementations§
source§impl AllDma
impl AllDma
sourcepub fn split(dmamux: DMAMUX, dma1: DMA1, dma2: DMA2, rcc: &mut RCC) -> Self
pub fn split(dmamux: DMAMUX, dma1: DMA1, dma2: DMA2, rcc: &mut RCC) -> Self
Split the DMA registers into individual channels.
This will enable clocks and reset the DMA1, DMA2, and DMAMUX peripherals.
Example
use stm32wlxx_hal::{dma::AllDma, pac};
let mut dp: pac::Peripherals = pac::Peripherals::take().unwrap();
let dma: AllDma = AllDma::split(dp.DMAMUX, dp.DMA1, dp.DMA2, &mut dp.RCC);
sourcepub unsafe fn pulse_resets(rcc: &mut RCC)
pub unsafe fn pulse_resets(rcc: &mut RCC)
sourcepub fn enable_clocks(rcc: &mut RCC)
pub fn enable_clocks(rcc: &mut RCC)
sourcepub unsafe fn disable_clocks(rcc: &mut RCC)
pub unsafe fn disable_clocks(rcc: &mut RCC)
Disable clocks for the DMA1, DMA2, and DMAMUX peripherals.
Safety
- Ensure nothing is using the DMA1, DMA2, and DMAMUX peripherals before disabling the clock.
- You are responsible for re-enabling the clock before using the DMA1, DMA2, and DMAMUX peripherals.
Example
use stm32wlxx_hal::{dma::AllDma, pac};
let mut dp: pac::Peripherals = pac::Peripherals::take().unwrap();
let dma: AllDma = AllDma::split(dp.DMAMUX, dp.DMA1, dp.DMA2, &mut dp.RCC);
// ... use DMA channels
// safety: DMA is not in use
unsafe { AllDma::disable_clocks(&mut dp.RCC) };
// have a low power nap or something
AllDma::enable_clocks(&mut dp.RCC);
// ... use DMA channels
sourcepub const unsafe fn steal() -> Self
pub const unsafe fn steal() -> Self
Steal all DMA channels.
Safety
- Ensure that the code stealing the DMA channels has exclusive access. Singleton checks are bypassed with this method.
- You are responsible for resetting and enabling clocks on the DMA1, DMA2, and DMAMUX peripherals.
Example
use stm32wlxx_hal::{dma::AllDma, pac};
let mut dp: pac::Peripherals = pac::Peripherals::take().unwrap();
// DMAs cannot be used via registers now
let _: pac::DMA1 = dp.DMA1;
let _: pac::DMA2 = dp.DMA2;
let _: pac::DMAMUX = dp.DMAMUX;
// safety: nothing is using the peripherals
unsafe { AllDma::pulse_resets(&mut dp.RCC) };
AllDma::enable_clocks(&mut dp.RCC);
// safety
// 1. We have exclusive access
// 2. peripherals have been setup
let dmas: AllDma = unsafe { AllDma::steal() };
Trait Implementations§
Auto Trait Implementations§
impl RefUnwindSafe for AllDma
impl Send for AllDma
impl Sync for AllDma
impl Unpin for AllDma
impl UnwindSafe for AllDma
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more