硬汉嵌入式论坛

 找回密码
 立即注册
查看: 1799|回复: 9
收起左侧

[ThreadX全家桶] Threadx usb host

[复制链接]

2

主题

6

回帖

12

积分

新手上路

积分
12
QQ
发表于 2022-1-13 11:31:34 | 显示全部楼层 |阅读模式
Threadx 官方提供的stm32f746和rt1060中关于usb host的例程为什么进不了线程啊?其他例程都好好的,就这个不行,有没有大佬帮忙解答下
回复

使用道具 举报

2

主题

6

回帖

12

积分

新手上路

积分
12
QQ
 楼主| 发表于 2022-1-13 11:42:37 | 显示全部楼层
我参照例程改的程序可以进线程,但是卡在注册usb驱动哪里了,现在没得参考,不知道怎么办
回复

使用道具 举报

2

主题

6

回帖

12

积分

新手上路

积分
12
QQ
 楼主| 发表于 2022-1-13 11:44:37 | 显示全部楼层
我参照例程自己修改的例程可以进入线程,但是卡在了注册usb驱动哪里了,现在没得参考
回复

使用道具 举报

1万

主题

7万

回帖

11万

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
115834
QQ
发表于 2022-1-13 14:59:25 | 显示全部楼层
这个是ThreadX很久以前做的例子。

使用ST搞的那个ThreadX软件,有专门的例子,比较好使:

https://github.com/STMicroelectr ... K/Applications/USBX
回复

使用道具 举报

2

主题

6

回帖

12

积分

新手上路

积分
12
QQ
 楼主| 发表于 2022-1-19 10:03:01 | 显示全部楼层
eric2013 发表于 2022-1-13 14:59
这个是ThreadX很久以前做的例子。

使用ST搞的那个ThreadX软件,有专门的例子,比较好使:

现在卡在demo_class_storage_get里有个ux_host_stack_class_instance_get一直找不到实例,无法返回成功值,不知道什么原因

UINT  _ux_host_stack_class_instance_get(UX_HOST_CLASS *host_class, UINT class_index, VOID **class_instance)
{
   
VOID    **current_class_instance;
   

    /* 从附加到类容器的第一个类实例开始.  */
    current_class_instance =  host_class -> ux_host_class_first_instance;
   
    /* 检查是否附加了任何实例.  */
    if(current_class_instance == UX_NULL)
    {        

        return(UX_HOST_CLASS_INSTANCE_UNKNOWN);
    }

    /* 遍历类实例列表,直到找到正确的实例.  */        
    while (class_index-- != 0)
    {

        /* 指向下一个类实例.  */
        current_class_instance =  *current_class_instance;

        /* 检查我们是否已到达类实例列表的末尾.  */
        if (current_class_instance == UX_NULL)
        {        

            return(UX_HOST_CLASS_INSTANCE_UNKNOWN);
        }
    }

    /* 从调用方更新类实例指针.  */
    *class_instance =  current_class_instance;
   
    /* 返回成功完成.  */
    return(UX_SUCCESS);
}
回复

使用道具 举报

17

主题

84

回帖

135

积分

初级会员

积分
135
QQ
发表于 2022-1-19 16:18:32 | 显示全部楼层
这个函数在哪里调用的?我怎么没用到
回复

使用道具 举报

2

主题

6

回帖

12

积分

新手上路

积分
12
QQ
 楼主| 发表于 2022-1-20 10:34:20 | 显示全部楼层
linminghui 发表于 2022-1-19 16:18
这个函数在哪里调用的?我怎么没用到

我参考的Azure_RTOS_STM32F746G-DISCO的例程,上面的函数是在usbx库里的函数
回复

使用道具 举报

2

主题

6

回帖

12

积分

新手上路

积分
12
QQ
 楼主| 发表于 2022-1-20 11:44:42 | 显示全部楼层
linminghui 发表于 2022-1-19 16:18
这个函数在哪里调用的?我怎么没用到

UINT  demo_class_storage_get(void)
{

UX_HOST_CLASS       *class;


    /* Find the main storage container */
    status =  ux_host_stack_class_get(_ux_system_host_class_storage_name, &class);
    if (status != UX_SUCCESS)
        return(status);

    /* We get the first instance of the storage device */
    do  
    {

        status =  ux_host_stack_class_instance_get(class, 0, (void **) &storage);
        tx_thread_sleep(10);
    } while (status != UX_SUCCESS);

    /* We still need to wait for the storage status to be live */
    while (storage -> ux_host_class_storage_state != UX_HOST_CLASS_INSTANCE_LIVE)
        tx_thread_sleep(10);

    /* We try to get the first media attached to the class container.  */
    while (class -> ux_host_class_media == UX_NULL)
    {

        tx_thread_sleep(10);
    }

    /* Setup media pointer.  */
    storage_media =  (UX_HOST_CLASS_STORAGE_MEDIA *) class -> ux_host_class_media;
    media =  &storage_media -> ux_host_class_storage_media;

    return(UX_SUCCESS);
}
回复

使用道具 举报

14

主题

50

回帖

97

积分

初级会员

积分
97
发表于 2022-2-18 10:43:54 | 显示全部楼层
image.png
回复

使用道具 举报

14

主题

50

回帖

97

积分

初级会员

积分
97
发表于 2022-2-18 10:45:08 | 显示全部楼层
image.png
你可以这样修改试一下。我目前修改后可以正常获取实例的。
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|小黑屋|Archiver|手机版|硬汉嵌入式论坛

GMT+8, 2025-5-22 06:15 , Processed in 0.333529 second(s), 27 queries .

Powered by Discuz! X3.4 Licensed

Copyright © 2001-2023, Tencent Cloud.

快速回复 返回顶部 返回列表