This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

app_gpiote.c doesn't include NRF_GPIOTE->EVENTS_IN's

I am using NRF_GPIOTE->EVENTS_IN[0] and NRF_GPIOTE->EVENTS_IN[1] in my software. I had my own GPIOTE_IRQHandler working. Today I am adding UART module into my source code, compiler tells me that app_gpiote.c has a GPIOTE_IRQHandler too.

I checked app_gpiote.c, it only deals with NRF_GPIOTE->EVENTS_PORT.

What is the best way to organize that: my own GPIOTE_IRQHandler for handling NRF_GPIOTE->EVENTS_IN's, and SDK's GPIOTE_IRQHandler for NRF_GPIOTE->EVENTS_PORT?

Thanks

  • Not trivially. There's one handler for each IRQ, that's it, it's in the interrupt vector table.

    So if you want to send some types of interrupt one way and some types another way then you need to

    1. rename the SDK's GPIOTE handler to something different, say SDK_GPIOTE_IRQHandler and make it public so you can call it
    2. rename your GPIOTE handler to something different and make that public as well
    3. Write one new GPIOTE_IRQHandler which checks the events which are set and calls one or the other or both of the handlers

    You could just do 1) above and write the code to send events into your current handler, same effect, but breaking it out makes it clearer and more maintainable.

    However one question is .. why does adding a UART module need the app_gpiote.c to be added at all? I didn't think they were related and see nothing in the Nordic uart code which uses it.

    One other option is not to use the GPIOTE directly in your code but rewrite your use of NRG_GPIOTE->EVENTS_IN[] to use the gpiote module if you have to include that anyway for other reasons.

  • Yes, this is what I have done. rename and rewrite some code. I was looking for a "proper" way to avoid breaking away from SDK's updates. The reason for the gpiote used for UART is for CTS RTS signal.

  • I would say that 'proper way', if you're using the gpiote module for one thing, is to use it for your other code too, I see an app_gpiote_input_event_handler_register() function which may do what you want.

    I see now the uart module uses the gpiote for low power mode. That's frustrating.

Related