13 Replies Latest reply on Sep 23, 2017 10:22 AM by Madhu Lakshmipathy

    FX3 UsbspiGpioMode SpiSetConfig?

    milkfish1227_2635671

      Hi,

      I am using the UsbSpiGpioMode code to development a FW so the host app can talk to a SPI slave device connect to FX3 kit.

       

      My question is "why there is no CyU3PSpiSetConfig() function call to setup SPI config as UsbSpiDmaMode code does?"  If the SPI is not correctly config, how can it work?

       

      In my case, I need to setup cpol and cpha. Below is the code from UsbSpiDmaMode code.

       

      Please help.

       

      CyFxSpiInit (uint16_t pageLen)

      {

          CyU3PSpiConfig_t spiConfig;

          CyU3PDmaChannelConfig_t dmaConfig;

          CyU3PReturnStatus_t status = CY_U3P_SUCCESS;

       

       

          /* Start the SPI module and configure the master. */

          status = CyU3PSpiInit();

          if (status != CY_U3P_SUCCESS)

          {

              return status;

          }

       

       

          /* Start the SPI master block. Run the SPI clock at 8MHz

           * and configure the word length to 8 bits. Also configure

           * the slave select using FW. */

          CyU3PMemSet ((uint8_t *)&spiConfig, 0, sizeof(spiConfig));

          spiConfig.isLsbFirst = CyFalse;

          spiConfig.cpol       = CyTrue;

          spiConfig.ssnPol     = CyFalse;

          spiConfig.cpha       = CyTrue;

          spiConfig.leadTime   = CY_U3P_SPI_SSN_LAG_LEAD_HALF_CLK;

          spiConfig.lagTime    = CY_U3P_SPI_SSN_LAG_LEAD_HALF_CLK;

          spiConfig.ssnCtrl    = CY_U3P_SPI_SSN_CTRL_FW;

          spiConfig.clock      = 8000000;

          spiConfig.wordLen    = 8;

       

       

      Thanks,

      Dick