cancel
Showing results for 
Search instead for 
Did you mean: 

USB Low-Full-High Speed Peripherals

New Contributor

I am creating a small application which would communicate with a PSOC LP5 HID and execute small operations like writing and reading to the GPIO port.

I have installed CyUSB Suite for the same and used a sample application CyDesc which would open the device with the Cypres GUID and get the device descriptor.

But the device count is always 0.  I followed the the below link and ensured that theh GUID in CyAPI.h is same as that of the driver. Cypress CyUsb3.sys Device Not visible in C++ but in USB Console

However I still find that the HID device is still not visible.

I tried using the GUID of USB Host 3.0 and HID as visible in the image below yet could not fix the issue. Need help to fix this.

pastedImage_4.png

pastedImage_5.png

The sample code is as below

#include <windows.h>

#include <iostream>

#include "CyAPI.h"

using namespace std;

void main()

{

CCyUSBDevice *USBDevice;

USB_DEVICE_DESCRIPTOR descr;

USBDevice = new CCyUSBDevice(NULL);

int a = USBDevice->DeviceCount();

cout << USBDevice->DeviceCount();

bool b = USBDevice->Open(a);

USBDevice->GetDeviceDescriptor(&descr

}

0 Likes
Reply
1 Solution
Moderator
Moderator

Hello,

HID interface guid needs to be passed as an argument for CCyUSBDevice.

You can obtain this using HID API: HidD_GetHidGuid

Please use the below lines to obtain Interface GUID for HID devices and pass the same in CCyUSBDevice :

GUID myHidGuid;

memset(&myHidGuid, 0, sizeof(GUID));

HidD_GetHidGuid(&myHidGuid);

USBDevice = new CCyUSBDevice(NULL, myHidGuid, true);

You will need to add the "Hidsdi.h" header file and include  Hid.lib in the linker inputs.

Please confirm if this works.

Thanks,

Yatheesh

View solution in original post

0 Likes
Reply
7 Replies
Moderator
Moderator

Hello,

The Cypress CyAPI will work with the devices only bound to cypress driver. Can you please confirm if the device which you are accessing is bound to cypress driver. You can check this in the device manager, properties of the device-> under driver tab.

Best Regards,

Yatheesh

0 Likes
Reply
New Contributor

Hi Yatheesh,

I have a C# application which makes use of CyUSB.dll provided for .Net  applications. This application is able to connect to the HID port. But the same is not possible using CyAPI.h is there any specific reason for it?

Am I doing something wrong with the C++ API?

Regards,

Mayank

0 Likes
Reply
Moderator
Moderator

Hello,

Please make sure the you pass the cypress guid or your specific driver guid in the application ( CCyUSBDevice( ) constructor) which uses CyAPI.lib to recognize the device.

The guid used in the inf and the constructor should match.

Thanks,

Yatheesh 

0 Likes
Reply
New Contributor

Hi,

As mentioned earlier I have tried passing the GUID of the device as mentioned in the images attached  earlier.

I wrote a c# application and that seems to work just fine without altering the GUID, however the CyAPI.lib fails to connect to the device.

//C# Code Works Just Fine

        static void Main(string[] args)

        {

            USBDeviceList usbDevices;

            CyHidDevice myHidDevice;

       

            usbDevices = new USBDeviceList(CyConst.DEVICES_HID);

            myHidDevice = usbDevices[0x04B4, 0xE177] as CyHidDevice;

        }

// C++ - Code to implement the same does not work

void main()

{

CCyUSBDevice *USBDevice;

USB_DEVICE_DESCRIPTOR descr;

static GUID MY_GUID = { 0x745a17a0, 0x74d3, 0x11d0, 0xb6, 0xfe, 0x00, 0xa0, 0xc9, 0x0f, 0x57, 0xda };

USBDevice = new CCyUSBDevice(NULL, MY_GUID, true);

int a = USBDevice->DeviceCount();

int x = USBDevice->EndPointCount();

}

Is there anything that I am doing wrong here ?

0 Likes
Reply
Moderator
Moderator

Hello,

HID interface guid needs to be passed as an argument for CCyUSBDevice.

You can obtain this using HID API: HidD_GetHidGuid

Please use the below lines to obtain Interface GUID for HID devices and pass the same in CCyUSBDevice :

GUID myHidGuid;

memset(&myHidGuid, 0, sizeof(GUID));

HidD_GetHidGuid(&myHidGuid);

USBDevice = new CCyUSBDevice(NULL, myHidGuid, true);

You will need to add the "Hidsdi.h" header file and include  Hid.lib in the linker inputs.

Please confirm if this works.

Thanks,

Yatheesh

View solution in original post

0 Likes
Reply
New Contributor

Hi Yathessh,

It did worked but only partially, like I can see there is some data in CCYUSBDevice like

DevPath = 0x000002345bfa8ac4 "\\\\?\\hid#vid_04b4&pid_e177#6&11e6450d&0&0000#{4d1e55b2-f16f-11cf-88cb-001111000030}"

and device path = 1

So I am actually able to connect to the required device but apart from these data there is no other data present in the CCYUSBDevice Object and device open function also fails.

I do not get ant data apart from the above two fields and Open() command also fails.

//Code Snippet

void main()

{

CCyUSBDevice *USBDevice;

USB_DEVICE_DESCRIPTOR descr;

GUID myHidGuid;

memset(&myHidGuid, 0, sizeof(GUID));

HidD_GetHidGuid(&myHidGuid);

USBDevice = new CCyUSBDevice(NULL, myHidGuid, true);

int deviceCount = USBDevice->DeviceCount();

cout << USBDevice->DeviceCount();

for (int i = 0; i < deviceCount; i++)

{

bool b = USBDevice->Open(i);

USBDevice->GetDeviceDescriptor(&descr);

cout << "bLength \t\t " << descr.bLength << endl;

cout << "bDescriptorType \t " << descr.bDescriptorType << endl;

cout << "bcdUSB \t\t\t " << descr.bcdUSB << endl;

cout << "bDeviceClass \t\t " << descr.bDeviceClass << endl;

cout << "bDeviceSubClass \t " << descr.bDeviceSubClass << endl;

cout << "bDeviceProtocol \t " << descr.bDeviceProtocol << endl;

cout << "bMaxPacketSize0 \t " << descr.bMaxPacketSize0 << endl;

cout << "idVendor \t\t " << descr.idVendor << endl;

cout << "idProduct \t\t " << descr.idProduct << endl;

cout << "bcdDevice \t\t " << descr.bcdDevice << endl;

cout << "iManufacturer \t\t " << descr.iManufacturer << endl;

cout << "iProduct \t\t " << descr.iProduct << endl;

cout << "iSerialNumber \t\t " << descr.iSerialNumber << endl;

cout << "bNumConfigurations \t " << descr.bNumConfigurations << endl;

USBDevice->Close();

}

0 Likes
Reply
Moderator
Moderator

Hello,

The CyAPI.lib is  built only to interact with Cypress devices in vendor class (bound to cypress driver: cyusb3) and not for HID.

You will have to bind the device to cypress driver or use HID specific API to interact with it.

Thanks,

Yatheesh

0 Likes
Reply