diff options
| author | Haobo Gu <[email protected]> | 2024-10-23 12:54:50 +0800 |
|---|---|---|
| committer | Haobo Gu <[email protected]> | 2024-10-23 12:54:50 +0800 |
| commit | e5bc2666547d0320635fede91c76d936c56a1a90 (patch) | |
| tree | d65e3afb4a01d9a54170de549acf5185d9a54fcc /embassy-stm32 | |
| parent | 398119ae43fdea147c43e72a5dea1fc83cb37340 (diff) | |
feat: set ospi memory mapped mode
Signed-off-by: Haobo Gu <[email protected]>
Diffstat (limited to 'embassy-stm32')
| -rw-r--r-- | embassy-stm32/src/ospi/mod.rs | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/embassy-stm32/src/ospi/mod.rs b/embassy-stm32/src/ospi/mod.rs index e4adc4b09..0574f7816 100644 --- a/embassy-stm32/src/ospi/mod.rs +++ b/embassy-stm32/src/ospi/mod.rs | |||
| @@ -179,6 +179,43 @@ pub struct Ospi<'d, T: Instance, M: PeriMode> { | |||
| 179 | } | 179 | } |
| 180 | 180 | ||
| 181 | impl<'d, T: Instance, M: PeriMode> Ospi<'d, T, M> { | 181 | impl<'d, T: Instance, M: PeriMode> Ospi<'d, T, M> { |
| 182 | pub fn enable_memory_mapped_mode(&mut self) { | ||
| 183 | let reg = T::REGS; | ||
| 184 | while reg.sr().read().busy() { | ||
| 185 | info!("wait ospi busy"); | ||
| 186 | } | ||
| 187 | |||
| 188 | reg.ccr().modify(|r| { | ||
| 189 | r.set_isize(crate::ospi::vals::SizeInBits::_8BIT); | ||
| 190 | r.set_adsize(crate::ospi::vals::SizeInBits::_24BIT); | ||
| 191 | r.set_admode(crate::ospi::vals::PhaseMode::ONELINE); | ||
| 192 | r.set_imode(crate::ospi::vals::PhaseMode::ONELINE); | ||
| 193 | r.set_dmode(crate::ospi::vals::PhaseMode::FOURLINES); | ||
| 194 | }); | ||
| 195 | |||
| 196 | reg.cr().modify(|r| { | ||
| 197 | r.set_fmode(crate::ospi::vals::FunctionalMode::MEMORYMAPPED); | ||
| 198 | r.set_dmaen(false); | ||
| 199 | r.set_en(true); | ||
| 200 | }); | ||
| 201 | |||
| 202 | // reg.tcr().modify(|r| { | ||
| 203 | // r.set_dcyc(6); | ||
| 204 | // }); | ||
| 205 | |||
| 206 | } | ||
| 207 | pub fn disable_memory_mapped_mode(&mut self) { | ||
| 208 | let reg = T::REGS; | ||
| 209 | while reg.sr().read().busy() { | ||
| 210 | info!("wait ospi busy"); | ||
| 211 | } | ||
| 212 | reg.cr().modify(|r| { | ||
| 213 | r.set_fmode(crate::ospi::vals::FunctionalMode::INDIRECTWRITE); | ||
| 214 | r.set_dmaen(false); | ||
| 215 | r.set_en(true); | ||
| 216 | }); | ||
| 217 | } | ||
| 218 | |||
| 182 | fn new_inner( | 219 | fn new_inner( |
| 183 | peri: impl Peripheral<P = T> + 'd, | 220 | peri: impl Peripheral<P = T> + 'd, |
| 184 | d0: Option<PeripheralRef<'d, AnyPin>>, | 221 | d0: Option<PeripheralRef<'d, AnyPin>>, |
