/** * Configures the EZRadio GPIO port and pins * * @param[in] ezradioIrqCallback EZRadio interrupt callback configuration * @param[in] enablePTI If true enables the radio PTI bridge in the controller. */ void ezradio_hal_GpioInit( GPIOINT_IrqCallbackPtr_t ezradioIrqCallback, bool enablePTI ) { #if defined(_EZR32_HAPPY_FAMILY) (void)enablePTI; #endif #if !defined(EZRADIODRV_SPI_4WIRE_MODE) GPIO_PinModeSet( (GPIO_Port_TypeDef) RF_USARTRF_CS_PORT, RF_USARTRF_CS_PIN, gpioModePushPull, 1 ); #endif /* Setup enable and interrupt pins to radio */ GPIO_PinModeSet( (GPIO_Port_TypeDef) RF_SDN_PORT, RF_SDN_PIN, gpioModePushPull, 0 ); GPIO_PinModeSet( (GPIO_Port_TypeDef) RF_INT_PORT, RF_INT_PIN, gpioModeInputPull, 1 ); /* EZR32HG family uses hard wired PTI interface from the radio to the board controller */ #if ( !defined(_EZR32_HAPPY_FAMILY) && !defined(EZRADIODRV_DISABLE_PTI) ) if (enablePTI) { /* Setup PRS for PTI pins */ CMU_ClockEnable(cmuClock_PRS, true); /* Configure RF_GPIO0 and RF_GPIO1 to inputs. */ GPIO_PinModeSet((GPIO_Port_TypeDef)RF_GPIO0_PORT, RF_GPIO0_PIN, gpioModeInput, 0); GPIO_PinModeSet((GPIO_Port_TypeDef)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((GPIO_Port_TypeDef)RF_GPIO0_PORT, RF_GPIO0_PIN, false, false, false); GPIO_IntConfig((GPIO_Port_TypeDef)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); } #endif //#if !defined(_EZR32_HAPPY_FAMILY) #if defined(EZRADIODRV_DISABLE_PTI) && defined(EZRADIODRV_COMM_USE_GPIO1_FOR_CTS) //Enable GPIO1 for CTS input GPIO_PinModeSet((GPIO_Port_TypeDef)RF_GPIO1_PORT, RF_GPIO1_PIN, gpioModeInput, 0); #endif if (NULL != ezradioIrqCallback) { /* Register callback and enable interrupt */ GPIOINT_CallbackRegister( RF_INT_PIN, ezradioIrqCallback ); GPIO_IntConfig( (GPIO_Port_TypeDef) RF_INT_PORT, RF_INT_PIN, false, true, true ); } }
/** @brief Configure and enable/disable the device interrupt IRQ */ static void halExtDeviceIntCfgIrq(void) { /* Configure nIRQ signal to trigger Port Pin ISR */ GPIO_PinModeSet((GPIO_Port_TypeDef) RF_INT_PORT, RF_INT_PIN, gpioModeInput, 1u); GPIO_InputSenseSet(GPIO_INSENSE_INT, GPIO_INSENSE_INT); GPIOINT_CallbackRegister(RF_INT_PIN, halIrqxIsr); GPIO_IntConfig((GPIO_Port_TypeDef) RF_INT_PORT, RF_INT_PIN, false, true, true); if (halExtDeviceIntCB == NULL) { halExtDeviceIntLevel = EXT_DEVICE_INT_UNCONFIGURED; } else { halExtDeviceIntLevel = EXT_DEVICE_INT_LEVEL_OFF; // Callers need to use halExtDeviceIntEnable() to enable top level } }
/** @brief Initialize External Device GPIOs * @param deviceIntCB The callback routine for device general interrupt * (NULL to disable) * @param deviceRdyCB The callback routine for device ready interrupt * (NULL to disable) * @return bitmask of configured features for this device * @note First initialization after bootup leaves the device powered down * and unselected. Subsequent inits don't touch the device powered * or selected states and can be used to reconfigure callback(s), * which always clears any stale/pending events. For deviceRdyCB, * its interrupt is enabled upon configuration; for deviceIntCB, * halExtDeviceIntEnable() must subsequently be called to enable it. */ HalExtDeviceConfig halExtDeviceInit(HalExtDeviceIrqCB deviceIntCB, HalExtDeviceIrqCB deviceRdyCB) { UNUSED_VAR(halExtDeviceRdyCB); // Work around potential compiler warnings UNUSED_VAR(halExtDeviceIntCB); // Work around potential compiler warnings halExtDeviceRdyCB = deviceRdyCB; halExtDeviceIntCB = deviceIntCB; CMU_ClockEnable(cmuClock_PRS, true); /* Pin is configured to Push-pull: SDN */ GPIO_PinModeSet((GPIO_Port_TypeDef) RF_SDN_PORT, RF_SDN_PIN, gpioModePushPull, 1u); /* Pin is configured to Push-pull: nSEL */ GPIO_PinModeSet((GPIO_Port_TypeDef) RF_USARTRF_CS_PORT, RF_USARTRF_CS_PIN, gpioModePushPull, 1u); /* Pin PE13 is configured input: nIRQ */ //GPIO_PinModeSet(RF_INT_PORT, RF_INT_PIN, gpioModeInput, 0u); /* Pin PA15 and PE14 are connected to GPIO0 and GPIO1 respectively. */ GPIO_PinModeSet((GPIO_Port_TypeDef) RF_GPIO0_PORT, RF_GPIO0_PIN, gpioModeInput, 0); GPIO_PinModeSet((GPIO_Port_TypeDef) RF_GPIO1_PORT, RF_GPIO1_PIN, gpioModeInput, 0); /* Pin PA0 and PA1 are output the GPIO0 and GPIO1 via PRS */ GPIO_PinModeSet(gpioPortA, 0, gpioModePushPull, 0); GPIO_PinModeSet(gpioPortA, 1, gpioModePushPull, 0); /* Configure INT/PRS channels */ GPIO_IntConfig((GPIO_Port_TypeDef) RF_GPIO0_PORT, RF_GPIO0_PIN, false, false, false); GPIO_IntConfig((GPIO_Port_TypeDef) RF_GPIO1_PORT, RF_GPIO1_PIN, false, false, false); /* Setup PRS */ 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); /* TODO: Check whether the removed part is required for the EZR32 implementation */ halExtDeviceRdyCfgIrq(); halExtDeviceIntCfgIrq(); return 0; }