- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi!
How do I write a program in C for Linux to configure all 21 GPIO pins of the CY7C65215?
I want some to be GPIO inputs and some to be GPIO outputs, and 2 pins will be configured for I2C master.
I successfully wrote a small program to handle the reading and setting of values for the GPIO configured pins. I just need to configure them first according to your documentation that should be possible.
Please don't recommend that Windows demo/example app that was made for experimentation with the evaluation board.
I need to make configuration and programming during mass production in a factory environment without human interaction.
This is very urgent, so please provide source code examples if possible.
Thank you!
Best regards,
Magnus
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Varun,
To clarify, I needed to know how to free the last GPIO in your Windows GUI application for making the correct configuration file with the maximum number of GPIOs.
I figured out why the last GPIO went missing. There is a tab in the Windows GUI that can configure #POWER on pin 31/GPIO_06. Disabling that feature will allow for 17 GPIOs to be configured.
To recap:
- There are not 21 GPIOs as advertised.
- There are 19 GPIOs in total, but only 17 of those can be configured as GPIO simultaneously.
- It is impossible to configure a chip using the API. Instead a configuration file has to be created and decoded in Windows. After that a program can be written for Linux to upload it automatically during production. The decoder and example program has to be downloaded through this forum, since they are not officially provided in the support package.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Mangus,
As per datasheet, you can configure 17 PIN as INPUT/OUTPUT/Tristate using USB
serial configuration utility tool.
after configuring input or output you can read and write to the Pin please check GPIO.c attached with this thread.
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <getopt.h>
#include <string.h>
#include <signal.h>
#include <stdbool.h>
#include <unistd.h>
#include <sys/time.h>
#include <pthread.h>
#include <ctype.h>
#include <stdlib.h>
#include "../../common/header/CyUSBSerial.h"
#define MFG_INTERFACE 2
unsigned int getNumberOfDevices(void)
{
unsigned int num = 255;
CyGetListofDevices(&num);
return num;
} /* This function is used to find Cypress device */
bool isCypressDevice(int deviceNum)
{
CY_HANDLE handle;
unsigned char signature[6];
CY_RETURN_STATUS rStatus;
rStatus = CyOpen (deviceNum, MFG_INTERFACE, &handle);
if (rStatus != CY_SUCCESS)
{
return false;
}
rStatus = CyGetSignature (handle, signature);
if (rStatus == CY_SUCCESS)
{
CyClose (handle);
return 1;
}
else
{
return 0;
}
}
int findCypressDevice()
{
unsigned int num_devices = getNumberOfDevices();
for (unsigned int curdev = 0; curdev < num_devices; curdev++)
{
if (isCypressDevice(curdev))
return curdev;
}
return -1;
}
int main(int argc, char *argv[])
{
CY_HANDLE handle;
unsigned int device;
CY_RETURN_STATUS rStatus;
CY_DEVICE_INFO deviceInfo;
UINT8 value = 0;
UINT8 Gpio_Num = 10;
printf("Infineon USB Serail GPIO Read Toggle Utility\n");
if( argc == 2 )
{
Gpio_Num = atoi(argv[1]);
printf("Selected GPIO %d\n", Gpio_Num);
}
else
{
printf("Only One argument expected, [./CySerailGpio 10] \n");
}
rStatus = CyLibraryInit (); //Initates Cypress Library
if (rStatus != CY_SUCCESS)
{
printf ("CY:Error in Doing library init Error NO:<%d> \n", rStatus);
return rStatus;
}
device = findCypressDevice(); //This function is used to detect Cypress device connected to USB bus.
printf("device : %d\n",device);
if (device < 0)
{
printf ("CY:Error in Find Cypress USB Serail Device Error NO:<%d> \n", rStatus);
return 0;
}
rStatus = CyGetDeviceInfo(device, &deviceInfo); //This API is used to get information(VID,PID) about detected Cypress device.
if (rStatus != CY_SUCCESS)
{
printf ("CY:Error in Get device Info Error NO:<%d> \n", rStatus);
return 0;
}
rStatus = CyOpen(device, MFG_INTERFACE, &handle); //This API is used to open Cypress device (Gets handle of device)
if (rStatus != CY_SUCCESS)
{
printf ("CY:Error in Open Device Error NO:<%d> \n", rStatus);
return 0;
}
rStatus=CyGetGpioValue(handle,Gpio_Num,&value); //This API is used to retrieve value of GPIO1.
if (rStatus == CY_SUCCESS)
{
printf("GPIO Status retrieved %d\n",value);
}
else
{
printf("GPIO Status Read Error\n");
}
if(value == 1)
{
value = 0;
}
else
{
value = 1;
}
rStatus=CySetGpioValue(handle,Gpio_Num,value); //This API is used to set value of GPIO.
if (rStatus == CY_SUCCESS)
{
printf("Value changed to %d\n",value);
}
else
{
printf("Not changed \n");
}
rStatus= CyClose(handle); //This API is used to close the Cypress device.
if (rStatus == CY_SUCCESS)
{
printf("Device closed\n");
}
else
{
printf("Not closed\n");
}
CyLibraryExit (); //This API is used to exit library.
} /* This function is used to get number of connected Cypress Devices */
Thank you
Varun Narolkar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
1. Correct the error on your product page:
2. What are the instructions for configuring 17 GPIO pins using the configuration utility tool?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Mangus ,
Sorry for inconvenience, we reported this and Update ASAP.
This is fixed firmware product, you can configure it using only with USB Seial configuration utility tool .
For application development we released CYSetGPIoValue() and CyGetGPioValue().
Thank you
Varun Narolkar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
.... and here we have 19 GPIOs. What is the correct specification?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Mangas,
in configuration utility you can only disable 1 SCB ,other SCB is muxed with different protocol like UART/I2C/SPI so you have to select minimum 2 pin for that soo only 17 GPIO will Available .
Source code of configuration Utility is confidential for windows , you can use Linux configuration utility for your Debug .
For Linux Configuration Utility follow below thread.
Password: Cypress
Thank you
Varun Narolkar
Thank You
Varun Narolkar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thank you Varun.
So this means that I will be able to configure 17 GPIO and 1 I2C using Linux only?
Best regards,
Magnus
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Mangus ,
not like that you with Windows also you can do, but you need a code for GPIO INPUT/OUTPUT configuration will be available for Linux.
Thank you
Vsarun Narolkar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hmm, it seems that the Linux program in your link could only be used to upload configuration files generated using some Windows app. I that correct?
/Magnus
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Mangus,
As per procedure given in Linux utility tool, you have to copy the encrypted configuration file from windows only.
Thank you
Varun Narolkar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I now connected the evaluation board to a PC with Windows installed in order to create the configuration file. However, only 16 "unused GPIOs" show up in the config tool. Is that the maximum I could get?
/Magnus
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
hi Mungas ,
yes,as per the configuration utility you will get max 16 GPIOs
thank you
Varun Narolkar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Varun,
Will the Linux "hack" for configuring the device work on new chips with default setting?
Regards,
Magnus
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
hi Mangas,
No there is no hack with the utility tool , just you can get the base layer API.
Thanks
varun narolkar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Great!
Please let me know how to upload the configuration file to new chips in production using Linux. Preferably without any user interaction since this will be handled automatically by a computer. This is all I need.
Thanks
Regards,
Magnus
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Mungas ,
In production, you can use Linux utility tool or you can use a windows command line utility for configuration.
please follow the steps given in the below link for windows.
For Linux command line Utility follow steps in given Thread .
Thank you
Varun Narolkar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Varun,
Could you please give me a link to the actual Linux configuration tool? All i can find is the test utility that is used for demonstration.
Regards,
Magnus
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Do you mean the modified demo app?
It does not work.
/Magnus
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Ok, I can use the source for that and modify it to what I need.
So what about the missing GPIO, do you know where it went?
/Magnus
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi mungas,
As we discuss in previous chat configuration tool will only allow to configure free GPIO ,so you can only use 16 GPIO MAX.
Thank you
Varun Narolkar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Varun,
To clarify, I needed to know how to free the last GPIO in your Windows GUI application for making the correct configuration file with the maximum number of GPIOs.
I figured out why the last GPIO went missing. There is a tab in the Windows GUI that can configure #POWER on pin 31/GPIO_06. Disabling that feature will allow for 17 GPIOs to be configured.
To recap:
- There are not 21 GPIOs as advertised.
- There are 19 GPIOs in total, but only 17 of those can be configured as GPIO simultaneously.
- It is impossible to configure a chip using the API. Instead a configuration file has to be created and decoded in Windows. After that a program can be written for Linux to upload it automatically during production. The decoder and example program has to be downloaded through this forum, since they are not officially provided in the support package.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Mungas,
for Production you can use our windows command line utility as discussed ,once you connected to USB poet on single enter you can program the device .
yes considering your point without human intervention you can not programmed the USB serial Bridge controller but you can do it in very minimal effort .
coming to GPIO it is mentioned in Datasheet will support 17 GPIO .
Thank You
Varun Narolkar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
A simplified version of the Linux utility mentioned in this thread.
Same usage but without need for user interaction. Good for production or part of automatic configuration in Linux.
Should only be used with one Cypress USB device connected, since the detected one will be programmed.
I just did some cleanup, but this is still work in progress.
Uploading it in case someone finds it useful.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Mungas,
Thank You for your contribution, let us know if you require any further details.
Thank You
Varun Narolkar