USB stack configuration
Device configuration
A device configuration file is set up for each example, such as:
<install_dir>/boards/twrk22f120m/usb_examples/usb_device_hid_mouse/bm/usb_device_config.h
This file is used to either enable or disable the USB class driver and to configure the interface type (high-speed or full speed). The object number is configurable either to decrease the memory usage or to meet specific requirements.
If the device stack configuration is changed, rebuild the example projects. For each device, follow these steps.
If the board is a Tower or Freedom platform, enable the following macros:
Enable #define USB_DEVICE_CONFIG_KHCI (0U) macro for full speed.
Enable #define USB_DEVICE_CONFIG_EHCI (0U) macro if the board supports high-speed.
Note: Only EHCI support pin detect feature.
If board is part of the LPC series, enable the following macros:
Enable #define USB_DEVICE_CONFIG_LPCIP3511FS (0U) macro for full speed.
Enable #define USB_DEVICE_CONFIG_LPCIP3511HS (0U) macro if the board supports high-speed.
Parent topic:USB stack configuration
Host configuration
A host configuration file is set up for each example, such as:
<install_dir>/boards/twrk22f120m/usb_examples/usb_host_hid_mouse/bm/usb_host_config.h
This file is used to either enable or disable the USB class driver. The object number is configurable either to decrease the memory usage or to meet specific requirements.
If the Host stack configuration is changed, rebuild the example projects.
For each Host, follow these steps.
If the board is a Tower for Freedom platform, enable the following macros:
Enable this macro for full speed.
#define USB_HOST_CONFIG_KHCI (0U)
Enable this macro if the board supports high-speed.
#define USB_HOST_CONFIG_EHCI (0U)
Note: Only EHCI support pin detect feature.
If board is part of the LPC series, enable the following macros:
Enable this macro for full speed.
#define USB_HOST_CONFIG_OHCI (0U)
Enable this macro if the board supports high-speed.
#define USB_HOST_CONFIG_IP3516HS (0U)
Parent topic:USB stack configuration
USB cache-related MACROs definitions
There are few MACROs in the USB stack to define USB data attributes.
USB_STACK_USE_DEDICATED_RAM
The following values are used to configure the USB stack to use dedicated RAM or not.
USB_STACK_DEDICATED_RAM_TYPE_BDT_GLOBAL - The USB device global variables (controller data and device stack data) are put into the USB-dedicated RAM.
USB_STACK_DEDICATED_RAM_TYPE_BDT - The USB device controller global variables (BDT data) are put into the USB-dedicated RAM.
0 - There is no USB-dedicated RAM.
USB_DEVICE_CONFIG_BUFFER_PROPERTY_CACHEABLE
The following values are used to configure the device stack cache to be enabled or not.
0: disabled
1: enable
This macro is not supported in the Cortex-M7 platforms.
USB_HOST_CONFIG_BUFFER_PROPERTY_CACHEABLE
The following values are used to configure host stack cache to be enabled or not.
0: disable
1: enable
This macro is not supported in the Cortex-M7 platforms.
Based on the above MACROs, the following cache-related MACROs are defined in the USB stack.
||USB_DEVICE_CONFIG_BUFFER_PROPERTY_CACHEABLE ||
USB_HOST_CONFIG_BUFFER_PROPERTY_CACHEABLE is true
|USB_DEVICE_CONFIG_BUFFER_PROPERTY_CACHEABLE ||
USB_HOST_CONFIG_BUFFER_PROPERTY_CACHEABLE is false
|
|USB_STACK_USE_DEDICATED_RAM’s Value| |DATA_SECTION_IS_CACHEABLE is true|DATA_SECTION_IS_CACHEABLE is false|
|USB_STACK_DEDICATED_RAM_TYPE_BDT_GLOBAL||USB_GLOBAL|dedicated ram, stack use only|
|USB_BDT|dedicated ram, stack use only|
|USB_CONTROLLER_DATA|NonCachable, stack use only|
|USB_DMA_NONINIT_DATA_ALIGN(n)|cachable ram and alignment|
|USB_DMA_INIT_DATA_ALIGN(n)|cachable ram and alignment|
||USB_GLOBAL|dedicated ram, stack use only|
|USB_BDT|dedicated ram, stack use only|
|USB_CONTROLLER_DATA|NonCachable, stack use only|
|USB_DMA_NONINIT_DATA_ALIGN(n)|noncachable ram and alignment|
|USB_DMA_INIT_DATA_ALIGN(n)|noncachable ram and alignment|
||USB_GLOBAL|dedicated ram, stack use only|
|USB_BDT|dedicated ram, stack use only|
|USB_CONTROLLER_DATA|dedicated ram, stack use only|
|USB_DMA_NONINIT_DATA_ALIGN(n)|alignment|
|USB_DMA_INIT_DATA_ALIGN(n)|alignment|
|
|USB_STACK_DEDICATED_RAM_TYPE_BDT||USB_GLOBAL|cachable ram and alignment, stack use only|
|USB_BDT|dedicated ram, stack use only|
|USB_CONTROLLER_DATA|NonCachable, stack use only|
|USB_DMA_NONINIT_DATA_ALIGN(n)|cachable ram and alignment|
|USB_DMA_INIT_DATA_ALIGN(n)|cachable ram and alignment|
||USB_GLOBAL|NonCachable, stack use only|
|USB_BDT|dedicated ram, stack use only|
|USB_CONTROLLER_DATA|NonCachable, stack use only|
|USB_DMA_NONINIT_DATA_ALIGN(n)|NonCachable and alignment|
|USB_DMA_INIT_DATA_ALIGN(n)|NonCachable and alignment|
||USB_GLOBAL|NULL, stack use only|
|USB_BDT|dedicated ram, stack use only|
|USB_CONTROLLER_DATA|NULL, stack use only|
|USB_DMA_NONINIT_DATA_ALIGN(n)|alignment|
|USB_DMA_INIT_DATA_ALIGN(n)|alignment|
|
|0||USB_GLOBAL|cachable ram and alignment, stack use only|
|USB_BDT|NonCachable, stack use only|
|USB_CONTROLLER_DATA|NonCachable, stack use only|
|USB_DMA_NONINIT_DATA_ALIGN(n)|cachable ram and alignment|
|USB_DMA_INIT_DATA_ALIGN(n)|cachable ram and alignment|
||USB_GLOBAL|NonCachable, stack use only|
|USB_BDT|NonCachable, stack use only|
|USB_CONTROLLER_DATA|NonCachable, stack use only|
|USB_DMA_NONINIT_DATA_ALIGN(n)|NonCachable and alignment|
|USB_DMA_INIT_DATA_ALIGN(n)|NonCachable and alignment|
||USB_GLOBAL|NULL, stack use only|
|USB_BDT|NULL, stack use only|
|USB_CONTROLLER_DATA|NULL, stack use only|
|USB_DMA_NONINIT_DATA_ALIGN(n)|alignment|
|USB_DMA_INIT_DATA_ALIGN(n)|alignment|
|
Note: “NULL” means that the MACRO is empty and has no influence.
There are four assistant MACROs:
|USB_DATA_ALIGN_SIZE|Used in USB stack and application, defines the default align size for USB data.|
|USB_DATA_ALIGN_SIZE_MULTIPLE(n)|Used in USB stack and application, calculates the value that is multiple of the data align size.|
|USB_DMA_DATA_NONCACHEABLE|Used in USB stack and application, puts data in the noncacheable region if the cache is enabled.|
|USB_GLOBAL_DEDICATED_RAM|Used in USB stack and application, puts data in the dedicated RAM if dedicated RAM is enabled.|
Parent topic:USB stack configuration
Parent topic:Build the USB examples in MCUXpresso SDK