Introduction

This time, I will create an application that uses the GPIO of the QCA4020 as an external interrupt to turn on an LED. Ultimately, the code you create this time will be incorporated into the Wi-Fi connection app and used to trigger the Wi-Fi connection. From the QCA4020 Device Specification, use GPIO27 for interrupts.

App creation

Like the LED application, we will create it based on Helloworld. It waits for a signal in a Thread loop and starts working with an interrupt-triggered signal. First, create a Thread (Sample_thread).
In Thread,

- Signal initialization
- GPIO settings
- register interrupts
- Turn on LED after receiving Signal

process.

Signal initialization

This time, we will use Signal as a means of releasing the interrupt context after an interrupt occurs. Initialize Signal (qurt_signal_t) for that purpose.

qurt_signal_init(&gpio_int_signal);

GPIO settings

For the LED, use GPIO12 as OUTPUT as before. For Switch use GPIO27 as INPUT. For GPIO settings, set each parameter of qapi_TLMM_Config_t and set with qapi_TLMM_Config_Gpio.

// Configure GPIO12(LED) gpio_cfg_12.func = 0; gpio_cfg_12.dir = QAPI_GPIO_OUTPUT_E; gpio_cfg_12.pull = QAPI_GPIO_PULL_DOWN_E; gpio_cfg_12.drive = QAPI_GPIO_4P0MA_E; gpio_cfg_12.pin = 12; // Drive GPIO with high value qapi_TLMM_Get_Gpio_ID(&gpio_cfg_12, &gpio_id_12); qapi_TLMM_Config_Gpio(gpio_id_12, &gpio_cfg_12); // Configure GPIO27(Switch) gpio_cfg_27.func = 0; gpio_cfg_27.dir = QAPI_GPIO_INPUT_E; gpio_cfg_27.pull = QAPI_GPIO_PULL_UP_E; gpio_cfg_27.drive = QAPI_GPIO_2MA_E; gpio_cfg_27.pin = 27; qapi_TLMM_Get_Gpio_ID(&gpio_cfg_27, &gpio_id_27); qapi_TLMM_Config_Gpio(gpio_id_27, &gpio_cfg_27);

Interrupt registration

Register a handler with Falling edge trigger for GPIO27.

qapi_GPIOINT_Register_Interrupt(&int_handle, 27, pfnCallback, 0, QAPI_GPIOINT_TRIGGER_EDGE_FALLING_E, QAPI_GPIOINT_PRIO_MEDIUM_E, false); ============================ static void pfnCallback(qapi_GPIOINT_Callback_Data_t data) { qurt_signal_set(&gpio_int_signal, 1); }

Turn on LED after receiving Signal

Wait for Signal to receive notification from the interrupt handler. Set a signal from the interrupt handler when an interrupt occurs, and turn on the LED after receiving the signal in Thread.

while(true) { qurt_signal_wait(&gpio_int_signal, 1, QURT_SIGNAL_ATTR_CLEAR_MASK); qapi_TLMM_Drive_Gpio(gpio_id_12, gpio_cfg_12.pin, QAPI_GPIO_HIGH_VALUE_E); }

Summary

This time, I used a reference board to create an application that turns on an LED when triggered by an interrupt from a switch. Next time, we will create an application that connects to Wi-Fi using WPS using what we have created so far.

If you are interested in QCA4020, please contact us below.

Inquiry

For product inquiries, please use the link below.

To Qualcomm manufacturer information Top

If you want to return to the Qualcomm manufacturer information top page, please click below.