📄 usbtcdpdiusbd12interrupt.c
字号:
/* usbTcdPdiusbd12Interrupt.c - Defines modules for interrupt handling *//* Copyright 2004 Wind River Systems, Inc. *//*Modification history--------------------01a,17sep04,ami WindView Instrumentation Changes01b,11may04,hch merge after D12 driver testing.01b,19jul04,ami Coding Convnetion Changes01a,15mar04,ami First*//*DESCRIPTIONThis module implements the various hardware dependent features of PDIUSBD12which are related to interrupt handling.INCLUDE FILES: usb/usbPlatform.h, usb/ossLib.h, usb/target/usbIsaLib.h, drv/usb/target/usbPdiusbd12Eval.h, drv/usb/target/usbTcdPdiusbd12EvalLib.h, drv/usb/target/usbPdiusbd12Tcd.h, drv/usb/target/usbPdiusbd12Debug.h, usb/target/usbPeriphInstr.h *//* includes */#include "usb/usbPlatform.h" #include "usb/ossLib.h" #include "drv/usb/target/usbPdiusbd12Eval.h" #include "drv/usb/target/usbTcdPdiusbd12EvalLib.h" #include "drv/usb/target/usbPdiusbd12Tcd.h" #include "drv/usb/target/usbPdiusbd12Debug.h" #include "usb/target/usbPeriphInstr.h" /********************************************************************************* usbTcdPdiusbd12Isr - isr of pdiusbd12 TCD** This is the ISR for the pdiusbd12 TCD** RETURNS: N/A** ERRNO:* none** \NOMANUAL*/LOCAL VOID usbTcdPdiusbd12Isr ( pVOID param /* ISR Parameter */ ) { pUSB_TCD_PDIUSBD12_TARGET pTarget = NULL; /* USB_TCD_PDIUSBD12_TARGET */ if ( param == NULL ) { USBPDIUSBD12_DEBUG ("usbTcdPdiusbd12Isr : Invalid Parameter...\n", 0,0,0,0,0,0); return; } pTarget = (pUSB_TCD_PDIUSBD12_TARGET) param; /* * Is there an interrupt pending ? * * NOTE: INT_N is an active low signal. The interrupt is asserted * when INT_N == 0. */ USBPDIUSBD12_DEBUG ( " usbTcdPdiusbd12Isr : Entered the ISR...\n",0,0,0, 0,0,0); if ((IN_EVAL_GIN (pTarget) & D12EVAL_INTN) == 0) { /* A interrupt is pending. Disable interrupts */ USBPDIUSBD12_DEBUG ( " usbTcdPdiusbd12Isr : Disabling Interrupts...\n", 0,0,0,0,0,0); pTarget->goutByte &= ~D12EVAL_GOUT_INTENB; OUT_EVAL_GOUT (pTarget,pTarget->goutByte); /* Call the HAL ISR callback */ USBPDIUSBD12_DEBUG ( "usbTcdPdiusbd12Isr : Calling the HAL Isr... \n", 0,0,0,0,0,0 ); (*pTarget->usbHalIsr)(pTarget->usbHalIsrParam); /* Enable the interrupts */ USBPDIUSBD12_DEBUG ( " usbTcdPdiusbd12Isr : Enabling Interrupts...\n", 0,0,0,0,0,0); pTarget->goutByte |= D12EVAL_GOUT_INTENB; OUT_EVAL_GOUT (pTarget,pTarget->goutByte); } return; }#ifdef PDIUSBD12_POLLING/********************************************************************************* usbTcdPdiusbd12PollingIsr - polling ISR of pdiusbd12 TCD** This is the ISR for the pdiusbd12 TCD which runs in polling mode.** RETURNS: N/A** ERRNO:* none.** \NOMANUAL*/LOCAL VOID usbTcdPdiusbd12PollingIsr ( pVOID param /* ISR Polling Parameter */ ) { while(1) { usbTcdPdiusbd12Isr(param); OSS_THREAD_SLEEP (1); } return; }#endif/********************************************************************************* usbTcdPdiusbd12FncEndpointIntStatusGet - implements TCD_FNC_ENDPOINT_INTERRUPT_STATUS_GET** This function returns the interrupt status of an endpoint.** RETURNS : OK or ERROR, if not able to get the interrupt status** ERRNO:* none.** \NOMANUAL*/LOCAL STATUS usbTcdPdiusbd12FncEndpointIntStatusGet ( pTRB_ENDPOINT_INTERRUPT_STATUS_GET pTrb /* Trb to be executed */ ) { BOOL endptIntPending = FALSE; /* endpoint interrupt is pending */ UINT8 readLastStatusByte = 0; /* last status byte */ UINT8 readErrorByte = 0; /* error byte */ pTRB_HEADER pHeader = (pTRB_HEADER) pTrb; /* TRB_HEADER */ pUSB_TCD_PDIUSBD12_TARGET pTarget = NULL; /* USB_TCD_PDIUSBD12_TARGET */ pUSB_TCD_PDIUSBD12_ENDPOINT pEndpoint = NULL; /* USB_TCD_PDIUSBD12_ENDPOINT */ /* WindView Instrumentation */ USB_TCD_LOG_EVENT(USB_TCD_PDIUSBD12_INTERRUPT, "usbTcdPdiusbd12FncEndpointIntStatusGet entered ...", USB_TCD_PDIUSBD12_WV_FILTER); USBPDIUSBD12_DEBUG ( "usbTcdPdiusbd12FncEndpointIntStatusGet: Entered \ ...\n",0,0,0,0,0,0); /* Validate Parameters */ if ((pHeader == NULL) || (pHeader->trbLength < sizeof (TRB_HEADER)) || (pTrb->pipeHandle == 0)) { /* WindView Instrumentation */ USB_TCD_LOG_EVENT(USB_TCD_PDIUSBD12_INTERRUPT, "usbTcdPdiusbd12FncEndpointIntStatusGet exiting:Bad Parameters Received", USB_TCD_PDIUSBD12_WV_FILTER); USBPDIUSBD12_ERROR ( " usbTcdPdiusbd12FncEndpointIntStatusGet : \ Invalid parameters ...\n",0,0,0,0,0,0 ); return ossStatus (S_usbTcdLib_BAD_PARAM); } pTarget = (pUSB_TCD_PDIUSBD12_TARGET) pHeader->handle; pEndpoint = (pUSB_TCD_PDIUSBD12_ENDPOINT)pTrb->pipeHandle; /* Detemine whether interrupt is pending on this endpoint */ if (pTarget->endptIntPending != 0) { if(((pTarget->endptIntPending >> pEndpoint->endpointIndex) & 0x01) != 0) { /* Clear the interrupt pending bit of the endpoint */ pTarget->endptIntPending &= ~(0x01 << pEndpoint->endpointIndex); endptIntPending = TRUE; } } /* Interrupt is pending on that endpoint */ if (endptIntPending) { /* WindView Instrumentation */ USB_TCD_LOG_EVENT(USB_TCD_PDIUSBD12_INTERRUPT, "usbTcdPdiusbd12FncEndpointIntStatusGet Interrupt pending on Endpoint", USB_TCD_PDIUSBD12_WV_FILTER); /* Updating uEndptInterruptStatus flag */ pTrb->uEndptInterruptStatus = 0; pTrb->uEndptInterruptStatus |= USBTCD_ENDPOINT_INTERRUPT_PENDING_MASK; /* Reading Last Status Byte Register */ USBPDIUSBD12_DEBUG ( "usbTcdPdiusbd12FncEndpointIntStatusGet: Reading \ Last Status Byte Register...\n",0,0,0,0,0,0); /* Read the value which is stored in the data structure */ readLastStatusByte = pTarget->uLastTransactionStatus[pEndpoint->endpointIndex]; /* Clear the value in the data structure */ pTarget->uLastTransactionStatus[pEndpoint->endpointIndex] &= ~readLastStatusByte; /* No Error */ if ((readLastStatusByte & D12_CMD_RLTS_DATA_SUCCESS) != 0) { /* check whether setup packet is received */ if ((readLastStatusByte & D12_CMD_RLTS_SETUP_PACKET) != 0) { /* WindView Instrumentation */ USB_TCD_LOG_EVENT(USB_TCD_PDIUSBD12_INTERRUPT, "usbTcdPdiusbd12FncEndpointIntStatusGet: Setup Packet Received", USB_TCD_PDIUSBD12_WV_FILTER); USBPDIUSBD12_DEBUG ( "usbTcdPdiusbd12FncEndpointIntStatusGet: \ Setup Packet is received \n",0,0,0,0,0,0); /* update uEndptInterruptStatus flag */ pTrb->uEndptInterruptStatus |= USBTCD_ENDPOINT_SETUP_PID_MASK; /* Acknowledge the setup token */ USBPDIUSBD12_DEBUG ( "usbTcdPdiusbd12FncEndpointIntStatusGet: \ Acknowledge the Setup Packet received \n",0,0,0,0,0,0); /* Set the flag indicating that the setup ERP is pending */ pTarget->setupErpPending = TRUE; } else { if ( pEndpoint->direction == USB_ENDPOINT_OUT ) pTrb->uEndptInterruptStatus |= USBTCD_ENDPOINT_OUT_PID_MASK ; else pTrb->uEndptInterruptStatus |= USBTCD_ENDPOINT_IN_PID_MASK ; } pTrb->uEndptInterruptStatus |= USBTCD_ENDPOINT_TRANSFER_SUCCESS; } else { /* * To read the error codes -- * if any, or with pTrb->uEndptInterruptStatus */ /* Masking and then shifting the bits to retrieve the error codes */ readErrorByte = D12_CMD_RLTS_ERROR_CODE (readLastStatusByte) ; switch (readErrorByte) { case D12_CMD_RLTS_ERROR_DATA_TOGGLE : case D12_CMD_RLTS_ERROR_PID_ENCODE : case D12_CMD_RLTS_ERROR_PID_UNKNOWN : case D12_CMD_RLTS_ERROR_EXPECTED_PKT : USBPDIUSBD12_DEBUG ( "usbTcdPdiusbd12FncEndpointIntStatusGet:\ PID Mismatch Error...\n",0,0,0,0,0,0); pTrb->uEndptInterruptStatus |= USBTCD_ENDPOINT_PID_MISMATCH ; break; case D12_CMD_RLTS_ERROR_TOKEN_CRC : case D12_CMD_RLTS_ERROR_DATA_CRC : USBPDIUSBD12_DEBUG ( "usbTcdPdiusbd12FncEndpointIntStatusGet:\ Token CRC Error...\n",0,0,0,0,0,0); pTrb->uEndptInterruptStatus |= USBTCD_ENDPOINT_CRC_ERROR; break; case D12_CMD_RLTS_ERROR_TIME_OUT : USBPDIUSBD12_DEBUG ( "usbTcdPdiusbd12FncEndpointIntStatusGet:\ Time Out Error...\n",0,0,0,0,0,0); pTrb->uEndptInterruptStatus |= USBTCD_ENDPOINT_TIMEOUT_ERROR; break; case D12_CMD_RLTS_ERROR_END_OF_PKT : USBPDIUSBD12_DEBUG ( "usbTcdPdiusbd12FncEndpointIntStatusGet:\ End of Packet Error...\n",0,0,0,0,0,0); pTrb->uEndptInterruptStatus |= USBTCD_ENDPOINT_COMMN_FAULT; break; case D12_CMD_RLTS_ERROR_STALL : USBPDIUSBD12_DEBUG("usbTcdPdiusbd12FncEndpointIntStatusGet:\ Endpoint Stall Error...\n",0,0,0,0,0,0); pTrb->uEndptInterruptStatus |= USBTCD_ENDPOINT_STALL_ERROR; break; case D12_CMD_RLTS_ERROR_OVERFLOW :
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -