Beware that this post is related to an SDK in maintenance mode
More Info: Consider nRF Connect SDK for new designs
This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

SDK15 NRFX error numbering

Maybe there's a secret I'm missing but this looks like a development / debug flag that got left in.

I'm porting an app from SDK11 to SDK15, when I call app_button_init() it calls nrf_drv_gpiote_init() which is mapped to nrfx_gpiote_init()

Everything works and nrfx_gpiote_init() returns NRFX_SUCCESS.

But NRFX_SUCCESS is not zero.

So nrf_drv_gpiote_init() returns NRFX_SUCCESS which is then checked by VERIFY_SUCCESS(err_code), and promptly blows up and lands in the app error handler.

Since this is happening in the SDK code it's a problem

From app_button.c

if (!nrf_drv_gpiote_is_init())
{
    err_code = nrf_drv_gpiote_init();
    VERIFY_SUCCESS(err_code);
}

from nrfx_errors.h

#define NRFX_ERROR_BASE_NUM         0x0BAD0000
#define NRFX_ERROR_DRIVERS_BASE_NUM (NRFX_ERROR_BASE_NUM + 0x10000)

/** @brief Enumerated type for error codes. */
typedef enum {
    NRFX_SUCCESS                    = (NRFX_ERROR_BASE_NUM + 0),  ///< Operation performed successfully.
    NRFX_ERROR_INTERNAL             = (NRFX_ERROR_BASE_NUM + 1),  ///< Internal error.
    ...

Keith Vasilakes

Intricon

  • More info

    SES is not the greatest as showing the right preprocessor representation, so nfrx_err_t appears to be undefined in the editor but it really is. the macro #if !NRFX_CHECK(NRFX_CUSTOM_ERROR_CODES) confuses SES so it's all greyed out

  • Hi,

    If you include nrfx_glue.h from SDK15.0.0 it will set all error codes to standard SDK error codes. The nrfx_errors.h file is intended as a default in case you are using nrfx without the rest of the SDK and want to have distinct error codes.

    #if !NRFX_CHECK(NRFX_CUSTOM_ERROR_CODES) should gray out everything below it when you are using nrfx_glue.h since we do not want to define an already defined value.

    Best regards,
    Rune Holmgren

  • There must be more to it than that

    nrfx_glue.h only contains:

    #define NRFX_CUSTOM_ERROR_CODES 0. Setting it to zero removes nrfx_err_t completely

    don't see nrfx_err_t  defined anywhere else

    So it looks like I need to define my own nrfx_err_t ?

    Thats very unfriendly

  • So sorry, I should have been clearer. I was refering to the nrfx_glue.h located at "nRF5_SDK_15.0.0_a53641a/integration/nrfx" in the nRF5 SDK. It is based on the template from nrfx, but with changes required to use it with the nRF5 SDK. This section here is what you are missing:

    #include <sdk_errors.h>
    /**
     * @brief When set to a non-zero value, this macro specifies that the
     *        @ref nrfx_error_codes and the @ref ret_code_t type itself are defined
     *        in a customized way and the default definitions from @c <nrfx_error.h>
     *        should not be used.
     */
    #define NRFX_CUSTOM_ERROR_CODES 1
    
    typedef ret_code_t nrfx_err_t;
    
    #define NRFX_SUCCESS                    NRF_SUCCESS
    #define NRFX_ERROR_INTERNAL             NRF_ERROR_INTERNAL
    #define NRFX_ERROR_NO_MEM               NRF_ERROR_NO_MEM
    #define NRFX_ERROR_NOT_SUPPORTED        NRF_ERROR_NOT_SUPPORTED
    #define NRFX_ERROR_INVALID_PARAM        NRF_ERROR_INVALID_PARAM
    #define NRFX_ERROR_INVALID_STATE        NRF_ERROR_INVALID_STATE
    #define NRFX_ERROR_INVALID_LENGTH       NRF_ERROR_INVALID_LENGTH
    #define NRFX_ERROR_TIMEOUT              NRF_ERROR_TIMEOUT
    #define NRFX_ERROR_FORBIDDEN            NRF_ERROR_FORBIDDEN
    #define NRFX_ERROR_NULL                 NRF_ERROR_NULL
    #define NRFX_ERROR_INVALID_ADDR         NRF_ERROR_INVALID_ADDR
    #define NRFX_ERROR_BUSY                 NRF_ERROR_BUSY
    #define NRFX_ERROR_ALREADY_INITIALIZED  NRF_ERROR_MODULE_ALREADY_INITIALIZED
    
    #define NRFX_ERROR_DRV_TWI_ERR_OVERRUN  NRF_ERROR_DRV_TWI_ERR_OVERRUN
    #define NRFX_ERROR_DRV_TWI_ERR_ANACK    NRF_ERROR_DRV_TWI_ERR_ANACK
    #define NRFX_ERROR_DRV_TWI_ERR_DNACK    NRF_ERROR_DRV_TWI_ERR_DNACK

    For convenience, here is the file: nrfx_glue.h

    Best regards,
    Rune Holmgren

Related