mirror of
https://github.com/embassy-rs/embassy.git
synced 2024-11-21 22:32:29 +00:00
Merge pull request #2119 from JuliDi/fmc-sram-adc
STM32: Add raw access to FMC peripheral and fix typo in build.rs
This commit is contained in:
commit
46cffcc8d4
@ -828,7 +828,7 @@ fn main() {
|
||||
(("fmc", "NCE"), quote!(crate::fmc::NCEPin)),
|
||||
(("fmc", "NOE"), quote!(crate::fmc::NOEPin)),
|
||||
(("fmc", "NWE"), quote!(crate::fmc::NWEPin)),
|
||||
(("fmc", "Clk"), quote!(crate::fmc::ClkPin)),
|
||||
(("fmc", "CLK"), quote!(crate::fmc::ClkPin)),
|
||||
(("fmc", "BA0"), quote!(crate::fmc::BA0Pin)),
|
||||
(("fmc", "BA1"), quote!(crate::fmc::BA1Pin)),
|
||||
(("timer", "CH1"), quote!(crate::timer::Channel1Pin)),
|
||||
|
@ -12,6 +12,37 @@ pub struct Fmc<'d, T: Instance> {
|
||||
|
||||
unsafe impl<'d, T> Send for Fmc<'d, T> where T: Instance {}
|
||||
|
||||
impl<'d, T> Fmc<'d, T>
|
||||
where
|
||||
T: Instance,
|
||||
{
|
||||
/// Create a raw FMC instance.
|
||||
///
|
||||
/// **Note:** This is currently used to provide access to some basic FMC functions
|
||||
/// for manual configuration for memory types that stm32-fmc does not support.
|
||||
pub fn new_raw(_instance: impl Peripheral<P = T> + 'd) -> Self {
|
||||
Self { peri: PhantomData }
|
||||
}
|
||||
|
||||
/// Enable the FMC peripheral and reset it.
|
||||
pub fn enable(&mut self) {
|
||||
T::enable_and_reset();
|
||||
}
|
||||
|
||||
/// Enable the memory controller on applicable chips.
|
||||
pub fn memory_controller_enable(&mut self) {
|
||||
// fmc v1 and v2 does not have the fmcen bit
|
||||
// fsmc v1, v2 and v3 does not have the fmcen bit
|
||||
// This is a "not" because it is expected that all future versions have this bit
|
||||
#[cfg(not(any(fmc_v1x3, fmc_v2x1, fsmc_v1x0, fsmc_v1x3, fsmc_v2x3, fsmc_v3x1)))]
|
||||
T::REGS.bcr1().modify(|r| r.set_fmcen(true));
|
||||
}
|
||||
|
||||
pub fn source_clock_hz(&self) -> u32 {
|
||||
<T as crate::rcc::sealed::RccPeripheral>::frequency().0
|
||||
}
|
||||
}
|
||||
|
||||
unsafe impl<'d, T> stm32_fmc::FmcPeripheral for Fmc<'d, T>
|
||||
where
|
||||
T: Instance,
|
||||
|
Loading…
Reference in New Issue
Block a user