|
| 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 | + */ |
| 25 | + |
| 26 | +#ifndef _TUSB_CONFIG_H_ |
| 27 | +#define _TUSB_CONFIG_H_ |
| 28 | + |
| 29 | +#include "sdkconfig.h" |
| 30 | + |
| 31 | +#ifdef __cplusplus |
| 32 | +extern "C" { |
| 33 | +#endif |
| 34 | + |
| 35 | +//--------------------------------------------------------------------+ |
| 36 | +// Board Specific Configuration |
| 37 | +//--------------------------------------------------------------------+ |
| 38 | + |
| 39 | +#ifdef CONFIG_TINYUSB_RHPORT_HS |
| 40 | +# define CFG_TUSB_RHPORT1_MODE OPT_MODE_DEVICE | OPT_MODE_HIGH_SPEED |
| 41 | +# define CONFIG_USB_HS 1 |
| 42 | +#else |
| 43 | +# define CFG_TUSB_RHPORT0_MODE OPT_MODE_DEVICE | OPT_MODE_FULL_SPEED |
| 44 | +# define CONFIG_USB_HS 0 |
| 45 | +#endif |
| 46 | + |
| 47 | +//-------------------------------------------------------------------- |
| 48 | +// Common Configuration |
| 49 | +//-------------------------------------------------------------------- |
| 50 | + |
| 51 | +// defined by compiler flags for flexibility |
| 52 | +#ifndef CFG_TUSB_MCU |
| 53 | +#error CFG_TUSB_MCU must be defined |
| 54 | +#endif |
| 55 | + |
| 56 | +#ifndef CFG_TUSB_OS |
| 57 | +#define CFG_TUSB_OS OPT_OS_FREERTOS |
| 58 | +#endif |
| 59 | + |
| 60 | +#ifndef ESP_PLATFORM |
| 61 | +#define ESP_PLATFORM 1 |
| 62 | +#endif |
| 63 | + |
| 64 | +// Espressif IDF requires "freertos/" prefix in include path |
| 65 | +#if TU_CHECK_MCU(OPT_MCU_ESP32S2, OPT_MCU_ESP32S3, OPT_MCU_ESP32P4) |
| 66 | +#define CFG_TUSB_OS_INC_PATH freertos/ |
| 67 | +#endif |
| 68 | + |
| 69 | +#ifndef CFG_TUSB_DEBUG |
| 70 | +#define CFG_TUSB_DEBUG 0 |
| 71 | +#endif |
| 72 | + |
| 73 | +// Enable Device stack |
| 74 | +#define CFG_TUD_ENABLED 1 |
| 75 | + |
| 76 | +/* USB DMA on some MCUs can only access a specific SRAM region with restriction on alignment. |
| 77 | + * Tinyusb use follows macros to declare transferring memory so that they can be put |
| 78 | + * into those specific section. |
| 79 | + * e.g |
| 80 | + * - CFG_TUSB_MEM SECTION : __attribute__ (( section(".usb_ram") )) |
| 81 | + * - CFG_TUSB_MEM_ALIGN : __attribute__ ((aligned(4))) |
| 82 | + */ |
| 83 | +#ifndef CFG_TUSB_MEM_SECTION |
| 84 | +#define CFG_TUSB_MEM_SECTION |
| 85 | +#endif |
| 86 | + |
| 87 | +#ifndef CFG_TUSB_MEM_ALIGN |
| 88 | +#define CFG_TUSB_MEM_ALIGN __attribute__ ((aligned(4))) |
| 89 | +#endif |
| 90 | + |
| 91 | +//-------------------------------------------------------------------- |
| 92 | +// DEVICE CONFIGURATION |
| 93 | +//-------------------------------------------------------------------- |
| 94 | + |
| 95 | +#ifndef CFG_TUD_ENDPOINT0_SIZE |
| 96 | +#define CFG_TUD_ENDPOINT0_SIZE 64 |
| 97 | +#endif |
| 98 | + |
| 99 | +#define USB_VID CONFIG_TUSB_VID |
| 100 | +#define USB_PID CONFIG_TUSB_PID |
| 101 | +#define USB_MANUFACTURER CONFIG_TUSB_MANUFACTURER |
| 102 | +#define USB_PRODUCT CONFIG_TUSB_PRODUCT |
| 103 | + |
| 104 | +//------------- CLASS -------------// |
| 105 | +/*!< CDC ACM Class */ |
| 106 | +#define CFG_TUD_CDC 1 |
| 107 | +// CDC FIFO size of TX and RX |
| 108 | +#define CFG_TUD_CDC_RX_BUFSIZE 512 |
| 109 | +#define CFG_TUD_CDC_TX_BUFSIZE 512 |
| 110 | +#define CFG_TUD_CDC_EP_BUFSIZE CONFIG_USB_HS ? 512 : 64 |
| 111 | + |
| 112 | +#ifdef __cplusplus |
| 113 | +} |
| 114 | +#endif |
| 115 | + |
| 116 | +#endif /* _TUSB_CONFIG_H_ */ |
0 commit comments