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 /**************************************************************************/
15 /** */
16 /** USBX Component */
17 /** */
18 /** Utility */
19 /** */
20 /**************************************************************************/
21 /**************************************************************************/
22
23
24 /* Include necessary system files. */
25
26 #define UX_SOURCE_CODE
27
28 #include "ux_api.h"
29
30
31 #if !defined(UX_STANDALONE)
32 /**************************************************************************/
33 /* */
34 /* FUNCTION RELEASE */
35 /* */
36 /* _ux_utility_thread_create PORTABLE C */
37 /* 6.1.11 */
38 /* AUTHOR */
39 /* */
40 /* Chaoqiong Xiao, Microsoft Corporation */
41 /* */
42 /* DESCRIPTION */
43 /* */
44 /* This function creates a thread for USBX. */
45 /* */
46 /* INPUT */
47 /* */
48 /* thread_ptr Thread control block pointer */
49 /* name Pointer to thread name string */
50 /* entry_function Entry function of the thread */
51 /* entry_input 32-bit input value to thread */
52 /* stack_start Pointer to start of stack */
53 /* stack_size Stack size in bytes */
54 /* priority Priority of thread (0-31) */
55 /* preempt_threshold Preemption threshold */
56 /* time_slice Thread time-slice value */
57 /* auto_start Automatic start selection */
58 /* */
59 /* OUTPUT */
60 /* */
61 /* Completion Status */
62 /* */
63 /* CALLS */
64 /* */
65 /* tx_thread_create ThreadX create thread function*/
66 /* */
67 /* CALLED BY */
68 /* */
69 /* USBX Components */
70 /* */
71 /* RELEASE HISTORY */
72 /* */
73 /* DATE NAME DESCRIPTION */
74 /* */
75 /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */
76 /* 09-30-2020 Chaoqiong Xiao Modified comment(s), */
77 /* used UX prefix to refer to */
78 /* TX symbols instead of using */
79 /* them directly, */
80 /* resulting in version 6.1 */
81 /* 04-25-2022 Chaoqiong Xiao Modified comment(s), */
82 /* off in standalone build, */
83 /* resulting in version 6.1.11 */
84 /* */
85 /**************************************************************************/
_ux_utility_thread_create(UX_THREAD * thread_ptr,CHAR * name,VOID (* entry_function)(ULONG),ULONG entry_input,VOID * stack_start,ULONG stack_size,UINT priority,UINT preempt_threshold,ULONG time_slice,UINT auto_start)86 UINT _ux_utility_thread_create(UX_THREAD *thread_ptr, CHAR *name,
87 VOID (*entry_function)(ULONG), ULONG entry_input,
88 VOID *stack_start, ULONG stack_size,
89 UINT priority, UINT preempt_threshold,
90 ULONG time_slice, UINT auto_start)
91 {
92
93 UINT status;
94
95
96 /* Call ThreadX to create USBX thread. */
97 status = tx_thread_create(thread_ptr,name,entry_function,entry_input,
98 stack_start,stack_size, priority,preempt_threshold,time_slice,auto_start);
99
100 /* Check for status. */
101 if (status != UX_SUCCESS)
102 {
103
104 /* Error trap. */
105 _ux_system_error_handler(UX_SYSTEM_LEVEL_THREAD, UX_SYSTEM_CONTEXT_UTILITY, status);
106
107 /* If trace is enabled, insert this event into the trace buffer. */
108 UX_TRACE_IN_LINE_INSERT(UX_TRACE_ERROR, UX_THREAD_ERROR, thread_ptr, 0, 0, UX_TRACE_ERRORS, 0, 0)
109
110 }
111 /* Return completion status. */
112 return(status);
113 }
114 #endif
115