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_status PORTABLE C */ 37 /* 6.1.6 */ 38 /* AUTHOR */ 39 /* */ 40 /* Chaoqiong Xiao, Microsoft Corporation */ 41 /* */ 42 /* DESCRIPTION */ 43 /* */ 44 /* This function will return the status of the endpoint. */ 45 /* */ 46 /* INPUT */ 47 /* */ 48 /* dcd_sim_slave Pointer to device controller */ 49 /* endpoint_index Endpoint index */ 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 /* 04-02-2021 Chaoqiong Xiao Modified comment(s), */ 71 /* supported bi-dir-endpoints, */ 72 /* resulting in version 6.1.6 */ 73 /* */ 74 /**************************************************************************/ _ux_dcd_sim_slave_endpoint_status(UX_DCD_SIM_SLAVE * dcd_sim_slave,ULONG endpoint_index)75UINT _ux_dcd_sim_slave_endpoint_status(UX_DCD_SIM_SLAVE *dcd_sim_slave, ULONG endpoint_index) 76 { 77 78 UX_DCD_SIM_SLAVE_ED *ed; 79 80 81 #ifdef UX_DEVICE_BIDIRECTIONAL_ENDPOINT_SUPPORT 82 ULONG ed_addr = endpoint_index; /* Passed value as endpoint address. */ 83 ULONG ed_dir = ed_addr & UX_ENDPOINT_DIRECTION; 84 ULONG ed_index = ed_addr & ~UX_ENDPOINT_DIRECTION; 85 86 /* Fetch the address of the physical endpoint. */ 87 ed = ((ed_addr == 0) ? &dcd_sim_slave -> ux_dcd_sim_slave_ed[0] : 88 ((ed_dir) ? &dcd_sim_slave -> ux_dcd_sim_slave_ed_in[ed_index] : 89 &dcd_sim_slave -> ux_dcd_sim_slave_ed[ed_index])); 90 #else 91 92 /* Fetch the address of the physical endpoint. */ 93 ed = &dcd_sim_slave -> ux_dcd_sim_slave_ed[endpoint_index]; 94 #endif 95 96 /* Check the endpoint status, if it is free, we have a illegal endpoint. */ 97 if ((ed -> ux_sim_slave_ed_status & UX_DCD_SIM_SLAVE_ED_STATUS_USED) == 0) 98 return(UX_ERROR); 99 100 /* Check if the endpoint is stalled. */ 101 if ((ed -> ux_sim_slave_ed_status & UX_DCD_SIM_SLAVE_ED_STATUS_STALLED) == 0) 102 return(UX_FALSE); 103 else 104 return(UX_TRUE); 105 } 106 107