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 /**************************************************************************/
33 /*                                                                        */
34 /*  FUNCTION                                               RELEASE        */
35 /*                                                                        */
36 /*    _ux_device_stack_configuration_get                  PORTABLE C      */
37 /*                                                           6.1          */
38 /*  AUTHOR                                                                */
39 /*                                                                        */
40 /*    Chaoqiong Xiao, Microsoft Corporation                               */
41 /*                                                                        */
42 /*  DESCRIPTION                                                           */
43 /*                                                                        */
44 /*    This function gets the current configuration for the device.        */
45 /*                                                                        */
46 /*  INPUT                                                                 */
47 /*                                                                        */
48 /*    None                                                                */
49 /*                                                                        */
50 /*  OUTPUT                                                                */
51 /*                                                                        */
52 /*    Completion Status                                                   */
53 /*                                                                        */
54 /*  CALLS                                                                 */
55 /*                                                                        */
56 /*    _ux_device_stack_transfer_request     Transfer request              */
57 /*                                                                        */
58 /*  CALLED BY                                                             */
59 /*                                                                        */
60 /*    Application                                                         */
61 /*    Device Stack                                                        */
62 /*                                                                        */
63 /*  RELEASE HISTORY                                                       */
64 /*                                                                        */
65 /*    DATE              NAME                      DESCRIPTION             */
66 /*                                                                        */
67 /*  05-19-2020     Chaoqiong Xiao           Initial Version 6.0           */
68 /*  09-30-2020     Chaoqiong Xiao           Modified comment(s),          */
69 /*                                            resulting in version 6.1    */
70 /*                                                                        */
71 /**************************************************************************/
_ux_device_stack_configuration_get(VOID)72 UINT  _ux_device_stack_configuration_get(VOID)
73 {
74 
75 UX_SLAVE_TRANSFER       *transfer_request;
76 UX_SLAVE_DEVICE         *device;
77 UX_SLAVE_ENDPOINT       *endpoint;
78 UINT                    status;
79 
80     /* Get the pointer to the device.  */
81     device =  &_ux_system_slave -> ux_system_slave_device;
82 
83     /* Get the control endpoint for the device.  */
84     endpoint =  &device -> ux_slave_device_control_endpoint;
85 
86     /* Get the pointer to the transfer request associated with the endpoint.  */
87     transfer_request =  &endpoint -> ux_slave_endpoint_transfer_request;
88 
89     /* Set the value of the configuration in the buffer.  */
90     *transfer_request -> ux_slave_transfer_request_data_pointer =
91                 (UCHAR) device -> ux_slave_device_configuration_selected;
92 
93     /* If trace is enabled, insert this event into the trace buffer.  */
94     UX_TRACE_IN_LINE_INSERT(UX_TRACE_DEVICE_STACK_CONFIGURATION_GET, device -> ux_slave_device_configuration_selected, 0, 0, 0, UX_TRACE_DEVICE_STACK_EVENTS, 0, 0)
95 
96     /* Set the phase of the transfer to data out.  */
97     transfer_request -> ux_slave_transfer_request_phase =  UX_TRANSFER_PHASE_DATA_OUT;
98 
99     /* Send the descriptor with the appropriate length to the host.  */
100     status =  _ux_device_stack_transfer_request(transfer_request, 1, 1);
101 
102     /* Return the function status.  */
103     return(status);
104 }
105 
106