Error checking for USB interrupt transfer
This commit is contained in:
parent
e14d4863b9
commit
a42c8f6c41
@ -3,7 +3,7 @@
|
|||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
README file for "USBD" USB host controller driver.
|
README file for "USBD" USB host controller driver.
|
||||||
|
|
||||||
created march-may 2014, JPEmbedded (info@jpembedded.eu)
|
created march-june 2014, JPEmbedded (info@jpembedded.eu)
|
||||||
|
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
* KNOWN LIMITATIONS: *
|
* KNOWN LIMITATIONS: *
|
||||||
@ -13,4 +13,7 @@ created march-may 2014, JPEmbedded (info@jpembedded.eu)
|
|||||||
- DDEKit does not implement resource deallocation for corresponding thread
|
- DDEKit does not implement resource deallocation for corresponding thread
|
||||||
creation (see ddekit_thread_terminate, ddekit_thread_create) thus resources
|
creation (see ddekit_thread_terminate, ddekit_thread_create) thus resources
|
||||||
are spilled
|
are spilled
|
||||||
- Driver assumes that there is no preemption for DDEKit threading
|
- Driver assumes that there is no preemption for DDEKit threading
|
||||||
|
- URBs are enqueued in DDEKit but not in USBD itself
|
||||||
|
- DDEKit way of handling interface numbers is not explicitly defined, bitmask
|
||||||
|
formatting for it, is therefore hardcoded into USBD
|
||||||
|
@ -804,8 +804,10 @@ hcd_data_transfer(hcd_device_state * this_device, hcd_datarequest * request)
|
|||||||
request->data += transfer_len;
|
request->data += transfer_len;
|
||||||
|
|
||||||
/* Total length shall not become negative */
|
/* Total length shall not become negative */
|
||||||
USB_ASSERT(request->size >= 0,
|
if (request->size < 0) {
|
||||||
"Invalid amount of data received");
|
USB_MSG("Invalid amount of data received");
|
||||||
|
return EXIT_FAILURE;
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
/* TODO: REMOVEME (dumping of data transfer) */
|
/* TODO: REMOVEME (dumping of data transfer) */
|
||||||
@ -813,7 +815,8 @@ hcd_data_transfer(hcd_device_state * this_device, hcd_datarequest * request)
|
|||||||
int i;
|
int i;
|
||||||
USB_MSG("RECEIVED: %d", transfer_len);
|
USB_MSG("RECEIVED: %d", transfer_len);
|
||||||
for (i = 0; i < transfer_len; i++)
|
for (i = 0; i < transfer_len; i++)
|
||||||
USB_MSG("%c",
|
USB_MSG("0x%02X: %c",
|
||||||
|
(request->data-transfer_len)[i],
|
||||||
(request->data-transfer_len)[i]);
|
(request->data-transfer_len)[i]);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@ -835,7 +838,7 @@ hcd_data_transfer(hcd_device_state * this_device, hcd_datarequest * request)
|
|||||||
|
|
||||||
/* Total length shall not become negative */
|
/* Total length shall not become negative */
|
||||||
USB_ASSERT(request->size >= 0,
|
USB_ASSERT(request->size >= 0,
|
||||||
"Invalid amount of data received");
|
"Invalid amount of transfer data calculated");
|
||||||
|
|
||||||
/* Start actual data transfer */
|
/* Start actual data transfer */
|
||||||
d->tx_stage(d->private_data, &temp_req);
|
d->tx_stage(d->private_data, &temp_req);
|
||||||
|
@ -795,13 +795,17 @@ musb_check_error(void * cfg, hcd_transfer transfer, hcd_direction dir)
|
|||||||
|
|
||||||
DEBUG_DUMP;
|
DEBUG_DUMP;
|
||||||
|
|
||||||
|
/* TODO: ISO transfer */
|
||||||
|
USB_ASSERT(HCD_TRANSFER_ISOCHRONOUS != transfer,
|
||||||
|
"ISO transfer not supported");
|
||||||
|
|
||||||
r = ((musb_core_config *)cfg)->regs;
|
r = ((musb_core_config *)cfg)->regs;
|
||||||
|
|
||||||
/* Set EP and device address to be used in this command */
|
/* Set EP and device address to be used in this command */
|
||||||
musb_set_state((musb_core_config *)cfg);
|
musb_set_state((musb_core_config *)cfg);
|
||||||
|
|
||||||
/* TODO: In MUSB only EP0 is allowed to handle control transfers
|
/* TODO: More than one control EP? */
|
||||||
* so there is no EP checking in this function */
|
/* In MUSB EP0 has it's own registers for error handling */
|
||||||
if (HCD_TRANSFER_CONTROL == transfer) {
|
if (HCD_TRANSFER_CONTROL == transfer) {
|
||||||
/* Get control status register */
|
/* Get control status register */
|
||||||
host_csr = HCD_RD2(r, MUSB_REG_HOST_CSR0);
|
host_csr = HCD_RD2(r, MUSB_REG_HOST_CSR0);
|
||||||
@ -831,7 +835,9 @@ musb_check_error(void * cfg, hcd_transfer transfer, hcd_direction dir)
|
|||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((HCD_TRANSFER_BULK == transfer) && (HCD_DIRECTION_OUT == dir)) {
|
/* Non-control transfer error check,
|
||||||
|
* is based on transfer direction */
|
||||||
|
if (HCD_DIRECTION_OUT == dir) {
|
||||||
/* Get RX status register */
|
/* Get RX status register */
|
||||||
host_csr = HCD_RD2(r, MUSB_REG_HOST_TXCSR);
|
host_csr = HCD_RD2(r, MUSB_REG_HOST_TXCSR);
|
||||||
|
|
||||||
@ -860,7 +866,7 @@ musb_check_error(void * cfg, hcd_transfer transfer, hcd_direction dir)
|
|||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((HCD_TRANSFER_BULK == transfer) && (HCD_DIRECTION_IN == dir)) {
|
if (HCD_DIRECTION_IN == dir) {
|
||||||
/* Get RX status register */
|
/* Get RX status register */
|
||||||
host_csr = HCD_RD2(r, MUSB_REG_HOST_RXCSR);
|
host_csr = HCD_RD2(r, MUSB_REG_HOST_RXCSR);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user