|
| 1 | +/* |
| 2 | + * Copyright (c) 2025, RT-Thread Development Team |
| 3 | + * |
| 4 | + * SPDX-License-Identifier: Apache-2.0 |
| 5 | + * |
| 6 | + * Change Logs: |
| 7 | + * Date Author Notes |
| 8 | + * 2025-01-17 Supperthomas first version |
| 9 | + */ |
| 10 | +#ifndef CHERRYUSB_CONFIG_H |
| 11 | +#define CHERRYUSB_CONFIG_H |
| 12 | + |
| 13 | +/* ================ USB common Configuration ================ */ |
| 14 | + |
| 15 | +#define CONFIG_USB_PRINTF(...) printf(__VA_ARGS__) |
| 16 | + |
| 17 | +#ifndef CONFIG_USB_DBG_LEVEL |
| 18 | +#define CONFIG_USB_DBG_LEVEL USB_DBG_INFO |
| 19 | +#endif |
| 20 | + |
| 21 | +/* Enable print with color */ |
| 22 | +#define CONFIG_USB_PRINTF_COLOR_ENABLE |
| 23 | + |
| 24 | +/* data align size when use dma */ |
| 25 | +#ifndef CONFIG_USB_ALIGN_SIZE |
| 26 | +#define CONFIG_USB_ALIGN_SIZE 4 |
| 27 | +#endif |
| 28 | + |
| 29 | +/* attribute data into no cache ram */ |
| 30 | +#define USB_NOCACHE_RAM_SECTION __attribute__((section(".NonCacheable"))) |
| 31 | + |
| 32 | +/* ================= USB Device Stack Configuration ================ */ |
| 33 | + |
| 34 | +/* Ep0 in and out transfer buffer */ |
| 35 | +#ifndef CONFIG_USBDEV_REQUEST_BUFFER_LEN |
| 36 | +#define CONFIG_USBDEV_REQUEST_BUFFER_LEN 512 |
| 37 | +#endif |
| 38 | + |
| 39 | +/* Setup packet log for debug */ |
| 40 | +// #define CONFIG_USBDEV_SETUP_LOG_PRINT |
| 41 | + |
| 42 | +/* Check if the input descriptor is correct */ |
| 43 | +// #define CONFIG_USBDEV_DESC_CHECK |
| 44 | + |
| 45 | +/* Enable test mode */ |
| 46 | +// #define CONFIG_USBDEV_TEST_MODE |
| 47 | + |
| 48 | +#ifndef CONFIG_USBDEV_MSC_MAX_LUN |
| 49 | +#define CONFIG_USBDEV_MSC_MAX_LUN 1 |
| 50 | +#endif |
| 51 | + |
| 52 | +#ifndef CONFIG_USBDEV_MSC_MAX_BUFSIZE |
| 53 | +#define CONFIG_USBDEV_MSC_MAX_BUFSIZE 512 |
| 54 | +#endif |
| 55 | + |
| 56 | +#ifndef CONFIG_USBDEV_MSC_MANUFACTURER_STRING |
| 57 | +#define CONFIG_USBDEV_MSC_MANUFACTURER_STRING "" |
| 58 | +#endif |
| 59 | + |
| 60 | +#ifndef CONFIG_USBDEV_MSC_PRODUCT_STRING |
| 61 | +#define CONFIG_USBDEV_MSC_PRODUCT_STRING "" |
| 62 | +#endif |
| 63 | + |
| 64 | +#ifndef CONFIG_USBDEV_MSC_VERSION_STRING |
| 65 | +#define CONFIG_USBDEV_MSC_VERSION_STRING "0.01" |
| 66 | +#endif |
| 67 | + |
| 68 | +// #define CONFIG_USBDEV_MSC_THREAD |
| 69 | + |
| 70 | +#ifndef CONFIG_USBDEV_MSC_PRIO |
| 71 | +#define CONFIG_USBDEV_MSC_PRIO 4 |
| 72 | +#endif |
| 73 | + |
| 74 | +#ifndef CONFIG_USBDEV_MSC_STACKSIZE |
| 75 | +#define CONFIG_USBDEV_MSC_STACKSIZE 2048 |
| 76 | +#endif |
| 77 | + |
| 78 | +#ifndef CONFIG_USBDEV_RNDIS_RESP_BUFFER_SIZE |
| 79 | +#define CONFIG_USBDEV_RNDIS_RESP_BUFFER_SIZE 156 |
| 80 | +#endif |
| 81 | + |
| 82 | +#ifndef CONFIG_USBDEV_RNDIS_ETH_MAX_FRAME_SIZE |
| 83 | +#define CONFIG_USBDEV_RNDIS_ETH_MAX_FRAME_SIZE 1580 |
| 84 | +#endif |
| 85 | + |
| 86 | +#ifndef CONFIG_USBDEV_RNDIS_VENDOR_ID |
| 87 | +#define CONFIG_USBDEV_RNDIS_VENDOR_ID 0x0000ffff |
| 88 | +#endif |
| 89 | + |
| 90 | +#ifndef CONFIG_USBDEV_RNDIS_VENDOR_DESC |
| 91 | +#define CONFIG_USBDEV_RNDIS_VENDOR_DESC "CherryUSB" |
| 92 | +#endif |
| 93 | + |
| 94 | +#define CONFIG_USBDEV_RNDIS_USING_LWIP |
| 95 | + |
| 96 | +/* ================ USB HOST Stack Configuration ================== */ |
| 97 | + |
| 98 | +#define CONFIG_USBHOST_MAX_RHPORTS 1 |
| 99 | +#define CONFIG_USBHOST_MAX_EXTHUBS 1 |
| 100 | +#define CONFIG_USBHOST_MAX_EHPORTS 4 |
| 101 | +#define CONFIG_USBHOST_MAX_INTERFACES 8 |
| 102 | +#define CONFIG_USBHOST_MAX_INTF_ALTSETTINGS 8 |
| 103 | +#define CONFIG_USBHOST_MAX_ENDPOINTS 4 |
| 104 | + |
| 105 | +#define CONFIG_USBHOST_MAX_CDC_ACM_CLASS 4 |
| 106 | +#define CONFIG_USBHOST_MAX_HID_CLASS 4 |
| 107 | +#define CONFIG_USBHOST_MAX_MSC_CLASS 2 |
| 108 | +#define CONFIG_USBHOST_MAX_AUDIO_CLASS 1 |
| 109 | +#define CONFIG_USBHOST_MAX_VIDEO_CLASS 1 |
| 110 | + |
| 111 | +#define CONFIG_USBHOST_DEV_NAMELEN 16 |
| 112 | + |
| 113 | +#ifndef CONFIG_USBHOST_PSC_PRIO |
| 114 | +#define CONFIG_USBHOST_PSC_PRIO 0 |
| 115 | +#endif |
| 116 | +#ifndef CONFIG_USBHOST_PSC_STACKSIZE |
| 117 | +#define CONFIG_USBHOST_PSC_STACKSIZE 2048 |
| 118 | +#endif |
| 119 | + |
| 120 | +//#define CONFIG_USBHOST_GET_STRING_DESC |
| 121 | + |
| 122 | +// #define CONFIG_USBHOST_MSOS_ENABLE |
| 123 | +#ifndef CONFIG_USBHOST_MSOS_VENDOR_CODE |
| 124 | +#define CONFIG_USBHOST_MSOS_VENDOR_CODE 0x00 |
| 125 | +#endif |
| 126 | + |
| 127 | +/* Ep0 max transfer buffer */ |
| 128 | +#ifndef CONFIG_USBHOST_REQUEST_BUFFER_LEN |
| 129 | +#define CONFIG_USBHOST_REQUEST_BUFFER_LEN 512 |
| 130 | +#endif |
| 131 | + |
| 132 | +#ifndef CONFIG_USBHOST_CONTROL_TRANSFER_TIMEOUT |
| 133 | +#define CONFIG_USBHOST_CONTROL_TRANSFER_TIMEOUT 500 |
| 134 | +#endif |
| 135 | + |
| 136 | +#ifndef CONFIG_USBHOST_MSC_TIMEOUT |
| 137 | +#define CONFIG_USBHOST_MSC_TIMEOUT 5000 |
| 138 | +#endif |
| 139 | + |
| 140 | +/* This parameter affects usb performance, and depends on (TCP_WND)tcp eceive windows size, |
| 141 | + * you can change with 2K,4K,8K,16K,default is 2K to get one TCP_MSS |
| 142 | + */ |
| 143 | +#ifndef CONFIG_USBHOST_RNDIS_ETH_MAX_RX_SIZE |
| 144 | +#define CONFIG_USBHOST_RNDIS_ETH_MAX_RX_SIZE (2048) |
| 145 | +#endif |
| 146 | +#ifndef CONFIG_USBHOST_RNDIS_ETH_MAX_TX_SIZE |
| 147 | +#define CONFIG_USBHOST_RNDIS_ETH_MAX_TX_SIZE (2048) |
| 148 | +#endif |
| 149 | + |
| 150 | +/* This parameter affects usb performance, and depends on (TCP_WND)tcp eceive windows size, |
| 151 | + * you can change with 2K,4K,8K,16K,default is 2K to get one TCP_MSS |
| 152 | + */ |
| 153 | +#ifndef CONFIG_USBHOST_CDC_NCM_ETH_MAX_RX_SIZE |
| 154 | +#define CONFIG_USBHOST_CDC_NCM_ETH_MAX_RX_SIZE (2048) |
| 155 | +#endif |
| 156 | +#ifndef CONFIG_USBHOST_CDC_NCM_ETH_MAX_TX_SIZE |
| 157 | +#define CONFIG_USBHOST_CDC_NCM_ETH_MAX_TX_SIZE (2048) |
| 158 | +#endif |
| 159 | + |
| 160 | +#define CONFIG_USBHOST_BLUETOOTH_HCI_H4 |
| 161 | +// #define CONFIG_USBHOST_BLUETOOTH_HCI_LOG |
| 162 | + |
| 163 | +#ifndef CONFIG_USBHOST_BLUETOOTH_TX_SIZE |
| 164 | +#define CONFIG_USBHOST_BLUETOOTH_TX_SIZE 2048 |
| 165 | +#endif |
| 166 | +#ifndef CONFIG_USBHOST_BLUETOOTH_RX_SIZE |
| 167 | +#define CONFIG_USBHOST_BLUETOOTH_RX_SIZE 2048 |
| 168 | +#endif |
| 169 | + |
| 170 | +/* ================ USB Device Port Configuration ================*/ |
| 171 | + |
| 172 | +#ifndef CONFIG_USBDEV_MAX_BUS |
| 173 | +#define CONFIG_USBDEV_MAX_BUS 1 // for now, bus num must be 1 except hpm ip |
| 174 | +#endif |
| 175 | + |
| 176 | +#ifndef CONFIG_USBDEV_EP_NUM |
| 177 | +#define CONFIG_USBDEV_EP_NUM 4 |
| 178 | +#endif |
| 179 | + |
| 180 | +/* ---------------- FSDEV Configuration ---------------- */ |
| 181 | +//#define CONFIG_USBDEV_FSDEV_PMA_ACCESS 2 // maybe 1 or 2, many chips may have a difference |
| 182 | + |
| 183 | +/* ---------------- DWC2 Configuration ---------------- */ |
| 184 | +// #define CONFIG_USB_DWC2_RXALL_FIFO_SIZE (1024 / 4) |
| 185 | +#define CONFIG_USB_DWC2_TX0_FIFO_SIZE (64 / 4) |
| 186 | +#define CONFIG_USB_DWC2_TX1_FIFO_SIZE (64 / 4) |
| 187 | +#define CONFIG_USB_DWC2_TX2_FIFO_SIZE (64 / 4) |
| 188 | +#define CONFIG_USB_DWC2_TX3_FIFO_SIZE (64 / 4) |
| 189 | +// #define CONFIG_USB_DWC2_TX4_FIFO_SIZE (0 / 4) |
| 190 | +// #define CONFIG_USB_DWC2_TX5_FIFO_SIZE (0 / 4) |
| 191 | +// #define CONFIG_USB_DWC2_TX6_FIFO_SIZE (0 / 4) |
| 192 | +// #define CONFIG_USB_DWC2_TX7_FIFO_SIZE (0 / 4) |
| 193 | +// #define CONFIG_USB_DWC2_TX8_FIFO_SIZE (0 / 4) |
| 194 | + |
| 195 | +/* ---------------- MUSB Configuration ---------------- */ |
| 196 | +// #define CONFIG_USB_MUSB_SUNXI |
| 197 | + |
| 198 | +/* ================ USB Host Port Configuration ==================*/ |
| 199 | +#ifndef CONFIG_USBHOST_MAX_BUS |
| 200 | +#define CONFIG_USBHOST_MAX_BUS 1 |
| 201 | +#endif |
| 202 | + |
| 203 | +#ifndef CONFIG_USBHOST_PIPE_NUM |
| 204 | +#define CONFIG_USBHOST_PIPE_NUM 10 |
| 205 | +#endif |
| 206 | + |
| 207 | +/* ---------------- EHCI Configuration ---------------- */ |
| 208 | + |
| 209 | +#define CONFIG_USB_EHCI_HCCR_OFFSET (0x0) |
| 210 | +#define CONFIG_USB_EHCI_FRAME_LIST_SIZE 1024 |
| 211 | +#define CONFIG_USB_EHCI_QH_NUM CONFIG_USBHOST_PIPE_NUM |
| 212 | +#define CONFIG_USB_EHCI_QTD_NUM 3 |
| 213 | +#define CONFIG_USB_EHCI_ITD_NUM 20 |
| 214 | +// #define CONFIG_USB_EHCI_HCOR_RESERVED_DISABLE |
| 215 | +// #define CONFIG_USB_EHCI_CONFIGFLAG |
| 216 | +// #define CONFIG_USB_EHCI_ISO |
| 217 | +// #define CONFIG_USB_EHCI_WITH_OHCI |
| 218 | + |
| 219 | +/* ---------------- OHCI Configuration ---------------- */ |
| 220 | +#define CONFIG_USB_OHCI_HCOR_OFFSET (0x0) |
| 221 | + |
| 222 | +/* ---------------- XHCI Configuration ---------------- */ |
| 223 | +#define CONFIG_USB_XHCI_HCCR_OFFSET (0x0) |
| 224 | + |
| 225 | +/* ---------------- DWC2 Configuration ---------------- */ |
| 226 | +/* largest non-periodic USB packet used / 4 */ |
| 227 | +// #define CONFIG_USB_DWC2_NPTX_FIFO_SIZE (512 / 4) |
| 228 | +/* largest periodic USB packet used / 4 */ |
| 229 | +// #define CONFIG_USB_DWC2_PTX_FIFO_SIZE (1024 / 4) |
| 230 | +/* |
| 231 | + * (largest USB packet used / 4) + 1 for status information + 1 transfer complete + |
| 232 | + * 1 location each for Bulk/Control endpoint for handling NAK/NYET scenario |
| 233 | + */ |
| 234 | +// #define CONFIG_USB_DWC2_RX_FIFO_SIZE ((1012 - CONFIG_USB_DWC2_NPTX_FIFO_SIZE - CONFIG_USB_DWC2_PTX_FIFO_SIZE)) |
| 235 | + |
| 236 | +/* ---------------- MUSB Configuration ---------------- */ |
| 237 | +// #define CONFIG_USB_MUSB_SUNXI |
| 238 | + |
| 239 | +#endif |
0 commit comments