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 /** 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 /* RELEASE HISTORY */ 67 /* */ 68 /* DATE NAME DESCRIPTION */ 69 /* */ 70 /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */ 71 /* 09-30-2020 Chaoqiong Xiao Modified comment(s), */ 72 /* resulting in version 6.1 */ 73 /* */ 74 /**************************************************************************/ _ux_host_class_cdc_acm_transfer_request_completed(UX_TRANSFER * transfer_request)75VOID _ux_host_class_cdc_acm_transfer_request_completed(UX_TRANSFER *transfer_request) 76 { 77 78 UX_HOST_CLASS_CDC_ACM *cdc_acm; 79 ULONG notification_type; 80 ULONG notification_value; 81 82 83 /* Get the class instance for this transfer request. */ 84 cdc_acm = (UX_HOST_CLASS_CDC_ACM *) transfer_request -> ux_transfer_request_class_instance; 85 86 /* Check the state of the transfer. If there is an error, we do not proceed with this notification. */ 87 if (transfer_request -> ux_transfer_request_completion_code != UX_SUCCESS) 88 89 /* We do not proceed. */ 90 return; 91 92 /* Increment the notification count. */ 93 cdc_acm -> ux_host_class_cdc_acm_notification_count++; 94 95 /* Get the notification. */ 96 notification_type = (ULONG) *(transfer_request -> ux_transfer_request_data_pointer + UX_HOST_CLASS_CDC_ACM_NPF_NOTIFICATION_TYPE); 97 98 /* And the value. */ 99 notification_value = (ULONG) _ux_utility_short_get(transfer_request -> ux_transfer_request_data_pointer + UX_HOST_CLASS_CDC_ACM_NPF_VALUE); 100 101 /* If there is a callback present, invoke it. */ 102 if (cdc_acm -> ux_host_class_cdc_acm_device_status_change_callback != UX_NULL) 103 104 /* There is a callback, send the status change to the application. */ 105 cdc_acm -> ux_host_class_cdc_acm_device_status_change_callback(cdc_acm, notification_type, notification_value); 106 107 /* Reactivate the CDC_ACM interrupt pipe. */ 108 _ux_host_stack_transfer_request(transfer_request); 109 110 /* Return to caller. */ 111 return; 112 } 113 114