Cypress Perform

Home > Design Support > Cypress Developer CommunityTM > Cypress Forums > USB Controllers > UsbI2cRegMode Example Firmware Project

Bookmark and Share
Cypress Developer CommunityTM
Forums | Videos | Blogs | Training | Rewards Program | Community Components



UsbI2cRegMode Example Firmware Project
Moderator:
RSKV

Post Reply
Follow this topic



UsbI2cRegMode Example Firmware Project

aulucan posted on 22 Mar 2012 1:04 AM PST
Senior Member
19 Forum Posts

Hello,

I want to read/write I2C EEPROM on the FX3 board with UsbI2cRegMode example firmware project.
But I couldn't understand the process.

Project readme file says,
" The device enumerates as a vendor specific USB device with only the control endpoint and provides a set of vendor commands to read/write the data on I2C EEPROM devices.".

That's all. There is no additional information how it can be realized.

When I look over "CyFxUSBSetupCB" callback function and "CyFxUsbI2cTransfer" function,
 I can produce callback function's "setupdat0" and "setupdat1" parameters.

1. How can I generate vendor commands with "setupdat0" and "setupdat1"?
2. How can I send vendor commands within "USB Control Center"?
3. When I send a read command, how can I observe the data?
4. When I want to write to EEPROM, how can I send the EEPROM data?

I would appreciate, if someone help me.

Regards,
Ali




Re: UsbI2cRegMode Example Firmware Project

sodafarl posted on 23 Mar 2012 04:11 PM PST
Top Contributor
128 Forum Posts

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

 



Re: UsbI2cRegMode Example Firmware Project

aulucan posted on 26 Mar 2012 08:07 AM PST
Senior Member
19 Forum Posts

Hi Sodafarl,

Your answer was very clear and it worked. Thanks for your help.

Regards,
Ali






ALL CONTENT AND MATERIALS ON THIS SITE ARE PROVIDED "AS IS". CYPRESS SEMICONDUCTOR AND ITS RESPECTIVE SUPPLIERS MAKE NO REPRESENTATIONS ABOUT THE SUITABILITY OF THESE MATERIALS FOR ANY PURPOSE AND DISCLAIM ALL WARRANTIES AND CONDITIONS WITH REGARD TO THESE MATERIALS, INCLUDING BUT NOT LIMITED TO, ALL IMPLIED WARRANTIES AND CONDITIONS OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT OF ANY THIRD PARTY INTELLECTUAL PROPERTY RIGHT. NO LICENSE, EITHER EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, IS GRANTED BY CYPRESS SEMICONDUCTOR. USE OF THE INFORMATION ON THIS SITE MAY REQUIRE A LICENSE FROM A THIRD PARTY, OR A LICENSE FROM CYPRESS SEMICONDUCTOR.

Content on this site may contain or be subject to specific guidelines or limitations on use. All postings and use of the content on this site are subject to the Terms and Conditions of the site; third parties using this content agree to abide by any limitations or guidelines and to comply with the Terms and Conditions of this site. Cypress Semiconductor and its suppliers reserve the right to make corrections, deletions, modifications, enhancements, improvements and other changes to the content and materials, its products, programs and services at any time or to move or discontinue any content, products, programs, or services without notice.