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

source

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

pub unsafe fn pulse_resets(rcc: &mut RCC)

Reset the DMA1 and DMAMUX peripherals.

split will pulse reset for you.

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

See steal.

source

pub fn enable_clocks(rcc: &mut RCC)

Enable clocks for the DMA1 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 and DMAMUX peripherals.

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

pub const unsafe fn steal() -> Self

Steal the DMA1 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, 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§

source§

impl Debug for Dma1

source§

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

Formats the value using the given formatter. Read more

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> 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.