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 /** Audio 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_audio.h" 30 #include "ux_host_stack.h" 31 32 33 /**************************************************************************/ 34 /* */ 35 /* FUNCTION RELEASE */ 36 /* */ 37 /* _ux_host_class_audio_transfer_request PORTABLE C */ 38 /* 6.1.12 */ 39 /* AUTHOR */ 40 /* */ 41 /* Chaoqiong Xiao, Microsoft Corporation */ 42 /* */ 43 /* DESCRIPTION */ 44 /* */ 45 /* This function submits an isochronous audio transfer request to the */ 46 /* USBX stack. */ 47 /* */ 48 /* INPUT */ 49 /* */ 50 /* audio Pointer to audio class */ 51 /* audio_transfer_request Pointer to transfer request */ 52 /* */ 53 /* OUTPUT */ 54 /* */ 55 /* Completion Status */ 56 /* */ 57 /* CALLS */ 58 /* */ 59 /* _ux_host_stack_transfer_request Process transfer request */ 60 /* */ 61 /* CALLED BY */ 62 /* */ 63 /* Audio Class */ 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 /* 07-29-2022 Chaoqiong Xiao Modified comment(s), */ 73 /* refined transfer implement, */ 74 /* resulting in version 6.1.12 */ 75 /* */ 76 /**************************************************************************/ _ux_host_class_audio_transfer_request(UX_HOST_CLASS_AUDIO * audio,UX_HOST_CLASS_AUDIO_TRANSFER_REQUEST * audio_transfer_request)77UINT _ux_host_class_audio_transfer_request(UX_HOST_CLASS_AUDIO *audio, 78 UX_HOST_CLASS_AUDIO_TRANSFER_REQUEST *audio_transfer_request) 79 { 80 81 UX_INTERRUPT_SAVE_AREA 82 UINT status; 83 UX_TRANSFER *transfer_request; 84 85 /* The transfer request is embedded in the application transfer request. */ 86 transfer_request = &audio_transfer_request -> ux_host_class_audio_transfer_request; 87 88 /* Saved the direction, by taking the endpoint transfer direction. */ 89 transfer_request -> ux_transfer_request_type = 90 audio -> ux_host_class_audio_isochronous_endpoint -> 91 ux_endpoint_transfer_request.ux_transfer_request_type; 92 93 /* Fill the transfer request with all the required fields. */ 94 transfer_request -> ux_transfer_request_endpoint = audio -> ux_host_class_audio_isochronous_endpoint; 95 transfer_request -> ux_transfer_request_data_pointer = audio_transfer_request -> ux_host_class_audio_transfer_request_data_pointer; 96 transfer_request -> ux_transfer_request_requested_length = audio_transfer_request -> ux_host_class_audio_transfer_request_requested_length; 97 transfer_request -> ux_transfer_request_packet_length = audio_transfer_request -> ux_host_class_audio_transfer_request_packet_size; 98 transfer_request -> ux_transfer_request_completion_function = _ux_host_class_audio_transfer_request_completed; 99 transfer_request -> ux_transfer_request_class_instance = audio; 100 transfer_request -> ux_transfer_request_next_transfer_request = UX_NULL; /* Add one by one. */ 101 102 /* We memorize the application transfer request in the local transfer request. */ 103 transfer_request -> ux_transfer_request_user_specific = (VOID *) audio_transfer_request; 104 105 UX_DISABLE 106 107 /* Hook the audio transfer request to the chain of transfer requests in the audio instance. */ 108 audio_transfer_request -> ux_host_class_audio_transfer_request_next_audio_transfer_request = 109 audio -> ux_host_class_audio_tail_transfer_request; 110 audio -> ux_host_class_audio_tail_transfer_request = audio_transfer_request; 111 112 /* Check if this is the first time we have had a transfer request, if so update the head as well. */ 113 if (audio -> ux_host_class_audio_head_transfer_request == UX_NULL) 114 audio -> ux_host_class_audio_head_transfer_request = audio_transfer_request; 115 116 UX_RESTORE 117 118 /* Transfer the transfer request (queued in lower level). */ 119 status = _ux_host_stack_transfer_request(transfer_request); 120 121 /* Return completion status. */ 122 return(status); 123 } 124