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 24 /**************************************************************************/ 25 /* */ 26 /* COMPONENT DEFINITION RELEASE */ 27 /* */ 28 /* ux_dcd_sim_slave.h PORTABLE C */ 29 /* 6.1.10 */ 30 /* AUTHOR */ 31 /* */ 32 /* Chaoqiong Xiao, Microsoft Corporation */ 33 /* */ 34 /* DESCRIPTION */ 35 /* */ 36 /* This file contains all the header and extern functions used by the */ 37 /* USBX slave simulator. It is designed to work ONLY with the USBX */ 38 /* host simulator. */ 39 /* */ 40 /* RELEASE HISTORY */ 41 /* */ 42 /* DATE NAME DESCRIPTION */ 43 /* */ 44 /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */ 45 /* 09-30-2020 Chaoqiong Xiao Modified comment(s), */ 46 /* resulting in version 6.1 */ 47 /* 04-02-2021 Chaoqiong Xiao Modified comment(s), */ 48 /* added HCD connected to, */ 49 /* supported bi-dir-endpoints, */ 50 /* resulting in version 6.1.6 */ 51 /* 08-02-2021 Chaoqiong Xiao Modified comment(s), */ 52 /* added extern "C" keyword */ 53 /* for compatibility with C++, */ 54 /* resulting in version 6.1.8 */ 55 /* 01-31-2022 Chaoqiong Xiao Modified comment(s), */ 56 /* added standalone support, */ 57 /* resulting in version 6.1.10 */ 58 /* */ 59 /**************************************************************************/ 60 61 #ifndef UX_DCD_SIM_SLAVE_H 62 #define UX_DCD_SIM_SLAVE_H 63 64 /* Determine if a C++ compiler is being used. If so, ensure that standard 65 C is used to process the API information. */ 66 67 #ifdef __cplusplus 68 69 /* Yes, C++ compiler is present. Use standard C. */ 70 extern "C" { 71 72 #endif 73 74 75 /* Define USB slave simulator major equivalences. */ 76 77 #define UX_DCD_SIM_SLAVE_SLAVE_CONTROLLER 98 78 #define UX_DCD_SIM_SLAVE_MAX_ED 16 79 80 81 /* Define USB slave simulator error code register bits. */ 82 83 #define UX_DCD_SIM_SLAVE_ERROR_TRANSMISSION_OK 0x00000001u 84 #define UX_DCD_SIM_SLAVE_ERROR_CODE_MASK 0x0000000eu 85 #define UX_DCD_SIM_SLAVE_ERROR_CODE_SHIFT 0x00000001u 86 #define UX_DCD_SIM_SLAVE_ERROR_CODE_PID_ERROR 0x00000001u 87 #define UX_DCD_SIM_SLAVE_ERROR_CODE_PID_UNKNOWN 0x00000002u 88 #define UX_DCD_SIM_SLAVE_ERROR_CODE_UNEXPECTED_PACKET 0x00000003u 89 #define UX_DCD_SIM_SLAVE_ERROR_CODE_TOKEN_CRC 0x00000004u 90 #define UX_DCD_SIM_SLAVE_ERROR_CODE_DATA_CRC 0x00000005u 91 #define UX_DCD_SIM_SLAVE_ERROR_CODE_TIME_OUT 0x00000006u 92 #define UX_DCD_SIM_SLAVE_ERROR_CODE_BABBLE 0x00000007u 93 #define UX_DCD_SIM_SLAVE_ERROR_CODE_UNEXPECTED_EOP 0x00000008u 94 #define UX_DCD_SIM_SLAVE_ERROR_CODE_NAK 0x00000009u 95 #define UX_DCD_SIM_SLAVE_ERROR_CODE_STALLED 0x0000000au 96 #define UX_DCD_SIM_SLAVE_ERROR_CODE_OVERFLOW 0x0000000bu 97 #define UX_DCD_SIM_SLAVE_ERROR_CODE_EMPTY_PACKET 0x0000000cu 98 #define UX_DCD_SIM_SLAVE_ERROR_CODE_BIT_STUFFING 0x0000000du 99 #define UX_DCD_SIM_SLAVE_ERROR_CODE_SYNC_ERROR 0x0000000eu 100 #define UX_DCD_SIM_SLAVE_ERROR_CODE_DATA_TOGGLE 0x0000000fu 101 102 103 /* Define USB slave simulator physical endpoint status definition. */ 104 105 #define UX_DCD_SIM_SLAVE_ED_STATUS_UNUSED 0u 106 #define UX_DCD_SIM_SLAVE_ED_STATUS_USED 1u 107 #define UX_DCD_SIM_SLAVE_ED_STATUS_TRANSFER 2u 108 #define UX_DCD_SIM_SLAVE_ED_STATUS_STALLED 4u 109 #define UX_DCD_SIM_SLAVE_ED_STATUS_DONE 8u 110 111 112 /* Define USB slave simulator physical endpoint structure. */ 113 114 typedef struct UX_DCD_SIM_SLAVE_ED_STRUCT 115 { 116 117 ULONG ux_sim_slave_ed_status; 118 ULONG ux_sim_slave_ed_index; 119 ULONG ux_sim_slave_ed_payload_length; 120 ULONG ux_sim_slave_ed_ping_pong; 121 ULONG ux_sim_slave_ed_status_register; 122 ULONG ux_sim_slave_ed_configuration_value; 123 struct UX_SLAVE_ENDPOINT_STRUCT 124 *ux_sim_slave_ed_endpoint; 125 } UX_DCD_SIM_SLAVE_ED; 126 127 128 /* Define USB slave simulator DCD structure definition. */ 129 130 typedef struct UX_DCD_SIM_SLAVE_STRUCT 131 { 132 133 struct UX_SLAVE_DCD_STRUCT 134 *ux_dcd_sim_slave_dcd_owner; 135 struct UX_DCD_SIM_SLAVE_ED_STRUCT 136 ux_dcd_sim_slave_ed[UX_DCD_SIM_SLAVE_MAX_ED]; 137 #ifdef UX_DEVICE_BIDIRECTIONAL_ENDPOINT_SUPPORT 138 struct UX_DCD_SIM_SLAVE_ED_STRUCT 139 ux_dcd_sim_slave_ed_in[UX_DCD_SIM_SLAVE_MAX_ED]; 140 #endif 141 UINT (*ux_dcd_sim_slave_dcd_control_request_process_hub)(UX_SLAVE_TRANSFER *transfer_request); 142 VOID *ux_dcd_sim_slave_hcd; 143 } UX_DCD_SIM_SLAVE; 144 145 146 /* Define slave simulator function prototypes. */ 147 148 UINT _ux_dcd_sim_slave_address_set(UX_DCD_SIM_SLAVE *dcd_sim_slave, ULONG address); 149 UINT _ux_dcd_sim_slave_endpoint_create(UX_DCD_SIM_SLAVE *dcd_sim_slave, UX_SLAVE_ENDPOINT *endpoint); 150 UINT _ux_dcd_sim_slave_endpoint_destroy(UX_DCD_SIM_SLAVE *dcd_sim_slave, UX_SLAVE_ENDPOINT *endpoint); 151 UINT _ux_dcd_sim_slave_endpoint_reset(UX_DCD_SIM_SLAVE *dcd_sim_slave, UX_SLAVE_ENDPOINT *endpoint); 152 UINT _ux_dcd_sim_slave_endpoint_stall(UX_DCD_SIM_SLAVE *dcd_sim_slave, UX_SLAVE_ENDPOINT *endpoint); 153 UINT _ux_dcd_sim_slave_endpoint_status(UX_DCD_SIM_SLAVE *dcd_sim_slave, ULONG endpoint_index); 154 UINT _ux_dcd_sim_slave_frame_number_get(UX_DCD_SIM_SLAVE *dcd_sim_slave, ULONG *frame_number); 155 UINT _ux_dcd_sim_slave_function(UX_SLAVE_DCD *dcd, UINT function, VOID *parameter); 156 UINT _ux_dcd_sim_slave_initialize(VOID); 157 UINT _ux_dcd_sim_slave_initialize_complete(VOID); 158 UINT _ux_dcd_sim_slave_state_change(UX_DCD_SIM_SLAVE *dcd_sim_slave, ULONG state); 159 UINT _ux_dcd_sim_slave_transfer_request(UX_DCD_SIM_SLAVE *dcd_sim_slave, UX_SLAVE_TRANSFER *transfer_request); 160 UINT _ux_dcd_sim_slave_transfer_run(UX_DCD_SIM_SLAVE *dcd_sim_slave, UX_SLAVE_TRANSFER *transfer_request); 161 UINT _ux_dcd_sim_slave_transfer_abort(UX_DCD_SIM_SLAVE *dcd_sim_slave, UX_SLAVE_TRANSFER *transfer_request); 162 163 /* Define Device Simulator Class API prototypes. */ 164 165 #define ux_dcd_sim_slave_initialize _ux_dcd_sim_slave_initialize 166 167 /* Determine if a C++ compiler is being used. If so, complete the standard 168 C conditional started above. */ 169 #ifdef __cplusplus 170 } 171 #endif 172 173 #endif 174 175