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 /** Pictbridge Application */
19 /** */
20 /**************************************************************************/
21 /**************************************************************************/
22
23
24 /* Include necessary system files. */
25
26 #define UX_SOURCE_CODE
27
28 #include "ux_api.h"
29 #include "ux_pictbridge.h"
30 #include "ux_device_class_pima.h"
31
32
33 /**************************************************************************/
34 /* */
35 /* FUNCTION RELEASE */
36 /* */
37 /* _ux_pictbridge_dpsclient_api_capability PORTABLE C */
38 /* 6.1.12 */
39 /* AUTHOR */
40 /* */
41 /* Chaoqiong Xiao, Microsoft Corporation */
42 /* */
43 /* DESCRIPTION */
44 /* */
45 /* This function creates the tag lines of the configure_print_service */
46 /* request and then output the request to the printer. */
47 /* */
48 /* INPUT */
49 /* */
50 /* pictbridge Pictbridge instance */
51 /* capability_code What capability to get */
52 /* capability_parameter Optional parameter */
53 /* */
54 /* OUTPUT */
55 /* */
56 /* Completion Status */
57 /* */
58 /* CALLS */
59 /* */
60 /* _ux_utility_delay_ms Delay ms */
61 /* _ux_pictbridge_dps_client_input_object_prepare */
62 /* _ux_system_event_flags_get */
63 /* */
64 /* CALLED BY */
65 /* */
66 /* _ux_pictbridge_dpshost_object_get */
67 /* */
68 /* RELEASE HISTORY */
69 /* */
70 /* DATE NAME DESCRIPTION */
71 /* */
72 /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */
73 /* 09-30-2020 Chaoqiong Xiao Modified comment(s), */
74 /* used UX prefix to refer to */
75 /* TX symbols instead of using */
76 /* them directly, */
77 /* resulting in version 6.1 */
78 /* 07-29-2022 Chaoqiong Xiao Modified comment(s), */
79 /* used macros for RTOS calls, */
80 /* resulting in version 6.1.12 */
81 /* */
82 /**************************************************************************/
_ux_pictbridge_dpsclient_api_capability(UX_PICTBRIDGE * pictbridge,ULONG capability_code,ULONG capability_parameter)83 UINT _ux_pictbridge_dpsclient_api_capability(UX_PICTBRIDGE *pictbridge, ULONG capability_code,
84 ULONG capability_parameter)
85 {
86 UINT status;
87 ULONG actual_flags;
88
89 /* Wait for 100 ms to give a chance to the host to send a request before the client can post a Object Added event. */
90 _ux_utility_delay_ms(100);
91
92 /* Prepare the object for capability. */
93 status = _ux_pictbridge_dpsclient_input_object_prepare(pictbridge, UX_PICTBRIDGE_OR_GET_CAPABILITY,
94 capability_code, capability_parameter);
95
96 /* Check status. */
97 if (status != UX_SUCCESS)
98 return(status);
99
100 /* We should wait for the host to send a script with the response. */
101 status = _ux_system_event_flags_get(&pictbridge -> ux_pictbridge_event_flags_group, UX_PICTBRIDGE_EVENT_FLAG_CAPABILITY,
102 UX_AND_CLEAR, &actual_flags, UX_PICTBRIDGE_EVENT_TIMEOUT);
103
104 /* Check status. */
105 if (status != UX_SUCCESS)
106 return(UX_EVENT_ERROR);
107
108 /* Ensure the flag was set. */
109 if (actual_flags & UX_PICTBRIDGE_EVENT_FLAG_CAPABILITY)
110
111 /* Return completion status. */
112 return(UX_SUCCESS);
113
114 else
115
116 /* Return completion status. */
117 return(UX_ERROR);
118 }
119
120