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
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
use poll_fn;
use PhantomData;
use ;
use Poll;
use AtomicWaker;
use embassy_usb_driver as driver;
use ;
pub use common;
pub use UsbInstance;
pub use Endpoint;
use ;
pub use MusbDriver;
pub use Bus;
pub use ControlPipe;
// TODO
const EP_COUNT: usize = 6;
const MAX_FIFO_SIZE_BTYES: = ;
// TODO
// const MAX_FIFO_SIZE_BTYES: u8 = 8;
const NEW_AW: AtomicWaker = new;
static BUS_WAKER: AtomicWaker = NEW_AW;
static EP_TX_WAKERS: = ;
static EP_RX_WAKERS: = ;
static IRQ_RESET: AtomicBool = new;
static IRQ_SUSPEND: AtomicBool = new;
static IRQ_RESUME: AtomicBool = new;
static EP_TX_ENABLED: AtomicU16 = new;
static EP_RX_ENABLED: AtomicU16 = new;
/// Interrupt handler.
pub unsafe
/// Marker type for the "IN" direction.
/// Marker type for the "OUT" direction.
// typedef volatile struct
// {
// /* common registers */
// REG8 faddr; //0x0000
// REG8 power; //0x0001
// REG16 intrtx; //0x0002
// REG16 intrrx; //0x0004
// REG16 intrtxe; //0x0006
// REG16 intrrxe; //0x0008
// REG8 intrusb; //0x000a
// REG8 intrusbe; //0x000b
// REG16 frame; //0x000c
// REG8 index; //0x000e
// REG8 testmode; //0x000f
// /* indexed registers */
// REG16 txmaxp; //0x0010
// REG16 csr0_txcsr; //0x0012
// REG16 rxmaxp; //0x0014
// REG16 rxcsr; //0x0016
// REG16 rxcount; //0x0018
// REG8 txtype; //0x001a
// REG8 txinterval; //0x001b
// REG8 rxtype; //0x001c
// REG8 rxinterval; //0x001d
// REG8 reserved0; //0x001e
// REG8 cfdt_fifosz; //0x001f
// /* fifo */
// REG32 fifox[0x10]; //0x0020
// /* OTG, dynamic FIFO, version & vendor registers */
// REG8 devctl; //0x0060
// REG8 reserved1; //0x0061
// REG8 txfifosz; //0x0062
// REG8 rxfifosz; //0x0063
// REG16 txfifoadd; //0x0064
// REG16 rxfifoadd; //0x0066
// REG32 vcontrol; //0x0068
// REG16 hwvers; //0x006c
// REG16 reserved2a[1]; //0x006e
// REG8 ulpi_busctl; //0x0070
// REG8 reserved2b[1]; //0x0071
// REG16 reserved2[3]; //0x0072
// REG8 epinfo; //0x0078
// REG8 raminfo; //0x0079
// REG8 linkinfo; //0x007a
// REG8 vplen; //0x007b
// REG8 hseof1; //0x007c
// REG8 fseof1; //0x007d
// REG8 lseof1; //0x007e
// REG8 soft_rst; //0x007f
// /* target address registers */ //0x0080
// struct musb_tar_regs
// {
// REG8 txfuncaddr;
// REG8 reserved0;
// REG8 txhubaddr;
// REG8 txhubport;
// REG8 rxfuncaddr;
// REG8 reserved1;
// REG8 rxhubaddr;
// REG8 rxhubport;
// } tar[0x10];
// /*
// * endpoint registers
// * ep0 elements are valid when array index is 0
// * otherwise epN is valid
// */
// union musb_ep_regs //0x0100
// {
// struct musb_ep0_regs ep0;
// struct musb_epN_regs epN;
// } ep[0x10];
// //REG32 reserved1fe; //0x0200
// REG32 dmaintr;
// struct musb_dma_regs
// {
// REG32 cntl; //0x0204
// REG32 addr; //0x0208
// REG32 count; //0x020c
// REG32 rsvd; //0x0210
// } dma[0x10];
// struct musb_reserved_1
// {
// REG32 reserved_1; //0x0304
// } rsvd_1[0xf];
// REG8 dpbrxdisl; //0x0340
// REG8 dpbrxdish; //0x0341
// REG8 dpbtxdisl; //0x0342
// REG8 dpbtxdish; //0x0343
// struct musb_reserved_2
// {
// REG32 reserved_2; //0x0344
// } rsvd_2[0x9];
// REG8 dbgl; //0x0368
// REG8 dbgh; //0x0369
// REG16 reserved_0; //0x036a
// REG32 reserved_1; //0x036c
// REG8 usbcfg; //0x0370
// struct musb_reserved_3
// {
// REG8 reserved_3; //0x0371~0x3bb
// } rsvd_3[0x4b];
// REG8 dbgcntl0; //0x3bc
// REG8 dbgcntl1; //0x3bd
// } __attribute__((packed, aligned(32))) USBC_X_Typedef;