Commit 7352b4d
committed
shared/tinyusb,extmod/machine_usb_device: Simplify class state to flags.
Replace mp_usbd_class_state_t boolean fields (cdc_enabled, msc_enabled)
with single uint8_t flags field to eliminate redundant state storage.
Changes:
- Use MP_USBD_CDC_ENABLED() and MP_USBD_MSC_ENABLED() macros for checks
- Remove mp_usbd_update_class_state() and mp_usbd_class_state_to_flags()
- Store and access flags directly in mp_usbd_class_state.flags
- Add compile-time guards (#if CFG_TUD_CDC) in descriptor length calc
Code size impact (NUCLEO_H563ZI):
- Runtime mode: +24 bytes
- Static mode: +16 bytes
The slight size increase is due to macro expansion overhead, but the
code is simpler with single source of truth for enabled class state.
Signed-off-by: Andrew Leech <[email protected]>1 parent 69072b1 commit 7352b4d
4 files changed
+25
-49
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
84 | 84 | | |
85 | 85 | | |
86 | 86 | | |
| 87 | + | |
87 | 88 | | |
88 | 89 | | |
89 | | - | |
90 | | - | |
91 | | - | |
92 | | - | |
93 | | - | |
94 | | - | |
95 | | - | |
96 | | - | |
97 | | - | |
| 90 | + | |
98 | 91 | | |
99 | 92 | | |
100 | 93 | | |
101 | 94 | | |
102 | | - | |
103 | | - | |
104 | | - | |
105 | | - | |
106 | | - | |
107 | | - | |
108 | | - | |
109 | | - | |
110 | | - | |
| 95 | + | |
111 | 96 | | |
112 | 97 | | |
113 | 98 | | |
| |||
546 | 531 | | |
547 | 532 | | |
548 | 533 | | |
549 | | - | |
| 534 | + | |
550 | 535 | | |
551 | 536 | | |
552 | 537 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
58 | 58 | | |
59 | 59 | | |
60 | 60 | | |
61 | | - | |
62 | | - | |
| 61 | + | |
63 | 62 | | |
64 | 63 | | |
65 | 64 | | |
| |||
103 | 102 | | |
104 | 103 | | |
105 | 104 | | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
106 | 109 | | |
107 | 110 | | |
108 | 111 | | |
109 | 112 | | |
110 | | - | |
111 | | - | |
| 113 | + | |
112 | 114 | | |
113 | 115 | | |
114 | | - | |
115 | | - | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
116 | 119 | | |
117 | 120 | | |
118 | 121 | | |
119 | | - | |
120 | | - | |
121 | | - | |
122 | | - | |
123 | | - | |
124 | | - | |
125 | 122 | | |
126 | 123 | | |
127 | 124 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
108 | 108 | | |
109 | 109 | | |
110 | 110 | | |
111 | | - | |
| 111 | + | |
| 112 | + | |
112 | 113 | | |
| 114 | + | |
113 | 115 | | |
114 | 116 | | |
115 | 117 | | |
| |||
165 | 167 | | |
166 | 168 | | |
167 | 169 | | |
168 | | - | |
| 170 | + | |
| 171 | + | |
169 | 172 | | |
170 | 173 | | |
171 | | - | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
172 | 177 | | |
173 | 178 | | |
| 179 | + | |
174 | 180 | | |
175 | 181 | | |
176 | 182 | | |
| |||
196 | 202 | | |
197 | 203 | | |
198 | 204 | | |
199 | | - | |
200 | | - | |
201 | | - | |
202 | | - | |
203 | | - | |
204 | | - | |
205 | | - | |
206 | | - | |
207 | | - | |
208 | | - | |
209 | | - | |
210 | | - | |
211 | 205 | | |
212 | 206 | | |
213 | | - | |
214 | | - | |
| 207 | + | |
215 | 208 | | |
216 | 209 | | |
217 | 210 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
125 | 125 | | |
126 | 126 | | |
127 | 127 | | |
128 | | - | |
| 128 | + | |
| 129 | + | |
129 | 130 | | |
130 | 131 | | |
131 | 132 | | |
| |||
0 commit comments