硬汉嵌入式论坛

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

[ThreadX全家桶] ThreadX USBX可以独立使用了,不依赖ThreadX内核

  [复制链接]

1万

主题

6万

回帖

10万

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
106685
QQ
发表于 2022-2-4 21:39:54 | 显示全部楼层 |阅读模式
从V6.1.10版本开始,通过宏定义可以使能:
https://www.armbbs.cn/forum.php?mod=viewthread&tid=97925


通过宏定义UX_STANDALONE可以使能:

  1. /**************************************************************************/
  2. /*                                                                        */
  3. /*       Copyright (c) Microsoft Corporation. All rights reserved.        */
  4. /*                                                                        */
  5. /*       This software is licensed under the Microsoft Software License   */
  6. /*       Terms for Microsoft Azure RTOS. Full text of the license can be  */
  7. /*       found in the LICENSE file at https://aka.ms/AzureRTOS_EULA       */
  8. /*       and in the root directory of this software.                      */
  9. /*                                                                        */
  10. /**************************************************************************/


  11. /**************************************************************************/
  12. /**************************************************************************/
  13. /**                                                                       */
  14. /** USBX Component                                                        */
  15. /**                                                                       */
  16. /**   Port Specific                                                       */
  17. /**                                                                       */
  18. /**************************************************************************/
  19. /**************************************************************************/


  20. /**************************************************************************/
  21. /*                                                                        */
  22. /*  PORT SPECIFIC C INFORMATION                            RELEASE        */
  23. /*                                                                        */
  24. /*    ux_port.h                                         Cortex-M7/IAR     */
  25. /*                                                           6.1.10       */
  26. /*                                                                        */
  27. /*  AUTHOR                                                                */
  28. /*                                                                        */
  29. /*    Chaoqiong Xiao, Microsoft Corporation                               */
  30. /*                                                                        */
  31. /*  DESCRIPTION                                                           */
  32. /*                                                                        */
  33. /*    This file contains data type definitions that make USBX function    */
  34. /*    identically on a variety of different processor architectures.      */
  35. /*                                                                        */
  36. /*  RELEASE HISTORY                                                       */
  37. /*                                                                        */
  38. /*    DATE              NAME                      DESCRIPTION             */
  39. /*                                                                        */
  40. /*  09-30-2020     Chaoqiong Xiao           Initial Version 6.1           */
  41. /*  01-31-2022     Chaoqiong Xiao           Modified comment(s),          */
  42. /*                                            moved tx_api.h include and  */
  43. /*                                            typedefs from ux_api.h,     */
  44. /*                                            resulting in version 6.1.10 */
  45. /*                                                                        */
  46. /**************************************************************************/

  47. #ifndef UX_PORT_H
  48. #define UX_PORT_H


  49. /* Determine if the optional USBX user define file should be used.  */

  50. #ifdef UX_INCLUDE_USER_DEFINE_FILE


  51. /* Yes, include the user defines in ux_user.h. The defines in this file may
  52.    alternately be defined on the command line.  */

  53. #include "ux_user.h"
  54. #endif


  55. /* Include library header files.  */

  56. #include <stdio.h>
  57. #include <string.h>


  58. #if !defined(UX_STANDALONE)
  59. #include "tx_api.h"
  60. #else

  61. /* VAR types used in UX,
  62.    if TX still used, expects tx_api.h included before include this.  */
  63. #if !defined(TX_API_H) && !defined(TX_PORT_H)

  64. #include <stdint.h>
  65. typedef void                                    VOID;
  66. typedef char                                    CHAR;
  67. typedef unsigned char                           UCHAR;
  68. typedef int                                     INT;
  69. typedef unsigned int                            UINT;
  70. typedef long                                    LONG;
  71. typedef unsigned long                           ULONG;
  72. typedef short                                   SHORT;
  73. typedef unsigned short                          USHORT;
  74. typedef uint64_t                                ULONG64;

  75. #ifndef ALIGN_TYPE_DEFINED
  76. #define ALIGN_TYPE                              ULONG
  77. #endif

  78. #endif
  79. #endif


  80. /* CPU definition for X86 systems without preemptive timer function.
  81.    This will make USBX uses the controller for the timer. */

  82. #undef THREADX_X86_NO_PTIMER


  83. /* For X86 systems, the define #define UX_USE_IO_INSTRUCTIONS should be used.  */


  84. /* Define additional generic USBX types.  */

  85. typedef long                        SLONG;


  86. /*  Generic USBX Project constants follow.  */

  87. #ifndef UX_PERIODIC_RATE
  88. #define UX_PERIODIC_RATE                                    100
  89. #endif

  90. #ifndef UX_MAX_CLASS_DRIVER
  91. #define UX_MAX_CLASS_DRIVER                                 8
  92. #endif

  93. #ifndef UX_MAX_SLAVE_CLASS_DRIVER
  94. #define UX_MAX_SLAVE_CLASS_DRIVER                           4
  95. #endif

  96. #ifndef UX_MAX_HCD
  97. #define UX_MAX_HCD                                          2
  98. #endif

  99. #ifndef UX_MAX_DEVICES
  100. #define UX_MAX_DEVICES                                      8
  101. #endif

  102. #ifndef UX_MAX_ED
  103. #define UX_MAX_ED                                           80
  104. #endif

  105. #ifndef UX_MAX_TD
  106. #define UX_MAX_TD                                           32
  107. #endif

  108. #ifndef UX_MAX_ISO_TD
  109. #define UX_MAX_ISO_TD                                       16
  110. #endif

  111. #ifndef UX_HOST_ENUM_THREAD_STACK_SIZE
  112. #define UX_HOST_ENUM_THREAD_STACK_SIZE                      (2*1024)
  113. #endif

  114. #ifndef UX_THREAD_STACK_SIZE
  115. #define UX_THREAD_STACK_SIZE                                (1*1024)
  116. #endif

  117. #ifndef UX_THREAD_PRIORITY_ENUM
  118. #define UX_THREAD_PRIORITY_ENUM                             20
  119. #endif

  120. #ifndef UX_THREAD_PRIORITY_CLASS
  121. #define UX_THREAD_PRIORITY_CLASS                            20
  122. #endif

  123. #ifndef UX_THREAD_PRIORITY_KEYBOARD
  124. #define UX_THREAD_PRIORITY_KEYBOARD                         20
  125. #endif

  126. #ifndef UX_THREAD_PRIORITY_HCD
  127. #define UX_THREAD_PRIORITY_HCD                              2
  128. #endif

  129. #ifndef UX_THREAD_PRIORITY_DCD
  130. #define UX_THREAD_PRIORITY_DCD                              2
  131. #endif

  132. #ifndef UX_NO_TIME_SLICE
  133. #define UX_NO_TIME_SLICE                                    0
  134. #endif

  135. #ifndef UX_MAX_SLAVE_LUN
  136. #define UX_MAX_SLAVE_LUN                                    2
  137. #endif

  138. #ifndef UX_MAX_HOST_LUN
  139. #define UX_MAX_HOST_LUN                                     2
  140. #endif

  141. #ifndef UX_HOST_CLASS_STORAGE_MAX_MEDIA
  142. #define UX_HOST_CLASS_STORAGE_MAX_MEDIA                     2
  143. #endif

  144. #ifndef UX_SLAVE_REQUEST_CONTROL_MAX_LENGTH
  145. #define UX_SLAVE_REQUEST_CONTROL_MAX_LENGTH                 256
  146. #endif


  147. #ifndef UX_SLAVE_REQUEST_DATA_MAX_LENGTH
  148. #define UX_SLAVE_REQUEST_DATA_MAX_LENGTH                    4096
  149. #endif

  150. #ifndef UX_USE_IO_INSTRUCTIONS

  151. /* Don't use IO instructions if this define is not set.  Default to memory mapped.  */

  152. #define inpb(a)                                            *((UCHAR *)  (a))
  153. #define inpw(a)                                            *((USHORT *) (a))
  154. #define inpl(a)                                            *((ULONG *)  (a))
  155. #define outpb(a, b)                                        *((UCHAR *)  (a)) =  ((UCHAR)  (b))
  156. #define outpw(a, b)                                        *((USHORT *) (a)) =  ((USHORT) (b))
  157. #define outpl(a, b)                                        *((ULONG *)  (a)) =  ((ULONG)  (b))
  158. #else


  159. /* Define simple prototypes for non-memory mapped hardware access.  */

  160. UCHAR   inpb(ULONG);
  161. USHORT  inpw(ULONG);
  162. ULONG   inpl(ULONG);

  163. VOID    outpb(ULONG,UCHAR);
  164. VOID    outpw(ULONG,USHORT);
  165. VOID    outpl(ULONG,ULONG);

  166. #endif
  167. /* Define local delay function for board specific bsps.  */
  168. #ifdef TI_AM335
  169.     #define UX_BSP_SPECIFIC_DELAY_FUNCTION
  170. #endif


  171. /* Define interrupt lockout constructs to protect the memory allocation/release which could happen
  172.    under ISR in the device stack.  */

  173. #define UX_INT_SAVE_AREA        unsigned int  old_interrupt_posture;
  174. #define UX_DISABLE_INTS         old_interrupt_posture =  tx_interrupt_control(TX_INT_DISABLE);
  175. #define UX_RESTORE_INTS         tx_interrupt_control(old_interrupt_posture);


  176. /* Define the version ID of USBX.  This may be utilized by the application.  */

  177. #ifdef  UX_SYSTEM_INIT
  178. CHAR                            _ux_version_id[] =
  179.                                     "Copyright (c) Microsoft Corporation. All rights reserved. * USBX Cortex-M7/IAR Version 6.1.10 *";
  180. #else
  181. extern  CHAR                    _ux_version_id[];
  182. #endif

  183. #endif
复制代码
回复

使用道具 举报

5

主题

9

回帖

24

积分

新手上路

积分
24
发表于 2022-2-5 16:10:40 | 显示全部楼层
期待出和FreeRTOS联合使用的例程啊
回复

使用道具 举报

1万

主题

6万

回帖

10万

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
106685
QQ
 楼主| 发表于 2022-2-5 16:53:02 | 显示全部楼层
南北雁 发表于 2022-2-5 16:10
期待出和FreeRTOS联合使用的例程啊

后面有时间了搞个CMSIS-RTOS封装层版的接口,这样那个系统就可以方便的使用了,不用单独移植了。
回复

使用道具 举报

2

主题

55

回帖

61

积分

初级会员

积分
61
发表于 2022-2-7 16:45:40 来自手机 | 显示全部楼层
netx啥时候也能跟进一下就好啦
回复

使用道具 举报

0

主题

57

回帖

57

积分

初级会员

积分
57
发表于 2022-2-8 01:05:44 | 显示全部楼层
南北雁 发表于 2022-2-5 16:10
期待出和FreeRTOS联合使用的例程啊

听听您意见:希望有什么样的联合? FreeRTOS + NetX?  + USBX?
回复

使用道具 举报

1万

主题

6万

回帖

10万

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
106685
QQ
 楼主| 发表于 2022-2-8 01:30:40 | 显示全部楼层
yuxinzhou 发表于 2022-2-8 01:05
听听您意见:希望有什么样的联合? FreeRTOS + NetX?  + USBX?

推荐做个CMSIS-RTOS封装层版移植,如果使用ThreadX当前为FreeRTOS封装层版,感觉意义并不大。

通用性不强。
回复

使用道具 举报

4

主题

29

回帖

41

积分

新手上路

积分
41
发表于 2022-2-8 11:27:33 | 显示全部楼层
还是要修改一些地方才能使用,代码中的_ux_utility_mutex_需要自己替换成_ux_system_mutex_ 否则编译不通过
回复

使用道具 举报

0

主题

6

回帖

6

积分

新手上路

积分
6
发表于 2022-2-8 14:42:47 | 显示全部楼层
miss-you 发表于 2022-2-8 11:27
还是要修改一些地方才能使用,代码中的_ux_utility_mutex_需要自己替换成_ux_system_mutex_ 否则编译不通过

是common下的code么?理论上common下的code通过宏的配置是不会出现编译错误的。

另外,本次standalone的支持其实只有一部分的class,包括device stack, device cdc_acm, hid, dfu 和 storage ,以及host stack,host cdc_acm, hid, printer 和 storage,其他的class暂时还不支持standalone。
关于网络相关的东西,个人认为还是上RTOS比较好,用standalone加上其他RTOS就没有必要了。
回复

使用道具 举报

4

主题

29

回帖

41

积分

新手上路

积分
41
发表于 2022-2-9 10:24:05 | 显示全部楼层
xiaocq2001 发表于 2022-2-8 14:42
是common下的code么?理论上common下的code通过宏的配置是不会出现编译错误的。

另外,本次standalone ...

是tag里发布的那个,只是测试了一下, hid, ohci的
回复

使用道具 举报

0

主题

6

回帖

6

积分

新手上路

积分
6
发表于 2022-2-11 14:34:33 | 显示全部楼层
miss-you 发表于 2022-2-9 10:24
是tag里发布的那个,只是测试了一下, hid, ohci的

OHCI还没有根据standalone模式做修改,理论上即使修改_utility_编译通过,实际硬件上使用还是会有问题。
另外由于不通过rtos管理,原有的示例也得做相应的修改才能用。
回复

使用道具 举报

9

主题

51

回帖

78

积分

初级会员

积分
78
发表于 2023-12-27 18:13:08 | 显示全部楼层
独立运行之后描述符要改嘛,我咋感觉还需要改描述符,我好不容易把CDC和MSC复合设备跑通了,现在独立运行又连不上电脑了
回复

使用道具 举报

1万

主题

6万

回帖

10万

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
106685
QQ
 楼主| 发表于 2023-12-28 08:22:12 | 显示全部楼层
嵌入式菜鸟^_^ 发表于 2023-12-27 18:13
独立运行之后描述符要改嘛,我咋感觉还需要改描述符,我好不容易把CDC和MSC复合设备跑通了,现在独立运行又 ...

独立运行有例子,测试例子是否正常。
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2024-4-29 20:34 , Processed in 0.381206 second(s), 25 queries .

Powered by Discuz! X3.4 Licensed

Copyright © 2001-2023, Tencent Cloud.

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