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

source

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);
source

pub unsafe fn pulse_resets(rcc: &mut RCC)

Reset the DMA1, DMA2, and DMAMUX peripherals.

split will pulse reset for you.

Safety
  1. Ensure nothing is using the DMA1, DMA2, and DMAMUX peripherals before calling this function.
Example

See steal.

source

pub fn enable_clocks(rcc: &mut RCC)

Enable clocks for the DMA1, DMA2, and DMAMUX peripherals.

split will enable clocks for you.

Example

See steal.

source

pub unsafe fn disable_clocks(rcc: &mut RCC)

Disable clocks for the DMA1, DMA2, and DMAMUX peripherals.

Safety
  1. Ensure nothing is using the DMA1, DMA2, and DMAMUX peripherals before disabling the clock.
  2. 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
source

pub const unsafe fn steal() -> Self

Steal all DMA channels.

Safety
  1. Ensure that the code stealing the DMA channels has exclusive access. Singleton checks are bypassed with this method.
  2. 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§

source§

impl Debug for AllDma

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.