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 /** Host Sierra Wireless AR module 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_swar.h"
30 #include "ux_host_stack.h"
31
32
33 /**************************************************************************/
34 /* */
35 /* FUNCTION RELEASE */
36 /* */
37 /* _ux_host_class_swar_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 the Sierra modem. This way */
46 /* allows for non blocking calls based on a packet orientated round */
47 /* robbin buffer. When a packet is fully or partially received, an */
48 /* application callback function is invoked and a new transfer request */
49 /* is rescheduled. */
50 /* */
51 /* INPUT */
52 /* */
53 /* swar Pointer to swar class */
54 /* swar_reception Pointer to reception struct */
55 /* */
56 /* OUTPUT */
57 /* */
58 /* Completion Status */
59 /* */
60 /* CALLS */
61 /* */
62 /* _ux_host_stack_class_instance_verify Verify the class instance */
63 /* _ux_host_stack_endpoint_transfer_abort */
64 /* Abort transfer */
65 /* */
66 /* CALLED BY */
67 /* */
68 /* Application */
69 /* */
70 /* RELEASE HISTORY */
71 /* */
72 /* DATE NAME DESCRIPTION */
73 /* */
74 /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */
75 /* 09-30-2020 Chaoqiong Xiao Modified comment(s), */
76 /* resulting in version 6.1 */
77 /* */
78 /**************************************************************************/
_ux_host_class_swar_reception_stop(UX_HOST_CLASS_SWAR * swar,UX_HOST_CLASS_SWAR_RECEPTION * swar_reception)79 UINT _ux_host_class_swar_reception_stop (UX_HOST_CLASS_SWAR *swar,
80 UX_HOST_CLASS_SWAR_RECEPTION *swar_reception)
81 {
82
83 /* If trace is enabled, insert this event into the trace buffer. */
84 UX_TRACE_IN_LINE_INSERT(UX_TRACE_HOST_CLASS_SWAR_RECEPTION_STOP, swar, 0, 0, 0, UX_TRACE_HOST_CLASS_EVENTS, 0, 0)
85
86 /* Ensure the instance is valid. */
87 if (_ux_host_stack_class_instance_verify(_ux_system_host_class_swar_name, (VOID *) swar) != UX_SUCCESS)
88 {
89
90 /* Error trap. */
91 _ux_system_error_handler(UX_SYSTEM_LEVEL_THREAD, UX_SYSTEM_CONTEXT_CLASS, UX_HOST_CLASS_INSTANCE_UNKNOWN);
92
93 /* If trace is enabled, insert this event into the trace buffer. */
94 UX_TRACE_IN_LINE_INSERT(UX_TRACE_ERROR, UX_HOST_CLASS_INSTANCE_UNKNOWN, swar, 0, 0, UX_TRACE_ERRORS, 0, 0)
95
96 return(UX_HOST_CLASS_INSTANCE_UNKNOWN);
97 }
98
99 /* Check if we do have transfers for this application. If none, nothing to do. */
100 if (swar_reception -> ux_host_class_swar_reception_state == UX_HOST_CLASS_SWAR_RECEPTION_STATE_STOPPED)
101 return(UX_SUCCESS);
102
103 /* We need to abort transactions on the bulk In pipe. */
104 _ux_host_stack_endpoint_transfer_abort(swar -> ux_host_class_swar_bulk_in_endpoint);
105
106 /* Declare the reception stopped. */
107 swar_reception -> ux_host_class_swar_reception_state = UX_HOST_CLASS_SWAR_RECEPTION_STATE_STOPPED;
108
109 /* This function never really fails. */
110 return(UX_SUCCESS);
111 }
112
113