2021-07-15 05:42:06 +02:00
|
|
|
#[cfg(dma)]
|
2022-02-05 03:03:32 +01:00
|
|
|
pub(crate) mod dma;
|
2023-04-17 00:04:54 +02:00
|
|
|
#[cfg(dma)]
|
|
|
|
pub use dma::*;
|
|
|
|
|
|
|
|
// stm32h7 has both dma and bdma. In that case, we export dma as "main" dma,
|
|
|
|
// and bdma as "secondary", under `embassy_stm32::dma::bdma`.
|
|
|
|
#[cfg(all(bdma, dma))]
|
|
|
|
pub mod bdma;
|
|
|
|
|
|
|
|
#[cfg(all(bdma, not(dma)))]
|
|
|
|
pub(crate) mod bdma;
|
|
|
|
#[cfg(all(bdma, not(dma)))]
|
|
|
|
pub use bdma::*;
|
|
|
|
|
|
|
|
#[cfg(gpdma)]
|
|
|
|
pub(crate) mod gpdma;
|
|
|
|
#[cfg(gpdma)]
|
|
|
|
pub use gpdma::*;
|
|
|
|
|
2021-07-15 05:42:06 +02:00
|
|
|
#[cfg(dmamux)]
|
|
|
|
mod dmamux;
|
2021-05-16 02:57:46 +02:00
|
|
|
|
2023-04-18 20:56:23 +02:00
|
|
|
pub mod word;
|
|
|
|
|
2022-01-19 15:59:25 +01:00
|
|
|
use core::mem;
|
2022-06-12 22:15:44 +02:00
|
|
|
|
2022-11-23 10:11:19 +01:00
|
|
|
use embassy_cortex_m::interrupt::Priority;
|
2023-04-17 00:04:54 +02:00
|
|
|
use embassy_hal_common::impl_peripheral;
|
2021-05-25 04:17:24 +02:00
|
|
|
|
2022-07-22 22:00:12 +02:00
|
|
|
#[cfg(dmamux)]
|
|
|
|
pub use self::dmamux::*;
|
2021-11-19 19:15:55 +01:00
|
|
|
|
2023-04-17 00:04:54 +02:00
|
|
|
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
|
|
|
|
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
|
|
|
|
enum Dir {
|
|
|
|
MemoryToPeripheral,
|
|
|
|
PeripheralToMemory,
|
2021-07-15 05:42:06 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
pub struct NoDma;
|
|
|
|
|
2022-07-23 14:00:19 +02:00
|
|
|
impl_peripheral!(NoDma);
|
2021-07-15 05:42:06 +02:00
|
|
|
|
2022-01-19 15:59:25 +01:00
|
|
|
// TODO: replace transmutes with core::ptr::metadata once it's stable
|
|
|
|
#[allow(unused)]
|
|
|
|
pub(crate) fn slice_ptr_parts<T>(slice: *const [T]) -> (usize, usize) {
|
|
|
|
unsafe { mem::transmute(slice) }
|
|
|
|
}
|
|
|
|
|
|
|
|
#[allow(unused)]
|
|
|
|
pub(crate) fn slice_ptr_parts_mut<T>(slice: *mut [T]) -> (usize, usize) {
|
|
|
|
unsafe { mem::transmute(slice) }
|
|
|
|
}
|
2023-04-17 00:04:54 +02:00
|
|
|
|
|
|
|
// safety: must be called only once at startup
|
|
|
|
pub(crate) unsafe fn init(
|
|
|
|
#[cfg(bdma)] bdma_priority: Priority,
|
|
|
|
#[cfg(dma)] dma_priority: Priority,
|
|
|
|
#[cfg(gpdma)] gpdma_priority: Priority,
|
|
|
|
) {
|
|
|
|
#[cfg(bdma)]
|
|
|
|
bdma::init(bdma_priority);
|
|
|
|
#[cfg(dma)]
|
|
|
|
dma::init(dma_priority);
|
|
|
|
#[cfg(gpdma)]
|
|
|
|
gpdma::init(gpdma_priority);
|
|
|
|
#[cfg(dmamux)]
|
|
|
|
dmamux::init();
|
|
|
|
}
|