Using Python to Interface to CY7C65211A UART with HID DLL

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

cross mob
jocac_4016601
Level 3
Level 3
10 replies posted 10 likes given 5 replies posted

Using Python to Interface to CY7C65211A UART with HID DLL

I need to use Python to program the Cy7C65211A USB Bridge

I will be using UART mode and SPI mode and want to use the HID interface and not the CDC Interface.

In other words: No Virtual Com Port Implementation

Are their any examples of this available?

Do I use this DLL?

C:/Program Files (x86)/Cypress/USB-Serial SDK/library/cyusbserial/x86/cyusbserial.dll

There are sooo many .dll files I need to get this confirmed.

Also, in the API Documentation section 3.2:

3.2 CY_RETURN_STATUS

CY_SUCCESS = 0                       API returned successfully without any errors.

CY_ERROR_ACCESS_DENIED               Access of the API is denied for the application

CY_ERROR_DRIVER_INIT_FAILED          Driver initialisation failed

CY_ERROR_DEVICE_INFO_FETCH_FAILED    Device information fetch failed

CY_ERROR_DRIVER_OPEN_FAILED          Failed to open a device in the library

......

So we know the value if successful but what are the return values for all of the error conditions?

0 Likes
1 Solution

Hi John,

1) CyGetListofDevices returns the number of Devices connected to the vendor driver. In your case its 2 i.e. Vendor 1 and Vendor MFG comes up as two separate devices with 1 interface each, which are bound to the same vendor driver.

About the enums may I know which return values are you referring to?

2) Everything that works on 211 also works on 211A, in addition to certain firmware enhancements in 211A.

You may change the silicon at any point of time since they both have that same functionality.

3) All the 3 data structures mentioned are enums.

     a)  CY_DEVICE_TYPE is an enum which returns the type of the device.

typedef enum _CY_DEVICE_TYPE {

    CY_TYPE_DISABLED = 0,               /*Invalid device type or interface is not CY_CLASS_VENDOR*/

    CY_TYPE_UART,                       /*Interface of device is of type UART*/

    CY_TYPE_SPI,                        /*Interface of device is of type SPI */

    CY_TYPE_I2C,                        /*Interface of device is of type I2C */

    CY_TYPE_JTAG,                       /*Interface of device is of type JTAG*/

    CY_TYPE_MFG                         /*Interface of device is in Manufacturing mode*/

} CY_DEVICE_TYPE;

In case of Vendor mode, the Vendor 1(in device manager)  which is configured as UART returns a device type1(CY_TYPE_UART)  and the vendor MFG returns device type 5. (see Fig 1.)

In case of CDC mode there is only one device type i.e. vendor MFG. that returns device type 5. (see Fig. 2) and the Other interface comes as a serial Adapter and as a COM port.

    b) CY_DEVICE_CLASS is an enum which returns class of a particular device interface.

typedef enum _CY_DEVICE_CLASS{

    CY_CLASS_DISABLED = 0,              /*None or the interface is disabled */

    CY_CLASS_CDC = 0x02,                /*CDC ACM class*/

    CY_CLASS_PHDC = 0x0F,               /*PHDC class */

    CY_CLASS_VENDOR = 0xFF              /*VENDOR specific class*/

} CY_DEVICE_CLASS;

In vendor mode both the device classes are Vendor class. so it returns with 255 (0xFF h)

          c)   CY_DEVICE_SERIAL_BLOCK is an enum which  returns the Serial Block number of a particular device bound to Vendor driver.

typedef enum _CY_DEVICE_SERIAL_BLOCK

{

    SerialBlock_SCB0 = 0,               /*Serial Block Number 0*/

    SerialBlock_SCB1,                   /*Serial Block Number 1*/

    SerialBlock_MFG                     /*Serial Block Manufacturing Interface.*/

} CY_DEVICE_SERIAL_BLOCK;

CY_MAX_DEVICE_INTERFACE

this is the maximum value of configurable interfaces possible.

As in case of CY_DEVICE_TYPE the maximum value that can be returned is 5 i.e. for the Manufacturing mode.

4) the device block is also an enum. It represents the present driver interface instance that is associated with a serial block.

5) Your information is correct. When the device is configured for CDC interface there will be only one vendor interface bounded to the vendor driver  i.e. vendor MFG which returns device type as 5 (from the enum CY_DEVICE_TYPE) and the serial block is 2 (from the enum CY_DEVICE_SERIAL_BLOCK) the other interface comes under the COM port and as a Serial Adapter.( refer Fig 1 and Fig 2)

pastedImage_3.png

                                                          Fig 1.(Vendor protocol)

pastedImage_0.png

                                                  Fig 2.(CDC protocol)

Best Regards

Yatheesh

View solution in original post

0 Likes
11 Replies
YatheeshD_36
Moderator
Moderator
Moderator
750 replies posted 500 replies posted 250 solutions authored

Hi John

CY7C65211A has a fixed firmware which cannot be altered.

It does not support HID interface (supports only CDC and Vendor Defined modes).

The return types are enums so the return value get incremented for every different error message (from top to the bottom, with CY_SUCCESS = 0 , CY_ERROR_ACCESS_DENIED = 1 and so on.)

Best Regards,

Yatheesh Kumar

The API returns I now understand.  I understand that the chip doesn't report in as an HID but instead it reports in with a Cypress Driver. 

Does this driver allow for multiple instances of the hardware and then use an Index to address them?

Also, I am still confused about which DLL to use and how to use it...

One of my problems is that your documentation doesn’t match reality.  The references to directories is not correct.

I installed the driver at the following address:

C:\Program Files (x86)\Cypress\USB-Serial SDK\driver

                                               CypressDriverInstaller.exe

I think the following files apply to me but I do not know what to do with them:

C:\Program Files (x86)\Cypress\USB-Serial SDK\Cypress USB-Serial Driver\DriverBinary\Vendor_Driver\bin\Win10\x86

                                                  cyusb33.cat

cyusb3.inf

cyusb3.sys

WdfCoinstaller01011.dll

Should I have edited the .inf above prior to installation?  Was I supposed to do the driver install from the following directory and if so which file was I supposed to use?

C:\Program Files (x86)\Cypress\USB-Serial SDK\Cypress USB-Serial Driver\DriverBinary\Vendor_Driver\installer

  1. dpinst.exe or dpinst64? (I suspect that dpinst.exe is the correct one)

Where is the .dll I should use and where are the calls defined?  I looked at the API document but things like data sizes are missing in the definitions. Maybe I am looking in the wrong place?

Again, I am trying to use python3 in windows 10.

Hi John

Please find the answers to your queries below:

  1. Creation of multiple instances of the hardware is not allowed.
  2. CY7C65211A does not support HID class.
  3. If u want to use the CDC driver u can find the dll at C:\Program Files (x86)\Cypress\USB-Serial SDK\library\cyusbserial\<Architecture>
  4. You need not worry about the following files

         cyusb3.cat

         cyusb3.inf

         cyusb3.sys

         WdfCoinstaller01011.dll

     The .inf file is not supposed to be altered. If altered, it looses the signature in the catalog and the driver

may not be installed on the host.

5.  Python library and dll is not provided by Cypress to interact with the driver.

Best Regards

Yatheesh Kumar

0 Likes

I do not think you understand my questions.  Based upon your responses:

1. Are you aware that you have the use of a serial number in section 2.2.2 of the USB-Serial Configuration Utility User Guide?  Since there will never be more than 1 of these chips found in any system there is no reason to have a serial number.  It simply has no use.  Will all your customers be advised to put "Not compatible with any other products based on Cypress CY7C65211 chips" on their product packages?

2. I said " I understand that the chip doesn't report in as an HID but instead it reports in with a Cypress Driver. ​".  Your response is "CY7C65211A does not support HID class."  What am I missing here?  You are in disagreement with my statement?

3. I said "I will be using UART mode and SPI mode and want to use the HID interface and not the CDC Interface.

In other words: No Virtual Com Port Implementation".  You responded with "If u want to use the CDC driver u can find the dll at ..."  What am I missing here?  Is it not clear that I do n ot want to use the CDC driver?  Isn't the CDC driver the VCP implementation?  What am I missing here?

4. Section of 3.1 of the USB-Serial Configuration Utility User Guide goes into great detail on how to edit the .inf file.  You should delete this in the document since you aren't supposed to edit the file, per your response.

5. I use ctypes in python to do software for these types of chips.  Since your chip doesn't support any software development why do you have so many dll's and libraries?  Maybe you could search your software and identify all dll's and .lib's and explain what each is used for?  I see that you have 99 .dll files... tell me what each is used for please.

Please have someone else look at this thread.  While I am sure I am confused I do not think you are doing much to help that.  Thanks!

0 Likes

Hello John,

Replying to your questions in order:

- There are scenarios where multiple USB-Serial ICs are being used in a system where serial numbers are of use. Also, there are customers who would prefer to have the same COM port number upon connection to different ports on the same PC which is served by the serial number string. Another advantage of serial number is the identification of devices in the host application through the hardware ID of the device. In the absence of serial number, the host generates a random serial number in the device's hardware ID.

- The IC reports with a Cypress specific vendor driver which is meant for the configuration update and vendor specific implementation of UART, I2C and SPI interfaces. The CYUSB3 driver is a Cypress vendor specific driver and cannot be used for HID class implementation. Kindly, let me know if this clears your query or if you need more detail.

- HID interface cannot be used with the device's firmware. If you can let us know your implementation, we could suggest if that can be implemented over the CDC/Vendor interface of CY7C65211/A.

- Modifying the INF file of the driver would result in loss of signature. Digitally unsigned drivers could be force bound in Windows 8.1 and below. For Windows 10 and above, if the *.cat file signature is lost, the driver binding fails. The driver package should be certified by Microsoft if there are changes made to the INF file.

- The firmware of the CY7C65211/A cannot be modified but the host application to interact with the device can be developed depending on whether it is configured as CDC device or vendor device. The cyusbserial.dll can be used to interact with the vendor driver (CYUSB3.SYS) and the cyusbserialVCP.dll can be used to interact with the virtual COM port driver (CypressUsbConsoleWindowsDriver64.SYS). Please refer to the example host applications that come with the USB-Serial SDK. These examples use the cyusbserial.dll and the cyusbserialVCP.dll files.

Best regards,

Srinath S

0 Likes

I am using the following DLL:

C:/Program Files (x86)/Cypress/USB-Serial SDK/library/cyusbserial/x86/cyusbserial.dll

I am trying to call the CyGetListofDevices from Python3 as shown below:

ret_code = CY7C65211A_CyGetListofDevices(byref(CY7C65211A_numDevices))

Your C++ example is similar.

I get an error from Python that complains about the parameter, CY7C65211A_numDevices, and I have defined it as just about all the cytpes that are 8 bits (1 byte) which should be equivalent to the UINT8 C++ type.

If I call the function without parameters I get a "Success" return code, but no device count (obviously), as shown below:

ret_code = CY7C65211A_CyGetListofDevices()  # Success!

What am I doing wrong?

0 Likes

Skip last question, needed to use CDLL instead of windll.  TY!  Progress is being made, one pot hole at a time!

0 Likes

I am going to use the vendor class drivers for both UART and SPI, working on the UART first...

1. In the Cypress Configuration Tool:

When I select Protocol: Vendor on the SCB TAB I get 2 USB enumerations:

USB-Serial (Single Channel) Vendor 1

USB-Serial (Single Channel) Vendor MFG

PID changes to 0x0004 as expected

When I call CyGetListofDevices it reports back 2

When I call CyGetDeviceInfo Number of interfaces = 1

Which USB enum am I talking to with the DLL when I am in Vendor Protocol?   Should I be using the CDC protocol even thought I am exercising the interface through the Vendor Class driver?  I think it should say that I have 1 physical interface with 2 drivers installed (one for mfg and one for the vendor driver used for the config chosen).  Please explain.

2. I am currently using the 211 chip on the dev kit pcb.  I have purchased the 211A silicon.  Should I switch it?  Is there a point at which I need to switch it?  Will all of this stuff work with the 211A silicon?

3. In the USB Serial API documentation, 3.4 CY_DEVICE_INFO I need some information on the last 3 entries in the data structure.  What are the data types for the following:

CY_DEVICE_TYPE = deviceType[CY_MAX_DEVICE_INTERFACE];

CY_DEVICE_CLASS = deviceClass[CY_MAX_DEVICE_INTERFACE];

CY_DEVICE_SERIAL_BLOCK = deviceBlock

Is the device type and device class really an array?  If so, what does CY_MAX_DEVICE_INTERFACE equal? I see =5 in some of your code but the maximum number of devices allowed isn’t 5 is it?  Please explain

4. Is the deviceBlock also an array?

5. When I config the device for the UART CDC interface I think it is telling me that the chip is in device type 5 (mfg mode) and device serial block is 2 (manufacturing mode).  Can you explain why this is?  I am guessing the data structure so my information could be wrong.

Thanks for the guidance!

0 Likes

Hi John,

1) CyGetListofDevices returns the number of Devices connected to the vendor driver. In your case its 2 i.e. Vendor 1 and Vendor MFG comes up as two separate devices with 1 interface each, which are bound to the same vendor driver.

About the enums may I know which return values are you referring to?

2) Everything that works on 211 also works on 211A, in addition to certain firmware enhancements in 211A.

You may change the silicon at any point of time since they both have that same functionality.

3) All the 3 data structures mentioned are enums.

     a)  CY_DEVICE_TYPE is an enum which returns the type of the device.

typedef enum _CY_DEVICE_TYPE {

    CY_TYPE_DISABLED = 0,               /*Invalid device type or interface is not CY_CLASS_VENDOR*/

    CY_TYPE_UART,                       /*Interface of device is of type UART*/

    CY_TYPE_SPI,                        /*Interface of device is of type SPI */

    CY_TYPE_I2C,                        /*Interface of device is of type I2C */

    CY_TYPE_JTAG,                       /*Interface of device is of type JTAG*/

    CY_TYPE_MFG                         /*Interface of device is in Manufacturing mode*/

} CY_DEVICE_TYPE;

In case of Vendor mode, the Vendor 1(in device manager)  which is configured as UART returns a device type1(CY_TYPE_UART)  and the vendor MFG returns device type 5. (see Fig 1.)

In case of CDC mode there is only one device type i.e. vendor MFG. that returns device type 5. (see Fig. 2) and the Other interface comes as a serial Adapter and as a COM port.

    b) CY_DEVICE_CLASS is an enum which returns class of a particular device interface.

typedef enum _CY_DEVICE_CLASS{

    CY_CLASS_DISABLED = 0,              /*None or the interface is disabled */

    CY_CLASS_CDC = 0x02,                /*CDC ACM class*/

    CY_CLASS_PHDC = 0x0F,               /*PHDC class */

    CY_CLASS_VENDOR = 0xFF              /*VENDOR specific class*/

} CY_DEVICE_CLASS;

In vendor mode both the device classes are Vendor class. so it returns with 255 (0xFF h)

          c)   CY_DEVICE_SERIAL_BLOCK is an enum which  returns the Serial Block number of a particular device bound to Vendor driver.

typedef enum _CY_DEVICE_SERIAL_BLOCK

{

    SerialBlock_SCB0 = 0,               /*Serial Block Number 0*/

    SerialBlock_SCB1,                   /*Serial Block Number 1*/

    SerialBlock_MFG                     /*Serial Block Manufacturing Interface.*/

} CY_DEVICE_SERIAL_BLOCK;

CY_MAX_DEVICE_INTERFACE

this is the maximum value of configurable interfaces possible.

As in case of CY_DEVICE_TYPE the maximum value that can be returned is 5 i.e. for the Manufacturing mode.

4) the device block is also an enum. It represents the present driver interface instance that is associated with a serial block.

5) Your information is correct. When the device is configured for CDC interface there will be only one vendor interface bounded to the vendor driver  i.e. vendor MFG which returns device type as 5 (from the enum CY_DEVICE_TYPE) and the serial block is 2 (from the enum CY_DEVICE_SERIAL_BLOCK) the other interface comes under the COM port and as a Serial Adapter.( refer Fig 1 and Fig 2)

pastedImage_3.png

                                                          Fig 1.(Vendor protocol)

pastedImage_0.png

                                                  Fig 2.(CDC protocol)

Best Regards

Yatheesh

0 Likes

You do not understand the questions.  Here are the correct answers:

First answer:

DeviceType is an array of 5 32 bit unsigned integers

DeviceClass is an array of 5 32 bit unsigned integers

DeviceSerialBlock is an array of 45687 double precision floating point numbers

Please confirm that this is the correct answer. (hint: the last one is wrong but there is no way for me to confirm the correct answer)

Next answer:

We here at cypress like to make things confusing.  When you order 10 211A devices we only ship 5.  This is because each chip is 2 devices.  There is only 1 interface for the single chip 2 devices.  If you want 10 chips order 10 211A interfaces, you will receive 20 devices. 

Please confirm this is true.

When I got my dev kit I thought there was one 211 device on the board.  I thought that that device, in vendor mode, reported in as 2 software interfaces, vendor 1 and vendor mfg.  I use type def enum .english::\;{}

Question: DeviceClass only has 4 values.  I could have done that in 2 bits.  Why did you use 5 32 bit unsigned integers to return this value?  I have also determined that you do not properly initiallize the other 4 unused 32 bit unsigned integers as type def enum CY_CLASS_DISABLED.  Why not?

Question: DEVICE_TYPE only has 6 values.  I could have done that in 3 bits.  Why did you use 5 32 bit unsigned integers to return this value?  I have also determined that you do not properly initiallize the other 4 unused 32 bit unsigned integers as type def enum CY_TYPE_DISABLED

Thanks for the help

0 Likes

The correct information:

Cypress will not tell you what the sizes of data items are to interface to their API.  The API is generated using constants so that you can guess for hours and hours at the data types.  Of course, in a list of data items there is no effective way to determine the data type of the last data item.

This is the correct answer.

0 Likes