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

Embedding GPIOTE module in TWI example

Hello,

another  question from me :)

First of all, I'm working with Eclipse, GCC compiler and SDK 15.2.0.

I want to add GPIOTE funtionality to the TWI example of Nordic. I'm not quit sure which module to use. I found one GPIOTE module under libraries/gpiote folder (app_gpiote.h) and one in modules/nrfx/drivers/include (nrfx_gpiote.h). Finally my decition was to use the one in the libraries folder (app_gpiote.h). So my first question: what is the correct module? Why are there two modules for the same function?

Second question: I included header file for GPIOTE module to main.c and in the makefile, activated GPIOTE definition in sdk_config.h (actually there are two of these in the sdk also, why is that?). In the main routine I used the APP_GPIOTE_INIT macro as mentioned in the offline documentation. Compiling of the project works fine, but the linker rejects an undefined reference. Is there something else I must do to add the software module?

Thanks in advance for your help!!

Kind regards

Sascha Schmidt

Parents
  • Hi Sascha,

    I understand it can be a bit confusing. The app_gpiote.h is from the GPIOTE handling library, which uses the GPIOTE driver.  But as you can see in the documentation page this library is obsolete and should not be used in new designs. The advice is to use the drivers directly.

    About the drivers now, we have just migrated from our old drivers (nrf_drv) to the new drivers (nrfx). We still have a legacy layer which serves as a wrapper for the new nrfx drivers, see GPIO driver - legacy layer. Please read more about the migration to the nrfx drivers here.

    As a warning you should know that the legacy layer will not be supported in future SDK releases. But in SDK v15.2.0 we still recommend using the legacy layer wrapper, see the documentation for the GPIO driver here, but you can easily use the nrfx driver directly without going through the legacy layer by taking a look at the forwardings to the new implementation here.

    The legacy layer driver is located in:

    integration\nrfx\legacy\nrf_drv_gpiote.h

    And the nrfx driver is located in:

    modules\nrfx\drivers\include\nrfx_gpiote.h



    Second question:

    Use the GPIOTE driver instead of the library. In sdk_config.h you need to enable both the nrf_dvr_gpiote driver and the nrfx_gpiote regardless of what you choose to use. Do not set the old GPIOTE_ENABLED entry to 0, see the note in the migration guide.

    I hope this provide some clarity. It is a bit confusing because of the migration. I think maybe the easiest way would be to use the legacy layer and follow the steps in the documentation. Try to build the GPIOTE example from the SDK and you can see how the legacy driver is wrapping the nrfx driver. The example is located in examples/peripherals/gpiote

    Best Regards,

    Marjeris

Reply
  • Hi Sascha,

    I understand it can be a bit confusing. The app_gpiote.h is from the GPIOTE handling library, which uses the GPIOTE driver.  But as you can see in the documentation page this library is obsolete and should not be used in new designs. The advice is to use the drivers directly.

    About the drivers now, we have just migrated from our old drivers (nrf_drv) to the new drivers (nrfx). We still have a legacy layer which serves as a wrapper for the new nrfx drivers, see GPIO driver - legacy layer. Please read more about the migration to the nrfx drivers here.

    As a warning you should know that the legacy layer will not be supported in future SDK releases. But in SDK v15.2.0 we still recommend using the legacy layer wrapper, see the documentation for the GPIO driver here, but you can easily use the nrfx driver directly without going through the legacy layer by taking a look at the forwardings to the new implementation here.

    The legacy layer driver is located in:

    integration\nrfx\legacy\nrf_drv_gpiote.h

    And the nrfx driver is located in:

    modules\nrfx\drivers\include\nrfx_gpiote.h



    Second question:

    Use the GPIOTE driver instead of the library. In sdk_config.h you need to enable both the nrf_dvr_gpiote driver and the nrfx_gpiote regardless of what you choose to use. Do not set the old GPIOTE_ENABLED entry to 0, see the note in the migration guide.

    I hope this provide some clarity. It is a bit confusing because of the migration. I think maybe the easiest way would be to use the legacy layer and follow the steps in the documentation. Try to build the GPIOTE example from the SDK and you can see how the legacy driver is wrapping the nrfx driver. The example is located in examples/peripherals/gpiote

    Best Regards,

    Marjeris

Children
Related