diff options
| -rw-r--r-- | embassy-stm32/build.rs | 2 | ||||
| -rw-r--r-- | embassy-stm32/src/fmc.rs | 31 |
2 files changed, 32 insertions, 1 deletions
diff --git a/embassy-stm32/build.rs b/embassy-stm32/build.rs index 965fe4e87..1307656a0 100644 --- a/embassy-stm32/build.rs +++ b/embassy-stm32/build.rs | |||
| @@ -828,7 +828,7 @@ fn main() { | |||
| 828 | (("fmc", "NCE"), quote!(crate::fmc::NCEPin)), | 828 | (("fmc", "NCE"), quote!(crate::fmc::NCEPin)), |
| 829 | (("fmc", "NOE"), quote!(crate::fmc::NOEPin)), | 829 | (("fmc", "NOE"), quote!(crate::fmc::NOEPin)), |
| 830 | (("fmc", "NWE"), quote!(crate::fmc::NWEPin)), | 830 | (("fmc", "NWE"), quote!(crate::fmc::NWEPin)), |
| 831 | (("fmc", "Clk"), quote!(crate::fmc::ClkPin)), | 831 | (("fmc", "CLK"), quote!(crate::fmc::ClkPin)), |
| 832 | (("fmc", "BA0"), quote!(crate::fmc::BA0Pin)), | 832 | (("fmc", "BA0"), quote!(crate::fmc::BA0Pin)), |
| 833 | (("fmc", "BA1"), quote!(crate::fmc::BA1Pin)), | 833 | (("fmc", "BA1"), quote!(crate::fmc::BA1Pin)), |
| 834 | (("timer", "CH1"), quote!(crate::timer::Channel1Pin)), | 834 | (("timer", "CH1"), quote!(crate::timer::Channel1Pin)), |
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 | ||
| 13 | unsafe impl<'d, T> Send for Fmc<'d, T> where T: Instance {} | 13 | unsafe impl<'d, T> Send for Fmc<'d, T> where T: Instance {} |
| 14 | 14 | ||
| 15 | impl<'d, T> Fmc<'d, T> | ||
| 16 | where | ||
| 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 | |||
| 15 | unsafe impl<'d, T> stm32_fmc::FmcPeripheral for Fmc<'d, T> | 46 | unsafe impl<'d, T> stm32_fmc::FmcPeripheral for Fmc<'d, T> |
| 16 | where | 47 | where |
| 17 | T: Instance, | 48 | T: Instance, |
