Use multiple wkupct_enable_irq with different callbacks?

⚠️
Hi there.. thanks for coming to the forums. Exciting news! we’re now in the process of moving to our new forum platform that will offer better functionality and is contained within the main Dialog website. All posts and accounts have been migrated. We’re now accepting traffic on the new forum only - please POST any new threads at//www.wsdof.com/support. We’ll be fixing bugs / optimising the searching and tagging over the coming days.
6 posts / 0 new
Last post
gme_johannes
Offline
Last seen:2 days 44 min ago
Joined:2017-12-22 10:09
Use multiple wkupct_enable_irq with different callbacks?

Hi,

we are using the "old" IoT sensor with SDK5, ported to Murata ZY (DA14580).

The SDK uses the BMI160 for interrupts during operation (FIFO watermark for sensor readout) and during sleep (motion wakeup), e.g.

#ifndef BLE_APP_SENSOR_FUSION void config_da1458x_pin_intr_1_enable(void) { wrbl_env.wrbl_intr_1_cb = wkup_intr_1_cb; wkupct_register_callback(wrbl_env.wrbl_intr_1_cb); #ifdef USE_MAG_DRDY_INTR wkupct_enable_irq(0x0040, 0x0040, 1, 0); //active high #else wkupct_enable_irq(WKUPCT_PIN_SELECT(INT1_PORT, INT1_PIN), WKUPCT_PIN_SELECT(INT1_PORT, INT1_PIN), 1, 0); //active low #endif }

We want to use another GPIO as interrupt to execute a specific command, it should work during operation but also during sleep modes (hence we can not use the GPIO_EnabeIRQ).

My understanding is:

1) Multiple GPIOs can be configured as wakeup source.
2) For wkupct_enable_irq it is not possible to register different callback functions for different interrupt sources.
3) If wkupct_register_callback() is called multiple times throughout the code, the last registered callback will be used.
Correct?

Question:
4) Is there a register that I can read after waking up, telling me which pin was the interrupt source? Fromhttps://support.dialog-semiconductor.com/forums/post/dialog-smartbond-bl...I understand this is not possible?
5) But what about using NVIC_GetPendingIRQ? Aren't different interrupts assigned different IRQn?
--> I found out that they all use the same IRQn:

// datasheet.h WKUP_QUADEC_IRQn = 9, /* Combines the Wake up Capture Timer interrupt, the GPIO interrupt and the QuadDecoder interrupt */

BR Johannes

Device:
PM_Dialog
Offline
Last seen:9 hours 17 min ago
Staff
Joined:2018-02-08 11:03
Hi gme_johannes,

Hi gme_johannes,

Regarding your first, question, yes you can configure multiple GPIO as a wake-up source. Please check the code snippet below:

wkupct_enable_irq(WKUPCT_PIN_SELECT(GPIO_BUTTON_PORT, GPIO_BUTTON_PIN) | WKUPCT_PIN_SELECT(GPIO_BUTTON_2_PORT, GPIO_BUTTON_2_PIN), WKUPCT_PIN_POLARITY(GPIO_BUTTON_PORT, GPIO_BUTTON_PIN, WKUPCT_PIN_POLARITY_LOW) | WKUPCT_PIN_POLARITY(GPIO_BUTTON_2_PORT, GPIO_BUTTON_2_PIN, WKUPCT_PIN_POLARITY_LOW), 1, 40);

Regarding your second question, could you please clarify it? You are correct, in wkupct_register_callback() you are able to register only one callback function. So, if I am able to understand correctly, that you would like to accomplish is to trigger different callback functions from different wake-up interrupts? For example, if you get the interrupt from GPIO_1, the callback_1 should executed and if you get the interrupt from GPIO_2, the callback_2 should executed.

Thanks, PM_Dialog

gme_johannes
Offline
Last seen:2 days 44 min ago
Joined:2017-12-22 10:09
Yes, that is correct.

Yes, that is correct.

Fromhttps://support.dialog-semiconductor.com/forums/post/dialog-smartbond-bl...I understand I can check the GPIO state after the interrupt was triggered.

Will this be fast enough in any case? Will the GPIO state always be retained long enought, if the first thing I do in the callback function is to check its state?

PM_Dialog
Offline
Last seen:9 hours 17 min ago
Staff
Joined:2018-02-08 11:03
Hi gme_johannes,

Hi gme_johannes,

In the past forum thread that you have referred, MT_Dialog correctly had mentioned that there is no register that will indicate the port/pin that the interrupt occurred, So you will have to read the status of the pin right after the device has been awaken and according to the pin status you will have to decide which callback function will be triggered.

Thanks, PM_Dialog

gme_johannes
Offline
Last seen:2 days 44 min ago
Joined:2017-12-22 10:09
Thank you, I will attempt to

Thank you, I will attempt to solve my problem this way.

PM_Dialog
Offline
Last seen:9 hours 17 min ago
Staff
Joined:2018-02-08 11:03
Hi gme_johannes,

Hi gme_johannes,

Thanks for accepting my answer. Please let me know if you have any other issues.

Thanks, PM_Dialog