Skip to content

Commit f1234a4

Browse files
committed
DCD Simulator Controller Driver: Add uninitializes API
- Adds _ux_dcd_sim_slave_uninitialize() to free the simulated slave DCD controller instance, clear DCD bindings, and return the DCD to UX_UNUSED (idempotent if already unused). - Registers the new uninitialize source in CMakeLists.txt. - Updates simulator headers to export ux_dcd_sim_slave_uninitialize (and ux_hcd_sim_host_uninitialize) and does minor whitespace/style cleanup in the simulator header blocks.
1 parent 515c9a4 commit f1234a4

File tree

4 files changed

+186
-93
lines changed

4 files changed

+186
-93
lines changed

common/core/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ target_sources(${PROJECT_NAME} PRIVATE
1010
${CMAKE_CURRENT_LIST_DIR}/src/ux_dcd_sim_slave_function.c
1111
${CMAKE_CURRENT_LIST_DIR}/src/ux_dcd_sim_slave_initialize.c
1212
${CMAKE_CURRENT_LIST_DIR}/src/ux_dcd_sim_slave_initialize_complete.c
13+
${CMAKE_CURRENT_LIST_DIR}/src/ux_dcd_sim_slave_uninitialize.c
1314
${CMAKE_CURRENT_LIST_DIR}/src/ux_dcd_sim_slave_state_change.c
1415
${CMAKE_CURRENT_LIST_DIR}/src/ux_dcd_sim_slave_transfer_abort.c
1516
${CMAKE_CURRENT_LIST_DIR}/src/ux_dcd_sim_slave_transfer_request.c

common/core/inc/ux_dcd_sim_slave.h

Lines changed: 35 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,45 @@
11
/***************************************************************************
2-
* Copyright (c) 2024 Microsoft Corporation
3-
*
2+
* Copyright (c) 2024 Microsoft Corporation
3+
*
44
* This program and the accompanying materials are made available under the
55
* terms of the MIT License which is available at
66
* https://opensource.org/licenses/MIT.
7-
*
7+
*
88
* SPDX-License-Identifier: MIT
99
**************************************************************************/
1010

1111

1212
/**************************************************************************/
1313
/**************************************************************************/
14-
/** */
15-
/** USBX Component */
14+
/** */
15+
/** USBX Component */
1616
/** */
1717
/** Slave Simulator Controller Driver */
1818
/** */
1919
/**************************************************************************/
2020
/**************************************************************************/
2121

2222

23-
/**************************************************************************/
24-
/* */
25-
/* COMPONENT DEFINITION RELEASE */
26-
/* */
27-
/* ux_dcd_sim_slave.h PORTABLE C */
23+
/**************************************************************************/
24+
/* */
25+
/* COMPONENT DEFINITION RELEASE */
26+
/* */
27+
/* ux_dcd_sim_slave.h PORTABLE C */
2828
/* 6.1.10 */
2929
/* AUTHOR */
3030
/* */
3131
/* Chaoqiong Xiao, Microsoft Corporation */
3232
/* */
3333
/* DESCRIPTION */
34-
/* */
34+
/* */
3535
/* This file contains all the header and extern functions used by the */
36-
/* USBX slave simulator. It is designed to work ONLY with the USBX */
37-
/* host simulator. */
38-
/* */
39-
/* RELEASE HISTORY */
40-
/* */
41-
/* DATE NAME DESCRIPTION */
42-
/* */
36+
/* USBX slave simulator. It is designed to work ONLY with the USBX */
37+
/* host simulator. */
38+
/* */
39+
/* RELEASE HISTORY */
40+
/* */
41+
/* DATE NAME DESCRIPTION */
42+
/* */
4343
/* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */
4444
/* 09-30-2020 Chaoqiong Xiao Modified comment(s), */
4545
/* resulting in version 6.1 */
@@ -60,15 +60,15 @@
6060
#ifndef UX_DCD_SIM_SLAVE_H
6161
#define UX_DCD_SIM_SLAVE_H
6262

63-
/* Determine if a C++ compiler is being used. If so, ensure that standard
64-
C is used to process the API information. */
63+
/* Determine if a C++ compiler is being used. If so, ensure that standard
64+
C is used to process the API information. */
6565

66-
#ifdef __cplusplus
66+
#ifdef __cplusplus
6767

68-
/* Yes, C++ compiler is present. Use standard C. */
69-
extern "C" {
68+
/* Yes, C++ compiler is present. Use standard C. */
69+
extern "C" {
7070

71-
#endif
71+
#endif
7272

7373

7474
/* Define USB slave simulator major equivalences. */
@@ -110,7 +110,7 @@ extern "C" {
110110

111111
/* Define USB slave simulator physical endpoint structure. */
112112

113-
typedef struct UX_DCD_SIM_SLAVE_ED_STRUCT
113+
typedef struct UX_DCD_SIM_SLAVE_ED_STRUCT
114114
{
115115

116116
ULONG ux_sim_slave_ed_status;
@@ -119,22 +119,22 @@ typedef struct UX_DCD_SIM_SLAVE_ED_STRUCT
119119
ULONG ux_sim_slave_ed_ping_pong;
120120
ULONG ux_sim_slave_ed_status_register;
121121
ULONG ux_sim_slave_ed_configuration_value;
122-
struct UX_SLAVE_ENDPOINT_STRUCT
122+
struct UX_SLAVE_ENDPOINT_STRUCT
123123
*ux_sim_slave_ed_endpoint;
124124
} UX_DCD_SIM_SLAVE_ED;
125125

126126

127127
/* Define USB slave simulator DCD structure definition. */
128128

129129
typedef struct UX_DCD_SIM_SLAVE_STRUCT
130-
{
130+
{
131131

132-
struct UX_SLAVE_DCD_STRUCT
132+
struct UX_SLAVE_DCD_STRUCT
133133
*ux_dcd_sim_slave_dcd_owner;
134-
struct UX_DCD_SIM_SLAVE_ED_STRUCT
134+
struct UX_DCD_SIM_SLAVE_ED_STRUCT
135135
ux_dcd_sim_slave_ed[UX_DCD_SIM_SLAVE_MAX_ED];
136136
#ifdef UX_DEVICE_BIDIRECTIONAL_ENDPOINT_SUPPORT
137-
struct UX_DCD_SIM_SLAVE_ED_STRUCT
137+
struct UX_DCD_SIM_SLAVE_ED_STRUCT
138138
ux_dcd_sim_slave_ed_in[UX_DCD_SIM_SLAVE_MAX_ED];
139139
#endif
140140
UINT (*ux_dcd_sim_slave_dcd_control_request_process_hub)(UX_SLAVE_TRANSFER *transfer_request);
@@ -154,6 +154,7 @@ UINT _ux_dcd_sim_slave_frame_number_get(UX_DCD_SIM_SLAVE *dcd_sim_slave, ULON
154154
UINT _ux_dcd_sim_slave_function(UX_SLAVE_DCD *dcd, UINT function, VOID *parameter);
155155
UINT _ux_dcd_sim_slave_initialize(VOID);
156156
UINT _ux_dcd_sim_slave_initialize_complete(VOID);
157+
UINT _ux_dcd_sim_slave_uninitialize(VOID);
157158
UINT _ux_dcd_sim_slave_state_change(UX_DCD_SIM_SLAVE *dcd_sim_slave, ULONG state);
158159
UINT _ux_dcd_sim_slave_transfer_request(UX_DCD_SIM_SLAVE *dcd_sim_slave, UX_SLAVE_TRANSFER *transfer_request);
159160
UINT _ux_dcd_sim_slave_transfer_run(UX_DCD_SIM_SLAVE *dcd_sim_slave, UX_SLAVE_TRANSFER *transfer_request);
@@ -162,11 +163,12 @@ UINT _ux_dcd_sim_slave_transfer_abort(UX_DCD_SIM_SLAVE *dcd_sim_slave, UX_SLA
162163
/* Define Device Simulator Class API prototypes. */
163164

164165
#define ux_dcd_sim_slave_initialize _ux_dcd_sim_slave_initialize
166+
#define ux_dcd_sim_slave_uninitialize _ux_dcd_sim_slave_uninitialize
165167

166-
/* Determine if a C++ compiler is being used. If so, complete the standard
167-
C conditional started above. */
168+
/* Determine if a C++ compiler is being used. If so, complete the standard
169+
C conditional started above. */
168170
#ifdef __cplusplus
169-
}
171+
}
170172
#endif
171173

172174
#endif

0 commit comments

Comments
 (0)