Hi Dialog,
Problem Statement
- Register a GPIO interrupt/ISR using GPIO_RegisterCallback( ) and detect if the short press and long press on the button when the system is up and running.
What I tried
- I'm using the SW_2 (P0_6) for this functionality since the SW_3 is currently been used for wkupct_register_callback( ) that initialises the BLE advertisement.
- I was able to register the GPIO interrupt callback by the following method
- I've configured the GPIO under the set_pad_functions( ) and reserved the GPIO in GPIO_reservations( ).
- Turn the LED on the DA14583_ProDK if the SW_2 is pressed, and when pressed again, turn off the LED.
空白register_button_isr(空白)
{
NVIC_DisableIRQ(GPIO1_IRQn);
// set isr callback for button pressed interrupt
GPIO_RegisterCallback(GPIO1_IRQn, push_button_callback);
// Push Button input
GPIO_EnableIRQ(GPIO_PORT_0, GPIO_PIN_6, GPIO1_IRQn, true, true, 0);
}
Observation
- When the system is in active mode, i.e. broadcasting BLE advertisement packets, the ISR is not generated by the SW_2 pin
- If I follow the same process by modifying the Blinky example, everything just works perfect
Attached below (ble_examples.zip) is the file containing the modified Blinky example and the new file that I added in the ble_all_in_one application
Looking towards a positive response.
Thanking you in advance
Regards
Dhruv Shah
Keywords:
Device:
嗨dhruv11593,
It is expectable that your project does not working when the system is in active mode, because the chip goes to sleep between advertising and connection intervals. The Blinky example of the SDK does not support any BLE functionality, so you are able to implement that with ISR. In case of ble_all_in_one project, you should use the wake up controller and implement the button pressing with the similar way as the SW3. You will find attached an example code regarding the button configuration and how you could do that.
Regards, PM_Dialog