From 86271ea39e841bfa7f8d74defc4aaa07a680be13 Mon Sep 17 00:00:00 2001 From: Lambert Sartory Date: Thu, 11 Dec 2025 00:04:37 +0100 Subject: Enable STM32N6 DMA and I2C clock sources --- embassy-stm32/src/dma/gpdma/mod.rs | 1 - embassy-stm32/src/dma/mod.rs | 4 ---- embassy-stm32/src/rcc/n6.rs | 20 ++++++++++++++++++++ 3 files changed, 20 insertions(+), 5 deletions(-) (limited to 'embassy-stm32') diff --git a/embassy-stm32/src/dma/gpdma/mod.rs b/embassy-stm32/src/dma/gpdma/mod.rs index 51c107cb4..afb18ec1a 100644 --- a/embassy-stm32/src/dma/gpdma/mod.rs +++ b/embassy-stm32/src/dma/gpdma/mod.rs @@ -137,7 +137,6 @@ pub(crate) unsafe fn init(cs: critical_section::CriticalSection, irq_priority: c impl AnyChannel { /// Safety: Must be called with a matching set of parameters for a valid dma channel - #[cfg(not(stm32n6))] pub(crate) unsafe fn on_irq(&self) { let info = self.info(); #[cfg(feature = "_dual-core")] diff --git a/embassy-stm32/src/dma/mod.rs b/embassy-stm32/src/dma/mod.rs index 90feab167..05d9c2e51 100644 --- a/embassy-stm32/src/dma/mod.rs +++ b/embassy-stm32/src/dma/mod.rs @@ -48,11 +48,9 @@ pub type Request = u8; pub type Request = (); pub(crate) trait SealedChannel: StoppablePeripheral { - #[cfg(not(stm32n6))] fn id(&self) -> u8; } -#[cfg(not(stm32n6))] pub(crate) trait ChannelInterrupt { #[cfg_attr(not(feature = "rt"), allow(unused))] unsafe fn on_irq(); @@ -62,7 +60,6 @@ pub(crate) trait ChannelInterrupt { #[allow(private_bounds)] pub trait Channel: SealedChannel + PeripheralType + Into + 'static {} -#[cfg(not(stm32n6))] macro_rules! dma_channel_impl { ($channel_peri:ident, $index:expr, $stop_mode:ident) => { impl crate::rcc::StoppablePeripheral for crate::peripherals::$channel_peri { @@ -125,7 +122,6 @@ impl StoppablePeripheral for AnyChannel { } impl SealedChannel for AnyChannel { - #[cfg(not(stm32n6))] fn id(&self) -> u8 { self.id } diff --git a/embassy-stm32/src/rcc/n6.rs b/embassy-stm32/src/rcc/n6.rs index 866851bbd..178ec57d4 100644 --- a/embassy-stm32/src/rcc/n6.rs +++ b/embassy-stm32/src/rcc/n6.rs @@ -1003,6 +1003,24 @@ pub(crate) unsafe fn init(config: Config) { p.SCB.cpacr.modify(|w| w | (3 << 20) | (3 << 22)); } + // TODO: ugly workaround for DMA accesses until RIF is properly implemented + debug!("deactivating RIF"); + const RISAF3_BASE_NS: *mut u32 = stm32_metapac::RNG.wrapping_byte_offset(0x8000) as _; // AHB3PERIPH_BASE_NS + 0x8000UL + const RISAF3_REG0_CFGR: *mut u32 = RISAF3_BASE_NS.wrapping_byte_offset(0x40); + const RISAF3_REG0_ENDR: *mut u32 = RISAF3_BASE_NS.wrapping_byte_offset(0x48); + const RISAF3_REG0_CIDCFGR: *mut u32 = RISAF3_BASE_NS.wrapping_byte_offset(0x4C); + const RISAF3_REG1_CFGR: *mut u32 = RISAF3_BASE_NS.wrapping_byte_offset(0x80); + const RISAF3_REG1_ENDR: *mut u32 = RISAF3_BASE_NS.wrapping_byte_offset(0x88); + const RISAF3_REG1_CIDCFGR: *mut u32 = RISAF3_BASE_NS.wrapping_byte_offset(0x8C); + unsafe { + *RISAF3_REG0_CIDCFGR = 0x000F000F; /* RW for everyone */ + *RISAF3_REG0_ENDR = 0xFFFFFFFF; /* all-encompassing */ + *RISAF3_REG0_CFGR = 0x00000101; /* enabled, secure, unprivileged for everyone */ + *RISAF3_REG1_CIDCFGR = 0x00FF00FF; /* RW for everyone */ + *RISAF3_REG1_ENDR = 0xFFFFFFFF; /* all-encompassing */ + *RISAF3_REG1_CFGR = 0x00000001; /* enabled, non-secure, unprivileged*/ + } + debug!("setting power supply config"); power_supply_config(config.supply_config); @@ -1039,7 +1057,9 @@ pub(crate) unsafe fn init(config: Config) { i2s_ckin: None, ic8: None, ic9: None, + ic10: None, ic14: None, + ic15: None, ic17: None, ic20: None, ); -- cgit