diff options
| author | Cristian Milatinov <[email protected]> | 2025-07-05 00:47:30 -0400 |
|---|---|---|
| committer | Cristian Milatinov <[email protected]> | 2025-07-05 00:47:30 -0400 |
| commit | fb21fcf4f1d2acfa15cf4da03fff190c0bb9df59 (patch) | |
| tree | 29240a00ae9b16fa2b2357ff3c705207fe8c80b4 /embassy-stm32 | |
| parent | f53b6649dd42918f7d5228d06821ac5b95e33d38 (diff) | |
Added sample shifting to qspi config for stm32
Diffstat (limited to 'embassy-stm32')
| -rw-r--r-- | embassy-stm32/src/qspi/enums.rs | 16 | ||||
| -rw-r--r-- | embassy-stm32/src/qspi/mod.rs | 5 |
2 files changed, 20 insertions, 1 deletions
diff --git a/embassy-stm32/src/qspi/enums.rs b/embassy-stm32/src/qspi/enums.rs index 9ec4c1b43..3905fcbf8 100644 --- a/embassy-stm32/src/qspi/enums.rs +++ b/embassy-stm32/src/qspi/enums.rs | |||
| @@ -331,3 +331,19 @@ impl From<DummyCycles> for u8 { | |||
| 331 | } | 331 | } |
| 332 | } | 332 | } |
| 333 | } | 333 | } |
| 334 | |||
| 335 | #[allow(missing_docs)] | ||
| 336 | #[derive(Copy, Clone)] | ||
| 337 | pub enum SampleShifting { | ||
| 338 | None, | ||
| 339 | HalfCycle | ||
| 340 | } | ||
| 341 | |||
| 342 | impl From<SampleShifting> for bool { | ||
| 343 | fn from(value: SampleShifting) -> Self { | ||
| 344 | match value { | ||
| 345 | SampleShifting::None => false, | ||
| 346 | SampleShifting::HalfCycle => true | ||
| 347 | } | ||
| 348 | } | ||
| 349 | } \ No newline at end of file | ||
diff --git a/embassy-stm32/src/qspi/mod.rs b/embassy-stm32/src/qspi/mod.rs index 0df057c53..52b1f3084 100644 --- a/embassy-stm32/src/qspi/mod.rs +++ b/embassy-stm32/src/qspi/mod.rs | |||
| @@ -58,6 +58,8 @@ pub struct Config { | |||
| 58 | pub fifo_threshold: FIFOThresholdLevel, | 58 | pub fifo_threshold: FIFOThresholdLevel, |
| 59 | /// Minimum number of cycles that chip select must be high between issued commands | 59 | /// Minimum number of cycles that chip select must be high between issued commands |
| 60 | pub cs_high_time: ChipSelectHighTime, | 60 | pub cs_high_time: ChipSelectHighTime, |
| 61 | /// Shift sampling point of input data (none, or half-cycle) | ||
| 62 | pub sample_shifting: SampleShifting, | ||
| 61 | } | 63 | } |
| 62 | 64 | ||
| 63 | impl Default for Config { | 65 | impl Default for Config { |
| @@ -68,6 +70,7 @@ impl Default for Config { | |||
| 68 | prescaler: 128, | 70 | prescaler: 128, |
| 69 | fifo_threshold: FIFOThresholdLevel::_17Bytes, | 71 | fifo_threshold: FIFOThresholdLevel::_17Bytes, |
| 70 | cs_high_time: ChipSelectHighTime::_5Cycle, | 72 | cs_high_time: ChipSelectHighTime::_5Cycle, |
| 73 | sample_shifting: SampleShifting::None | ||
| 71 | } | 74 | } |
| 72 | } | 75 | } |
| 73 | } | 76 | } |
| @@ -120,7 +123,7 @@ impl<'d, T: Instance, M: PeriMode> Qspi<'d, T, M> { | |||
| 120 | T::REGS.cr().modify(|w| { | 123 | T::REGS.cr().modify(|w| { |
| 121 | w.set_en(true); | 124 | w.set_en(true); |
| 122 | //w.set_tcen(false); | 125 | //w.set_tcen(false); |
| 123 | w.set_sshift(false); | 126 | w.set_sshift(config.sample_shifting.into()); |
| 124 | w.set_fthres(config.fifo_threshold.into()); | 127 | w.set_fthres(config.fifo_threshold.into()); |
| 125 | w.set_prescaler(config.prescaler); | 128 | w.set_prescaler(config.prescaler); |
| 126 | w.set_fsel(fsel.into()); | 129 | w.set_fsel(fsel.into()); |
