1 |
|
|
/*************************************************************************** |
2 |
|
|
* Copyright (c) 2024 Microsoft Corporation |
3 |
|
|
* |
4 |
|
|
* This program and the accompanying materials are made available under the |
5 |
|
|
* terms of the MIT License which is available at |
6 |
|
|
* https://opensource.org/licenses/MIT. |
7 |
|
|
* |
8 |
|
|
* SPDX-License-Identifier: MIT |
9 |
|
|
**************************************************************************/ |
10 |
|
|
|
11 |
|
|
|
12 |
|
|
/**************************************************************************/ |
13 |
|
|
/**************************************************************************/ |
14 |
|
|
/** */ |
15 |
|
|
/** USBX Component */ |
16 |
|
|
/** */ |
17 |
|
|
/** CDC_ACM Class */ |
18 |
|
|
/** */ |
19 |
|
|
/**************************************************************************/ |
20 |
|
|
/**************************************************************************/ |
21 |
|
|
|
22 |
|
|
|
23 |
|
|
/* Include necessary system files. */ |
24 |
|
|
|
25 |
|
|
#define UX_SOURCE_CODE |
26 |
|
|
|
27 |
|
|
#include "ux_api.h" |
28 |
|
|
#include "ux_host_class_cdc_acm.h" |
29 |
|
|
#include "ux_host_stack.h" |
30 |
|
|
|
31 |
|
|
|
32 |
|
|
/**************************************************************************/ |
33 |
|
|
/* */ |
34 |
|
|
/* FUNCTION RELEASE */ |
35 |
|
|
/* */ |
36 |
|
|
/* _ux_host_class_cdc_acm_transfer_request_completed PORTABLE C */ |
37 |
|
|
/* 6.1 */ |
38 |
|
|
/* AUTHOR */ |
39 |
|
|
/* */ |
40 |
|
|
/* Chaoqiong Xiao, Microsoft Corporation */ |
41 |
|
|
/* */ |
42 |
|
|
/* DESCRIPTION */ |
43 |
|
|
/* */ |
44 |
|
|
/* This function is called by the completion thread when a transfer */ |
45 |
|
|
/* request has been completed either because the transfer is */ |
46 |
|
|
/* successful or there was an error. */ |
47 |
|
|
/* */ |
48 |
|
|
/* INPUT */ |
49 |
|
|
/* */ |
50 |
|
|
/* transfer_request Pointer to transfer request */ |
51 |
|
|
/* */ |
52 |
|
|
/* OUTPUT */ |
53 |
|
|
/* */ |
54 |
|
|
/* None */ |
55 |
|
|
/* */ |
56 |
|
|
/* CALLS */ |
57 |
|
|
/* */ |
58 |
|
|
/* _ux_host_stack_transfer_request Transfer request */ |
59 |
|
|
/* _ux_utility_short_get Get 16-bit value */ |
60 |
|
|
/* */ |
61 |
|
|
/* CALLED BY */ |
62 |
|
|
/* */ |
63 |
|
|
/* USBX stack */ |
64 |
|
|
/* */ |
65 |
|
|
/* RELEASE HISTORY */ |
66 |
|
|
/* */ |
67 |
|
|
/* DATE NAME DESCRIPTION */ |
68 |
|
|
/* */ |
69 |
|
|
/* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */ |
70 |
|
|
/* 09-30-2020 Chaoqiong Xiao Modified comment(s), */ |
71 |
|
|
/* resulting in version 6.1 */ |
72 |
|
|
/* */ |
73 |
|
|
/**************************************************************************/ |
74 |
|
60 |
VOID _ux_host_class_cdc_acm_transfer_request_completed(UX_TRANSFER *transfer_request) |
75 |
|
|
{ |
76 |
|
|
|
77 |
|
|
UX_HOST_CLASS_CDC_ACM *cdc_acm; |
78 |
|
|
ULONG notification_type; |
79 |
|
|
ULONG notification_value; |
80 |
|
|
|
81 |
|
|
|
82 |
|
|
/* Get the class instance for this transfer request. */ |
83 |
|
60 |
cdc_acm = (UX_HOST_CLASS_CDC_ACM *) transfer_request -> ux_transfer_request_class_instance; |
84 |
|
|
|
85 |
|
|
/* Check the state of the transfer. If there is an error, we do not proceed with this notification. */ |
86 |
✓✓ |
60 |
if (transfer_request -> ux_transfer_request_completion_code != UX_SUCCESS) |
87 |
|
|
|
88 |
|
|
/* We do not proceed. */ |
89 |
|
57 |
return; |
90 |
|
|
|
91 |
|
|
/* Increment the notification count. */ |
92 |
|
3 |
cdc_acm -> ux_host_class_cdc_acm_notification_count++; |
93 |
|
|
|
94 |
|
|
/* Get the notification. */ |
95 |
|
3 |
notification_type = (ULONG) *(transfer_request -> ux_transfer_request_data_pointer + UX_HOST_CLASS_CDC_ACM_NPF_NOTIFICATION_TYPE); |
96 |
|
|
|
97 |
|
|
/* And the value. */ |
98 |
|
3 |
notification_value = (ULONG) _ux_utility_short_get(transfer_request -> ux_transfer_request_data_pointer + UX_HOST_CLASS_CDC_ACM_NPF_VALUE); |
99 |
|
|
|
100 |
|
|
/* If there is a callback present, invoke it. */ |
101 |
✓✓ |
3 |
if (cdc_acm -> ux_host_class_cdc_acm_device_status_change_callback != UX_NULL) |
102 |
|
|
|
103 |
|
|
/* There is a callback, send the status change to the application. */ |
104 |
|
2 |
cdc_acm -> ux_host_class_cdc_acm_device_status_change_callback(cdc_acm, notification_type, notification_value); |
105 |
|
|
|
106 |
|
|
/* Reactivate the CDC_ACM interrupt pipe. */ |
107 |
|
3 |
_ux_host_stack_transfer_request(transfer_request); |
108 |
|
|
|
109 |
|
|
/* Return to caller. */ |
110 |
|
3 |
return; |
111 |
|
|
} |
112 |
|
|
|