Esempio n. 1
0
void assert_status_ok_message(HCD_STATUS status,
							  char const *mess,
							  char const *func,
							  char const *file,
							  uint32_t const line)
{
	if (HCD_STATUS_OK != status) {
		hcd_printf("%s\r\n", func);
		hcd_printf("\t%s: %d\r\n", file, line);
		hcd_printf("\tEvaluated HCD_STATUS = %d\r\n", (uint32_t) status);
		if (mess != NULL) {
			hcd_printf("\t%s\r\n", mess);
		}
	}
}
Esempio n. 2
0
static void ProcessDoneQueue(uint8_t HostID, uint32_t donehead)
{
    PHC_GTD pCurTD = (PHC_GTD) donehead;
    PHC_GTD pTDList = NULL;

    /* do nothing if done queue is empty */
    if (!donehead) {
        return;
    }

    /* reverse done queue order */
    do {
        uint32_t nextTD = pCurTD->NextTD;
        pCurTD->NextTD = (uint32_t) pTDList;
        pTDList = pCurTD;
        pCurTD = (PHC_GTD) nextTD;
    } while (pCurTD);

    while (pTDList != NULL) {
        uint32_t EdIdx;

        pCurTD  = pTDList;
        pTDList = (PHC_GTD) pTDList->NextTD;

        /* TODO Cannot determine EdIdx because GTD and ITD have different offsets for EdIdx  */
        if ( ((uint32_t) pCurTD) <=  ((uint32_t) HcdITD(MAX_ITD - 1)) ) {	/* ISO TD address range */
            PHCD_IsoTransferDescriptor pItd = (PHCD_IsoTransferDescriptor) pCurTD;
            EdIdx = pItd->EdIdx;
        }
        else {	/* GTD */
            PHCD_GeneralTransferDescriptor pGtd = (PHCD_GeneralTransferDescriptor) pCurTD;
            EdIdx = pGtd->EdIdx;

            if (pGtd->hcGTD.CurrentBufferPointer) {
                pGtd->TransferCount -=
                    ( Align4k( ((uint32_t) pGtd->hcGTD.BufferEnd) ^
                               ((uint32_t) pGtd->hcGTD.CurrentBufferPointer) ) ? 0x00001000 : 0 ) +
                    Offset4k((uint32_t) pGtd->hcGTD.BufferEnd) - Offset4k(
                        (uint32_t) pGtd->hcGTD.CurrentBufferPointer) + 1;
            }
            if (HcdED(EdIdx)->pActualTransferCount) {
                *(HcdED(EdIdx)->pActualTransferCount) = pGtd->TransferCount;/* increase usb request transfer count */

            }
        }

        if (pCurTD->DelayInterrupt != TD_NoInterruptOnComplete) {	/* Update ED status if Interrupt on Complete is set */
            HcdED(EdIdx)->status = pCurTD->ConditionCode;
        }

        if ( pCurTD->ConditionCode ) {	/* also update ED status if TD complete with error */
            HcdED(EdIdx)->status =
                (HcdED(EdIdx)->hcED.HeadP.Halted == 1) ? HCD_STATUS_TRANSFER_Stall : pCurTD->ConditionCode;
            HcdED(EdIdx)->hcED.HeadP.Halted = 0;
            hcd_printf("Error on Endpoint 0x%X has HCD_STATUS code %d\r\n",
                       HcdED(EdIdx)->hcED.FunctionAddr | (HcdED(EdIdx)->hcED.Direction == 2 ? 0x80 : 0x00),
                       pCurTD->ConditionCode);
        }

        /* remove completed TD from usb request list, if request list is now empty complete usb request */
        if (IsIsoEndpoint(EdIdx)) {
            FreeItd( (PHCD_IsoTransferDescriptor) pCurTD);
        }
        else {
            FreeGtd( (PHCD_GeneralTransferDescriptor) pCurTD);
        }

        /* Post Semaphore to signal TDs are transfer */
    }
}