From 881fee982005b36a73c3b09b69bda48f81603084 Mon Sep 17 00:00:00 2001 From: Brian Schwind Date: Sat, 13 Sep 2025 00:12:36 +0900 Subject: [PATCH] Apply fixes to XSPI as well --- embassy-stm32/src/xspi/mod.rs | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/embassy-stm32/src/xspi/mod.rs b/embassy-stm32/src/xspi/mod.rs index 60ccf3c97..5ae074a90 100644 --- a/embassy-stm32/src/xspi/mod.rs +++ b/embassy-stm32/src/xspi/mod.rs @@ -110,7 +110,7 @@ pub struct TransferConfig { /// Data width (DMODE) pub dwidth: XspiWidth, - /// Data buffer + /// Data Double Transfer rate enable pub ddtr: bool, /// Number of dummy cycles (DCYC) @@ -424,11 +424,6 @@ impl<'d, T: Instance, M: PeriMode> Xspi<'d, T, M> { // Configure alternate bytes if let Some(ab) = command.alternate_bytes { T::REGS.abr().write(|v| v.set_alternate(ab)); - T::REGS.ccr().modify(|w| { - w.set_abmode(CcrAbmode::from_bits(command.abwidth.into())); - w.set_abdtr(command.abdtr); - w.set_absize(CcrAbsize::from_bits(command.absize.into())); - }) } else { T::REGS.ccr().modify(|w| { // disable alternate bytes @@ -445,14 +440,14 @@ impl<'d, T: Instance, M: PeriMode> Xspi<'d, T, M> { if let Some(data_length) = data_len { T::REGS.dlr().write(|v| { v.set_dl((data_length - 1) as u32); - }) + }); } else { T::REGS.dlr().write(|v| { v.set_dl((0) as u32); - }) + }); } - // Configure instruction/address/data modes + // Configure instruction/address/alternate bytes/data modes T::REGS.ccr().modify(|w| { w.set_imode(CcrImode::from_bits(command.iwidth.into())); w.set_idtr(command.idtr); @@ -462,6 +457,10 @@ impl<'d, T: Instance, M: PeriMode> Xspi<'d, T, M> { w.set_addtr(command.addtr); w.set_adsize(CcrAdsize::from_bits(command.adsize.into())); + w.set_abmode(CcrAbmode::from_bits(command.abwidth.into())); + w.set_abdtr(command.abdtr); + w.set_absize(CcrAbsize::from_bits(command.absize.into())); + w.set_dmode(CcrDmode::from_bits(command.dwidth.into())); w.set_ddtr(command.ddtr); });