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