summaryrefslogtreecommitdiff
path: root/common/core/inc/ux_dcd_sim_slave.h
blob: d3f451729998556cee0959f4d5f9e124fce8390a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
/***************************************************************************
 * Copyright (c) 2024 Microsoft Corporation
 * Copyright (c) 2026-present Eclipse ThreadX contributors
 *
 * This program and the accompanying materials are made available under the
 * terms of the MIT License which is available at
 * https://opensource.org/licenses/MIT.
 *
 * SPDX-License-Identifier: MIT
 **************************************************************************/


/**************************************************************************/
/**************************************************************************/
/**                                                                       */
/** USBX Component                                                        */
/**                                                                       */
/**   Slave Simulator Controller Driver                                   */
/**                                                                       */
/**************************************************************************/
/**************************************************************************/


/**************************************************************************/
/*                                                                        */
/*  COMPONENT DEFINITION                                   RELEASE        */
/*                                                                        */
/*    ux_dcd_sim_slave.h                                  PORTABLE C      */
/*                                                           6.1.10       */
/*  AUTHOR                                                                */
/*                                                                        */
/*    Chaoqiong Xiao, Microsoft Corporation                               */
/*                                                                        */
/*  DESCRIPTION                                                           */
/*                                                                        */
/*    This file contains all the header and extern functions used by the  */
/*    USBX slave simulator. It is designed to work ONLY with the USBX     */
/*    host simulator.                                                     */
/*                                                                        */
/**************************************************************************/

#ifndef UX_DCD_SIM_SLAVE_H
#define UX_DCD_SIM_SLAVE_H

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

#ifdef   __cplusplus

/* Yes, C++ compiler is present.  Use standard C.  */
extern   "C" {

#endif


/* Define USB slave simulator major equivalences.  */

#define UX_DCD_SIM_SLAVE_SLAVE_CONTROLLER                       98
#define UX_DCD_SIM_SLAVE_MAX_ED                                 16


/* Define USB slave simulator error code register bits.  */

#define UX_DCD_SIM_SLAVE_ERROR_TRANSMISSION_OK                  0x00000001u
#define UX_DCD_SIM_SLAVE_ERROR_CODE_MASK                        0x0000000eu
#define UX_DCD_SIM_SLAVE_ERROR_CODE_SHIFT                       0x00000001u
#define UX_DCD_SIM_SLAVE_ERROR_CODE_PID_ERROR                   0x00000001u
#define UX_DCD_SIM_SLAVE_ERROR_CODE_PID_UNKNOWN                 0x00000002u
#define UX_DCD_SIM_SLAVE_ERROR_CODE_UNEXPECTED_PACKET           0x00000003u
#define UX_DCD_SIM_SLAVE_ERROR_CODE_TOKEN_CRC                   0x00000004u
#define UX_DCD_SIM_SLAVE_ERROR_CODE_DATA_CRC                    0x00000005u
#define UX_DCD_SIM_SLAVE_ERROR_CODE_TIME_OUT                    0x00000006u
#define UX_DCD_SIM_SLAVE_ERROR_CODE_BABBLE                      0x00000007u
#define UX_DCD_SIM_SLAVE_ERROR_CODE_UNEXPECTED_EOP              0x00000008u
#define UX_DCD_SIM_SLAVE_ERROR_CODE_NAK                         0x00000009u
#define UX_DCD_SIM_SLAVE_ERROR_CODE_STALLED                     0x0000000au
#define UX_DCD_SIM_SLAVE_ERROR_CODE_OVERFLOW                    0x0000000bu
#define UX_DCD_SIM_SLAVE_ERROR_CODE_EMPTY_PACKET                0x0000000cu
#define UX_DCD_SIM_SLAVE_ERROR_CODE_BIT_STUFFING                0x0000000du
#define UX_DCD_SIM_SLAVE_ERROR_CODE_SYNC_ERROR                  0x0000000eu
#define UX_DCD_SIM_SLAVE_ERROR_CODE_DATA_TOGGLE                 0x0000000fu


/* Define USB slave simulator physical endpoint status definition.  */

#define UX_DCD_SIM_SLAVE_ED_STATUS_UNUSED                       0u
#define UX_DCD_SIM_SLAVE_ED_STATUS_USED                         1u
#define UX_DCD_SIM_SLAVE_ED_STATUS_TRANSFER                     2u
#define UX_DCD_SIM_SLAVE_ED_STATUS_STALLED                      4u
#define UX_DCD_SIM_SLAVE_ED_STATUS_DONE                         8u


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

typedef struct UX_DCD_SIM_SLAVE_ED_STRUCT
{

    ULONG           ux_sim_slave_ed_status;
    ULONG           ux_sim_slave_ed_index;
    ULONG           ux_sim_slave_ed_payload_length;
    ULONG           ux_sim_slave_ed_ping_pong;
    ULONG           ux_sim_slave_ed_status_register;
    ULONG           ux_sim_slave_ed_configuration_value;
    struct UX_SLAVE_ENDPOINT_STRUCT
                    *ux_sim_slave_ed_endpoint;
} UX_DCD_SIM_SLAVE_ED;


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

typedef struct UX_DCD_SIM_SLAVE_STRUCT
{

    struct UX_SLAVE_DCD_STRUCT
                    *ux_dcd_sim_slave_dcd_owner;
    struct UX_DCD_SIM_SLAVE_ED_STRUCT
                    ux_dcd_sim_slave_ed[UX_DCD_SIM_SLAVE_MAX_ED];
#ifdef UX_DEVICE_BIDIRECTIONAL_ENDPOINT_SUPPORT
    struct UX_DCD_SIM_SLAVE_ED_STRUCT
                    ux_dcd_sim_slave_ed_in[UX_DCD_SIM_SLAVE_MAX_ED];
#endif
    UINT            (*ux_dcd_sim_slave_dcd_control_request_process_hub)(UX_SLAVE_TRANSFER *transfer_request);
    VOID            *ux_dcd_sim_slave_hcd;
} UX_DCD_SIM_SLAVE;


/* Define slave simulator function prototypes.  */

UINT    _ux_dcd_sim_slave_address_set(UX_DCD_SIM_SLAVE *dcd_sim_slave, ULONG address);
UINT    _ux_dcd_sim_slave_endpoint_create(UX_DCD_SIM_SLAVE *dcd_sim_slave, UX_SLAVE_ENDPOINT *endpoint);
UINT    _ux_dcd_sim_slave_endpoint_destroy(UX_DCD_SIM_SLAVE *dcd_sim_slave, UX_SLAVE_ENDPOINT *endpoint);
UINT    _ux_dcd_sim_slave_endpoint_reset(UX_DCD_SIM_SLAVE *dcd_sim_slave, UX_SLAVE_ENDPOINT *endpoint);
UINT    _ux_dcd_sim_slave_endpoint_stall(UX_DCD_SIM_SLAVE *dcd_sim_slave, UX_SLAVE_ENDPOINT *endpoint);
UINT    _ux_dcd_sim_slave_endpoint_status(UX_DCD_SIM_SLAVE *dcd_sim_slave, ULONG endpoint_index);
UINT    _ux_dcd_sim_slave_frame_number_get(UX_DCD_SIM_SLAVE *dcd_sim_slave, ULONG *frame_number);
UINT    _ux_dcd_sim_slave_function(UX_SLAVE_DCD *dcd, UINT function, VOID *parameter);
UINT    _ux_dcd_sim_slave_initialize(VOID);
UINT    _ux_dcd_sim_slave_initialize_complete(VOID);
UINT    _ux_dcd_sim_slave_uninitialize(VOID);
UINT    _ux_dcd_sim_slave_state_change(UX_DCD_SIM_SLAVE *dcd_sim_slave, ULONG state);
UINT    _ux_dcd_sim_slave_transfer_request(UX_DCD_SIM_SLAVE *dcd_sim_slave, UX_SLAVE_TRANSFER *transfer_request);
UINT    _ux_dcd_sim_slave_transfer_run(UX_DCD_SIM_SLAVE *dcd_sim_slave, UX_SLAVE_TRANSFER *transfer_request);
UINT    _ux_dcd_sim_slave_transfer_abort(UX_DCD_SIM_SLAVE *dcd_sim_slave, UX_SLAVE_TRANSFER *transfer_request);

/* Define Device Simulator Class API prototypes.  */

#define ux_dcd_sim_slave_initialize                 _ux_dcd_sim_slave_initialize
#define ux_dcd_sim_slave_uninitialize               _ux_dcd_sim_slave_uninitialize

/* Determine if a C++ compiler is being used.  If so, complete the standard
   C conditional started above.  */
#ifdef __cplusplus
}
#endif

#endif