📄 usbhaldevicecontrolstatus.c
字号:
/* usbHalDeviceControlStatus.c - HAL Device Control and Status handler module *//* Copyright 2004 Wind River Systems, Inc. *//*Modification history--------------------01d,17sep04,ami WindView Instrumentation Changes01c,03aug04,mta Modification History Changes01b,19jul04,ami Coding Convention Changes01a,08mar04,mta First.*//*DESCRIPTIONThis file contains device control and status handler routines of theHardware Adaption Layer.INCLUDE FILES: usb/target/usbHalLib.h usb/target/usbHal.h usb/target/usbHalDebug.h, usb/target/usbPeriphInstr.h*//* includes */#include "usb/target/usbHalLib.h" #include "usb/target/usbHal.h" #include "usb/target/usbHalDebug.h"#include "usb/target/usbPeriphInstr.h" /********************************************************************************* usbHalTcdAddressSet - hal interface to set address.** This function sets an address on the target controller.** RETURNS: OK, if address set successfully; ERROR otherwise.** ERRNO:* None.*/STATUS usbHalTcdAddressSet ( pUSBHAL_TCD_NEXUS pNexus, /* TCD_NEXUS structure member */ UINT8 deviceAddress /* Address of the device to set */ ) { TRB_ADDRESS_SET trbAddressSet; /* TRB_ADDRESS_SET */ STATUS status = OK; pUSBHAL_TCD pHalTcd = NULL; /* USBHAL_TCD */ /* WindView Instrumentation */ USB_HAL_LOG_EVENT(USB_HAL_DEVICE_CNTL, "usbHalTcdAddressSet entered ...", USB_HAL_WV_FILTER); USBHAL_DEBUG("usbHalTcdAddressSet - Entering\n",0,0,0,0,0,0); /* Check the validity of the parameters */ if ((pNexus == NULL) || (pNexus->handle == NULL)) { /* WindView Instrumentation */ USB_HAL_LOG_EVENT(USB_HAL_DEVICE_CNTL, "usbHalTcdAddressSet exiting: Bad Parameter Received...", USB_HAL_WV_FILTER); USBHAL_ERR("usbHalTcdAddressSet : Invalid parameters\n",0,0,0,0,0,0); return ERROR; } /* Retrieve the hal data structure */ pHalTcd = (pUSBHAL_TCD)(pNexus->handle); /* Populate the TRB - start */ trbHeaderInit((pTRB_HEADER)(&trbAddressSet), pHalTcd->pTCDHandle, TCD_FNC_ADDRESS_SET, sizeof(TRB_ADDRESS_SET)); trbAddressSet.deviceAddress = deviceAddress; /* Populate the TRB - end */ /* call the TCD's SEP to set the address*/ status = (*pNexus->tcdExecFunc)(&trbAddressSet); if (status == ERROR) USBHAL_ERR("usbHalTcdAddressSet : Error in setting address\n", 0,0,0,0,0,0); /* WindView Instrumentation */ USB_HAL_LOG_EVENT(USB_HAL_DEVICE_CNTL, "usbHalTcdAddressSet exiting...", USB_HAL_WV_FILTER); USBHAL_DEBUG("usbHalTcdAddressSet - Exiting\n",0,0,0,0,0,0); return status; }/********************************************************************************* usbHalTcdSignalResume - hal interface to initiate resume signal.** This function initiates resume signalling on the bus.** RETURNS: OK if resume signalling is initiated successfully, ERROR otherwise.** ERRNO:* None.*/STATUS usbHalTcdSignalResume ( pUSBHAL_TCD_NEXUS pNexus /* USBHAL_TCD_NEXUS */ ) { TRB_SIGNAL_RESUME trbSignalResume; /* TRB_SIGNAL_RESUME */ STATUS status = OK; pUSBHAL_TCD pHalTcd = NULL; /* USBHAL_TCD */ /* WindView Instrumentation */ USB_HAL_LOG_EVENT(USB_HAL_DEVICE_CNTL, "usbHalTcdSignalResume entered ...", USB_HAL_WV_FILTER); USBHAL_DEBUG("usbHalTcdSignalResume - Entering\n",0,0,0,0,0,0); /* Check the validity of the parameters */ if ((pNexus == NULL) || (pNexus->handle == NULL)) { /* WindView Instrumentation */ USB_HAL_LOG_EVENT(USB_HAL_DEVICE_CNTL, "usbHalTcdSignalResume exiting: Bad Parameter Received...", USB_HAL_WV_FILTER); USBHAL_ERR("usbHalTcdSignalResume : Invalid parameters\n",0,0,0,0,0,0); return ERROR; } /* Retrieve the hal data structure */ pHalTcd = (pUSBHAL_TCD)(pNexus->handle); /* Populate the TRB - start */ trbHeaderInit((pTRB_HEADER)(&trbSignalResume), pHalTcd->pTCDHandle, TCD_FNC_SIGNAL_RESUME, sizeof(TRB_SIGNAL_RESUME)); /* Populate the TRB - end */ /* call the TCD's SEP to initiate resume signalling */ status = (*pNexus->tcdExecFunc)(&trbSignalResume); if (status == ERROR) USBHAL_ERR("usbHalTcdSignalResume: Error in initiating signal resume\n", 0,0,0,0,0,0); /* WindView Instrumentation */ USB_HAL_LOG_EVENT(USB_HAL_DEVICE_CNTL, "usbHalTcdSignalResume exiting...", USB_HAL_WV_FILTER); USBHAL_DEBUG("usbHalTcdSignalResume - Exiting\n",0,0,0,0,0,0); return status; }/********************************************************************************* usbHalTcdDeviceFeatureSet - hal interface to set feature on the device.** This function sets a feature on the target controller** RETURNS: OK if feature set successfully, ERROR otherwise.** ERRNO:* None.*/STATUS usbHalTcdDeviceFeatureSet ( pUSBHAL_TCD_NEXUS pNexus, /* USBHAL_TCD_NEXUS */ UINT16 uFeatureSelector, /* Feature to set */ UINT8 uTestSelector /* Test Mode arguments */ ) { TRB_DEVICE_FEATURE_SET_CLEAR trbDeviceFeatureSet; /* TRB_DEVICE_FEATURE_SET_CLEAR */ STATUS status = OK; pUSBHAL_TCD pHalTcd = NULL; /* USBHAL_TCD */ /* WindView Instrumentation */ USB_HAL_LOG_EVENT (USB_HAL_DEVICE_CNTL, "usbHalTcdDeviceFeatureSet entered ...", USB_HAL_WV_FILTER); USBHAL_DEBUG("usbHalTcdDeviceFeatureSet - Entering\n",0,0,0,0,0,0); /* Check the validity of the parameters */ if ((pNexus == NULL) || (pNexus->handle == NULL)) { /* WindView Instrumentation */ USB_HAL_LOG_EVENT(USB_HAL_DEVICE_CNTL, "usbHalTcdDeviceFeatureSet exiting: Bad Parameter Received...", USB_HAL_WV_FILTER); USBHAL_ERR("usbHalTcdDeviceFeatureSet : Invalid parameters\n", 0,0,0,0,0,0); return ERROR; } /* Retrieve the hal data structure */ pHalTcd = (pUSBHAL_TCD)(pNexus->handle); /* Populate the TRB - start */ trbHeaderInit((pTRB_HEADER)(&trbDeviceFeatureSet), pHalTcd->pTCDHandle, TCD_FNC_DEVICE_FEATURE_SET, sizeof(TRB_DEVICE_FEATURE_SET_CLEAR)); trbDeviceFeatureSet.uFeatureSelector = uFeatureSelector; trbDeviceFeatureSet.uTestSelector = uTestSelector; /* Populate the TRB - end */ /* call the TCD's SEP to set the feature on device */ status = (*pNexus->tcdExecFunc)(&trbDeviceFeatureSet); if (status == ERROR) USBHAL_ERR("usbHalTcdDeviceFeatureSet : Error in setting feature\n", 0,0,0,0,0,0); /* WindView Instrumentation */ USB_HAL_LOG_EVENT(USB_HAL_DEVICE_CNTL, "usbHalTcdDeviceFeatureSet exiting...", USB_HAL_WV_FILTER); USBHAL_DEBUG("usbHalTcdDeviceFeatureSet - Exiting\n",0,0,0,0,0,0); return status; }/********************************************************************************* usbHalTcdDeviceFeatureClear - hal interface to clear feature on device.** This function clears a feature on the target controller.** RETURNS: OK if feature cleared successfully, ERROR otherwise.** ERRNO:* none.*/STATUS usbHalTcdDeviceFeatureClear ( pUSBHAL_TCD_NEXUS pNexus, /* USBHAL_TCD_NEXUS */ UINT16 uFeatureSelector /* Feature to be cleared */ ) { TRB_DEVICE_FEATURE_SET_CLEAR trbDeviceFeatureClear; /* TRB_DEVICE_FEATURE_SET_CLEAR */ STATUS status = OK; pUSBHAL_TCD pHalTcd = NULL; /* USBHAL_TCD */ /* WindView Instrumentation */ USB_HAL_LOG_EVENT(USB_HAL_DEVICE_CNTL, "usbHalTcdDeviceFeatureClear entered ...", USB_HAL_WV_FILTER); USBHAL_DEBUG("usbHalTcdDeviceFeatureClear - Entering\n",0,0,0,0,0,0); /* Check the validity of the parameters */ if ((pNexus == NULL) || (pNexus->handle == NULL)) { /* WindView Instrumentation */ USB_HAL_LOG_EVENT(USB_HAL_DEVICE_CNTL, "usbHalTcdDeviceFeatureClear exiting: Bad Parameter Received...", USB_HAL_WV_FILTER); USBHAL_ERR("usbHalTcdDeviceFeatureClear : Invalid parameters\n", 0,0,0,0,0,0); return ERROR; } /* Retrieve the hal data structure */ pHalTcd = (pUSBHAL_TCD)(pNexus->handle); /* Populate the TRB - start */ trbHeaderInit((pTRB_HEADER)(&trbDeviceFeatureClear), pHalTcd->pTCDHandle, TCD_FNC_DEVICE_FEATURE_CLEAR, sizeof(TRB_DEVICE_FEATURE_SET_CLEAR)); trbDeviceFeatureClear.uFeatureSelector = uFeatureSelector; /* Populate the TRB - end */ /* call the TCD's SEP to clear the feature on device*/ status = (*pNexus->tcdExecFunc)(&trbDeviceFeatureClear); if (status == ERROR) USBHAL_ERR("usbHalTcdDeviceFeatureClear : Error in clearing feature\n", 0,0,0,0,0,0); /* WindView Instrumentation */ USB_HAL_LOG_EVENT(USB_HAL_DEVICE_CNTL, "usbHalTcdDeviceFeatureClear exiting...", USB_HAL_WV_FILTER); USBHAL_DEBUG("usbHalTcdDeviceFeatureClear - Exiting\n",0,0,0,0,0,0); return status; }/********************************************************************************* usbHalTcdCurrentFrameGet - hal interface to get Currrent Frame Number.** This function gets the current frame number.** RETURNS: OK if frame number is retrieved successfully, ERROR otherwise.** ERRNO:* None.*/STATUS usbHalTcdCurrentFrameGet ( pUSBHAL_TCD_NEXUS pNexus, /* USBHAL_TCD_NEXUS */ pUINT16 pFrameNo /* Frame number */ ) { TRB_CURRENT_FRAME_GET trbCurrentFrameGet; /* TRB_CURRENT_FRAME_GET */ STATUS status = OK; pUSBHAL_TCD pHalTcd = NULL; /* USBHAL_TCD */ /* WindView Instrumentation */ USB_HAL_LOG_EVENT(USB_HAL_DEVICE_CNTL, "usbHalTcdCurrentFrameGet entered ...", USB_HAL_WV_FILTER); USBHAL_DEBUG("usbHalTcdCurrentFrameGet - Entering\n",0,0,0,0,0,0); /* Check the validity of the parameters */ if ((pNexus == NULL) || (pNexus->handle == NULL) ||(pFrameNo == NULL)) { /* WindView Instrumentation */ USB_HAL_LOG_EVENT(USB_HAL_DEVICE_CNTL, "usbHalTcdCurrentFrameGet exiting: Bad Parameter Received...", USB_HAL_WV_FILTER); USBHAL_ERR("usbHalTcdCurrentFrameGet:Invalid parameters\n",0,0,0,0,0,0); return ERROR; } /* Retrieve the hal data structure */ pHalTcd = (pUSBHAL_TCD)(pNexus->handle); /* Populate the TRB - start */ trbHeaderInit((pTRB_HEADER)(&trbCurrentFrameGet), pHalTcd->pTCDHandle, TCD_FNC_CURRENT_FRAME_GET, sizeof(TRB_CURRENT_FRAME_GET)); /* Populate the TRB - end */ /* call the TCD's SEP to get the current frame number*/ status = (*pNexus->tcdExecFunc)(&trbCurrentFrameGet); if (status == ERROR) { USBHAL_ERR("usbHalTcdCurrentFrameGet : Error in clearing feature\n", 0,0,0,0,0,0); return ERROR; } /* update the frame number */ *pFrameNo = trbCurrentFrameGet.frameNo; /* WindView Instrumentation */ USB_HAL_LOG_EVENT(USB_HAL_DEVICE_CNTL, "usbHalTcdCurrentFrameGet exiting...", USB_HAL_WV_FILTER); USBHAL_DEBUG("usbHalTcdCurrentFrameGet - Exiting\n",0,0,0,0,0,0); return OK; }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -