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 0x001002 10 11 /* ================ USB common Configuration ================ */ 12 13 #define CONFIG_USB_PRINTF(...) printf(__VA_ARGS__) 14 15 #define usb_malloc(size) malloc(size) 16 #define usb_free(ptr) free(ptr) 17 18 #ifndef CONFIG_USB_DBG_LEVEL 19 #define CONFIG_USB_DBG_LEVEL USB_DBG_INFO 20 #endif 21 22 /* Enable print with color */ 23 #define CONFIG_USB_PRINTF_COLOR_ENABLE 24 25 /* data align size when use dma */ 26 #ifndef CONFIG_USB_ALIGN_SIZE 27 #define CONFIG_USB_ALIGN_SIZE 4 28 #endif 29 30 /* attribute data into no cache ram */ 31 #define USB_NOCACHE_RAM_SECTION __attribute__((section(".noncacheable"))) 32 33 /* ================= USB Device Stack Configuration ================ */ 34 35 /* Ep0 max transfer buffer, specially for receiving data from ep0 out */ 36 #define CONFIG_USBDEV_REQUEST_BUFFER_LEN 256 37 38 /* Setup packet log for debug */ 39 // #define CONFIG_USBDEV_SETUP_LOG_PRINT 40 41 /* Check if the input descriptor is correct */ 42 // #define CONFIG_USBDEV_DESC_CHECK 43 44 /* Enable test mode */ 45 // #define CONFIG_USBDEV_TEST_MODE 46 47 #ifndef CONFIG_USBDEV_MSC_BLOCK_SIZE 48 #define CONFIG_USBDEV_MSC_BLOCK_SIZE 512 49 #endif 50 51 #ifndef CONFIG_USBDEV_MSC_MANUFACTURER_STRING 52 #define CONFIG_USBDEV_MSC_MANUFACTURER_STRING "" 53 #endif 54 55 #ifndef CONFIG_USBDEV_MSC_PRODUCT_STRING 56 #define CONFIG_USBDEV_MSC_PRODUCT_STRING "" 57 #endif 58 59 #ifndef CONFIG_USBDEV_MSC_VERSION_STRING 60 #define CONFIG_USBDEV_MSC_VERSION_STRING "0.01" 61 #endif 62 63 // #define CONFIG_USBDEV_MSC_THREAD 64 65 #ifndef CONFIG_USBDEV_MSC_PRIO 66 #define CONFIG_USBDEV_MSC_PRIO 4 67 #endif 68 69 #ifndef CONFIG_USBDEV_MSC_STACKSIZE 70 #define CONFIG_USBDEV_MSC_STACKSIZE 2048 71 #endif 72 73 #ifndef CONFIG_USBDEV_RNDIS_RESP_BUFFER_SIZE 74 #define CONFIG_USBDEV_RNDIS_RESP_BUFFER_SIZE 156 75 #endif 76 77 #ifndef CONFIG_USBDEV_RNDIS_ETH_MAX_FRAME_SIZE 78 #define CONFIG_USBDEV_RNDIS_ETH_MAX_FRAME_SIZE 1536 79 #endif 80 81 #ifndef CONFIG_USBDEV_RNDIS_VENDOR_ID 82 #define CONFIG_USBDEV_RNDIS_VENDOR_ID 0x0000ffff 83 #endif 84 85 #ifndef CONFIG_USBDEV_RNDIS_VENDOR_DESC 86 #define CONFIG_USBDEV_RNDIS_VENDOR_DESC "CherryUSB" 87 #endif 88 89 #define CONFIG_USBDEV_RNDIS_USING_LWIP 90 91 /* ================ USB HOST Stack Configuration ================== */ 92 93 #define CONFIG_USBHOST_MAX_RHPORTS 1 94 #define CONFIG_USBHOST_MAX_EXTHUBS 1 95 #define CONFIG_USBHOST_MAX_EHPORTS 4 96 #define CONFIG_USBHOST_MAX_INTERFACES 6 97 #define CONFIG_USBHOST_MAX_INTF_ALTSETTINGS 1 98 #define CONFIG_USBHOST_MAX_ENDPOINTS 4 99 100 #define CONFIG_USBHOST_MAX_CDC_ACM_CLASS 4 101 #define CONFIG_USBHOST_MAX_HID_CLASS 4 102 #define CONFIG_USBHOST_MAX_MSC_CLASS 2 103 #define CONFIG_USBHOST_MAX_AUDIO_CLASS 1 104 #define CONFIG_USBHOST_MAX_VIDEO_CLASS 1 105 106 #define CONFIG_USBHOST_DEV_NAMELEN 16 107 108 #ifndef CONFIG_USBHOST_PSC_PRIO 109 #define CONFIG_USBHOST_PSC_PRIO 4 110 #endif 111 #ifndef CONFIG_USBHOST_PSC_STACKSIZE 112 #define CONFIG_USBHOST_PSC_STACKSIZE 2048 113 #endif 114 115 //#define CONFIG_USBHOST_GET_STRING_DESC 116 117 // #define CONFIG_USBHOST_MSOS_ENABLE 118 #define CONFIG_USBHOST_MSOS_VENDOR_CODE 0x00 119 120 /* Ep0 max transfer buffer */ 121 #define CONFIG_USBHOST_REQUEST_BUFFER_LEN 512 122 123 #ifndef CONFIG_USBHOST_CONTROL_TRANSFER_TIMEOUT 124 #define CONFIG_USBHOST_CONTROL_TRANSFER_TIMEOUT 500 125 #endif 126 127 #ifndef CONFIG_USBHOST_MSC_TIMEOUT 128 #define CONFIG_USBHOST_MSC_TIMEOUT 5000 129 #endif 130 131 /* ================ USB Device Port Configuration ================*/ 132 133 //#define USBD_IRQHandler USBD_IRQHandler 134 //#define USB_BASE (0x40080000UL) 135 //#define USB_NUM_BIDIR_ENDPOINTS 4 136 137 /* ================ USB Host Port Configuration ==================*/ 138 139 #define CONFIG_USBHOST_PIPE_NUM 10 140 141 /* ================ EHCI Configuration ================ */ 142 143 #define CONFIG_USB_EHCI_HCCR_BASE (0x20072000) 144 #define CONFIG_USB_EHCI_HCOR_BASE (0x20072000 + 0x10) 145 #define CONFIG_USB_EHCI_FRAME_LIST_SIZE 1024 146 // #define CONFIG_USB_EHCI_INFO_ENABLE 147 // #define CONFIG_USB_EHCI_HCOR_RESERVED_DISABLE 148 // #define CONFIG_USB_EHCI_CONFIGFLAG 149 // #define CONFIG_USB_EHCI_PORT_POWER 150 151 #endif 152