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 /**   Device Stack                                                        */
19 /**                                                                       */
20 /**************************************************************************/
21 /**************************************************************************/
22 
23 #define UX_SOURCE_CODE
24 
25 
26 /* Include necessary system files.  */
27 
28 #include "ux_api.h"
29 #include "ux_device_stack.h"
30 
31 
32 #if defined(UX_DEVICE_STANDALONE)
33 /**************************************************************************/
34 /*                                                                        */
35 /*  FUNCTION                                                 RELEASE      */
36 /*                                                                        */
37 /*    _ux_device_stack_tasks_run                            PORTABLE C    */
38 /*                                                             6.1.10     */
39 /*  AUTHOR                                                                */
40 /*                                                                        */
41 /*    Chaoqiong Xiao, Microsoft Corporation                               */
42 /*                                                                        */
43 /*  DESCRIPTION                                                           */
44 /*                                                                        */
45 /*    This function runs device stack and registered classes tasks.       */
46 /*                                                                        */
47 /*    It's for standalone mode.                                           */
48 /*                                                                        */
49 /*  INPUT                                                                 */
50 /*                                                                        */
51 /*                                                                        */
52 /*  OUTPUT                                                                */
53 /*                                                                        */
54 /*    UX_STATE_RESET                        Tasks suspended               */
55 /*    UX_STATE_IDLE                         Activated but no task ran     */
56 /*    (others > UX_STATE_IDLE)              Tasks running                 */
57 /*                                                                        */
58 /*  CALLS                                                                 */
59 /*                                                                        */
60 /*    (ux_slave_dcd_function)               run DCD function              */
61 /*    (ux_slave_class_task_function)        run Class tasks function      */
62 /*                                                                        */
63 /*  CALLED BY                                                             */
64 /*                                                                        */
65 /*    Application                                                         */
66 /*                                                                        */
67 /*  RELEASE HISTORY                                                       */
68 /*                                                                        */
69 /*    DATE              NAME                      DESCRIPTION             */
70 /*                                                                        */
71 /*  01-31-2022     Chaoqiong Xiao           Initial Version 6.1.10        */
72 /*                                                                        */
73 /**************************************************************************/
_ux_device_stack_tasks_run(VOID)74 UINT  _ux_device_stack_tasks_run(VOID)
75 {
76 
77 UX_SLAVE_DCD                *dcd;
78 UX_SLAVE_CLASS              *class_instance;
79 ULONG                       class_index;
80 UINT                        status;
81 
82 
83     status = UX_STATE_RESET;
84 
85     /* Run all DCD tasks (pending ISR handle).  */
86     dcd = &_ux_system_slave -> ux_system_slave_dcd;
87     dcd -> ux_slave_dcd_function(dcd, UX_DCD_TASKS_RUN, UX_NULL);
88 
89     /* Run all Class instance tasks.  */
90     class_instance =  _ux_system_slave -> ux_system_slave_class_array;
91     for (class_index = 0; class_index < UX_SYSTEM_DEVICE_MAX_CLASS_GET(); class_index++)
92     {
93 
94         /* Skip classes not used.  */
95         if (class_instance -> ux_slave_class_status == UX_UNUSED)
96             continue;
97 
98         /* Skip classes has no task function.  */
99         if (class_instance -> ux_slave_class_task_function == UX_NULL)
100             continue;
101 
102         /* Invoke task function.  */
103         status |= class_instance -> ux_slave_class_task_function(class_instance -> ux_slave_class_instance);
104 
105         /* Move to the next class.  */
106         class_instance ++;
107     }
108 
109     /* Return overall status.  */
110     return(status);
111 }
112 #endif
113