HPM APP
HPMicro Application solution
usb_config.h
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2022, sakumisu
3
* Copyright (c) 2022-2024, HPMicro
4
*
5
* SPDX-License-Identifier: Apache-2.0
6
*/
7
#ifndef CHERRYUSB_CONFIG_H
8
#define CHERRYUSB_CONFIG_H
9
10
#include "hpm_soc_feature.h"
11
12
/* ================ USB common Configuration ================ */
13
14
#define CONFIG_USB_PRINTF(...) printf(__VA_ARGS__)
15
16
#define usb_malloc(size) malloc(size)
17
#define usb_free(ptr) free(ptr)
18
19
#ifndef CONFIG_USB_DBG_LEVEL
20
#define CONFIG_USB_DBG_LEVEL USB_DBG_INFO
21
#endif
22
23
#ifdef CONFIG_USB_DEVICE_FS
24
#undef CONFIG_USB_HS
25
#else
26
#define CONFIG_USB_HS
27
#endif
28
29
/* Enable print with color */
30
#define CONFIG_USB_PRINTF_COLOR_ENABLE
31
32
/* data align size when use dma */
33
#ifndef CONFIG_USB_ALIGN_SIZE
34
#define CONFIG_USB_ALIGN_SIZE 4
35
#endif
36
37
/* descriptor common define */
38
#define CONFIG_USBDEV_ADVANCE_DESC
39
#define USBD_VID 0x34B7
/* HPMicro VID */
40
#define USBD_PID 0xFFFF
41
#define USBD_MAX_POWER 200
42
43
/* attribute data into no cache ram */
44
#define USB_NOCACHE_RAM_SECTION __attribute__((section(".noncacheable"
)))
45
46
/* ================= USB Device Stack Configuration ================ */
47
48
/* Ep0 in and out transfer buffer */
49
#ifndef CONFIG_USBDEV_REQUEST_BUFFER_LEN
50
#define CONFIG_USBDEV_REQUEST_BUFFER_LEN 512
51
#endif
52
53
/* Setup packet log for debug */
54
/* #define CONFIG_USBDEV_SETUP_LOG_PRINT */
55
56
/* Send ep0 in data from user buffer instead of copying into ep0 reqdata
57
* Please note that user buffer must be aligned with CONFIG_USB_ALIGN_SIZE
58
*/
59
/* #define CONFIG_USBDEV_EP0_INDATA_NO_COPY */
60
61
/* Check if the input descriptor is correct */
62
/* #define CONFIG_USBDEV_DESC_CHECK */
63
64
/* Enable test mode */
65
/* #define CONFIG_USBDEV_TEST_MODE */
66
67
#ifndef CONFIG_USBDEV_MSC_MAX_LUN
68
#define CONFIG_USBDEV_MSC_MAX_LUN 1
69
#endif
70
71
#ifndef CONFIG_USBDEV_MSC_MAX_BUFSIZE
72
#define CONFIG_USBDEV_MSC_MAX_BUFSIZE 512
73
#endif
74
75
#ifndef CONFIG_USBDEV_MSC_MANUFACTURER_STRING
76
#define CONFIG_USBDEV_MSC_MANUFACTURER_STRING ""
77
#endif
78
79
#ifndef CONFIG_USBDEV_MSC_PRODUCT_STRING
80
#define CONFIG_USBDEV_MSC_PRODUCT_STRING ""
81
#endif
82
83
#ifndef CONFIG_USBDEV_MSC_VERSION_STRING
84
#define CONFIG_USBDEV_MSC_VERSION_STRING "0.01"
85
#endif
86
87
/* #define CONFIG_USBDEV_MSC_THREAD */
88
89
#ifndef CONFIG_USBDEV_MSC_PRIO
90
#define CONFIG_USBDEV_MSC_PRIO 4
91
#endif
92
93
#ifndef CONFIG_USBDEV_MSC_STACKSIZE
94
#define CONFIG_USBDEV_MSC_STACKSIZE 2048
95
#endif
96
97
#ifndef CONFIG_USBDEV_RNDIS_RESP_BUFFER_SIZE
98
#define CONFIG_USBDEV_RNDIS_RESP_BUFFER_SIZE 156
99
#endif
100
101
/* rndis transfer buffer size, must be a multiple of (1536 + 44)*/
102
#ifndef CONFIG_USBDEV_RNDIS_ETH_MAX_FRAME_SIZE
103
#define CONFIG_USBDEV_RNDIS_ETH_MAX_FRAME_SIZE 1580
104
#endif
105
106
#ifndef CONFIG_USBDEV_RNDIS_VENDOR_ID
107
#define CONFIG_USBDEV_RNDIS_VENDOR_ID 0x0000ffff
108
#endif
109
110
#ifndef CONFIG_USBDEV_RNDIS_VENDOR_DESC
111
#define CONFIG_USBDEV_RNDIS_VENDOR_DESC "HPMicro"
112
#endif
113
114
#define CONFIG_USBDEV_RNDIS_USING_LWIP
115
116
/* ================ USB HOST Stack Configuration ================== */
117
118
#define CONFIG_USBHOST_MAX_RHPORTS 1
119
#define CONFIG_USBHOST_MAX_EXTHUBS 1
120
#define CONFIG_USBHOST_MAX_EHPORTS 4
121
#define CONFIG_USBHOST_MAX_INTERFACES 8
122
#define CONFIG_USBHOST_MAX_INTF_ALTSETTINGS 2
123
#define CONFIG_USBHOST_MAX_ENDPOINTS 8
124
125
#define CONFIG_USBHOST_MAX_CDC_ACM_CLASS 4
126
#define CONFIG_USBHOST_MAX_HID_CLASS 4
127
#define CONFIG_USBHOST_MAX_MSC_CLASS 2
128
#define CONFIG_USBHOST_MAX_AUDIO_CLASS 1
129
#define CONFIG_USBHOST_MAX_VIDEO_CLASS 1
130
131
#define CONFIG_USBHOST_DEV_NAMELEN 16
132
133
#ifndef CONFIG_USBHOST_PSC_PRIO
134
#define CONFIG_USBHOST_PSC_PRIO 0
135
#endif
136
#ifndef CONFIG_USBHOST_PSC_STACKSIZE
137
#define CONFIG_USBHOST_PSC_STACKSIZE 2048
138
#endif
139
140
/* #define CONFIG_USBHOST_GET_STRING_DESC */
141
142
/* #define CONFIG_USBHOST_MSOS_ENABLE */
143
#ifndef CONFIG_USBHOST_MSOS_VENDOR_CODE
144
#define CONFIG_USBHOST_MSOS_VENDOR_CODE 0x00
145
#endif
146
147
/* Ep0 max transfer buffer */
148
#ifndef CONFIG_USBHOST_REQUEST_BUFFER_LEN
149
#define CONFIG_USBHOST_REQUEST_BUFFER_LEN 512
150
#endif
151
152
#ifndef CONFIG_USBHOST_CONTROL_TRANSFER_TIMEOUT
153
#define CONFIG_USBHOST_CONTROL_TRANSFER_TIMEOUT 500
154
#endif
155
156
#ifndef CONFIG_USBHOST_MSC_TIMEOUT
157
#define CONFIG_USBHOST_MSC_TIMEOUT 5000
158
#endif
159
160
/* This parameter affects usb performance, and depends on (TCP_WND)tcp eceive windows size,
161
* you can change to 2K ~ 16K and must be larger than TCP RX windows size in order to avoid being overflow.
162
*/
163
#ifndef CONFIG_USBHOST_RNDIS_ETH_MAX_RX_SIZE
164
#define CONFIG_USBHOST_RNDIS_ETH_MAX_RX_SIZE (2048)
165
#endif
166
167
/* Because lwip do not support multi pbuf at a time, so increasing this variable has no performance improvement */
168
#ifndef CONFIG_USBHOST_RNDIS_ETH_MAX_TX_SIZE
169
#define CONFIG_USBHOST_RNDIS_ETH_MAX_TX_SIZE (2048)
170
#endif
171
172
/* This parameter affects usb performance, and depends on (TCP_WND)tcp eceive windows size,
173
* you can change to 2K ~ 16K and must be larger than TCP RX windows size in order to avoid being overflow.
174
*/
175
#ifndef CONFIG_USBHOST_CDC_NCM_ETH_MAX_RX_SIZE
176
#define CONFIG_USBHOST_CDC_NCM_ETH_MAX_RX_SIZE (2048)
177
#endif
178
/* Because lwip do not support multi pbuf at a time, so increasing this variable has no performance improvement */
179
#ifndef CONFIG_USBHOST_CDC_NCM_ETH_MAX_TX_SIZE
180
#define CONFIG_USBHOST_CDC_NCM_ETH_MAX_TX_SIZE (2048)
181
#endif
182
183
/* This parameter affects usb performance, and depends on (TCP_WND)tcp eceive windows size,
184
* you can change to 2K ~ 16K and must be larger than TCP RX windows size in order to avoid being overflow.
185
*/
186
#ifndef CONFIG_USBHOST_RTL8152_ETH_MAX_RX_SIZE
187
#define CONFIG_USBHOST_RTL8152_ETH_MAX_RX_SIZE (2048)
188
#endif
189
/* Because lwip do not support multi pbuf at a time, so increasing this variable has no performance improvement */
190
#ifndef CONFIG_USBHOST_RTL8152_ETH_MAX_TX_SIZE
191
#define CONFIG_USBHOST_RTL8152_ETH_MAX_TX_SIZE (2048)
192
#endif
193
194
#define CONFIG_USBHOST_BLUETOOTH_HCI_H4
195
/* #define CONFIG_USBHOST_BLUETOOTH_HCI_LOG */
196
197
#ifndef CONFIG_USBHOST_BLUETOOTH_TX_SIZE
198
#define CONFIG_USBHOST_BLUETOOTH_TX_SIZE 2048
199
#endif
200
#ifndef CONFIG_USBHOST_BLUETOOTH_RX_SIZE
201
#define CONFIG_USBHOST_BLUETOOTH_RX_SIZE 2048
202
#endif
203
204
/* ================ USB Device Port Configuration ================*/
205
206
#define CONFIG_USBDEV_MAX_BUS USB_SOC_MAX_COUNT
207
208
#ifndef CONFIG_USBDEV_EP_NUM
209
#define CONFIG_USBDEV_EP_NUM USB_SOC_DCD_MAX_ENDPOINT_COUNT
210
#endif
211
212
#ifndef CONFIG_HPM_USBD_BASE
213
#define CONFIG_HPM_USBD_BASE HPM_USB0
214
#endif
215
#ifndef CONFIG_HPM_USBD_IRQn
216
#define CONFIG_HPM_USBD_IRQn IRQn_USB0
217
#endif
218
219
/* ================ USB Host Port Configuration ==================*/
220
#define CONFIG_USBHOST_MAX_BUS USB_SOC_MAX_COUNT
221
#define CONFIG_USBHOST_PIPE_NUM 5
222
223
#ifndef CONFIG_HPM_USBH_BASE
224
#define CONFIG_HPM_USBH_BASE HPM_USB0_BASE
225
#endif
226
#ifndef CONFIG_HPM_USBH_IRQn
227
#define CONFIG_HPM_USBH_IRQn IRQn_USB0
228
#endif
229
230
/* ================ EHCI Configuration ================ */
231
232
#define CONFIG_USB_EHCI_HPMICRO (1)
233
#define CONFIG_USB_EHCI_HCCR_OFFSET (0x100u)
234
#define CONFIG_USB_EHCI_FRAME_LIST_SIZE 1024
235
#define CONFIG_USB_EHCI_QTD_NUM 8
236
237
#endif
apps
monitor_adc
software
hpm_monitor
inc
config
usb_config.h
Generated on Thu Dec 25 2025 10:02:22 for HPM APP by
1.9.1