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 /** Prolific Class */
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_host_class_prolific.h"
30 #include "ux_host_stack.h"
31
32
33 /**************************************************************************/
34 /* */
35 /* FUNCTION RELEASE */
36 /* */
37 /* _ux_host_class_prolific_reception_stop PORTABLE C */
38 /* 6.1 */
39 /* AUTHOR */
40 /* */
41 /* Chaoqiong Xiao, Microsoft Corporation */
42 /* */
43 /* DESCRIPTION */
44 /* */
45 /* This function starts a reception with a prolific device. This */
46 /* mechanism allows for non blocking calls based on a packet */
47 /* orientated round robbin buffer. When a packet is fully or partially */
48 /* received, an application callback function is invoked and a new */
49 /* transfer request is rescheduled. */
50 /* */
51 /* INPUT */
52 /* */
53 /* prolific Pointer to prolific class */
54 /* prolific_reception Pointer to reception struct */
55 /* */
56 /* OUTPUT */
57 /* */
58 /* Completion Status */
59 /* */
60 /* CALLS */
61 /* */
62 /* _ux_host_stack_endpoint_transfer_abort */
63 /* Abort transfer */
64 /* */
65 /* CALLED BY */
66 /* */
67 /* Application */
68 /* */
69 /* RELEASE HISTORY */
70 /* */
71 /* DATE NAME DESCRIPTION */
72 /* */
73 /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */
74 /* 09-30-2020 Chaoqiong Xiao Modified comment(s), */
75 /* resulting in version 6.1 */
76 /* */
77 /**************************************************************************/
_ux_host_class_prolific_reception_stop(UX_HOST_CLASS_PROLIFIC * prolific,UX_HOST_CLASS_PROLIFIC_RECEPTION * prolific_reception)78 UINT _ux_host_class_prolific_reception_stop (UX_HOST_CLASS_PROLIFIC *prolific,
79 UX_HOST_CLASS_PROLIFIC_RECEPTION *prolific_reception)
80 {
81
82 /* If trace is enabled, insert this event into the trace buffer. */
83 UX_TRACE_IN_LINE_INSERT(UX_TRACE_HOST_CLASS_PROLIFIC_RECEPTION_STOP, prolific, 0, 0, 0, UX_TRACE_HOST_CLASS_EVENTS, 0, 0)
84
85 /* Ensure the instance is valid. */
86 if (prolific -> ux_host_class_prolific_state != UX_HOST_CLASS_INSTANCE_LIVE)
87 {
88
89 /* Error trap. */
90 _ux_system_error_handler(UX_SYSTEM_LEVEL_THREAD, UX_SYSTEM_CONTEXT_CLASS, UX_HOST_CLASS_INSTANCE_UNKNOWN);
91
92 /* If trace is enabled, insert this event into the trace buffer. */
93 UX_TRACE_IN_LINE_INSERT(UX_TRACE_ERROR, UX_HOST_CLASS_INSTANCE_UNKNOWN, prolific, 0, 0, UX_TRACE_ERRORS, 0, 0)
94
95 return(UX_HOST_CLASS_INSTANCE_UNKNOWN);
96 }
97
98 /* Check if we do have transfers for this application. If none, nothing to do. */
99 if (prolific_reception -> ux_host_class_prolific_reception_state == UX_HOST_CLASS_PROLIFIC_RECEPTION_STATE_STOPPED)
100 return(UX_SUCCESS);
101
102 /* We need to abort transactions on the bulk In pipe. */
103 _ux_host_stack_endpoint_transfer_abort(prolific -> ux_host_class_prolific_bulk_in_endpoint);
104
105 /* Declare the reception stopped. */
106 prolific_reception -> ux_host_class_prolific_reception_state = UX_HOST_CLASS_PROLIFIC_RECEPTION_STATE_STOPPED;
107
108 /* This function never really fails. */
109 return(UX_SUCCESS);
110 }
111
112