aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--embassy-stm32/CHANGELOG.md1
-rw-r--r--embassy-stm32/src/qspi/mod.rs52
-rw-r--r--examples/stm32f7/src/bin/qspi.rs16
-rw-r--r--examples/stm32h742/src/bin/qspi.rs16
-rw-r--r--examples/stm32l432/src/bin/qspi_mmap.rs16
5 files changed, 53 insertions, 48 deletions
diff --git a/embassy-stm32/CHANGELOG.md b/embassy-stm32/CHANGELOG.md
index 93a1f4f64..eb48fd6fe 100644
--- a/embassy-stm32/CHANGELOG.md
+++ b/embassy-stm32/CHANGELOG.md
@@ -17,6 +17,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
17- feat: Added support for more OctoSPI configurations (e.g. APS6408 RAM) ([#4581](https://github.com/embassy-rs/embassy/pull/4581)) 17- feat: Added support for more OctoSPI configurations (e.g. APS6408 RAM) ([#4581](https://github.com/embassy-rs/embassy/pull/4581))
18- fix: stm32/usart: fix bug with blocking flush in buffered uart ([#4648](https://github.com/embassy-rs/embassy/pull/4648)) 18- fix: stm32/usart: fix bug with blocking flush in buffered uart ([#4648](https://github.com/embassy-rs/embassy/pull/4648))
19- fix: stm32/(ospi/hspi/xspi): Fix the alternate bytes register config sticking around for subsequent writes 19- fix: stm32/(ospi/hspi/xspi): Fix the alternate bytes register config sticking around for subsequent writes
20- feat: Configurable gpio speed for QSPI
20 21
21## 0.4.0 - 2025-08-26 22## 0.4.0 - 2025-08-26
22 23
diff --git a/embassy-stm32/src/qspi/mod.rs b/embassy-stm32/src/qspi/mod.rs
index c0cd216f0..0644069a6 100644
--- a/embassy-stm32/src/qspi/mod.rs
+++ b/embassy-stm32/src/qspi/mod.rs
@@ -48,6 +48,7 @@ impl Default for TransferConfig {
48 48
49/// QSPI driver configuration. 49/// QSPI driver configuration.
50#[derive(Clone, Copy)] 50#[derive(Clone, Copy)]
51#[non_exhaustive]
51pub struct Config { 52pub struct Config {
52 /// Flash memory size representend as 2^[0-32], as reasonable minimum 1KiB(9) was chosen. 53 /// Flash memory size representend as 2^[0-32], as reasonable minimum 1KiB(9) was chosen.
53 /// If you need other value the whose predefined use `Other` variant. 54 /// If you need other value the whose predefined use `Other` variant.
@@ -62,6 +63,8 @@ pub struct Config {
62 pub cs_high_time: ChipSelectHighTime, 63 pub cs_high_time: ChipSelectHighTime,
63 /// Shift sampling point of input data (none, or half-cycle) 64 /// Shift sampling point of input data (none, or half-cycle)
64 pub sample_shifting: SampleShifting, 65 pub sample_shifting: SampleShifting,
66 /// GPIO Speed
67 pub gpio_speed: Speed,
65} 68}
66 69
67impl Default for Config { 70impl Default for Config {
@@ -73,6 +76,7 @@ impl Default for Config {
73 fifo_threshold: FIFOThresholdLevel::_17Bytes, 76 fifo_threshold: FIFOThresholdLevel::_17Bytes,
74 cs_high_time: ChipSelectHighTime::_5Cycle, 77 cs_high_time: ChipSelectHighTime::_5Cycle,
75 sample_shifting: SampleShifting::None, 78 sample_shifting: SampleShifting::None,
79 gpio_speed: Speed::VeryHigh,
76 } 80 }
77 } 81 }
78} 82}
@@ -286,14 +290,14 @@ impl<'d, T: Instance> Qspi<'d, T, Blocking> {
286 ) -> Self { 290 ) -> Self {
287 Self::new_inner( 291 Self::new_inner(
288 peri, 292 peri,
289 new_pin!(d0, AfType::output(OutputType::PushPull, Speed::VeryHigh)), 293 new_pin!(d0, AfType::output(OutputType::PushPull, config.gpio_speed)),
290 new_pin!(d1, AfType::output(OutputType::PushPull, Speed::VeryHigh)), 294 new_pin!(d1, AfType::output(OutputType::PushPull, config.gpio_speed)),
291 new_pin!(d2, AfType::output(OutputType::PushPull, Speed::VeryHigh)), 295 new_pin!(d2, AfType::output(OutputType::PushPull, config.gpio_speed)),
292 new_pin!(d3, AfType::output(OutputType::PushPull, Speed::VeryHigh)), 296 new_pin!(d3, AfType::output(OutputType::PushPull, config.gpio_speed)),
293 new_pin!(sck, AfType::output(OutputType::PushPull, Speed::VeryHigh)), 297 new_pin!(sck, AfType::output(OutputType::PushPull, config.gpio_speed)),
294 new_pin!( 298 new_pin!(
295 nss, 299 nss,
296 AfType::output_pull(OutputType::PushPull, Speed::VeryHigh, Pull::Up) 300 AfType::output_pull(OutputType::PushPull, config.gpio_speed, Pull::Up)
297 ), 301 ),
298 None, 302 None,
299 config, 303 config,
@@ -314,14 +318,14 @@ impl<'d, T: Instance> Qspi<'d, T, Blocking> {
314 ) -> Self { 318 ) -> Self {
315 Self::new_inner( 319 Self::new_inner(
316 peri, 320 peri,
317 new_pin!(d0, AfType::output(OutputType::PushPull, Speed::VeryHigh)), 321 new_pin!(d0, AfType::output(OutputType::PushPull, config.gpio_speed)),
318 new_pin!(d1, AfType::output(OutputType::PushPull, Speed::VeryHigh)), 322 new_pin!(d1, AfType::output(OutputType::PushPull, config.gpio_speed)),
319 new_pin!(d2, AfType::output(OutputType::PushPull, Speed::VeryHigh)), 323 new_pin!(d2, AfType::output(OutputType::PushPull, config.gpio_speed)),
320 new_pin!(d3, AfType::output(OutputType::PushPull, Speed::VeryHigh)), 324 new_pin!(d3, AfType::output(OutputType::PushPull, config.gpio_speed)),
321 new_pin!(sck, AfType::output(OutputType::PushPull, Speed::VeryHigh)), 325 new_pin!(sck, AfType::output(OutputType::PushPull, config.gpio_speed)),
322 new_pin!( 326 new_pin!(
323 nss, 327 nss,
324 AfType::output_pull(OutputType::PushPull, Speed::VeryHigh, Pull::Up) 328 AfType::output_pull(OutputType::PushPull, config.gpio_speed, Pull::Up)
325 ), 329 ),
326 None, 330 None,
327 config, 331 config,
@@ -345,14 +349,14 @@ impl<'d, T: Instance> Qspi<'d, T, Async> {
345 ) -> Self { 349 ) -> Self {
346 Self::new_inner( 350 Self::new_inner(
347 peri, 351 peri,
348 new_pin!(d0, AfType::output(OutputType::PushPull, Speed::VeryHigh)), 352 new_pin!(d0, AfType::output(OutputType::PushPull, config.gpio_speed)),
349 new_pin!(d1, AfType::output(OutputType::PushPull, Speed::VeryHigh)), 353 new_pin!(d1, AfType::output(OutputType::PushPull, config.gpio_speed)),
350 new_pin!(d2, AfType::output(OutputType::PushPull, Speed::VeryHigh)), 354 new_pin!(d2, AfType::output(OutputType::PushPull, config.gpio_speed)),
351 new_pin!(d3, AfType::output(OutputType::PushPull, Speed::VeryHigh)), 355 new_pin!(d3, AfType::output(OutputType::PushPull, config.gpio_speed)),
352 new_pin!(sck, AfType::output(OutputType::PushPull, Speed::VeryHigh)), 356 new_pin!(sck, AfType::output(OutputType::PushPull, config.gpio_speed)),
353 new_pin!( 357 new_pin!(
354 nss, 358 nss,
355 AfType::output_pull(OutputType::PushPull, Speed::VeryHigh, Pull::Up) 359 AfType::output_pull(OutputType::PushPull, config.gpio_speed, Pull::Up)
356 ), 360 ),
357 new_dma!(dma), 361 new_dma!(dma),
358 config, 362 config,
@@ -374,14 +378,14 @@ impl<'d, T: Instance> Qspi<'d, T, Async> {
374 ) -> Self { 378 ) -> Self {
375 Self::new_inner( 379 Self::new_inner(
376 peri, 380 peri,
377 new_pin!(d0, AfType::output(OutputType::PushPull, Speed::VeryHigh)), 381 new_pin!(d0, AfType::output(OutputType::PushPull, config.gpio_speed)),
378 new_pin!(d1, AfType::output(OutputType::PushPull, Speed::VeryHigh)), 382 new_pin!(d1, AfType::output(OutputType::PushPull, config.gpio_speed)),
379 new_pin!(d2, AfType::output(OutputType::PushPull, Speed::VeryHigh)), 383 new_pin!(d2, AfType::output(OutputType::PushPull, config.gpio_speed)),
380 new_pin!(d3, AfType::output(OutputType::PushPull, Speed::VeryHigh)), 384 new_pin!(d3, AfType::output(OutputType::PushPull, config.gpio_speed)),
381 new_pin!(sck, AfType::output(OutputType::PushPull, Speed::VeryHigh)), 385 new_pin!(sck, AfType::output(OutputType::PushPull, config.gpio_speed)),
382 new_pin!( 386 new_pin!(
383 nss, 387 nss,
384 AfType::output_pull(OutputType::PushPull, Speed::VeryHigh, Pull::Up) 388 AfType::output_pull(OutputType::PushPull, config.gpio_speed, Pull::Up)
385 ), 389 ),
386 new_dma!(dma), 390 new_dma!(dma),
387 config, 391 config,
diff --git a/examples/stm32f7/src/bin/qspi.rs b/examples/stm32f7/src/bin/qspi.rs
index ab29ddeff..80652b865 100644
--- a/examples/stm32f7/src/bin/qspi.rs
+++ b/examples/stm32f7/src/bin/qspi.rs
@@ -273,14 +273,14 @@ async fn main(_spawner: Spawner) -> ! {
273 let p = embassy_stm32::init(config); 273 let p = embassy_stm32::init(config);
274 info!("Embassy initialized"); 274 info!("Embassy initialized");
275 275
276 let config = QspiCfg { 276 let mut config = QspiCfg::default();
277 memory_size: MemorySize::_8MiB, 277 config.memory_size = MemorySize::_8MiB;
278 address_size: AddressSize::_24bit, 278 config.address_size = AddressSize::_24bit;
279 prescaler: 16, 279 config.prescaler = 16;
280 cs_high_time: ChipSelectHighTime::_1Cycle, 280 config.cs_high_time = ChipSelectHighTime::_1Cycle;
281 fifo_threshold: FIFOThresholdLevel::_16Bytes, 281 config.fifo_threshold = FIFOThresholdLevel::_16Bytes;
282 sample_shifting: SampleShifting::None, 282 config.sample_shifting = SampleShifting::None;
283 }; 283
284 let driver = Qspi::new_bank1( 284 let driver = Qspi::new_bank1(
285 p.QUADSPI, p.PF8, p.PF9, p.PE2, p.PF6, p.PF10, p.PB10, p.DMA2_CH7, config, 285 p.QUADSPI, p.PF8, p.PF9, p.PE2, p.PF6, p.PF10, p.PB10, p.DMA2_CH7, config,
286 ); 286 );
diff --git a/examples/stm32h742/src/bin/qspi.rs b/examples/stm32h742/src/bin/qspi.rs
index 50e37ec52..9e79d7089 100644
--- a/examples/stm32h742/src/bin/qspi.rs
+++ b/examples/stm32h742/src/bin/qspi.rs
@@ -266,14 +266,14 @@ async fn main(_spawner: Spawner) -> ! {
266 let p = embassy_stm32::init(config); 266 let p = embassy_stm32::init(config);
267 info!("Embassy initialized"); 267 info!("Embassy initialized");
268 268
269 let config = QspiCfg { 269 let mut config = QspiCfg::default();
270 memory_size: MemorySize::_8MiB, 270 config.memory_size = MemorySize::_8MiB;
271 address_size: AddressSize::_24bit, 271 config.address_size = AddressSize::_24bit;
272 prescaler: 16, 272 config.prescaler = 16;
273 cs_high_time: ChipSelectHighTime::_1Cycle, 273 config.cs_high_time = ChipSelectHighTime::_1Cycle;
274 fifo_threshold: FIFOThresholdLevel::_16Bytes, 274 config.fifo_threshold = FIFOThresholdLevel::_16Bytes;
275 sample_shifting: SampleShifting::None, 275 config.sample_shifting = SampleShifting::None;
276 }; 276
277 let driver = Qspi::new_blocking_bank1(p.QUADSPI, p.PD11, p.PD12, p.PE2, p.PD13, p.PB2, p.PB10, config); 277 let driver = Qspi::new_blocking_bank1(p.QUADSPI, p.PD11, p.PD12, p.PE2, p.PD13, p.PB2, p.PB10, config);
278 let mut flash = FlashMemory::new(driver); 278 let mut flash = FlashMemory::new(driver);
279 let flash_id = flash.read_id(); 279 let flash_id = flash.read_id();
diff --git a/examples/stm32l432/src/bin/qspi_mmap.rs b/examples/stm32l432/src/bin/qspi_mmap.rs
index 075458fe5..feabdd532 100644
--- a/examples/stm32l432/src/bin/qspi_mmap.rs
+++ b/examples/stm32l432/src/bin/qspi_mmap.rs
@@ -246,14 +246,14 @@ const MEMORY_ADDR: u32 = 0x00000000 as u32;
246async fn main(_spawner: Spawner) { 246async fn main(_spawner: Spawner) {
247 let p = embassy_stm32::init(Default::default()); 247 let p = embassy_stm32::init(Default::default());
248 248
249 let config = qspi::Config { 249 let mut config = qspi::Config::default();
250 memory_size: MemorySize::_16MiB, 250 config.memory_size = MemorySize::_16MiB;
251 address_size: AddressSize::_24bit, 251 config.address_size = AddressSize::_24bit;
252 prescaler: 200, 252 config.prescaler = 200;
253 cs_high_time: ChipSelectHighTime::_1Cycle, 253 config.cs_high_time = ChipSelectHighTime::_1Cycle;
254 fifo_threshold: FIFOThresholdLevel::_16Bytes, 254 config.fifo_threshold = FIFOThresholdLevel::_16Bytes;
255 sample_shifting: SampleShifting::None, 255 config.sample_shifting = SampleShifting::None;
256 }; 256
257 let driver = qspi::Qspi::new_bank1(p.QUADSPI, p.PB1, p.PB0, p.PA7, p.PA6, p.PA3, p.PA2, p.DMA2_CH7, config); 257 let driver = qspi::Qspi::new_bank1(p.QUADSPI, p.PB1, p.PB0, p.PA7, p.PA6, p.PA3, p.PA2, p.DMA2_CH7, config);
258 let mut flash = FlashMemory::new(driver); 258 let mut flash = FlashMemory::new(driver);
259 let mut wr_buf = [0u8; 256]; 259 let mut wr_buf = [0u8; 256];