Docs and fix on the cy-config util
This commit is contained in:
BIN
cy-config.o
Normal file
BIN
cy-config.o
Normal file
Binary file not shown.
@@ -69,24 +69,50 @@ After the installation of TinI/O, you actually don't need to do anything at all
|
||||
|
||||
## 3.1 Flashing the chips
|
||||
|
||||
|
||||
Cypress CY7C65211 can be flashed only from Windows with a dedicated Cypress utility due to its unique flash file format. Fortunately, after some bargaining with Cypress I got a Linux utility that is licensed under LGPL and free (as speech _and_ beer). It can flash special, decoded versions of flash files that can be produced with a special Windows decoder executable that I can't provide with TinI/O because it's not GPL'd (actually it's not even licensed!) and isn't released to the public (yet). Instead the TinI/O package includes 2 already decoded flash files that should satisfy the needs of a typical user. Their names are:
|
||||
|
||||
- `5-5_decoded.cyusbd`, that provides 5 input and 5 output ports
|
||||
- `3-3cs_decoded.cyusbd`, that provides 3 input and 3 output ports, plus a CapSense button with its dedicated input.
|
||||
|
||||
And they provide the following configurations:
|
||||
| _parameter_ | _value in `5-5_decoded.cyusbd`_ | _value in `3-3cs_decoded.cyusbd`_ |
|
||||
|-------------|---------------------------------|-----------------------------------|
|
||||
|
||||
| parameter | value in `5-5_decoded.cyusbd` | value in `3-3cs_decoded.cyusbd` |
|
||||
|----|----|----|
|
||||
| **USB** | | |
|
||||
| Max. current drawn from USB | 350 mA | 350 mA |
|
||||
| USB device class | PHDC | PHDC |
|
||||
| I/O logic level | LVTTL | LVTTL |
|
||||
| USB Vendor ID | 0x04b4 (Cypress) | 0x04b4 (Cypress) |
|
||||
| USB Product ID | 0x0002 | 0x0002 |
|
||||
| USB ID (vid:pid) | 0x04b4:0004 (Cypress) | 0x04b4:0004 (Cypress) |
|
||||
| Manufacturer string | TinI/O | TinI/O |
|
||||
| Product string | 5/5 | 3/3CS |
|
||||
| UART Tx pin | 5 | 5 |
|
||||
| **Serial** | | |
|
||||
| UART Tx/Rx pins | 5(Tx)/6(Rx) | 5/6 |
|
||||
| UART Speed | 9600 baud | 9600 baud |
|
||||
| UART Data/Stop bits | 8/1 | 8/1 |
|
||||
| UART Parity | None | None |
|
||||
| **I/O** | | |
|
||||
| I/O logic level | LVTTL | LVTTL |
|
||||
| Pin 0 | Input | **RESERVED for CapSense** Should be decoupled to ground by a 2n2 capacitor |
|
||||
| Pin 1 | Input | Input |
|
||||
| Pin 2 | Input | **RESERVED for CapSense** CapSense sense (connect to your button) |
|
||||
| Pin 3 | Input | **RESERVED for CapSense** CapSense output (the output of your button) |
|
||||
| Pin 4 | Input | Input |
|
||||
| Pin 5 | **RESERVED** UART Tx | UART Tx |
|
||||
| Pin 6 | **RESERVED** UART Rx | UART Rx |
|
||||
| Pin 7 | Output | Input |
|
||||
| Pin 8 | Output | Output |
|
||||
| Pin 9 | Output | Output |
|
||||
| Pin 10 | Output | Output |
|
||||
| Pin 11 | Output | Input |
|
||||
_Note: Not all of the information here is neccesary to know when using TinI/O.
|
||||
For a stripped-down version refer to the next chapter, "Using TinI/O"_
|
||||
|
||||
Please notice that flashing of these files isn't the only way of configuring chips. They can be also customized with the Windows utility. The important thing is that you should
|
||||
configure the USB settings as described in the table above.
|
||||
|
||||
## 3.3 Flashing with the `cy-config` utility
|
||||
The flash files I covered in the previous chapter can be flashed with the `cy-config` utility that installs with TinI/O. The utility is text-based. It can be used by running `cy-config`.
|
||||
|
||||
Upon execution,
|
||||
[chip]: http://www.cypress.com/part/cy7c65211-24ltxi
|
||||
[cylib]: http://github.com/cyrozap/libcyusbserial
|
||||
|
||||
@@ -4,10 +4,10 @@ default: tinio utils
|
||||
|
||||
tinio:
|
||||
echo "Building tinio..."
|
||||
$(CC) -lcyusbserial main.cpp -o tinio
|
||||
$(CC) -lcyusbserial tinio.cpp -o tinio
|
||||
|
||||
utils:
|
||||
$(CC) -lcyusbserial Command_Utility.c -o cy-config
|
||||
$(CC) -lcyusbserial cy-config.c -o cy-config
|
||||
|
||||
install:
|
||||
echo "Installing tinio and flasher"
|
||||
@@ -16,3 +16,4 @@ install:
|
||||
mkdir /usr/share/tinio
|
||||
mkdir /usr/share/tinio/flashes
|
||||
cp flashes/* /usr/share/tinio/flashes
|
||||
|
||||
|
||||
Binary file not shown.
@@ -1,4 +0,0 @@
|
||||
/root/projekti/CyUSB/tinio/main.cpp:6:43: fatal error: /usr/local/lib/libcyusbserial.h: Datoteka ali imenik s tem imenom ne obstaja
|
||||
#include "/usr/local/lib/libcyusbserial.h"
|
||||
^
|
||||
compilation terminated.
|
||||
@@ -1,53 +0,0 @@
|
||||
//Tinio - the Tiny I/O tool
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <CyUSBCommon.h>
|
||||
#include <CyUSBSerial.h>
|
||||
|
||||
|
||||
//----ACTUAL CODE BELOW
|
||||
int verifyArgNum(int num) //verifies the number of arguments. minimum is 2
|
||||
{
|
||||
if (num < 2)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
int initLib() //initializes the cypress library
|
||||
{
|
||||
if (CyLibraryInit() != CY_SUCCESS) //if the init procedure fails
|
||||
{ //the library may be running.
|
||||
if (CyLibraryExit() != CY_SUCCESS) //try to close the possibly running library
|
||||
{
|
||||
return 1; //if even that fails, abort.
|
||||
}
|
||||
initLib(); //if the library closed gracefully
|
||||
//try to reinitialize
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void usage()
|
||||
{
|
||||
puts("Tinio test build 1");
|
||||
puts("Usage:");
|
||||
//----TODO----//
|
||||
//add a command that prints a
|
||||
//usage summary.
|
||||
}
|
||||
|
||||
int locateDevice() //locate the device and verify it's the right one
|
||||
{
|
||||
;
|
||||
}
|
||||
|
||||
int main(int argc, char const *argv[]) {
|
||||
if (!(verifyArgNum(argc)))
|
||||
{
|
||||
usage();
|
||||
}
|
||||
initLib();
|
||||
}
|
||||
Binary file not shown.
Binary file not shown.
BIN
tinio/cy-config
Executable file
BIN
tinio/cy-config
Executable file
Binary file not shown.
@@ -30,8 +30,8 @@
|
||||
#include <pthread.h>
|
||||
#include <ctype.h>
|
||||
|
||||
#include "../../common/header/CyUSBSerial.h"
|
||||
#include "../../common/header/CyUSBBootloader.h"
|
||||
#include "include/CyUSBSerial.h"
|
||||
#include "include/CyUSBBootloader.h"
|
||||
|
||||
#define CY_MAX_DEVICES 30
|
||||
#define CY_MAX_INTERFACES 4
|
||||
@@ -54,6 +54,105 @@ unsigned short pageAddress = -1;
|
||||
short readWriteLength = -1;
|
||||
bool deviceAddedRemoved = false;
|
||||
unsigned char read_buffer[512];
|
||||
|
||||
void printListOfDevices (bool isPrint)
|
||||
{
|
||||
int index_i = 0, index_j = 0, i, j, countOfDevice = 0, devNum;
|
||||
int length, index = 0, numInterfaces, interfaceNum;
|
||||
bool set1 = false;
|
||||
|
||||
unsigned char deviceID[CY_MAX_DEVICES];
|
||||
char functionality[64];
|
||||
CY_DEVICE_INFO deviceInfo;
|
||||
CY_DEVICE_CLASS deviceClass[CY_MAX_INTERFACES];
|
||||
CY_DEVICE_TYPE deviceType[CY_MAX_INTERFACES];
|
||||
CY_RETURN_STATUS rStatus;
|
||||
|
||||
deviceAddedRemoved = false;
|
||||
CyGetListofDevices ((UINT8 *)&numDevices);
|
||||
//printf ("The number of devices is %d \n", numDevices);
|
||||
for (i = 0; i < numDevices; i++){
|
||||
for (j = 0; j< CY_MAX_INTERFACES; j++)
|
||||
glDevice[i].interfaceFunctionality[j] = -1;
|
||||
}
|
||||
if (isPrint){
|
||||
printf ("\n\n---------------------------------------------------------------------------------\n");
|
||||
printf ("Device Number | VID | PID | INTERFACE NUMBER | FUNCTIONALITY \n");
|
||||
printf ("---------------------------------------------------------------------------------\n");
|
||||
}
|
||||
cyDevices = 0;
|
||||
for (devNum = 0; devNum < numDevices; devNum++){
|
||||
rStatus = CyGetDeviceInfo (devNum, &deviceInfo);
|
||||
interfaceNum = 0;
|
||||
if (!rStatus)
|
||||
{
|
||||
//if (isCypressDevice (devNum)){
|
||||
// continue;
|
||||
//}
|
||||
strcpy (functionality, "NA");
|
||||
numInterfaces = deviceInfo.numInterfaces;
|
||||
glDevice[index].numInterface = numInterfaces;
|
||||
cyDevices++;
|
||||
|
||||
while (numInterfaces){
|
||||
if (deviceInfo.deviceClass[interfaceNum] == CY_CLASS_VENDOR)
|
||||
{
|
||||
glDevice[index].deviceNumber = devNum;
|
||||
switch (deviceInfo.deviceType[interfaceNum]){
|
||||
case CY_TYPE_I2C:
|
||||
glDevice[index].interfaceFunctionality[interfaceNum] = CY_TYPE_I2C;
|
||||
strcpy (functionality, "VENDOR_I2C");
|
||||
glDevice[index].isI2c = true;
|
||||
break;
|
||||
case CY_TYPE_SPI:
|
||||
glDevice[index].interfaceFunctionality[interfaceNum] = CY_TYPE_SPI;
|
||||
strcpy (functionality, "VENDOR_SPI");
|
||||
glDevice[index].isSpi = true;
|
||||
break;
|
||||
default:
|
||||
strcpy (functionality, "NA");
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if (deviceInfo.deviceClass[interfaceNum] == CY_CLASS_CDC){
|
||||
strcpy (functionality, "NA");
|
||||
}
|
||||
if (isPrint) {
|
||||
printf ("%d |%x |%x | %d | %s\n", \
|
||||
index, \
|
||||
deviceInfo.vidPid.vid, \
|
||||
deviceInfo.vidPid.pid, \
|
||||
interfaceNum, \
|
||||
functionality \
|
||||
);
|
||||
}
|
||||
interfaceNum++;
|
||||
numInterfaces--;
|
||||
}
|
||||
index++;
|
||||
}
|
||||
}
|
||||
if (isPrint){
|
||||
printf ("---------------------------------------------------------------------------------\n\n");
|
||||
}
|
||||
printf("Cydevices %d",cyDevices);
|
||||
}
|
||||
|
||||
void deviceHotPlug () {
|
||||
|
||||
CY_RETURN_STATUS rStatus;
|
||||
deviceAddedRemoved = true;
|
||||
selectedDeviceNum = -1;
|
||||
selectedInterfaceNum = -1;
|
||||
printf ("Device of interest Removed/Added \n");
|
||||
rStatus = CyGetListofDevices ((UINT8 *)&numDevices);
|
||||
if (rStatus != CY_SUCCESS) {
|
||||
printf ("CY:Error in Getting List of Devices: Error NO:<%d> \n", rStatus);
|
||||
return;
|
||||
}
|
||||
printListOfDevices (false);
|
||||
}
|
||||
|
||||
int getUserInput()
|
||||
{
|
||||
char userInput[6], x;
|
||||
@@ -92,21 +191,6 @@ unsigned int GetCheckSum(unsigned int *buff, unsigned int length)
|
||||
}
|
||||
|
||||
|
||||
void deviceHotPlug () {
|
||||
|
||||
CY_RETURN_STATUS rStatus;
|
||||
deviceAddedRemoved = true;
|
||||
selectedDeviceNum = -1;
|
||||
selectedInterfaceNum = -1;
|
||||
printf ("Device of interest Removed/Added \n");
|
||||
rStatus = CyGetListofDevices (&numDevices);
|
||||
if (rStatus != CY_SUCCESS) {
|
||||
printf ("CY:Error in Getting List of Devices: Error NO:<%d> \n", rStatus);
|
||||
return rStatus;
|
||||
}
|
||||
printListOfDevices (false);
|
||||
}
|
||||
|
||||
int main (int argc, char **argv)
|
||||
{
|
||||
int index = 0, i, j, userInput;
|
||||
@@ -119,7 +203,7 @@ int main (int argc, char **argv)
|
||||
int silicon_id;
|
||||
int tempSelectedDeviceNum, tempSelectedInterfaceNum;
|
||||
CY_RETURN_STATUS rStatus;
|
||||
signal (SIGUSR1, deviceHotPlug);
|
||||
//signal (SIGUSR1, deviceHotPlug);
|
||||
char src_file[100];
|
||||
char id[4];
|
||||
|
||||
@@ -136,7 +220,7 @@ int main (int argc, char **argv)
|
||||
printf ("CY:Error in Doing library init Error NO:<%d> \n", rStatus);
|
||||
return rStatus;
|
||||
}
|
||||
rStatus = CyGetListofDevices (&numDevices);
|
||||
rStatus = CyGetListofDevices ((UINT8 *)&numDevices);
|
||||
if (rStatus != CY_SUCCESS) {
|
||||
printf ("CY:Error in Getting List of Devices: Error NO:<%d> \n", rStatus);
|
||||
return rStatus;
|
||||
@@ -247,7 +331,7 @@ int main (int argc, char **argv)
|
||||
|
||||
// silicon_id = *(unsigned int *)buff;
|
||||
|
||||
rStatus=CyGetSiliconID(handle,&silicon_id);
|
||||
rStatus=CyGetSiliconID(handle,(UINT32 *)&silicon_id);
|
||||
if (rStatus == CY_SUCCESS){
|
||||
// printf(" Correct silicon id");
|
||||
|
||||
@@ -265,7 +349,7 @@ int main (int argc, char **argv)
|
||||
|
||||
|
||||
|
||||
rStatus=CyReadDeviceConfig(handle,&read_buffer);
|
||||
rStatus=CyReadDeviceConfig(handle, (UCHAR *)&read_buffer);
|
||||
if (rStatus == CY_SUCCESS){
|
||||
// printf(" Got the data");
|
||||
|
||||
@@ -379,86 +463,3 @@ int op;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
void printListOfDevices (bool isPrint)
|
||||
{
|
||||
int index_i = 0, index_j = 0, i, j, countOfDevice = 0, devNum;
|
||||
int length, index = 0, numInterfaces, interfaceNum;
|
||||
bool set1 = false;
|
||||
|
||||
unsigned char deviceID[CY_MAX_DEVICES];
|
||||
unsigned char functionality[64];
|
||||
CY_DEVICE_INFO deviceInfo;
|
||||
CY_DEVICE_CLASS deviceClass[CY_MAX_INTERFACES];
|
||||
CY_DEVICE_TYPE deviceType[CY_MAX_INTERFACES];
|
||||
CY_RETURN_STATUS rStatus;
|
||||
|
||||
deviceAddedRemoved = false;
|
||||
CyGetListofDevices (&numDevices);
|
||||
//printf ("The number of devices is %d \n", numDevices);
|
||||
for (i = 0; i < numDevices; i++){
|
||||
for (j = 0; j< CY_MAX_INTERFACES; j++)
|
||||
glDevice[i].interfaceFunctionality[j] = -1;
|
||||
}
|
||||
if (isPrint){
|
||||
printf ("\n\n---------------------------------------------------------------------------------\n");
|
||||
printf ("Device Number | VID | PID | INTERFACE NUMBER | FUNCTIONALITY \n");
|
||||
printf ("---------------------------------------------------------------------------------\n");
|
||||
}
|
||||
cyDevices = 0;
|
||||
for (devNum = 0; devNum < numDevices; devNum++){
|
||||
rStatus = CyGetDeviceInfo (devNum, &deviceInfo);
|
||||
interfaceNum = 0;
|
||||
if (!rStatus)
|
||||
{
|
||||
//if (isCypressDevice (devNum)){
|
||||
// continue;
|
||||
//}
|
||||
strcpy (functionality, "NA");
|
||||
numInterfaces = deviceInfo.numInterfaces;
|
||||
glDevice[index].numInterface = numInterfaces;
|
||||
cyDevices++;
|
||||
|
||||
while (numInterfaces){
|
||||
if (deviceInfo.deviceClass[interfaceNum] == CY_CLASS_VENDOR)
|
||||
{
|
||||
glDevice[index].deviceNumber = devNum;
|
||||
switch (deviceInfo.deviceType[interfaceNum]){
|
||||
case CY_TYPE_I2C:
|
||||
glDevice[index].interfaceFunctionality[interfaceNum] = CY_TYPE_I2C;
|
||||
strcpy (functionality, "VENDOR_I2C");
|
||||
glDevice[index].isI2c = true;
|
||||
break;
|
||||
case CY_TYPE_SPI:
|
||||
glDevice[index].interfaceFunctionality[interfaceNum] = CY_TYPE_SPI;
|
||||
strcpy (functionality, "VENDOR_SPI");
|
||||
glDevice[index].isSpi = true;
|
||||
break;
|
||||
default:
|
||||
strcpy (functionality, "NA");
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if (deviceInfo.deviceClass[interfaceNum] == CY_CLASS_CDC){
|
||||
strcpy (functionality, "NA");
|
||||
}
|
||||
if (isPrint) {
|
||||
printf ("%d |%x |%x | %d | %s\n", \
|
||||
index, \
|
||||
deviceInfo.vidPid.vid, \
|
||||
deviceInfo.vidPid.pid, \
|
||||
interfaceNum, \
|
||||
functionality \
|
||||
);
|
||||
}
|
||||
interfaceNum++;
|
||||
numInterfaces--;
|
||||
}
|
||||
index++;
|
||||
}
|
||||
}
|
||||
if (isPrint){
|
||||
printf ("---------------------------------------------------------------------------------\n\n");
|
||||
}
|
||||
printf("Cydevices %d",cyDevices);
|
||||
}
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
a.out
|
||||
@@ -15,7 +15,7 @@ bool valueToWrite=false, writeFlag=false, readFlag=false, exitFlag=false, expert
|
||||
// those vars are to be used with locateDevice function
|
||||
const uint8_t maxDevs = 16; // 16 connected devices should be enough...
|
||||
const CY_VID_PID deviceVidPid{UINT16(0x04b4),
|
||||
UINT16(0x0002)}; // the id for the chip
|
||||
UINT16(0x0004)}; // the id for the chip
|
||||
uint8_t deviceNumList[maxDevs];
|
||||
uint8_t deviceCount;
|
||||
CY_DEVICE_INFO deviceInfoList[maxDevs];
|
||||
@@ -171,16 +171,15 @@ int evalErrors(const CY_RETURN_STATUS error) { // evaluates errors, duh?
|
||||
int locateDevice() // locate the device and verify it's the right one
|
||||
{
|
||||
// printf("Locating devices..."); //debug, not needed
|
||||
try {
|
||||
|
||||
CY_RETURN_STATUS retVal;
|
||||
retVal = CyGetDeviceInfoVidPid(
|
||||
deviceVidPid, deviceNumList,
|
||||
deviceInfoList, //--searches for the device with given VID/PID
|
||||
&deviceCount, maxDevs); //--and stores them into lists
|
||||
//--refer to lib docs for more info
|
||||
throw retVal; // throws the return value of the func
|
||||
} catch (CY_RETURN_STATUS errVal) {
|
||||
int r = evalErrors(errVal); // evaluate the errors
|
||||
retVal = CyGetDeviceInfoVidPid( //--searches for the device with given VID/PID
|
||||
deviceVidPid, deviceNumList, //--and stores them into lists
|
||||
deviceInfoList, //--refer to lib docs for more info
|
||||
&deviceCount, maxDevs);
|
||||
|
||||
|
||||
int r = evalErrors(retVal); // evaluate the errors
|
||||
if (r != 0) { // exit on error
|
||||
return r;
|
||||
}
|
||||
@@ -192,7 +191,6 @@ int locateDevice() // locate the device and verify it's the right one
|
||||
return 10;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
int attachDevices() { // loops through devices and attaches them to handles
|
||||
|
||||
Reference in New Issue
Block a user