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 /** Slave Simulator Controller Driver */ 19 /** */ 20 /**************************************************************************/ 21 /**************************************************************************/ 22 23 #define UX_SOURCE_CODE 24 25 26 /* Include necessary system files. */ 27 28 #include "ux_api.h" 29 #include "ux_dcd_sim_slave.h" 30 31 32 /**************************************************************************/ 33 /* */ 34 /* FUNCTION RELEASE */ 35 /* */ 36 /* _ux_dcd_sim_slave_endpoint_reset PORTABLE C */ 37 /* 6.1.10 */ 38 /* AUTHOR */ 39 /* */ 40 /* Chaoqiong Xiao, Microsoft Corporation */ 41 /* */ 42 /* DESCRIPTION */ 43 /* */ 44 /* This function will reset a physical endpoint. */ 45 /* */ 46 /* INPUT */ 47 /* */ 48 /* dcd_sim_slave Pointer to device controller */ 49 /* endpoint Pointer to endpoint container */ 50 /* */ 51 /* OUTPUT */ 52 /* */ 53 /* Completion Status */ 54 /* */ 55 /* CALLS */ 56 /* */ 57 /* None */ 58 /* */ 59 /* CALLED BY */ 60 /* */ 61 /* Slave Simulator Controller Driver */ 62 /* */ 63 /* RELEASE HISTORY */ 64 /* */ 65 /* DATE NAME DESCRIPTION */ 66 /* */ 67 /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */ 68 /* 09-30-2020 Chaoqiong Xiao Modified comment(s), */ 69 /* resulting in version 6.1 */ 70 /* 06-02-2021 Chaoqiong Xiao Modified comment(s), */ 71 /* cleared transfer flag and */ 72 /* waked up suspended thread, */ 73 /* resulting in version 6.1.7 */ 74 /* 01-31-2022 Chaoqiong Xiao Modified comment(s), */ 75 /* added standalone support, */ 76 /* resulting in version 6.1.10 */ 77 /* */ 78 /**************************************************************************/ _ux_dcd_sim_slave_endpoint_reset(UX_DCD_SIM_SLAVE * dcd_sim_slave,UX_SLAVE_ENDPOINT * endpoint)79UINT _ux_dcd_sim_slave_endpoint_reset(UX_DCD_SIM_SLAVE *dcd_sim_slave, UX_SLAVE_ENDPOINT *endpoint) 80 { 81 82 UX_DCD_SIM_SLAVE_ED *ed; 83 ULONG transfer_waiting; 84 #if !defined(UX_DEVICE_STANDALONE) 85 UX_SLAVE_TRANSFER *transfer; 86 #endif 87 88 UX_PARAMETER_NOT_USED(dcd_sim_slave); 89 90 /* Get the physical endpoint address in the endpoint container. */ 91 ed = (UX_DCD_SIM_SLAVE_ED *) endpoint -> ux_slave_endpoint_ed; 92 93 #if defined(UX_DEVICE_STANDALONE) 94 95 /* Transfer pending always considered. */ 96 transfer_waiting = UX_DCD_SIM_SLAVE_ED_STATUS_TRANSFER; 97 #else 98 99 /* Save waiting status for non-zero endpoints. */ 100 if (ed -> ux_sim_slave_ed_index) 101 { 102 transfer_waiting = ed -> ux_sim_slave_ed_status; 103 transfer_waiting &= UX_DCD_SIM_SLAVE_ED_STATUS_TRANSFER; 104 } 105 else 106 transfer_waiting = 0; 107 #endif 108 109 /* Clear pending transfer and stall status. */ 110 ed -> ux_sim_slave_ed_status &= ~(ULONG)(transfer_waiting | 111 UX_DCD_SIM_SLAVE_ED_STATUS_STALLED | 112 UX_DCD_SIM_SLAVE_ED_STATUS_DONE); 113 114 #if !defined(UX_DEVICE_STANDALONE) 115 116 /* If some thread is pending, signal wakeup. */ 117 if (transfer_waiting) 118 { 119 transfer = &endpoint -> ux_slave_endpoint_transfer_request; 120 transfer -> ux_slave_transfer_request_completion_code = UX_TRANSFER_BUS_RESET; 121 _ux_device_semaphore_put(&transfer -> ux_slave_transfer_request_semaphore); 122 } 123 #endif 124 125 /* This function never fails. */ 126 return(UX_SUCCESS); 127 } 128 129