7 Replies Latest reply on Sep 13, 2017 6:10 PM by milkfish1227_2635671

    FX3 Spi reference code

    milkfish1227_2635671

      I am recently starting working on FX3 SPI code. This is a function in all of SPI code (UsbSpiDmaMode, UsbSpiGpioMode and UsbSpiRegMode). Basically this CyFxUSBSetupCB() function is a call back routine to process control end point 0 data and process. Following code is switching the vendor command.

       

      In the READ command, the code zero out the glEp0Buffer then pass to CySpiTransfer for SPI transfer. Instead of zero out the buffer, the code should get data from EP0 then pass for passing.

       

      I am just wondering how Cypress QA the code before publish.

       

      CyBool_t

      CyFxUSBSetupCB (

              uint32_t setupdat0,

              uint32_t setupdat1)

      {

      ...

                  case CY_FX_RQT_SPI_FLASH_WRITE:

                      status = CyU3PUsbGetEP0Data (wLength, glEp0Buffer, NULL);

                      if (status == CY_U3P_SUCCESS)

                      {

                          status = CyFxSpiTransfer (wIndex, wLength,  glEp0Buffer, CyFalse);

                      }

                      break;

       

                  case CY_FX_RQT_SPI_FLASH_READ:

                      CyU3PMemSet (glEp0Buffer, 0, sizeof (glEp0Buffer));

                     status = CyU3PUsbGetEP0Data (wLength, glEp0Buffer, NULL);

                      status = CyFxSpiTransfer (wIndex, wLength,  glEp0Buffer, CyTrue);

                      if (status == CY_U3P_SUCCESS)

                      {

                          status = CyU3PUsbSendEP0Data (wLength, glEp0Buffer);

                      }

                      break;

       

      Thanks,

      Dick