Skip to content

Commit 5d3062f

Browse files
committed
Enable AHB access as part of the contract for creating an FMC
1 parent 0dd7d9d commit 5d3062f

File tree

1 file changed

+6
-13
lines changed

1 file changed

+6
-13
lines changed

src/fmc.rs

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,10 @@ use crate::gpio::gpioi::{PI0, PI1, PI10, PI2, PI3, PI4, PI5, PI6, PI7, PI9};
3333
use crate::gpio::{Alternate, AF12, AF9};
3434

3535
/// Storage type for Flexible Memory Controller and its clocks
36+
///
37+
/// AHB access to the FMC peripheral must be enabled
3638
pub struct FMC {
3739
fmc: stm32::FMC,
38-
_prec: rec::Fmc,
3940
fmc_ker_ck: Option<Hertz>,
4041
}
4142

@@ -81,9 +82,11 @@ impl FmcExt for stm32::FMC {
8182
rec::FmcClkSel::PER => clocks.per_ck(),
8283
};
8384

85+
// Enable AHB access and reset peripheral
86+
prec.enable().reset();
87+
8488
FMC {
8589
fmc: self,
86-
_prec: prec,
8790
fmc_ker_ck,
8891
}
8992
}
@@ -93,17 +96,7 @@ unsafe impl FmcPeripheral for FMC {
9396
const REGISTERS: *const () = stm32::FMC::ptr() as *const ();
9497

9598
fn enable(&mut self) {
96-
// unsafe: we own this via the PREC structure
97-
let rcc = unsafe { &*stm32::RCC::ptr() };
98-
99-
cortex_m::interrupt::free(|_| {
100-
// Enable FMC peripheral
101-
rcc.ahb3enr.modify(|_, w| w.fmcen().set_bit());
102-
103-
// Reset FMC peripheral
104-
rcc.ahb3rstr.modify(|_, w| w.fmcrst().set_bit());
105-
rcc.ahb3rstr.modify(|_, w| w.fmcrst().clear_bit());
106-
});
99+
// Already enabled as part of the contract for creating FMC
107100
}
108101

109102
fn memory_controller_enable(&mut self) {

0 commit comments

Comments
 (0)