📄 usrusbpegasusendinit.c
字号:
/* usrUsbPegasusEndInit.c - Initialization of the USB END driver *//* Copyright 1999-2001 Wind River Systems, Inc. *//*Modification history--------------------01c,10jun01,wef moved end attach functionality to src/test/usb/usbPegasusTest.c01a,23aug00,wef Created*//*DESCRIPTIONThis configlette initializes the USB END pegasus driver. This assumes theUSB host stack has already been initialized and has a host controllerdriver attached. *//* includes */#include "usb/ossLib.h"#include "usb/usbQueueLib.h"#include "drv/usb/usbPegasusEnd.h"/* defines */#define INCLUDE_PEGASUS_TEST 0#define VX_UNBREAKABLE 0x0002/* externals *//* locals */LOCAL QUEUE_HANDLE pegasusCallbackQueue;LOCAL USB_MESSAGE pegasusDeviceStatus;/***************************************************************************** usbPegasusAttachCallback- TODO** This function initiates transmission on the ethernet.** RETURNS: OK or ERROR*/ VOID usbPegasusAttachCallback ( pVOID arg, /* caller-defined argument */ USB_PEGASUS_DEV * pDev, /* pointer to Pegasus Device */ UINT16 attachCode /* attach code */ ) { usbQueuePut (pegasusCallbackQueue, (UINT16)pDev->nodeId, attachCode, (UINT32)pDev, 5000); }/***************************************************************************** pegasusClientThread- TODO** This function initiates transmission on the ethernet.** RETURNS: OK or ERROR*/ void pegasusClientThread(void) { char * pAddrString; /* enet address */ char * pNetRoute; /* netroute */ int unitNum ; /* unit number */ int netmask=0xffff0000; /* netmask */ static int index; USB_PEGASUS_DEV * pDev; #if INCLUDE_PEGASUS_TEST pNetRoute = "90.0.0.3"; pAddrString = "90.0.0.53"; unitNum = 0;#endif while (1) { usbQueueGet (pegasusCallbackQueue, &pegasusDeviceStatus, OSS_BLOCK); pDev = (USB_PEGASUS_DEV *)pegasusDeviceStatus.lParam; if (pDev->productId == SOHOWARE_PRODUCT_ID && pDev->vendorId == SOHOWARE_VENDOR_ID) { logMsg ("Pegasus Device attched\n", 0, 0, 0, 0, 0, 0); } else { logMsg ("Unsupported Device.\n", 0, 0, 0, 0, 0, 0); continue; } if (pegasusDeviceStatus.wParam == USB_PEGASUS_ATTACH) { logMsg ("Wait...Loading Pegasus Device!\n", 0, 0, 0, 0, 0, 0); if (usbPegasusDevLock ((USBD_NODE_ID)pegasusDeviceStatus.msg) != OK) logMsg ("usbPegasusDevLock() returned ERROR\n", 0, 0, 0, 0, 0, 0); else {#if INCLUDE_PEGASUS_TEST /* * This is where the stack has become aware of the device * being plugged in. Here you may call code to further act * on a device. * The sample code called here can be found in: * target/src/test/usb/usbPegasusTest.c */ if(loadPegasus(unitNum,pDev) == OK) { /* Attach IP address*/ usbPegasusEndStart(unitNum, PEGASUS_IP_ADDRESS, netmask); } #endif } } else if (pegasusDeviceStatus.wParam == USB_PEGASUS_REMOVE) { logMsg (" Wait... Pegasus Device Unload in progress!\n", 0, 0, 0, 0, 0, 0); if (usbPegasusDevUnlock ((USBD_NODE_ID)pegasusDeviceStatus.msg) != OK) logMsg ("usbPegasusDevUnlock() returned ERROR!\n", 0, 0, 0, 0, 0, 0); /* * This is where the stack has become aware of the device * being removed in. Here you may call code to further handle * a device being removed from the system */#if INCLUDE_PEGASUS_TEST if (routeDelete(pNetRoute, pAddrString)!=OK) logMsg (" RouteDeletion failed! \n", 0, 0, 0, 0, 0, 0); if (muxDevUnload("usb",unitNum)!=OK) logMsg (" muxDevUnload failed!\n", 0, 0, 0, 0, 0, 0); logMsg (" Pegasus Device Unloaded sucessfully!!!\n", 0, 0, 0, 0, 0, 0);#endif } } }/******************************************************************************* usrUsbPegasusEndInit - initialize the USB END Pegasus driver** This function initializes the USB END Pegasus driver** RETURNS: Nothing */void usrUsbPegasusEndInit (void) { int taskId; if (usbPegasusEndInit () == OK) logMsg ("usbPegasusEndInit () returned OK\n", 0, 0, 0, 0, 0, 0); else logMsg ("usbPegasusEndInit () returned ERROR\n", 0, 0, 0, 0, 0, 0); if (usbQueueCreate (128, &pegasusCallbackQueue)!=OK) logMsg ("pegasusCallbackQueue creation error\n ", 0, 0, 0, 0, 0, 0); if((taskId = taskSpawn ("tUsbPgs", 5, 0, 20000, (FUNCPTR) pegasusClientThread, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 )) ==ERROR) logMsg (" TaskSpawn Error...!\n", 0, 0, 0, 0, 0, 0); if (usbPegasusDynamicAttachRegister (usbPegasusAttachCallback, NULL) != OK) logMsg ("usbPegasusDynamicAttachRegister() returned ERROR\n", 0, 0, 0, 0, 0, 0); }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -