2 Replies Latest reply on Sep 18, 2018 4:31 AM by annr_3532396

    FX3 CARKIT

    caydin_1559836

      Hi,

       

      I am trying to use CARKIT interface of FX3s. There are some example

      codes  in "001-76074_EZ-USB_FX3_Technical_Reference_Manual.pdf"

      as given below.

       

      /* Enable the USB PHY connections. */

      GCTLAON->control &= ~CY_U3P_GCTL_ANALOG_SWITCH;

      /* Enable and set the EPM clock to bus clock (100MHz). */

      GCTL->uib_core_clk = (CY_U3P_GCTL_UIBCLK_CLK_EN | CY_U3P_GCTL_UIB_CORE_CLK_DEFAULT);

      GCTLAON->control |= CY_U3P_GCTL_USB_POWER_EN;

      CyU3PBusyWait (100);

      CyU3PUsbPowerOn ();

      UIB->otg_ctrl = CY_U3P_UIB_OTG_CTRL_DEFAULT;

      GCTL->iomatrix |= CY_U3P_CARKIT;

      UIB->chgdet_ctrl = CY_U3P_UIB_CARKIT;

       

      But where those definitions such as "CY_U3P_GCTL_ANALOG_SWITCH" are given?

      I searched in Linux files but could not find anything.

      Can you please share the whole project? I will also appreciate an example code to set

      FX3S in CARKIT mode using CTL11 and CTL12 pins.

       

      Thank you.

      Cengiz

        • 1. Re: FX3 CARKIT
          srdr

          The definition is provided in the Source Code.

          You can find this in gctlaon_regs.h file of  Folder: C:\Program Files (x86)\Cypress\EZ-USB FX3 SDK\1.3\firmware\fx3_sdk_1_3_4_src\fx3_sdk_1_3_4_src\sdk\firmware\include

           

          I can see this in Windows Platform. It is supposed to be there in Linux platform too. Please check.

           

          Unfortunately, we do not have any example firmware for Carkit functionality.

          • 2. Re: FX3 CARKIT
            annr_3532396

            Hi Caydin,

             

            You can use the following code snippet in your project for configuring Carkit mode using CTL11 and CTL12 pins. Please go through the provided comments also.

             

            /*Registers to be configured for Carkit functionality*/
            uint32_t *CHGDET_CTRL    = (uint32_t *)0xE0031800;
            uint32_t *GCTL_CONTROL   = (uint32_t *)0xE0050000;
            uint32_t *GCTL_IOMATRIX  = (uint32_t *)0xE0051008;
            
            
            #define CHGDET_CTRL_CARKIT_ENABLE_REG_SHIFT (14)
            #define GCTL_IOMATRIX_CARKIT_SHIFT (1)
            
            
            /*Choose between LPP_UART and PIB_CTL for Carkit based on your requirement*/ 
            #define CARKIT_USE_PIB_CTL (0)
            #define CARKIT_USE_LPP_UART (1)
            
            
            void CYU3PConfigureCarkit (CyBool_t mode)
            {
                 *GCTL_CONTROL |= CY_U3P_GCTL_USB_POWER_EN;
                 *CHGDET_CTRL  |= (1 << CHGDET_CTRL_CARKIT_ENABLE_REG_SHIFT); /*Enable Carkit adaptor enable*/
                 if(mode)
                 {
                     CyU3PDebugPrint (1, "\nGPIO[49] and GPIO[48] selected for Carkit\r\n");
                     *GCTL_IOMATRIX &= ~(1 << GCTL_IOMATRIX_CARKIT_SHIFT); /*Use GPIO[49] and GPIO[48] for Carkit Function*/
                 }
                 else
                 {
                     CyU3PDebugPrint (1, "\nCTL[11] and CTL[12] selected for Carkit\r\n");
                     *GCTL_IOMATRIX |= (1 << GCTL_IOMATRIX_CARKIT_SHIFT); /*Use CTL[11] and CTL[12] for Carkit Function*/
                 }
                CyU3PDebugPrint (1, "\n\nCarkit initialized\r\n");
            }
            
            
            /* AppInit shown below can be CyFxBulkSrcSinkApplnInit etc based on the application */
            void AppInit(void) 
            {
            .
            .
            .
            .
            .
            .
            .
            .
            .
                /* Start the USB functionality. */
                apiRetStatus = CyU3PUsbStart();
                if (apiRetStatus == CY_U3P_ERROR_NO_REENUM_REQUIRED)
                {
                    no_renum = CyTrue;
                }
                else if (apiRetStatus != CY_U3P_SUCCESS)
                {
                    CyU3PDebugPrint (4, "CyU3PUsbStart failed to Start, Error code = %d\n", apiRetStatus);
                    CyFxAppErrorHandler(apiRetStatus);
                }
            
                /* CODE TO BE ADDED*/
                /* NOTE: CarKit configuration should be done after CyU3PUsbStart() function call */
                 CYU3PConfigureCarkit(CARKIT_USE_PIB_CTL);
            .
            .
            .
            .
            .
            .
            .
            .
            .
            .
            .
            .
            .
             }
            
            

             

            As explained in the snippet above, do the Carkit configuration after call to the CyU3PUsbStart() API.

            If you are still facing some issue, as a debug step, read back the registers that you are configuring to check if they are getting configured properly.

             

            Hope this helps.

            annr