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