|
| 1 | +/* |
| 2 | + * The MIT License (MIT) |
| 3 | + * |
| 4 | + * Copyright (c) 2018, hathach for Adafruit |
| 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 | +#ifndef TUSB_CONFIG_CH32_H_ |
| 26 | +#define TUSB_CONFIG_CH32_H_ |
| 27 | + |
| 28 | +#ifdef __cplusplus |
| 29 | +extern "C" { |
| 30 | +#endif |
| 31 | + |
| 32 | +//-------------------------------------------------------------------- |
| 33 | +// COMMON CONFIGURATION |
| 34 | +//-------------------------------------------------------------------- |
| 35 | +#if defined(CH32V20x) |
| 36 | +#define CFG_TUSB_MCU OPT_MCU_CH32V20X |
| 37 | +#define CFG_TUD_WCH_USBIP_FSDEV 1 // use USBD |
| 38 | +#elif defined(CH32V30x) |
| 39 | +#define CFG_TUSB_MCU OPT_MCU_CH32V307 |
| 40 | +#endif |
| 41 | + |
| 42 | +#define CFG_TUSB_OS OPT_OS_NONE |
| 43 | + |
| 44 | +#ifndef CFG_TUSB_DEBUG |
| 45 | +#define CFG_TUSB_DEBUG 0 |
| 46 | +#endif |
| 47 | + |
| 48 | +// For selectively disable device log (when > CFG_TUSB_DEBUG) |
| 49 | +// #define CFG_TUD_LOG_LEVEL 3 |
| 50 | +// #define CFG_TUH_LOG_LEVEL 3 |
| 51 | + |
| 52 | +#define CFG_TUSB_MEM_SECTION |
| 53 | +#define CFG_TUSB_MEM_ALIGN __attribute__((aligned(4))) |
| 54 | + |
| 55 | +#define CFG_TUD_ENABLED 1 |
| 56 | + |
| 57 | +// #ifdef USE_TINYUSB |
| 58 | +//// Enable device stack |
| 59 | +// #define CFG_TUD_ENABLED 1 |
| 60 | +// |
| 61 | +//// Enable host stack with MAX3421E (host shield) |
| 62 | +// #define CFG_TUH_ENABLED 1 |
| 63 | +// #define CFG_TUH_MAX3421 1 |
| 64 | +// |
| 65 | +// #else |
| 66 | +// #define CFG_TUD_ENABLED 0 |
| 67 | +// #define CFG_TUH_ENABLED 0 |
| 68 | +// #endif |
| 69 | + |
| 70 | +//-------------------------------------------------------------------- |
| 71 | +// DEVICE CONFIGURATION |
| 72 | +//-------------------------------------------------------------------- |
| 73 | + |
| 74 | +#define CFG_TUD_ENDPOINT0_SIZE 64 |
| 75 | + |
| 76 | +//------------- CLASS -------------// |
| 77 | +#ifndef CFG_TUD_CDC |
| 78 | +#define CFG_TUD_CDC 1 |
| 79 | +#endif |
| 80 | + |
| 81 | +#ifndef CFG_TUD_MSC |
| 82 | +#define CFG_TUD_MSC 1 |
| 83 | +#endif |
| 84 | + |
| 85 | +#ifndef CFG_TUD_HID |
| 86 | +#define CFG_TUD_HID 2 |
| 87 | +#endif |
| 88 | + |
| 89 | +#ifndef CFG_TUD_MIDI |
| 90 | +#define CFG_TUD_MIDI 1 |
| 91 | +#endif |
| 92 | + |
| 93 | +#ifndef CFG_TUD_VENDOR |
| 94 | +#define CFG_TUD_VENDOR 1 |
| 95 | +#endif |
| 96 | + |
| 97 | +#ifndef CFG_TUD_VIDEO |
| 98 | +#define CFG_TUD_VIDEO 1 // number of video control interfaces |
| 99 | +#endif |
| 100 | + |
| 101 | +#ifndef CFG_TUD_VIDEO_STREAMING |
| 102 | +#define CFG_TUD_VIDEO_STREAMING 1 // number of video streaming interfaces |
| 103 | +#endif |
| 104 | + |
| 105 | +// video streaming endpoint buffer size |
| 106 | +#define CFG_TUD_VIDEO_STREAMING_EP_BUFSIZE 256 |
| 107 | + |
| 108 | +// CDC FIFO size of TX and RX |
| 109 | +#define CFG_TUD_CDC_RX_BUFSIZE 256 |
| 110 | +#define CFG_TUD_CDC_TX_BUFSIZE 256 |
| 111 | + |
| 112 | +// MSC Buffer size of Device Mass storage |
| 113 | +#define CFG_TUD_MSC_EP_BUFSIZE 512 |
| 114 | + |
| 115 | +// HID buffer size Should be sufficient to hold ID (if any) + Data |
| 116 | +#define CFG_TUD_HID_EP_BUFSIZE 64 |
| 117 | + |
| 118 | +// MIDI FIFO size of TX and RX |
| 119 | +#define CFG_TUD_MIDI_RX_BUFSIZE 128 |
| 120 | +#define CFG_TUD_MIDI_TX_BUFSIZE 128 |
| 121 | + |
| 122 | +// Vendor FIFO size of TX and RX |
| 123 | +#ifndef CFG_TUD_VENDOR_RX_BUFSIZE |
| 124 | +#define CFG_TUD_VENDOR_RX_BUFSIZE 64 |
| 125 | +#endif |
| 126 | + |
| 127 | +#ifndef CFG_TUD_VENDOR_TX_BUFSIZE |
| 128 | +#define CFG_TUD_VENDOR_TX_BUFSIZE 64 |
| 129 | +#endif |
| 130 | + |
| 131 | +//-------------------------------------------------------------------- |
| 132 | +// Host Configuration |
| 133 | +//-------------------------------------------------------------------- |
| 134 | + |
| 135 | +// Size of buffer to hold descriptors and other data used for enumeration |
| 136 | +#define CFG_TUH_ENUMERATION_BUFSIZE 256 |
| 137 | + |
| 138 | +// Number of hub devices |
| 139 | +#define CFG_TUH_HUB 1 |
| 140 | + |
| 141 | +// max device support (excluding hub device): 1 hub typically has 4 ports |
| 142 | +#define CFG_TUH_DEVICE_MAX (3 * CFG_TUH_HUB + 1) |
| 143 | + |
| 144 | +// Enable tuh_edpt_xfer() API |
| 145 | +// #define CFG_TUH_API_EDPT_XFER 1 |
| 146 | + |
| 147 | +// Number of mass storage |
| 148 | +#define CFG_TUH_MSC 1 |
| 149 | + |
| 150 | +// Number of HIDs |
| 151 | +// typical keyboard + mouse device can have 3,4 HID interfaces |
| 152 | +#define CFG_TUH_HID (3 * CFG_TUH_DEVICE_MAX) |
| 153 | + |
| 154 | +// Number of CDC interfaces |
| 155 | +// FTDI and CP210x are not part of CDC class, only to re-use CDC driver API |
| 156 | +#define CFG_TUH_CDC 1 |
| 157 | +#define CFG_TUH_CDC_FTDI 1 |
| 158 | +#define CFG_TUH_CDC_CP210X 1 |
| 159 | +#define CFG_TUH_CDC_CH34X 1 |
| 160 | + |
| 161 | +// RX & TX fifo size |
| 162 | +#define CFG_TUH_CDC_RX_BUFSIZE 64 |
| 163 | +#define CFG_TUH_CDC_TX_BUFSIZE 64 |
| 164 | + |
| 165 | +// Set Line Control state on enumeration/mounted: |
| 166 | +// DTR ( bit 0), RTS (bit 1) |
| 167 | +#define CFG_TUH_CDC_LINE_CONTROL_ON_ENUM 0x03 |
| 168 | + |
| 169 | +// Set Line Coding on enumeration/mounted, value for cdc_line_coding_t |
| 170 | +// bit rate = 115200, 1 stop bit, no parity, 8 bit data width |
| 171 | +// This need Pico-PIO-USB at least 0.5.1 |
| 172 | +#define CFG_TUH_CDC_LINE_CODING_ON_ENUM \ |
| 173 | + { 115200, CDC_LINE_CONDING_STOP_BITS_1, CDC_LINE_CODING_PARITY_NONE, 8 } |
| 174 | + |
| 175 | +#ifdef __cplusplus |
| 176 | +} |
| 177 | +#endif |
| 178 | + |
| 179 | +#endif |
0 commit comments