|
24 | 24 | * This file is part of the TinyUSB stack.
|
25 | 25 | */
|
26 | 26 |
|
27 |
| -#ifndef TUSB_MCU_ATTR_H_ |
28 |
| -#define TUSB_MCU_ATTR_H_ |
| 27 | +#ifndef TUSB_MCU_H_ |
| 28 | +#define TUSB_MCU_H_ |
| 29 | + |
| 30 | +//--------------------------------------------------------------------+ |
| 31 | +// Port Specific |
| 32 | +// TUP stand for TinyUSB Port (can be renamed) |
| 33 | +//--------------------------------------------------------------------+ |
| 34 | + |
| 35 | +//------------- Unaligned Memory Access -------------// |
| 36 | + |
| 37 | +// ARMv7+ (M3-M7, M23-M33) can access unaligned memory |
| 38 | +#if (defined(__ARM_ARCH) && (__ARM_ARCH >= 7)) |
| 39 | + #define TUP_ARCH_STRICT_ALIGN 0 |
| 40 | +#else |
| 41 | + #define TUP_ARCH_STRICT_ALIGN 1 |
| 42 | +#endif |
29 | 43 |
|
30 | 44 | /* USB Controller Attributes for Device, Host or MCU (both)
|
31 | 45 | * - ENDPOINT_MAX: max (logical) number of endpoint
|
|
37 | 51 |
|
38 | 52 | //------------- NXP -------------//
|
39 | 53 | #if TU_CHECK_MCU(OPT_MCU_LPC11UXX, OPT_MCU_LPC13XX, OPT_MCU_LPC15XX)
|
40 |
| - #define DCD_ATTR_ENDPOINT_MAX 5 |
| 54 | + #define TUP_DCD_ENDPOINT_MAX 5 |
41 | 55 |
|
42 | 56 | #elif TU_CHECK_MCU(OPT_MCU_LPC175X_6X, OPT_MCU_LPC177X_8X, OPT_MCU_LPC40XX)
|
43 |
| - #define DCD_ATTR_ENDPOINT_MAX 16 |
44 |
| - #define HCD_ATTR_OHCI |
| 57 | + #define TUP_DCD_ENDPOINT_MAX 16 |
| 58 | + #define TUP_USBIP_OHCI |
45 | 59 |
|
46 | 60 | #elif TU_CHECK_MCU(OPT_MCU_LPC18XX, OPT_MCU_LPC43XX)
|
47 | 61 | // TODO USB0 has 6, USB1 has 4
|
48 |
| - #define MCU_ATTR_CONTROLLER_CHIPIDEA_HS |
49 |
| - #define DCD_ATTR_ENDPOINT_MAX 6 |
50 |
| - #define DCD_ATTR_RHPORT_HIGHSPEED 0x01 // Port0 HS, Port1 FS |
| 62 | + #define TUP_USBIP_CHIPIDEA_HS |
| 63 | + #define TUP_USBIP_EHCI |
| 64 | + |
| 65 | + #define TUP_DCD_ENDPOINT_MAX 6 |
| 66 | + #define TUP_RHPORT_HIGHSPEED 0x01 // Port0 HS, Port1 FS |
51 | 67 |
|
52 |
| - #define HCD_ATTR_EHCI |
53 | 68 |
|
54 | 69 | #elif TU_CHECK_MCU(OPT_MCU_LPC51UXX)
|
55 |
| - #define DCD_ATTR_ENDPOINT_MAX 5 |
| 70 | + #define TUP_DCD_ENDPOINT_MAX 5 |
56 | 71 |
|
57 | 72 | #elif TU_CHECK_MCU(OPT_MCU_LPC54XXX)
|
58 | 73 | // TODO USB0 has 5, USB1 has 6
|
59 |
| - #define DCD_ATTR_ENDPOINT_MAX 6 |
| 74 | + #define TUP_DCD_ENDPOINT_MAX 6 |
60 | 75 |
|
61 | 76 | #elif TU_CHECK_MCU(OPT_MCU_LPC55XX)
|
62 | 77 | // TODO USB0 has 5, USB1 has 6
|
63 |
| - #define DCD_ATTR_ENDPOINT_MAX 6 |
| 78 | + #define TUP_DCD_ENDPOINT_MAX 6 |
64 | 79 |
|
65 | 80 | #elif TU_CHECK_MCU(OPT_MCU_MIMXRT10XX)
|
66 |
| - #define MCU_ATTR_CONTROLLER_CHIPIDEA_HS |
67 |
| - #define DCD_ATTR_ENDPOINT_MAX 8 |
68 |
| - #define DCD_ATTR_RHPORT_HIGHSPEED 0x03 // Port0 HS, Port1 HS |
| 81 | + #define TUP_USBIP_CHIPIDEA_HS |
| 82 | + #define TUP_USBIP_EHCI |
| 83 | + |
| 84 | + #define TUP_DCD_ENDPOINT_MAX 8 |
| 85 | + #define TUP_RHPORT_HIGHSPEED 0x03 // Port0 HS, Port1 HS |
69 | 86 |
|
70 |
| - #define HCD_ATTR_EHCI |
71 | 87 |
|
72 | 88 | #elif TU_CHECK_MCU(OPT_MCU_MKL25ZXX, OPT_MCU_K32L2BXX)
|
73 |
| - #define DCD_ATTR_ENDPOINT_MAX 16 |
| 89 | + #define TUP_DCD_ENDPOINT_MAX 16 |
74 | 90 |
|
75 | 91 | #elif TU_CHECK_MCU(OPT_MCU_MM32F327X)
|
76 |
| - #define DCD_ATTR_ENDPOINT_MAX 16 |
| 92 | + #define TUP_DCD_ENDPOINT_MAX 16 |
77 | 93 |
|
78 | 94 | //------------- Nordic -------------//
|
79 | 95 | #elif TU_CHECK_MCU(OPT_MCU_NRF5X)
|
80 | 96 | // 8 CBI + 1 ISO
|
81 |
| - #define DCD_ATTR_ENDPOINT_MAX 9 |
| 97 | + #define TUP_DCD_ENDPOINT_MAX 9 |
82 | 98 |
|
83 | 99 | //------------- Microchip -------------//
|
84 | 100 | #elif TU_CHECK_MCU(OPT_MCU_SAMD21, OPT_MCU_SAMD51, OPT_MCU_SAME5X) || \
|
85 | 101 | TU_CHECK_MCU(OPT_MCU_SAMD11, OPT_MCU_SAML21, OPT_MCU_SAML22)
|
86 |
| - #define DCD_ATTR_ENDPOINT_MAX 8 |
| 102 | + #define TUP_DCD_ENDPOINT_MAX 8 |
87 | 103 |
|
88 | 104 | #elif TU_CHECK_MCU(OPT_MCU_SAMG)
|
89 |
| - #define DCD_ATTR_ENDPOINT_MAX 6 |
90 |
| - #define DCD_ATTR_ENDPOINT_EXCLUSIVE_NUMBER |
| 105 | + #define TUP_DCD_ENDPOINT_MAX 6 |
| 106 | + #define TUP_DCD_ENDPOINT_EXCLUSIVE_NUMBER |
91 | 107 |
|
92 | 108 | #elif TU_CHECK_MCU(OPT_MCU_SAMX7X)
|
93 |
| - #define DCD_ATTR_ENDPOINT_MAX 10 |
94 |
| - #define DCD_ATTR_RHPORT_HIGHSPEED 0x01 |
95 |
| - #define DCD_ATTR_ENDPOINT_EXCLUSIVE_NUMBER |
| 109 | + #define TUP_DCD_ENDPOINT_MAX 10 |
| 110 | + #define TUP_RHPORT_HIGHSPEED 0x01 |
| 111 | + #define TUP_DCD_ENDPOINT_EXCLUSIVE_NUMBER |
96 | 112 |
|
97 | 113 | #elif TU_CHECK_MCU(OPT_MCU_PIC32MZ)
|
98 |
| - #define DCD_ATTR_ENDPOINT_MAX 8 |
99 |
| - #define DCD_ATTR_ENDPOINT_EXCLUSIVE_NUMBER |
| 114 | + #define TUP_DCD_ENDPOINT_MAX 8 |
| 115 | + #define TUP_DCD_ENDPOINT_EXCLUSIVE_NUMBER |
100 | 116 |
|
101 | 117 | //------------- ST -------------//
|
102 | 118 | #elif TU_CHECK_MCU(OPT_MCU_STM32F0)
|
103 |
| - #define DCD_ATTR_ENDPOINT_MAX 8 |
| 119 | + #define TUP_DCD_ENDPOINT_MAX 8 |
104 | 120 |
|
105 | 121 | #elif TU_CHECK_MCU(OPT_MCU_STM32F1)
|
106 | 122 | #if defined (STM32F105x8) || defined (STM32F105xB) || defined (STM32F105xC) || \
|
107 | 123 | defined (STM32F107xB) || defined (STM32F107xC)
|
108 |
| - #define DCD_ATTR_ENDPOINT_MAX 4 |
109 |
| - #define DCD_ATTR_DWC2_STM32 |
| 124 | + #define TUP_USBIP_DWC2 |
| 125 | + #define TUP_USBIP_DWC2_STM32 |
| 126 | + |
| 127 | + #define TUP_DCD_ENDPOINT_MAX 4 |
110 | 128 | #else
|
111 |
| - #define DCD_ATTR_ENDPOINT_MAX 8 |
| 129 | + #define TUP_DCD_ENDPOINT_MAX 8 |
112 | 130 | #endif
|
113 | 131 |
|
114 | 132 | #elif TU_CHECK_MCU(OPT_MCU_STM32F2)
|
| 133 | + #define TUP_USBIP_DWC2 |
| 134 | + #define TUP_USBIP_DWC2_STM32 |
| 135 | + |
115 | 136 | // FS has 4 ep, HS has 5 ep
|
116 |
| - #define DCD_ATTR_ENDPOINT_MAX 6 |
117 |
| - #define DCD_ATTR_DWC2_STM32 |
| 137 | + #define TUP_DCD_ENDPOINT_MAX 6 |
118 | 138 |
|
119 | 139 | #elif TU_CHECK_MCU(OPT_MCU_STM32F3)
|
120 |
| - #define DCD_ATTR_ENDPOINT_MAX 8 |
| 140 | + #define TUP_DCD_ENDPOINT_MAX 8 |
121 | 141 |
|
122 | 142 | #elif TU_CHECK_MCU(OPT_MCU_STM32F4)
|
| 143 | + #define TUP_USBIP_DWC2 |
| 144 | + #define TUP_USBIP_DWC2_STM32 |
| 145 | + |
123 | 146 | // For most mcu, FS has 4, HS has 6. TODO 446/469/479 HS has 9
|
124 |
| - #define DCD_ATTR_ENDPOINT_MAX 6 |
125 |
| - #define DCD_ATTR_DWC2_STM32 |
| 147 | + #define TUP_DCD_ENDPOINT_MAX 6 |
126 | 148 |
|
127 | 149 | #elif TU_CHECK_MCU(OPT_MCU_STM32F7)
|
| 150 | + #define TUP_USBIP_DWC2 |
| 151 | + #define TUP_USBIP_DWC2_STM32 |
| 152 | + |
128 | 153 | // FS has 6, HS has 9
|
129 |
| - #define DCD_ATTR_ENDPOINT_MAX 9 |
130 |
| - #define DCD_ATTR_DWC2_STM32 |
| 154 | + #define TUP_DCD_ENDPOINT_MAX 9 |
| 155 | + |
| 156 | + // MCU with on-chip HS Phy |
| 157 | + #if defined(STM32F723xx) || defined(STM32F730xx) || defined(STM32F733xx) |
| 158 | + #define TUP_RHPORT_HIGHSPEED 0x02 // Port 0: FS, Port 1: HS |
| 159 | + #endif |
131 | 160 |
|
132 | 161 | #elif TU_CHECK_MCU(OPT_MCU_STM32H7)
|
133 |
| - #define DCD_ATTR_ENDPOINT_MAX 9 |
134 |
| - #define DCD_ATTR_DWC2_STM32 |
| 162 | + #define TUP_USBIP_DWC2 |
| 163 | + #define TUP_USBIP_DWC2_STM32 |
| 164 | + |
| 165 | + #define TUP_DCD_ENDPOINT_MAX 9 |
135 | 166 |
|
136 | 167 | #elif TU_CHECK_MCU(OPT_MCU_STM32G4)
|
137 |
| - #define DCD_ATTR_ENDPOINT_MAX 8 |
| 168 | + #define TUP_DCD_ENDPOINT_MAX 8 |
138 | 169 |
|
139 | 170 | #elif TU_CHECK_MCU(OPT_MCU_STM32L0, OPT_MCU_STM32L1)
|
140 |
| - #define DCD_ATTR_ENDPOINT_MAX 8 |
| 171 | + #define TUP_DCD_ENDPOINT_MAX 8 |
141 | 172 |
|
142 | 173 | #elif TU_CHECK_MCU(OPT_MCU_STM32L4)
|
143 | 174 | #if defined (STM32L475xx) || defined (STM32L476xx) || \
|
144 | 175 | defined (STM32L485xx) || defined (STM32L486xx) || defined (STM32L496xx) || \
|
145 | 176 | defined (STM32L4A6xx) || defined (STM32L4P5xx) || defined (STM32L4Q5xx) || \
|
146 | 177 | defined (STM32L4R5xx) || defined (STM32L4R7xx) || defined (STM32L4R9xx) || \
|
147 | 178 | defined (STM32L4S5xx) || defined (STM32L4S7xx) || defined (STM32L4S9xx)
|
148 |
| - #define DCD_ATTR_ENDPOINT_MAX 6 |
149 |
| - #define DCD_ATTR_DWC2_STM32 |
| 179 | + #define TUP_USBIP_DWC2 |
| 180 | + #define TUP_USBIP_DWC2_STM32 |
| 181 | + |
| 182 | + #define TUP_DCD_ENDPOINT_MAX 6 |
150 | 183 | #else
|
151 |
| - #define DCD_ATTR_ENDPOINT_MAX 8 |
| 184 | + #define TUP_DCD_ENDPOINT_MAX 8 |
152 | 185 | #endif
|
153 | 186 |
|
154 | 187 | //------------- Sony -------------//
|
155 | 188 | #elif TU_CHECK_MCU(OPT_MCU_CXD56)
|
156 |
| - #define DCD_ATTR_ENDPOINT_MAX 7 |
157 |
| - #define DCD_ATTR_RHPORT_HIGHSPEED 0x01 |
158 |
| - #define DCD_ATTR_ENDPOINT_EXCLUSIVE_NUMBER |
| 189 | + #define TUP_DCD_ENDPOINT_MAX 7 |
| 190 | + #define TUP_RHPORT_HIGHSPEED 0x01 |
| 191 | + #define TUP_DCD_ENDPOINT_EXCLUSIVE_NUMBER |
159 | 192 |
|
160 | 193 | //------------- TI -------------//
|
161 | 194 | #elif TU_CHECK_MCU(OPT_MCU_MSP430x5xx)
|
162 |
| - #define DCD_ATTR_ENDPOINT_MAX 8 |
| 195 | + #define TUP_DCD_ENDPOINT_MAX 8 |
163 | 196 |
|
164 | 197 | #elif TU_CHECK_MCU(OPT_MCU_MSP432E4, OPT_MCU_TM4C123, OPT_MCU_TM4C129)
|
165 |
| - #define DCD_ATTR_ENDPOINT_MAX 8 |
| 198 | + #define TUP_DCD_ENDPOINT_MAX 8 |
166 | 199 |
|
167 | 200 | //------------- ValentyUSB -------------//
|
168 | 201 | #elif TU_CHECK_MCU(OPT_MCU_VALENTYUSB_EPTRI)
|
169 |
| - #define DCD_ATTR_ENDPOINT_MAX 16 |
| 202 | + #define TUP_DCD_ENDPOINT_MAX 16 |
170 | 203 |
|
171 | 204 | //------------- Nuvoton -------------//
|
172 | 205 | #elif TU_CHECK_MCU(OPT_MCU_NUC121, OPT_MCU_NUC126)
|
173 |
| - #define DCD_ATTR_ENDPOINT_MAX 8 |
| 206 | + #define TUP_DCD_ENDPOINT_MAX 8 |
174 | 207 |
|
175 | 208 | #elif TU_CHECK_MCU(OPT_MCU_NUC120)
|
176 |
| - #define DCD_ATTR_ENDPOINT_MAX 6 |
| 209 | + #define TUP_DCD_ENDPOINT_MAX 6 |
177 | 210 |
|
178 | 211 | #elif TU_CHECK_MCU(OPT_MCU_NUC505)
|
179 |
| - #define DCD_ATTR_ENDPOINT_MAX 12 |
180 |
| - #define DCD_ATTR_RHPORT_HIGHSPEED 0x01 |
| 212 | + #define TUP_DCD_ENDPOINT_MAX 12 |
| 213 | + #define TUP_RHPORT_HIGHSPEED 0x01 |
181 | 214 |
|
182 | 215 | //------------- Espressif -------------//
|
183 | 216 | #elif TU_CHECK_MCU(OPT_MCU_ESP32S2, OPT_MCU_ESP32S3)
|
184 |
| - #define DCD_ATTR_ENDPOINT_MAX 6 |
| 217 | + #define TUP_USBIP_DWC2 |
| 218 | + #define TUP_DCD_ENDPOINT_MAX 6 |
185 | 219 |
|
186 | 220 | //------------- Dialog -------------//
|
187 | 221 | #elif TU_CHECK_MCU(OPT_MCU_DA1469X)
|
188 |
| - #define DCD_ATTR_ENDPOINT_MAX 4 |
| 222 | + #define TUP_DCD_ENDPOINT_MAX 4 |
189 | 223 |
|
190 | 224 | //------------- Raspberry Pi -------------//
|
191 | 225 | #elif TU_CHECK_MCU(OPT_MCU_RP2040)
|
192 |
| - #define DCD_ATTR_ENDPOINT_MAX 16 |
| 226 | + #define TUP_DCD_ENDPOINT_MAX 16 |
193 | 227 |
|
194 | 228 | //------------- Silabs -------------//
|
195 | 229 | #elif TU_CHECK_MCU(OPT_MCU_EFM32GG)
|
196 |
| - #define DCD_ATTR_ENDPOINT_MAX 7 |
| 230 | + #define TUP_USBIP_DWC2 |
| 231 | + #define TUP_DCD_ENDPOINT_MAX 7 |
197 | 232 |
|
198 | 233 | //------------- Renesas -------------//
|
199 | 234 | #elif TU_CHECK_MCU(OPT_MCU_RX63X, OPT_MCU_RX65X, OPT_MCU_RX72N)
|
200 |
| - #define DCD_ATTR_ENDPOINT_MAX 10 |
| 235 | + #define TUP_DCD_ENDPOINT_MAX 10 |
201 | 236 |
|
202 | 237 | //------------- GigaDevice -------------//
|
203 | 238 | #elif TU_CHECK_MCU(OPT_MCU_GD32VF103)
|
204 |
| - #define DCD_ATTR_ENDPOINT_MAX 4 |
| 239 | + #define TUP_USBIP_DWC2 |
| 240 | + #define TUP_DCD_ENDPOINT_MAX 4 |
205 | 241 |
|
206 | 242 | //------------- Broadcom -------------//
|
207 | 243 | #elif TU_CHECK_MCU(OPT_MCU_BCM2711, OPT_MCU_BCM2835, OPT_MCU_BCM2837)
|
208 |
| - #define DCD_ATTR_ENDPOINT_MAX 8 |
209 |
| - #define DCD_ATTR_RHPORT_HIGHSPEED 0x01 |
| 244 | + #define TUP_USBIP_DWC2 |
| 245 | + #define TUP_DCD_ENDPOINT_MAX 8 |
| 246 | + #define TUP_RHPORT_HIGHSPEED 0x01 |
210 | 247 |
|
211 | 248 | //------------- Broadcom -------------//
|
212 | 249 | #elif TU_CHECK_MCU(OPT_MCU_XMC4000)
|
213 |
| - #define DCD_ATTR_ENDPOINT_MAX 8 |
| 250 | + #define TUP_USBIP_DWC2 |
| 251 | + #define TUP_DCD_ENDPOINT_MAX 8 |
214 | 252 |
|
215 | 253 | //------------- BridgeTek -------------//
|
216 | 254 | #elif TU_CHECK_MCU(OPT_MCU_FT90X)
|
217 |
| - #define DCD_ATTR_ENDPOINT_MAX 8 |
218 |
| - #define DCD_ATTR_RHPORT_HIGHSPEED 0x01 |
| 255 | + #define TUP_DCD_ENDPOINT_MAX 8 |
| 256 | + #define TUP_RHPORT_HIGHSPEED 0x01 |
219 | 257 |
|
220 | 258 | #elif TU_CHECK_MCU(OPT_MCU_FT93X)
|
221 |
| - #define DCD_ATTR_ENDPOINT_MAX 16 |
222 |
| - #define DCD_ATTR_RHPORT_HIGHSPEED 0x01 |
| 259 | + #define TUP_DCD_ENDPOINT_MAX 16 |
| 260 | + #define TUP_RHPORT_HIGHSPEED 0x01 |
223 | 261 |
|
224 | 262 | //------------ Allwinner -------------//
|
225 | 263 | #elif TU_CHECK_MCU(OPT_MCU_F1C100S)
|
226 |
| - #define DCD_ATTR_ENDPOINT_MAX 4 |
| 264 | + #define TUP_DCD_ENDPOINT_MAX 4 |
227 | 265 |
|
228 | 266 | #endif
|
229 | 267 |
|
230 | 268 | //--------------------------------------------------------------------+
|
231 | 269 | // Default Values
|
232 | 270 | //--------------------------------------------------------------------+
|
233 | 271 |
|
234 |
| -#ifndef DCD_ATTR_ENDPOINT_MAX |
235 |
| - #warning "DCD_ATTR_ENDPOINT_MAX is not defined for this MCU, default to 8" |
236 |
| - #define DCD_ATTR_ENDPOINT_MAX 8 |
| 272 | +#ifndef TUP_DCD_ENDPOINT_MAX |
| 273 | + #warning "TUP_DCD_ENDPOINT_MAX is not defined for this MCU, default to 8" |
| 274 | + #define TUP_DCD_ENDPOINT_MAX 8 |
237 | 275 | #endif
|
238 | 276 |
|
239 | 277 | // Default to fullspeed if not defined
|
240 |
| -#ifndef DCD_ATTR_RHPORT_HIGHSPEED |
241 |
| - #define DCD_ATTR_RHPORT_HIGHSPEED 0x00 |
| 278 | +#ifndef TUP_RHPORT_HIGHSPEED |
| 279 | + #define TUP_RHPORT_HIGHSPEED 0x00 |
242 | 280 | #endif
|
243 | 281 |
|
244 | 282 | #endif
|
0 commit comments