|
36 | 36 | #include "stm32f0xx.h" |
37 | 37 | #define FSDEV_PMA_SIZE (1024u) |
38 | 38 | #define FSDEV_REG_BASE USB_BASE |
| 39 | + #define FSDEV_HAS_SBUF_ISO 0 |
39 | 40 | // F0x2 models are crystal-less |
40 | 41 | // All have internal D+ pull-up |
41 | 42 | // 070RB: 2 x 16 bits/word memory LPM Support, BCD Support |
|
44 | 45 | #elif CFG_TUSB_MCU == OPT_MCU_STM32F1 |
45 | 46 | #include "stm32f1xx.h" |
46 | 47 | #define FSDEV_PMA_SIZE (512u) |
| 48 | + #define FSDEV_HAS_SBUF_ISO 0 |
47 | 49 | // NO internal Pull-ups |
48 | 50 | // *B, and *C: 2 x 16 bits/word |
49 | 51 |
|
|
55 | 57 | defined(STM32F373xC) |
56 | 58 | #include "stm32f3xx.h" |
57 | 59 | #define FSDEV_PMA_SIZE (512u) |
| 60 | + #define FSDEV_HAS_SBUF_ISO 0 |
58 | 61 | // NO internal Pull-ups |
59 | 62 | // *B, and *C: 1 x 16 bits/word |
60 | 63 | // PMA dedicated to USB (no sharing with CAN) |
|
64 | 67 | defined(STM32F303xD) || defined(STM32F303xE) |
65 | 68 | #include "stm32f3xx.h" |
66 | 69 | #define FSDEV_PMA_SIZE (1024u) |
| 70 | + #define FSDEV_HAS_SBUF_ISO 0 |
67 | 71 | // NO internal Pull-ups |
68 | 72 | // *6, *8, *D, and *E: 2 x 16 bits/word LPM Support |
69 | 73 | // When CAN clock is enabled, USB can use first 768 bytes ONLY. |
70 | 74 |
|
71 | 75 | #elif CFG_TUSB_MCU == OPT_MCU_STM32L0 |
72 | 76 | #include "stm32l0xx.h" |
73 | 77 | #define FSDEV_PMA_SIZE (1024u) |
| 78 | + #define FSDEV_HAS_SBUF_ISO 0 |
74 | 79 |
|
75 | 80 | #elif CFG_TUSB_MCU == OPT_MCU_STM32L1 |
76 | 81 | #include "stm32l1xx.h" |
77 | 82 | #define FSDEV_PMA_SIZE (512u) |
| 83 | + #define FSDEV_HAS_SBUF_ISO 0 |
78 | 84 |
|
79 | 85 | #elif CFG_TUSB_MCU == OPT_MCU_STM32G4 |
80 | 86 | #include "stm32g4xx.h" |
81 | 87 | #define FSDEV_PMA_SIZE (1024u) |
| 88 | + #define FSDEV_HAS_SBUF_ISO 0 |
82 | 89 |
|
83 | 90 | #elif CFG_TUSB_MCU == OPT_MCU_STM32G0 |
84 | 91 | #include "stm32g0xx.h" |
85 | 92 | #define FSDEV_PMA_SIZE (2048u) |
| 93 | + #define FSDEV_HAS_SBUF_ISO 1 |
86 | 94 | #define USB USB_DRD_FS |
87 | 95 |
|
88 | 96 | #define USB_EP_CTR_RX USB_EP_VTRX |
|
107 | 115 | #elif CFG_TUSB_MCU == OPT_MCU_STM32C0 |
108 | 116 | #include "stm32c0xx.h" |
109 | 117 | #define FSDEV_PMA_SIZE (2048u) |
| 118 | + #define FSDEV_HAS_SBUF_ISO 1 |
110 | 119 | #define USB USB_DRD_FS |
111 | 120 | #define USB_EP_CTR_RX USB_CHEP_VTRX |
112 | 121 | #define USB_EP_CTR_TX USB_CHEP_VTTX |
|
121 | 130 | #elif CFG_TUSB_MCU == OPT_MCU_STM32H5 |
122 | 131 | #include "stm32h5xx.h" |
123 | 132 | #define FSDEV_PMA_SIZE (2048u) |
| 133 | + #define FSDEV_HAS_SBUF_ISO 1 |
124 | 134 | #define USB USB_DRD_FS |
125 | 135 |
|
126 | 136 | #define USB_EP_CTR_RX USB_EP_VTRX |
|
145 | 155 | #elif CFG_TUSB_MCU == OPT_MCU_STM32WB |
146 | 156 | #include "stm32wbxx.h" |
147 | 157 | #define FSDEV_PMA_SIZE (1024u) |
| 158 | + #define FSDEV_HAS_SBUF_ISO 0 |
148 | 159 | /* ST provided header has incorrect value of USB_PMAADDR */ |
149 | 160 | #define FSDEV_PMA_BASE USB1_PMAADDR |
150 | 161 |
|
151 | 162 | #elif CFG_TUSB_MCU == OPT_MCU_STM32L4 |
152 | 163 | #include "stm32l4xx.h" |
153 | 164 | #define FSDEV_PMA_SIZE (1024u) |
| 165 | + #define FSDEV_HAS_SBUF_ISO 0 |
154 | 166 |
|
155 | 167 | #elif CFG_TUSB_MCU == OPT_MCU_STM32L5 |
156 | 168 | #include "stm32l5xx.h" |
157 | 169 | #define FSDEV_PMA_SIZE (1024u) |
| 170 | + #define FSDEV_HAS_SBUF_ISO 0 |
158 | 171 |
|
159 | 172 | #ifndef USB_PMAADDR |
160 | 173 | #define USB_PMAADDR (USB_BASE + (USB_PMAADDR_NS - USB_BASE_NS)) |
|
163 | 176 | #elif CFG_TUSB_MCU == OPT_MCU_STM32U5 |
164 | 177 | #include "stm32u5xx.h" |
165 | 178 | #define FSDEV_PMA_SIZE (2048u) |
| 179 | + #define FSDEV_HAS_SBUF_ISO 1 |
166 | 180 | #define USB USB_DRD_FS |
167 | 181 |
|
168 | 182 | #define USB_EP_CTR_RX USB_EP_VTRX |
|
187 | 201 | #elif CFG_TUSB_MCU == OPT_MCU_STM32U0 |
188 | 202 | #include "stm32u0xx.h" |
189 | 203 | #define FSDEV_PMA_SIZE (2048u) |
| 204 | + #define FSDEV_HAS_SBUF_ISO 1 |
190 | 205 | #define USB USB_DRD_FS |
191 | 206 |
|
192 | 207 | #define USB_EP_CTR_RX USB_EP_VTRX |
|
248 | 263 | #define USB_ISTR_ALL_EVENTS (USB_ISTR_PMAOVR | USB_ISTR_ERR | USB_ISTR_WKUP | USB_ISTR_SUSP | \ |
249 | 264 | USB_ISTR_RESET | USB_ISTR_SOF | USB_ISTR_ESOF | USB_ISTR_L1REQ_FORCED ) |
250 | 265 |
|
| 266 | +#ifndef FSDEV_HAS_SBUF_ISO |
| 267 | + #error "FSDEV_HAS_SBUF_ISO not defined" |
| 268 | +#endif |
| 269 | + |
| 270 | +#ifndef CFG_TUD_FSDEV_DOUBLE_BUFFERED_ISO_EP |
| 271 | + // Default configuration for double-buffered isochronous endpoints: |
| 272 | + // - Enable double buffering on devices with >1KB Packet Memory Area (PMA) |
| 273 | + // to improve isochronous transfer reliability and performance |
| 274 | + // - Disable on devices with limited PMA to conserve memory space |
| 275 | + #if FSDEV_PMA_SIZE > 1024u |
| 276 | + #define CFG_TUD_FSDEV_DOUBLE_BUFFERED_ISO_EP 1 |
| 277 | + #else |
| 278 | + #define CFG_TUD_FSDEV_DOUBLE_BUFFERED_ISO_EP 0 |
| 279 | + #endif |
| 280 | +#endif |
| 281 | + |
| 282 | +#if FSDEV_HAS_SBUF_ISO != 0 && CFG_TUD_FSDEV_DOUBLE_BUFFERED_ISO_EP == 0 |
| 283 | + // SBUF_ISO configuration: |
| 284 | + // - Some STM32 devices have special hardware support for single-buffered isochronous endpoints |
| 285 | + // - When SBUF_ISO bit is available and double buffering is disabled: |
| 286 | + // Enable SBUF_ISO to optimize endpoint register usage (one half of endpoint pair register) |
| 287 | + #define FSDEV_USE_SBUF_ISO 1 |
| 288 | +#else |
| 289 | + // When either: |
| 290 | + // - Hardware doesn't support SBUF_ISO feature, or |
| 291 | + // - Double buffering is enabled for isochronous endpoints |
| 292 | + // We must use the entire endpoint pair register |
| 293 | + #define FSDEV_USE_SBUF_ISO 0 |
| 294 | +#endif |
| 295 | + |
251 | 296 | //--------------------------------------------------------------------+ |
252 | 297 | // |
253 | 298 | //--------------------------------------------------------------------+ |
|
0 commit comments