1 /*************************************************************************** 2 * Copyright (c) 2024 Microsoft Corporation 3 * 4 * This program and the accompanying materials are made available under the 5 * terms of the MIT License which is available at 6 * https://opensource.org/licenses/MIT. 7 * 8 * SPDX-License-Identifier: MIT 9 **************************************************************************/ 10 11 12 /**************************************************************************/ 13 /**************************************************************************/ 14 /** */ 15 /** USBX Component */ 16 /** */ 17 /** User Specific */ 18 /** */ 19 /**************************************************************************/ 20 /**************************************************************************/ 21 22 23 /**************************************************************************/ 24 /* */ 25 /* PORT SPECIFIC C INFORMATION RELEASE */ 26 /* */ 27 /* ux_user.h PORTABLE C */ 28 /* 6.x */ 29 /* */ 30 /* AUTHOR */ 31 /* */ 32 /* Chaoqiong Xiao, Microsoft Corporation */ 33 /* */ 34 /* DESCRIPTION */ 35 /* */ 36 /* This file contains user defines for configuring USBX in specific */ 37 /* ways. This file will have an effect only if the application and */ 38 /* USBX library are built with UX_INCLUDE_USER_DEFINE_FILE defined. */ 39 /* Note that all the defines in this file may also be made on the */ 40 /* command line when building USBX library and application objects. */ 41 /* */ 42 /* RELEASE HISTORY */ 43 /* */ 44 /* DATE NAME DESCRIPTION */ 45 /* */ 46 /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */ 47 /* 09-30-2020 Chaoqiong Xiao Modified comment(s), */ 48 /* resulting in version 6.1 */ 49 /* xx-xx-xxxx Chaoqiong Xiao Modified comment(s), */ 50 /* added standalone supoort, */ 51 /* resulting in version 6.x */ 52 /* */ 53 /**************************************************************************/ 54 55 #ifndef UX_USER_H 56 #define UX_USER_H 57 58 59 /* Define various build options for the USBX port. The application should either make changes 60 here by commenting or un-commenting the conditional compilation defined OR supply the defines 61 though the compiler's equivalent of the -D option. */ 62 /* #define UX_THREAD_STACK_SIZE (2 * 1024) */ 63 64 /* Define USBX Host Enum Thread Stack Size. The default is to use UX_THREAD_STACK_SIZE */ 65 /* 66 #define UX_HOST_ENUM_THREAD_STACK_SIZE UX_THREAD_STACK_SIZE 67 */ 68 69 70 /* Define USBX Host Thread Stack Size. The default is to use UX_THREAD_STACK_SIZE */ 71 /* 72 #define UX_HOST_HCD_THREAD_STACK_SIZE UX_THREAD_STACK_SIZE 73 */ 74 75 /* Define USBX Host HNP Polling Thread Stack Size. The default is to use UX_THREAD_STACK_SIZE */ 76 /* 77 #define UX_HOST_HNP_POLLING_THREAD_STACK UX_THREAD_STACK_SIZE 78 */ 79 80 /* Override various options with default values already assigned in ux_api.h or ux_port.h. Please 81 also refer to ux_port.h for descriptions on each of these options. */ 82 83 /* Defined, this value represents how many ticks per seconds for a specific hardware platform. 84 The default is 1000 indicating 1 tick per millisecond. */ 85 86 /* #define UX_PERIODIC_RATE 1000 87 */ 88 #ifdef TX_TIMER_TICKS_PER_SECOND 89 #define UX_PERIODIC_RATE (TX_TIMER_TICKS_PER_SECOND) 90 #else 91 #define UX_PERIODIC_RATE (100ul) 92 #endif 93 94 /* Defined, this value is the maximum number of classes that can be loaded by USBX. This value 95 represents the class container and not the number of instances of a class. For instance, if a 96 particular implementation of USBX needs the hub class, the printer class, and the storage 97 class, then the UX_MAX_CLASSES value can be set to 3 regardless of the number of devices 98 that belong to these classes. */ 99 100 /* #define UX_MAX_CLASSES 3 101 */ 102 103 104 /* Defined, this value is the maximum number of classes in the device stack that can be loaded by 105 USBX. */ 106 107 /* #define UX_MAX_SLAVE_CLASS_DRIVER 1 108 */ 109 110 /* Defined, this value is the maximum number of interfaces in the device framework. */ 111 112 /* #define UX_MAX_SLAVE_INTERFACES 16 113 */ 114 115 /* Defined, this value represents the number of different host controllers available in the system. 116 For USB 1.1 support, this value will usually be 1. For USB 2.0 support, this value can be more 117 than 1. This value represents the number of concurrent host controllers running at the same time. 118 If for instance there are two instances of OHCI running, or one EHCI and one OHCI controller 119 running, the UX_MAX_HCD should be set to 2. */ 120 121 /* #define UX_MAX_HCD 1 122 */ 123 124 125 /* Defined, this value represents the maximum number of devices that can be attached to the USB. 126 Normally, the theoretical maximum number on a single USB is 127 devices. This value can be 127 scaled down to conserve memory. Note that this value represents the total number of devices 128 regardless of the number of USB buses in the system. */ 129 130 /* #define UX_MAX_DEVICES 127 131 */ 132 133 134 /* Defined, this value represents the current number of SCSI logical units represented in the device 135 storage class driver. */ 136 137 /* #define UX_MAX_SLAVE_LUN 1 138 */ 139 140 141 /* Defined, this value represents the maximum number of SCSI logical units represented in the 142 host storage class driver. */ 143 144 #ifndef UX_MAX_HOST_LUN 145 #define UX_MAX_HOST_LUN 2 /* for test. */ 146 #endif 147 148 149 /* Defined, this value represents the maximum number of bytes received on a control endpoint in 150 the device stack. The default is 256 bytes but can be reduced in memory constraint environments. */ 151 152 #ifndef UX_SLAVE_REQUEST_CONTROL_MAX_LENGTH 153 #define UX_SLAVE_REQUEST_CONTROL_MAX_LENGTH 248 /* for test. */ 154 #endif 155 156 157 /* Defined, this value represents the maximum number of bytes that can be received or transmitted 158 on any endpoint. This value cannot be less than the maximum packet size of any endpoint. The default 159 is 4096 bytes but can be reduced in memory constraint environments. For cd-rom support in the storage 160 class, this value cannot be less than 2048. */ 161 162 /* #define UX_SLAVE_REQUEST_DATA_MAX_LENGTH (1024 * 2) */ 163 164 165 /* Defined, this value includes code to handle storage Multi-Media Commands (MMC). E.g., DVD-ROM. 166 */ 167 168 /* #define UX_SLAVE_CLASS_STORAGE_INCLUDE_MMC */ 169 170 171 /* Defined, this value represents the maximum number of bytes that a storage payload can send/receive. 172 The default is 8K bytes but can be reduced in memory constraint environments. */ 173 174 /* #define UX_HOST_CLASS_STORAGE_MEMORY_BUFFER_SIZE (1024 * 8) */ 175 176 /* Define USBX Mass Storage Thread Stack Size. The default is to use UX_THREAD_STACK_SIZE. */ 177 178 /* #define UX_HOST_CLASS_STORAGE_THREAD_STACK_SIZE UX_THREAD_STACK_SIZE 179 */ 180 181 /* Defined, this value represents the maximum number of Ed, regular TDs and Isochronous TDs. These values 182 depend on the type of host controller and can be reduced in memory constraint environments. */ 183 184 #ifndef UX_MAX_ED 185 #define UX_MAX_ED 80 /* for test */ 186 #endif 187 #ifndef UX_MAX_TD 188 #define UX_MAX_TD 128 /* for test */ 189 #endif 190 #ifndef UX_MAX_ISO_TD 191 #define UX_MAX_ISO_TD 8 /* for test */ 192 #endif 193 194 /* Defined, this value represents the maximum size of the HID decompressed buffer. This cannot be determined 195 in advance so we allocate a big block, usually 4K but for simple HID devices like keyboard and mouse 196 it can be reduced a lot. */ 197 198 /* #define UX_HOST_CLASS_HID_DECOMPRESSION_BUFFER 4096 */ 199 200 /* Defined, this value represents the maximum number of HID usages for a HID device. 201 Default is 2048 but for simple HID devices like keyboard and mouse it can be reduced a lot. */ 202 203 /* #define UX_HOST_CLASS_HID_USAGES 2048 */ 204 205 206 /* By default, each key in each HID report from the device is reported by ux_host_class_hid_keyboard_key_get 207 (a HID report from the device is received whenever there is a change in a key state i.e. when a key is pressed 208 or released. The report contains every key that is down). There are limitations to this method such as not being 209 able to determine when a key has been released. 210 211 Defined, this value causes ux_host_class_hid_keyboard_key_get to only report key changes i.e. key presses 212 and key releases. */ 213 214 /* #define UX_HOST_CLASS_HID_KEYBOARD_EVENTS_KEY_CHANGES_MODE */ 215 216 /* Works when UX_HOST_CLASS_HID_KEYBOARD_EVENTS_KEY_CHANGES_MODE is defined. 217 218 Defined, this value causes ux_host_class_hid_keyboard_key_get to only report key pressed/down changes; 219 key released/up changes are not reported. 220 */ 221 222 /* #define UX_HOST_CLASS_HID_KEYBOARD_EVENTS_KEY_CHANGES_MODE_REPORT_KEY_DOWN_ONLY */ 223 224 /* Works when UX_HOST_CLASS_HID_KEYBOARD_EVENTS_KEY_CHANGES_MODE is defined. 225 226 Defined, this value causes ux_host_class_hid_keyboard_key_get to report lock key (CapsLock/NumLock/ScrollLock) changes. 227 */ 228 229 /* #define UX_HOST_CLASS_HID_KEYBOARD_EVENTS_KEY_CHANGES_MODE_REPORT_LOCK_KEYS */ 230 231 /* Works when UX_HOST_CLASS_HID_KEYBOARD_EVENTS_KEY_CHANGES_MODE is defined. 232 233 Defined, this value causes ux_host_class_hid_keyboard_key_get to report modifier key (Ctrl/Alt/Shift/GUI) changes. 234 */ 235 236 /* #define UX_HOST_CLASS_HID_KEYBOARD_EVENTS_KEY_CHANGES_MODE_REPORT_MODIFIER_KEYS */ 237 238 239 /* Defined, this value represents the maximum number of media for the host storage class. 240 Default is 8 but for memory contrained resource systems this can ne reduced to 1. */ 241 242 #ifndef UX_HOST_CLASS_STORAGE_MAX_MEDIA 243 #define UX_HOST_CLASS_STORAGE_MAX_MEDIA 2 /* for test. */ 244 #endif 245 246 /* Defined, this value includes code to handle storage devices that use the CB 247 or CBI protocol (such as floppy disks). It is off by default because these 248 protocols are obsolete, being superseded by the Bulk Only Transport (BOT) protocol 249 which virtually all modern storage devices use. 250 */ 251 252 /* #define UX_HOST_CLASS_STORAGE_INCLUDE_LEGACY_PROTOCOL_SUPPORT */ 253 254 /* Defined, this value forces the memory allocation scheme to enforce alignement 255 of memory with the UX_SAFE_ALIGN field. 256 */ 257 258 /* #define UX_ENFORCE_SAFE_ALIGNMENT */ 259 260 /* Defined, this value represents the number of packets in the CDC_ECM device class. 261 The default is 16. 262 */ 263 264 /* #define UX_DEVICE_CLASS_CDC_ECM_NX_PKPOOL_ENTRIES 4 */ 265 266 /* Defined, this value represents the number of packets in the CDC_ECM host class. 267 The default is 16. 268 */ 269 270 /* #define UX_HOST_CLASS_CDC_ECM_NX_PKPOOL_ENTRIES 16 */ 271 272 /* Defined, this value represents the number of milliseconds to wait for packet 273 allocation until invoking the application's error callback and retrying. 274 The default is 1000 milliseconds. 275 */ 276 277 /* #define UX_HOST_CLASS_CDC_ECM_PACKET_POOL_WAIT 10 */ 278 279 /* Defined, this value represents the number of milliseconds to wait for packet 280 allocation until invoking the application's error callback and retrying. 281 */ 282 283 /* #define UX_DEVICE_CLASS_CDC_ECM_PACKET_POOL_WAIT 10 */ 284 285 /* Defined, this value represents the the maximum length of HID reports on the 286 device. 287 */ 288 289 /* #define UX_DEVICE_CLASS_HID_EVENT_BUFFER_LENGTH 64 */ 290 291 /* Defined, this value represents the the maximum number of HID events/reports 292 that can be queued at once. 293 */ 294 295 /* #define UX_DEVICE_CLASS_HID_MAX_EVENTS_QUEUE 8 */ 296 297 /* Defined, this value will only enable the host side of usbx. */ 298 /* #define UX_HOST_SIDE_ONLY */ 299 300 /* Defined, this value will only enable the device side of usbx. */ 301 /* #define UX_DEVICE_SIDE_ONLY */ 302 303 /* Defined, this value will include the OTG polling thread. OTG can only be active if both host/device are present. 304 */ 305 306 #ifndef UX_HOST_SIDE_ONLY 307 #ifndef UX_DEVICE_SIDE_ONLY 308 309 /* #define UX_OTG_SUPPORT */ 310 311 #endif 312 #endif 313 314 /* Defined, this value represents the maximum size of single tansfers for the SCSI data phase. 315 */ 316 317 /* #define UX_HOST_CLASS_STORAGE_MAX_TRANSFER_SIZE (1024 * 1) */ 318 319 /* Defined, this value represents the size of the log pool. 320 */ 321 #define UX_DEBUG_LOG_SIZE (1024 * 16) 322 323 324 /* Defined, this disables the assert checks inside usbx. */ 325 #ifndef UX_DISABLE_ASSERT 326 #define UX_ENABLE_ASSERT 327 #endif 328 329 /* Defined, this defines the assert action taken when failure detected. By default 330 it halts without any output. */ 331 void ux_test_assert_hit(char* file, int line); 332 #define UX_ASSERT_FAIL ux_test_assert_hit(__FILE__, __LINE__); 333 334 335 /* DEBUG includes and macros for a specific platform go here. */ 336 #ifdef UX_INCLUDE_USER_DEFINE_BSP 337 #include "usb_bsp.h" 338 #include "usbh_hcs.h" 339 #include "usbh_stdreq.h" 340 #include "usbh_core.h" 341 #endif 342 343 #endif 344 345