Struct stm32wlxx_hal::dma::Dma1
source · pub struct Dma1 {
pub c1: Dma1Ch1,
pub c2: Dma1Ch2,
pub c3: Dma1Ch3,
pub c4: Dma1Ch4,
pub c5: Dma1Ch5,
pub c6: Dma1Ch6,
pub c7: Dma1Ch7,
}
Expand description
All DMA controller 1 channels.
Fields§
§c1: Dma1Ch1
DMA controller 1 channel 1
c2: Dma1Ch2
DMA controller 1 channel 2
c3: Dma1Ch3
DMA controller 1 channel 3
c4: Dma1Ch4
DMA controller 1 channel 4
c5: Dma1Ch5
DMA controller 1 channel 5
c6: Dma1Ch6
DMA controller 1 channel 6
c7: Dma1Ch7
DMA controller 1 channel 7
Implementations§
source§impl Dma1
impl Dma1
sourcepub fn split(dmamux: DMAMUX, dma1: DMA1, rcc: &mut RCC) -> Self
pub fn split(dmamux: DMAMUX, dma1: DMA1, rcc: &mut RCC) -> Self
Split the DMA registers into individual channels.
This will enable clocks and reset the DMA1 and DMAMUX peripherals.
Most of the time you will want to use AllDma::split
.
This is provided for low-power use cases where you do not need
both DMA controllers.
Example
use stm32wlxx_hal::{dma::Dma1, pac};
let mut dp: pac::Peripherals = pac::Peripherals::take().unwrap();
let dma1: Dma1 = Dma1::split(dp.DMAMUX, dp.DMA1, &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 and DMAMUX peripherals.
Safety
- Ensure nothing is using the DMA1, and DMAMUX peripherals before disabling the clock.
- You are responsible for re-enabling the clock before using the DMA1, and DMAMUX peripherals.
Example
use stm32wlxx_hal::{dma::Dma1, pac};
let mut dp: pac::Peripherals = pac::Peripherals::take().unwrap();
let dma1: Dma1 = Dma1::split(dp.DMAMUX, dp.DMA1, &mut dp.RCC);
// ... use DMA channels
// safety: DMA is not in use
unsafe { Dma1::disable_clocks(&mut dp.RCC) };
// have a low power nap or something
Dma1::enable_clocks(&mut dp.RCC);
// ... use DMA channels
sourcepub const unsafe fn steal() -> Self
pub const unsafe fn steal() -> Self
Steal the DMA1 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, and DMAMUX peripherals.
Example
use stm32wlxx_hal::{dma::Dma1, pac};
let mut dp: pac::Peripherals = pac::Peripherals::take().unwrap();
// DMAs cannot be used via registers now
let _: pac::DMA1 = dp.DMA1;
let _: pac::DMAMUX = dp.DMAMUX;
// safety: nothing is using the peripherals
unsafe { Dma1::pulse_resets(&mut dp.RCC) };
Dma1::enable_clocks(&mut dp.RCC);
// safety
// 1. We have exclusive access
// 2. peripherals have been setup
let dmas: Dma1 = unsafe { Dma1::steal() };
Trait Implementations§
Auto Trait Implementations§
impl RefUnwindSafe for Dma1
impl Send for Dma1
impl Sync for Dma1
impl Unpin for Dma1
impl UnwindSafe for Dma1
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