Problem with CY7C68013A

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
Anonymous
Not applicable
        Dear all,   
   
   
I need help to solve the follow problem:   
- I have an external harware connected to a PC, and this hardware use the component CY7C68013A. I´ve written a delphi code to get the information from USB, the problem happened when I open and close de software between the seventh and nith time that I do that.   
- To map de dll to Delphi I written the follow code:   
   
   
Thanks,   
   
   
#include "targetver.h"   
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers   
// Windows Header Files:   
#include        
#include          
#include            
      
#define DLLEXPORT extern "C" __declspec(dllexport)      
      
int WINAPI DllEntryPoint(HINSTANCE hinst, unsigned long reason, void* lpReserved)      
{      
if(reason == DLL_PROCESS_ATTACH)      
printf("Carregou DLL\n");      
else if(reason == DLL_PROCESS_DETACH)      
printf("Descarregou DLL\n");      
return 1;      
}      
      
//---------------------------------------------------------------------------      
      
//USBDevice-----------------------------------------------------------------      
CCyUSBDevice* device = NULL;      
      
DLLEXPORT bool USBDevice_new(HANDLE hnd){      
//if (device) {      
// return true;      
//}      
__asm int 3;      
      
device = new CCyUSBDevice(hnd);      
      
if (!device) {      
return false;      
}      
return true;      
}      
      
DLLEXPORT bool USBDevice_Open(UCHAR d){      
return device->Open(d);      
}      
      
DLLEXPORT int USBDevice_DeviceCount(){      
return device->DeviceCount();      
}      
      
DLLEXPORT bool USBDevice_HighSpeed(){      
return device->bHighSpeed;      
}      
      
DLLEXPORT int USBDevice_VendorID(){      
return device->VendorID;      
}      
      
DLLEXPORT int USBDevice_ProductID(){      
return device->ProductID;      
}      
      
DLLEXPORT int USBDevice_EndPointCount(){      
return device->EndPointCount();      
}      
      
DLLEXPORT void USBDevice_Close(){      
device->Close();      
}      
      
DLLEXPORT void USBDevice_ReConnect(){      
device->ReConnect();      
}      
      
      
DLLEXPORT void USBDevice_Reset(){      
device->Reset();      
}      
      
//Endpoint-----------------------------------------------------------------      
long lastLen[4] = {0, 0, 0 ,0};      
      
DLLEXPORT void USBEndPoint_SetTimeout(int ep, int timeout){      
device->EndPoints[ep]->TimeOut = timeout;      
}      
      
DLLEXPORT bool USBEndPoint_XferData(unsigned char *buf, long len, int ep){ // Talvez de pau por causa da referencia...      
bool ret;      
long lenRef = len;      
ret = device->EndPoints[ep]->XferData(buf, lenRef);      
lastLen[ep] = lenRef;      
return ret;      
}      
      
DLLEXPORT int USBEndPoint_LastLen(int ep){      
return lastLen[ep];      
}      
      
DLLEXPORT unsigned char USBEndPoint_Attributes(int ep){      
return device->EndPoints[ep]->Attributes;      
}      
      
DLLEXPORT unsigned char USBEndPoint_Address(int ep){      
return device->EndPoints[ep]->Address;      
}      
      
DLLEXPORT int USBEndPoint_BulkOutEndPtNumber(){      
CCyBulkEndPoint* b = device->BulkOutEndPt;      
for (int i=0; i < device->EndPointCount(); i++) {      
if (b == device->EndPoints       ) {
return i;
}
}
return -1;
}

DLLEXPORT int USBEndPoint_BulkInEndPtNumber(){
CCyBulkEndPoint* b = device->BulkInEndPt;
for (int i=0; i < device->EndPointCount(); i++) {
if (b == device->EndPoints) {
return i;
}
}
return -1;
}
     
    
   
0 Likes
6 Replies
Anonymous
Not applicable
        I forgot to wrote the problem better, but is:   
- When I close de software in the seventh or eighth time, I can´t open the software again, and the Windows stopped to reconize the USB device, I need to unplugged the hardware from the USB.   
- Another problem is, when I restart the PC, and the hardware is freezed and plugged, the BIOS stopped to work.   
   
Thanks,   
0 Likes
Anonymous
Not applicable
        Are you stopping the streaming of data before closing the application?   
0 Likes
Anonymous
Not applicable
        Yes, I'm. I take care to stop the streamming and the aplication close function invoke to USBDevice_Close() API.   
0 Likes
Anonymous
Not applicable
        Are you using abort() to clear the requests that might have been queued??   
0 Likes
Anonymous
Not applicable
        yes, the close() does it. At know I discoverd another thing, folloy:   
- I have two machines, one's that hardware works very well, without problems, and other that it doesn't work. The machines is similar, both has a core 2 duo, 2GB Ram and a motheboard Intel Pearl Creek DG31PR, the same drivers and applications. The only difference is: The machine whose hardware works very well has a BIOS version older than other machine. What can I to solve the problem? Is it possible to force a Hardware Reset and Wake Up per software?   
Thanks   
0 Likes
Anonymous
Not applicable
        That is strange... abort() should be taking care of these things...   
do you by any chance have a CATC to observe what is going on in the bus when this happens?? are you able to send commands to the device using cyconsole or control center after the hang...   
0 Likes