|
Hi
In the USB Control Centre highlight the control endpoint, click on the data transfer tab and then enter values in the following fields to suit your application
Direction Out/IN you decide
Req Type Vendor
Target Device
Req Code Your Vendor code
wValue you decide
wIndex you decide
USB setup data is an 8 byte array sent by the host pc and these are stored in setupdat0 and setupdat1 which the firmware then parses to decode the control information contained in the setup data. In the eeprom example (cyfxusbi2cregmode.c) this is done in the following code
/* Parse the control request parameters. */
attr = (uint8_t) (setupdat0 & 0x000000FF);
rqt = (uint8_t)((setupdat0 & 0x0000FF00) >> 8);
value = (uint16_t) (setupdat0 >> 16);
index = (uint16_t) (setupdat1 & 0x0000FFFF);
length = (uint16_t) (setupdat1 >> 16);
attr is the request type and will be set by Control Centre when you select Vendor.
rqt is the users vendor code and in this example for an eeprom read the code shows
case CY_FX_RQT_I2C_EEPROM_READ:
i2cAddr = 0xA0 | ((value & 0x0007) << 1);
CyU3PMemSet (glEp0Buffer, 0, sizeof (glEp0Buffer));
status = CyFxUsbI2cTransfer (index, i2cAddr, length,
glEp0Buffer, CyTrue);
if (status == CY_U3P_SUCCESS)
{
status = CyU3PUsbSendEP0Data(length, glEp0Buffer);
}
break;
If you look in cyfxusbi2cregmode.h you will see that this is defined as 0xBB
Likewise the value field in this example is the eeproms address while index give the internal eeprom offset address.
To read the eeprom then the following data is put into Control Centre
Direction IN
Req Type Vendor
Target Device
Req Code 0xBB
wValue try 0x0000 but depends on how the eeprom address pins are set
wIndex 0x0000
In the Bytes to Transfer Box type in the number of bytes you want to read.
Hope this helps.
Sodafarl
|