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 
31 
32 /**************************************************************************/
33 /*                                                                        */
34 /*  FUNCTION                                               RELEASE        */
35 /*                                                                        */
36 /*    _ux_pictbridge_xml_function_input_startjob          PORTABLE C      */
37 /*                                                           6.1.12       */
38 /*                                                                        */
39 /*                                                                        */
40 /*  AUTHOR                                                                */
41 /*                                                                        */
42 /*    Chaoqiong Xiao, Microsoft Corporation                               */
43 /*                                                                        */
44 /*  DESCRIPTION                                                           */
45 /*                                                                        */
46 /*    This function receives an order for a new job.  It issues           */
47 /*    notification to the pictbridge thread.                              */
48 /*                                                                        */
49 /*  INPUT                                                                 */
50 /*                                                                        */
51 /*    pictbridge                             Pictbridge instance          */
52 /*    input_variable                         Pointer to variable          */
53 /*    input_string                           Pointer to string            */
54 /*                                                                        */
55 /*  OUTPUT                                                                */
56 /*                                                                        */
57 /*    Completion Status                                                   */
58 /*                                                                        */
59 /*  CALLS                                                                 */
60 /*                                                                        */
61 /*                                                                        */
62 /*  CALLED BY                                                             */
63 /*                                                                        */
64 /*    _ux_pictbridge_object_parse                                         */
65 /*                                                                        */
66 /*  RELEASE HISTORY                                                       */
67 /*                                                                        */
68 /*    DATE              NAME                      DESCRIPTION             */
69 /*                                                                        */
70 /*  05-19-2020     Chaoqiong Xiao           Initial Version 6.0           */
71 /*  09-30-2020     Chaoqiong Xiao           Modified comment(s),          */
72 /*                                            resulting in version 6.1    */
73 /*  07-29-2022     Chaoqiong Xiao           Modified comment(s),          */
74 /*                                            used macros for RTOS calls, */
75 /*                                            resulting in version 6.1.12 */
76 /*                                                                        */
77 /**************************************************************************/
_ux_pictbridge_xml_function_input_startjob(UX_PICTBRIDGE * pictbridge,UCHAR * input_variable,UCHAR * input_string,UCHAR * xml_parameter)78 UINT  _ux_pictbridge_xml_function_input_startjob(UX_PICTBRIDGE *pictbridge,
79                             UCHAR *input_variable, UCHAR *input_string, UCHAR *xml_parameter)
80 {
81 UX_PICTBRIDGE_EVENT         *pictbridge_next_event;
82 UX_PICTBRIDGE_EVENT         *pictbridge_event;
83 
84     UX_PARAMETER_NOT_USED(input_string);
85     UX_PARAMETER_NOT_USED(input_variable);
86     UX_PARAMETER_NOT_USED(xml_parameter);
87 
88     /* Compute the next entry in the event array.  */
89     if ((pictbridge -> ux_pictbridge_event_array_head + 1) == pictbridge -> ux_pictbridge_event_array_end)
90 
91         /* Start at the beginning of the list.  */
92         pictbridge_next_event = pictbridge -> ux_pictbridge_event_array;
93     else
94 
95         /* Point to the next entry in the event array.  */
96         pictbridge_next_event = pictbridge -> ux_pictbridge_event_array_head + 1;
97 
98     /* Check to see if we can store this event.  */
99     if (pictbridge_next_event == pictbridge -> ux_pictbridge_event_array_tail)
100 
101         /* No place to store this event, throw it away.  */
102         return(UX_ERROR);
103 
104     /* Current storage is in the current head.  */
105     pictbridge_event =  pictbridge -> ux_pictbridge_event_array_head;
106 
107     /* Store the start job event in the pictbridge event queue.  */
108     pictbridge_event -> ux_pictbridge_event_code            =   UX_PICTBRIDGE_EC_START_JOB;
109     pictbridge_event -> ux_pictbridge_event_parameter_1     =   0;
110     pictbridge_event -> ux_pictbridge_event_parameter_2     =   0;
111     pictbridge_event -> ux_pictbridge_event_parameter_3     =   0;
112 
113     /* Advance the pictbridge event queue head.  */
114     pictbridge -> ux_pictbridge_event_array_head    = pictbridge_next_event;
115 
116     /* Wake up the Pictbridge notification handler thread.  */
117     _ux_system_semaphore_put(&pictbridge -> ux_pictbridge_notification_semaphore);
118 
119     /* This function never fails.  */
120     return(UX_SUCCESS);
121 }
122 
123 
124