aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/consts.rs147
1 files changed, 147 insertions, 0 deletions
diff --git a/src/consts.rs b/src/consts.rs
index bee706600..140cb4b6d 100644
--- a/src/consts.rs
+++ b/src/consts.rs
@@ -1,4 +1,5 @@
1#![allow(unused)] 1#![allow(unused)]
2
2pub(crate) const FUNC_BUS: u32 = 0; 3pub(crate) const FUNC_BUS: u32 = 0;
3pub(crate) const FUNC_BACKPLANE: u32 = 1; 4pub(crate) const FUNC_BACKPLANE: u32 = 1;
4pub(crate) const FUNC_WLAN: u32 = 2; 5pub(crate) const FUNC_WLAN: u32 = 2;
@@ -103,3 +104,149 @@ pub(crate) const WRITE: bool = true;
103pub(crate) const READ: bool = false; 104pub(crate) const READ: bool = false;
104pub(crate) const INC_ADDR: bool = true; 105pub(crate) const INC_ADDR: bool = true;
105pub(crate) const FIXED_ADDR: bool = false; 106pub(crate) const FIXED_ADDR: bool = false;
107
108#[allow(dead_code)]
109pub(crate) struct FormatStatus(pub u32);
110
111#[cfg(feature = "defmt")]
112impl defmt::Format for FormatStatus {
113 fn format(&self, fmt: defmt::Formatter) {
114 macro_rules! implm {
115 ($($name:ident),*) => {
116 $(
117 if self.0 & $name > 0 {
118 defmt::write!(fmt, " | {}", &stringify!($name)[7..]);
119 }
120 )*
121 };
122 }
123
124 implm!(
125 STATUS_DATA_NOT_AVAILABLE,
126 STATUS_UNDERFLOW,
127 STATUS_OVERFLOW,
128 STATUS_F2_INTR,
129 STATUS_F3_INTR,
130 STATUS_F2_RX_READY,
131 STATUS_F3_RX_READY,
132 STATUS_HOST_CMD_DATA_ERR,
133 STATUS_F2_PKT_AVAILABLE,
134 STATUS_F3_PKT_AVAILABLE
135 );
136 }
137}
138
139#[cfg(feature = "log")]
140impl core::fmt::Debug for FormatStatus {
141 fn fmt(&self, fmt: &mut core::fmt::Formatter) -> core::fmt::Result {
142 macro_rules! implm {
143 ($($name:ident),*) => {
144 $(
145 if self.0 & $name > 0 {
146 core::write!(fmt, " | {}", &stringify!($name)[7..])?;
147 }
148 )*
149 };
150 }
151
152 implm!(
153 STATUS_DATA_NOT_AVAILABLE,
154 STATUS_UNDERFLOW,
155 STATUS_OVERFLOW,
156 STATUS_F2_INTR,
157 STATUS_F3_INTR,
158 STATUS_F2_RX_READY,
159 STATUS_F3_RX_READY,
160 STATUS_HOST_CMD_DATA_ERR,
161 STATUS_F2_PKT_AVAILABLE,
162 STATUS_F3_PKT_AVAILABLE
163 );
164 Ok(())
165 }
166}
167
168#[cfg(feature = "log")]
169impl core::fmt::Display for FormatStatus {
170 fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
171 core::fmt::Debug::fmt(self, f)
172 }
173}
174
175#[allow(dead_code)]
176pub(crate) struct FormatInterrupt(pub u16);
177
178#[cfg(feature = "defmt")]
179impl defmt::Format for FormatInterrupt {
180 fn format(&self, fmt: defmt::Formatter) {
181 macro_rules! implm {
182 ($($name:ident),*) => {
183 $(
184 if self.0 & $name > 0 {
185 defmt::write!(fmt, " | {}", &stringify!($name)[4..]);
186 }
187 )*
188 };
189 }
190
191 implm!(
192 IRQ_DATA_UNAVAILABLE,
193 IRQ_F2_F3_FIFO_RD_UNDERFLOW,
194 IRQ_F2_F3_FIFO_WR_OVERFLOW,
195 IRQ_COMMAND_ERROR,
196 IRQ_DATA_ERROR,
197 IRQ_F2_PACKET_AVAILABLE,
198 IRQ_F3_PACKET_AVAILABLE,
199 IRQ_F1_OVERFLOW,
200 IRQ_MISC_INTR0,
201 IRQ_MISC_INTR1,
202 IRQ_MISC_INTR2,
203 IRQ_MISC_INTR3,
204 IRQ_MISC_INTR4,
205 IRQ_F1_INTR,
206 IRQ_F2_INTR,
207 IRQ_F3_INTR
208 );
209 }
210}
211
212#[cfg(feature = "log")]
213impl core::fmt::Debug for FormatInterrupt {
214 fn fmt(&self, fmt: &mut core::fmt::Formatter) -> core::fmt::Result {
215 macro_rules! implm {
216 ($($name:ident),*) => {
217 $(
218 if self.0 & $name > 0 {
219 core::write!(fmt, " | {}", &stringify!($name)[7..])?;
220 }
221 )*
222 };
223 }
224
225 implm!(
226 IRQ_DATA_UNAVAILABLE,
227 IRQ_F2_F3_FIFO_RD_UNDERFLOW,
228 IRQ_F2_F3_FIFO_WR_OVERFLOW,
229 IRQ_COMMAND_ERROR,
230 IRQ_DATA_ERROR,
231 IRQ_F2_PACKET_AVAILABLE,
232 IRQ_F3_PACKET_AVAILABLE,
233 IRQ_F1_OVERFLOW,
234 IRQ_MISC_INTR0,
235 IRQ_MISC_INTR1,
236 IRQ_MISC_INTR2,
237 IRQ_MISC_INTR3,
238 IRQ_MISC_INTR4,
239 IRQ_F1_INTR,
240 IRQ_F2_INTR,
241 IRQ_F3_INTR
242 );
243 Ok(())
244 }
245}
246
247#[cfg(feature = "log")]
248impl core::fmt::Display for FormatInterrupt {
249 fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
250 core::fmt::Debug::fmt(self, f)
251 }
252}