Cypress Perform

Home > Design Support > Cypress Developer CommunityTM > Cypress Forums > USB Controllers > Problem with CY7C68013A

Bookmark and Share
Cypress Developer CommunityTM
Forums | Videos | Blogs | Training | Rewards Program | Community Components



Problem with CY7C68013A
Moderator:
RSKV

Post Reply
Follow this topic



Problem with CY7C68013A

ricardodovalle posted on 16 Nov 2009 9:00 AM PST
Member
5 Forum Posts
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;
}


Re: Problem with CY7C68013A

ricardodovalle posted on 16 Nov 2009 09:13 AM PST
Member
5 Forum Posts
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,

Re: Problem with CY7C68013A

aasi posted on 18 Nov 2009 05:21 PM PST
Cypress Employee
1090 Forum Posts
Are you stopping the streaming of data before closing the application?

Re: Problem with CY7C68013A

ricardodovalle posted on 01 Dec 2009 06:47 AM PST
Member
5 Forum Posts
Yes, I'm. I take care to stop the streamming and the aplication close function invoke to USBDevice_Close() API.

Re: Problem with CY7C68013A

aasi posted on 01 Dec 2009 08:57 PM PST
Cypress Employee
1090 Forum Posts
Are you using abort() to clear the requests that might have been queued??

Re: Problem with CY7C68013A

ricardodovalle posted on 08 Dec 2009 10:44 AM PST
Member
5 Forum Posts
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

Re: Problem with CY7C68013A

aasi posted on 11 Dec 2009 02:45 AM PST
Cypress Employee
1090 Forum Posts
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...




ALL CONTENT AND MATERIALS ON THIS SITE ARE PROVIDED "AS IS". CYPRESS SEMICONDUCTOR AND ITS RESPECTIVE SUPPLIERS MAKE NO REPRESENTATIONS ABOUT THE SUITABILITY OF THESE MATERIALS FOR ANY PURPOSE AND DISCLAIM ALL WARRANTIES AND CONDITIONS WITH REGARD TO THESE MATERIALS, INCLUDING BUT NOT LIMITED TO, ALL IMPLIED WARRANTIES AND CONDITIONS OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT OF ANY THIRD PARTY INTELLECTUAL PROPERTY RIGHT. NO LICENSE, EITHER EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, IS GRANTED BY CYPRESS SEMICONDUCTOR. USE OF THE INFORMATION ON THIS SITE MAY REQUIRE A LICENSE FROM A THIRD PARTY, OR A LICENSE FROM CYPRESS SEMICONDUCTOR.

Content on this site may contain or be subject to specific guidelines or limitations on use. All postings and use of the content on this site are subject to the Terms and Conditions of the site; third parties using this content agree to abide by any limitations or guidelines and to comply with the Terms and Conditions of this site. Cypress Semiconductor and its suppliers reserve the right to make corrections, deletions, modifications, enhancements, improvements and other changes to the content and materials, its products, programs and services at any time or to move or discontinue any content, products, programs, or services without notice.

Spec No: None; Sunset Owner: KXP; Secondary Owner: VWA; Sunset Date: 01/01/20