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+
10+ #include <rtthread.h>
11+
12+ /* ================ USB common Configuration ================ */
13+ #define CONFIG_USB_PRINTF (...) rt_kprintf(__VA_ARGS__)
14+ #define usb_malloc (size ) malloc(size)
15+ #define usb_free (ptr ) free(ptr)
16+
17+ #ifndef CONFIG_USB_DBG_LEVEL
18+ //#define CONFIG_USB_DBG_LEVEL USB_DBG_INFO
19+ #define CONFIG_USB_DBG_LEVEL 3
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+ #ifndef CONFIG_USBDEV_MSC_MAX_LUN
39+ #define CONFIG_USBDEV_MSC_MAX_LUN 1
40+ #endif
41+
42+ #ifndef CONFIG_USBDEV_MSC_MAX_BUFSIZE
43+ #define CONFIG_USBDEV_MSC_MAX_BUFSIZE 512
44+ #endif
45+
46+ #ifndef CONFIG_USBDEV_MSC_MANUFACTURER_STRING
47+ #define CONFIG_USBDEV_MSC_MANUFACTURER_STRING ""
48+ #endif
49+
50+ #ifndef CONFIG_USBDEV_MSC_PRODUCT_STRING
51+ #define CONFIG_USBDEV_MSC_PRODUCT_STRING ""
52+ #endif
53+
54+ #ifndef CONFIG_USBDEV_MSC_VERSION_STRING
55+ #define CONFIG_USBDEV_MSC_VERSION_STRING "0.01"
56+ #endif
57+
58+ #ifndef CONFIG_USBDEV_MSC_PRIO
59+ #define CONFIG_USBDEV_MSC_PRIO 4
60+ #endif
61+
62+ #ifndef CONFIG_USBDEV_MSC_STACKSIZE
63+ #define CONFIG_USBDEV_MSC_STACKSIZE 2048
64+ #endif
65+
66+ #ifndef CONFIG_USBDEV_RNDIS_RESP_BUFFER_SIZE
67+ #define CONFIG_USBDEV_RNDIS_RESP_BUFFER_SIZE 156
68+ #endif
69+
70+ #ifndef CONFIG_USBDEV_RNDIS_ETH_MAX_FRAME_SIZE
71+ #define CONFIG_USBDEV_RNDIS_ETH_MAX_FRAME_SIZE 1536
72+ #endif
73+
74+ #ifndef CONFIG_USBDEV_RNDIS_VENDOR_ID
75+ #define CONFIG_USBDEV_RNDIS_VENDOR_ID 0x0000ffff
76+ #endif
77+
78+ #ifndef CONFIG_USBDEV_RNDIS_VENDOR_DESC
79+ #define CONFIG_USBDEV_RNDIS_VENDOR_DESC "CherryUSB"
80+ #endif
81+
82+ #define CONFIG_USBDEV_RNDIS_USING_LWIP
83+
84+ /* ================ USB HOST Stack Configuration ================== */
85+
86+ #define CONFIG_USBHOST_MAX_RHPORTS 1
87+ #define CONFIG_USBHOST_MAX_EXTHUBS 1
88+ #define CONFIG_USBHOST_MAX_EHPORTS 4
89+ #define CONFIG_USBHOST_MAX_INTERFACES 8
90+ #define CONFIG_USBHOST_MAX_INTF_ALTSETTINGS 8
91+ #define CONFIG_USBHOST_MAX_ENDPOINTS 4
92+
93+ #define CONFIG_USBHOST_MAX_CDC_ACM_CLASS 4
94+ #define CONFIG_USBHOST_MAX_HID_CLASS 4
95+ #define CONFIG_USBHOST_MAX_MSC_CLASS 2
96+ #define CONFIG_USBHOST_MAX_AUDIO_CLASS 1
97+ #define CONFIG_USBHOST_MAX_VIDEO_CLASS 1
98+
99+ #define CONFIG_USBHOST_DEV_NAMELEN 16
100+
101+ #ifndef CONFIG_USBHOST_PSC_PRIO
102+ #define CONFIG_USBHOST_PSC_PRIO 0
103+ #endif
104+ #ifndef CONFIG_USBHOST_PSC_STACKSIZE
105+ #define CONFIG_USBHOST_PSC_STACKSIZE 2048
106+ #endif
107+
108+ #define CONFIG_USBHOST_MSOS_VENDOR_CODE 0x00
109+
110+ /* Ep0 max transfer buffer */
111+ #define CONFIG_USBHOST_REQUEST_BUFFER_LEN 512
112+
113+ #ifndef CONFIG_USBHOST_CONTROL_TRANSFER_TIMEOUT
114+ #define CONFIG_USBHOST_CONTROL_TRANSFER_TIMEOUT 500
115+ #endif
116+
117+ #ifndef CONFIG_USBHOST_MSC_TIMEOUT
118+ #define CONFIG_USBHOST_MSC_TIMEOUT 5000
119+ #endif
120+
121+ /* ================ USB Device Port Configuration ================*/
122+ #define CONFIG_USBDEV_MAX_BUS 1
123+
124+ #define CONFIG_USBDEV_EP_NUM 8
125+ #define CONFIG_USBDEV_FSDEV_PMA_ACCESS 2
126+
127+ /* ================ USB Host Port Configuration ==================*/
128+
129+ #define CONFIG_USBHOST_PIPE_NUM 10
130+
131+ /* ================ EHCI Configuration ================ */
132+
133+ #define CONFIG_USB_EHCI_HCCR_BASE (0x20072000)
134+ #define CONFIG_USB_EHCI_HCOR_BASE (0x20072000 + 0x10)
135+ #define CONFIG_USB_EHCI_FRAME_LIST_SIZE 1024
136+
137+ #endif
0 commit comments