aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDario Nieuwenhuis <[email protected]>2025-09-15 23:09:39 +0000
committerGitHub <[email protected]>2025-09-15 23:09:39 +0000
commitfe95e338617d28116e38af6b8c5a5be37c6c24a0 (patch)
tree87c60cced9c638f6f65fcf56b95931eaee6b1e95
parent92a6fd2946f2cbb15359290f68aa360953da2ff7 (diff)
parent337da33c7a127b083652d635d956f03d79a952bc (diff)
Merge pull request #4667 from tonarino/config-derive
Unify derivation of Clone, Copy and defmt::format for all *SPI configs
-rw-r--r--embassy-stm32/CHANGELOG.md1
-rw-r--r--embassy-stm32/src/hspi/mod.rs2
-rw-r--r--embassy-stm32/src/ospi/enums.rs8
-rw-r--r--embassy-stm32/src/ospi/mod.rs3
-rw-r--r--embassy-stm32/src/qspi/enums.rs7
-rw-r--r--embassy-stm32/src/qspi/mod.rs2
-rw-r--r--embassy-stm32/src/xspi/enums.rs8
-rw-r--r--embassy-stm32/src/xspi/mod.rs3
8 files changed, 34 insertions, 0 deletions
diff --git a/embassy-stm32/CHANGELOG.md b/embassy-stm32/CHANGELOG.md
index eb48fd6fe..624845b3a 100644
--- a/embassy-stm32/CHANGELOG.md
+++ b/embassy-stm32/CHANGELOG.md
@@ -18,6 +18,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
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- feat: Configurable gpio speed for QSPI
21- feat: derive Clone, Copy and defmt::Format for all *SPI-related configs
21 22
22## 0.4.0 - 2025-08-26 23## 0.4.0 - 2025-08-26
23 24
diff --git a/embassy-stm32/src/hspi/mod.rs b/embassy-stm32/src/hspi/mod.rs
index 3b73062a2..95d9e5099 100644
--- a/embassy-stm32/src/hspi/mod.rs
+++ b/embassy-stm32/src/hspi/mod.rs
@@ -86,6 +86,8 @@ impl Default for Config {
86} 86}
87 87
88/// HSPI transfer configuration. 88/// HSPI transfer configuration.
89#[derive(Clone, Copy)]
90#[cfg_attr(feature = "defmt", derive(defmt::Format))]
89pub struct TransferConfig { 91pub struct TransferConfig {
90 /// Instruction width (IMODE) 92 /// Instruction width (IMODE)
91 pub iwidth: HspiWidth, 93 pub iwidth: HspiWidth,
diff --git a/embassy-stm32/src/ospi/enums.rs b/embassy-stm32/src/ospi/enums.rs
index 4021f7ce3..4db801752 100644
--- a/embassy-stm32/src/ospi/enums.rs
+++ b/embassy-stm32/src/ospi/enums.rs
@@ -23,6 +23,7 @@ impl Into<u8> for OspiMode {
23/// Ospi lane width 23/// Ospi lane width
24#[allow(dead_code)] 24#[allow(dead_code)]
25#[derive(Copy, Clone)] 25#[derive(Copy, Clone)]
26#[cfg_attr(feature = "defmt", derive(defmt::Format))]
26pub enum OspiWidth { 27pub enum OspiWidth {
27 /// None 28 /// None
28 NONE, 29 NONE,
@@ -71,6 +72,7 @@ impl Into<bool> for FlashSelection {
71#[allow(dead_code)] 72#[allow(dead_code)]
72#[allow(missing_docs)] 73#[allow(missing_docs)]
73#[derive(Copy, Clone)] 74#[derive(Copy, Clone)]
75#[cfg_attr(feature = "defmt", derive(defmt::Format))]
74pub enum WrapSize { 76pub enum WrapSize {
75 None, 77 None,
76 _16Bytes, 78 _16Bytes,
@@ -95,6 +97,7 @@ impl Into<u8> for WrapSize {
95#[allow(missing_docs)] 97#[allow(missing_docs)]
96#[allow(dead_code)] 98#[allow(dead_code)]
97#[derive(Copy, Clone)] 99#[derive(Copy, Clone)]
100#[cfg_attr(feature = "defmt", derive(defmt::Format))]
98pub enum MemoryType { 101pub enum MemoryType {
99 Micron, 102 Micron,
100 Macronix, 103 Macronix,
@@ -120,6 +123,7 @@ impl Into<u8> for MemoryType {
120/// Ospi memory size. 123/// Ospi memory size.
121#[allow(missing_docs)] 124#[allow(missing_docs)]
122#[derive(Copy, Clone)] 125#[derive(Copy, Clone)]
126#[cfg_attr(feature = "defmt", derive(defmt::Format))]
123pub enum MemorySize { 127pub enum MemorySize {
124 _1KiB, 128 _1KiB,
125 _2KiB, 129 _2KiB,
@@ -180,6 +184,7 @@ impl Into<u8> for MemorySize {
180 184
181/// Ospi Address size 185/// Ospi Address size
182#[derive(Copy, Clone)] 186#[derive(Copy, Clone)]
187#[cfg_attr(feature = "defmt", derive(defmt::Format))]
183pub enum AddressSize { 188pub enum AddressSize {
184 /// 8-bit address 189 /// 8-bit address
185 _8Bit, 190 _8Bit,
@@ -205,6 +210,7 @@ impl Into<u8> for AddressSize {
205/// Time the Chip Select line stays high. 210/// Time the Chip Select line stays high.
206#[allow(missing_docs)] 211#[allow(missing_docs)]
207#[derive(Copy, Clone)] 212#[derive(Copy, Clone)]
213#[cfg_attr(feature = "defmt", derive(defmt::Format))]
208pub enum ChipSelectHighTime { 214pub enum ChipSelectHighTime {
209 _1Cycle, 215 _1Cycle,
210 _2Cycle, 216 _2Cycle,
@@ -234,6 +240,7 @@ impl Into<u8> for ChipSelectHighTime {
234/// FIFO threshold. 240/// FIFO threshold.
235#[allow(missing_docs)] 241#[allow(missing_docs)]
236#[derive(Copy, Clone)] 242#[derive(Copy, Clone)]
243#[cfg_attr(feature = "defmt", derive(defmt::Format))]
237pub enum FIFOThresholdLevel { 244pub enum FIFOThresholdLevel {
238 _1Bytes, 245 _1Bytes,
239 _2Bytes, 246 _2Bytes,
@@ -311,6 +318,7 @@ impl Into<u8> for FIFOThresholdLevel {
311/// Dummy cycle count 318/// Dummy cycle count
312#[allow(missing_docs)] 319#[allow(missing_docs)]
313#[derive(Copy, Clone)] 320#[derive(Copy, Clone)]
321#[cfg_attr(feature = "defmt", derive(defmt::Format))]
314pub enum DummyCycles { 322pub enum DummyCycles {
315 _0, 323 _0,
316 _1, 324 _1,
diff --git a/embassy-stm32/src/ospi/mod.rs b/embassy-stm32/src/ospi/mod.rs
index cbd6c8d35..eebaf5573 100644
--- a/embassy-stm32/src/ospi/mod.rs
+++ b/embassy-stm32/src/ospi/mod.rs
@@ -23,6 +23,7 @@ use crate::{peripherals, Peri};
23 23
24/// OPSI driver config. 24/// OPSI driver config.
25#[derive(Clone, Copy)] 25#[derive(Clone, Copy)]
26#[cfg_attr(feature = "defmt", derive(defmt::Format))]
26pub struct Config { 27pub struct Config {
27 /// Fifo threshold used by the peripheral to generate the interrupt indicating data 28 /// Fifo threshold used by the peripheral to generate the interrupt indicating data
28 /// or space is available in the FIFO 29 /// or space is available in the FIFO
@@ -83,6 +84,8 @@ impl Default for Config {
83} 84}
84 85
85/// OSPI transfer configuration. 86/// OSPI transfer configuration.
87#[derive(Clone, Copy)]
88#[cfg_attr(feature = "defmt", derive(defmt::Format))]
86pub struct TransferConfig { 89pub struct TransferConfig {
87 /// Instruction width (IMODE) 90 /// Instruction width (IMODE)
88 pub iwidth: OspiWidth, 91 pub iwidth: OspiWidth,
diff --git a/embassy-stm32/src/qspi/enums.rs b/embassy-stm32/src/qspi/enums.rs
index fa5e36d06..8a8420127 100644
--- a/embassy-stm32/src/qspi/enums.rs
+++ b/embassy-stm32/src/qspi/enums.rs
@@ -23,6 +23,7 @@ impl From<QspiMode> for u8 {
23/// QSPI lane width 23/// QSPI lane width
24#[allow(dead_code)] 24#[allow(dead_code)]
25#[derive(Copy, Clone)] 25#[derive(Copy, Clone)]
26#[cfg_attr(feature = "defmt", derive(defmt::Format))]
26pub enum QspiWidth { 27pub enum QspiWidth {
27 /// None 28 /// None
28 NONE, 29 NONE,
@@ -67,6 +68,7 @@ impl From<FlashSelection> for bool {
67/// QSPI memory size. 68/// QSPI memory size.
68#[allow(missing_docs)] 69#[allow(missing_docs)]
69#[derive(Copy, Clone)] 70#[derive(Copy, Clone)]
71#[cfg_attr(feature = "defmt", derive(defmt::Format))]
70pub enum MemorySize { 72pub enum MemorySize {
71 _1KiB, 73 _1KiB,
72 _2KiB, 74 _2KiB,
@@ -127,6 +129,7 @@ impl From<MemorySize> for u8 {
127 129
128/// QSPI Address size 130/// QSPI Address size
129#[derive(Copy, Clone)] 131#[derive(Copy, Clone)]
132#[cfg_attr(feature = "defmt", derive(defmt::Format))]
130pub enum AddressSize { 133pub enum AddressSize {
131 /// 8-bit address 134 /// 8-bit address
132 _8Bit, 135 _8Bit,
@@ -152,6 +155,7 @@ impl From<AddressSize> for u8 {
152/// Time the Chip Select line stays high. 155/// Time the Chip Select line stays high.
153#[allow(missing_docs)] 156#[allow(missing_docs)]
154#[derive(Copy, Clone)] 157#[derive(Copy, Clone)]
158#[cfg_attr(feature = "defmt", derive(defmt::Format))]
155pub enum ChipSelectHighTime { 159pub enum ChipSelectHighTime {
156 _1Cycle, 160 _1Cycle,
157 _2Cycle, 161 _2Cycle,
@@ -181,6 +185,7 @@ impl From<ChipSelectHighTime> for u8 {
181/// FIFO threshold. 185/// FIFO threshold.
182#[allow(missing_docs)] 186#[allow(missing_docs)]
183#[derive(Copy, Clone)] 187#[derive(Copy, Clone)]
188#[cfg_attr(feature = "defmt", derive(defmt::Format))]
184pub enum FIFOThresholdLevel { 189pub enum FIFOThresholdLevel {
185 _1Bytes, 190 _1Bytes,
186 _2Bytes, 191 _2Bytes,
@@ -258,6 +263,7 @@ impl From<FIFOThresholdLevel> for u8 {
258/// Dummy cycle count 263/// Dummy cycle count
259#[allow(missing_docs)] 264#[allow(missing_docs)]
260#[derive(Copy, Clone)] 265#[derive(Copy, Clone)]
266#[cfg_attr(feature = "defmt", derive(defmt::Format))]
261pub enum DummyCycles { 267pub enum DummyCycles {
262 _0, 268 _0,
263 _1, 269 _1,
@@ -334,6 +340,7 @@ impl From<DummyCycles> for u8 {
334 340
335#[allow(missing_docs)] 341#[allow(missing_docs)]
336#[derive(Copy, Clone)] 342#[derive(Copy, Clone)]
343#[cfg_attr(feature = "defmt", derive(defmt::Format))]
337pub enum SampleShifting { 344pub enum SampleShifting {
338 None, 345 None,
339 HalfCycle, 346 HalfCycle,
diff --git a/embassy-stm32/src/qspi/mod.rs b/embassy-stm32/src/qspi/mod.rs
index 0644069a6..b03cd9009 100644
--- a/embassy-stm32/src/qspi/mod.rs
+++ b/embassy-stm32/src/qspi/mod.rs
@@ -18,6 +18,7 @@ use crate::{peripherals, Peri};
18 18
19/// QSPI transfer configuration. 19/// QSPI transfer configuration.
20#[derive(Clone, Copy)] 20#[derive(Clone, Copy)]
21#[cfg_attr(feature = "defmt", derive(defmt::Format))]
21pub struct TransferConfig { 22pub struct TransferConfig {
22 /// Instruction width (IMODE) 23 /// Instruction width (IMODE)
23 pub iwidth: QspiWidth, 24 pub iwidth: QspiWidth,
@@ -48,6 +49,7 @@ impl Default for TransferConfig {
48 49
49/// QSPI driver configuration. 50/// QSPI driver configuration.
50#[derive(Clone, Copy)] 51#[derive(Clone, Copy)]
52#[cfg_attr(feature = "defmt", derive(defmt::Format))]
51#[non_exhaustive] 53#[non_exhaustive]
52pub struct Config { 54pub struct Config {
53 /// Flash memory size representend as 2^[0-32], as reasonable minimum 1KiB(9) was chosen. 55 /// Flash memory size representend as 2^[0-32], as reasonable minimum 1KiB(9) was chosen.
diff --git a/embassy-stm32/src/xspi/enums.rs b/embassy-stm32/src/xspi/enums.rs
index c96641180..2e510fada 100644
--- a/embassy-stm32/src/xspi/enums.rs
+++ b/embassy-stm32/src/xspi/enums.rs
@@ -22,6 +22,7 @@ impl Into<u8> for XspiMode {
22 22
23/// Xspi lane width 23/// Xspi lane width
24#[derive(Copy, Clone)] 24#[derive(Copy, Clone)]
25#[cfg_attr(feature = "defmt", derive(defmt::Format))]
25pub enum XspiWidth { 26pub enum XspiWidth {
26 /// None 27 /// None
27 NONE, 28 NONE,
@@ -50,6 +51,7 @@ impl Into<u8> for XspiWidth {
50/// Wrap Size 51/// Wrap Size
51#[allow(missing_docs)] 52#[allow(missing_docs)]
52#[derive(Copy, Clone)] 53#[derive(Copy, Clone)]
54#[cfg_attr(feature = "defmt", derive(defmt::Format))]
53pub enum WrapSize { 55pub enum WrapSize {
54 None, 56 None,
55 _16Bytes, 57 _16Bytes,
@@ -73,6 +75,7 @@ impl Into<u8> for WrapSize {
73/// Memory Type 75/// Memory Type
74#[allow(missing_docs)] 76#[allow(missing_docs)]
75#[derive(Copy, Clone)] 77#[derive(Copy, Clone)]
78#[cfg_attr(feature = "defmt", derive(defmt::Format))]
76pub enum MemoryType { 79pub enum MemoryType {
77 Micron, 80 Micron,
78 Macronix, 81 Macronix,
@@ -98,6 +101,7 @@ impl Into<u8> for MemoryType {
98/// Xspi memory size. 101/// Xspi memory size.
99#[allow(missing_docs)] 102#[allow(missing_docs)]
100#[derive(Copy, Clone)] 103#[derive(Copy, Clone)]
104#[cfg_attr(feature = "defmt", derive(defmt::Format))]
101pub enum MemorySize { 105pub enum MemorySize {
102 _1KiB, 106 _1KiB,
103 _2KiB, 107 _2KiB,
@@ -158,6 +162,7 @@ impl Into<u8> for MemorySize {
158 162
159/// Xspi Address size 163/// Xspi Address size
160#[derive(Copy, Clone)] 164#[derive(Copy, Clone)]
165#[cfg_attr(feature = "defmt", derive(defmt::Format))]
161pub enum AddressSize { 166pub enum AddressSize {
162 /// 8-bit address 167 /// 8-bit address
163 _8bit, 168 _8bit,
@@ -183,6 +188,7 @@ impl Into<u8> for AddressSize {
183/// Time the Chip Select line stays high. 188/// Time the Chip Select line stays high.
184#[allow(missing_docs)] 189#[allow(missing_docs)]
185#[derive(Copy, Clone)] 190#[derive(Copy, Clone)]
191#[cfg_attr(feature = "defmt", derive(defmt::Format))]
186pub enum ChipSelectHighTime { 192pub enum ChipSelectHighTime {
187 _1Cycle, 193 _1Cycle,
188 _2Cycle, 194 _2Cycle,
@@ -212,6 +218,7 @@ impl Into<u8> for ChipSelectHighTime {
212/// FIFO threshold. 218/// FIFO threshold.
213#[allow(missing_docs)] 219#[allow(missing_docs)]
214#[derive(Copy, Clone)] 220#[derive(Copy, Clone)]
221#[cfg_attr(feature = "defmt", derive(defmt::Format))]
215pub enum FIFOThresholdLevel { 222pub enum FIFOThresholdLevel {
216 _1Bytes, 223 _1Bytes,
217 _2Bytes, 224 _2Bytes,
@@ -289,6 +296,7 @@ impl Into<u8> for FIFOThresholdLevel {
289/// Dummy cycle count 296/// Dummy cycle count
290#[allow(missing_docs)] 297#[allow(missing_docs)]
291#[derive(Copy, Clone)] 298#[derive(Copy, Clone)]
299#[cfg_attr(feature = "defmt", derive(defmt::Format))]
292pub enum DummyCycles { 300pub enum DummyCycles {
293 _0, 301 _0,
294 _1, 302 _1,
diff --git a/embassy-stm32/src/xspi/mod.rs b/embassy-stm32/src/xspi/mod.rs
index 5ae074a90..901569f64 100644
--- a/embassy-stm32/src/xspi/mod.rs
+++ b/embassy-stm32/src/xspi/mod.rs
@@ -23,6 +23,7 @@ use crate::{peripherals, Peri};
23 23
24/// XPSI driver config. 24/// XPSI driver config.
25#[derive(Clone, Copy)] 25#[derive(Clone, Copy)]
26#[cfg_attr(feature = "defmt", derive(defmt::Format))]
26pub struct Config { 27pub struct Config {
27 /// Fifo threshold used by the peripheral to generate the interrupt indicating data 28 /// Fifo threshold used by the peripheral to generate the interrupt indicating data
28 /// or space is available in the FIFO 29 /// or space is available in the FIFO
@@ -80,6 +81,8 @@ impl Default for Config {
80} 81}
81 82
82/// XSPI transfer configuration. 83/// XSPI transfer configuration.
84#[derive(Clone, Copy)]
85#[cfg_attr(feature = "defmt", derive(defmt::Format))]
83pub struct TransferConfig { 86pub struct TransferConfig {
84 /// Instruction width (IMODE) 87 /// Instruction width (IMODE)
85 pub iwidth: XspiWidth, 88 pub iwidth: XspiWidth,