Open FFBoard
Open source force feedback firmware
dcd_nuc121.c
Go to the documentation of this file.
1/*
2 * The MIT License (MIT)
3 *
4 * Copyright (c) 2019 Peter Lawrence
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to deal
8 * in the Software without restriction, including without limitation the rights
9 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 * copies of the Software, and to permit persons to whom the Software is
11 * furnished to do so, subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be included in
14 * all copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 * THE SOFTWARE.
23 *
24 * This file is part of the TinyUSB stack.
25 */
26
27/*
28 Theory of operation:
29
30 The NUC121/NUC125/NUC126 USBD peripheral has eight "EP"s, but each is simplex,
31 so two collectively (peripheral nomenclature of "EP0" and "EP1") are needed to
32 implement USB EP0. PERIPH_EP0 and PERIPH_EP1 are used by this driver for
33 EP0_IN and EP0_OUT respectively. This leaves up to six for user usage.
34*/
35
36#include "tusb_option.h"
37
38#if CFG_TUD_ENABLED && ( (CFG_TUSB_MCU == OPT_MCU_NUC121) || (CFG_TUSB_MCU == OPT_MCU_NUC126) )
39
40#include "device/dcd.h"
41#include "NuMicro.h"
42
43// Since TinyUSB doesn't use SOF for now, and this interrupt too often (1ms interval)
44// We disable SOF for now until needed later on
45#ifndef USE_SOF
46# define USE_SOF 0
47#endif
48
49/* allocation of USBD RAM for Setup, EP0_IN, and and EP_OUT */
50#define PERIPH_SETUP_BUF_BASE 0
51#define PERIPH_SETUP_BUF_LEN 8
52#define PERIPH_EP0_BUF_BASE (PERIPH_SETUP_BUF_BASE + PERIPH_SETUP_BUF_LEN)
53#define PERIPH_EP0_BUF_LEN CFG_TUD_ENDPOINT0_SIZE
54#define PERIPH_EP1_BUF_BASE (PERIPH_EP0_BUF_BASE + PERIPH_EP0_BUF_LEN)
55#define PERIPH_EP1_BUF_LEN CFG_TUD_ENDPOINT0_SIZE
56#define PERIPH_EP2_BUF_BASE (PERIPH_EP1_BUF_BASE + PERIPH_EP1_BUF_LEN)
57
58/* rather important info unfortunately not provided by device include files: how much there is */
59#define USBD_BUF_SIZE ((CFG_TUSB_MCU == OPT_MCU_NUC121) ? 768 : 512)
60
62{
72};
73
74/* reset by dcd_init(), this is used by dcd_edpt_open() to assign USBD peripheral buffer addresses */
75static uint32_t bufseg_addr;
76
77/* used by dcd_edpt_xfer() and the ISR to reset the data sync (DATA0/DATA1) in an EP0_IN transfer */
78static bool active_ep0_xfer;
79
80/* RAM table needed to track ongoing transfers performed by dcd_edpt_xfer(), dcd_in_xfer(), and the ISR */
81static struct xfer_ctl_t
82{
83 uint8_t *data_ptr; /* data_ptr tracks where to next copy data to (for OUT) or from (for IN) */
84 // tu_fifo_t * ff; // TODO support dcd_edpt_xfer_fifo API
85 union {
86 uint16_t in_remaining_bytes; /* for IN endpoints, we track how many bytes are left to transfer */
87 uint16_t out_bytes_so_far; /* but for OUT endpoints, we track how many bytes we've transferred so far */
88 };
89 uint16_t max_packet_size; /* needed since device driver only finds out this at runtime */
90 uint16_t total_bytes; /* quantity needed to pass as argument to dcd_event_xfer_complete() (for IN endpoints) */
92
93/*
94 local helper functions
95*/
96
97static void usb_attach(void)
98{
99 USBD->SE0 &= ~USBD_SE0_SE0_Msk;
100}
101
102static void usb_detach(void)
103{
104 USBD->SE0 |= USBD_SE0_SE0_Msk;
105}
106
107static inline void usb_memcpy(uint8_t *dest, uint8_t *src, uint16_t size)
108{
109 while(size--) *dest++ = *src++;
110}
111
112static void usb_control_send_zlp(void)
113{
114 USBD->EP[PERIPH_EP0].CFG |= USBD_CFG_DSQSYNC_Msk;
115 USBD->EP[PERIPH_EP0].MXPLD = 0;
116}
117
118/* reconstruct ep_addr from particular USB Configuration Register */
119static uint8_t decode_ep_addr(USBD_EP_T *ep)
120{
121 uint8_t ep_addr = ep->CFG & USBD_CFG_EPNUM_Msk;
122 if ( USBD_CFG_EPMODE_IN == (ep->CFG & USBD_CFG_STATE_Msk) )
123 ep_addr |= TUSB_DIR_IN_MASK;
124 return ep_addr;
125}
126
127/* map 8-bit ep_addr into peripheral endpoint index (PERIPH_EP0...) */
128static USBD_EP_T *ep_entry(uint8_t ep_addr, bool add)
129{
130 USBD_EP_T *ep;
131 enum ep_enum ep_index;
132
133 for (ep_index = PERIPH_EP0, ep = USBD->EP; ep_index < PERIPH_MAX_EP; ep_index++, ep++)
134 {
135 if (add)
136 {
137 /* take first peripheral endpoint that is unused */
138 if (0 == (ep->CFG & USBD_CFG_STATE_Msk)) return ep;
139 }
140 else
141 {
142 /* find a peripheral endpoint that matches ep_addr */
143 uint8_t candidate_ep_addr = decode_ep_addr(ep);
144 if (candidate_ep_addr == ep_addr) return ep;
145 }
146 }
147
148 return NULL;
149}
150
151/* perform an IN endpoint transfer; this is called by dcd_edpt_xfer() and the ISR */
152static void dcd_in_xfer(struct xfer_ctl_t *xfer, USBD_EP_T *ep)
153{
154 uint16_t bytes_now = tu_min16(xfer->in_remaining_bytes, xfer->max_packet_size);
155
156#if 0 // TODO support dcd_edpt_xfer_fifo API
157 if (xfer->ff)
158 {
159 tu_fifo_read_n(xfer->ff, (void *) (USBD_BUF_BASE + ep->BUFSEG), bytes_now);
160 }
161 else
162#endif
163 {
164 // USB SRAM seems to only support byte access and memcpy could possibly do it by words
165 usb_memcpy((uint8_t *)(USBD_BUF_BASE + ep->BUFSEG), xfer->data_ptr, bytes_now);
166 }
167
168 ep->MXPLD = bytes_now;
169}
170
171/* called by dcd_init() as well as by the ISR during a USB bus reset */
172static void bus_reset(void)
173{
174 USBD->STBUFSEG = PERIPH_SETUP_BUF_BASE;
175
176 for (enum ep_enum ep_index = PERIPH_EP0; ep_index < PERIPH_MAX_EP; ep_index++)
177 {
178 USBD->EP[ep_index].CFG = 0;
179 USBD->EP[ep_index].CFGP = 0;
180 }
181
182 /* allocate the default EP0 endpoints */
183
184 USBD->EP[PERIPH_EP0].CFG = USBD_CFG_CSTALL_Msk | USBD_CFG_EPMODE_IN;
185 USBD->EP[PERIPH_EP0].BUFSEG = PERIPH_EP0_BUF_BASE;
186 xfer_table[PERIPH_EP0].max_packet_size = PERIPH_EP0_BUF_LEN;
187
188 USBD->EP[PERIPH_EP1].CFG = USBD_CFG_CSTALL_Msk | USBD_CFG_EPMODE_OUT;
189 USBD->EP[PERIPH_EP1].BUFSEG = PERIPH_EP1_BUF_BASE;
190 xfer_table[PERIPH_EP1].max_packet_size = PERIPH_EP1_BUF_LEN;
191
192 /* USB RAM beyond what we've allocated above is available to the user */
193 bufseg_addr = PERIPH_EP2_BUF_BASE;
194
195 /* Reset USB device address */
196 USBD->FADDR = 0;
197
198 /* reset EP0_IN flag */
199 active_ep0_xfer = false;
200}
201
202/* centralized location for USBD interrupt enable bit mask */
203enum {
204 ENABLED_IRQS = USBD_INTSTS_VBDETIF_Msk | USBD_INTSTS_BUSIF_Msk | USBD_INTSTS_SETUP_Msk |
205 USBD_INTSTS_USBIF_Msk | (USE_SOF ? USBD_INTSTS_SOFIF_Msk : 0)
207
208/*
209 NUC121/NUC125/NUC126 TinyUSB API driver implementation
210*/
211
212bool dcd_init(uint8_t rhport, const tusb_rhport_init_t* rh_init) {
213 (void) rhport;
214 (void) rh_init;
215
216#ifdef SUPPORT_LPM
217 USBD->ATTR = 0x7D0 | USBD_LPMACK;
218#else
219 USBD->ATTR = 0x7D0;
220#endif
221
222 usb_detach();
223
224 bus_reset();
225
226 usb_attach();
227
228 USBD->INTSTS = ENABLED_IRQS;
229 USBD->INTEN = ENABLED_IRQS;
230
231 return true;
232}
233
234void dcd_int_enable(uint8_t rhport)
235{
236 (void) rhport;
237 NVIC_EnableIRQ(USBD_IRQn);
238}
239
240void dcd_int_disable(uint8_t rhport)
241{
242 (void) rhport;
243 NVIC_DisableIRQ(USBD_IRQn);
244}
245
246void dcd_set_address(uint8_t rhport, uint8_t dev_addr)
247{
248 (void) rhport;
249 (void) dev_addr;
250 usb_control_send_zlp(); /* SET_ADDRESS is the one exception where TinyUSB doesn't use dcd_edpt_xfer() to generate a ZLP */
251
252 // DCD can only set address after status for this request is complete.
253 // do it at dcd_edpt0_status_complete()
254}
255
256static void remote_wakeup_delay(void)
257{
258 // try to delay for 1 ms
259 uint32_t count = SystemCoreClock / 1000;
260 while(count--) __NOP();
261}
262
263void dcd_remote_wakeup(uint8_t rhport)
264{
265 (void) rhport;
266 // Enable PHY before sending Resume('K') state
267 USBD->ATTR |= USBD_ATTR_PHYEN_Msk;
268 USBD->ATTR |= USBD_ATTR_RWAKEUP_Msk;
269
270 // Per specs: remote wakeup signal bit must be clear within 1-15ms
272 USBD->ATTR &=~USBD_ATTR_RWAKEUP_Msk;
273}
274
275bool dcd_edpt_open(uint8_t rhport, tusb_desc_endpoint_t const * p_endpoint_desc)
276{
277 (void) rhport;
278
279 USBD_EP_T *ep = ep_entry(p_endpoint_desc->bEndpointAddress, true);
280 TU_ASSERT(ep);
281
282 /* mine the data for the information we need */
283 int const dir = tu_edpt_dir(p_endpoint_desc->bEndpointAddress);
284 int const size = tu_edpt_packet_size(p_endpoint_desc);
285 tusb_xfer_type_t const type = (tusb_xfer_type_t) p_endpoint_desc->bmAttributes.xfer;
286 struct xfer_ctl_t *xfer = &xfer_table[ep - USBD->EP];
287
288 /* allocate buffer from USB RAM */
289 ep->BUFSEG = bufseg_addr;
290 bufseg_addr += size;
291 TU_ASSERT(bufseg_addr <= USBD_BUF_SIZE);
292
293 /* construct USB Configuration Register value and then write it */
294 uint32_t cfg = tu_edpt_number(p_endpoint_desc->bEndpointAddress);
295 cfg |= (TUSB_DIR_IN == dir) ? USBD_CFG_EPMODE_IN : USBD_CFG_EPMODE_OUT;
296 if (TUSB_XFER_ISOCHRONOUS == type)
297 cfg |= USBD_CFG_TYPE_ISO;
298 ep->CFG = cfg;
299
300 /* make a note of the endpoint size */
301 xfer->max_packet_size = size;
302
303 return true;
304}
305
306void dcd_edpt_close_all (uint8_t rhport)
307{
308 (void) rhport;
309 // TODO implement dcd_edpt_close_all()
310}
311
312bool dcd_edpt_xfer(uint8_t rhport, uint8_t ep_addr, uint8_t *buffer, uint16_t total_bytes)
313{
314 (void) rhport;
315
316 /* mine the data for the information we need */
317 tusb_dir_t dir = tu_edpt_dir(ep_addr);
318 USBD_EP_T *ep = ep_entry(ep_addr, false);
319 struct xfer_ctl_t *xfer = &xfer_table[ep - USBD->EP];
320
321 /* store away the information we'll needing now and later */
322 xfer->data_ptr = buffer;
323 // xfer->ff = NULL; // TODO support dcd_edpt_xfer_fifo API
324 xfer->in_remaining_bytes = total_bytes;
325 xfer->total_bytes = total_bytes;
326
327 /* for the first of one or more EP0_IN packets in a message, the first must be DATA1 */
328 if ( (0x80 == ep_addr) && !active_ep0_xfer ) ep->CFG |= USBD_CFG_DSQSYNC_Msk;
329
330 if (TUSB_DIR_IN == dir)
331 {
332 dcd_in_xfer(xfer, ep);
333 }
334 else
335 {
336 xfer->out_bytes_so_far = 0;
337 ep->MXPLD = xfer->max_packet_size;
338 }
339
340 return true;
341}
342
343#if 0 // TODO support dcd_edpt_xfer_fifo API
344bool dcd_edpt_xfer_fifo (uint8_t rhport, uint8_t ep_addr, tu_fifo_t * ff, uint16_t total_bytes)
345{
346 (void) rhport;
347
348 /* mine the data for the information we need */
350 USBD_EP_T *ep = ep_entry(ep_addr, false);
351 struct xfer_ctl_t *xfer = &xfer_table[ep - USBD->EP];
352
353 /* store away the information we'll needing now and later */
354 xfer->data_ptr = NULL; // Indicates a FIFO shall be used
355 xfer->ff = ff;
356 xfer->in_remaining_bytes = total_bytes;
357 xfer->total_bytes = total_bytes;
358
359 if (TUSB_DIR_IN == dir)
360 {
361 dcd_in_xfer(xfer, ep);
362 }
363 else
364 {
365 xfer->out_bytes_so_far = 0;
366 ep->MXPLD = xfer->max_packet_size;
367 }
368
369 return true;
370}
371#endif
372
373void dcd_edpt_stall(uint8_t rhport, uint8_t ep_addr)
374{
375 (void) rhport;
376 USBD_EP_T *ep = ep_entry(ep_addr, false);
377 ep->CFGP |= USBD_CFGP_SSTALL_Msk;
378}
379
380void dcd_edpt_clear_stall(uint8_t rhport, uint8_t ep_addr)
381{
382 (void) rhport;
383 USBD_EP_T *ep = ep_entry(ep_addr, false);
384 ep->CFG = (ep->CFG & ~USBD_CFG_DSQSYNC_Msk) | USBD_CFG_CSTALL_Msk;
385}
386
387void dcd_int_handler(uint8_t rhport)
388{
389 (void) rhport;
390
391 // Mask non-enabled irqs, ex. SOF
392 uint32_t status = USBD->INTSTS & (ENABLED_IRQS | 0xffffff00);
393
394#ifdef SUPPORT_LPM
395 uint32_t state = USBD->ATTR & 0x300f;
396#else
397 uint32_t state = USBD->ATTR & 0xf;
398#endif
399
400 if(status & USBD_INTSTS_VBDETIF_Msk)
401 {
402 if(USBD->VBUSDET & USBD_VBUSDET_VBUSDET_Msk)
403 {
404 /* USB connect */
405 USBD->ATTR |= USBD_ATTR_USBEN_Msk | USBD_ATTR_PHYEN_Msk;
406 }
407 else
408 {
409 /* USB disconnect */
410 USBD->ATTR &= ~USBD_ATTR_USBEN_Msk;
411 }
412 }
413
414 if(status & USBD_INTSTS_BUSIF_Msk)
415 {
416 if(state & USBD_ATTR_USBRST_Msk)
417 {
418 /* USB bus reset */
419 USBD->ATTR |= USBD_ATTR_USBEN_Msk | USBD_ATTR_PHYEN_Msk;
420
421 bus_reset();
422
424 }
425
426 if(state & USBD_ATTR_SUSPEND_Msk)
427 {
428 /* Enable USB but disable PHY */
429 USBD->ATTR &= ~USBD_ATTR_PHYEN_Msk;
430 dcd_event_bus_signal(0, DCD_EVENT_SUSPEND, true);
431 }
432
433 if(state & USBD_ATTR_RESUME_Msk)
434 {
435 /* Enable USB and enable PHY */
436 USBD->ATTR |= USBD_ATTR_USBEN_Msk | USBD_ATTR_PHYEN_Msk;
437 dcd_event_bus_signal(0, DCD_EVENT_RESUME, true);
438 }
439 }
440
441 if(status & USBD_INTSTS_SETUP_Msk)
442 {
443 /* clear the data ready flag of control endpoints */
444 USBD->EP[PERIPH_EP0].CFGP |= USBD_CFGP_CLRRDY_Msk;
445 USBD->EP[PERIPH_EP1].CFGP |= USBD_CFGP_CLRRDY_Msk;
446
447 /* get SETUP packet from USB buffer */
448 dcd_event_setup_received(0, (uint8_t *)USBD_BUF_BASE, true);
449 }
450
451 if(status & USBD_INTSTS_USBIF_Msk)
452 {
453 if (status & USBD_INTSTS_EPEVT0_Msk) /* PERIPH_EP0 (EP0_IN) event: this is treated separately from the rest */
454 {
455 uint16_t const available_bytes = USBD->EP[PERIPH_EP0].MXPLD;
456
458
459 dcd_event_xfer_complete(0, 0x80, available_bytes, XFER_RESULT_SUCCESS, true);
460 }
461
462 /* service PERIPH_EP1 through PERIPH_EP7 */
463 enum ep_enum ep_index;
464 uint32_t mask;
465 struct xfer_ctl_t *xfer;
466 USBD_EP_T *ep;
467 for (ep_index = PERIPH_EP1, mask = USBD_INTSTS_EPEVT1_Msk, xfer = &xfer_table[PERIPH_EP1], ep = &USBD->EP[PERIPH_EP1]; ep_index <= PERIPH_EP7; ep_index++, mask <<= 1, xfer++, ep++)
468 {
469 if(status & mask)
470 {
471 USBD->INTSTS = mask;
472
473 uint16_t const available_bytes = ep->MXPLD;
474 uint8_t const ep_addr = decode_ep_addr(ep);
475 bool const out_ep = !(ep_addr & TUSB_DIR_IN_MASK);
476
477 if (out_ep)
478 {
479 /* copy the data from the PC to the previously provided buffer */
480#if 0 // TODO support dcd_edpt_xfer_fifo API
481 if (xfer->ff)
482 {
483 tu_fifo_write_n(xfer->ff, (const void *) (USBD_BUF_BASE + ep->BUFSEG), available_bytes);
484 }
485 else
486#endif
487 {
488 // USB SRAM seems to only support byte access and memcpy could possibly do it by words
489 usb_memcpy(xfer->data_ptr, (uint8_t *)(USBD_BUF_BASE + ep->BUFSEG), available_bytes);
490 xfer->data_ptr += available_bytes;
491 }
492
493 xfer->out_bytes_so_far += available_bytes;
494
495 /* when the transfer is finished, alert TinyUSB; otherwise, accept more data */
496 if ( (xfer->total_bytes == xfer->out_bytes_so_far) || (available_bytes < xfer->max_packet_size) )
497 dcd_event_xfer_complete(0, ep_addr, xfer->out_bytes_so_far, XFER_RESULT_SUCCESS, true);
498 else
499 ep->MXPLD = xfer->max_packet_size;
500 }
501 else
502 {
503 /* update the bookkeeping to reflect the data that has now been sent to the PC */
504 xfer->in_remaining_bytes -= available_bytes;
505 xfer->data_ptr += available_bytes;
506
507 /* if more data to send, send it; otherwise, alert TinyUSB that we've finished */
508 if (xfer->in_remaining_bytes)
509 dcd_in_xfer(xfer, ep);
510 else
512 }
513 }
514 }
515 }
516
517 if(status & USBD_INTSTS_SOFIF_Msk)
518 {
519 /* Start-Of-Frame event */
520 dcd_event_bus_signal(0, DCD_EVENT_SOF, true);
521 }
522
523 /* acknowledge all interrupts */
524 USBD->INTSTS = status & ENABLED_IRQS;
525}
526
527// Invoked when a control transfer's status stage is complete.
528// May help DCD to prepare for next control transfer, this API is optional.
530{
531 (void) rhport;
532
536 {
537 uint8_t const dev_addr = (uint8_t) request->wValue;
538
539 // Setting new address after the whole request is complete
540 USBD->FADDR = dev_addr;
541 }
542}
543
544void dcd_disconnect(uint8_t rhport)
545{
546 (void) rhport;
547 usb_detach();
548}
549
550void dcd_connect(uint8_t rhport)
551{
552 (void) rhport;
553 usb_attach();
554}
555
556void dcd_sof_enable(uint8_t rhport, bool en)
557{
558 (void) rhport;
559 (void) en;
560
561 // TODO implement later
562}
563
564#endif
static TU_ATTR_ALWAYS_INLINE void dcd_event_bus_signal(uint8_t rhport, dcd_eventid_t eid, bool in_isr)
Definition: dcd.h:196
static TU_ATTR_ALWAYS_INLINE void dcd_event_xfer_complete(uint8_t rhport, uint8_t ep_addr, uint32_t xferred_bytes, uint8_t result, bool in_isr)
Definition: dcd.h:222
static TU_ATTR_ALWAYS_INLINE void dcd_event_setup_received(uint8_t rhport, uint8_t const *setup, bool in_isr)
Definition: dcd.h:213
static TU_ATTR_ALWAYS_INLINE void dcd_event_bus_reset(uint8_t rhport, tusb_speed_t speed, bool in_isr)
Definition: dcd.h:204
u32 SystemCoreClock
xfer_td_t xfer[EP_CBI_COUNT+1][2]
Definition: dcd_nrf5x.c:119
ep_enum
Definition: dcd_nuc120.c:56
static USBD_EP_T * ep_entry(uint8_t ep_addr, bool add)
Definition: dcd_nuc121.c:128
bool dcd_edpt_xfer_fifo(uint8_t rhport, uint8_t ep_addr, tu_fifo_t *ff, uint16_t total_bytes)
Definition: dcd_nuc121.c:344
static struct xfer_ctl_t xfer_table[PERIPH_MAX_EP]
@ PERIPH_EP5
Definition: dcd_nuc121.c:68
@ PERIPH_EP6
Definition: dcd_nuc121.c:69
@ PERIPH_EP2
Definition: dcd_nuc121.c:65
@ PERIPH_EP3
Definition: dcd_nuc121.c:66
@ PERIPH_EP7
Definition: dcd_nuc121.c:70
@ PERIPH_EP4
Definition: dcd_nuc121.c:67
@ PERIPH_EP0
Definition: dcd_nuc121.c:63
@ PERIPH_MAX_EP
Definition: dcd_nuc121.c:71
@ PERIPH_EP1
Definition: dcd_nuc121.c:64
void dcd_edpt_stall(uint8_t rhport, uint8_t ep_addr)
Definition: dcd_nuc121.c:373
static void usb_detach(void)
Definition: dcd_nuc121.c:102
static void bus_reset(void)
Definition: dcd_nuc121.c:172
static void usb_control_send_zlp(void)
Definition: dcd_nuc121.c:112
void dcd_int_handler(uint8_t rhport)
Definition: dcd_nuc121.c:387
static void dcd_in_xfer(struct xfer_ctl_t *xfer, USBD_EP_T *ep)
Definition: dcd_nuc121.c:152
void dcd_disconnect(uint8_t rhport)
Definition: dcd_nuc121.c:544
static void remote_wakeup_delay(void)
Definition: dcd_nuc121.c:256
static void usb_memcpy(uint8_t *dest, uint8_t *src, uint16_t size)
Definition: dcd_nuc121.c:107
@ ENABLED_IRQS
Definition: dcd_nuc121.c:204
void dcd_edpt_close_all(uint8_t rhport)
Definition: dcd_nuc121.c:306
void dcd_int_disable(uint8_t rhport)
Definition: dcd_nuc121.c:240
bool dcd_edpt_open(uint8_t rhport, tusb_desc_endpoint_t const *p_endpoint_desc)
Definition: dcd_nuc121.c:275
static void usb_attach(void)
Definition: dcd_nuc121.c:97
void dcd_edpt_clear_stall(uint8_t rhport, uint8_t ep_addr)
Definition: dcd_nuc121.c:380
static uint8_t decode_ep_addr(USBD_EP_T *ep)
Definition: dcd_nuc121.c:119
void dcd_connect(uint8_t rhport)
Definition: dcd_nuc121.c:550
bool dcd_edpt_xfer(uint8_t rhport, uint8_t ep_addr, uint8_t *buffer, uint16_t total_bytes)
Definition: dcd_nuc121.c:312
void dcd_edpt0_status_complete(uint8_t rhport, tusb_control_request_t const *request)
Definition: dcd_nuc121.c:529
static uint32_t bufseg_addr
Definition: dcd_nuc121.c:75
void dcd_set_address(uint8_t rhport, uint8_t dev_addr)
Definition: dcd_nuc121.c:246
bool dcd_init(uint8_t rhport, const tusb_rhport_init_t *rh_init)
Definition: dcd_nuc121.c:212
void dcd_int_enable(uint8_t rhport)
Definition: dcd_nuc121.c:234
void dcd_remote_wakeup(uint8_t rhport)
Definition: dcd_nuc121.c:263
void dcd_sof_enable(uint8_t rhport, bool en)
Definition: dcd_nuc121.c:556
static bool active_ep0_xfer
Definition: dcd_nuc121.c:78
uint16_t total_bytes
Definition: dcd_nuc505.c:113
uint8_t dev_addr
Definition: dcd_pic32mz.c:81
uint8_t const * buffer
Definition: midi_device.h:100
AUDIO Channel Cluster Descriptor (4.1)
Definition: audio.h:647
uint16_t wValue
Definition: audio.h:934
struct TU_ATTR_PACKED::@16::TU_ATTR_PACKED bmRequestType_bit
uint8_t bmAttributes
See: audio_clock_source_attribute_t.
Definition: audio.h:672
uint8_t bEndpointAddress
Definition: video.h:306
uint8_t bRequest
Request type audio_cs_req_t.
Definition: audio.h:831
uint8_t * data_ptr
Definition: dcd_nuc120.c:78
uint16_t total_bytes
Definition: dcd_nuc120.c:85
uint16_t out_bytes_so_far
Definition: dcd_nuc120.c:82
uint16_t in_remaining_bytes
Definition: dcd_nuc120.c:81
tu_fifo_t * ff
uint8_t ep_addr
Definition: dcd_da146xx.c:221
uint16_t max_packet_size
Definition: dcd_da146xx.c:216
static TU_ATTR_ALWAYS_INLINE uint16_t tu_min16(uint16_t x, uint16_t y)
Definition: tusb_common.h:155
uint16_t tu_fifo_write_n(tu_fifo_t *f, const void *data, uint16_t n)
This function will write n elements into the array index specified by the write pointer and increment...
Definition: tusb_fifo.c:861
uint16_t tu_fifo_read_n(tu_fifo_t *f, void *buffer, uint16_t n)
This function will read n elements from the array index specified by the read pointer and increment t...
Definition: tusb_fifo.c:730
tusb_dir_t
Definition: tusb_types.h:65
@ TUSB_DIR_IN
Definition: tusb_types.h:67
@ TUSB_DIR_IN_MASK
Definition: tusb_types.h:69
@ TUSB_REQ_SET_ADDRESS
Definition: tusb_types.h:127
@ TUSB_SPEED_FULL
Definition: tusb_types.h:50
static TU_ATTR_ALWAYS_INLINE uint8_t tu_edpt_number(uint8_t addr)
Definition: tusb_types.h:507
@ XFER_RESULT_SUCCESS
Definition: tusb_types.h:237
@ TUSB_REQ_RCPT_DEVICE
Definition: tusb_types.h:151
static TU_ATTR_ALWAYS_INLINE uint16_t tu_edpt_packet_size(tusb_desc_endpoint_t const *desc_ep)
Definition: tusb_types.h:515
tusb_xfer_type_t
defined base on USB Specs Endpoint's bmAttributes
Definition: tusb_types.h:58
@ TUSB_XFER_ISOCHRONOUS
Definition: tusb_types.h:60
TU_ATTR_PACKED_END TU_ATTR_BIT_FIELD_ORDER_END static TU_ATTR_ALWAYS_INLINE tusb_dir_t tu_edpt_dir(uint8_t addr)
Definition: tusb_types.h:502
@ TUSB_REQ_TYPE_STANDARD
Definition: tusb_types.h:144
CFG_TUH_MEM_ALIGN tusb_control_request_t request
Definition: usbh.c:259