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

SDK 15.2.0: app_usbd_hid_generic_idle_report_set does not compile: 'ret' undeclared

ret is declared inside a "CRITICAL_REGION" which is a block, so not accessible outside that block to return:

ret_code_t app_usbd_hid_generic_idle_report_set(app_usbd_hid_generic_t const * p_generic, const void * p_buff, size_t size) { app_usbd_class_inst_t const * p_inst = (app_usbd_class_inst_t const *)p_generic; app_usbd_hid_generic_ctx_t * p_generic_ctx = hid_generic_ctx_get(p_generic); nrf_drv_usbd_ep_t ep_addr = app_usbd_hid_epin_addr_get(p_inst); app_usbd_hid_state_flag_clr(&p_generic_ctx->hid_ctx, APP_USBD_HID_STATE_FLAG_TRANS_IN_PROGRESS); NRF_DRV_USBD_TRANSFER_IN(transfer, p_buff, size); CRITICAL_REGION_ENTER(); ret_code_t ret = app_usbd_ep_transfer(ep_addr, &transfer); if (ret == NRF_SUCCESS) { app_usbd_hid_state_flag_set(&p_generic_ctx->hid_ctx, APP_USBD_HID_STATE_FLAG_TRANS_IN_PROGRESS); } CRITICAL_REGION_EXIT(); return ret; }

'ret' undeclared (first use in this function); did you mean 'getc'?
Parents Reply
  • I am not sure I understand the original problem reported here, but I had a compiler error from the same code (__CR_NESTED not defined). My fix was to merge the definitions for CRITICAL_REGION_ENTER() and CRITICAL_REGION_EXIT() as follows:

    #ifdef SOFTDEVICE_PRESENT
    uint8_t __CR_NESTED = 0;
    #define CRITICAL_REGION_ENTER() app_util_critical_region_enter(&__CR_NESTED);
    #define CRITICAL_REGION_EXIT() app_util_critical_region_exit(__CR_NESTED);
    #else
    #define CRITICAL_REGION_ENTER() app_util_critical_region_enter(NULL)
    #define CRITICAL_REGION_EXIT() app_util_critical_region_exit(0)
    #endif

Children
Related