现在打算实现OTG,让主从自动识别,硬件上的ID和VBUS sensing都预留了。这个怎么关联?那里有示例工程?
主机模式打算实现MSC,从机打算实现MSC+CDC。
工程是用CUBEMX生成的。
现在把ux_user.h中的宏定义手工修改了。
[C] 纯文本查看 复制代码 //#define UX_HOST_SIDE_ONLY
/* Defined, this value will only enable the device side of usbx. */
//#define UX_DEVICE_SIDE_ONLY
/* Defined, this value will include the OTG polling thread. OTG can only be active if both host/device are present.
*/
#ifndef UX_HOST_SIDE_ONLY
#ifndef UX_DEVICE_SIDE_ONLY
#define UX_OTG_SUPPORT
#endif
#endif
然后如果不这样修改,只是单纯分别初始化HOST或DEVICE的话,在_ux_host_stack_initialize中,会报UX_MEMORY_INSUFFICIENT错误。
内存已经修改大。
[C] 纯文本查看 复制代码 #if !defined(UX_HOST_STANDALONE)
/* Obtain enough stack for the two USBX host threads. */
if (status == UX_SUCCESS)
{
_ux_system_host -> ux_system_host_enum_thread_stack = _ux_utility_memory_allocate(UX_NO_ALIGN, UX_REGULAR_MEMORY,
UX_HOST_ENUM_THREAD_STACK_SIZE);
/* Check for successful allocation. */
if (_ux_system_host -> ux_system_host_enum_thread_stack == UX_NULL)
status = UX_MEMORY_INSUFFICIENT;
}
|