aboutsummaryrefslogtreecommitdiff
path: root/embassy-stm32/src/fmc.rs
diff options
context:
space:
mode:
authorJuliDi <[email protected]>2023-10-28 13:50:02 +0200
committerJuliDi <[email protected]>2023-10-28 13:50:02 +0200
commitb1e5b6ffe1587362d4a58f5da831338dfa41a1bc (patch)
tree96faa529f335ad32245063011ee4ad6f5f2ebc70 /embassy-stm32/src/fmc.rs
parent2aaf4bf96b960d6379b4c089145031d18c065aa3 (diff)
Add raw fmc access implementation
Diffstat (limited to 'embassy-stm32/src/fmc.rs')
-rw-r--r--embassy-stm32/src/fmc.rs31
1 files changed, 31 insertions, 0 deletions
diff --git a/embassy-stm32/src/fmc.rs b/embassy-stm32/src/fmc.rs
index d6e25996c..dd0d27217 100644
--- a/embassy-stm32/src/fmc.rs
+++ b/embassy-stm32/src/fmc.rs
@@ -12,6 +12,37 @@ pub struct Fmc<'d, T: Instance> {
12 12
13unsafe impl<'d, T> Send for Fmc<'d, T> where T: Instance {} 13unsafe impl<'d, T> Send for Fmc<'d, T> where T: Instance {}
14 14
15impl<'d, T> Fmc<'d, T>
16where
17 T: Instance,
18{
19 /// Create a raw FMC instance.
20 ///
21 /// **Note:** This is currently used to provide access to some basic FMC functions
22 /// for manual configuration for memory types that stm32-fmc does not support.
23 pub fn new_raw(_instance: impl Peripheral<P = T> + 'd) -> Self {
24 Self { peri: PhantomData }
25 }
26
27 /// Enable the FMC peripheral and reset it.
28 pub fn enable(&mut self) {
29 T::enable_and_reset();
30 }
31
32 /// Enable the memory controller on applicable chips.
33 pub fn memory_controller_enable(&mut self) {
34 // fmc v1 and v2 does not have the fmcen bit
35 // fsmc v1, v2 and v3 does not have the fmcen bit
36 // This is a "not" because it is expected that all future versions have this bit
37 #[cfg(not(any(fmc_v1x3, fmc_v2x1, fsmc_v1x0, fsmc_v1x3, fsmc_v2x3, fsmc_v3x1)))]
38 T::REGS.bcr1().modify(|r| r.set_fmcen(true));
39 }
40
41 pub fn source_clock_hz(&self) -> u32 {
42 <T as crate::rcc::sealed::RccPeripheral>::frequency().0
43 }
44}
45
15unsafe impl<'d, T> stm32_fmc::FmcPeripheral for Fmc<'d, T> 46unsafe impl<'d, T> stm32_fmc::FmcPeripheral for Fmc<'d, T>
16where 47where
17 T: Instance, 48 T: Instance,