Proprietary Knowledge Base

    Publish
     
      • 如何连接射频GPIO 0 和 1到EZR32LG 或 EZR32WG的引脚?

        Siliconlabs | 11/316/2015 | 04:47 AM

        Question

        如何连接射频GPIO 0 和 1到EZR32LG 或 EZR32WG的引脚?

         

        Answer

        射频的GPIO 0 和 1引脚并不直接连接到EZR32LG 和 EZR32WG的引脚,如果要使用它们,你需要设置PRS频道。

        如下的代码设置了两个异步通道

        RF_GPIO0 -> PortA0

        RF_GPIO1 -> PortA1

        异步在这里意味着其同时在EM2和EM3下运行。

        /* Enable PRS clock */
        CMU_ClockEnable(cmuClock_PRS, true);
        
        /* Configure RF_GPIO0 and RF_GPIO1 to inputs. */
        GPIO_PinModeSet(RF_GPIO0_PORT, RF_GPIO0_PIN, gpioModeInput, 0);
        GPIO_PinModeSet(RF_GPIO1_PORT, RF_GPIO1_PIN, gpioModeInput, 0);
        
        /* Pin PA0 and PA1 output the GPIO0 and GPIO1 via PRS to PTI */
        GPIO_PinModeSet(gpioPortA, 0, gpioModePushPull, 0);
        GPIO_PinModeSet(gpioPortA, 1, gpioModePushPull, 0);
        
        /* Disable INT for PRS channels */
        GPIO_IntConfig(RF_GPIO0_PORT, RF_GPIO0_PIN, false, false, false);
        GPIO_IntConfig(RF_GPIO1_PORT, RF_GPIO1_PIN, false, false, false);
        
        /* Setup PRS for RF GPIO pins  */
        PRS_SourceAsyncSignalSet(0, PRS_CH_CTRL_SOURCESEL_GPIOH, PRS_CH_CTRL_SIGSEL_GPIOPIN15);
        PRS_SourceAsyncSignalSet(1, PRS_CH_CTRL_SOURCESEL_GPIOH, PRS_CH_CTRL_SIGSEL_GPIOPIN14);
        PRS->ROUTE = (PRS_ROUTE_CH0PEN | PRS_ROUTE_CH1PEN);
        
        /* Make sure PRS sensing is enabled (should be by default) */
        GPIO_InputSenseSet(GPIO_INSENSE_PRS, GPIO_INSENSE_PRS);