mirror of
https://github.com/hathach/tinyusb.git
synced 2026-08-18 11:02:16 +00:00
Add is_isr parameter to dcd_edpt_xfer and dcd_edpt_xfer_fifo
Co-authored-by: HiFiPhile <4375114+HiFiPhile@users.noreply.github.com>
This commit is contained in:
@ -158,11 +158,11 @@ bool dcd_edpt_open (uint8_t rhport, tusb_desc_endpoint_t const * desc
|
||||
void dcd_edpt_close_all (uint8_t rhport);
|
||||
|
||||
// Submit a transfer, When complete dcd_event_xfer_complete() is invoked to notify the stack
|
||||
bool dcd_edpt_xfer (uint8_t rhport, uint8_t ep_addr, uint8_t * buffer, uint16_t total_bytes);
|
||||
bool dcd_edpt_xfer (uint8_t rhport, uint8_t ep_addr, uint8_t * buffer, uint16_t total_bytes, bool is_isr);
|
||||
|
||||
// Submit an transfer using fifo, When complete dcd_event_xfer_complete() is invoked to notify the stack
|
||||
// This API is optional, may be useful for register-based for transferring data.
|
||||
bool dcd_edpt_xfer_fifo (uint8_t rhport, uint8_t ep_addr, tu_fifo_t * ff, uint16_t total_bytes);
|
||||
bool dcd_edpt_xfer_fifo (uint8_t rhport, uint8_t ep_addr, tu_fifo_t * ff, uint16_t total_bytes, bool is_isr);
|
||||
|
||||
// Stall endpoint, any queuing transfer should be removed from endpoint
|
||||
void dcd_edpt_stall (uint8_t rhport, uint8_t ep_addr);
|
||||
|
||||
@ -415,8 +415,8 @@ TU_ATTR_WEAK usbd_class_driver_t const* usbd_app_driver_get_cb(uint8_t* driver_c
|
||||
return NULL;
|
||||
}
|
||||
|
||||
TU_ATTR_WEAK bool dcd_edpt_xfer_fifo(uint8_t rhport, uint8_t ep_addr, tu_fifo_t * ff, uint16_t total_bytes) {
|
||||
(void) rhport; (void) ep_addr; (void) ff; (void) total_bytes;
|
||||
TU_ATTR_WEAK bool dcd_edpt_xfer_fifo(uint8_t rhport, uint8_t ep_addr, tu_fifo_t * ff, uint16_t total_bytes, bool is_isr) {
|
||||
(void) rhport; (void) ep_addr; (void) ff; (void) total_bytes; (void) is_isr;
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -1433,7 +1433,7 @@ bool usbd_edpt_xfer(uint8_t rhport, uint8_t ep_addr, uint8_t* buffer, uint16_t t
|
||||
// could return and USBD task can preempt and clear the busy
|
||||
_usbd_dev.ep_status[epnum][dir].busy = 1;
|
||||
|
||||
if (dcd_edpt_xfer(rhport, ep_addr, buffer, total_bytes)) {
|
||||
if (dcd_edpt_xfer(rhport, ep_addr, buffer, total_bytes, false)) {
|
||||
return true;
|
||||
} else {
|
||||
// DCD error, mark endpoint as ready to allow next transfer
|
||||
@ -1464,7 +1464,7 @@ bool usbd_edpt_xfer_fifo(uint8_t rhport, uint8_t ep_addr, tu_fifo_t* ff, uint16_
|
||||
// and usbd task can preempt and clear the busy
|
||||
_usbd_dev.ep_status[epnum][dir].busy = 1;
|
||||
|
||||
if (dcd_edpt_xfer_fifo(rhport, ep_addr, ff, total_bytes)) {
|
||||
if (dcd_edpt_xfer_fifo(rhport, ep_addr, ff, total_bytes, false)) {
|
||||
TU_LOG_USBD("OK\r\n");
|
||||
return true;
|
||||
} else {
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
|
||||
/*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
@ -556,7 +557,7 @@ void dcd_set_address(uint8_t rhport, uint8_t dev_addr)
|
||||
(void)dev_addr;
|
||||
|
||||
// Respond with status. There is no checking that the address is in range.
|
||||
dcd_edpt_xfer(rhport, tu_edpt_addr(USBD_EP_0, TUSB_DIR_IN), NULL, 0);
|
||||
dcd_edpt_xfer(rhport, tu_edpt_addr(USBD_EP_0, TUSB_DIR_IN), NULL, 0, false);
|
||||
|
||||
// Set the update bit for the address register.
|
||||
dev_addr |= 0x80;
|
||||
@ -807,8 +808,9 @@ void dcd_edpt_close_all(uint8_t rhport)
|
||||
}
|
||||
|
||||
// Submit a transfer, When complete dcd_event_xfer_complete() is invoked to notify the stack
|
||||
bool dcd_edpt_xfer(uint8_t rhport, uint8_t ep_addr, uint8_t *buffer, uint16_t total_bytes)
|
||||
bool dcd_edpt_xfer(uint8_t rhport, uint8_t ep_addr, uint8_t * buffer, uint16_t total_bytes, bool is_isr)
|
||||
{
|
||||
(void) is_isr;
|
||||
(void)rhport;
|
||||
uint8_t ep_number = tu_edpt_number(ep_addr);
|
||||
uint8_t ep_dir = tu_edpt_dir(ep_addr);
|
||||
@ -891,8 +893,9 @@ bool dcd_edpt_xfer(uint8_t rhport, uint8_t ep_addr, uint8_t *buffer, uint16_t to
|
||||
}
|
||||
|
||||
// Submit a transfer where is managed by FIFO, When complete dcd_event_xfer_complete() is invoked to notify the stack - optional, however, must be listed in usbd.c
|
||||
bool dcd_edpt_xfer_fifo(uint8_t rhport, uint8_t ep_addr, tu_fifo_t *ff, uint16_t total_bytes)
|
||||
bool dcd_edpt_xfer_fifo(uint8_t rhport, uint8_t ep_addr, tu_fifo_t * ff, uint16_t total_bytes, bool is_isr)
|
||||
{
|
||||
(void) is_isr;
|
||||
(void)rhport;
|
||||
(void)ep_addr;
|
||||
(void)ff;
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
|
||||
/*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
@ -303,7 +304,7 @@ void dcd_set_address(uint8_t rhport, uint8_t dev_addr)
|
||||
{
|
||||
_dcd.addr = dev_addr & 0x7F;
|
||||
/* Response with status first before changing device address */
|
||||
dcd_edpt_xfer(rhport, tu_edpt_addr(0, TUSB_DIR_IN), NULL, 0);
|
||||
dcd_edpt_xfer(rhport, tu_edpt_addr(0, TUSB_DIR_IN), NULL, 0, false);
|
||||
}
|
||||
|
||||
void dcd_remote_wakeup(uint8_t rhport)
|
||||
@ -419,8 +420,9 @@ void dcd_edpt_close(uint8_t rhport, uint8_t ep_addr)
|
||||
dcd_int_enable(rhport);
|
||||
}
|
||||
|
||||
bool dcd_edpt_xfer(uint8_t rhport, uint8_t ep_addr, uint8_t* buffer, uint16_t total_bytes)
|
||||
bool dcd_edpt_xfer(uint8_t rhport, uint8_t ep_addr, uint8_t * buffer, uint16_t total_bytes, bool is_isr)
|
||||
{
|
||||
(void) is_isr;
|
||||
const unsigned epn = tu_edpt_number(ep_addr);
|
||||
const unsigned dir = tu_edpt_dir(ep_addr);
|
||||
endpoint_state_t *ep = &_dcd.endpoint[epn][dir];
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
|
||||
/*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
@ -277,7 +278,7 @@ void dcd_int_disable(uint8_t rhport)
|
||||
void dcd_set_address(uint8_t rhport, uint8_t dev_addr)
|
||||
{
|
||||
// Response with status first before changing device address
|
||||
dcd_edpt_xfer(rhport, tu_edpt_addr(0, TUSB_DIR_IN), NULL, 0);
|
||||
dcd_edpt_xfer(rhport, tu_edpt_addr(0, TUSB_DIR_IN), NULL, 0, false);
|
||||
|
||||
ci_hs_regs_t* dcd_reg = CI_HS_REG(rhport);
|
||||
dcd_reg->DEVICEADDR = (dev_addr << 25) | TU_BIT(24);
|
||||
@ -465,8 +466,9 @@ static void qhd_start_xfer(uint8_t rhport, uint8_t epnum, uint8_t dir)
|
||||
dcd_reg->ENDPTPRIME = TU_BIT(epnum + (dir ? 16 : 0));
|
||||
}
|
||||
|
||||
bool dcd_edpt_xfer(uint8_t rhport, uint8_t ep_addr, uint8_t * buffer, uint16_t total_bytes)
|
||||
bool dcd_edpt_xfer(uint8_t rhport, uint8_t ep_addr, uint8_t * buffer, uint16_t total_bytes, bool is_isr)
|
||||
{
|
||||
(void) is_isr;
|
||||
uint8_t const epnum = tu_edpt_number(ep_addr);
|
||||
uint8_t const dir = tu_edpt_dir(ep_addr);
|
||||
|
||||
@ -486,8 +488,9 @@ bool dcd_edpt_xfer(uint8_t rhport, uint8_t ep_addr, uint8_t * buffer, uint16_t t
|
||||
#if !CFG_TUD_MEM_DCACHE_ENABLE
|
||||
// fifo has to be aligned to 4k boundary
|
||||
// It's incompatible with dcache enabled transfer, since neither address nor size is aligned to cache line
|
||||
bool dcd_edpt_xfer_fifo (uint8_t rhport, uint8_t ep_addr, tu_fifo_t * ff, uint16_t total_bytes)
|
||||
bool dcd_edpt_xfer_fifo(uint8_t rhport, uint8_t ep_addr, tu_fifo_t * ff, uint16_t total_bytes, bool is_isr)
|
||||
{
|
||||
(void) is_isr;
|
||||
uint8_t const epnum = tu_edpt_number(ep_addr);
|
||||
uint8_t const dir = tu_edpt_dir(ep_addr);
|
||||
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
|
||||
/*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
@ -837,7 +838,7 @@ void dcd_set_address(uint8_t rhport, uint8_t dev_addr)
|
||||
// Set default address for one ZLP
|
||||
USB->USB_EPC0_REG = USB_USB_EPC0_REG_USB_DEF_Msk;
|
||||
USB->USB_FAR_REG = (dev_addr & USB_USB_FAR_REG_USB_AD_Msk) | USB_USB_FAR_REG_USB_AD_EN_Msk;
|
||||
dcd_edpt_xfer(rhport, tu_edpt_addr(0, TUSB_DIR_IN), NULL, 0);
|
||||
dcd_edpt_xfer(rhport, tu_edpt_addr(0, TUSB_DIR_IN), NULL, 0, false);
|
||||
}
|
||||
|
||||
void dcd_remote_wakeup(uint8_t rhport)
|
||||
@ -1025,8 +1026,9 @@ void dcd_edpt_close(uint8_t rhport, uint8_t ep_addr)
|
||||
tu_memclr(xfer, sizeof(*xfer));
|
||||
}
|
||||
|
||||
bool dcd_edpt_xfer(uint8_t rhport, uint8_t ep_addr, uint8_t * buffer, uint16_t total_bytes)
|
||||
bool dcd_edpt_xfer(uint8_t rhport, uint8_t ep_addr, uint8_t * buffer, uint16_t total_bytes, bool is_isr)
|
||||
{
|
||||
(void) is_isr;
|
||||
uint8_t const epnum = tu_edpt_number(ep_addr);
|
||||
uint8_t const dir = tu_edpt_dir(ep_addr);
|
||||
xfer_ctl_t * xfer = XFER_CTL_BASE(epnum, dir);
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
|
||||
/*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
@ -772,8 +773,9 @@ void dcd_edpt_close_all(uint8_t rhport)
|
||||
}
|
||||
|
||||
// Submit a transfer, When complete dcd_event_xfer_complete() is invoked to notify the stack
|
||||
bool dcd_edpt_xfer(uint8_t rhport, uint8_t ep_addr, uint8_t * buffer, uint16_t total_bytes)
|
||||
bool dcd_edpt_xfer(uint8_t rhport, uint8_t ep_addr, uint8_t * buffer, uint16_t total_bytes, bool is_isr)
|
||||
{
|
||||
(void) is_isr;
|
||||
(void)rhport;
|
||||
bool ret;
|
||||
// TU_LOG1("X %x %d\r\n", ep_addr, total_bytes);
|
||||
@ -794,8 +796,9 @@ bool dcd_edpt_xfer(uint8_t rhport, uint8_t ep_addr, uint8_t * buffer, uint16_t t
|
||||
|
||||
// Submit a transfer where is managed by FIFO, When complete dcd_event_xfer_complete() is invoked to notify the stack
|
||||
// - optional, however, must be listed in usbd.c
|
||||
bool dcd_edpt_xfer_fifo(uint8_t rhport, uint8_t ep_addr, tu_fifo_t * ff, uint16_t total_bytes)
|
||||
bool dcd_edpt_xfer_fifo(uint8_t rhport, uint8_t ep_addr, tu_fifo_t * ff, uint16_t total_bytes, bool is_isr)
|
||||
{
|
||||
(void) is_isr;
|
||||
(void)rhport;
|
||||
bool ret;
|
||||
// TU_LOG1("X %x %d\r\n", ep_addr, total_bytes);
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
|
||||
/*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
@ -545,7 +546,7 @@ void dcd_set_address(uint8_t rhport, uint8_t dev_addr)
|
||||
{
|
||||
_dcd.addr = dev_addr & 0x7F;
|
||||
/* Response with status first before changing device address */
|
||||
dcd_edpt_xfer(rhport, tu_edpt_addr(0, TUSB_DIR_IN), NULL, 0);
|
||||
dcd_edpt_xfer(rhport, tu_edpt_addr(0, TUSB_DIR_IN), NULL, 0, false);
|
||||
}
|
||||
|
||||
void dcd_remote_wakeup(uint8_t rhport)
|
||||
@ -687,8 +688,9 @@ void dcd_edpt_close(uint8_t rhport, uint8_t ep_addr)
|
||||
if (ie) intr_enable(rhport);
|
||||
}
|
||||
|
||||
bool dcd_edpt_xfer(uint8_t rhport, uint8_t ep_addr, uint8_t* buffer, uint16_t total_bytes)
|
||||
bool dcd_edpt_xfer(uint8_t rhport, uint8_t ep_addr, uint8_t * buffer, uint16_t total_bytes, bool is_isr)
|
||||
{
|
||||
(void) is_isr;
|
||||
|
||||
const unsigned epn = tu_edpt_number(ep_addr);
|
||||
const unsigned dir = tu_edpt_dir(ep_addr);
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
|
||||
/*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
@ -444,8 +445,9 @@ void dcd_edpt_close(uint8_t rhport, uint8_t ep_addr)
|
||||
(void) ep_addr;
|
||||
}
|
||||
|
||||
bool dcd_edpt_xfer(uint8_t rhport, uint8_t ep_addr, uint8_t * buffer, uint16_t total_bytes)
|
||||
bool dcd_edpt_xfer(uint8_t rhport, uint8_t ep_addr, uint8_t * buffer, uint16_t total_bytes, bool is_isr)
|
||||
{
|
||||
(void) is_isr;
|
||||
uint8_t const epnum = tu_edpt_number(ep_addr);
|
||||
uint8_t const dir = tu_edpt_dir(ep_addr);
|
||||
xfer_ctl_t * xfer = XFER_CTL_BASE(epnum, dir);
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
|
||||
/*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
@ -142,7 +143,7 @@ void dcd_set_address (uint8_t rhport, uint8_t dev_addr)
|
||||
(void) dev_addr;
|
||||
|
||||
// Response with zlp status
|
||||
dcd_edpt_xfer(rhport, 0x80, NULL, 0);
|
||||
dcd_edpt_xfer(rhport, 0x80, NULL, 0, false);
|
||||
|
||||
// DCD can only set address after status for this request is complete
|
||||
// do it at dcd_edpt0_status_complete()
|
||||
@ -258,8 +259,9 @@ void dcd_edpt_close_all (uint8_t rhport)
|
||||
// TODO implement dcd_edpt_close_all()
|
||||
}
|
||||
|
||||
bool dcd_edpt_xfer (uint8_t rhport, uint8_t ep_addr, uint8_t * buffer, uint16_t total_bytes)
|
||||
bool dcd_edpt_xfer(uint8_t rhport, uint8_t ep_addr, uint8_t * buffer, uint16_t total_bytes, bool is_isr)
|
||||
{
|
||||
(void) is_isr;
|
||||
(void) rhport;
|
||||
|
||||
uint8_t const epnum = tu_edpt_number(ep_addr);
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
|
||||
/*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
@ -175,7 +176,7 @@ void dcd_set_address (uint8_t rhport, uint8_t dev_addr)
|
||||
(void) dev_addr;
|
||||
|
||||
// Response with zlp status
|
||||
dcd_edpt_xfer(rhport, 0x80, NULL, 0);
|
||||
dcd_edpt_xfer(rhport, 0x80, NULL, 0, false);
|
||||
|
||||
// DCD can only set address after status for this request is complete.
|
||||
// do it at dcd_edpt0_status_complete()
|
||||
@ -282,8 +283,9 @@ void dcd_edpt_close_all (uint8_t rhport)
|
||||
}
|
||||
|
||||
// Submit a transfer, When complete dcd_event_xfer_complete() is invoked to notify the stack
|
||||
bool dcd_edpt_xfer (uint8_t rhport, uint8_t ep_addr, uint8_t * buffer, uint16_t total_bytes)
|
||||
bool dcd_edpt_xfer(uint8_t rhport, uint8_t ep_addr, uint8_t * buffer, uint16_t total_bytes, bool is_isr)
|
||||
{
|
||||
(void) is_isr;
|
||||
(void) rhport;
|
||||
|
||||
uint8_t const epnum = tu_edpt_number(ep_addr);
|
||||
@ -309,8 +311,9 @@ bool dcd_edpt_xfer (uint8_t rhport, uint8_t ep_addr, uint8_t * buffer, uint16_t
|
||||
}
|
||||
|
||||
#if 0 // TODO support dcd_edpt_xfer_fifo API
|
||||
bool dcd_edpt_xfer_fifo (uint8_t rhport, uint8_t ep_addr, tu_fifo_t * ff, uint16_t total_bytes)
|
||||
bool dcd_edpt_xfer_fifo(uint8_t rhport, uint8_t ep_addr, tu_fifo_t * ff, uint16_t total_bytes, bool is_isr)
|
||||
{
|
||||
(void) is_isr;
|
||||
(void) rhport;
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
|
||||
/*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
@ -132,7 +133,7 @@ void dcd_set_address (uint8_t rhport, uint8_t dev_addr)
|
||||
// do it at dcd_edpt0_status_complete()
|
||||
|
||||
// Response with zlp status
|
||||
dcd_edpt_xfer(rhport, tu_edpt_addr(0, TUSB_DIR_IN), NULL, 0);
|
||||
dcd_edpt_xfer(rhport, tu_edpt_addr(0, TUSB_DIR_IN), NULL, 0, false);
|
||||
}
|
||||
|
||||
// Wake up host
|
||||
@ -605,8 +606,9 @@ static void dcd_transmit_packet(xfer_ctl_t * xfer, uint8_t ep_ix)
|
||||
}
|
||||
|
||||
// Submit a transfer, When complete dcd_event_xfer_complete() is invoked to notify the stack
|
||||
bool dcd_edpt_xfer (uint8_t rhport, uint8_t ep_addr, uint8_t * buffer, uint16_t total_bytes)
|
||||
bool dcd_edpt_xfer(uint8_t rhport, uint8_t ep_addr, uint8_t * buffer, uint16_t total_bytes, bool is_isr)
|
||||
{
|
||||
(void) is_isr;
|
||||
(void) rhport;
|
||||
uint8_t const epnum = tu_edpt_number(ep_addr);
|
||||
uint8_t const dir = tu_edpt_dir(ep_addr);
|
||||
@ -666,8 +668,9 @@ bool dcd_edpt_xfer (uint8_t rhport, uint8_t ep_addr, uint8_t * buffer, uint16_t
|
||||
// bytes should be written and second to keep the return value free to give back a boolean
|
||||
// success message. If total_bytes is too big, the FIFO will copy only what is available
|
||||
// into the USB buffer!
|
||||
bool dcd_edpt_xfer_fifo (uint8_t rhport, uint8_t ep_addr, tu_fifo_t * ff, uint16_t total_bytes)
|
||||
bool dcd_edpt_xfer_fifo(uint8_t rhport, uint8_t ep_addr, tu_fifo_t * ff, uint16_t total_bytes, bool is_isr)
|
||||
{
|
||||
(void) is_isr;
|
||||
(void) rhport;
|
||||
uint8_t const epnum = tu_edpt_number(ep_addr);
|
||||
uint8_t const dir = tu_edpt_dir(ep_addr);
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
|
||||
/*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
@ -282,7 +283,7 @@ void dcd_set_address(uint8_t rhport, uint8_t dev_addr)
|
||||
(void) rhport;
|
||||
_dcd.addr = dev_addr & 0x7F;
|
||||
/* Response with status first before changing device address */
|
||||
dcd_edpt_xfer(rhport, tu_edpt_addr(0, TUSB_DIR_IN), NULL, 0);
|
||||
dcd_edpt_xfer(rhport, tu_edpt_addr(0, TUSB_DIR_IN), NULL, 0, false);
|
||||
}
|
||||
|
||||
#ifdef __GNUC__ // caused by extra declaration of SystemCoreClock in freeRTOSConfig.h
|
||||
@ -381,8 +382,9 @@ void dcd_edpt_close(uint8_t rhport, uint8_t ep_addr)
|
||||
bd->head = 0;
|
||||
}
|
||||
|
||||
bool dcd_edpt_xfer(uint8_t rhport, uint8_t ep_addr, uint8_t* buffer, uint16_t total_bytes)
|
||||
bool dcd_edpt_xfer(uint8_t rhport, uint8_t ep_addr, uint8_t * buffer, uint16_t total_bytes, bool is_isr)
|
||||
{
|
||||
(void) is_isr;
|
||||
(void) rhport;
|
||||
NVIC_DisableIRQ(USB_FS_IRQn);
|
||||
const unsigned epn = ep_addr & 0xFu;
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
|
||||
/*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
@ -426,7 +427,8 @@ void dcd_edpt_close(uint8_t rhport, uint8_t ep_addr) {
|
||||
__DSB();
|
||||
}
|
||||
|
||||
bool dcd_edpt_xfer(uint8_t rhport, uint8_t ep_addr, uint8_t* buffer, uint16_t total_bytes) {
|
||||
bool dcd_edpt_xfer(uint8_t rhport, uint8_t ep_addr, uint8_t * buffer, uint16_t total_bytes, bool is_isr) {
|
||||
(void) is_isr;
|
||||
(void) rhport;
|
||||
|
||||
uint8_t const epnum = tu_edpt_number(ep_addr);
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
|
||||
/*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
@ -294,8 +295,9 @@ void dcd_edpt_close_all (uint8_t rhport)
|
||||
// TODO implement dcd_edpt_close_all()
|
||||
}
|
||||
|
||||
bool dcd_edpt_xfer(uint8_t rhport, uint8_t ep_addr, uint8_t *buffer, uint16_t total_bytes)
|
||||
bool dcd_edpt_xfer(uint8_t rhport, uint8_t ep_addr, uint8_t * buffer, uint16_t total_bytes, bool is_isr)
|
||||
{
|
||||
(void) is_isr;
|
||||
(void) rhport;
|
||||
|
||||
/* mine the data for the information we need */
|
||||
@ -326,8 +328,9 @@ bool dcd_edpt_xfer(uint8_t rhport, uint8_t ep_addr, uint8_t *buffer, uint16_t to
|
||||
}
|
||||
|
||||
#if 0 // TODO support dcd_edpt_xfer_fifo API
|
||||
bool dcd_edpt_xfer_fifo (uint8_t rhport, uint8_t ep_addr, tu_fifo_t * ff, uint16_t total_bytes)
|
||||
bool dcd_edpt_xfer_fifo(uint8_t rhport, uint8_t ep_addr, tu_fifo_t * ff, uint16_t total_bytes, bool is_isr)
|
||||
{
|
||||
(void) is_isr;
|
||||
(void) rhport;
|
||||
|
||||
/* mine the data for the information we need */
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
|
||||
/*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
@ -323,8 +324,9 @@ void dcd_edpt_close_all (uint8_t rhport)
|
||||
// TODO implement dcd_edpt_close_all()
|
||||
}
|
||||
|
||||
bool dcd_edpt_xfer(uint8_t rhport, uint8_t ep_addr, uint8_t *buffer, uint16_t total_bytes)
|
||||
bool dcd_edpt_xfer(uint8_t rhport, uint8_t ep_addr, uint8_t * buffer, uint16_t total_bytes, bool is_isr)
|
||||
{
|
||||
(void) is_isr;
|
||||
(void) rhport;
|
||||
|
||||
/* mine the data for the information we need */
|
||||
@ -355,8 +357,9 @@ bool dcd_edpt_xfer(uint8_t rhport, uint8_t ep_addr, uint8_t *buffer, uint16_t to
|
||||
}
|
||||
|
||||
#if 0 // TODO support dcd_edpt_xfer_fifo API
|
||||
bool dcd_edpt_xfer_fifo (uint8_t rhport, uint8_t ep_addr, tu_fifo_t * ff, uint16_t total_bytes)
|
||||
bool dcd_edpt_xfer_fifo(uint8_t rhport, uint8_t ep_addr, tu_fifo_t * ff, uint16_t total_bytes, bool is_isr)
|
||||
{
|
||||
(void) is_isr;
|
||||
(void) rhport;
|
||||
|
||||
/* mine the data for the information we need */
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
|
||||
/*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
@ -376,8 +377,9 @@ void dcd_edpt_close_all (uint8_t rhport)
|
||||
// TODO implement dcd_edpt_close_all()
|
||||
}
|
||||
|
||||
bool dcd_edpt_xfer(uint8_t rhport, uint8_t ep_addr, uint8_t *buffer, uint16_t total_bytes)
|
||||
bool dcd_edpt_xfer(uint8_t rhport, uint8_t ep_addr, uint8_t * buffer, uint16_t total_bytes, bool is_isr)
|
||||
{
|
||||
(void) is_isr;
|
||||
(void) rhport;
|
||||
|
||||
if (0x80 == ep_addr) /* control EP0 IN */
|
||||
@ -437,8 +439,9 @@ bool dcd_edpt_xfer(uint8_t rhport, uint8_t ep_addr, uint8_t *buffer, uint16_t to
|
||||
}
|
||||
|
||||
#if 0 // TODO support dcd_edpt_xfer_fifo API
|
||||
bool dcd_edpt_xfer_fifo (uint8_t rhport, uint8_t ep_addr, tu_fifo_t * ff, uint16_t total_bytes)
|
||||
bool dcd_edpt_xfer_fifo(uint8_t rhport, uint8_t ep_addr, tu_fifo_t * ff, uint16_t total_bytes, bool is_isr)
|
||||
{
|
||||
(void) is_isr;
|
||||
(void) rhport;
|
||||
|
||||
TU_ASSERT(0x80 != ep_addr && 0x00 != ep_addr); // Must not be used for control stuff
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
|
||||
/*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
@ -314,7 +315,7 @@ void dcd_set_address(uint8_t rhport, uint8_t dev_addr)
|
||||
{
|
||||
_dcd.addr = dev_addr & 0x7F;
|
||||
/* Response with status first before changing device address */
|
||||
dcd_edpt_xfer(rhport, tu_edpt_addr(0, TUSB_DIR_IN), NULL, 0);
|
||||
dcd_edpt_xfer(rhport, tu_edpt_addr(0, TUSB_DIR_IN), NULL, 0, false);
|
||||
}
|
||||
|
||||
void dcd_remote_wakeup(uint8_t rhport)
|
||||
@ -428,8 +429,9 @@ void dcd_edpt_close(uint8_t rhport, uint8_t ep_addr)
|
||||
if (ie) NVIC_EnableIRQ(USB0_IRQn);
|
||||
}
|
||||
|
||||
bool dcd_edpt_xfer(uint8_t rhport, uint8_t ep_addr, uint8_t* buffer, uint16_t total_bytes)
|
||||
bool dcd_edpt_xfer(uint8_t rhport, uint8_t ep_addr, uint8_t * buffer, uint16_t total_bytes, bool is_isr)
|
||||
{
|
||||
(void) is_isr;
|
||||
(void) rhport;
|
||||
const unsigned epn = tu_edpt_number(ep_addr);
|
||||
const unsigned dir = tu_edpt_dir(ep_addr);
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
|
||||
/*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
@ -205,7 +206,7 @@ void dcd_int_disable(uint8_t rhport)
|
||||
void dcd_set_address(uint8_t rhport, uint8_t dev_addr)
|
||||
{
|
||||
// Response with status first before changing device address
|
||||
dcd_edpt_xfer(rhport, tu_edpt_addr(0, TUSB_DIR_IN), NULL, 0);
|
||||
dcd_edpt_xfer(rhport, tu_edpt_addr(0, TUSB_DIR_IN), NULL, 0, false);
|
||||
|
||||
sie_write(SIE_CMDCODE_SET_ADDRESS, 1, 0x80 | dev_addr); // 7th bit is : device_enable
|
||||
|
||||
@ -399,8 +400,9 @@ static bool control_xact(uint8_t rhport, uint8_t dir, uint8_t * buffer, uint8_t
|
||||
return true;
|
||||
}
|
||||
|
||||
bool dcd_edpt_xfer (uint8_t rhport, uint8_t ep_addr, uint8_t* buffer, uint16_t total_bytes)
|
||||
bool dcd_edpt_xfer(uint8_t rhport, uint8_t ep_addr, uint8_t * buffer, uint16_t total_bytes, bool is_isr)
|
||||
{
|
||||
(void) is_isr;
|
||||
// Control transfer is not DMA support, and must be done in slave mode
|
||||
if ( tu_edpt_number(ep_addr) == 0 )
|
||||
{
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
|
||||
/*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
@ -322,7 +323,7 @@ void dcd_set_address(uint8_t rhport, uint8_t dev_addr)
|
||||
dcd_registers_t* dcd_reg = _dcd_controller[rhport].regs;
|
||||
|
||||
// Response with status first before changing device address
|
||||
dcd_edpt_xfer(rhport, tu_edpt_addr(0, TUSB_DIR_IN), NULL, 0);
|
||||
dcd_edpt_xfer(rhport, tu_edpt_addr(0, TUSB_DIR_IN), NULL, 0, false);
|
||||
|
||||
dcd_reg->DEVCMDSTAT &= ~DEVCMDSTAT_DEVICE_ADDR_MASK;
|
||||
dcd_reg->DEVCMDSTAT |= dev_addr;
|
||||
@ -464,7 +465,8 @@ static void prepare_ep_xfer(uint8_t rhport, uint8_t ep_id, uint16_t buf_offset,
|
||||
ep_cs[0].cmd_sts.active = 1;
|
||||
}
|
||||
|
||||
bool dcd_edpt_xfer(uint8_t rhport, uint8_t ep_addr, uint8_t* buffer, uint16_t total_bytes) {
|
||||
bool dcd_edpt_xfer(uint8_t rhport, uint8_t ep_addr, uint8_t * buffer, uint16_t total_bytes, bool is_isr) {
|
||||
(void) is_isr;
|
||||
uint8_t const ep_id = ep_addr2id(ep_addr);
|
||||
|
||||
if (!buffer || total_bytes == 0) {
|
||||
@ -486,6 +488,7 @@ bool dcd_edpt_xfer(uint8_t rhport, uint8_t ep_addr, uint8_t* buffer, uint16_t to
|
||||
//--------------------------------------------------------------------+
|
||||
static void bus_reset(uint8_t rhport)
|
||||
{
|
||||
(void) is_isr;
|
||||
tu_memclr(&_dcd, sizeof(dcd_data_t));
|
||||
edpt_reset_all(rhport);
|
||||
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
|
||||
/*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
@ -76,7 +77,7 @@ void dcd_set_address (uint8_t rhport, uint8_t dev_addr)
|
||||
{
|
||||
// must be called before queuing status
|
||||
pio_usb_device_set_address(dev_addr);
|
||||
dcd_edpt_xfer(rhport, 0x80, NULL, 0);
|
||||
dcd_edpt_xfer(rhport, 0x80, NULL, 0, false);
|
||||
}
|
||||
|
||||
// Wake up host
|
||||
@ -114,15 +115,16 @@ void dcd_edpt_close_all (uint8_t rhport)
|
||||
}
|
||||
|
||||
// Submit a transfer, When complete dcd_event_xfer_complete() is invoked to notify the stack
|
||||
bool dcd_edpt_xfer (uint8_t rhport, uint8_t ep_addr, uint8_t * buffer, uint16_t total_bytes)
|
||||
bool dcd_edpt_xfer(uint8_t rhport, uint8_t ep_addr, uint8_t * buffer, uint16_t total_bytes, bool is_isr)
|
||||
{
|
||||
(void) is_isr;
|
||||
(void) rhport;
|
||||
endpoint_t *ep = pio_usb_device_get_endpoint_by_address(ep_addr);
|
||||
return pio_usb_ll_transfer_start(ep, buffer, total_bytes);
|
||||
}
|
||||
|
||||
// Submit a transfer where is managed by FIFO, When complete dcd_event_xfer_complete() is invoked to notify the stack - optional, however, must be listed in usbd.c
|
||||
//bool dcd_edpt_xfer_fifo (uint8_t rhport, uint8_t ep_addr, tu_fifo_t * ff, uint16_t total_bytes)
|
||||
//bool dcd_edpt_xfer_fifo(uint8_t rhport, uint8_t ep_addr, tu_fifo_t * ff, uint16_t total_bytes, bool is_isr)
|
||||
//{
|
||||
// (void) rhport;
|
||||
// (void) ep_addr;
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
|
||||
/*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
@ -526,7 +527,8 @@ void dcd_edpt_close_all(uint8_t rhport) {
|
||||
reset_non_control_endpoints();
|
||||
}
|
||||
|
||||
bool dcd_edpt_xfer(__unused uint8_t rhport, uint8_t ep_addr, uint8_t* buffer, uint16_t total_bytes) {
|
||||
bool dcd_edpt_xfer(__unused uint8_t rhport, uint8_t ep_addr, uint8_t* buffer, uint16_t total_bytes, bool is_isr) {
|
||||
(void) is_isr;
|
||||
assert(rhport == 0);
|
||||
hw_endpoint_xfer(ep_addr, buffer, total_bytes);
|
||||
return true;
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
|
||||
/*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
@ -859,8 +860,9 @@ void dcd_edpt_close(uint8_t rhport, uint8_t ep_addr)
|
||||
_dcd.ep[dir][epn] = 0;
|
||||
}
|
||||
|
||||
bool dcd_edpt_xfer(uint8_t rhport, uint8_t ep_addr, uint8_t* buffer, uint16_t total_bytes)
|
||||
bool dcd_edpt_xfer(uint8_t rhport, uint8_t ep_addr, uint8_t * buffer, uint16_t total_bytes, bool is_isr)
|
||||
{
|
||||
(void) is_isr;
|
||||
rusb2_reg_t* rusb = RUSB2_REG(rhport);
|
||||
|
||||
dcd_int_disable(rhport);
|
||||
@ -870,8 +872,9 @@ bool dcd_edpt_xfer(uint8_t rhport, uint8_t ep_addr, uint8_t* buffer, uint16_t to
|
||||
return r;
|
||||
}
|
||||
|
||||
bool dcd_edpt_xfer_fifo(uint8_t rhport, uint8_t ep_addr, tu_fifo_t * ff, uint16_t total_bytes)
|
||||
bool dcd_edpt_xfer_fifo(uint8_t rhport, uint8_t ep_addr, tu_fifo_t * ff, uint16_t total_bytes, bool is_isr)
|
||||
{
|
||||
(void) is_isr;
|
||||
// USB buffers always work in bytes so to avoid unnecessary divisions we demand item_size = 1
|
||||
TU_ASSERT(ff->item_size == 1);
|
||||
rusb2_reg_t* rusb = RUSB2_REG(rhport);
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
|
||||
/*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
@ -358,8 +359,9 @@ void dcd_edpt_close_all (uint8_t rhport)
|
||||
// TODO implement dcd_edpt_close_all()
|
||||
}
|
||||
|
||||
bool dcd_edpt_xfer(uint8_t rhport, uint8_t ep_addr, uint8_t *buffer, uint16_t total_bytes)
|
||||
bool dcd_edpt_xfer(uint8_t rhport, uint8_t ep_addr, uint8_t * buffer, uint16_t total_bytes, bool is_isr)
|
||||
{
|
||||
(void) is_isr;
|
||||
(void) rhport;
|
||||
|
||||
bool ret = true;
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
|
||||
/*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
@ -246,7 +247,7 @@ void dcd_set_address(uint8_t rhport, uint8_t dev_addr) {
|
||||
(void)dev_addr;
|
||||
|
||||
// Respond with status
|
||||
dcd_edpt_xfer(rhport, TUSB_DIR_IN_MASK | 0x00, NULL, 0);
|
||||
dcd_edpt_xfer(rhport, TUSB_DIR_IN_MASK | 0x00, NULL, 0, false);
|
||||
|
||||
// DCD can only set address after status for this request is complete.
|
||||
// do it at dcd_edpt0_status_complete()
|
||||
@ -788,7 +789,8 @@ static bool edpt_xfer(uint8_t rhport, uint8_t ep_num, tusb_dir_t dir) {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool dcd_edpt_xfer(uint8_t rhport, uint8_t ep_addr, uint8_t *buffer, uint16_t total_bytes) {
|
||||
bool dcd_edpt_xfer(uint8_t rhport, uint8_t ep_addr, uint8_t * buffer, uint16_t total_bytes, bool is_isr) {
|
||||
(void) is_isr;
|
||||
uint8_t const ep_num = tu_edpt_number(ep_addr);
|
||||
tusb_dir_t const dir = tu_edpt_dir(ep_addr);
|
||||
xfer_ctl_t *xfer = xfer_ctl_ptr(ep_num, dir);
|
||||
@ -801,7 +803,8 @@ bool dcd_edpt_xfer(uint8_t rhport, uint8_t ep_addr, uint8_t *buffer, uint16_t to
|
||||
return edpt_xfer(rhport, ep_num, dir);
|
||||
}
|
||||
|
||||
bool dcd_edpt_xfer_fifo(uint8_t rhport, uint8_t ep_addr, tu_fifo_t *ff, uint16_t total_bytes) {
|
||||
bool dcd_edpt_xfer_fifo(uint8_t rhport, uint8_t ep_addr, tu_fifo_t * ff, uint16_t total_bytes, bool is_isr) {
|
||||
(void) is_isr;
|
||||
uint8_t const ep_num = tu_edpt_number(ep_addr);
|
||||
tusb_dir_t const dir = tu_edpt_dir(ep_addr);
|
||||
xfer_ctl_t *xfer = xfer_ctl_ptr(ep_num, dir);
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
|
||||
/*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
@ -1083,8 +1084,9 @@ void dcd_edpt_close(uint8_t rhport, uint8_t ep_addr)
|
||||
}
|
||||
|
||||
// Submit a transfer, When complete dcd_event_xfer_complete() is invoked to notify the stack
|
||||
bool dcd_edpt_xfer(uint8_t rhport, uint8_t ep_addr, uint8_t * buffer, uint16_t total_bytes)
|
||||
bool dcd_edpt_xfer(uint8_t rhport, uint8_t ep_addr, uint8_t * buffer, uint16_t total_bytes, bool is_isr)
|
||||
{
|
||||
(void) is_isr;
|
||||
(void)rhport;
|
||||
bool ret;
|
||||
// TU_LOG1("X %x %d\r\n", ep_addr, total_bytes);
|
||||
@ -1102,8 +1104,9 @@ bool dcd_edpt_xfer(uint8_t rhport, uint8_t ep_addr, uint8_t * buffer, uint16_t t
|
||||
}
|
||||
|
||||
// Submit a transfer where is managed by FIFO, When complete dcd_event_xfer_complete() is invoked to notify the stack - optional, however, must be listed in usbd.c
|
||||
bool dcd_edpt_xfer_fifo(uint8_t rhport, uint8_t ep_addr, tu_fifo_t * ff, uint16_t total_bytes)
|
||||
bool dcd_edpt_xfer_fifo(uint8_t rhport, uint8_t ep_addr, tu_fifo_t * ff, uint16_t total_bytes, bool is_isr)
|
||||
{
|
||||
(void) is_isr;
|
||||
(void)rhport;
|
||||
bool ret;
|
||||
// TU_LOG1("X %x %d\r\n", ep_addr, total_bytes);
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
|
||||
/*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
@ -456,7 +457,7 @@ void dcd_set_address(uint8_t rhport, uint8_t dev_addr) {
|
||||
dwc2->dcfg = (dwc2->dcfg & ~DCFG_DAD_Msk) | (dev_addr << DCFG_DAD_Pos);
|
||||
|
||||
// Response with status after changing device address
|
||||
dcd_edpt_xfer(rhport, tu_edpt_addr(0, TUSB_DIR_IN), NULL, 0);
|
||||
dcd_edpt_xfer(rhport, tu_edpt_addr(0, TUSB_DIR_IN), NULL, 0, false, false);
|
||||
}
|
||||
|
||||
void dcd_remote_wakeup(uint8_t rhport) {
|
||||
@ -577,13 +578,14 @@ bool dcd_edpt_iso_activate(uint8_t rhport, tusb_desc_endpoint_t const * p_endpo
|
||||
return true;
|
||||
}
|
||||
|
||||
bool dcd_edpt_xfer(uint8_t rhport, uint8_t ep_addr, uint8_t* buffer, uint16_t total_bytes) {
|
||||
bool dcd_edpt_xfer(uint8_t rhport, uint8_t ep_addr, uint8_t* buffer, uint16_t total_bytes, bool is_isr) {
|
||||
(void) is_isr;
|
||||
uint8_t const epnum = tu_edpt_number(ep_addr);
|
||||
uint8_t const dir = tu_edpt_dir(ep_addr);
|
||||
xfer_ctl_t* xfer = XFER_CTL_BASE(epnum, dir);
|
||||
bool ret;
|
||||
|
||||
usbd_spin_lock(false);
|
||||
usbd_spin_lock(is_isr);
|
||||
|
||||
if (xfer->max_size == 0) {
|
||||
ret = false; // Endpoint is closed
|
||||
@ -602,7 +604,7 @@ bool dcd_edpt_xfer(uint8_t rhport, uint8_t ep_addr, uint8_t* buffer, uint16_t to
|
||||
ret = true;
|
||||
}
|
||||
|
||||
usbd_spin_unlock(false);
|
||||
usbd_spin_unlock(is_isr);
|
||||
|
||||
return ret;
|
||||
}
|
||||
@ -611,7 +613,8 @@ bool dcd_edpt_xfer(uint8_t rhport, uint8_t ep_addr, uint8_t* buffer, uint16_t to
|
||||
// bytes should be written and second to keep the return value free to give back a boolean
|
||||
// success message. If total_bytes is too big, the FIFO will copy only what is available
|
||||
// into the USB buffer!
|
||||
bool dcd_edpt_xfer_fifo(uint8_t rhport, uint8_t ep_addr, tu_fifo_t* ff, uint16_t total_bytes) {
|
||||
bool dcd_edpt_xfer_fifo(uint8_t rhport, uint8_t ep_addr, tu_fifo_t* ff, uint16_t total_bytes, bool is_isr) {
|
||||
(void) is_isr;
|
||||
// USB buffers always work in bytes so to avoid unnecessary divisions we demand item_size = 1
|
||||
TU_ASSERT(ff->item_size == 1);
|
||||
|
||||
@ -620,7 +623,7 @@ bool dcd_edpt_xfer_fifo(uint8_t rhport, uint8_t ep_addr, tu_fifo_t* ff, uint16_t
|
||||
xfer_ctl_t* xfer = XFER_CTL_BASE(epnum, dir);
|
||||
bool ret;
|
||||
|
||||
usbd_spin_lock(false);
|
||||
usbd_spin_lock(is_isr);
|
||||
|
||||
if (xfer->max_size == 0) {
|
||||
ret = false; // Endpoint is closed
|
||||
@ -635,7 +638,7 @@ bool dcd_edpt_xfer_fifo(uint8_t rhport, uint8_t ep_addr, tu_fifo_t* ff, uint16_t
|
||||
ret = true;
|
||||
}
|
||||
|
||||
usbd_spin_unlock(false);
|
||||
usbd_spin_unlock(is_isr);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
|
||||
/*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
@ -113,7 +114,8 @@ void dcd_edpt_close_all (uint8_t rhport) {
|
||||
}
|
||||
|
||||
// Submit a transfer, When complete dcd_event_xfer_complete() is invoked to notify the stack
|
||||
bool dcd_edpt_xfer (uint8_t rhport, uint8_t ep_addr, uint8_t * buffer, uint16_t total_bytes) {
|
||||
bool dcd_edpt_xfer(uint8_t rhport, uint8_t ep_addr, uint8_t * buffer, uint16_t total_bytes, bool is_isr) {
|
||||
(void) is_isr;
|
||||
(void) rhport;
|
||||
(void) ep_addr;
|
||||
(void) buffer;
|
||||
@ -122,7 +124,8 @@ bool dcd_edpt_xfer (uint8_t rhport, uint8_t ep_addr, uint8_t * buffer, uint16_t
|
||||
}
|
||||
|
||||
// Submit a transfer where is managed by FIFO, When complete dcd_event_xfer_complete() is invoked to notify the stack - optional, however, must be listed in usbd.c
|
||||
bool dcd_edpt_xfer_fifo (uint8_t rhport, uint8_t ep_addr, tu_fifo_t * ff, uint16_t total_bytes) {
|
||||
bool dcd_edpt_xfer_fifo(uint8_t rhport, uint8_t ep_addr, tu_fifo_t * ff, uint16_t total_bytes, bool is_isr) {
|
||||
(void) is_isr;
|
||||
(void) rhport;
|
||||
(void) ep_addr;
|
||||
(void) ff;
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
|
||||
/*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
@ -219,7 +220,7 @@ void dcd_set_address (uint8_t rhport, uint8_t dev_addr)
|
||||
USBFUNADR = dev_addr;
|
||||
|
||||
// Response with status after changing device address
|
||||
dcd_edpt_xfer(rhport, tu_edpt_addr(0, TUSB_DIR_IN), NULL, 0);
|
||||
dcd_edpt_xfer(rhport, tu_edpt_addr(0, TUSB_DIR_IN), NULL, 0, false);
|
||||
}
|
||||
|
||||
void dcd_remote_wakeup(uint8_t rhport)
|
||||
@ -344,8 +345,9 @@ void dcd_edpt_close_all (uint8_t rhport)
|
||||
// TODO implement dcd_edpt_close_all()
|
||||
}
|
||||
|
||||
bool dcd_edpt_xfer (uint8_t rhport, uint8_t ep_addr, uint8_t * buffer, uint16_t total_bytes)
|
||||
bool dcd_edpt_xfer(uint8_t rhport, uint8_t ep_addr, uint8_t * buffer, uint16_t total_bytes, bool is_isr)
|
||||
{
|
||||
(void) is_isr;
|
||||
(void) rhport;
|
||||
|
||||
uint8_t const epnum = tu_edpt_number(ep_addr);
|
||||
@ -393,8 +395,9 @@ bool dcd_edpt_xfer (uint8_t rhport, uint8_t ep_addr, uint8_t * buffer, uint16_t
|
||||
}
|
||||
|
||||
#if 0 // TODO support dcd_edpt_xfer_fifo API
|
||||
bool dcd_edpt_xfer_fifo (uint8_t rhport, uint8_t ep_addr, tu_fifo_t * ff, uint16_t total_bytes)
|
||||
bool dcd_edpt_xfer_fifo(uint8_t rhport, uint8_t ep_addr, tu_fifo_t * ff, uint16_t total_bytes, bool is_isr)
|
||||
{
|
||||
(void) is_isr;
|
||||
(void) rhport;
|
||||
|
||||
uint8_t const epnum = tu_edpt_number(ep_addr);
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
|
||||
/*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
@ -375,7 +376,7 @@ void dcd_int_disable(uint8_t rhport)
|
||||
void dcd_set_address(uint8_t rhport, uint8_t dev_addr)
|
||||
{
|
||||
// Respond with ACK status first before changing device address
|
||||
dcd_edpt_xfer(rhport, tu_edpt_addr(0, TUSB_DIR_IN), NULL, 0);
|
||||
dcd_edpt_xfer(rhport, tu_edpt_addr(0, TUSB_DIR_IN), NULL, 0, false);
|
||||
|
||||
// Wait for the response packet to get sent
|
||||
while (tx_active)
|
||||
@ -475,8 +476,9 @@ void dcd_edpt_clear_stall(uint8_t rhport, uint8_t ep_addr)
|
||||
// IN endpoints will get un-stalled when more data is written.
|
||||
}
|
||||
|
||||
bool dcd_edpt_xfer (uint8_t rhport, uint8_t ep_addr, uint8_t* buffer, uint16_t total_bytes)
|
||||
bool dcd_edpt_xfer(uint8_t rhport, uint8_t ep_addr, uint8_t * buffer, uint16_t total_bytes, bool is_isr)
|
||||
{
|
||||
(void) is_isr;
|
||||
(void)rhport;
|
||||
uint8_t ep_num = tu_edpt_number(ep_addr);
|
||||
uint8_t ep_dir = tu_edpt_dir(ep_addr);
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
|
||||
/*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
@ -218,7 +219,7 @@ void dcd_int_disable(uint8_t rhport) {
|
||||
|
||||
void dcd_set_address(uint8_t rhport, uint8_t dev_addr) {
|
||||
(void) dev_addr;
|
||||
dcd_edpt_xfer(rhport, 0x80, NULL, 0); // zlp status response
|
||||
dcd_edpt_xfer(rhport, 0x80, NULL, 0, false); // zlp status response
|
||||
}
|
||||
|
||||
void dcd_remote_wakeup(uint8_t rhport) {
|
||||
@ -289,7 +290,8 @@ void dcd_edpt_close(uint8_t rhport, uint8_t ep_addr) {
|
||||
// TODO optional
|
||||
}
|
||||
|
||||
bool dcd_edpt_xfer(uint8_t rhport, uint8_t ep_addr, uint8_t* buffer, uint16_t total_bytes) {
|
||||
bool dcd_edpt_xfer(uint8_t rhport, uint8_t ep_addr, uint8_t * buffer, uint16_t total_bytes, bool is_isr) {
|
||||
(void) is_isr;
|
||||
(void) rhport;
|
||||
uint8_t ep = tu_edpt_number(ep_addr);
|
||||
uint8_t dir = tu_edpt_dir(ep_addr);
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
|
||||
/*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
@ -203,7 +204,7 @@ void dcd_set_address(uint8_t rhport, uint8_t dev_addr) {
|
||||
(void) dev_addr;
|
||||
|
||||
// Response with zlp status
|
||||
dcd_edpt_xfer(rhport, 0x80, NULL, 0);
|
||||
dcd_edpt_xfer(rhport, 0x80, NULL, 0, false);
|
||||
}
|
||||
|
||||
void dcd_remote_wakeup(uint8_t rhport) {
|
||||
@ -315,7 +316,8 @@ void dcd_edpt_clear_stall(uint8_t rhport, uint8_t ep_addr) {
|
||||
}
|
||||
}
|
||||
|
||||
bool dcd_edpt_xfer(uint8_t rhport, uint8_t ep_addr, uint8_t* buffer, uint16_t total_bytes) {
|
||||
bool dcd_edpt_xfer(uint8_t rhport, uint8_t ep_addr, uint8_t * buffer, uint16_t total_bytes, bool is_isr) {
|
||||
(void) is_isr;
|
||||
(void) rhport;
|
||||
uint8_t const ep_num = tu_edpt_number(ep_addr);
|
||||
tusb_dir_t const dir = tu_edpt_dir(ep_addr);
|
||||
|
||||
@ -256,7 +256,7 @@ void test_msc(void)
|
||||
dcd_edpt_open_ExpectAndReturn(rhport, (tusb_desc_endpoint_t const *) tu_desc_next(desc_ep), true);
|
||||
|
||||
// Prepare SCSI command
|
||||
dcd_edpt_xfer_ExpectAndReturn(rhport, EDPT_MSC_OUT, NULL, sizeof(msc_cbw_t), true);
|
||||
dcd_edpt_xfer_ExpectAndReturn(rhport, EDPT_MSC_OUT, NULL, sizeof(msc_cbw_t), false, true);
|
||||
dcd_edpt_xfer_IgnoreArg_buffer();
|
||||
dcd_edpt_xfer_ReturnMemThruPtr_buffer( (uint8_t*) &cbw_read10, sizeof(msc_cbw_t));
|
||||
|
||||
@ -264,20 +264,20 @@ void test_msc(void)
|
||||
dcd_event_xfer_complete(rhport, EDPT_MSC_OUT, sizeof(msc_cbw_t), 0, true);
|
||||
|
||||
// control status
|
||||
dcd_edpt_xfer_ExpectAndReturn(rhport, EDPT_CTRL_IN, NULL, 0, true);
|
||||
dcd_edpt_xfer_ExpectAndReturn(rhport, EDPT_CTRL_IN, NULL, 0, false, true);
|
||||
|
||||
// SCSI Data transfer
|
||||
dcd_edpt_xfer_ExpectAndReturn(rhport, EDPT_MSC_IN, NULL, 512, true);
|
||||
dcd_edpt_xfer_ExpectAndReturn(rhport, EDPT_MSC_IN, NULL, 512, false, true);
|
||||
dcd_edpt_xfer_IgnoreArg_buffer();
|
||||
dcd_event_xfer_complete(rhport, EDPT_MSC_IN, 512, 0, true); // complete
|
||||
|
||||
// SCSI Status
|
||||
dcd_edpt_xfer_ExpectAndReturn(rhport, EDPT_MSC_IN, NULL, 13, true);
|
||||
dcd_edpt_xfer_ExpectAndReturn(rhport, EDPT_MSC_IN, NULL, 13, false, true);
|
||||
dcd_edpt_xfer_IgnoreArg_buffer();
|
||||
dcd_event_xfer_complete(rhport, EDPT_MSC_IN, 13, 0, true);
|
||||
|
||||
// Prepare for next command
|
||||
dcd_edpt_xfer_ExpectAndReturn(rhport, EDPT_MSC_OUT, NULL, sizeof(msc_cbw_t), true);
|
||||
dcd_edpt_xfer_ExpectAndReturn(rhport, EDPT_MSC_OUT, NULL, sizeof(msc_cbw_t), false, true);
|
||||
dcd_edpt_xfer_IgnoreArg_buffer();
|
||||
|
||||
tud_task();
|
||||
|
||||
@ -151,11 +151,11 @@ void test_usbd_get_device_descriptor(void)
|
||||
dcd_event_setup_received(rhport, (uint8_t*) &req_get_desc_device, false);
|
||||
|
||||
// data
|
||||
dcd_edpt_xfer_ExpectWithArrayAndReturn(rhport, 0x80, (uint8_t*)&data_desc_device, sizeof(tusb_desc_device_t), sizeof(tusb_desc_device_t), true);
|
||||
dcd_edpt_xfer_ExpectWithArrayAndReturn(rhport, 0x80, (uint8_t*)&data_desc_device, sizeof(tusb_desc_device_t), sizeof(tusb_desc_device_t), false, true);
|
||||
dcd_event_xfer_complete(rhport, EDPT_CTRL_IN, sizeof(tusb_desc_device_t), 0, false);
|
||||
|
||||
// status
|
||||
dcd_edpt_xfer_ExpectAndReturn(rhport, EDPT_CTRL_OUT, NULL, 0, true);
|
||||
dcd_edpt_xfer_ExpectAndReturn(rhport, EDPT_CTRL_OUT, NULL, 0, false, true);
|
||||
dcd_event_xfer_complete(rhport, EDPT_CTRL_OUT, 0, 0, false);
|
||||
dcd_edpt0_status_complete_ExpectWithArray(rhport, &req_get_desc_device, 1);
|
||||
|
||||
@ -184,11 +184,11 @@ void test_usbd_get_configuration_descriptor(void)
|
||||
dcd_event_setup_received(rhport, (uint8_t*) &req_get_desc_configuration, false);
|
||||
|
||||
// data
|
||||
dcd_edpt_xfer_ExpectWithArrayAndReturn(rhport, 0x80, (uint8_t*) data_desc_configuration, total_len, total_len, true);
|
||||
dcd_edpt_xfer_ExpectWithArrayAndReturn(rhport, 0x80, (uint8_t*) data_desc_configuration, total_len, total_len, false, true);
|
||||
dcd_event_xfer_complete(rhport, EDPT_CTRL_IN, total_len, 0, false);
|
||||
|
||||
// status
|
||||
dcd_edpt_xfer_ExpectAndReturn(rhport, EDPT_CTRL_OUT, NULL, 0, true);
|
||||
dcd_edpt_xfer_ExpectAndReturn(rhport, EDPT_CTRL_OUT, NULL, 0, false, true);
|
||||
dcd_event_xfer_complete(rhport, EDPT_CTRL_OUT, 0, 0, false);
|
||||
dcd_edpt0_status_complete_ExpectWithArray(rhport, &req_get_desc_configuration, 1);
|
||||
|
||||
@ -227,20 +227,20 @@ void test_usbd_control_in_zlp(void)
|
||||
|
||||
// 1st transaction
|
||||
dcd_edpt_xfer_ExpectWithArrayAndReturn(rhport, EDPT_CTRL_IN,
|
||||
zlp_desc_configuration, CFG_TUD_ENDPOINT0_SIZE, CFG_TUD_ENDPOINT0_SIZE, true);
|
||||
zlp_desc_configuration, CFG_TUD_ENDPOINT0_SIZE, CFG_TUD_ENDPOINT0_SIZE, false, true);
|
||||
dcd_event_xfer_complete(rhport, EDPT_CTRL_IN, CFG_TUD_ENDPOINT0_SIZE, 0, false);
|
||||
|
||||
// 2nd transaction
|
||||
dcd_edpt_xfer_ExpectWithArrayAndReturn(rhport, EDPT_CTRL_IN,
|
||||
zlp_desc_configuration + CFG_TUD_ENDPOINT0_SIZE, CFG_TUD_ENDPOINT0_SIZE, CFG_TUD_ENDPOINT0_SIZE, true);
|
||||
zlp_desc_configuration + CFG_TUD_ENDPOINT0_SIZE, CFG_TUD_ENDPOINT0_SIZE, CFG_TUD_ENDPOINT0_SIZE, false, true);
|
||||
dcd_event_xfer_complete(rhport, EDPT_CTRL_IN, CFG_TUD_ENDPOINT0_SIZE, 0, false);
|
||||
|
||||
// Expect Zero length Packet
|
||||
dcd_edpt_xfer_ExpectAndReturn(rhport, EDPT_CTRL_IN, NULL, 0, true);
|
||||
dcd_edpt_xfer_ExpectAndReturn(rhport, EDPT_CTRL_IN, NULL, 0, false, true);
|
||||
dcd_event_xfer_complete(rhport, EDPT_CTRL_IN, 0, 0, false);
|
||||
|
||||
// Status
|
||||
dcd_edpt_xfer_ExpectAndReturn(rhport, EDPT_CTRL_OUT, NULL, 0, true);
|
||||
dcd_edpt_xfer_ExpectAndReturn(rhport, EDPT_CTRL_OUT, NULL, 0, false, true);
|
||||
dcd_event_xfer_complete(rhport, EDPT_CTRL_OUT, 0, 0, false);
|
||||
dcd_edpt0_status_complete_ExpectWithArray(rhport, &req_get_desc_configuration, 1);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user