📄 usbtcdpdiusbd12initexit.c
字号:
"usbTcdPdiusbd12FncAttach exiting: Error hooking function for reboot...", USB_TCD_PDIUSBD12_WV_FILTER); USBPDIUSBD12_DEBUG ( " usbTcdPdiusbd12FncAttach: Not able \ to hook a function on reboot ", 0,0,0,0,0,0); destroyTarget (pTarget); return ERROR; } /* Set Address to Zero */ USBPDIUSBD12_DEBUG ( " usbTcdPdiusbd12FncAttach : Setting Device address \ to 0 \n ",0,0,0,0,0,0); pTarget->deviceAddress = 0; OUT_D12_CMD (pTarget,D12_CMD_SET_ADDRESS); OUT_D12_DATA (pTarget,byte); /* Disable endpoints 1 and 2 */ d12SetEndpointEnable (pTarget, 0); /* Clear Endpoint Fifo Buffers and endpoint status. */ USBPDIUSBD12_DEBUG ( " usbTcdPdiusbd12FncAttach : Clearing Endpoints \n ", 0,0,0,0,0,0); for (i = 0; i < D12_NUM_ENDPOINTS; i++) { d12SelectEndpoint (pTarget, i); d12ClearBfr (pTarget); d12ReadLastTransStatusByte (pTarget, i); } /* Clear the Interrupt Status Register */ USBPDIUSBD12_DEBUG ( " usbTcdPdiusbd12FncAttach : Clearing Interrupt \ Status Register ...", 0,0,0,0,0,0); d12ReadIntReg (pTarget); /* Store HAL parameters */ pTarget->usbHalIsr = pTrb->usbHalIsr; pTarget->usbHalIsrParam = pTrb->usbHalIsrParam; /* Hook the ISR */ USBPDIUSBD12_DEBUG ( " usbTcdPdiusbd12FncAttach : Hooking \ the ISR...\n",0,0,0,0,0,0);#ifndef PDIUSBD12_POLLING if (USB_ISA_INT_CONNECT (usbTcdPdiusbd12Isr, pTarget, pTarget->irq)!= OK) { /* WindView Instrumentation */ USB_TCD_LOG_EVENT(USB_TCD_PDIUSBD12_INIT_EXIT, "usbTcdPdiusbd12FncAttach exiting: Error Hooking ISR...", USB_TCD_PDIUSBD12_WV_FILTER); USBPDIUSBD12_ERROR ( "usbTcdPdiusbd12FncAttach : Hooking of ISR \ Failed... " ,0,0,0,0,0,0); destroyTarget (pTarget); return ERROR; }#else /* Create a thread for handling the interrupts */ if (OSS_THREAD_CREATE((THREAD_PROTOTYPE)usbTcdPdiusbd12PollingIsr, pTarget, 100, "d12Thread", &pTarget->threadId) != OK) { /* WindView Instrumentation */ USB_TCD_LOG_EVENT(USB_TCD_PDIUSBD12_INIT_EXIT, "usbTcdPdiusbd12FncAttach exiting: Error spawning the thread...", USB_TCD_PDIUSBD12_WV_FILTER); USBPDIUSBD12_ERROR ( "usbTcdPdiusbd12FncAttach : Spawning of polling \ ISR Failed... " ,0,0,0,0,0,0); destroyTarget (pTarget); return ERROR; }#endif /* continue initializing hardware */ /* * set basic operating mode * * NOTE: Setting the "clock running" bit keeps the chip alive even during * suspend in order to facilitate debugging. In a production environment * where power device power consumption may be an issue, this bit should * not be set. */ USBPDIUSBD12_DEBUG ( " usbTcdPdiusbd12FncAttach : Setting the Mode \ Register...\n",0,0,0,0,0,0); pTarget->configByte = D12_CMD_SM_CFG_NO_LAZYCLOCK | D12_CMD_SM_CFG_CLOCK_RUNNING | D12_CMD_SM_CFG_MODE0_NON_ISO; pTarget->clkDivByte = D12_CMD_SM_CLK_DIV_DEFAULT | D12_CMD_SM_CLK_SET_TO_ONE; d12SetMode (pTarget); /* * Set default DMA mode * * NOTE: Originally when writing this code I set the PDIUSBD12 for * single-cycle DMA mode. However, I noticed that the D12 would stop * asserting DRQ mid-transfer. In examining the Philips evaluation code, * I noticed that they only use "burst 16" DMA mode, and that appears * to work correct. -rcb */ USBPDIUSBD12_DEBUG ( " usbTcdPdiusbd12FncAttach : Setting the \ DMA Register ...\n",0,0,0,0,0,0); pTarget->dmaByte = D12_CMD_SD_DMA_BURST_16 | D12_CMD_SD_ENDPT_2_OUT_INTRPT | D12_CMD_SD_ENDPT_2_IN_INTRPT; d12SetDma (pTarget); /* * The following command enables interrupts. Since we're using * an evaluation board with some debug LEDs, we also turn on an "LED" * to indicate that the board is configured. */ pTarget->goutByte = ATTACH_LED | D12EVAL_GOUT_INTENB; OUT_EVAL_GOUT (pTarget,pTarget->goutByte); /* Return target information to caller */ pTrb->pHalDeviceInfo->uNumberEndpoints = D12_NUM_ENDPOINTS; /* supports remote wake up */ pTrb->pDeviceInfo->uDeviceFeature = USB_FEATURE_DEVICE_REMOTE_WAKEUP; /* * Setting the bit maps for usEndpointNumbr Bitmap * bits 0,1,2 are to be set for out endpoint, * bits 16,17,18 are to be set for in endpoint */ pTrb->pDeviceInfo->uEndpointNumberBitmap = USB_PDIUSBD12_TCD_OUT_ENDPOINT | USB_PDIUSBD12_TCD_IN_ENDPOINT ; USBPDIUSBD12_DEBUG ( " usbTcdPdiusbd12FncAttach : Updating the \ Handle...\n",0, 0,0,0,0,0); /* update handle */ pHeader->handle = pTarget; /* WindView Instrumentation */ USB_TCD_LOG_EVENT(USB_TCD_PDIUSBD12_INIT_EXIT, "usbTcdPdiusbd12FncAttach exiting...", USB_TCD_PDIUSBD12_WV_FILTER); USBPDIUSBD12_DEBUG ( " usbTcdPdiusbd12FncAttach : Exiting ...\ \n",0,0,0,0,0,0); return OK; }/********************************************************************************* destroyTarget - function releases target structure** This function releases the resources allocated for a target controller** RETURNS: N/A** ERRNO:* none.** \NOMANUAL*/LOCAL VOID destroyTarget ( pUSB_TCD_PDIUSBD12_TARGET pTarget /* USB_TCD_PDIUSBD12_TARGET */ ) { /* WindView Instrumentation */ USB_TCD_LOG_EVENT(USB_TCD_PDIUSBD12_INIT_EXIT, "destroyTarget entered...",USB_TCD_PDIUSBD12_WV_FILTER); USBPDIUSBD12_DEBUG ("destroyTarget: Entering destroyTarget...\n", 0,0,0,0,0,0); if (pTarget) { /* Disable interrupts, turn off LEDs */ if (pTarget->ioBase != 0) OUT_EVAL_GOUT (pTarget,0); if (pTarget->usbHalIsr)#ifndef PDIUSBD12_POLLING USB_ISA_INT_RESTORE (usbTcdPdiusbd12Isr, pTarget,pTarget->irq);#else OSS_THREAD_DESTROY(pTarget->threadId);#endif OSS_FREE (pTarget); } USBPDIUSBD12_DEBUG ("destroyTarget: Exiting \ destroyTarget...\n", 0,0,0,0,0,0); }/********************************************************************************* usbTcdPdiusbd12FncDetach - implements TCD_FNC_DETACH** The purpose of this function is to shutdown the Target Controller** RETURNS: OK or ERROR, if TCD is not able to detach.** ERRNO:* none** \NOMANUAL*/LOCAL STATUS usbTcdPdiusbd12FncDetach ( pTRB_DETACH pTrb /* TRB to be executed */ ) { pTRB_HEADER pHeader = (pTRB_HEADER) pTrb; /* TRB_HEADER */ pUSB_TCD_PDIUSBD12_TARGET pTarget = NULL; /* USB_TCD_PDIUSBD12_TARGET */ /* WindView Instrumentation */ USB_TCD_LOG_EVENT(USB_TCD_PDIUSBD12_INIT_EXIT, "usbTcdPdiusbd12FncDetach entered...",USB_TCD_PDIUSBD12_WV_FILTER); USBPDIUSBD12_DEBUG ("usbTcdPdiusbd12FncDetach: Entered ...\n", 0,0,0,0,0,0); /* Validate parameters */ if (pHeader == NULL || pHeader->trbLength < sizeof (TRB_HEADER) || (pHeader->handle == NULL) ) { /* WindView Instrumentation */ USB_TCD_LOG_EVENT(USB_TCD_PDIUSBD12_INIT_EXIT, "usbTcdPdiusbd12FncDetach exiting: Bad Paramters Received...", USB_TCD_PDIUSBD12_WV_FILTER); USBPDIUSBD12_DEBUG (" usbTcdPdiusbd12FncDetach: Parameter Validation \ is unsuccessful",0,0,0,0,0,0); return ERROR; } pTarget = (pUSB_TCD_PDIUSBD12_TARGET) pHeader->handle; /* Disable the target controller */ pTarget->configByte &= ~D12_CMD_SM_CFG_SOFTCONNECT; d12SetMode (pTarget); pTarget->goutByte &= ~ENABLE_LED; OUT_EVAL_GOUT (pTarget,pTarget->goutByte); destroyTarget(pTarget); /* WindView Instrumentation */ USB_TCD_LOG_EVENT(USB_TCD_PDIUSBD12_INIT_EXIT, "usbTcdPdiusbd12FncDetach exiting...",USB_TCD_PDIUSBD12_WV_FILTER); USBPDIUSBD12_DEBUG ("usbTcdPdiusbd12FncDetach: Exiting...\n",0,0,0,0,0,0); return OK; }/********************************************************************************* usbTcdPdiusbd12FncEnable - implements TCD_FNC_ENABLE** The purpose of this function is to enable the Target Controller** RETURNS: OK or ERROR, if not able to enable the target controller.** ERRNO:* none** \NOMANUAL*/LOCAL STATUS usbTcdPdiusbd12FncEnable ( pTRB_ENABLE_DISABLE pTrb /* TRB to executed */ ) { pTRB_HEADER pHeader = (pTRB_HEADER) pTrb; /* TRB_HEADER */ pUSB_TCD_PDIUSBD12_TARGET pTarget = NULL; /* USB_TCD_PDIUSBD12_TARGET */ /* WindView Instrumentation */ USB_TCD_LOG_EVENT(USB_TCD_PDIUSBD12_INIT_EXIT, "usbTcdPdiusbd12FncEnable entered...",USB_TCD_PDIUSBD12_WV_FILTER); USBPDIUSBD12_DEBUG ("usbTcdPdiusbd12FncEnable: Entered...",0,0,0,0,0,0); /* Validate parameters */ if (pHeader == NULL || pHeader->trbLength < sizeof (TRB_HEADER) || (pHeader->handle == NULL) ) { /* WindView Instrumentation */ USB_TCD_LOG_EVENT(USB_TCD_PDIUSBD12_INIT_EXIT, "usbTcdPdiusbd12FncEnable exiting: Bad Paramters Received...", USB_TCD_PDIUSBD12_WV_FILTER); USBPDIUSBD12_DEBUG ("usbTcdPdiusbd12FncEnable: Parameter Validation \ is unsuccessful",0,0,0,0,0,0); return ERROR; } /* Extract the target pointer from the handle */ pTarget = (pUSB_TCD_PDIUSBD12_TARGET) pHeader->handle; /* enable soft connect */ USBPDIUSBD12_DEBUG ( " usbTcdPdiusbd12FncEnable : \ Enabling Soft Connect...",0, 0,0,0,0,0); pTarget->configByte |= D12_CMD_SM_CFG_SOFTCONNECT; d12SetMode (pTarget); /* light LED indicating that target is enabled */ pTarget->goutByte |= ENABLE_LED; OUT_EVAL_GOUT (pTarget,pTarget->goutByte); /* WindView Instrumentation */ USB_TCD_LOG_EVENT(USB_TCD_PDIUSBD12_INIT_EXIT, "usbTcdPdiusbd12FncEnable exiting...",USB_TCD_PDIUSBD12_WV_FILTER); USBPDIUSBD12_DEBUG ("usbTcdPdiusbd12FncEnable: Exiting \ ...",0,0,0,0,0,0); return OK; }/********************************************************************************* usbTcdPdiusbd12FncDisable - implements TCD_FNC_DISABLE** The purpose of this function is to disable the Target Controller** RETURNS: OK or ERROR, if not able to disable the target controller.** ERRNO:* none.** \NOMANUAL*/LOCAL STATUS usbTcdPdiusbd12FncDisable ( pTRB_ENABLE_DISABLE pTrb /* TRB to be executed */ ) { pTRB_HEADER pHeader = (pTRB_HEADER) pTrb; /* TRB_HEADER */ pUSB_TCD_PDIUSBD12_TARGET pTarget = NULL; /* USB_TCD_PDIUSBD12_TARGET */ /* WindView Instrumentation */ USB_TCD_LOG_EVENT(USB_TCD_PDIUSBD12_INIT_EXIT, "usbTcdPdiusbd12FncDisable entered...",USB_TCD_PDIUSBD12_WV_FILTER); USBPDIUSBD12_DEBUG ( " usbTcdPdiusbd12FncDisable:Entered...\n",0,0,0,0,0,0); /* Validate parameters */ if (pHeader == NULL || pHeader->trbLength < sizeof (TRB_HEADER) || (pHeader->handle == NULL) ) { /* WindView Instrumentation */ USB_TCD_LOG_EVENT(USB_TCD_PDIUSBD12_INIT_EXIT, "usbTcdPdiusbd12FncDisable exiting: Bad Paramters Received...", USB_TCD_PDIUSBD12_WV_FILTER); USBPDIUSBD12_DEBUG ("usbTcdPdiusbd12FncDisable: Parameter Validation \ is unsuccessful",0,0,0,0,0,0); return ERROR; } /* Extract the target pointer from the handle */ pTarget = (pUSB_TCD_PDIUSBD12_TARGET) pHeader->handle; /* Disable controller */ USBPDIUSBD12_DEBUG ("usbTcdPdiusbd12FncDisable : Disabling the Soft \ Connect...\n",0,0,0,0,0,0); pTarget->configByte &= ~D12_CMD_SM_CFG_SOFTCONNECT; d12SetMode (pTarget); pTarget->goutByte &= ~ENABLE_LED; OUT_EVAL_GOUT (pTarget,pTarget->goutByte); /* WindView Instrumentation */ USB_TCD_LOG_EVENT(USB_TCD_PDIUSBD12_INIT_EXIT, "usbTcdPdiusbd12FncDisable exiting...",USB_TCD_PDIUSBD12_WV_FILTER); USBPDIUSBD12_DEBUG("usbTcdPdiusbd12FncDisable: Exiting \ ...\n",0,0,0,0,0,0); return OK; }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -