Austin Schuh | 41baf20 | 2022-01-01 14:33:40 -0800 | [diff] [blame^] | 1 | /* |
| 2 | * The MIT License (MIT) |
| 3 | * |
| 4 | * Copyright (c) 2019 Ha Thach (tinyusb.org) |
| 5 | * |
| 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy |
| 7 | * of this software and associated documentation files (the "Software"), to deal |
| 8 | * in the Software without restriction, including without limitation the rights |
| 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
| 10 | * copies of the Software, and to permit persons to whom the Software is |
| 11 | * furnished to do so, subject to the following conditions: |
| 12 | * |
| 13 | * The above copyright notice and this permission notice shall be included in |
| 14 | * all copies or substantial portions of the Software. |
| 15 | * |
| 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
| 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
| 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
| 22 | * THE SOFTWARE. |
| 23 | * |
| 24 | * This file is part of the TinyUSB stack. |
| 25 | */ |
| 26 | |
| 27 | #ifndef _TUSB_OPTION_H_ |
| 28 | #define _TUSB_OPTION_H_ |
| 29 | |
| 30 | #include "common/tusb_compiler.h" |
| 31 | |
| 32 | #define TUSB_VERSION_MAJOR 0 |
| 33 | #define TUSB_VERSION_MINOR 12 |
| 34 | #define TUSB_VERSION_REVISION 0 |
| 35 | #define TUSB_VERSION_STRING TU_STRING(TUSB_VERSION_MAJOR) "." TU_STRING(TUSB_VERSION_MINOR) "." TU_STRING(TUSB_VERSION_REVISION) |
| 36 | |
| 37 | //--------------------------------------------------------------------+ |
| 38 | // Supported MCUs |
| 39 | // CFG_TUSB_MCU must be defined to one of following value |
| 40 | //--------------------------------------------------------------------+ |
| 41 | |
| 42 | #define OPT_MCU_NONE 0 |
| 43 | |
| 44 | // LPC |
| 45 | #define OPT_MCU_LPC11UXX 1 ///< NXP LPC11Uxx |
| 46 | #define OPT_MCU_LPC13XX 2 ///< NXP LPC13xx |
| 47 | #define OPT_MCU_LPC15XX 3 ///< NXP LPC15xx |
| 48 | #define OPT_MCU_LPC175X_6X 4 ///< NXP LPC175x, LPC176x |
| 49 | #define OPT_MCU_LPC177X_8X 5 ///< NXP LPC177x, LPC178x |
| 50 | #define OPT_MCU_LPC18XX 6 ///< NXP LPC18xx |
| 51 | #define OPT_MCU_LPC40XX 7 ///< NXP LPC40xx |
| 52 | #define OPT_MCU_LPC43XX 8 ///< NXP LPC43xx |
| 53 | #define OPT_MCU_LPC51UXX 9 ///< NXP LPC51U6x |
| 54 | #define OPT_MCU_LPC54XXX 10 ///< NXP LPC54xxx |
| 55 | #define OPT_MCU_LPC55XX 11 ///< NXP LPC55xx |
| 56 | |
| 57 | // NRF |
| 58 | #define OPT_MCU_NRF5X 100 ///< Nordic nRF5x series |
| 59 | |
| 60 | // SAM |
| 61 | #define OPT_MCU_SAMD21 200 ///< MicroChip SAMD21 |
| 62 | #define OPT_MCU_SAMD51 201 ///< MicroChip SAMD51 |
| 63 | #define OPT_MCU_SAMG 202 ///< MicroChip SAMDG series |
| 64 | #define OPT_MCU_SAME5X 203 ///< MicroChip SAM E5x |
| 65 | #define OPT_MCU_SAMD11 204 ///< MicroChip SAMD11 |
| 66 | #define OPT_MCU_SAML22 205 ///< MicroChip SAML22 |
| 67 | #define OPT_MCU_SAML21 206 ///< MicroChip SAML21 |
| 68 | #define OPT_MCU_SAMX7X 207 ///< MicroChip SAME70, S70, V70, V71 family |
| 69 | |
| 70 | // STM32 |
| 71 | #define OPT_MCU_STM32F0 300 ///< ST F0 |
| 72 | #define OPT_MCU_STM32F1 301 ///< ST F1 |
| 73 | #define OPT_MCU_STM32F2 302 ///< ST F2 |
| 74 | #define OPT_MCU_STM32F3 303 ///< ST F3 |
| 75 | #define OPT_MCU_STM32F4 304 ///< ST F4 |
| 76 | #define OPT_MCU_STM32F7 305 ///< ST F7 |
| 77 | #define OPT_MCU_STM32H7 306 ///< ST H7 |
| 78 | #define OPT_MCU_STM32L1 308 ///< ST L1 |
| 79 | #define OPT_MCU_STM32L0 307 ///< ST L0 |
| 80 | #define OPT_MCU_STM32L4 309 ///< ST L4 |
| 81 | #define OPT_MCU_STM32G0 310 ///< ST G0 |
| 82 | #define OPT_MCU_STM32G4 311 ///< ST G4 |
| 83 | |
| 84 | // Sony |
| 85 | #define OPT_MCU_CXD56 400 ///< SONY CXD56 |
| 86 | |
| 87 | // TI |
| 88 | #define OPT_MCU_MSP430x5xx 500 ///< TI MSP430x5xx |
| 89 | #define OPT_MCU_MSP432E4 510 ///< TI MSP432E4xx |
| 90 | #define OPT_MCU_TM4C123 511 ///< TI Tiva-C 123x |
| 91 | #define OPT_MCU_TM4C129 512 ///< TI Tiva-C 129x |
| 92 | |
| 93 | // ValentyUSB eptri |
| 94 | #define OPT_MCU_VALENTYUSB_EPTRI 600 ///< Fomu eptri config |
| 95 | |
| 96 | // NXP iMX RT |
| 97 | #define OPT_MCU_MIMXRT10XX 700 ///< NXP iMX RT10xx |
| 98 | |
| 99 | // Nuvoton |
| 100 | #define OPT_MCU_NUC121 800 |
| 101 | #define OPT_MCU_NUC126 801 |
| 102 | #define OPT_MCU_NUC120 802 |
| 103 | #define OPT_MCU_NUC505 803 |
| 104 | |
| 105 | // Espressif |
| 106 | #define OPT_MCU_ESP32S2 900 ///< Espressif ESP32-S2 |
| 107 | #define OPT_MCU_ESP32S3 901 ///< Espressif ESP32-S3 |
| 108 | |
| 109 | // Dialog |
| 110 | #define OPT_MCU_DA1469X 1000 ///< Dialog Semiconductor DA1469x |
| 111 | |
| 112 | // Raspberry Pi |
| 113 | #define OPT_MCU_RP2040 1100 ///< Raspberry Pi RP2040 |
| 114 | |
| 115 | // NXP Kinetis |
| 116 | #define OPT_MCU_MKL25ZXX 1200 ///< NXP MKL25Zxx |
| 117 | #define OPT_MCU_K32L2BXX 1201 ///< NXP K32L2Bxx |
| 118 | |
| 119 | // Silabs |
| 120 | #define OPT_MCU_EFM32GG 1300 ///< Silabs EFM32GG |
| 121 | |
| 122 | // Renesas RX |
| 123 | #define OPT_MCU_RX63X 1400 ///< Renesas RX63N/631 |
| 124 | #define OPT_MCU_RX65X 1401 ///< Renesas RX65N/RX651 |
| 125 | #define OPT_MCU_RX72N 1402 ///< Renesas RX72N |
| 126 | |
| 127 | // Mind Motion |
| 128 | #define OPT_MCU_MM32F327X 1500 ///< Mind Motion MM32F327 |
| 129 | |
| 130 | // GigaDevice |
| 131 | #define OPT_MCU_GD32VF103 1600 ///< GigaDevice GD32VF103 |
| 132 | |
| 133 | // Broadcom |
| 134 | #define OPT_MCU_BCM2711 1700 ///< Broadcom BCM2711 |
| 135 | |
| 136 | // Infineon |
| 137 | #define OPT_MCU_XMC4000 1800 ///< Infineon XMC4000 |
| 138 | |
| 139 | // Helper to check if configured MCU is one of listed |
| 140 | // Apply _TU_CHECK_MCU with || as separator to list of input |
| 141 | #define _TU_CHECK_MCU(_m) (CFG_TUSB_MCU == _m) |
| 142 | #define TU_CHECK_MCU(...) (TU_ARGS_APPLY(_TU_CHECK_MCU, ||, __VA_ARGS__)) |
| 143 | |
| 144 | //--------------------------------------------------------------------+ |
| 145 | // Supported OS |
| 146 | //--------------------------------------------------------------------+ |
| 147 | |
| 148 | #define OPT_OS_NONE 1 ///< No RTOS |
| 149 | #define OPT_OS_FREERTOS 2 ///< FreeRTOS |
| 150 | #define OPT_OS_MYNEWT 3 ///< Mynewt OS |
| 151 | #define OPT_OS_CUSTOM 4 ///< Custom OS is implemented by application |
| 152 | #define OPT_OS_PICO 5 ///< Raspberry Pi Pico SDK |
| 153 | #define OPT_OS_RTTHREAD 6 ///< RT-Thread |
| 154 | |
| 155 | // Allow to use command line to change the config name/location |
| 156 | #ifdef CFG_TUSB_CONFIG_FILE |
| 157 | #include CFG_TUSB_CONFIG_FILE |
| 158 | #else |
| 159 | #include "tusb_config.h" |
| 160 | #endif |
| 161 | |
| 162 | //-------------------------------------------------------------------- |
| 163 | // RootHub Mode Configuration |
| 164 | // CFG_TUSB_RHPORTx_MODE contains operation mode and speed for that port |
| 165 | //-------------------------------------------------------------------- |
| 166 | |
| 167 | // Lower 4-bit is operational mode |
| 168 | #define OPT_MODE_NONE 0x00 ///< Disabled |
| 169 | #define OPT_MODE_DEVICE 0x01 ///< Device Mode |
| 170 | #define OPT_MODE_HOST 0x02 ///< Host Mode |
| 171 | |
| 172 | // Higher 4-bit is max operational speed (corresponding to tusb_speed_t) |
| 173 | #define OPT_MODE_FULL_SPEED 0x00 ///< Max Full Speed |
| 174 | #define OPT_MODE_LOW_SPEED 0x10 ///< Max Low Speed |
| 175 | #define OPT_MODE_HIGH_SPEED 0x20 ///< Max High Speed |
| 176 | |
| 177 | |
| 178 | #ifndef CFG_TUSB_RHPORT0_MODE |
| 179 | #define CFG_TUSB_RHPORT0_MODE OPT_MODE_NONE |
| 180 | #endif |
| 181 | |
| 182 | |
| 183 | #ifndef CFG_TUSB_RHPORT1_MODE |
| 184 | #define CFG_TUSB_RHPORT1_MODE OPT_MODE_NONE |
| 185 | #endif |
| 186 | |
| 187 | #if (((CFG_TUSB_RHPORT0_MODE) & OPT_MODE_HOST ) && ((CFG_TUSB_RHPORT1_MODE) & OPT_MODE_HOST )) || \ |
| 188 | (((CFG_TUSB_RHPORT0_MODE) & OPT_MODE_DEVICE) && ((CFG_TUSB_RHPORT1_MODE) & OPT_MODE_DEVICE)) |
| 189 | #error "TinyUSB currently does not support same modes on more than 1 roothub port" |
| 190 | #endif |
| 191 | |
| 192 | // Which roothub port is configured as host |
| 193 | #define TUH_OPT_RHPORT ( ((CFG_TUSB_RHPORT0_MODE) & OPT_MODE_HOST) ? 0 : (((CFG_TUSB_RHPORT1_MODE) & OPT_MODE_HOST) ? 1 : -1) ) |
| 194 | #define TUSB_OPT_HOST_ENABLED ( TUH_OPT_RHPORT >= 0 ) |
| 195 | |
| 196 | // Which roothub port is configured as device |
| 197 | #define TUD_OPT_RHPORT ( ((CFG_TUSB_RHPORT0_MODE) & OPT_MODE_DEVICE) ? 0 : (((CFG_TUSB_RHPORT1_MODE) & OPT_MODE_DEVICE) ? 1 : -1) ) |
| 198 | |
| 199 | #if TUD_OPT_RHPORT == 0 |
| 200 | #define TUD_OPT_HIGH_SPEED ( (CFG_TUSB_RHPORT0_MODE) & OPT_MODE_HIGH_SPEED ) |
| 201 | #else |
| 202 | #define TUD_OPT_HIGH_SPEED ( (CFG_TUSB_RHPORT1_MODE) & OPT_MODE_HIGH_SPEED ) |
| 203 | #endif |
| 204 | |
| 205 | #define TUSB_OPT_DEVICE_ENABLED ( TUD_OPT_RHPORT >= 0 ) |
| 206 | |
| 207 | //--------------------------------------------------------------------+ |
| 208 | // COMMON OPTIONS |
| 209 | //--------------------------------------------------------------------+ |
| 210 | |
| 211 | // Debug enable to print out error message |
| 212 | #ifndef CFG_TUSB_DEBUG |
| 213 | #define CFG_TUSB_DEBUG 0 |
| 214 | #endif |
| 215 | |
| 216 | // place data in accessible RAM for usb controller |
| 217 | #ifndef CFG_TUSB_MEM_SECTION |
| 218 | #define CFG_TUSB_MEM_SECTION |
| 219 | #endif |
| 220 | |
| 221 | // alignment requirement of buffer used for endpoint transferring |
| 222 | #ifndef CFG_TUSB_MEM_ALIGN |
| 223 | #define CFG_TUSB_MEM_ALIGN TU_ATTR_ALIGNED(4) |
| 224 | #endif |
| 225 | |
| 226 | // OS selection |
| 227 | #ifndef CFG_TUSB_OS |
| 228 | #define CFG_TUSB_OS OPT_OS_NONE |
| 229 | #endif |
| 230 | |
| 231 | #ifndef CFG_TUSB_OS_INC_PATH |
| 232 | #define CFG_TUSB_OS_INC_PATH |
| 233 | #endif |
| 234 | |
| 235 | //-------------------------------------------------------------------- |
| 236 | // DEVICE OPTIONS |
| 237 | //-------------------------------------------------------------------- |
| 238 | |
| 239 | #ifndef CFG_TUD_ENDPOINT0_SIZE |
| 240 | #define CFG_TUD_ENDPOINT0_SIZE 64 |
| 241 | #endif |
| 242 | |
| 243 | #ifndef CFG_TUD_CDC |
| 244 | #define CFG_TUD_CDC 0 |
| 245 | #endif |
| 246 | |
| 247 | #ifndef CFG_TUD_MSC |
| 248 | #define CFG_TUD_MSC 0 |
| 249 | #endif |
| 250 | |
| 251 | #ifndef CFG_TUD_HID |
| 252 | #define CFG_TUD_HID 0 |
| 253 | #endif |
| 254 | |
| 255 | #ifndef CFG_TUD_AUDIO |
| 256 | #define CFG_TUD_AUDIO 0 |
| 257 | #endif |
| 258 | |
| 259 | #ifndef CFG_TUD_VIDEO |
| 260 | #define CFG_TUD_VIDEO 0 |
| 261 | #endif |
| 262 | |
| 263 | #ifndef CFG_TUD_MIDI |
| 264 | #define CFG_TUD_MIDI 0 |
| 265 | #endif |
| 266 | |
| 267 | #ifndef CFG_TUD_VENDOR |
| 268 | #define CFG_TUD_VENDOR 0 |
| 269 | #endif |
| 270 | |
| 271 | #ifndef CFG_TUD_USBTMC |
| 272 | #define CFG_TUD_USBTMC 0 |
| 273 | #endif |
| 274 | |
| 275 | #ifndef CFG_TUD_DFU_RUNTIME |
| 276 | #define CFG_TUD_DFU_RUNTIME 0 |
| 277 | #endif |
| 278 | |
| 279 | #ifndef CFG_TUD_DFU |
| 280 | #define CFG_TUD_DFU 0 |
| 281 | #endif |
| 282 | |
| 283 | #ifndef CFG_TUD_BTH |
| 284 | #define CFG_TUD_BTH 0 |
| 285 | #endif |
| 286 | |
| 287 | #ifndef CFG_TUD_ECM_RNDIS |
| 288 | #ifdef CFG_TUD_NET |
| 289 | #warning "CFG_TUD_NET is renamed to CFG_TUD_ECM_RNDIS" |
| 290 | #define CFG_TUD_ECM_RNDIS CFG_TUD_NET |
| 291 | #else |
| 292 | #define CFG_TUD_ECM_RNDIS 0 |
| 293 | #endif |
| 294 | #endif |
| 295 | |
| 296 | #ifndef CFG_TUD_NCM |
| 297 | #define CFG_TUD_NCM 0 |
| 298 | #endif |
| 299 | |
| 300 | //-------------------------------------------------------------------- |
| 301 | // HOST OPTIONS |
| 302 | //-------------------------------------------------------------------- |
| 303 | #if TUSB_OPT_HOST_ENABLED |
| 304 | #ifndef CFG_TUH_DEVICE_MAX |
| 305 | #define CFG_TUH_DEVICE_MAX 1 |
| 306 | #endif |
| 307 | |
| 308 | #ifndef CFG_TUH_ENUMERATION_BUFSIZE |
| 309 | #define CFG_TUH_ENUMERATION_BUFSIZE 256 |
| 310 | #endif |
| 311 | #endif // TUSB_OPT_HOST_ENABLED |
| 312 | |
| 313 | //------------- CLASS -------------// |
| 314 | |
| 315 | #ifndef CFG_TUH_HUB |
| 316 | #define CFG_TUH_HUB 0 |
| 317 | #endif |
| 318 | |
| 319 | #ifndef CFG_TUH_CDC |
| 320 | #define CFG_TUH_CDC 0 |
| 321 | #endif |
| 322 | |
| 323 | #ifndef CFG_TUH_HID |
| 324 | #define CFG_TUH_HID 0 |
| 325 | #endif |
| 326 | |
| 327 | #ifndef CFG_TUH_MIDI |
| 328 | #define CFG_TUH_MIDI 0 |
| 329 | #endif |
| 330 | |
| 331 | #ifndef CFG_TUH_MSC |
| 332 | #define CFG_TUH_MSC 0 |
| 333 | #endif |
| 334 | |
| 335 | #ifndef CFG_TUH_VENDOR |
| 336 | #define CFG_TUH_VENDOR 0 |
| 337 | #endif |
| 338 | |
| 339 | //--------------------------------------------------------------------+ |
| 340 | // Port Specific |
| 341 | // TUP stand for TinyUSB Port (can be renamed) |
| 342 | //--------------------------------------------------------------------+ |
| 343 | |
| 344 | //------------- Unaligned Memory -------------// |
| 345 | |
| 346 | // ARMv7+ (M3-M7, M23-M33) can access unaligned memory |
| 347 | #if (defined(__ARM_ARCH) && (__ARM_ARCH >= 7)) |
| 348 | #define TUP_ARCH_STRICT_ALIGN 0 |
| 349 | #else |
| 350 | #define TUP_ARCH_STRICT_ALIGN 1 |
| 351 | #endif |
| 352 | |
| 353 | // TUP_MCU_STRICT_ALIGN will overwrite TUP_ARCH_STRICT_ALIGN. |
| 354 | // In case TUP_MCU_STRICT_ALIGN = 1 and TUP_ARCH_STRICT_ALIGN =0, we will not reply on compiler |
| 355 | // to generate unaligned access code. |
| 356 | // LPC_IP3511 Highspeed cannot access unaligned memory on USB_RAM |
| 357 | #if TUD_OPT_HIGH_SPEED && (CFG_TUSB_MCU == OPT_MCU_LPC54XXX || CFG_TUSB_MCU == OPT_MCU_LPC55XX) |
| 358 | #define TUP_MCU_STRICT_ALIGN 1 |
| 359 | #else |
| 360 | #define TUP_MCU_STRICT_ALIGN 0 |
| 361 | #endif |
| 362 | |
| 363 | |
| 364 | //------------------------------------------------------------------ |
| 365 | // Configuration Validation |
| 366 | //------------------------------------------------------------------ |
| 367 | #if CFG_TUD_ENDPOINT0_SIZE > 64 |
| 368 | #error Control Endpoint Max Packet Size cannot be larger than 64 |
| 369 | #endif |
| 370 | |
| 371 | #endif /* _TUSB_OPTION_H_ */ |
| 372 | |
| 373 | /** @} */ |