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 /** USBX Component */
16 /** */
17 /** Device PIMA Class */
18 /** */
19 /**************************************************************************/
20 /**************************************************************************/
21
22 #define UX_SOURCE_CODE
23
24
25 /* Include necessary system files. */
26
27 #include "ux_api.h"
28 #include "ux_device_class_pima.h"
29 #include "ux_device_stack.h"
30
31
32 /**************************************************************************/
33 /* */
34 /* FUNCTION RELEASE */
35 /* */
36 /* _ux_device_class_pima_event_get PORTABLE C */
37 /* 6.1 */
38 /* AUTHOR */
39 /* */
40 /* Chaoqiong Xiao, Microsoft Corporation */
41 /* */
42 /* DESCRIPTION */
43 /* */
44 /* This function checks if there is an event from the application */
45 /* */
46 /* INPUT */
47 /* */
48 /* pima Address of pima class */
49 /* event Pointer of the event */
50 /* */
51 /* OUTPUT */
52 /* */
53 /* status UX_SUCCESS if there is an */
54 /* event */
55 /* CALLS */
56 /* */
57 /* None */
58 /* */
59 /* CALLED BY */
60 /* */
61 /* ThreadX */
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_class_pima_event_get(UX_SLAVE_CLASS_PIMA * pima,UX_SLAVE_CLASS_PIMA_EVENT * pima_event)72 UINT _ux_device_class_pima_event_get(UX_SLAVE_CLASS_PIMA *pima,
73 UX_SLAVE_CLASS_PIMA_EVENT *pima_event)
74 {
75
76 UX_SLAVE_CLASS_PIMA_EVENT *current_pima_event;
77
78 /* If trace is enabled, insert this event into the trace buffer. */
79 UX_TRACE_IN_LINE_INSERT(UX_TRACE_DEVICE_CLASS_PIMA_EVENT_GET, pima, pima_event, 0, 0, UX_TRACE_DEVICE_CLASS_EVENTS, 0, 0)
80
81 /* Check if the head and the tail of the event array is the same. */
82 if (pima -> ux_device_class_pima_event_array_head ==
83 pima -> ux_device_class_pima_event_array_tail)
84
85 /* No event to report. */
86 return(UX_ERROR);
87
88 /* There is an event to report, get the current pointer to the event. */
89 current_pima_event = pima -> ux_device_class_pima_event_array_tail;
90
91 /* fill in the event structure from the user. */
92 pima_event -> ux_device_class_pima_event_code = current_pima_event -> ux_device_class_pima_event_code;
93 pima_event -> ux_device_class_pima_event_session_id = pima -> ux_device_class_pima_session_id;
94 pima_event -> ux_device_class_pima_event_transaction_id = pima -> ux_device_class_pima_transaction_id;
95 pima_event -> ux_device_class_pima_event_parameter_1 = current_pima_event -> ux_device_class_pima_event_parameter_1;
96 pima_event -> ux_device_class_pima_event_parameter_2 = current_pima_event -> ux_device_class_pima_event_parameter_2;
97 pima_event -> ux_device_class_pima_event_parameter_3 = current_pima_event -> ux_device_class_pima_event_parameter_3;
98
99
100 /* Adjust the tail pointer. Check if we are at the end. */
101 if ((current_pima_event + 1) == pima -> ux_device_class_pima_event_array_end)
102
103 /* We are at the end, go back to the beginning. */
104 pima -> ux_device_class_pima_event_array_tail = pima -> ux_device_class_pima_event_array;
105
106 else
107 /* We are not at the end, increment the tail position. */
108 pima -> ux_device_class_pima_event_array_tail++;
109
110
111 /* Return event status to the user. */
112 return(UX_SUCCESS);
113 }
114
115